hi3559_imx334_sensor修改配置1080P60

简介: 先说一下我的需求:让hi3559上支持驱动Mp60/4MP60 的imx334海思把一些可能用到的驱动文件开放让我们修改,这样我们确实是可以做一些自己的适配本文从csdn同步过来的

hi3559 imx334 sensor修改1080P60

先说一下我的需求:让hi3559上支持驱动Mp60/4MP60 的imx334
海思把一些可能用到的驱动文件开放让我们修改,这样我们确实是可以做一些自己的适配,挺好的
先给指一下路,imx334路径
在这里插入图片描述

obj文件是编译之后会生成的,编译之前没有很正常。
主要要修改的就是imx334_cmos.c,imx334_sensor_ctl.c
然后思路就是修改底层之后在上层(sample)做适配,本文最终呈现基于海思官方SDK下的sample下的vio
另外,原理不清楚,但是亲测ko文件是不用重新生成的。
具体的修改测试方法是:
先修改component 下的底层驱动-> make clean->make
再修改sample_comm_vi.c,sample_comm_isp.c/sample_comm_isp.h 新增对应的驱动配置,
最后修改sample 下的Makefile.param,把SENSOR0_TYPE配成你新生成的配置(如果你回改可以配其他的)

334驱动修改

如果直接说这玩意改哪个地方的代码就没必要写个东西记录了,直接移步下载就可以了,重点说一下修改的思路,以防万一之后有什么需要还得重新看,虽然也没看全。

HIISP开发参考.pdf

下面的图说了ISP用到的的几个指针的功能,
在这里插入图片描述

这里说了这几个函数指针的功能,所以cmos.c和ctl.c是在生成函数指针给海思内核调用,根据个人观察 ,他的调用方法是没有开放的,也就是说只能通过修改他给的接口的函数指针,让他去执行我们写的函数,从而实现初始化/驱动。
个人建议是把这个手册ISP初始化的部分跳着看一看的
在这里插入图片描述
这里可以看到初始化有两个前置函数 ,内存初始化不看,看属性配置HI_MPI_SetPubAttr
下面是SDK功能的描述
在这里插入图片描述

也就是说我们的一切修改都是在修改这几个函数,修改它对相机的配置
在这里插入图片描述

剩下的都是用得到的时候再看就来得及,这里贴上来看一眼

cmos.c

cmos_set_image_mode

根据传进来的image的尺寸设定初始化的模式,下面是我的部分配置

if (f32Fps <= 120) {
        if (pstSnsState->enWDRMode == WDR_MODE_NONE) {
            if (f32Fps==60 && IMX334_RES_IS_2K60_12BIT(u32W,u32H)) {
                u8SensorImageMode     = IMX334_2M_60FPS_12BIT_LINEAR_MODE;
                pstSnsState->u32FLStd = IMX334_VMAX_8M_30FPS_12BIT_LINEAR;
            }else if(f32Fps>=60){
                u8SensorImageMode     = IMX334_8M_60FPS_12BIT_LINEAR_MODE;
                pstSnsState->u32FLStd = IMX334_VMAX_8M_30FPS_12BIT_LINEAR;
            }
            else if(f32Fps>=60){
                u8SensorImageMode     = IMX334_2M_120FPS_12BIT_LINEAR_MODE;
                pstSnsState->u32FLStd = IMX334_VMAX_8M_30FPS_12BIT_LINEAR;
            }
            else if(IMX334_RES_IS_4K30_12BIT(u32W, u32H)){
                u8SensorImageMode     = IMX334_8M_30FPS_12BIT_LINEAR_MODE;
                pstSnsState->u32FLStd = IMX334_VMAX_8M_30FPS_12BIT_LINEAR;
            }

可以看到传进来给这个函数识别的结构体只剩下下面的几个属性

typedef struct hiISP_CMOS_SENSOR_IMAGE_MODE_S {
    HI_U16   u16Width;
    HI_U16   u16Height;
    HI_FLOAT f32Fps;
    HI_U8    u8SnsMode;
} ISP_CMOS_SENSOR_IMAGE_MODE_S;

也就是说最好根据帧率,尺寸来确定这个东西的初始化配置,那个额外的参数怎么传还不大确定,也不太想去确定了,也就是说在这里根据对面ISP 接口传进来的属性配置之后的初始化方案。
剩下的思路就是Ctrl+F "IMX334_8M_30FPS_12BIT_LINEAR_MODE" 这个配置的位置,配置当为"IMX334_2M_60FPS_12BIT_LINEAR_MODE"时候应该有的操作
比如

        } else if (IMX334_8M_60FPS_12BIT_LINEAR_MODE == pstSnsState->u8ImgMode) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 60) / 5;
        } else if (IMX334_2M_60FPS_12BIT_LINEAR_MODE == pstSnsState->u8ImgMode) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 60) / 5;
        } else if (IMX334_2M_120FPS_12BIT_LINEAR_MODE == pstSnsState->u8ImgMode) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 120) / 5;

仅供参考

cmos_init_sensor_exp_function

重点说一下这个函数的接口的指针函数的定义,不过一般也不用改,如果自己写全部的话需要了解

sensor_register_callback

这个是包括ae,awb等一些额外功能在内的函数的注册函数,大概就是让系统知道这段函数代码的指针位置,一般也不用改

cmos_set_pixel_detect

static HI_VOID cmos_set_pixel_detect(VI_PIPE ViPipe, HI_BOOL bEnable)
{
    HI_U32 u32FullLines_5Fps;
    ISP_SNS_STATE_S *pstSnsState = HI_NULL;

    IMX334_SENSOR_GET_CTX(ViPipe, pstSnsState);
    CMOS_CHECK_POINTER_VOID(pstSnsState);

    if (pstSnsState->enWDRMode == WDR_MODE_2To1_LINE) {
        u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_2TO1_WDR * 30) / 5;
    } else {
        if (pstSnsState->u8ImgMode == IMX334_8M_30FPS_12BIT_LINEAR_MODE) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 30) / 5;
        } else if (IMX334_8M_60FPS_12BIT_LINEAR_MODE == pstSnsState->u8ImgMode) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 60) / 5;
        } else if (IMX334_2M_60FPS_12BIT_LINEAR_MODE == pstSnsState->u8ImgMode) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 60) / 5;
        } else if (IMX334_2M_120FPS_12BIT_LINEAR_MODE == pstSnsState->u8ImgMode) {
            u32FullLines_5Fps = (IMX334_VMAX_8M_30FPS_12BIT_LINEAR * 120) / 5;
        } else {
            return;
        }
    }

    if (bEnable) { /* setup for ISP pixel calibration mode */
        /* Sensor must be programmed for slow frame rate (5 fps and below) */
        /* change frame rate to 5 fps by setting 1 frame length  */
        /* Analog and Digital gains both must be programmed for their minimum values */
        imx334_write_register(ViPipe, IMX334_PGC_L, 0x00);
        imx334_write_register(ViPipe, IMX334_PGC_H, 0x00);

        imx334_write_register(ViPipe, IMX334_VMAX_L, u32FullLines_5Fps & 0xFF);
        imx334_write_register(ViPipe, IMX334_VMAX_M, (u32FullLines_5Fps & 0xFF00) >> 8);
        imx334_write_register(ViPipe, IMX334_VMAX_H, (u32FullLines_5Fps & 0xF0000) >> 16);
    } else { /* setup for ISP 'normal mode' */
        pstSnsState->u32FLStd = (pstSnsState->u32FLStd > IMX334_FULL_LINES_MAX) ? IMX334_FULL_LINES_MAX : pstSnsState->u32FLStd;
        imx334_write_register(ViPipe, IMX334_VMAX_L, (pstSnsState->u32FLStd & 0xff));
        imx334_write_register(ViPipe, IMX334_VMAX_M, (pstSnsState->u32FLStd & 0xff00) >> 8);
        imx334_write_register(ViPipe, IMX334_VMAX_H, (pstSnsState->u32FLStd & 0xf0000) >> 16);
        pstSnsState->bSyncInit = HI_FALSE;
    }

    return;
}

ctl.c

imx334_init

这个函数主要实现init 一些寄存器的配置
下面是在网上抄的reg配置 334 1080P60,亲测配置可用


void imx334_linear_2M60_12bit_init(VI_PIPE ViPipe)  //4 lane
{
#if 1
    //refer to datasheet page.45 & 53 & 75
    imx334_write_register(ViPipe, 0x3000, 0x01); //standby
    imx334_write_register(ViPipe, 0x3001, 0x00);
    imx334_write_register(ViPipe, 0x3002, 0x01);
    imx334_write_register(ViPipe, 0x3003, 0x00);
    imx334_write_register(ViPipe, 0x300C, 0x3B); //74.25M:0xB6 37.125M:0x5B 24M:0x3B 18M:0x2D 12M:0x1E 6M:0x0F
    imx334_write_register(ViPipe, 0x300D, 0x2A); //74.25M:0x7F 37.125M:0x40 24M:0x2A 18M:0x1F 12M:0x15 6M:0x0B
    imx334_write_register(ViPipe, 0x3018, 0x01); //window mode: 0:all pixel scan 1:h/v 2-2-line binning 4:win cropping
    imx334_write_register(ViPipe, 0x302C, 0x30); //win cropping mode start position
    imx334_write_register(ViPipe, 0x302D, 0x00);
    imx334_write_register(ViPipe, 0x302E, 0x18); //cropping horizontal 0xF18:3864
    imx334_write_register(ViPipe, 0x302F, 0x0F);
    imx334_write_register(ViPipe, 0x3030, 0xCA); //VMAX 0x8CA:2250
    imx334_write_register(ViPipe, 0x3031, 0x08);
    imx334_write_register(ViPipe, 0x3032, 0x00);
    imx334_write_register(ViPipe, 0x3033, 0x00);
    imx334_write_register(ViPipe, 0x3034, 0x26); //HMAX 0x226: 0x294: 0x44C: 0x528:refer to datasheet
    imx334_write_register(ViPipe, 0x3035, 0x02);
    imx334_write_register(ViPipe, 0x304C, 0x14);

    imx334_write_register(ViPipe, 0x3050, 0x00); //10bit:0x00 12bit:0x01

    imx334_write_register(ViPipe, 0x3076, 0x84); //width 0x884:2180
    imx334_write_register(ViPipe, 0x3077, 0x08);

    imx334_write_register(ViPipe, 0x3090, 0x84); //width 0x884:2180
    imx334_write_register(ViPipe, 0x3091, 0x08);

    imx334_write_register(ViPipe, 0x30C6, 0x00);
    imx334_write_register(ViPipe, 0x30C7, 0x00);
    imx334_write_register(ViPipe, 0x30CE, 0x00);
    imx334_write_register(ViPipe, 0x30CF, 0x00);
    imx334_write_register(ViPipe, 0x30D8, 0xF8);
    imx334_write_register(ViPipe, 0x30D9, 0x11);

    imx334_write_register(ViPipe, 0x3117, 0x00);
    imx334_write_register(ViPipe, 0x314C, 0xC6);
    imx334_write_register(ViPipe, 0x314D, 0x00);
    imx334_write_register(ViPipe, 0x315A, 0x02); //6M:0x0 12M/18M:0x1 24M/37.125M:0x2 74.25M:0x3
    imx334_write_register(ViPipe, 0x3168, 0xA0); //6M/12M:0xA0 18M:0x6B 24M:0xA0 37.125M/74.25M:0x68
    imx334_write_register(ViPipe, 0x316A, 0x7E);
    imx334_write_register(ViPipe, 0x3199, 0x10);
    imx334_write_register(ViPipe, 0x319D, 0x01); //10bit:0x00 12bit:0x01
    imx334_write_register(ViPipe, 0x319E, 0x01); //1728M:0x0 1188M:0x1 891M:0x2
    imx334_write_register(ViPipe, 0x31A0, 0x2A);
    imx334_write_register(ViPipe, 0x31D4, 0x00);
    imx334_write_register(ViPipe, 0x31D5, 0x00);
    //imx334_write_register(ViPipe, 0x31DC, 0x04);
    imx334_write_register(ViPipe, 0x31DD, 0x04);
    imx334_write_register(ViPipe, 0x3288, 0x21);
    imx334_write_register(ViPipe, 0x328A, 0x02);
    imx334_write_register(ViPipe, 0x3300, 0x01);
    imx334_write_register(ViPipe, 0x3302, 0x32);
    imx334_write_register(ViPipe, 0x3303, 0x00);
    imx334_write_register(ViPipe, 0x3308, 0x42);
    imx334_write_register(ViPipe, 0x3309, 0x04);
    imx334_write_register(ViPipe, 0x3414, 0x05);
    imx334_write_register(ViPipe, 0x3416, 0x18);
    imx334_write_register(ViPipe, 0x341C, 0xFF); //12bit:0x47 10bit:0x1FF
    imx334_write_register(ViPipe, 0x341D, 0x01);
    imx334_write_register(ViPipe, 0x35AC, 0x0E);
    imx334_write_register(ViPipe, 0x3648, 0x01);
    imx334_write_register(ViPipe, 0x364A, 0x04);
    imx334_write_register(ViPipe, 0x364C, 0x04);
    imx334_write_register(ViPipe, 0x3678, 0x01);
    imx334_write_register(ViPipe, 0x367C, 0x31);
    imx334_write_register(ViPipe, 0x367E, 0x31);
    imx334_write_register(ViPipe, 0x3708, 0x02);
    imx334_write_register(ViPipe, 0x3714, 0x01);
    imx334_write_register(ViPipe, 0x3715, 0x02);
    imx334_write_register(ViPipe, 0x3716, 0x02);
    imx334_write_register(ViPipe, 0x3717, 0x02);
    imx334_write_register(ViPipe, 0x371C, 0x3D);
    imx334_write_register(ViPipe, 0x371D, 0x3F);
    imx334_write_register(ViPipe, 0x372C, 0x00);
    imx334_write_register(ViPipe, 0x372D, 0x00);
    imx334_write_register(ViPipe, 0x372E, 0x46);
    imx334_write_register(ViPipe, 0x372F, 0x00);
    imx334_write_register(ViPipe, 0x3730, 0x89);
    imx334_write_register(ViPipe, 0x3731, 0x00);
    imx334_write_register(ViPipe, 0x3732, 0x08);
    imx334_write_register(ViPipe, 0x3733, 0x01);
    imx334_write_register(ViPipe, 0x3734, 0xFE);
    imx334_write_register(ViPipe, 0x3735, 0x05);
    imx334_write_register(ViPipe, 0x375D, 0x00);
    imx334_write_register(ViPipe, 0x375E, 0x00);
    imx334_write_register(ViPipe, 0x375F, 0x61);
    imx334_write_register(ViPipe, 0x3760, 0x06);
    imx334_write_register(ViPipe, 0x3768, 0x1B);
    imx334_write_register(ViPipe, 0x3769, 0x1B);
    imx334_write_register(ViPipe, 0x376A, 0x1A);
    imx334_write_register(ViPipe, 0x376B, 0x19);
    imx334_write_register(ViPipe, 0x376C, 0x18);
    imx334_write_register(ViPipe, 0x376D, 0x14);
    imx334_write_register(ViPipe, 0x376E, 0x0F);
    imx334_write_register(ViPipe, 0x3776, 0x00);
    imx334_write_register(ViPipe, 0x3777, 0x00);
    imx334_write_register(ViPipe, 0x3778, 0x46);
    imx334_write_register(ViPipe, 0x3779, 0x00);
    imx334_write_register(ViPipe, 0x377A, 0x08);
    imx334_write_register(ViPipe, 0x377B, 0x01);
    imx334_write_register(ViPipe, 0x377C, 0x45);
    imx334_write_register(ViPipe, 0x377D, 0x01);
    imx334_write_register(ViPipe, 0x377E, 0x23);
    imx334_write_register(ViPipe, 0x377F, 0x02);
    imx334_write_register(ViPipe, 0x3780, 0xD9);
    imx334_write_register(ViPipe, 0x3781, 0x03);
    imx334_write_register(ViPipe, 0x3782, 0xF5);
    imx334_write_register(ViPipe, 0x3783, 0x06);
    imx334_write_register(ViPipe, 0x3784, 0xA5);
    imx334_write_register(ViPipe, 0x3788, 0x0F);
    imx334_write_register(ViPipe, 0x378A, 0xD9);
    imx334_write_register(ViPipe, 0x378B, 0x03);
    imx334_write_register(ViPipe, 0x378C, 0xEB);
    imx334_write_register(ViPipe, 0x378D, 0x05);
    imx334_write_register(ViPipe, 0x378E, 0x87);
    imx334_write_register(ViPipe, 0x378F, 0x06);
    imx334_write_register(ViPipe, 0x3790, 0xF5);
    imx334_write_register(ViPipe, 0x3792, 0x43);
    imx334_write_register(ViPipe, 0x3794, 0x7A);
    imx334_write_register(ViPipe, 0x3796, 0xA1);
    imx334_write_register(ViPipe, 0x3A01, 0x03);
    imx334_write_register(ViPipe, 0x3A18, 0x8F); //4/8-lane 30fps: 0x7F 4-lane 60fps:0xB7
    imx334_write_register(ViPipe, 0x3A19, 0x00);
    imx334_write_register(ViPipe, 0x3A1A, 0x4F); //4/8-lane 30fps: 0x37 4-lane 60fps:0x67
    imx334_write_register(ViPipe, 0x3A1B, 0x00);
    imx334_write_register(ViPipe, 0x3A1C, 0x47); //4/8-lane 30fps: 0x37 4-lane 60fps:0x6F
    imx334_write_register(ViPipe, 0x3A1D, 0x00);
    imx334_write_register(ViPipe, 0x3A1E, 0x37); //4/8-lane 30fps: 0xF7 4-lane 60fps:0x1DF
    imx334_write_register(ViPipe, 0x3A1F, 0x01);
    imx334_write_register(ViPipe, 0x3A20, 0x4F); //4/8-lane 30fps: 0x3F 4-lane 60fps:0x6F
    imx334_write_register(ViPipe, 0x3A21, 0x00);
    imx334_write_register(ViPipe, 0x3A22, 0x87); //4/8-lane 30fps: 0x6F 4-lane 60fps:0xCF
    imx334_write_register(ViPipe, 0x3A23, 0x00);
    imx334_write_register(ViPipe, 0x3A24, 0x4F); //4/8-lane 30fps: 0x3F 4-lane 60fps:0x6F
    imx334_write_register(ViPipe, 0x3A25, 0x00);
    imx334_write_register(ViPipe, 0x3A26, 0x7F); //4/8-lane 30fps: 0x5F 4-lane 60fps:0xB7
    imx334_write_register(ViPipe, 0x3A27, 0x00);
    imx334_write_register(ViPipe, 0x3A28, 0x3F); //4/8-lane 30fps: 0x2F 4-lane 60fps:0x5F
    imx334_write_register(ViPipe, 0x3A29, 0x00);
    imx334_write_register(ViPipe, 0x3E04, 0x0E);
    imx334_write_register(ViPipe, 0x3078, 0x04);
    imx334_write_register(ViPipe, 0x3079, 0xFE);
    imx334_write_register(ViPipe, 0x307A, 0x04);
    imx334_write_register(ViPipe, 0x307B, 0x02);

    imx334_write_register(ViPipe, 0x3081, 0xFE);
    imx334_write_register(ViPipe, 0x3082, 0x04);
    imx334_write_register(ViPipe, 0x3083, 0x02);
    imx334_write_register(ViPipe, 0x3088, 0x04);
    imx334_write_register(ViPipe, 0x3094, 0xFE);
    imx334_write_register(ViPipe, 0x3095, 0x04);
    imx334_write_register(ViPipe, 0x3096, 0x02);

    imx334_write_register(ViPipe, 0x309C, 0xFE);
    imx334_write_register(ViPipe, 0x309D, 0x04);
    imx334_write_register(ViPipe, 0x309E, 0x02);
    imx334_write_register(ViPipe, 0x30A4, 0x33);
    imx334_write_register(ViPipe, 0x30A5, 0x33);

    //Sensor registers used for normal image
#if 1
    imx334_write_register(ViPipe, 0x304E, 0x00);
    imx334_write_register(ViPipe, 0x304F, 0x00);

    imx334_write_register(ViPipe, 0x3074, 0xB0);
    imx334_write_register(ViPipe, 0x3075, 0x00);

    imx334_write_register(ViPipe, 0x308E, 0xB1);
    imx334_write_register(ViPipe, 0x308F, 0x00);

    imx334_write_register(ViPipe, 0x30B6, 0x00);
    imx334_write_register(ViPipe, 0x30B7, 0x00);

    imx334_write_register(ViPipe, 0x3116, 0x08);
    imx334_write_register(ViPipe, 0x3080, 0x04);
    imx334_write_register(ViPipe, 0x309B, 0x04);
#endif


    imx334_write_register(ViPipe, 0x3000, 0x00); //Standby Cancel
    delay_ms(18);
    imx334_write_register(ViPipe, 0x3002, 0x00);
    delay_ms(320);  //wait for image stablization

    printf("===Imx334 2M60fps 12bit LINE binning 4lane Init OK!===\n");
    
    return;
}

另外init函数,不存在的标签自己定义一下宏

void imx334_init(VI_PIPE ViPipe)
{
    HI_U8           u8ImgMode;
    HI_BOOL         bInit;

    bInit       = g_pastImx334[ViPipe]->bInit;
    u8ImgMode   = g_pastImx334[ViPipe]->u8ImgMode;

    /* 1. sensor i2c init */
    imx334_i2c_init(ViPipe);

    if (bInit == HI_FALSE) {
        /* 2.  sensor registers init */
        if (u8ImgMode == IMX334_8M_30FPS_12BIT_LINEAR_MODE) {     /* 4K@30fps Linear */
            imx334_linear_8M30_12bit_init(ViPipe);
        } else if (IMX334_8M_30FPS_12BIT_2t1_DOL_MODE == u8ImgMode) { /* 4K@30fps DOL2 */
            imx334_DOL_2t1_8M30_12bit_init(ViPipe);
        } else if (IMX334_8M_60FPS_12BIT_LINEAR_MODE == u8ImgMode) { /* 4K@60fps Linear */
                imx334_linear_8M60_12bit_init(ViPipe);
        } else if (IMX334_2M_120FPS_12BIT_LINEAR_MODE == u8ImgMode) { /* 1K@120fps Linear */
                imx334_linear_2M120_12bit_init(ViPipe);
        } else if (IMX334_2M_60FPS_12BIT_LINEAR_MODE == u8ImgMode) { /*2K@60fps Linear */
                imx334_linear_2M60_12bit_init(ViPipe);

        }
    } else {

    /* When sensor switch mode(linear<->WDR or resolution), config different registers(if possible) */
        /* 2.  sensor registers init */
        if (u8ImgMode == IMX334_8M_30FPS_12BIT_LINEAR_MODE) {     /* 4K@30fps Linear */
            imx334_linear_8M30_12bit_init(ViPipe);
        } else if (IMX334_8M_30FPS_12BIT_2t1_DOL_MODE == u8ImgMode) { /* 4K@30fps DOL2 */
            imx334_DOL_2t1_8M30_12bit_init(ViPipe);
        } else if (IMX334_8M_60FPS_12BIT_LINEAR_MODE == u8ImgMode) { /* 4K@60fps Linear */
            imx334_linear_8M60_12bit_init(ViPipe);
        } else if (IMX334_2M_120FPS_12BIT_LINEAR_MODE == u8ImgMode) { /* 2K@120fps Linear */
            imx334_linear_2M120_12bit_init(ViPipe);
        }else if (IMX334_2M_60FPS_12BIT_LINEAR_MODE == u8ImgMode) { /*2K@60fps Linear */
            imx334_linear_2M60_12bit_init(ViPipe);   
        }
    }

    g_pastImx334[ViPipe]->bInit = HI_TRUE;

    return;

}

至此,底层修改就说道这,深的也还没看

isp接口修改

Makefile.param

新写一个宏 这个宏定义的位置在sample_common.h

typedef enum hiSAMPLE_SNS_TYPE_E
{
    SONY_IMX477_MIPI_12M_30FPS_12BIT,
    SONY_IMX477_MIPI_9M_50FPS_10BIT,
    SONY_IMX477_MIPI_9M_60FPS_10BIT,
    SONY_IMX477_MIPI_8M_60FPS_12BIT,
    SONY_IMX477_MIPI_8M_30FPS_12BIT,
    SONY_IMX290_MIPI_2M_30FPS_12BIT,
    SONY_IMX290_MIPI_2M_30FPS_12BIT_WDR3TO1,
    SONY_IMX334_SLAVE_MIPI_8M_30FPS_12BIT,
    SONY_IMX334_MIPI_8M_30FPS_12BIT,
    SONY_IMX334_MIPI_8M_30FPS_12BIT_WDR2TO1,
    SONY_IMX334_MIPI_8M_60FPS_12BIT,
    SONY_IMX334_MIPI_2M_60FPS_12BIT,
    SONY_IMX334_MIPI_2M_120FPS_12BIT,
    SONY_IMX277_SLVS_8M_120FPS_10BIT,
    SONY_IMX277_SLVS_8M_30FPS_12BIT,
    SONY_IMX277_SLVS_8M_60FPS_12BIT,
    SONY_IMX277_SLVS_12M_30FPS_12BIT,
    SONY_IMX277_SLVS_2M_240FPS_12BIT,
    COMSIS_SHARP8K_SLVDS_8K_30FPS_12BIT,
    SAMPLE_SNS_TYPE_BUTT,
} SAMPLE_SNS_TYPE_E;

下面的是param里面的配置

## SENSOR0_TYPE ?= SONY_IMX334_MIPI_8M_30FPS_12BIT
SENSOR0_TYPE ?= SONY_IMX334_MIPI_2M_60FPS_12BIT

sample_comm_vi.c

SAMPLE_COMM_VI_GetSizeBySensor

里面新加一个case

        case SONY_IMX334_MIPI_2M_60FPS_12BIT:
            *penSize = PIC_1080P;
            break;

SAMPLE_COMM_VI_GetFrameRateBySensor

switch (enMode)里面新加一个case

    case SONY_IMX334_MIPI_2M_60FPS_12BIT:
        *pu32FrameRate = 60;
    break;

SAMPLE_COMM_VI_GetChnAttrBySns

    case SONY_IMX334_MIPI_2M_60FPS_12BIT:
        memcpy_s(pstChnAttr, sizeof(VI_CHN_ATTR_S), &CHN_ATTR_1920x1080_420_SDR8_LINEAR, sizeof(VI_CHN_ATTR_S));
        break;

其中配置结构体的定义

VI_CHN_ATTR_S CHN_ATTR_1920x1080_420_SDR8_LINEAR =
{
    {1920, 1080},
    PIXEL_FORMAT_YVU_SEMIPLANAR_420,
    DYNAMIC_RANGE_SDR8,
    VIDEO_FORMAT_LINEAR,
    COMPRESS_MODE_NONE,
    0,      0,
    0,
    { -1, -1}
};

SAMPLE_COMM_VI_GetPipeAttrBySns

加一个case

    case SONY_IMX334_MIPI_2M_60FPS_12BIT:
        memcpy_s(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S));
        break;

结构体定义

VI_PIPE_ATTR_S PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR =
{
    VI_PIPE_BYPASS_NONE, HI_FALSE,HI_FALSE,
    1920, 1080,
    PIXEL_FORMAT_RGB_BAYER_12BPP,
    COMPRESS_MODE_LINE,
    DATA_BITWIDTH_12,
    HI_TRUE,
    {
        PIXEL_FORMAT_YVU_SEMIPLANAR_420,
        DATA_BITWIDTH_10,
        VI_NR_REF_FROM_RFR,
        COMPRESS_MODE_NONE
    },
    HI_FALSE,
    { -1, -1}
};

SAMPLE_COMM_VI_GetDevAttrBySns

    case SONY_IMX334_MIPI_2M_60FPS_12BIT:
        memcpy_s(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX334_2M_BASE, sizeof(VI_DEV_ATTR_S));
        break;

结构体

VI_DEV_ATTR_S DEV_ATTR_IMX334_2M_BASE =
{
    VI_MODE_MIPI,
    VI_WORK_MODE_1Multiplex,
    {0xFFF00000,    0x0},
    VI_SCAN_PROGRESSIVE,
    {-1, -1, -1, -1},
    VI_DATA_SEQ_YUYV,

    {
    /*port_vsync   port_vsync_neg     port_hsync        port_hsync_neg        */
    VI_VSYNC_PULSE, VI_VSYNC_NEG_LOW, VI_HSYNC_VALID_SINGNAL,VI_HSYNC_NEG_HIGH,VI_VSYNC_VALID_SINGAL,VI_VSYNC_VALID_NEG_HIGH,

    /*hsync_hfb    hsync_act    hsync_hhb*/
    {0,            1280,        0,
    /*vsync0_vhb vsync0_act vsync0_hhb*/
     0,            720,        0,
    /*vsync1_vhb vsync1_act vsync1_hhb*/
     0,            0,            0}
    },
    VI_DATA_TYPE_RGB,
    HI_FALSE,
    {1920, 1080},
    {
        {
            {1920 , 1080},

        },
        {
            VI_REPHASE_MODE_NONE,
            VI_REPHASE_MODE_NONE
        }
    },
    {
        WDR_MODE_NONE,
        1080
    },
    DATA_RATE_X1
};

SAMPLE_COMM_VI_GetComboAttrBySns

        case SONY_IMX334_MIPI_2M_60FPS_12BIT:
            if (0 == MipiDev)
            {
                memcpy_s(pstComboAttr, sizeof(combo_dev_attr_t), &MIPI_4lane_CHN0_SENSOR_IMX334_12BIT_2M_NOWDR_ATTR, sizeof(combo_dev_attr_t));
            }

结构体

combo_dev_attr_t MIPI_4lane_CHN4_SENSOR_IMX477_12BIT_12M_NOWDR_ATTR =
{
    .devno = 4,
    .input_mode = INPUT_MODE_MIPI,
    .data_rate = MIPI_DATA_RATE_X1,
    .img_rect = {0, 0, 4000, 3000},

    {
        .mipi_attr =
        {
            DATA_TYPE_RAW_12BIT,
            HI_MIPI_WDR_MODE_NONE,
            {8, 9, 10, 11, -1, -1, -1, -1}
        }
    }
};

vi要改的基本就是这样 下面改isp.c

sample_comm_isp.c

SAMPLE_COMM_ISP_GetSnsObj

    case SONY_IMX334_MIPI_2M_60FPS_12BIT:
    case SONY_IMX334_MIPI_2M_120FPS_12BIT:
        return &stSnsImx334Obj;

SAMPLE_COMM_ISP_GetIspAttrBySns

    case SONY_IMX334_MIPI_2M_60FPS_12BIT:
        memcpy(pstPubAttr, &ISP_PUB_ATTR_IMX334_2K_60FPS, sizeof(ISP_PUB_ATTR_S));
        break;

其中结构体:

ISP_PUB_ATTR_S ISP_PUB_ATTR_IMX334_2K_60FPS =
{
    {0, 0, 1920, 1080},
    {1920, 1080},
    60,
    BAYER_RGGB,
    WDR_MODE_NONE,
    0,
};

至此,操作完毕,基本上,就ok了

编译测试

在编译完imx334这边再重新编译sample_vio ,然后调用SAMPLE_VIO_8K30_PARALLEL()之后就可以在电脑上得到图像,没有操作其他的也能得到图像,具体原因懒得看了,因为有下面这句话,

printf("===Imx334 2M60fps 12bit LINE binning 4lane Init OK!===\n");

所以在执行程序后看见下图就认调成了
在这里插入图片描述

目录
相关文章
|
6月前
|
存储 Linux 开发工具
Rockchip系列之浅度分析UART接口系列(1)
Rockchip系列之浅度分析UART接口系列(1)
379 1
|
6月前
|
Java Android开发
Rockchip系列之客制化GPIO接口应用部分(5)
Rockchip系列之客制化GPIO接口应用部分(5)
62 0
|
6月前
|
Linux API Android开发
Rockchip系列之客制化GPIO接口Hardware部分(3)
Rockchip系列之客制化GPIO接口Hardware部分(3)
98 0
|
6月前
|
Shell Android开发
Android USB系统初始化init.usb.rc
Android USB系统初始化init.usb.rc
317 0
|
芯片
IMX6ULL平台的I2C
IMX6ULL平台的I2C
146 0
IMX6ULL平台的I2C
|
6月前
|
存储 Unix C语言
STM32--RTC实时时钟
STM32--RTC实时时钟
160 0
|
存储 Linux C语言
stm32cubeMX学习、USB DFU(Download Firmware Update)固件更新
stm32cubeMX学习、USB DFU(Download Firmware Update)固件更新
651 1
|
芯片
stm32-HAL使用stop模式后DMA初始化的问题
stm32-HAL使用stop模式后DMA初始化的问题
276 1
stm32-HAL使用stop模式后DMA初始化的问题
|
物联网 中间件
AliOS Things 使用HAL库的USB_DEVICE MSC调用SPI W25Q128
AliOS Things的USB_DEVICE MSC的SPI W25Q128实现
1135 0