高通Camera 驅動調試要點(一)

本文主要介紹QCOM camera調試的重要參數;


(1)Lane_assign 和lane_mask

  現在攝像頭基本都是mipi接口類型,因爲前後攝都對應到平臺這邊不同的mipi接口,相應的數據lane需要一一對應;

  lane assign:

這裏寫圖片描述

  lane_mask:

這裏寫圖片描述

比如:

101       <LaneMask>0x1F</LaneMask>                                                                                                                    
102       <LaneAssign>0x4320</LaneAssign>

  0x1F:只有0~4表示有效,對應bit位置爲1表示該位的lane或者clock有效,0x1F即表示該mipi接口上的4條data線和clk線都有效;
  0x4320:表示sensor這邊幾條data線對應到平臺這邊mipi接口的第幾路接口端口映射;bit0~3表示lane0對應平臺這邊mipi的第0接口,bit12~15表示lane 3對應平臺這邊mipi的第4接口,那第1個接口就是爲時鐘clk對接的;


(2)combo_mode

  如該平臺這邊只有一個mipi phy設備,有時候就需要前後攝共用這個phy,此時combo_mode就要設爲1,或者在雙攝的情況下:主副攝會與前攝共用,這個值也會設爲1,下面是兩個camera分配情況:

這裏寫圖片描述

  比如只有一個PHY interface 的msm8909平臺就可以這樣配置:

//前攝配置

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

  像素時鐘(pixel clk): 是經過主時鐘MCLK(EXTCLK) 經過PLL得到的,決定了該sensor突出數據的速度;相關PLL設定需要查看sensor 寄存器的data sheet,以s5k2ya爲例:

這裏寫圖片描述

  如下爲一個sensor的clk相關的配置:

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

  平臺根據寫入不同的曝光行來控制幀率,比如在暗處希望犧牲一點幀率,讓Gain值更高,就用這個公式來計算,最後計算的 frame_length_lines 寫入相應寄存器;

  注意一點的是不同的平臺需要一個最小的blanking time,所以frame_length_lines是要大於真是有效數據行y_output,而且差值一般16對齊;

這裏寫圖片描述

  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.

  這個時鐘決定了sensor mipi data lane 吐出數據的帶寬;不同的平臺的處理能力不一樣,所以這個值不能超過平臺規範定義的值;

這裏寫圖片描述


(4)settle_cnt

  settle_cnt(即穩定計數)–表示mipi開始切換到高速模式的一個穩定時間,必須根據傳感器輸出特性配置該值,以確保傳感器的 PHY 發送器與 MSM 的 PHY 接收器無障礙同步;

  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(即穩定計數)– 必須根據sensor傳感器輸出特性配置該值,以確保傳感器的 PHY 發送器與 MSM 的 PHY 接收器無障礙同步;對於 28 nm 以及更小的 MSM 芯片,使用以下公式計算穩定計數:

settle_cnt = T(HS_SETTLE)_avg /T(TIMER_CLK),

  其中 T(HS_SETTLE)_avg = (T(HS_SETTLE)_min + T(HS_SETTLE)_max) / 2,如傳感器數據表所指示:

這裏寫圖片描述

這裏寫圖片描述

  其中 T(HS_SETTLE)_avg = (T(HS_SETTLE)_min + T(HS_SETTLE)_max) / 2,如傳感器數據表所指示。

  TIMER_CLK 指攝像頭傳感器所連接的 PHY 接口的工作頻率。(例如,PHY0 的CAMSS_PHY0_CSI0PHYTIMER_CLK)。該值在 kernel/arch/arm/boot/dts/msm/
msmXXXX-camera.dtsi 文件中設置,其中 XXXX 指正在使用 MSM 芯片組。另
外,也可在攝像頭數據流傳輸期間確認,方法是通過 adb shell 檢查相應的時鐘信
息。例如,可通過命令提示窗口發出以下命令以確認 PHY0 定時器時鐘值:

adb root
adb remount
adb shell
cd /sys/kernel/debug/clk/gcc_camss_csi0phytimer_clk
cat measure
200000146

  對於 45 nm MSM 芯片,使用與 28 nm MSM 芯片相似的公式,其中的 T(TIMER_CLK)替換爲 T(DDR_CLK)。

  – DDR_CLK 指攝像頭傳感器的 MIPI CLK 通道的工作頻率,該值由通過傳感器攝像頭驅動程序設置的攝像頭傳感器 PLL 配置確定。
  – T(DDR_CLK) 爲工作頻率等於 DDR_CLK 時的時鐘週期持續時間,以納秒爲單位表示。例如,DDR_CLK 200 MHz 的 T(DDR_CLK) 爲 (1 * (10^9)) / (200 * (10^6)) =5 ns。

  有關 T(HS_SETTLE) 的定義,可參見針對 D-PHY(版本 1.1)的 MIPI(R)聯盟規範。爲了防止上述係數在傳感器工作時所處的不同數據流傳輸模式間發生變化,必須爲攝像頭傳感器驅動程序中每個唯一的數據流傳輸模式單獨配置 settle_cnt。


(5)Binning Mode

  Camera Binning Mode:像素合併模式,將相鄰的像素單元電荷通過物理的方法疊加在一起作爲一個像素輸出信號;

 935         .binning_factor = 1,                                                                                                                      
 936         .binning_method = 0,

這裏寫圖片描述

  水平方向Binning: 同列相鄰行的電荷疊加;
  垂直方向Binning: 同行相鄰列的電荷疊加;

  Binning Mode 優勢:增加感光面積,提高暗處對光感應的靈敏度;應用:增加物理感光像素單元,採用像素合併模式,提升暗處對光感應的靈敏度;
  Binning Mode 劣勢:降低輸出分辨率;

額外補充:

  sensor 開窗的不同模式:ROI, BIN,SKIP;

  1. ROI :Region of interes在相機傳感器分辨範圍內定義一個或多個感興趣的窗口區域,僅對這些窗口內的圖像信息進行讀出,只獲取該局部區域的圖像;
  2. BIN :這種模式就是按照一定的規律,把想要的數據採集上來,把其餘的數據扔掉;
  3. SKIP:就是把相鄰的像素合成一個像素,然後再輸出。


(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,
};

  高通平臺上兩條Camera I2C設備總線是專門爲Camera用的,配置不同的i2c頻率的參數值定義在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:

TODO

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章