在上一篇博客中我们提到Camera模块fail项,本篇博客我们单独讲解Camera模块的。
GMS中涉及Camera的有:
1、CTS部分的CtsCameraTestCases模块
2、CTS VERIFY测试的Camera模块,其中verify部分还包括Camera FOV角的计算
3、其他问题
这里面CTS 的CtsCameraTestCases模块fail项又分为Camera Sensor 部分和HAL层的分辨率配置两大块。

一、Camera Sensor模块的fail项

android 检测相机是否可用 简书 手机测试相机模块_android 检测相机是否可用 简书

首先我们截取一部分关键log去分析:
 Camera-JNI: release camera
01-11 08:23:41.653  7670  7678 I Camera-JNI: release camera
01-11 08:23:41.655  7670 26697 I art     : Starting a blocking GC Explicit
01-11 08:23:41.664   624   634 D BroadcastQueue: Add broadcast <BroadcastRecord{1f1b5f4 u-1 android.intent.action.BATTERY_CHANGED}> into [parallel | background], pending size 0
01-11 08:23:41.665   624   637 D BroadcastQueue: Done with parallel broadcast [background] [BroadcastRecord{1f1b5f4 u-1 android.intent.action.BATTERY_CHANGED}]
01-11 08:23:41.677   259 26661 I isp_ctrl: ISP_RAW: id:0x00, 10229 line, _isp_ctrl_routine : SOF
01-11 08:23:41.678   259 26661 I         : ISP_RAW: id:0x00, 00553 line, _ispAeInfoSet : mode 0, iso 0, fps 5
01-11 08:23:41.678   259 26661 I         : ISP_RAW: id:0x00, 00214 line, _ispGetFrameLine : min fps:7, line_time:658 
01-11 08:23:41.678   259 26661 I         : ISP_RAW: id:0x00, 00222 line, _ispGetFrameLine : max fps:30, line_time:658 
01-11 08:23:41.679   259 26661 I         : ISP_RAW: id:0x00, 00230 line, _ispGetFrameLine : auto fps:7, line_time:658 
01-11 08:23:41.679   259 26661 I         : ISP_RAW: id:0x00, 00431 line, _isp_ae_set_exposure : exposure = 303, dummy = 203
01-11 08:23:41.679   259 26661 I         : 774, gc030a_write_exposure: current mode = 1, exposure_line = 303
01-11 08:23:41.679   259 26661 I         : 813, gc030a_write_gain_value: real_gain = 0x50
01-11 08:23:41.680   259 26661 I isp_ctrl: _ispCfgContrast contrast_factor error!!!!!!
01-11 08:23:41.686   940   940 W Settings: Setting bugreport_in_power_menu has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
01-11 08:23:41.688   940 26569 D Index   : Indexing locale 'en_US' took 17 millis
01-11 08:23:41.695   624  1793 W PackageManager: com.android.shell == 0 == 0 0
01-11 08:23:41.695   624  1793 D PackageManager: kings:packageName=com.android.shell, className=com.android.shell.BugreportStorageProvider
01-11 08:23:41.705  7670 26697 I art     : Explicit concurrent mark sweep GC freed 1016(61KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 3MB/5MB, paused 762us total 49.407ms
01-11 08:23:41.706  7670 26697 I TestRunner: failed: testMeteringAreas(android.hardware.cts.CameraTest)
01-11 08:23:41.706  7670 26697 I TestRunner: ----- begin exception -----
01-11 08:23:41.707  7670 26697 I TestRunner: junit.framework.AssertionFailedError: Fail to open camera.
01-11 08:23:41.707  7670 26697 I TestRunner:    at junit.framework.Assert.fail(Assert.java:50)
01-11 08:23:41.707  7670 26697 I TestRunner:    at junit.framework.Assert.assertTrue(Assert.java:20)
01-11 08:23:41.707  7670 26697 I TestRunner:    at junit.framework.Assert.assertNotNull(Assert.java:218)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.hardware.cts.CameraTest.initializeMessageLooper(CameraTest.java:174)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.hardware.cts.CameraTest.testMeteringAreas(CameraTest.java:2407)
01-11 08:23:41.707  7670 26697 I TestRunner:    at java.lang.reflect.Method.invoke(Native Method)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:220)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.test.InstrumentationTestCase.-wrap0(InstrumentationTestCase.java)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.test.InstrumentationTestCase$2.run(InstrumentationTestCase.java:195)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:1950)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.os.Handler.handleCallback(Handler.java:751)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.os.Handler.dispatchMessage(Handler.java:95)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.os.Looper.loop(Looper.java:154)
01-11 08:23:41.707  7670 26697 I TestRunner:    at android.app.ActivityThread.main(ActivityThread.java:6153)
01-11 08:23:41.707  7670 26697 I TestRunner:    at java.lang.reflect.Method.invoke(Native Method)
01-11 08:23:41.707  7670 26697 I TestRunner:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
01-11 08:23:41.707  7670 26697 I TestRunner:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
01-11 08:23:41.707  7670 26697 I TestRunner: ----- end exception -----

从上述log中我们大概可以看到摄像头帧率范围是7-30(MIN~MAX)帧,当前配置的是浮动帧率,报错的时候帧率只有5帧,报错后摄像头直接打不开,可想而知这个模块剩下的测试项将是全部fail。
既然是帧率的问题,我们要搞懂它的原理然后再去配置。一般在做客制需求时客户都会要求摄像头芯片厂 FAE去调摄像头的效果。在我与这些FAE的打交道中了解到,摄像头的帧有一定的范围,比如最大是30帧,根据客户要调的效果,FAE一般会调成浮动帧率,这样摄像头的拍照效果很更好。但是CTS的要求更为严格,CTS对于帧率的测试,是允许有一定量的误差值,但测量出的帧率与目标范围相差过大时,就会fail,且现在预览帧率都为AE自动调整,当测试环境不同时,结果也可能不同,如上log 中实际帧率只有5帧就会fail。使用平台默认的浮动帧率配置,前后摄会有几组不同的帧率范围,如测试环境复杂时,就会容易fail。所以解决方案是:过CTS的时候出现帧率fail就将摄像头效果调成固定帧率

第一步:从FAE那里拿到摄像头模组调成固定帧率的效果文件。比如在当前项目中他给我调的前后摄都是25帧
第二步:同步修改SprdCamera3Setting.cpp文件里面的kavailable_fps_ranges_back和kavailable_fps_ranges_front数组。

vendor/sprd/modules/libcamera/hal3/SprdCamera3Setting.cpp 里面
const int32_t kavailable_fps_ranges_back[] = {5, 25, 25, 25};//后摄修改之后帧率
//{5, 20, 8, 20, 10, 20, 5, 25, 10, 25, 5, 30, 10, 30};//后摄修改之前帧率
const int32_t kavailable_fps_ranges_front[] = {5, 25, 25, 25};//前摄修改之后帧率
//{5, 15, 5, 20, 10, 20, 5, 25, 10, 25, 5, 30, 10, 30};//前摄修改之前帧率

这里面简单介绍下这两个数组的作用。这个数组是控制录像的时候视频的帧率范围。MIN,MAX两两为一组。比如修改之后我的帧率范围有两组分别是5-25 和25-25。因此在录像的时候我们不能出现这个范围之外的帧率,否则录像功能就不能正常的使用下面就要进行我们的第三步。

第三步:修改sc7731g_n/device/sprd\scx35/sp7731g_1h10目录下面的media_profiles.xml文件。这里面media_profiles.xml文件的路径每个平台都不同,不能死记路径,我们可以通过代码查找。

find device/sprd/ -name "media_profiles.xml" 
device/sprd/scx35/common/rootdir/system/etc/media_profiles.xml
device/sprd/scx35/sp7731g_1h10/media_profiles.xml

这里有两个可能的media_profiles.xml文件,我们需要判断哪个才是代码里面引用的

```
在代码device目录下查找
grep -rn "media_profiles.xml" device/sprd/scx35
device/sprd/scx35/sp7731g_1h10/sp7731g_1h10_common.mk:35:PRODUCT_COPY_FILES += $(BOARDDIR)/media_profiles.xml:system/etc/media_profiles.xml

我们打开对应的Makefile文件

TARGET_PLATFORM := sc8830
TARGET_HARDWARE := sp7731g
TARGET_BOARD := sp7731g_1h10
PLATDIR := device/sprd/scx35
PLATCOMM := $(PLATDIR)/common
BOARDDIR := $(PLATDIR)/$(TARGET_BOARD)
ROOTDIR := $(BOARDDIR)/rootdir
ROOTCOMM := $(PLATCOMM)/rootdir

BOARD_KERNEL_PAGESIZE := 2048
BOARD_KERNEL_SEPARATED_DT := true

#use sprd's four(wifi bt gps fm) integrated one chip
USE_SPRD_WCN := true

# copy media_profiles.xml before calling device.mk,
# because we want to use our file, not the common one
PRODUCT_COPY_FILES += $(BOARDDIR)/media_profiles.xml:system/etc/media_profiles.xml
PRODUCT_COPY_FILES += $(BOARDDIR)/media_codecs.xml:system/etc/media_codecs.xml

这里面执行copy动作是将sp7731g_1h10目录下的media_profiles.xml文件复制出来,所以代码里面引用的是第二个路径下的文件。
我们打开media_profiles.xml文件,下面贴出部分代码

<CamcorderProfiles cameraId="0">
        <EncoderProfile quality="low" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="256000"
                   width="176"
                   height="144"
                   frameRate="15" />
            <Audio codec="amrnb"
                   bitRate="12200"
                   sampleRate="8000"
                   channels="1" />
        </EncoderProfile>

这里面h264编解码格式的视频尺寸大小为176x144,帧率为15帧,这里面虽然15帧在配置的范围内,但是为了测试顺利,我们将这个文件里面的所有frameRate都改为25帧。同时视频尺寸的宽高也要在我们支持的分辨率里面,下面的分辨率部分将会讲解到。按照上述三步修改,就基本可以解决帧率的fail项。

二、Camera分辨率部分的fail项

android 检测相机是否可用 简书 手机测试相机模块_android 检测相机是否可用 简书_02


从报告的截图中我们可以看到提示说

junit.framework.AssertionFailedError: Required HD size not found for format 100 for: ID 1 : No elements from [,720x480640x480480x640352x288320x240176x144] in [, 1280x720]

在1280x720里面没有找到没有找到720x480 640x480 480x640 352x288 320x240 176x144这些分辨率,下面的同理。

1、配置BroadConfig.mk文件里面的前后摄大小,比如当前项目配置的是gc030a+gc5025前30w 后500w像素的模组

device/sprd/scx35/sp7731g_1h10/BoardConfig.mk

# select camera 2M,3M,5M,8M
CAMERA_SUPPORT_SIZE := 5M
FRONT_CAMERA_SUPPORT_SIZE := 0P3M

2、配置vendor/sprd/modules/libcamera/hal3/SprdCamera3Setting.h里面前后摄的最大拍照尺寸

#elif CONFIG_CAMERA_SUPPORT_5M
#define BACK_SENSOR_ORIG_WIDTH 2592
#define BACK_SENSOR_ORIG_HEIGHT 1944
#else
#define BACK_SENSOR_ORIG_WIDTH 1600
#define BACK_SENSOR_ORIG_HEIGHT 1200
#endif

#elif CONFIG_FRONT_CAMERA_SUPPORT_2M
#define FRONT_SENSOR_ORIG_WIDTH 1600 //select according to max jpg resolution
#define FRONT_SENSOR_ORIG_HEIGHT 1200
#elif CONFIG_FRONT_CAMERA_SUPPORT_0P3M
#define FRONT_SENSOR_ORIG_WIDTH 640 //select according to max jpg resolution
#define FRONT_SENSOR_ORIG_HEIGHT 480
#else

这里面标准的500万像素照片大小是:2592x1944 (2592/1944=4:3) 2592x1944 =5038848
标准30万像素照片大小是 :640x480 (640/480=4:3)640x480=307200

3、配置vendor/sprd/modules/libcamera/hal3/SprdCamera3Setting.cpp文件里面的分辨率

hal 层的SprdCamera3Setting.cpp文件之前我们有提到过,Camera 底层的分辨率也是在这里面配置的。

const int32_t kavailable_back_stream_configurations[CAMERA_SETTINGS_CONFIG_ARRAYSIZE][4] = {
    // configure table for preview size.
#if defined(CONFIG_CAMERA_SUPPORT_13M)
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 4160, 3120, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M)
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 3264, 2448, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT}, //for CTS
    //{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 3264, 1836, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},//for ss
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M)
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 2592, 1944, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 2448, 2448, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},//for ss
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M)
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 2048, 1536, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 2048, 1152, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},//for ss
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1920, 1088, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M)
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1600, 1200, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1280, 960, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1280, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M) || defined(CONFIG_CAMERA_SUPPORT_1M)
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 960, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 864, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M) || defined(CONFIG_CAMERA_SUPPORT_1M) \
    || defined(CONFIG_CAMERA_SUPPORT_0M4)
    //{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 800, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 720, 544, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 720, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
    // please at least use 0.3M sensor.
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
//  {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 624, 352, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 480, 640, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 352, 288, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 240, 320, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 176, 144, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},

//  {HAL_PIXEL_FORMAT_YV12, 3264, 2448, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 2592, 1944, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 2048, 1536, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 1920, 1088, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 1600, 1200, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 1280, 960, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 1280, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 960, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 864, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_YV12, 720, 544, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 720, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 480, 640, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 352, 288, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 240, 320, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YV12, 176, 144, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    // configure table for callback stream size.
#if defined(CONFIG_CAMERA_SUPPORT_13M)
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 4160, 3120, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M)
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 3264, 2448, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M)
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 2592, 1944, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_YCbCr_420_888, 2560, 1536, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    ||  defined(CONFIG_CAMERA_SUPPORT_3M)
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 2048, 1536, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 1920, 1088, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M)
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 1600, 1200, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 1280, 960, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 1280, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M) || defined(CONFIG_CAMERA_SUPPORT_1M)
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 960, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 864, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M) || defined(CONFIG_CAMERA_SUPPORT_1M) \
    || defined(CONFIG_CAMERA_SUPPORT_0M4)
    //{HAL_PIXEL_FORMAT_YCbCr_420_888, 800, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_YCbCr_420_888, 720, 544, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 720, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
    // please at least use 0.3M sensor.
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 480, 640, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 352, 288, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 240, 320, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_YCbCr_420_888, 176, 144, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},

    // configure table for capture.
#if defined(CONFIG_CAMERA_SUPPORT_13M)
    {HAL_PIXEL_FORMAT_BLOB, 4160, 3120, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M)
    {HAL_PIXEL_FORMAT_BLOB, 3264, 2448, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_BLOB, 3264, 1836, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},//for ss
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M)
    {HAL_PIXEL_FORMAT_BLOB, 2592, 1944, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_BLOB, 2560, 1536, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_BLOB, 2448, 2448, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},//for ss
#endif
#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    ||  defined(CONFIG_CAMERA_SUPPORT_3M)
    {HAL_PIXEL_FORMAT_BLOB, 2048, 1536, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    //{HAL_PIXEL_FORMAT_BLOB, 2048, 1152, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},//for ss
    {HAL_PIXEL_FORMAT_BLOB, 1920, 1088, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined (CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M)
    {HAL_PIXEL_FORMAT_BLOB, 1600, 1200, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_BLOB, 1280, 960, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_BLOB, 1280, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M) || defined(CONFIG_CAMERA_SUPPORT_1M)
    {HAL_PIXEL_FORMAT_BLOB, 960, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_BLOB, 864, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

#if defined(CONFIG_CAMERA_SUPPORT_13M) || defined(CONFIG_CAMERA_SUPPORT_8M) || defined(CONFIG_CAMERA_SUPPORT_5M) \
    || defined(CONFIG_CAMERA_SUPPORT_3M) || defined(CONFIG_CAMERA_SUPPORT_2M) || defined(CONFIG_CAMERA_SUPPORT_1M) \
    || defined(CONFIG_CAMERA_SUPPORT_0M4)
    {HAL_PIXEL_FORMAT_BLOB, 720, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
#endif

    // please at least use 0.3M sensor.
    {HAL_PIXEL_FORMAT_BLOB, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT}, //for CTS
    {HAL_PIXEL_FORMAT_BLOB, 480, 640, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT}, //for volte
    {HAL_PIXEL_FORMAT_BLOB, 352, 288, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_BLOB, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_BLOB, 240, 320, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_BLOB, 176, 144, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
};

我贴出来的是其中的一个kavailable_back_stream_configurations数组,以这个为例,我们先看这个数组的代码。
这里有四种格式的数据:

HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED  //预览尺寸
{HAL_PIXEL_FORMAT_YV12                   //
{HAL_PIXEL_FORMAT_YCbCr_420_888          //录像尺寸
HAL_PIXEL_FORMAT_BLOB                    //拍照尺寸

这四中格式下面每种格式都有很多分辨率的,而且这个里面有很多if ,else的宏定义需要一点C/C++的知识,并且耐心看代码。
先看后摄500W的HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED数据,类似上面的数据中定义到的500W的尺寸有:

{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 2592, 1944, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
{HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1600, 1200, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1280, 960, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 1280, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 960, 720, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 864, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 720, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 480, 640, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 352, 288, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 240, 320, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},
    {HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 176, 144, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT},

这里面总共有13组数据,2592x1944 - - 176x144。
同样的这个数组里面的其他剩余的3中格式的数据,500W定义的也要是这13组分辨率,要保持一致,不能一组分辨率在这个格式里面有,在另外一个格式里面没有按照这样的原则去配置。
其实继续看这个SprdCamera3Setting.cpp里面的代码,我们可以发现前后摄对应的都有三个相同的数组。
后摄:kavailable_back_stream_configurations
     kavailable_back_min_frame_durations
     kavailable_back_stall_durations

前摄:kavailable_front_stream_configurations  
     kavailable_front_min_frame_durations      
     kavailable_front_stall_durations
这三个数组都按照前面的方法配齐,这样既可以保证不会分辨率的fail 项了。

三、其他问题
这里面有一个android.hardware.camera2.cts.AllocationTest#testAllocationFromCameraFlexibleYuv
fail
junit.framework.AssertionFailedError: Input allocation data was not updated

testAllocationFromCameraFlexibleYuv要求callback数据不能为全黑数据,否则case会失败, 
使用如下宏打开该规避方案: 
TARGET_FORCE_PASS_FLEXIBLEYUV_IN_DARK := true 
该宏在Boardconfig.mk定义 同时修改libcamera 下oemv20目录下 cmr_priview.c文件, 
cmr_int prev_pop_zsl_buffer(struct prev_handle *handle, cmr_u32 camera_id, struct frm_info *data, cmr_u32 is_to_hal) 
{ 

    CMR_LOGD("valid_num %ld", valid_num); 

    if (prev_cxt->cap_zsl_frm[0].addr_phy.addr_y == data->yaddr && valid_num > 0) { 
        frame_type.y_phy_addr = prev_cxt->cap_zsl_phys_addr_array[0]; 
        frame_type.y_vir_addr = prev_cxt->cap_zsl_virt_addr_array[0]; 
++        frame_type.width = prev_cxt->prev_param.picture_size.width; 
++        frame_type.height = prev_cxt->prev_param.picture_size.height; 
        frame_type.type       = PREVIEW_ZSL_CANCELED_FRAME; 

}

最后我们来总结一下,通篇博客的内容其实很简单。关于CTS Camera 模块的配置就是一句话:固定帧率,对齐分辨率
如果你对这个分辨率的配置还是不太明白,请下载Android 7.0 GMS CtsCameraTestCases模块配置分辨率文档仔细阅读,应该是很容易明白的。
也可以参考我的SprdCamera3Setting.cpp代码去看里面的30w和500w的像素分辨率是怎么配置的。 

如果上述博客里面的内容说明有误,请博客评论或者私信我,欢迎指教和探讨。