Skip to content

Commit

Permalink
(hybris) camera: support ISO setting on HAL3 devices under API1 on Qu…
Browse files Browse the repository at this point in the history
…alcomm devices

[camera] Support ISO setting on HAL3 devices under API1 on Qualcomm devices. Fixes JB#42952

Change-Id: I359080b21108e08d98a3983831bc02c4369b4610
  • Loading branch information
Andrew Branson authored and sledges committed Feb 6, 2019
1 parent 7c8c11b commit 4eb7f04
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
76 changes: 76 additions & 0 deletions services/camera/libcameraservice/api1/client2/Parameters.cpp
Expand Up @@ -33,6 +33,9 @@
#include <android/hardware/ICamera.h>
#include <media/MediaProfiles.h>
#include <media/mediarecorder.h>
#include <camera/CameraMetadata.h>
#include <camera_metadata_hidden.h>
#include <camera/VendorTagDescriptor.h>

namespace android {
namespace camera2 {
Expand Down Expand Up @@ -63,6 +66,25 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
res = buildQuirks();
if (res != OK) return res;

/* Fetch Qualcomm specific vendor tags for controlling ISO exposure.
* This is used because HAL3 SENSOR_SENSITIVITY disables flash and auto exposure control.
* A tag for fetching supported ISO values is available, but only went up to ISO400.
*/
sp<VendorTagDescriptor> vTags;
sp<VendorTagDescriptorCache> cache = VendorTagDescriptorCache::getGlobalVendorTagCache();
if (cache.get()) {
const camera_metadata_t *metaBuffer = info->getAndLock();
metadata_vendor_id_t vendorId = get_camera_metadata_vendor_id(metaBuffer);
info->unlock(metaBuffer);
cache->getVendorTagDescriptor(vendorId, &vTags);
}
// select_priority instructs the HAL to fix ISO over other values
res = info->getTagFromName("org.codeaurora.qcamera3.iso_exp_priority.select_priority", vTags.get(), &select_priority);
if (res != OK) return res;
// use_iso_exp_priority sets the desired ISO speed (plus 0 for auto and 1 for HJR)
res = info->getTagFromName("org.codeaurora.qcamera3.iso_exp_priority.use_iso_exp_priority", vTags.get(), &use_iso_exp_priority);
if (res != OK) return res;

const Size MAX_PREVIEW_SIZE = { MAX_PREVIEW_WIDTH, MAX_PREVIEW_HEIGHT };
// Treat the H.264 max size as the max supported video size.
MediaProfiles *videoEncoderProfiles = MediaProfiles::getInstance();
Expand Down Expand Up @@ -365,6 +387,29 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
gpsProcessingMethod = "unknown";
// GPS fields in CameraParameters are not set by implementation

/* Generate possible ISO values cameras
* Take lowest supported sensitivity, and keep doubling it until we exceed the highest
* This is not Qualcomm specific
*/
isoSpeed = 0;
params.set("iso", isoSpeed);

camera_metadata_ro_entry_t sensitivityRange =
staticInfo(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, 0, 0, false);
String8 supportedISOSpeeds;
supportedISOSpeeds = "auto,ISO_HJR";
if (sensitivityRange.count == 2 && sensitivityRange.data.i32[1] > sensitivityRange.data.i32[0]) {
ALOGD("ISO range available: ISO%d - ISO%d", sensitivityRange.data.i32[0], sensitivityRange.data.i32[1]);
int32_t thisSpeed = sensitivityRange.data.i32[0];
while (thisSpeed <= sensitivityRange.data.i32[1]) {
supportedISOSpeeds.appendFormat(",ISO%d", thisSpeed);
thisSpeed *= 2;
}
}
ALOGD("Reporting available ISO values: %s", supportedISOSpeeds.string());
params.set("iso-values", supportedISOSpeeds);


wbMode = ANDROID_CONTROL_AWB_MODE_AUTO;
params.set(CameraParameters::KEY_WHITE_BALANCE,
CameraParameters::WHITE_BALANCE_AUTO);
Expand Down Expand Up @@ -1968,6 +2013,30 @@ status_t Parameters::set(const String8& paramString) {
ALOGE("%s: Video stabilization not supported", __FUNCTION__);
}

// ISO
String8 isoString;
isoString = newParams.get("iso");
if (isoString == "auto") {
validatedParams.isoSpeed = 0;
}
else if (isoString == "ISO_HJR") {
validatedParams.isoSpeed = 1;
}
else if (isoString.contains("ISO")) { // Check ordinary ISO values against sensitivity range.
int64_t newISO;
sscanf(isoString.string(), "ISO%" PRId64, &newISO);
camera_metadata_ro_entry_t sensitivityRange =
staticInfo(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, 0, 0, false);
if (sensitivityRange.count != 2 || newISO < sensitivityRange.data.i32[0] || newISO > sensitivityRange.data.i32[1]) {
ALOGE("%s: ISO value %s out of range", __FUNCTION__, isoString.string());
return BAD_VALUE;
}
else {
validatedParams.isoSpeed=newISO;
ALOGD("Setting ISO speed to %" PRId64, newISO);
}
}

/** Update internal parameters */

*this = validatedParams;
Expand Down Expand Up @@ -2131,6 +2200,13 @@ status_t Parameters::updateRequest(CameraMetadata *request) const {
if (res != OK) return res;
}

// Set ISO sensitivity using Qualcomm vendor tags
int32_t zero = 0;
res = request->update(select_priority, &zero, 1);
if (res != OK) return res;
res = request->update(use_iso_exp_priority, &isoSpeed, 1);
if (res != OK) return res;

res = request->update(ANDROID_CONTROL_AWB_MODE,
&wbMode, 1);
if (res != OK) return res;
Expand Down
2 changes: 2 additions & 0 deletions services/camera/libcameraservice/api1/client2/Parameters.h
Expand Up @@ -66,6 +66,7 @@ struct Parameters {
double gpsCoordinates[3];
int64_t gpsTimestamp;
String8 gpsProcessingMethod;
int64_t isoSpeed;

uint8_t wbMode;
uint8_t effectMode;
Expand Down Expand Up @@ -211,6 +212,7 @@ struct Parameters {
// Full static camera info, object owned by someone else, such as
// Camera2Device.
const CameraMetadata *info;
uint32_t select_priority, use_iso_exp_priority;

// Fast-access static device information; this is a subset of the
// information available through the staticInfo() method, used for
Expand Down

0 comments on commit 4eb7f04

Please sign in to comment.