【Camera专题】Qcom-你应该掌握的Camera调试技巧2

系列文章
【Camera专题】Qcom-你应该掌握的Camera调试技巧1
【Camera专题】Qcom-你应该掌握的Camera调试技巧2

0.APP端增加性能分析log

增加性能日志:Tag:[KPI_CAMERA]
日志打印:

  1. 打开摄像头:CAMERA_OPEN
  2. 第一帧回调:onFirstPreviewFrame
  3. 切换摄像头:SWITCH_CAMERA
  4. 拍照:TAKE_PICTURE
  5. 拍照完成:TAKE_PICTURE_FINISH
  6. 小视频开始录制:START_RECORD
  7. 小视频录制完成:RECORD_COMPLETE

1.dump YUV 数据(添加第三方算法时,dump数据)

//zcf
void dumpFile(void* frame,int w,int h,int size,int base_index)
{
    char buf[128];
    int res=0;
    snprintf(buf, sizeof(buf), "%s%d_%dx%d.yuv","/data/misc/camera/",base_index, w, h);
    int file_fd = open(buf,O_RDWR | O_CREAT,0777);
    if(file_fd == -1){ 
        LOGI("zcf open file failed file_fd=%d",file_fd);
    }    
    res = write(file_fd,frame,size);
    if(res !=size)
        LOGI("zcf dumpFile failed!res=%d",res);
    close(file_fd);
}
//

2.修改I2C速率

kernel/arch/arm/boot/dts/qcom/msm8909.dtsi

i2c_3: i2c@78b7000 { /* BLSP1 QUP3 */
···
- qcom,clk-freq-out = <100000>;
+ qcom,clk-freq-out = <400000>;//修改成400k
  qcom,clk-freq-in  = <19200000>;
  pinctrl-names = "i2c_active", "i2c_sleep";
···
}

3.修改I2C占空比

I2C资料:80-NU767-1,参考68-69页

举个例子:
i2c速率(I2C_FS_CLK ):400k
I2C_CLK:24M
占空比改成:50%

I2C_FS_CLK = I2C_CLK/(fs_div+hs_div+6)
fs_div + hs_div = 24M/400k - 6 = 60-6=54
如果占空比为50%

fs_div=hs_div=54/2=27

kernel/arch/arm/boot/dts/qcom/msm8909.dtsi

i2c_3: i2c@78b7000 { /* BLSP1 QUP3 */
···
 qcom,clk-freq-out = <400000>;//修改成400k
 //snip
 qcom,fs-clk-div = <27>;
 qcom,high-time-clk-div = <27>;
···
}

I2C节点解释:
kernel/Documentation/devicetree/bindings/i2c/i2c-msm-v2.txt

qcom,high-time-clk-div : 
  high time divider value to configure clk-ctl register. 
  When missing, default to the value given in driver.
qcom,fs-clk-div: 
  fs divider value to configure clk-ctl register. 
  When missing, default to the value given in driver.

4.生成与合入patch

git diff > a.patch
patch -p1 < a.patch

5.新平台开启HAL的log

80  static module_debug_t cam_loginfo[(int)CAM_LAST_MODULE] = {
81    {CAM_GLBL_DBG_ERR, 1,
82        "",         "persist.vendor.camera.global.debug"     }, /* CAM_NO_MODULE     */
83    {CAM_GLBL_DBG_ERR, 1,
84        "<MCT   >", "persist.vendor.camera.mct.debug"        }, /* CAM_MCT_MODULE    */
85    {CAM_GLBL_DBG_ERR, 1,
86        "<SENSOR>", "persist.vendor.camera.sensor.debug"     }, /* CAM_SENSOR_MODULE */
87    {CAM_GLBL_DBG_WARN, 1,
88        "<IFACE >", "persist.vendor.camera.iface.logs"       }, /* CAM_IFACE_MODULE  */
89    {CAM_GLBL_DBG_ERR, 1,
90        "<ISP   >", "persist.vendor.camera.isp.debug"        }, /* CAM_ISP_MODULE    */
91    {CAM_GLBL_DBG_ERR, 1,
92        "<PPROC >", "persist.vendor.camera.pproc.debug.mask" }, /* CAM_PPROC_MODULE  */
93    {CAM_GLBL_DBG_WARN, 1,
94        "<IMGLIB>", "persist.vendor.camera.imglib.logs"      }, /* CAM_IMGLIB_MODULE */
95    {CAM_GLBL_DBG_WARN, 1,
96        "<CPP   >", "persist.vendor.camera.cpp.debug.mask"   }, /* CAM_CPP_MODULE    */
97    {CAM_GLBL_DBG_ERR, 1,
98        "<HAL   >", "persist.vendor.camera.hal.debug"        }, /* CAM_HAL_MODULE    */
99    {CAM_GLBL_DBG_ERR, 1,
100        "<JPEG  >", "persist.vendor.camera.mmstill.logs"     }, /* CAM_JPEG_MODULE   */
101    {CAM_GLBL_DBG_WARN, 1,
102        "<C2D   >", "persist.vendor.camera.c2d.debug.mask"   }, /* CAM_C2D_MODULE    */
103    {CAM_GLBL_DBG_ERR, 1,
104        "<STATS >", "persist.vendor.camera.stats.debug" }, /* CAM_STATS_MODULE  */
105    {CAM_GLBL_DBG_ERR, 1,
106        "<STATS_AF >", "persist.vendor.camera.stats.af.debug"    }, /* CAM_STATS_AF_MODULE   */
107    {CAM_GLBL_DBG_ERR, 1,
108        "<STATS_AEC >", "persist.vendor.camera.stats.aec.debug"  }, /* CAM_STATS_AEC_MODULE  */
109    {CAM_GLBL_DBG_ERR, 1,
110        "<STATS_AWB >", "persist.vendor.camera.stats.awb.debug"  }, /* CAM_STATS_AWB_MODULE  */
111    {CAM_GLBL_DBG_ERR, 1,
112        "<STATS_ASD >", "persist.vendor.camera.stats.asd.debug"  }, /* CAM_STATS_ASD_MODULE  */
113    {CAM_GLBL_DBG_ERR, 1,
114        "<STATS_AFD >", "persist.vendor.camera.stats.afd.debug"  }, /* CAM_STATS_AFD_MODULE  */
115    {CAM_GLBL_DBG_ERR, 1,
116        "<STATS_Q3A >", "persist.vendor.camera.stats.q3a.debug"  }, /* CAM_STATS_Q3A_MODULE  */
117    {CAM_GLBL_DBG_ERR, 1,
118        "<STATS_AIS >", "persist.vendor.camera.stats.is.debug"   }, /* CAM_STATS_IS_MODULE   */
119    {CAM_GLBL_DBG_ERR, 1,
120        "<STATS_HAF >", "persist.vendor.camera.stats.haf.debug"  }, /* CAM_STATS_HAF_MODULE  */
121    {CAM_GLBL_DBG_ERR, 1,
122        "<STATS_CAFSCAN >", "persist.vendor.camera.stats.cafscan"  }, /* CAM_STATS_CAFSCAN_MODULE  */
123    {CAM_GLBL_DBG_ERR, 1,
124        "<SHIM  >", "persist.vendor.camera.shim.debug"          }, /* CAM_SHIM_LAYER    */
125
126  };


2575static module_debug_t cam_loginfo[(int)CAM_LAST_MODULE] = {
2576  {CAM_GLBL_DBG_ERR, 1,
2577      "",         "persist.vendor.camera.global.debug"     }, /* CAM_NO_MODULE     */
2578  {CAM_GLBL_DBG_ERR, 1,
2579      "<HAL>", "persist.vendor.camera.hal.debug"        }, /* CAM_HAL_MODULE    */
2580  {CAM_GLBL_DBG_ERR, 1,
2581      "<MCI>", "persist.vendor.camera.mci.debug"        }, /* CAM_MCI_MODULE    */
2582  {CAM_GLBL_DBG_ERR, 1,
2583      "<JPEG>", "persist.vendor.camera.mmstill.logs"     }, /* CAM_JPEG_MODULE   */
2584};

13966void QCamera3HardwareInterface::getLogLevel()
13967{
13968    char prop[PROPERTY_VALUE_MAX];
13969    uint32_t globalLogLevel = 0;
13970
13971    property_get("persist.vendor.camera.hal.debug", prop, "0");
13972    int val = atoi(prop);
13973    if (0 <= val) {
13974        gCamHal3LogLevel = (uint32_t)val;
13975    }
13976
13977    property_get("persist.vendor.camera.kpi.debug", prop, "0");
13978    gKpiDebugLevel = atoi(prop);
13979
13980    property_get("persist.vendor.camera.global.debug", prop, "0");
13981    val = atoi(prop);
13982    if (0 <= val) {
13983        globalLogLevel = (uint32_t)val;
13984    }
13985
13986    /* Highest log level among hal.logs and global.logs is selected */
13987    if (gCamHal3LogLevel < globalLogLevel)
13988        gCamHal3LogLevel = globalLogLevel;
13989
13990    return;
13991}

6.在系统中定义一个宏变量

7.查看pdaf版本库 和关键log

查看pd lib库
adb shell setprop persist.vendor.camera.pdaf_logging 1
then reset device. version will be print out like “PDLib Version: Major: %d Minor: %d Revision: %d”

lib库和校准工具对应关系
PD_lib_version Calibration_Version
3.3 J
4.2 J,L3
4.4 J,L3
4.5 J,L3,L4
4.6 J,L3,L4
4.7 J,L3,L4
5.0 L3,L4
5.1 L3,L4
5.2 L3,L4
5.3 L3,L4

关键log

007569 02-22 05:54:51.576  3809  4611 D mm-camera: <STATS_HAF >< HIGH> 3552: 
af_pdaf_proc_pd_single: roi(0) lens_pos=6 index=18,
 pd=16.00, defocus(um)=328, conf=1023, is_conf=TRUE, not_conf_cnt=0, is_stable=TRUE

注意,如果pdaf版本库在4.5-5.3之间,OV的sensor left map和right map 和高通是相反的
即:

8.op_pixel_clk 的计算公式

op_pixel_clk = (传感器总数据传输速率) / 每个像素的位数
op_pixel_clk = sensor_MIPI_speed*lanes/每个像素的位数

传感器总数据传输速率 = sensor_MIPI_speed*lanes

vt_pixel_clk= HTS(0x380c/0x380d)* VTS(0x380e/0x380f)*FPS
op_pixel_clk=sensor_MIPI_speed*lanes/bits-per-pixel

9.查看当前应用包名

adb shell dumpsys window | findstr mCurrentFocus

10.driver only版本抓取kernel log

adb shell dmesg > kernel.log

11.AF

1.对焦速度 af_haf_util_end_search

12.eis生效log

adb root
adb shell setprop persist.vendor.camera.stats.is.debug 5

关键log: eis2_process

13.骁龙相机安装失败


经过odex 的apk ,这样apk 是不完整的。
相机 mk 里加上 LOCAL_DEX_PREOPT := false

14.查看平台效果库

module_sensor_load_chromatix_stream_on

15.AF roi

1.最终的 AF ROI 坐标和大小,如何从 log 中获取?
key word:

af_util_adjust_roi|af_util_update_def_roi_ratios|af_util_check_if_input_is_default_roi|af_util_get_roi_default|Low-light
mm-camera: <STATS_AF >< HIGH> 2590: af_util_adjust_roi: Input ROI - x: 0 y: 0 dx: 0 dy: 0 weight 0 pd enable
mm-camera: <STATS_AF >< HIGH> 2591: af_util_adjust_roi: CAMIF size: 3264 x 2448
mm-camera: <STATS_AF >< HIGH> 2594: af_util_adjust_roi: ROI adjustment 1 ROI_TYPE: 0
mm-camera: <STATS_AF >< LOW> 2628: af_util_adjust_roi: lighting_cond_chgd: 0 spot_light_flag: 0
mm-camera: <STATS_AF >< LOW> 2650: af_util_adjust_roi: roi_updated: 1 need_to_configure_filter: 0
mm-camera: <STATS_AF >< LOW> 2659: af_util_adjust_roi: ROI needs to be updated!
mm-camera: <STATS_AF >< HIGH> 2668: af_util_adjust_roi: Input Zoom factor: 1.666667
mm-camera: <STATS_AF >< LOW> 689: af_util_update_def_roi_ratios: Default ROI ratios:
mm-camera: <STATS_AF >< LOW> 2677: af_util_adjust_roi: ROI limit check failed. Using Center ROI!
mm-camera: <STATS_AF >< LOW> 1191: af_util_check_if_input_is_default_roi: CAMIF size: 3264x2448 FOV ctr: 1632x1224 ROI ctr: 1632x1224
mm-camera: <STATS_AF >< LOW> 1196: af_util_check_if_input_is_default_roi: Distance between two ctr: 0
mm-camera: <STATS_AF >< LOW> 2787: af_util_adjust_roi: Default ROI
mm-camera: <STATS_AF >< LOW> 2793: af_util_adjust_roi: zoom_ratio = 0.600000, mw_zoom_threshold = 0.000000
mm-camera: <STATS_AF >< LOW> 2798: af_util_adjust_roi: PD MW is disabled!
mm-camera: <STATS_AF >< HIGH> 2328: af_util_get_roi_default: Input Zoom factor: 1.666667
mm-camera: <STATS_AF >< LOW> 2380: af_util_get_roi_default: Default ROI type: -1 index: 0 x: 1088 y: 816 dx: 1088 dy: 816
mm-camera: <STATS_AF >< HIGH> 2880: af_util_adjust_roi: Calculated new ROI: (1088, 816, 1088 816)
mm-camera: <STATS_AF >< LOW> 2883: af_util_adjust_roi: Request ISP to configure new ROI

0.200000f, /* H Clip Ratio Normal Light /
0.200000f,/
V Clip Ratio Normal Light /
0.500000f,/
H Clip Ratio Lowlight /
0.500000f, /
V Clip Ratio Lowlight */

1、请问 Calculated new ROI 的大小是怎么计算的?
ctr_x = image_width / 2;
ctr_y = image_height / 2;
dx = image_width * h_ratio * zoom_factor;
dy = image_height * v_ratio * zoom_factor;
x = ctr_x < (roi_out->dx / 2) ? 0 : (ctr_x - (roi_out->dx / 2));
y = ctr_y < (roi_out->dy / 2) ? 0 : (ctr_y - (roi_out->dy / 2));
2、假设 CAF 默认以中心为 ROI,那么 APP 有接口可以修改 ROI 的位置吗?
As you can see from 1(formula), no parameters are passed to change this value.

16.dump OTP 数据

adb shell setprop persist.vendor.camera.cal.dump 1
数据路径:"/data/misc/camera/" 或者"/data/vendor/camera/"

17.dump h264编码前后数据

8909:

echo on
adb wait-for-device
adb root
adb remount

adb shell chmod 777 /data/misc/media
adb shell setenforce 0
adb shell setprop vidc.enc.log.in 1
adb shell setprop vidc.enc.log.out 1
pause

新:

echo on
adb wait-for-device
adb root
adb remount

adb shell chmod 777 /data/vendor/media
adb shell setenforce 0
adb shell setprop vendor.vidc.enc.log.in 1
adb shell setprop vendor.vidc.enc.log.out 1
pause

18.user root

adb root

19.确认dtsi文件

1.开机log里面搜索fdt
OF: fdt:Machine model: Qualcomm Technologies, Inc. SDM429 QRD Spyro DVT Overlay
2.搜索"Qualcomm Technologies, Inc. SDM429 QRD Spyro DVT Overlay"

3.打开kernel/msm-4.9/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-dvt-overlay.dts

4.打开sdm429-spyro-qrd-evt.dtsi

20.打印进程调用栈

adb shell debuggerd -b

21.固定帧率

persist.vendor.debug.set.fixedfps

22.抓log的骚姿势

adb logcat -c && adb logcat -G 256M && adb logcat -v threadtime -b main -b crash -b kernel 1 > log.txt

23.VFE clock的计算

24.ae收敛帧数计算

aec_settle

25.ISO计算

ISO = (analog_gain*100)/ISO_100_gain。
效果参数中 ISO_100_gain =1

26.sprd增加一组支持的尺寸

27.adb命令查看 camera 支持的尺寸

adb shell dumpsys media.camera

28.使能HAL3

adb shell setprop persist.vendor.camera.HAL3.enabled 1

29.如何调出系统原生相机

  • qcom:
    vendor/qcom/proprietary/common/config/device-vendor.mk
MM_CAMERA += SnapdragonCamera

adb uninstall org.codeaurora.snapcam
//高通骁龙相机位置
vendor/qcom/proprietary/common/config/device-vendor.mk
#MM_CAMERA += SnapdragonCamera
packages/apps/SnapdragonCamera/AndroidManifest.xml
android:targetSdkVersion="21"
  • sprd
diff --git a/build/target/product/generic_no_telephony.mk b/build/target/product/generic_no_telephony.mk
index adf8116..d2ad6b0 100755
--- a/build/target/product/generic_no_telephony.mk
+++ b/build/target/product/generic_no_telephony.mk

@@ -21,7 +21,6 @@ PRODUCT_POLICY := android.policy_phone
 
 PRODUCT_PACKAGES := \
     Bluetooth \
-    Camera2 \
     Exchange2 \
     FusedLocation \
     LatinIME \
@@ -45,6 +44,7 @@ PRODUCT_PACKAGES := \
 #InputDevices \
 #Keyguard \
 #Settings \
+#Camera2 \

30.mmm编译的一些小技巧

当我们用mmm编译时,可能找不到某些依赖,又不想又mmma编译。
比如:
mmm packages/apps/Camera2

这里找不到littlemock_intermediates,我们可以去搜源码,找到littlemock

先编译
mmm external/littlemock/

在这里插入图片描述

再编译 mmm packages/apps/Camera2

在这里插入图片描述

继续当一名咸鱼(* ̄︶ ̄)!
常常因为自己很菜,流下难过的泪水。

Stay Hungry,Stay Foolish!

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值