SemiDrive D9360 AHD Camera 1080P 調試

SemiDrive D9360 EVK 目前支持2路MIPI-CSI  1路parallel-CSI 接口,total 9個camera ,本次調試和測試MIPI-CSI2接N4 再連結1080P AHD camera.

1. 查看SCH AHD camera 的連結狀況。

 N4 AHD Camera input


N4 AHD Camera output



D9360 AHD Camera input

N4 I2C bus & slave address



2. 根據硬體原理圖配置好 dts 文件。
source\android\kernel\arch\arm64\boot\dts\semidrive\d9_d9360_ap1_android_ref.dts

&csimipi1 {
status = "okay";
lanerate = <1200000000>;
hsa = <10>;
hbp = <20>;
hsd = <0x60>;
output-type = <0x1e>;

ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;
csimipi1_0_in: endpoint@0 {
remote-endpoint = <&cam1_to_mipi_0>;
reg = <0>;
};
csimipi1_0_out: endpoint@1 {
remote-endpoint = <&csi1_stream0_in>;
reg = <0>;
};
};
port@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;
csimipi1_1_in: endpoint@0 {
remote-endpoint = <&cam1_to_mipi_1>;
reg = <1>;
};
csimipi1_1_out: endpoint@1 {
remote-endpoint = <&csi1_stream1_in>;
reg = <1>;
};
};
port@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <2>;
csimipi1_2_in: endpoint@0 {
remote-endpoint = <&cam1_to_mipi_2>;
reg = <2>;
};
csimipi1_2_out: endpoint@1 {
remote-endpoint = <&csi1_stream2_in>;
reg = <2>;
};
};
port@3 {
#address-cells = <1>;
#size-cells = <0>;
reg = <3>;
csimipi1_3_in: endpoint@0 {
remote-endpoint = <&cam1_to_mipi_3>;
reg = <3>;
};
csimipi1_3_out: endpoint@1 {
remote-endpoint = <&csi1_stream3_in>;
reg = <3>;
};
};
};
};​

&i2c5 {
status = "okay";
nextchipn4:nextchipn4@30 {
compatible = "nextchip,n4";
reg = <0x30>;
sync = <0>;
rst-gpios = <&port4c 15 GPIO_ACTIVE_HIGH>;//index(79) gpio D15
ports {
port@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;
cam1_to_mipi_0: endpoint@0 {
remote-endpoint = <&csimipi1_0_in>;
};
};
port@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;
cam1_to_mipi_1: endpoint@0 {
remote-endpoint = <&csimipi1_1_in>;
};
};
port@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <2>;
cam1_to_mipi_2: endpoint@0 {
remote-endpoint = <&csimipi1_2_in>;
};
};
port@3 {
#address-cells = <1>;
#size-cells = <0>;
reg = <3>;
cam1_to_mipi_3: endpoint@0 {
remote-endpoint = <&csimipi1_3_in>;
};
};
};
};

ksz9896c:ksz9896c@5f {
compatible = "microchip,ksz9896c";

ksz9896c,reset-gpio = <&port4b 24 GPIO_ACTIVE_LOW>;
ksz9896c,pwdn-gpio = <&port4b 28 GPIO_ACTIVE_LOW>;
//gpios = <&port4d 28 GPIO_ACTIVE_LOW> ;//sch-part-J8<->gpio_H2 io124 Y7

reg = <0x5f>;
};
};​

 

3. 添加AHD Camera Driver
\source\android\kernel\drivers\media\platform\sdrv-cam-v2\external\sensor\n4.c
修改相應1080P部分

unsigned int i2c = 1; //1:non-continue 0:continue
//add
#define N4_MODE_720P_25FPS 0
#define N4_MODE_1080P_25FPS 1
enum n4_mode_id {
n4_MODE_720P_1280_720 = 0,
n4_MODE_1080P_1920_1080 = 1, //add
static const struct n4_mode_info
n4_mode_data[n4_NUM_FRAMERATES][n4_NUM_MODES] = {
{
{
n4_MODE_720P_1280_720, SUBSAMPLING,
1280, 1892, 720, 740,
},
{//add
n4_MODE_1080P_1920_1080, SUBSAMPLING,
1920, 2200, 1080, 1280,
},
static void n4_common_settings(void)
{
dev_info(&n4_i2c_client->dev, "n4_common_settings ENTER\n");

//add
#if N4_MODE_1080P_25FPS
mclk = 0;
#else
mclk = 3;
#endif

 

static int n4_init(void)
{
n4_common_settings();
//add
#if N4_MODE_1080P_25FPS
n4_init_ch(0,CH_VALUE_FHD25);
n4_init_ch(1,CH_VALUE_FHD25);
n4_init_ch(2,CH_VALUE_FHD25);
n4_init_ch(3,CH_VALUE_FHD25);
#else
n4_init_ch(0,CH_VALUE_HD25);
n4_init_ch(1,CH_VALUE_HD25);
n4_init_ch(2,CH_VALUE_HD25);
n4_init_ch(3,CH_VALUE_HD25);
#endif
static int n4_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{

fmt = &sensor->fmt;
fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
//fmt->code = MEDIA_BUS_FMT_RGB565_2X8_LE;
fmt->colorspace = V4L2_COLORSPACE_SRGB;
fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace);
fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace);
fmt->field = V4L2_FIELD_NONE;

#if N4_MODE_720P_25FPS
fmt->width = 1280;
fmt->height = 720;
sensor->frame_interval.numerator = 1;
sensor->frame_interval.denominator = n4_framerates[n4_25_FPS];
sensor->current_fr = n4_25_FPS;
sensor->current_mode =
&n4_mode_data[n4_25_FPS][n4_MODE_720P_1280_720];
sensor->ae_target = 52;
#elif N4_MODE_1080P_25FPS
fmt->width = 1920;
fmt->height = 1080;
sensor->frame_interval.numerator = 1;
sensor->frame_interval.denominator = n4_framerates[n4_25_FPS];
sensor->current_fr = n4_25_FPS;
sensor->current_mode =
&n4_mode_data[n4_25_FPS][n4_MODE_1080P_1920_1080];
sensor->ae_target = 52;
#else
fmt->width = 1280;
fmt->height = 720;
sensor->frame_interval.numerator = 1;
sensor->frame_interval.denominator = n4_framerates[n4_25_FPS];
sensor->current_fr = n4_25_FPS;
sensor->current_mode =
&n4_mode_data[n4_25_FPS][n4_MODE_720P_1280_720];
sensor->ae_target = 52;
#endif



4. 編譯並打包。並用SDToolBox工具燒錄編譯後的pac文件。

5. 運行測試

SDDVR app 測試結果。



命令行csi-test 測試結果。
# csi-test -d video-dvr0 -w1920 -v1080 -y2

★博文內容均由個人提供,與平台無關,如有違法或侵權,請與網站管理員聯繫。

★文明上網,請理性發言。內容一周內被舉報5次,發文人進小黑屋喔~

評論