高通Camera驅(qū)動(dòng)--調(diào)試技術(shù)大全(看完悟了)
本文主要介紹QCOM camera調(diào)試的重要參數(shù);
(1)Lane_assign 和lane_mask
現(xiàn)在攝像頭基本都是mipi接口類(lèi)型,因?yàn)榍昂髷z都對(duì)應(yīng)到平臺(tái)這邊不同的mipi接口,相應(yīng)的數(shù)據(jù)lane需要一一對(duì)應(yīng);
lane assign:

lane_mask:

比如:
101 ? ? ? <LaneMask>0x1F</LaneMask> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 102 ? ? ? <LaneAssign>0x4320</LaneAssign>
0x1F:只有0~4表示有效,對(duì)應(yīng)bit位置為1表示該位的lane或者clock有效,0x1F即表示該mipi接口上的4條data線(xiàn)和clk線(xiàn)都有效;
0x4320:表示sensor這邊幾條data線(xiàn)對(duì)應(yīng)到平臺(tái)這邊mipi接口的第幾路接口端口映射;bit0~3表示lane0對(duì)應(yīng)平臺(tái)這邊mipi的第0接口,bit12~15表示lane 3對(duì)應(yīng)平臺(tái)這邊mipi的第4接口,那第1個(gè)接口就是為時(shí)鐘clk對(duì)接的;
(2)combo_mode
如該平臺(tái)這邊只有一個(gè)mipi phy設(shè)備,有時(shí)候就需要前后攝共用這個(gè)phy,此時(shí)combo_mode就要設(shè)為1,或者在雙攝的情況下:主副攝會(huì)與前攝共用,這個(gè)值也會(huì)設(shè)為1,下面是兩個(gè)camera分配情況:

比如只有一個(gè)PHY interface 的msm8909平臺(tái)就可以這樣配置:
//前攝配置
151 static struct csi_lane_params_t csi_lane_params = {
152 ? .csi_lane_assign = 0x004,
153 ? .csi_lane_mask = 0x18,
154 ? .csi_if = 1, // not used
155 ? .csid_core = {0},
156 ? .csi_phy_sel = 0,
157 };
432 ? .csiphy_params = {
433 ? ? .lane_cnt = 1,
434 ? ? .settle_cnt = 0x1b,//0x1b, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
436 ? ? .combo_mode = 1,
438 ? },
//后攝配置
198 static struct csi_lane_params_t csi_lane_params = {
199 ? .csi_lane_assign = 0x4320,
200 ? .csi_lane_mask = 0x7,
201 ? .csi_if = 1, // not used
202 ? .csid_core = {0},
203 ? .csi_phy_sel = 0,
204 };
334 ? .csiphy_params = {
335 ? ? .lane_cnt = 2, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
336 ? ? .settle_cnt = 0x18,
338 ? ? .combo_mode = 1,
340 ? },
(3)pixel_clk
像素時(shí)鐘(pixel clk): 是經(jīng)過(guò)主時(shí)鐘MCLK(EXTCLK) 經(jīng)過(guò)PLL得到的,決定了該sensor突出數(shù)據(jù)的速度;相關(guān)PLL設(shè)定需要查看sensor 寄存器的data sheet,以s5k2ya為例:

如下為一個(gè)sensor的clk相關(guān)的配置:
static struct sensor_lib_out_info_t sensor_out_info[] = {
{
/* full size @ 24 fps*/
.x_output = 4208,
.y_output = 3120,
.line_length_pclk = 4572,
.frame_length_lines = 3142,
.vt_pixel_clk = 360000000,
.op_pixel_clk = 360000000,
.binning_factor = 1,
.max_fps = 24.01,
.min_fps = 7.5,
.mode = SENSOR_DEFAULT_MODE,
},
vt_pixel_clk(video timing clk value) – Virtual clock value used for calculating shutter time,and used by?
AEC for correcting banding artifacts?
vt_pixel_clk = line_length_pclk * frame_length_lines * frame rate
平臺(tái)根據(jù)寫(xiě)入不同的曝光行來(lái)控制幀率,比如在暗處希望犧牲一點(diǎn)幀率,讓Gain值更高,就用這個(gè)公式來(lái)計(jì)算,最后計(jì)算的 frame_length_lines 寫(xiě)入相應(yīng)寄存器;
注意一點(diǎn)的是不同的平臺(tái)需要一個(gè)最小的blanking time,所以frame_length_lines是要大于真是有效數(shù)據(jù)行y_output,而且差值一般16對(duì)齊;

op_pixel_clk – Represents how much data comes out of the camera over MIPI lanes to set the VFE clock op_pixel_clk = (total data rate from sensor)/bits-per-pixel if the MIPI DDR clock value (speed of the clock lane of the MIPI camera sensor) is 300 MHz, and the sensor transmits on 4 lanes, each lane has a 600 MHz data rate.Thus, the total data rate is 2400 MHz. For 10 bits per pixel Bayer data, this translates to the op_pixel_clk value of 2400/10 = 240 MHz. These values must be filled in accordance with the sensor specifications.
這個(gè)時(shí)鐘決定了sensor mipi data lane 吐出數(shù)據(jù)的帶寬;不同的平臺(tái)的處理能力不一樣,所以這個(gè)值不能超過(guò)平臺(tái)規(guī)范定義的值;

【文章福利】小編推薦自己的Linux內(nèi)核技術(shù)交流群:【891587639】整理了一些個(gè)人覺(jué)得比較好的學(xué)習(xí)書(shū)籍、視頻資料共享在群文件里面,有需要的可以自行添加哦!??!前100名進(jìn)群領(lǐng)取,額外贈(zèng)送一份價(jià)值699的內(nèi)核資料包(含視頻教程、電子書(shū)、實(shí)戰(zhàn)項(xiàng)目及代碼)? ??


(4)settle_cnt
settle_cnt(即穩(wěn)定計(jì)數(shù))–表示mipi開(kāi)始切換到高速模式的一個(gè)穩(wěn)定時(shí)間,必須根據(jù)傳感器輸出特性配置該值,以確保傳感器的 PHY 發(fā)送器與 MSM 的 PHY 接收器無(wú)障礙同步;
settle_cnt – For CSI_Tx (the sensor) and CRI_Rx (the device) to work properly, a period for syncing between them is required. This time is set here as number of timer clock ticks. It has to be between the MIN and MAX values calculated by the formulas:
MIN [Settle count * T(Timer clock)] > T(HS_SETTLE)_MIN
MAX [Settle count * T(Timer clock)] < T(HS-PREPARE)+T(HS_ZERO) - 4*T(Timer clock)
settle_cnt(即穩(wěn)定計(jì)數(shù))– 必須根據(jù)sensor傳感器輸出特性配置該值,以確保傳感器的 PHY 發(fā)送器與 MSM 的 PHY 接收器無(wú)障礙同步;對(duì)于 28 nm 以及更小的 MSM 芯片,使用以下公式計(jì)算穩(wěn)定計(jì)數(shù):
settle_cnt = T(HS_SETTLE)_avg /T(TIMER_CLK),
其中 T(HS_SETTLE)_avg = (T(HS_SETTLE)_min + T(HS_SETTLE)_max) / 2,如傳感器數(shù)據(jù)表所指示:


其中 T(HS_SETTLE)_avg = (T(HS_SETTLE)_min + T(HS_SETTLE)_max) / 2,如傳感器數(shù)據(jù)表所指示。
TIMER_CLK 指攝像頭傳感器所連接的 PHY 接口的工作頻率。(例如,PHY0 的CAMSS_PHY0_CSI0PHYTIMER_CLK)。該值在 kernel/arch/arm/boot/dts/msm/msmXXXX-camera.dtsi 文件中設(shè)置,其中 XXXX 指正在使用 MSM 芯片組。另外,也可在攝像頭數(shù)據(jù)流傳輸期間確認(rèn),方法是通過(guò) adb shell 檢查相應(yīng)的時(shí)鐘信息。
例如,可通過(guò)命令提示窗口發(fā)出以下命令以確認(rèn) PHY0 定時(shí)器時(shí)鐘值:
adb root adb remount adb shell cd /sys/kernel/debug/clk/gcc_camss_csi0phytimer_clk cat measure 200000146
對(duì)于 45 nm MSM 芯片,使用與 28 nm MSM 芯片相似的公式,其中的 T(TIMER_CLK)替換為 T(DDR_CLK)。
– DDR_CLK 指攝像頭傳感器的 MIPI CLK 通道的工作頻率,該值由通過(guò)傳感器攝像頭驅(qū)動(dòng)程序設(shè)置的攝像頭傳感器 PLL 配置確定。
– T(DDR_CLK) 為工作頻率等于 DDR_CLK 時(shí)的時(shí)鐘周期持續(xù)時(shí)間,以納秒為單位表示。例如,DDR_CLK 200 MHz 的 T(DDR_CLK) 為 (1 * (10^9)) / (200 * (10^6)) =5 ns。
有關(guān) T(HS_SETTLE) 的定義,可參見(jiàn)針對(duì) D-PHY(版本 1.1)的 MIPI(R)聯(lián)盟規(guī)范。為了防止上述系數(shù)在傳感器工作時(shí)所處的不同數(shù)據(jù)流傳輸模式間發(fā)生變化,必須為攝像頭傳感器驅(qū)動(dòng)程序中每個(gè)唯一的數(shù)據(jù)流傳輸模式單獨(dú)配置 settle_cnt。
(5)Binning Mode
Camera Binning Mode:像素合并模式,將相鄰的像素單元電荷通過(guò)物理的方法疊加在一起作為一個(gè)像素輸出信號(hào);
935 ? ? ? ? .binning_factor = 1,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 936 ? ? ? ? .binning_method = 0,

水平方向Binning: 同列相鄰行的電荷疊加;
垂直方向Binning: 同行相鄰列的電荷疊加;
Binning Mode 優(yōu)勢(shì):增加感光面積,提高暗處對(duì)光感應(yīng)的靈敏度;應(yīng)用:增加物理感光像素單元,采用像素合并模式,提升暗處對(duì)光感應(yīng)的靈敏度;
Binning Mode 劣勢(shì):降低輸出分辨率;
額外補(bǔ)充:
sensor 開(kāi)窗的不同模式:ROI, BIN,SKIP;
ROI :Region of interes在相機(jī)傳感器分辨范圍內(nèi)定義一個(gè)或多個(gè)感興趣的窗口區(qū)域,僅對(duì)這些窗口內(nèi)的圖像信息進(jìn)行讀出,只獲取該局部區(qū)域的圖像;
BIN :這種模式就是按照一定的規(guī)律,把想要的數(shù)據(jù)采集上來(lái),把其余的數(shù)據(jù)扔掉;
SKIP:就是把相鄰的像素合成一個(gè)像素,然后再輸出。
(6)I2C CLK
The available I2C frequency modes are defined in kernel/include/media/msm_cam_sensor.h:standard (100 kHz), fast (400 kHz), and Custom mode.
enum i2c_freq_mode_t {
I2C_STANDARD_MODE,
I2C_FAST_MODE,
I2C_CUSTOM_MODE,
I2C_MAX_MODES,
};
高通平臺(tái)上兩條Camera I2C設(shè)備總線(xiàn)是專(zhuān)門(mén)為Camera用的,配置不同的i2c頻率的參數(shù)值定義在dtsi里面;
479 &i2c_freq_100Khz {
480 ? ? qcom,hw-thigh = <78>;
481 ? ? qcom,hw-tlow = <114>;
482 ? ? qcom,hw-tsu-sto = <28>;
483 ? ? qcom,hw-tsu-sta = <28>;
484 ? ? qcom,hw-thd-dat = <10>;
485 ? ? qcom,hw-thd-sta = <77>;
486 ? ? qcom,hw-tbuf = <118>;
487 ? ? qcom,hw-scl-stretch-en = <0>;
488 ? ? qcom,hw-trdhld = <6>;
489 ? ? qcom,hw-tsp = <1>;
490 };
CCI clock = (src clock) / (hw_thigh + hw_tlow) //src clock 19.2MHZ
解釋如下:
qcom,hw-thigh : should contain high period of the SCL clock in terms of CCI clock cycle qcom,hw-tlow : should contain high period of the SCL clock in terms of CCI clock cycle qcom,hw-tsu-sto : should contain setup time for STOP condition?
qcom,hw-tsu-sta : should contain setup time for Repeated START condition?
qcom,hw-thd-dat : should contain hold time for the data?
qcom,hw-thd-sta : should contain hold time for START condition?
qcom,hw-tbuf : should contain free time between a STOP and a START condition qcom,hw-scl-stretch-en : should contain enable or disable clock stretching?
qcom,hw-trdhld : should contain internal hold time for SDA?
qcom,hw-tsp : should contain filtering of glitches i2c burst mode:?
+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
(一)bus overflow
攝像頭傳感器時(shí)鐘通道(即 MIPI DDR 時(shí)鐘)的工作頻率與激活的數(shù)據(jù)通道數(shù)決定攝像頭傳感器在指定操作模式下的總數(shù)據(jù)傳輸速率(吞吐量)。每個(gè)通道的數(shù)據(jù)傳輸速率是 MIPI DDR 時(shí)鐘速度的兩倍。例如,工作在 200 MHz MIPI DDR 時(shí)鐘頻率和 4 個(gè)激活通道下的攝像頭傳感器的總數(shù)據(jù)傳輸速率為 1600 Mbps(每個(gè)通道的數(shù)據(jù)傳輸速率為 200 * 2 = 400 Mbps)。
每個(gè)幀的分辨率、額外/虛擬像素/線(xiàn)數(shù)、水平消隱、垂直消隱、MIPI 包開(kāi)銷(xiāo)、每像素位數(shù)、數(shù)據(jù)格式、內(nèi)部是否存在多個(gè)交錯(cuò)數(shù)據(jù)流以及每個(gè)流的數(shù)據(jù)傳輸速率/開(kāi)銷(xiāo)等,都會(huì)影響數(shù)據(jù)傳輸速率。指定工作模式下初步攝像頭調(diào)通,計(jì)算:X = 幀寬 * (幀高垂直消隱) 每像素位數(shù) * 每秒幀數(shù) * (MIPI 協(xié)議和其他數(shù)據(jù)流的開(kāi)銷(xiāo))在 VFE 時(shí)鐘優(yōu)化中為給定的 MSM 找到大于 X 的最接近的值作為 VFE 時(shí)鐘的初始值。
在標(biāo)稱(chēng)時(shí)鐘模式下,比如MSM8909的VFE最大速度為266MHz每條MIPI通道的PHY限制為1.5 Gbps (1.5 * 109 bps),由于存在MIPI/空白開(kāi)銷(xiāo)(約15-25%,各傳感器的具體數(shù)值有所不同),實(shí)際幀數(shù)據(jù)吞吐量略少于預(yù)期原圖拍攝接口數(shù)據(jù)傳輸速率與VFE時(shí)鐘無(wú)關(guān)在4通道PHY接口上,每條通道的最大數(shù)據(jù)為(266 x bpp)/通道數(shù);bpp → 每像素的傳感器輸出位數(shù)對(duì)于每通道10位數(shù)據(jù)傳輸速率 - (266*10)/4 - 665 Mbps;
當(dāng)我們VFE 時(shí)鐘設(shè)置為小于傳感器輸出MIPI的數(shù)據(jù)傳輸速率時(shí),將出現(xiàn)溢出bus overflow; 502: ? ? ? ?pr_err_ratelimited("%s: image master 0 bus overflow\n",?
507: ? ? ? ?pr_err_ratelimited("%s: image master 1 bus overflow\n",?
512: ? ? ? ?pr_err_ratelimited("%s: image master 2 bus overflow\n",?
517: ? ? ? ?pr_err_ratelimited("%s: image master 3 bus overflow\n",?
522: ? ? ? ?pr_err_ratelimited("%s: image master 4 bus overflow\n",?
527: ? ? ? ?pr_err_ratelimited("%s: image master 5 bus overflow\n",?
532: ? ? ? ?pr_err_ratelimited("%s: image master 6 bus overflow\n",
增大VFE時(shí)鐘可防止溢出發(fā)生。要更改VFE時(shí)鐘,需打Vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/sensor_libs/xxxx/ xxxx_lib.c文并編輯 op_pixel_clk 參數(shù)。
選擇正確的 VFE 時(shí)鐘非常重要。VFE 時(shí)鐘頻率應(yīng)足夠高以匹配傳感器輸出端的數(shù)據(jù)速率(即傳感器輸出幀 x 幀/s),否則可能會(huì)引起 ISPIF 溢出。不過(guò)也不應(yīng)設(shè)置過(guò)高的頻率。設(shè)置過(guò)高的 VFE 時(shí)鐘頻率會(huì)導(dǎo)致兩類(lèi)問(wèn)題:
由于可能填充內(nèi)部 VFE 輸出緩存(也稱(chēng)為統(tǒng)一緩存),總線(xiàn)溢出的幾率增大。
如果 VFE 時(shí)鐘頻率較高,會(huì)導(dǎo)致功耗增大。
A. 檢查與 VFE 總線(xiàn)溢出相關(guān)的總線(xiàn)時(shí)鐘
當(dāng)過(guò)多的 VFE 數(shù)據(jù)流量以超過(guò)可用總線(xiàn)帶寬的速率產(chǎn)生時(shí),會(huì)導(dǎo)致 VFE 總線(xiàn)溢出錯(cuò)誤。解決該問(wèn)題的一種可行方法是檢查能否通過(guò)設(shè)置更高的總線(xiàn)時(shí)鐘頻率來(lái)增加總線(xiàn)帶寬。例如在 MSM8916 芯片組中,VFE 生成處理后的輸出幀到系統(tǒng) NoC (SNoC) 總線(xiàn)。數(shù)據(jù)流隨后被轉(zhuǎn)發(fā)到總線(xiàn)集成內(nèi)存控制器 (BIMC) 總線(xiàn),暫時(shí)保存在 DDR 內(nèi)存中。VFE 生成的數(shù)據(jù)流將在這兩條總線(xiàn)形成的路徑上運(yùn)行。因此,SNoC 和 BMIC 總線(xiàn)都必須進(jìn)行檢查。adb shell 腳本每隔一秒會(huì)轉(zhuǎn)儲(chǔ) SNoC 和 BIMC 時(shí)鐘頻率。
#adb shell "while true; do cat /d/clk/snoc_clk/measure; cat /d/clk/bimc_clk/measure; echo '-----'; sleep 1; done" 200001391 748805675 -----
B. 將時(shí)鐘總線(xiàn)設(shè)為最大頻率
VFE 總線(xiàn)溢出分類(lèi)的第一步是檢查能否通過(guò)設(shè)置更高總線(xiàn)時(shí)鐘頻率來(lái)增加可用總線(xiàn)帶寬。增加總線(xiàn)帶寬后,查看 VFE 總線(xiàn)溢出問(wèn)題是否得以解決。
adb root adb shell sleep 1?
adb shell mount -t debugfs none /d?
adb shell echo "22 > /d/msm-bus-dbg/shell-client/mas"?
adb shell echo "512 > /d/msm-bus-dbg/shell-client/slv"?
adb shell echo "0 > /d/msm-bus-dbg/shell-client/ab"?
adb shell echo "6400000000 > /d/msm-bus-dbg/shell-client/ib"?
adb shell echo "1 > /d/msm-bus-dbg/shell-client/update_request"
以上腳本嘗試設(shè)置從 MDP(顯示硬件模塊)到 DDR 內(nèi)存路徑中的所有總線(xiàn)。不管攝像頭如何操作,通過(guò)從 MDP 顯示屏側(cè)(ID 22 表示 MDP)請(qǐng)求高帶寬,總線(xiàn)會(huì)始終保持最大時(shí)鐘頻率。選擇顯示屏 (MDP) 而不是攝像頭 ISP (VFE) 的原因是顯示屏 MDP 一直運(yùn)行,而攝像頭驅(qū)動(dòng)程序在啟動(dòng)和停止時(shí)會(huì)覆蓋攝像頭表決。而且這種更簡(jiǎn)單的測(cè)試場(chǎng)景能解決所有起伏問(wèn)題。通過(guò)以上測(cè)試,再次檢查總線(xiàn)時(shí)鐘是否增加到最大頻率。應(yīng)用上述設(shè)置后,SNoC 和BIMC 時(shí)鐘頻率分別應(yīng)為 266 MHz 和 533 MHz(不同平臺(tái)參數(shù)不一致,對(duì)應(yīng)不同的性能等級(jí))。
如果沒(méi)有任何改進(jìn),可嘗試按以下步驟在 CPU 高性能模式下運(yùn)行系統(tǒng)并設(shè)置最大總線(xiàn)時(shí)鐘頻率:
adb shell "echo 1 > /sys/devices/system/cpu/cpu1/online" adb shell "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
C. 從 VFE 檢查 AB/IB 表決帶寬
在檢查 VFE 側(cè)要求的總 AB 和 IB 帶寬時(shí),確保攝像頭已啟動(dòng)。
運(yùn)行以下命令:
adb root?
adb shell cat /d/msm-bus-dbg/client-data/msm_camera_isp?
1223.023734896?
curr ? : 1?
masters: 29 ??
slaves : 512 ??
ab ? ? : 100000000 ??
ib ? ? : 100000000 ??
1223.024648282?
curr ? : 2?
masters: 29 ??
slaves : 512 ??
ab ? ? : 200000000 ??
ib ? ? : 200000000 ??
1228.214552238?
curr ? : 1?
masters: 29 ??
slaves : 512 ??
ab ? ? : 921819520 ??
ib ? ? : 921819520
輸出第一行中的數(shù)字 351.706326427 表示發(fā)出請(qǐng)求時(shí)的內(nèi)核時(shí)間戳。Master(s) 29 表示總線(xiàn)流量來(lái)自 VFE,Slave(s) 512 表示總線(xiàn)流量的目的地設(shè)為 memory;AB/IB VFE 發(fā)出的最終寬帶請(qǐng)求分別為 930 MBps/1.62 GBps。
D. 識(shí)別 AXI 配置
VFE 總線(xiàn)溢出日志經(jīng)常始于表明某個(gè)具體寫(xiě)入主控上出現(xiàn)溢出,因此內(nèi)核日志顯示的首個(gè)溢出實(shí)例就顯得非常重要,可以幫助確認(rèn)溢出來(lái)源。在 VFE 總線(xiàn)溢出分析(特別是 ZSL 預(yù)覽場(chǎng)景)過(guò)程中,通常要求找到具體圖像寫(xiě)入主器件和預(yù)覽/快照輸出幀面的映射關(guān)系,以確定要優(yōu)化的數(shù)據(jù)流。例如,確定預(yù)覽數(shù)據(jù)流的總線(xiàn)溢出后,僅關(guān)注預(yù)覽數(shù)據(jù)流。在內(nèi)核中添加以下調(diào)試日志消息,并在 Salesforce 用列系統(tǒng)分享該日志。
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
@@ -1384,8 +1384,10 @@ static int ?msm_isp_axi_stream_enable_cfg(
? ? ? ?if (stream_info->state == START_PENDING ||
? ? ? ? ? ? ? ?stream_info->state == RESUME_PENDING) {
? ? ? ? ? ? ? ?enable_wm = 1;
+ ? ? ? ?pr_err("__debug__: WM[%d] ENABLE, src = %d, max_width = %u\n",stream_info->wm[i], stream_info->stream_src, stream_info->max_width);
? ? ? ?} else {
? ? ? ? ? ? ? ?enable_wm = 0;
+ ? ? ? ?pr_err("__debug__: WM[%d] DISENABLE, src = %d, max_width = %u\n",stream_info->wm[i], stream_info->stream_src, stream_info->max_width);
? ? ? ?}
E. 增加 AB/IB
如果將時(shí)鐘總線(xiàn)設(shè)為最大頻率,能夠解決buffer ovflow的問(wèn)題,可以嘗試增加總體總線(xiàn)時(shí)鐘頻率,總線(xiàn)時(shí)鐘頻率只會(huì)在攝像頭工作時(shí)增加,逐漸增加或?qū)⒃瓉?lái)數(shù)字乘2或逐漸減少來(lái)找出最優(yōu)數(shù)量。
//kernel/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
62 #define MSM_ISP_MIN_AB 100000000 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 63 #define MSM_ISP_MIN_IB 100000000
F. 提高VFE 突發(fā)長(zhǎng)度變化
盡管最優(yōu) VFE 突發(fā)長(zhǎng)度沒(méi)有明確答案,但改變 VFE 突發(fā)長(zhǎng)度也能夠減少 VFE 總線(xiàn)溢出問(wèn)題。
28 #define VFE40_BURST_LEN 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 29 #define VFE40_BURST_LEN_8916_VERSION 2 30 #define VFE40_BURST_LEN_8952_VERSION 3 33 #define VFE40_STATS_BURST_LEN 1 34 #define VFE40_STATS_BURST_LEN_8916_VERSION 2
(二)sof freeze
sof freeze(SOF:start of frame)表示ISP這邊沒(méi)有收到sensor這邊輸出的圖像幀數(shù)據(jù),這時(shí)必須檢查 CSID/CSIPHY/CAMIF是否出錯(cuò)。有專(zhuān)門(mén)建立了thread來(lái)負(fù)責(zé)SOF的檢測(cè),start_sof_check_thread() -> mct_bus_sof_thread_run(),log當(dāng)中會(huì)有下面的錯(cuò)誤發(fā)出:
// msm-3.18/drivers/media/platform/msm/camera_v2/msm.c
803 ? ? case MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG: { 804 ? ? ? ? if (event_data->status) { 805 ? ? ? ? ? ? pr_err("%s:Notifying subdevs about potential sof freeze\n", 806 ? ? ? ? ? ? ? ? __func__);
首先看能否dump出現(xiàn)數(shù)據(jù):
?/*
? ? ? ?0 Disabled; this value is set by default
? ? ? ?2 Dump preview frames
? ? ? ?8 Dump snapshot frames
? ? ? ?16 Dump video frames
? ? ? ?*/
? ? ? ?adb root
? ? ? ?adb shell setprop persist.camera.isp.dump 8
? ? ? ?adb shell chmod 777 /data
Verifying the VFE hardware configuration
? ?In the msm_isp_axis_util.c file, locate the following code snippet:
? ?if (vfe_dev->dump_reg)
? ? msm_camera_io_dump_2(vfe_dev->vfe_base, 0x900);
Replace it with:
24 if (1) 25 msm_camera_io_dump_2(vfe_dev->vfe_base, 0x900);
若聲明的傳感器輸出大小與 VFE 實(shí)際接收到的傳感器輸出大小之間不匹配,將發(fā)生 CAMIF錯(cuò)誤。
//mm-camera/mm-camera2/media-controller/modules/iface2/iface_util.c
//mm-camera/mm-camera2/media-controller/modules/iface2/iface_util.c
8878 static void iface_util_dump_camif_cfg(struct msm_vfe_input_cfg *input_cfg) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 8879 { 8880 ? struct msm_vfe_pix_cfg *pix_cfg = NULL; 8881 8882 ? if (input_cfg == NULL) 8883 ? ? return; 8884 8885 ? pix_cfg = &input_cfg->d.pix_cfg; 8886 ? IFACE_HIGH("=====Camif DUMP cfg for PIX interface====\n"); 8887 ? IFACE_HIGH("camif input type = %d(MIPI=3), op_pix_clk = %d\n", 8888 ? ? pix_cfg->camif_cfg.camif_input, input_cfg->input_pix_clk); 8889 ? IFACE_HIGH("camif pix_pattern(RGRG-0/GRGR-1/BGBG-2/GBGB-3) = %d\n", 8890 ? ? pix_cfg->pixel_pattern); 8891 ? IFACE_HIGH("camif first_pix = %d, last_pix = %d\n", 8892 ? ? pix_cfg->camif_cfg.first_pixel, pix_cfg->camif_cfg.last_pixel); 8893 ? IFACE_HIGH("camif first_line = %d, last_line = %d\n", 8894 ? ? pix_cfg->camif_cfg.first_line, pix_cfg->camif_cfg.last_line); 8895 ? IFACE_HIGH("camif pixels_per_line = %d, lines_per_frame = %d\n", 8896 ? ? pix_cfg->camif_cfg.pixels_per_line, pix_cfg->camif_cfg.lines_per_frame); 8897 ? IFACE_HIGH("camif irq subsample pattern = %x, period = %d sof_step %d\n", 8898 ? ? pix_cfg->camif_cfg.subsample_cfg.irq_subsample_pattern, 8899 ? ? pix_cfg->camif_cfg.subsample_cfg.irq_subsample_period, 8900 ? ? pix_cfg->camif_cfg.subsample_cfg.sof_counter_step); 8901 }
將調(diào)試消息中指示的幀大小與 ISP 傳感器的幀大小進(jìn)行比較。在以下 CAMIF 錯(cuò)誤示例中,錯(cuò)誤狀態(tài) 0x9a70a00 表示 ISP 接收幀的大小為 2471x2560(0x9a7 = 2471,0xa00 = 2560)。
01-01 08:07:20.175 E/mm-camera( 302): isp_hw_camif_dump_cfg: camif input_format= 0 01-01 08:07:20.175 E/mm-camera( 302): isp_hw_camif_dump_cfg: camif last_pix = 6527 01-01 08:07:20.175 E/mm-camera( 302): isp_hw_camif_dump_cfg: camif last_line = 0 01-01 08:07:20.175 E/mm-camera( 302): isp_hw_camif_dump_cfg: camif lines per frame = 2448 01-01 08:07:24.335 E/klogd (640): [81.563301] msm_vfe40_process_error_status: camif error status: 0x9a70a00
如果存在不匹配,則根本原因可能如下:
檢查傳感器設(shè)置是否正確,是否滿(mǎn)足分辨率大小的要求。例如,傳感器的輸出大小配置為 12 MB,但 ISP 的接收大小卻配置為 8 MB。可能有些傳感器無(wú)法確保在新分辨率設(shè)置發(fā)送至傳感器后,最初的幀大小能夠滿(mǎn)足要求。在這種情況下,需要與傳感器供應(yīng)商一起解決此問(wèn)題。
