和你一起终身学习,这里是程序员Android
经典好文推荐,通过阅读本文,您将收获以下知识点:
一、硬件功耗
二、相机软件功耗
三、参考文档
一、硬件功耗
1.1 硬件信息
以下硬件信息最好提前获取到
模块 | 备注 |
---|---|
平台 | MTK or Qcom or sprd |
CPU频率 | 大中小核 |
L2 Cache size | CPU缓存 |
DDR | DRAM 类型,品牌 |
屏幕 | 类型,品牌 |
相机Sensor | 型号,出图size,帧率,几M |
1.2 硬件功耗拆解
硬件电流一般需要使用功耗拆解板测试,使用功耗拆解版软件+工具 可以拆解详细硬件模块的功耗,数据格式如下:
模块 | 备注 |
---|---|
0_BAT | |
1_BB | CPU 功耗 |
2_MEMORY | 内存 |
3_LCM | 屏 |
4_AUDIO | 多媒体 |
5_CAMERA | 相机 |
6_RF | 射频 |
7_WIFI | wifi |
8_SENSOR | 传感器 |
9_SIM | SIM 卡 |
10_USB | USB |
11_PMU | 电源管理单元 |
12_FLASH_LED | 闪光灯 |
二、相机软件功耗
2.1 影响相机功耗的点
1.CPU 差异(MIPS百万指令每秒:可以准确的表现当时CPU的运算量)
2.Camera 模组差异
3.Camera APP 差异
4.Camera HAL 差异
5.Camera算法差异
6.PDAF差异
7.Camera Feature、SensorSize、RRZO Size、Camera FPS、P2 display size 、p2 preview callback size ,预览拍照 size 等差异
2.2 MTK 相机功耗拆解模板

2.3 功耗log关键字总结
Log 关键字
connect call|select size|MtkCam/StreamingPipe/Timer.*Frame timer|imgoDefaultRequest|prepareIORequest.*Outs|control.enableZsl|ZSL mode enable|feature=
log举例
//1. com.android.camera camera APP 调用的 API 2
08-09 02:19:08.699 991 4433 I CameraService: CameraService::connect call (PID 4733 "com.android.camera", camera ID 0) and Camera API version 2
//2. 模组setting size与fps:(4080x3072)@30
//3. 模组Setting mode :sensorMode:1
08-09 02:19:08.837 1056 2832 I mtkcam-SensorSettingPolicy4cell: select size(4080x3072)@30 sensorMode:1 hdrSensorMode:0 hdrHalMode:0 HfpsMode:0
//4. IMGO :imgoDefaultRequest={ format:0x2201 4080x3072 }
//5. RRZO :rrzoDefaultRequest={ format:0x2205 1440x1088 }
08-09 02:19:08.838 1056 2832 I mtkcam-P1HwSettingPolicy: { .imgoAlloc={ format:0x2201 4080x3072 } .imgoDefaultRequest={ format:0x2201 4080x3072 } .imgoSeamlessRequest={ format:0 0x0 } .rrzoDefaultRequest={ format:0x2205 1440x1088 } .rssoSize=288x512 .pixelMode=2 .usingCamSV=0 }
//6. ZSL mode : ZSL mode enable = 0 control.enableZsl:0
08-09 02:19:08.839 1056 2832 I mtkcam-PipelineModelSession4Cell: [configure] ZSL mode enable = 0
08-09 02:19:08.893 1056 3615 I mtkcam-PipelineModelSession: [submitRequest] <4Cell/0> requestNo:0 { repeating:0 control.aeTargetFpsRange:5,30 control.captureIntent:1 control.enableZsl:0 control.processRawEn:0 control.mode:1 control.sceneMode:0 control.videoStabilizationMode:0 edge.mode:1 }
08-09 02:19:08.900 1056 2835 I mtkcam-PipelineModelSession: [submitRequest] <4Cell/0> requestNo:1 { repeating:0 control.aeTargetFpsRange:5,30 control.captureIntent:1 control.enableZsl:0 control.processRawEn:0 control.mode:1 control.sceneMode:0 control.videoStabilizationMode:0 edge.mode:1 }
//7. StreamFeature : feature=0x1008(TPI_YUV+3DNR)
//8. Preview&&Display Callback: buf(0xb400007a589920d0/1)(1440x1080),tran(0),type(1), tar(disp)
08-09 02:19:09.064 1056 5261 D MtkCam/StreamingPipe/Pipe: [prepareIORequest]P2S cam 0 MWFrame:#0 MWReq:#0, frame 1-1 master/slave/fd(0/-1/0) ReqNo(1), feature=0x1008(TPI_YUV+3DNR), cycle(33), fps(n/a)=(30/30), ZoomROI((1440.000000x1082.000000)@(0.000000,2.000000)) SFPIOMgr:[sID(0)--IMG(0x0/0),RRZ(0xb400007a589b6670/1),LCS(0xb400007a5898cc70/1),LCSH(0xb400007a589b4810/1),pRSS(0x0/0),cRSS(0x0/0),RSSR2(0x0/0),FYuv(0x0/0),RYuv1(0x0/0),RYuv2(0x0/0),mAIYuv(0x0/0),HalI(0xb4000079a8996c10),AppI(0xb4000079889a5ab8),AppDI(0xb4000079a898ff90),AppOver(0x0)]{path(GEN),halO(0xb40000798898d830),appO(0xb4000079889a7370),Outs--[buf(0xb400007a58994cb0/1)(640x480),tran(0),type(4), tar(fd), prof(0), crop(0.000000,2.000000,1440.000000x1082.000000), flag(0x3)][buf(0xb400007a589920d0/1)(1440x1080),tran(0),type(1), tar(disp), prof(0), crop(0.000000,2.000000,1440.000000x1082.000000), flag(0x3)][buf(0xb400007a58999930/1)(1440x1080),tran(0),type(3), tar(unknown), prof(0), crop(0.000000,2
//9. HAL FPS: [fps24.39/24.39/ 5/ 30]
08-09 02:19:09.090 1056 5256 D MtkCam/StreamingPipe/Timer: [print]Frame timer [# 1/ 0][t 25][io 0][tof 0/ 0][d 0/ 0][mss 0/ 0/ 0/ 0][a 14/ 3/ 9][tun 0/ 0][msf 0/ 0][vnr 0/ 0/ 0][am 0][b 0/ 0][tpi( 3/ 3)/( 0/ 0)/( 0/ 0)][vmdp_A 5/ 0 vmdp_B 0/ 0][h 0/ 0/ 0][e 0][r 0/ 0][w_A 0/ 0/ 0/ 0 w_B 0/ 0/ 0/ 0][x 0][disp 0/ 0][async 0/ 0][p2sm 0/ 0/ 0][fps0.00/0.00/ 5/ 30]
08-09 02:19:09.131 1056 5256 D MtkCam/StreamingPipe/Timer: [print]Frame timer [# 2/ 0][t 28][io 0][tof 0/ 0][d 0/ 0][mss 0/ 0/ 0/ 0][a 9/ 0/ 8][tun 0/ 0][msf 0/ 0][vnr 0/ 0/ 0][am 0][b 0/ 0][tpi( 7/ 6)/( 0/ 0)/( 0/ 0)][vmdp_A 6/ 0 vmdp_B 0/ 0][h 0/ 0/ 0][e 0][r 0/ 0][w_A 0/ 0/ 0/ 0 w_B 0/ 0/ 0/ 0][x 0][disp 0/ 0][async 0/ 0][p2sm 0/ 0/ 0][fps24.39/24.39/ 5/ 30]
2.4 MTK Log 关键字详细拆解
2.4.1 开启MTK 更多log的方法
C:\Users\platform-tools>adb shell setprop persist.vendor.debug.camera.log 3
C:\Users\platform-tools>adb shell pkill camera*
C:\Users\platform-tools>adb logcat -c
2.4.2 SensorSize、SensorMode、FPS、RRZO、IMGO、相机API
log 关键字:
P1NodeImp.*check_config|select size|connect call|imgoDefaultRequest |P1::ENQ
Log 举例
//1. com.android.camera camera APP 调用的 API 2
08-09 02:19:08.699 991 4433 I CameraService: CameraService::connect call (PID 4733 "com.android.camera", camera ID 0) and Camera API version 2
//2. 模组setting size与fps:(4080x3072)@30
//3. 模组Setting mode :sensorMode:1
08-09 02:19:08.837 1056 2832 I mtkcam-SensorSettingPolicy4cell: select size(4080x3072)@30 sensorMode:1 hdrSensorMode:0 hdrHalMode:0 HfpsMode:0
//4. IMGO :imgoDefaultRequest={ format:0x2201 4080x3072 }
//5. RRZO :rrzoDefaultRequest={ format:0x2205 1440x1088 }
08-09 02:19:08.838 1056 2832 I mtkcam-P1HwSettingPolicy: { .imgoAlloc={ format:0x2201 4080x3072 } .imgoDefaultRequest={ format:0x2201 4080x3072 } .imgoSeamlessRequest={ format:0 0x0 } .rrzoDefaultRequest={ format:0x2205 1440x1088 } .rssoSize=288x512 .pixelMode=2 .usingCamSV=0 }
2.4.3 ZSL 是否支持
log 关键字:
control.enableZsl|ZSL mode enable|connect call
log 举例
行 468: 08-09 02:19:08.699 991 4433 I CameraService: CameraService::connect call (PID 4733 "com.android.camera", camera ID 0) and Camera API version 2
行 1755: 08-09 02:19:08.839 1056 2832 I mtkcam-PipelineModelSession4Cell: [configure] ZSL mode enable = 0
行 2580: 08-09 02:19:08.893 1056 3615 I mtkcam-PipelineModelSession: [submitRequest] <4Cell/0> requestNo:0 { repeating:0 control.aeTargetFpsRange:5,30 control.captureIntent:1 control.enableZsl:0 control.processRawEn:0 control.mode:1 control.sceneMode:0 control.videoStabilizationMode:0 edge.mode:1 }
行 2657: 08-09 02:19:08.900 1056 2835 I mtkcam-PipelineModelSession: [submitRequest] <4Cell/0> requestNo:1 { repeating:0 control.aeTargetFpsRange:5,30 control.captureIntent:1 control.enableZsl:0 control.processRawEn:0 control.mode:1 control.sceneMode:0 control.videoStabilizationMode:0 edge.mode:1 }
行 5566: 08-09 02:19:09.119 1056 3615 I mtkcam-PipelineModelSession: [submitRequest] <4Cell/0> requestNo:6 { repeating:0 control.aeTargetFpsRange:5,30 control.captureIntent:1 control.enableZsl:0 control.processRawEn:0 control.mode:1 control.sceneMode:0 control.videoStabilizationMode:0 edge.mode:1 }
MTK 备用 log 关键字:
MtkCam/ppl_context.*dump|ZslProc
能搜索到 ZslProc,或者image stream中看到provide 就标准支持zsl
Log 举例
01-01 08:29:27.268390 12029 12029 I MtkCam/ZslProc: [ZslProcessor] mTimeSource(1) mFakeShutterNs(1522451160782)
01-01 08:29:27.268910 12029 12029 I MtkCam/ZslProc: [configure] mCustomLibHandle(0x0) mpCustomSelector(0x0)
01-01 08:29:27.275592 12029 12029 I MtkCam/ppl_context: [dump] <image streams>
01-01 08:29:27.275647 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-APP-PROVIDER]0 960x720 OUT ImgFormat:0x1000(NV12) BufPlanes(strides/sizeInBytes):[ 960/691200 960/345600 ] startOffset:0 bufStep:0 t:0/r:0 maxBuffers:12 d/s:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) s0:d0:App:NV12:0|SW_READ_OFTEN|HW_TEXTURE AllocImgFormat:0x1000(NV12) AllocBufPlanes(strides/sizeInBytes):[ 960/691200 960/345600 ] Real:0x1000(NV12) Request:0x23(YCbCr_420_888) Override:0x23(YCbCr_420_888) Hal-Client-usage:0x103(0|SW_READ_OFTEN|HW_TEXTURE) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 0xb40000705fc4f480 phy:-1
01-01 08:29:27.275684 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-APP-PROVIDER]0x1 4080x3072 OUT ImgFormat:0x11(NV21) BufPlanes(strides/sizeInBytes):[ 4096/12582912 4096/6297600 ] startOffset:0 bufStep:0 t:0/r:0 maxBuffers:12 d/s:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) s1:d0:App:YCrCb_420_SP:0|SW_READ_OFTEN AllocImgFormat:0x11(NV21) AllocBufPlanes(strides/sizeInBytes):[ 4096/12582912 4096/6297600 ] Real:0x11(YCrCb_420_SP) Request:0x23(YCbCr_420_888) Override:0x23(YCbCr_420_888) Hal-Client-usage:0x3(0|SW_READ_OFTEN) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 0xb40000705fc4f2c0 phy:-1
01-01 08:29:27.275719 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-APP-PROVIDER]0x2 4080x3072 OUT ImgFormat:0x2201(BAYER10) BufPlanes(strides/sizeInBytes):[ 5120/15728640 ] startOffset:0 bufStep:0 t:0/r:0 maxBuffers:8 d/s:0x00000001(ARBITRARY) s2:d0:App:RAW10:0|SW_READ_OFTEN AllocImgFormat:0x21(BLOB) AllocBufPlanes(strides/sizeInBytes):[ 15728640/15728640 ] Real:0x25(RAW10) Request:0x25(RAW10) Override:0x25(RAW10) Hal-Client-usage:0x3(0|SW_READ_OFTEN) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 0xb40000705fc4f100 phy:-1
01-01 08:29:27.275759 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-APP-PROVIDER]0x3 1280x720 OUT ImgFormat:0x32315659(YV12) BufPlanes(strides/sizeInBytes):[ 1280/921600 640/230400 640/263040 ] startOffset:0 bufStep:0 t:0/r:0 maxBuffers:12 d/s:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) s3:d0:App:YV12:0|SW_READ_OFTEN AllocImgFormat:0x32315659(YV12) AllocBufPlanes(strides/sizeInBytes):[ 1280/921600 640/230400 640/263040 ] Real:0x32315659(YV12) Request:0x32315659(YV12) Override:0x32315659(YV12) Hal-Client-usage:0x3(0|SW_READ_OFTEN) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 0xb40000705fc4ca80 phy:-1
01-01 08:29:27.275797 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-APP-PROVIDER]0x4 2560x1920 OUT ImgFormat:0x32315659(YV12) BufPlanes(strides/sizeInBytes):[ 2560/4915200 1280/1228800 1280/1232640 ] startOffset:0 bufStep:0 t:0/r:0 maxBuffers:12 d/s:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) s4:d0:App:YV12:0|SW_READ_OFTEN AllocImgFormat:0x32315659(YV12) AllocBufPlanes(strides/sizeInBytes):[ 2560/4915200 1280/1228800 1280/1232640 ] Real:0x32315659(YV12) Request:0x32315659(YV12) Override:0x32315659(YV12) Hal-Client-usage:0x3(0|SW_READ_OFTEN) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 0xb40000705fc4c700 phy:-1
01-01 08:29:27.275831 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-HAL-POOL ]0x100000001 4080x3072 ImgFormat:0x2201(BAYER10) BufPlanes(strides/sizeInBytes):[ 5104/15679488 ] startOffset:0 bufStep:0 t:0 maxBufNum:10 minInitBufNum:0 Hal:Image:P1:Fullraw_main1 AllocImgFormat:0x21(BLOB) AllocBufPlanes(strides/sizeInBytes):[ 15679488/15679488 ] Private{exist?0 id:0}
01-01 08:29:27.275855 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-HAL-POOL ]0x100000003 1280x976 ImgFormat:0x2205(FG_BAYER10) BufPlanes(strides/sizeInBytes):[ 2400/2342400 ] startOffset:0 bufStep:0 t:0 maxBufNum:12 minInitBufNum:0 Hal:Image:P1:Resizeraw_main1 AllocImgFormat:0x2205(FG_BAYER10) AllocBufPlanes(strides/sizeInBytes):[ 2400/2342400 ] Private{exist?0 id:0}
01-01 08:29:27.275879 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-HAL-POOL ]0x100000004 696696x1 ImgFormat:0x21(BLOB) BufPlanes(strides/sizeInBytes):[ 696696/696696 ] startOffset:0 bufStep:0 t:0 maxBufNum:12 minInitBufNum:1 Hal:Image:STT_main1 AllocImgFormat:0x21(BLOB) AllocBufPlanes(strides/sizeInBytes):[ 696696/696696 ] Private{exist?1 id:2}
01-01 08:29:27.275903 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-HAL-POOL ]0x100000005 288x512 ImgFormat:0x2400(STA_BYTE) BufPlanes(strides/sizeInBytes):[ 288/147456 ] startOffset:0 bufStep:0 t:0 maxBufNum:7 minInitBufNum:1 Hal:Image:RSSO_main1 AllocImgFormat:0x2400(STA_BYTE) AllocBufPlanes(strides/sizeInBytes):[ 288/147456 ] Private{exist?0 id:0}
01-01 08:29:27.275927 12029 12029 I MtkCam/ppl_context: [dump] [IMAGE-HAL-POOL ]0x100000014 640x488 ImgFormat:0x14(YUY2) BufPlanes(strides/sizeInBytes):[ 1280/624640 ] startOffset:0 bufStep:0 t:0 maxBufNum:5 minInitBufNum:1 Hal:Image:P1FDYuv_main1 AllocImgFormat:0x14(YUY2) AllocBufPlanes(strides/sizeInBytes):[ 1280/624640 ] Private{exist?0 id:0}
2.4.4 Feature && Display Callback size
log 关键字:
prepareIORequest
Log 举例
//7. StreamFeature : feature=0x1008(TPI_YUV+3DNR)
//8. Preview&&Display Callback: buf(0xb400007a589920d0/1)(1440x1080),tran(0),type(1), tar(disp)
08-09 02:19:09.064 1056 5261 D MtkCam/StreamingPipe/Pipe: [prepareIORequest]P2S cam 0 MWFrame:#0 MWReq:#0, frame 1-1 master/slave/fd(0/-1/0) ReqNo(1),
feature=0x1008(TPI_YUV+3DNR),
cycle(33), fps(n/a)=(30/30), ZoomROI((1440.000000x1082.000000)@(0.000000,2.000000)) SFPIOMgr:[sID(0)--IMG(0x0/0),RRZ(0xb400007a589b6670/1),LCS(0xb400007a5898cc70/1),LCSH(0xb400007a589b4810/1),pRSS(0x0/0),cRSS(0x0/0),RSSR2(0x0/0),FYuv(0x0/0),RYuv1(0x0/0),RYuv2(0x0/0),mAIYuv(0x0/0),HalI(0xb4000079a8996c10),AppI(0xb4000079889a5ab8),AppDI(0xb4000079a898ff90),AppOver(0x0)]{path(GEN),halO(0xb40000798898d830),appO(0xb4000079889a7370),Outs--[buf(0xb400007a58994cb0/1)(640x480),tran(0),type(4), tar(fd), prof(0), crop(0.000000,2.000000,1440.000000x1082.000000), flag(0x3)]
[buf(0xb400007a589920d0/1)(1440x1080),tran(0),type(1), tar(disp), prof(0), crop(0.000000,2.000000,1440.000000x1082.000000), flag(0x3)]
[buf(0xb400007a58999930/1)(1440x1080),tran(0),type(3), tar(unknown), prof(0),
2.4.5 Camera HAL 出图帧率
log关键字
MtkCam/StreamingPipe/Timer.*Frame timer|connect call
//9. HAL FPS: [fps24.39/24.39/ 5/ 30]
08-09 02:19:09.090 1056 5256 D MtkCam/StreamingPipe/Timer: [print]Frame timer [# 1/ 0][t 25][io 0][tof 0/ 0][d 0/ 0][mss 0/ 0/ 0/ 0][a 14/ 3/ 9][tun 0/ 0][msf 0/ 0][vnr 0/ 0/ 0][am 0][b 0/ 0][tpi( 3/ 3)/( 0/ 0)/( 0/ 0)][vmdp_A 5/ 0 vmdp_B 0/ 0][h 0/ 0/ 0][e 0][r 0/ 0][w_A 0/ 0/ 0/ 0 w_B 0/ 0/ 0/ 0][x 0][disp 0/ 0][async 0/ 0][p2sm 0/ 0/ 0][fps0.00/0.00/ 5/ 30]
08-09 02:19:09.131 1056 5256 D MtkCam/StreamingPipe/Timer: [print]Frame timer [# 2/ 0][t 28][io 0][tof 0/ 0][d 0/ 0][mss 0/ 0/ 0/ 0][a 9/ 0/ 8][tun 0/ 0][msf 0/ 0][vnr 0/ 0/ 0][am 0][b 0/ 0][tpi( 7/ 6)/( 0/ 0)/( 0/ 0)][vmdp_A 6/ 0 vmdp_B 0/ 0][h 0/ 0/ 0][e 0][r 0/ 0][w_A 0/ 0/ 0/ 0 w_B 0/ 0/ 0/ 0][x 0][disp 0/ 0][async 0/ 0][p2sm 0/ 0/ 0]
[fps24.39/24.39/ 5/ 30]
2.5 Callback AP Path
这个一般需要通过抓取 trace 来分析

拆解表格举例
后置照片预览 | Sensor size/FPS | sensor mode | HAL FPS | P1 RRZO | P1 IMGO | P2-MDP Display Callback | P2-MDP Preivew Callback | ZSD ON/OFF | Streaming Feature | Callback AP Path | 备注 |
---|---|---|---|---|---|---|---|---|---|---|---|
测试机 | (4080x3072)@30 | 1 | 25 | 1440x1088 | 4080x3072 | 1440x1080 | 1440x1080 | OFF | TPI_YUV+3DNR | SurfaceTexture | - |
对比机 |
三、参考文档
MTK相机功耗优化
【腾讯文档】Camera学习知识库
https://docs.qq.com/doc/DSWZ6dUlNemtUWndv
至此,本篇已结束。转载网络的文章,小编觉得很优秀,欢迎点击阅读原文,支持原创作者,如有侵权,恳请联系小编删除,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!