|
|
@ -492,7 +492,7 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode,
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
res = checkOperatingModeLocked(operatingMode);
|
|
|
|
res = checkOperatingMode(operatingMode, mDevice->info(), mCameraIdStr);
|
|
|
|
if (!res.isOk()) {
|
|
|
|
if (!res.isOk()) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -550,8 +550,8 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode,
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status CameraDeviceClient::checkSurfaceTypeLocked(size_t numBufferProducers,
|
|
|
|
binder::Status CameraDeviceClient::checkSurfaceType(size_t numBufferProducers,
|
|
|
|
bool deferredConsumer, int surfaceType) const {
|
|
|
|
bool deferredConsumer, int surfaceType) {
|
|
|
|
if (numBufferProducers > MAX_SURFACES_PER_STREAM) {
|
|
|
|
if (numBufferProducers > MAX_SURFACES_PER_STREAM) {
|
|
|
|
ALOGE("%s: GraphicBufferProducer count %zu for stream exceeds limit of %d",
|
|
|
|
ALOGE("%s: GraphicBufferProducer count %zu for stream exceeds limit of %d",
|
|
|
|
__FUNCTION__, numBufferProducers, MAX_SURFACES_PER_STREAM);
|
|
|
|
__FUNCTION__, numBufferProducers, MAX_SURFACES_PER_STREAM);
|
|
|
@ -572,28 +572,27 @@ binder::Status CameraDeviceClient::checkSurfaceTypeLocked(size_t numBufferProduc
|
|
|
|
return binder::Status::ok();
|
|
|
|
return binder::Status::ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status CameraDeviceClient::checkPhysicalCameraIdLocked(String8 physicalCameraId) {
|
|
|
|
binder::Status CameraDeviceClient::checkPhysicalCameraId(
|
|
|
|
if (physicalCameraId.size() > 0) {
|
|
|
|
const std::vector<std::string> &physicalCameraIds, const String8 &physicalCameraId,
|
|
|
|
std::vector<std::string> physicalCameraIds;
|
|
|
|
const String8 &logicalCameraId) {
|
|
|
|
bool logicalCamera =
|
|
|
|
if (physicalCameraId.size() == 0) {
|
|
|
|
mProviderManager->isLogicalCamera(mCameraIdStr.string(), &physicalCameraIds);
|
|
|
|
return binder::Status::ok();
|
|
|
|
if (!logicalCamera ||
|
|
|
|
}
|
|
|
|
std::find(physicalCameraIds.begin(), physicalCameraIds.end(),
|
|
|
|
if (std::find(physicalCameraIds.begin(), physicalCameraIds.end(),
|
|
|
|
physicalCameraId.string()) == physicalCameraIds.end()) {
|
|
|
|
physicalCameraId.string()) == physicalCameraIds.end()) {
|
|
|
|
String8 msg = String8::format("Camera %s: Camera doesn't support physicalCameraId %s.",
|
|
|
|
String8 msg = String8::format("Camera %s: Camera doesn't support physicalCameraId %s.",
|
|
|
|
mCameraIdStr.string(), physicalCameraId.string());
|
|
|
|
logicalCameraId.string(), physicalCameraId.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return binder::Status::ok();
|
|
|
|
return binder::Status::ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status CameraDeviceClient::checkOperatingModeLocked(int operatingMode) const {
|
|
|
|
binder::Status CameraDeviceClient::checkOperatingMode(int operatingMode,
|
|
|
|
|
|
|
|
const CameraMetadata &staticInfo, const String8 &cameraId) {
|
|
|
|
if (operatingMode < 0) {
|
|
|
|
if (operatingMode < 0) {
|
|
|
|
String8 msg = String8::format(
|
|
|
|
String8 msg = String8::format(
|
|
|
|
"Camera %s: Invalid operating mode %d requested", mCameraIdStr.string(), operatingMode);
|
|
|
|
"Camera %s: Invalid operating mode %d requested", cameraId.string(), operatingMode);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
|
|
|
|
msg.string());
|
|
|
|
msg.string());
|
|
|
@ -601,8 +600,7 @@ binder::Status CameraDeviceClient::checkOperatingModeLocked(int operatingMode) c
|
|
|
|
|
|
|
|
|
|
|
|
bool isConstrainedHighSpeed = (operatingMode == ICameraDeviceUser::CONSTRAINED_HIGH_SPEED_MODE);
|
|
|
|
bool isConstrainedHighSpeed = (operatingMode == ICameraDeviceUser::CONSTRAINED_HIGH_SPEED_MODE);
|
|
|
|
if (isConstrainedHighSpeed) {
|
|
|
|
if (isConstrainedHighSpeed) {
|
|
|
|
CameraMetadata staticInfo = mDevice->info();
|
|
|
|
camera_metadata_ro_entry_t entry = staticInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
|
|
|
|
camera_metadata_entry_t entry = staticInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
|
|
|
|
|
|
|
|
bool isConstrainedHighSpeedSupported = false;
|
|
|
|
bool isConstrainedHighSpeedSupported = false;
|
|
|
|
for(size_t i = 0; i < entry.count; ++i) {
|
|
|
|
for(size_t i = 0; i < entry.count; ++i) {
|
|
|
|
uint8_t capability = entry.data.u8[i];
|
|
|
|
uint8_t capability = entry.data.u8[i];
|
|
|
@ -614,7 +612,7 @@ binder::Status CameraDeviceClient::checkOperatingModeLocked(int operatingMode) c
|
|
|
|
if (!isConstrainedHighSpeedSupported) {
|
|
|
|
if (!isConstrainedHighSpeedSupported) {
|
|
|
|
String8 msg = String8::format(
|
|
|
|
String8 msg = String8::format(
|
|
|
|
"Camera %s: Try to create a constrained high speed configuration on a device"
|
|
|
|
"Camera %s: Try to create a constrained high speed configuration on a device"
|
|
|
|
" that doesn't support it.", mCameraIdStr.string());
|
|
|
|
" that doesn't support it.", cameraId.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
|
|
|
|
msg.string());
|
|
|
|
msg.string());
|
|
|
@ -645,39 +643,31 @@ void CameraDeviceClient::mapStreamInfo(const OutputStreamInfo &streamInfo,
|
|
|
|
stream->bufferSize = 0;
|
|
|
|
stream->bufferSize = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
binder::Status
|
|
|
|
const SessionConfiguration& sessionConfiguration, bool *status /*out*/) {
|
|
|
|
CameraDeviceClient::convertToHALStreamCombination(const SessionConfiguration& sessionConfiguration,
|
|
|
|
ATRACE_CALL();
|
|
|
|
const String8 &logicalCameraId, const CameraMetadata &deviceInfo,
|
|
|
|
|
|
|
|
metadataGetter getMetadata, const std::vector<std::string> &physicalCameraIds,
|
|
|
|
binder::Status res;
|
|
|
|
hardware::camera::device::V3_4::StreamConfiguration &streamConfiguration,
|
|
|
|
if (!(res = checkPidStatus(__FUNCTION__)).isOk()) return res;
|
|
|
|
bool *unsupported) {
|
|
|
|
|
|
|
|
|
|
|
|
Mutex::Autolock icl(mBinderSerializationLock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mDevice.get()) {
|
|
|
|
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto operatingMode = sessionConfiguration.getOperatingMode();
|
|
|
|
auto operatingMode = sessionConfiguration.getOperatingMode();
|
|
|
|
res = checkOperatingModeLocked(operatingMode);
|
|
|
|
binder::Status res = checkOperatingMode(operatingMode, deviceInfo, logicalCameraId);
|
|
|
|
if (!res.isOk()) {
|
|
|
|
if (!res.isOk()) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (status == nullptr) {
|
|
|
|
if (unsupported == nullptr) {
|
|
|
|
String8 msg = String8::format( "Camera %s: Invalid status!", mCameraIdStr.string());
|
|
|
|
String8 msg("unsupported nullptr");
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*unsupported = false;
|
|
|
|
hardware::camera::device::V3_4::StreamConfiguration streamConfiguration;
|
|
|
|
|
|
|
|
auto ret = Camera3Device::mapToStreamConfigurationMode(
|
|
|
|
auto ret = Camera3Device::mapToStreamConfigurationMode(
|
|
|
|
static_cast<camera3_stream_configuration_mode_t> (operatingMode),
|
|
|
|
static_cast<camera3_stream_configuration_mode_t> (operatingMode),
|
|
|
|
/*out*/ &streamConfiguration.operationMode);
|
|
|
|
/*out*/ &streamConfiguration.operationMode);
|
|
|
|
if (ret != OK) {
|
|
|
|
if (ret != OK) {
|
|
|
|
String8 msg = String8::format(
|
|
|
|
String8 msg = String8::format(
|
|
|
|
"Camera %s: Failed mapping operating mode %d requested: %s (%d)", mCameraIdStr.string(),
|
|
|
|
"Camera %s: Failed mapping operating mode %d requested: %s (%d)",
|
|
|
|
operatingMode, strerror(-ret), ret);
|
|
|
|
logicalCameraId.string(), operatingMode, strerror(-ret), ret);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
|
|
|
|
msg.string());
|
|
|
|
msg.string());
|
|
|
@ -711,12 +701,12 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
bool isStreamInfoValid = false;
|
|
|
|
bool isStreamInfoValid = false;
|
|
|
|
OutputStreamInfo streamInfo;
|
|
|
|
OutputStreamInfo streamInfo;
|
|
|
|
|
|
|
|
|
|
|
|
res = checkSurfaceTypeLocked(numBufferProducers, deferredConsumer, it.getSurfaceType());
|
|
|
|
res = checkSurfaceType(numBufferProducers, deferredConsumer, it.getSurfaceType());
|
|
|
|
if (!res.isOk()) {
|
|
|
|
if (!res.isOk()) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res = checkPhysicalCameraId(physicalCameraIds, physicalCameraId,
|
|
|
|
res = checkPhysicalCameraIdLocked(physicalCameraId);
|
|
|
|
logicalCameraId);
|
|
|
|
if (!res.isOk()) {
|
|
|
|
if (!res.isOk()) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -742,8 +732,10 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
|
|
|
|
|
|
|
|
for (auto& bufferProducer : bufferProducers) {
|
|
|
|
for (auto& bufferProducer : bufferProducers) {
|
|
|
|
sp<Surface> surface;
|
|
|
|
sp<Surface> surface;
|
|
|
|
|
|
|
|
const CameraMetadata &physicalDeviceInfo = getMetadata(physicalCameraId);
|
|
|
|
res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer,
|
|
|
|
res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer,
|
|
|
|
physicalCameraId);
|
|
|
|
logicalCameraId,
|
|
|
|
|
|
|
|
physicalCameraId.size() > 0 ? physicalDeviceInfo : deviceInfo );
|
|
|
|
|
|
|
|
|
|
|
|
if (!res.isOk())
|
|
|
|
if (!res.isOk())
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
@ -759,15 +751,15 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
std::vector<OutputStreamInfo> compositeStreams;
|
|
|
|
std::vector<OutputStreamInfo> compositeStreams;
|
|
|
|
if (isDepthCompositeStream) {
|
|
|
|
if (isDepthCompositeStream) {
|
|
|
|
ret = camera3::DepthCompositeStream::getCompositeStreamInfo(streamInfo,
|
|
|
|
ret = camera3::DepthCompositeStream::getCompositeStreamInfo(streamInfo,
|
|
|
|
mDevice->info(), &compositeStreams);
|
|
|
|
deviceInfo, &compositeStreams);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ret = camera3::HeicCompositeStream::getCompositeStreamInfo(streamInfo,
|
|
|
|
ret = camera3::HeicCompositeStream::getCompositeStreamInfo(streamInfo,
|
|
|
|
mDevice->info(), &compositeStreams);
|
|
|
|
deviceInfo, &compositeStreams);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret != OK) {
|
|
|
|
if (ret != OK) {
|
|
|
|
String8 msg = String8::format(
|
|
|
|
String8 msg = String8::format(
|
|
|
|
"Camera %s: Failed adding composite streams: %s (%d)",
|
|
|
|
"Camera %s: Failed adding composite streams: %s (%d)",
|
|
|
|
mCameraIdStr.string(), strerror(-ret), ret);
|
|
|
|
logicalCameraId.string(), strerror(-ret), ret);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -775,7 +767,7 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
if (compositeStreams.size() == 0) {
|
|
|
|
if (compositeStreams.size() == 0) {
|
|
|
|
// No internal streams means composite stream not
|
|
|
|
// No internal streams means composite stream not
|
|
|
|
// supported.
|
|
|
|
// supported.
|
|
|
|
*status = false;
|
|
|
|
*unsupported = true;
|
|
|
|
return binder::Status::ok();
|
|
|
|
return binder::Status::ok();
|
|
|
|
} else if (compositeStreams.size() > 1) {
|
|
|
|
} else if (compositeStreams.size() > 1) {
|
|
|
|
streamCount += compositeStreams.size() - 1;
|
|
|
|
streamCount += compositeStreams.size() - 1;
|
|
|
@ -796,6 +788,49 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return binder::Status::ok();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status CameraDeviceClient::isSessionConfigurationSupported(
|
|
|
|
|
|
|
|
const SessionConfiguration& sessionConfiguration, bool *status /*out*/) {
|
|
|
|
|
|
|
|
ATRACE_CALL();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status res;
|
|
|
|
|
|
|
|
status_t ret = OK;
|
|
|
|
|
|
|
|
if (!(res = checkPidStatus(__FUNCTION__)).isOk()) return res;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mutex::Autolock icl(mBinderSerializationLock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mDevice.get()) {
|
|
|
|
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto operatingMode = sessionConfiguration.getOperatingMode();
|
|
|
|
|
|
|
|
res = checkOperatingMode(operatingMode, mDevice->info(), mCameraIdStr);
|
|
|
|
|
|
|
|
if (!res.isOk()) {
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (status == nullptr) {
|
|
|
|
|
|
|
|
String8 msg = String8::format( "Camera %s: Invalid status!", mCameraIdStr.string());
|
|
|
|
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hardware::camera::device::V3_4::StreamConfiguration streamConfiguration;
|
|
|
|
|
|
|
|
bool earlyExit = false;
|
|
|
|
|
|
|
|
metadataGetter getMetadata = [this](const String8 &id) {return mDevice->info(id);};
|
|
|
|
|
|
|
|
std::vector<std::string> physicalCameraIds;
|
|
|
|
|
|
|
|
mProviderManager->isLogicalCamera(mCameraIdStr.string(), &physicalCameraIds);
|
|
|
|
|
|
|
|
res = convertToHALStreamCombination(sessionConfiguration, mCameraIdStr,
|
|
|
|
|
|
|
|
mDevice->info(), getMetadata, physicalCameraIds, streamConfiguration, &earlyExit);
|
|
|
|
|
|
|
|
if (!res.isOk()) {
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (earlyExit) {
|
|
|
|
|
|
|
|
*status = false;
|
|
|
|
|
|
|
|
return binder::Status::ok();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*status = false;
|
|
|
|
*status = false;
|
|
|
|
ret = mProviderManager->isSessionConfigurationSupported(mCameraIdStr.string(),
|
|
|
|
ret = mProviderManager->isSessionConfigurationSupported(mCameraIdStr.string(),
|
|
|
@ -935,7 +970,7 @@ binder::Status CameraDeviceClient::createStream(
|
|
|
|
String8 physicalCameraId = String8(outputConfiguration.getPhysicalCameraId());
|
|
|
|
String8 physicalCameraId = String8(outputConfiguration.getPhysicalCameraId());
|
|
|
|
bool deferredConsumerOnly = deferredConsumer && numBufferProducers == 0;
|
|
|
|
bool deferredConsumerOnly = deferredConsumer && numBufferProducers == 0;
|
|
|
|
|
|
|
|
|
|
|
|
res = checkSurfaceTypeLocked(numBufferProducers, deferredConsumer,
|
|
|
|
res = checkSurfaceType(numBufferProducers, deferredConsumer,
|
|
|
|
outputConfiguration.getSurfaceType());
|
|
|
|
outputConfiguration.getSurfaceType());
|
|
|
|
if (!res.isOk()) {
|
|
|
|
if (!res.isOk()) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
@ -944,8 +979,9 @@ binder::Status CameraDeviceClient::createStream(
|
|
|
|
if (!mDevice.get()) {
|
|
|
|
if (!mDevice.get()) {
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> physicalCameraIds;
|
|
|
|
res = checkPhysicalCameraIdLocked(physicalCameraId);
|
|
|
|
mProviderManager->isLogicalCamera(mCameraIdStr.string(), &physicalCameraIds);
|
|
|
|
|
|
|
|
res = checkPhysicalCameraId(physicalCameraIds, physicalCameraId, mCameraIdStr);
|
|
|
|
if (!res.isOk()) {
|
|
|
|
if (!res.isOk()) {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -974,7 +1010,7 @@ binder::Status CameraDeviceClient::createStream(
|
|
|
|
|
|
|
|
|
|
|
|
sp<Surface> surface;
|
|
|
|
sp<Surface> surface;
|
|
|
|
res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer,
|
|
|
|
res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer,
|
|
|
|
physicalCameraId);
|
|
|
|
mCameraIdStr, mDevice->info(physicalCameraId));
|
|
|
|
|
|
|
|
|
|
|
|
if (!res.isOk())
|
|
|
|
if (!res.isOk())
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
@ -1278,7 +1314,7 @@ binder::Status CameraDeviceClient::updateOutputConfiguration(int streamId,
|
|
|
|
OutputStreamInfo outInfo;
|
|
|
|
OutputStreamInfo outInfo;
|
|
|
|
sp<Surface> surface;
|
|
|
|
sp<Surface> surface;
|
|
|
|
res = createSurfaceFromGbp(outInfo, /*isStreamInfoValid*/ false, surface,
|
|
|
|
res = createSurfaceFromGbp(outInfo, /*isStreamInfoValid*/ false, surface,
|
|
|
|
newOutputsMap.valueAt(i), physicalCameraId);
|
|
|
|
newOutputsMap.valueAt(i), mCameraIdStr, mDevice->info(physicalCameraId));
|
|
|
|
if (!res.isOk())
|
|
|
|
if (!res.isOk())
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
|
@ -1358,11 +1394,11 @@ bool CameraDeviceClient::isPublicFormat(int32_t format)
|
|
|
|
binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
OutputStreamInfo& streamInfo, bool isStreamInfoValid,
|
|
|
|
OutputStreamInfo& streamInfo, bool isStreamInfoValid,
|
|
|
|
sp<Surface>& surface, const sp<IGraphicBufferProducer>& gbp,
|
|
|
|
sp<Surface>& surface, const sp<IGraphicBufferProducer>& gbp,
|
|
|
|
const String8& physicalId) {
|
|
|
|
const String8 &cameraId, const CameraMetadata &physicalCameraMetadata) {
|
|
|
|
|
|
|
|
|
|
|
|
// bufferProducer must be non-null
|
|
|
|
// bufferProducer must be non-null
|
|
|
|
if (gbp == nullptr) {
|
|
|
|
if (gbp == nullptr) {
|
|
|
|
String8 msg = String8::format("Camera %s: Surface is NULL", mCameraIdStr.string());
|
|
|
|
String8 msg = String8::format("Camera %s: Surface is NULL", cameraId.string());
|
|
|
|
ALOGW("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGW("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1374,13 +1410,13 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
status_t err;
|
|
|
|
status_t err;
|
|
|
|
if ((err = gbp->getConsumerUsage(&consumerUsage)) != OK) {
|
|
|
|
if ((err = gbp->getConsumerUsage(&consumerUsage)) != OK) {
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface consumer usage: %s (%d)",
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface consumer usage: %s (%d)",
|
|
|
|
mCameraIdStr.string(), strerror(-err), err);
|
|
|
|
cameraId.string(), strerror(-err), err);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consumerUsage & GraphicBuffer::USAGE_HW_TEXTURE) {
|
|
|
|
if (consumerUsage & GraphicBuffer::USAGE_HW_TEXTURE) {
|
|
|
|
ALOGW("%s: Camera %s with consumer usage flag: %" PRIu64 ": Forcing asynchronous mode for stream",
|
|
|
|
ALOGW("%s: Camera %s with consumer usage flag: %" PRIu64 ": Forcing asynchronous mode for stream",
|
|
|
|
__FUNCTION__, mCameraIdStr.string(), consumerUsage);
|
|
|
|
__FUNCTION__, cameraId.string(), consumerUsage);
|
|
|
|
useAsync = true;
|
|
|
|
useAsync = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1399,26 +1435,26 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
android_dataspace dataSpace;
|
|
|
|
android_dataspace dataSpace;
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_WIDTH, &width)) != OK) {
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_WIDTH, &width)) != OK) {
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface width: %s (%d)",
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface width: %s (%d)",
|
|
|
|
mCameraIdStr.string(), strerror(-err), err);
|
|
|
|
cameraId.string(), strerror(-err), err);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_HEIGHT, &height)) != OK) {
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_HEIGHT, &height)) != OK) {
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface height: %s (%d)",
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface height: %s (%d)",
|
|
|
|
mCameraIdStr.string(), strerror(-err), err);
|
|
|
|
cameraId.string(), strerror(-err), err);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_FORMAT, &format)) != OK) {
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_FORMAT, &format)) != OK) {
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface format: %s (%d)",
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface format: %s (%d)",
|
|
|
|
mCameraIdStr.string(), strerror(-err), err);
|
|
|
|
cameraId.string(), strerror(-err), err);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_DEFAULT_DATASPACE,
|
|
|
|
if ((err = anw->query(anw, NATIVE_WINDOW_DEFAULT_DATASPACE,
|
|
|
|
reinterpret_cast<int*>(&dataSpace))) != OK) {
|
|
|
|
reinterpret_cast<int*>(&dataSpace))) != OK) {
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface dataspace: %s (%d)",
|
|
|
|
String8 msg = String8::format("Camera %s: Failed to query Surface dataspace: %s (%d)",
|
|
|
|
mCameraIdStr.string(), strerror(-err), err);
|
|
|
|
cameraId.string(), strerror(-err), err);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1429,16 +1465,16 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
((consumerUsage & GRALLOC_USAGE_HW_MASK) &&
|
|
|
|
((consumerUsage & GRALLOC_USAGE_HW_MASK) &&
|
|
|
|
((consumerUsage & GRALLOC_USAGE_SW_READ_MASK) == 0))) {
|
|
|
|
((consumerUsage & GRALLOC_USAGE_SW_READ_MASK) == 0))) {
|
|
|
|
ALOGW("%s: Camera %s: Overriding format %#x to IMPLEMENTATION_DEFINED",
|
|
|
|
ALOGW("%s: Camera %s: Overriding format %#x to IMPLEMENTATION_DEFINED",
|
|
|
|
__FUNCTION__, mCameraIdStr.string(), format);
|
|
|
|
__FUNCTION__, cameraId.string(), format);
|
|
|
|
format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
|
|
|
|
format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Round dimensions to the nearest dimensions available for this format
|
|
|
|
// Round dimensions to the nearest dimensions available for this format
|
|
|
|
if (flexibleConsumer && isPublicFormat(format) &&
|
|
|
|
if (flexibleConsumer && isPublicFormat(format) &&
|
|
|
|
!CameraDeviceClient::roundBufferDimensionNearest(width, height,
|
|
|
|
!CameraDeviceClient::roundBufferDimensionNearest(width, height,
|
|
|
|
format, dataSpace, mDevice->info(physicalId), /*out*/&width, /*out*/&height)) {
|
|
|
|
format, dataSpace, physicalCameraMetadata, /*out*/&width, /*out*/&height)) {
|
|
|
|
String8 msg = String8::format("Camera %s: No supported stream configurations with "
|
|
|
|
String8 msg = String8::format("Camera %s: No supported stream configurations with "
|
|
|
|
"format %#x defined, failed to create output stream",
|
|
|
|
"format %#x defined, failed to create output stream",
|
|
|
|
mCameraIdStr.string(), format);
|
|
|
|
cameraId.string(), format);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1453,26 +1489,26 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (width != streamInfo.width) {
|
|
|
|
if (width != streamInfo.width) {
|
|
|
|
String8 msg = String8::format("Camera %s:Surface width doesn't match: %d vs %d",
|
|
|
|
String8 msg = String8::format("Camera %s:Surface width doesn't match: %d vs %d",
|
|
|
|
mCameraIdStr.string(), width, streamInfo.width);
|
|
|
|
cameraId.string(), width, streamInfo.width);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (height != streamInfo.height) {
|
|
|
|
if (height != streamInfo.height) {
|
|
|
|
String8 msg = String8::format("Camera %s:Surface height doesn't match: %d vs %d",
|
|
|
|
String8 msg = String8::format("Camera %s:Surface height doesn't match: %d vs %d",
|
|
|
|
mCameraIdStr.string(), height, streamInfo.height);
|
|
|
|
cameraId.string(), height, streamInfo.height);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (format != streamInfo.format) {
|
|
|
|
if (format != streamInfo.format) {
|
|
|
|
String8 msg = String8::format("Camera %s:Surface format doesn't match: %d vs %d",
|
|
|
|
String8 msg = String8::format("Camera %s:Surface format doesn't match: %d vs %d",
|
|
|
|
mCameraIdStr.string(), format, streamInfo.format);
|
|
|
|
cameraId.string(), format, streamInfo.format);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
|
|
|
|
if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
|
|
|
|
if (dataSpace != streamInfo.dataSpace) {
|
|
|
|
if (dataSpace != streamInfo.dataSpace) {
|
|
|
|
String8 msg = String8::format("Camera %s:Surface dataSpace doesn't match: %d vs %d",
|
|
|
|
String8 msg = String8::format("Camera %s:Surface dataSpace doesn't match: %d vs %d",
|
|
|
|
mCameraIdStr.string(), dataSpace, streamInfo.dataSpace);
|
|
|
|
cameraId.string(), dataSpace, streamInfo.dataSpace);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1481,7 +1517,7 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
|
|
|
|
if (consumerUsage != streamInfo.consumerUsage) {
|
|
|
|
if (consumerUsage != streamInfo.consumerUsage) {
|
|
|
|
String8 msg = String8::format(
|
|
|
|
String8 msg = String8::format(
|
|
|
|
"Camera %s:Surface usage flag doesn't match %" PRIu64 " vs %" PRIu64 "",
|
|
|
|
"Camera %s:Surface usage flag doesn't match %" PRIu64 " vs %" PRIu64 "",
|
|
|
|
mCameraIdStr.string(), consumerUsage, streamInfo.consumerUsage);
|
|
|
|
cameraId.string(), consumerUsage, streamInfo.consumerUsage);
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
ALOGE("%s: %s", __FUNCTION__, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1861,7 +1897,7 @@ binder::Status CameraDeviceClient::finalizeOutputConfigurations(int32_t streamId
|
|
|
|
|
|
|
|
|
|
|
|
sp<Surface> surface;
|
|
|
|
sp<Surface> surface;
|
|
|
|
res = createSurfaceFromGbp(mStreamInfoMap[streamId], true /*isStreamInfoValid*/,
|
|
|
|
res = createSurfaceFromGbp(mStreamInfoMap[streamId], true /*isStreamInfoValid*/,
|
|
|
|
surface, bufferProducer, physicalId);
|
|
|
|
surface, bufferProducer, mCameraIdStr, mDevice->info(physicalId));
|
|
|
|
|
|
|
|
|
|
|
|
if (!res.isOk())
|
|
|
|
if (!res.isOk())
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|