原创 续:i.MX27视频应用技术详解-TW2835

2011-10-11 12:27 1284 4 4 分类: 消费电子

interface_param = (sensor_interface *)

             kmalloc(sizeof(sensor_interface), GFP_KERNEL);

         if (!interface_param) {

                   printk(KERN_ERR "tw2835_detect_client: kmalloc failed \n");

                   return -1;

         }

         interface_param->mclk = 27000000;

 

         printk(KERN_INFO "TW2835 Detected\n");

 

         return 0;

}

 

 

struct camera_sensor camera_sensor_if = {

         .set_color = tw2835_set_color,

         .get_color = tw2835_get_color,

         .set_ae_mode = tw2835_set_ae_mode,

         .get_ae_mode = tw2835_get_ae_mode,

         .set_ae = tw2835_set_ae,

         .set_awb = tw2835_set_awb,

         .flicker_control = tw2835_flicker_control,

         .get_control_params = tw2835_get_control_params,

         .config = tw2835_config,

         .reset = tw2835_reset,

         .get_status = tw2835_get_status,

         .set_channel = tw2835_set_channel,

};

EXPORT_SYMBOL(camera_sensor_if);

导出camera_sensor_if,在v4l2采集驱动中被使用,用来实现该芯片的控制接口,因此如果有多个视频采集芯片驱动,那么同时只能有一个驱动导出该结构体。否则会

发生冲突。

 

 

static void tw2835_interface(sensor_interface * param, u32 width, u32 height)

{

         param->Vsync_pol = 0x0;

         param->clk_mode = 0x0;          //gated

         param->pixclk_pol = 0x0;

         param->data_width = 0x1;

         param->data_pol = 0x0;

         param->ext_vsync = 0x1;

         param->Vsync_pol = 0x0;

         param->Hsync_pol = 0x0;

         param->width = width - 1;

         param->height = height - 1;

         param->pixel_fmt = IPU_PIX_FMT_UYVY;

         param->mclk = 27000000;

         /* setup cropping */

         g_cam->crop_bounds.left = 0;

         g_cam->crop_bounds.width = width;

         g_cam->crop_bounds.top = 0;

         g_cam->crop_bounds.height = height;

         g_cam->crop_defrect = g_cam->crop_bounds;

         if ((g_cam->crop_current.width > g_cam->crop_bounds.width)

                || (g_cam->crop_current.height > g_cam->crop_bounds.height))

                   g_cam->crop_current = g_cam->crop_bounds;

         g_cam->streamparm.parm.capture.capturemode = 0;

 

         g_cam->standard.index = 0;

         g_cam->standard.id = (height == 576) ? V4L2_STD_PAL : V4L2_STD_NTSC;

         g_cam->standard.frameperiod.denominator = (height == 576) ? 50 : 60;

         g_cam->standard.frameperiod.numerator = 1;

         g_cam->standard.framelines = height;

}

 

在mxc_v4l2_capture.c[v4l2驱动实现]中定义了cam_data *g_cam;我们在tw2835.c[i2c驱动]中来填充它,

设置我们需要采集的视频的制式,场数,crop的高度和宽度等。

文章评论0条评论)

登录后参与讨论
我要评论
0
4
关闭 站长推荐上一条 /2 下一条