平台: android Q, qcom sm6125
报错信息:android.hardware.camera2.cts.CaptureRequestTest#testAeModeAndLock: Test failed for camera 0: Sensitivity is invalid for AE manaul control test, request: 104 result: 100
android.hardware.camera2.cts.CaptureRequestTest#testAeModeAndLock: Test failed for camera 0: Sensitivity is invalid for AE manaul control test, request: 104 result: 100
CTS此项部分测试步聚
若驱动的again定义如下
#define HI846_MIN_AGAIN 1.0 // minSensitivity
#define HI846_MAX_AGAIN 16.0 // maxSensitivity
那么根据CTS测试用例,会转化为以下九个数值,数值间的步进为 187
private static final int DEFAULT_NUM_SENSITIVITY_STEPS = 8;
/**
* Get the sensitivity array that contains multiple sensitivity steps in the
* sensitivity range.
*
* Sensitivity number of test values is determined by
* {@value #DEFAULT_SENSITIVITY_STEP_SIZE} and sensitivity range, and
* bounded by {@value #DEFAULT_NUM_SENSITIVITY_STEPS}.
*
*/
private int[] getSensitivityTestValues() {
int maxSensitivity = mStaticInfo.getSensitivityMaximumOrDefault(
DEFAULT_SENSITIVITY);
int minSensitivity = mStaticInfo.getSensitivityMinimumOrDefault(
DEFAULT_SENSITIVITY);
int range = maxSensitivity - minSensitivity;
int stepSize = DEFAULT_SENSITIVITY_STEP_SIZE;
int numSteps = range / stepSize;
// Bound the test steps to avoid supper long test.
if (numSteps > DEFAULT_NUM_SENSITIVITY_STEPS) {
numSteps = DEFAULT_NUM_SENSITIVITY_STEPS;//此处被重新赋值为8
stepSize = range / numSteps;
}
int[] testValues = new int[numSteps + 1];
for (int i = 0; i < testValues.length; i++) {
testValues[i] = maxSensitivity - stepSize * i;
testValues[i] = mStaticInfo.getSensitivityClampToRange(testValues[i]);
}
return testValues;
}
按照以上计算, 会得出以下数值去validate
Testing sensitivity 1600
Testing sensitivity 1413
Testing sensitivity 1226
Testing sensitivity 1039
Testing sensitivity 852
Testing sensitivity 665
Testing sensitivity 478
Testing sensitivity 291
Testing sensitivity 104
其中,104传到底层去转化 104除以100(ISO 100 在 tuning 文件 3A/zsl_preview中有定义)等于 1.04 传入 驱动中的 calculator_exposure,经过
reg_gain = (unsigned int)((real_gain-1) * 16);
real_gain = (float)reg_gain / 16+(float)1;
换算后, real_gain 等于 100. 差值就在于 (unsigned int) 取整小数等于 0 ,造成了误差大于3(104-100=4),测试用例报错
若我们把 #define HI846_MAX_AGAIN 16.0 // maxSensitivity
修改为#define HI846_MAX_AGAIN 15.0 // maxSensitivity
就会变为以下数值
Testing sensitivity 1500
Testing sensitivity 1325
Testing sensitivity 1150
Testing sensitivity 975
Testing sensitivity 800
Testing sensitivity 625
Testing sensitivity 450
Testing sensitivity 275
Testing sensitivity 100
数值的转换可以自己写个小程序
#include
int a[9] = {1600, 1413, 1226, 1039, 852, 665, 478, 291, 104};// maxSensitivity 为 1600
int b[9];// maxSensitivity 为 1500
double real_gain;
int i = 0, reg_gain, stepSize;
stepSize = (int)((1500 - 100) / 8);
int main () {
for (i = 0; i < 9; i++)
b[i] = 1500 - stepSize * i;// maxSensitivity 为 1500
for(i = 0; i < 9; i++)
{
real_gain = (double)b[i] / 100;//此处很关键, 一定要加 double, 不然, real_gain会是整数
reg_gain = (unsigned int)((real_gain-1) * 16);
real_gain = (double)reg_gain/16 + (float)1;
printf("%f\n", real_gain);
if( b[i] - real_gain*100 >= 3)
printf("not valib gain b[%d] = %d real_gain = %f\n", i, b[i], real_gain);
}
return 0;
}
这些数值可以通过以下测试
private static final float SENSITIVITY_ERROR_MARGIN_RATE = 0.03f; // 3%, Approximation.
/**
* Validate AE manual control sensitivity.
*
* @param request Request sensitivity
* @param result Result sensitivity
*/
private void validateSensitivity(int request, int result) {
float sensitivityDelta = request - result;
float sensitivityErrorMargin = request * SENSITIVITY_ERROR_MARGIN_RATE;
// First, round down not up, second, need close enough.
mCollector.expectTrue("Sensitivity is invalid for AE manaul control test, request: "
+ request + " result: " + result,
sensitivityDelta < sensitivityErrorMargin && sensitivityDelta >= 0);
}
可以再看看有没有其他的修改方法