3.5 cam_data结构体详解

来源:互联网 发布:五十知天命六十是什么 编辑:程序博客网 时间:2024/06/15 05:24
typedef struct _cam_data { struct video_device *video_dev; int device_type; /* semaphore guard against SMP multithreading */ struct semaphore busy_lock;    //针对SMP的信号量int open_count;  //open函数的引用计数,调用一次open函数,这个引用计数加1/* params lock for this camera */ struct semaphore param_lock;  //针对camera的信号量/* Encoder */ struct list_head ready_q; //三个工作队列之一,这个是应用程序 VIDIOC_QBUF调用后,buffer所处的队列struct list_head done_q; //三个工作队列之一,这个是应用程序调用mxc_streamon函数后,buffer所处的队列struct list_head working_q; //三个工作队列之一,这个是应用程序VIDIOC_DQBUF调用时,buffer所处的队列int ping_pong_csi; //这个值一般取0或者1,在CPMEM中buffer地址的更新过程中使用spinlock_t queue_int_lock; spinlock_t dqueue_int_lock; struct mxc_v4l_frame frame[FRAME_NUM]; /* 这个数组是buffer的核心,应用程序申请的frame的信息都   * 保存在这个数组中*/struct mxc_v4l_frame dummy_frame; //虚假的frame,在CPMEM初始化时用这个frame的地址来填充wait_queue_head_t enc_queue;  //译码buffer队列,一般在camera_callback函数中唤醒,在VIDIOC_DQBUF中进行等待,与下面的enc_counter一起使用int enc_counter;  //执行完译码任务的buffer计数,译码队列的唤醒条件dma_addr_t rot_enc_bufs[2];  //rot中需要使用两个buffer,其中buffer的物理地址存放在这个数组中void *rot_enc_bufs_vaddr[2];  //虚拟地址存放在这个数组中 int rot_enc_buf_size[2];  //这两个buffer的大小分别存放在这个数组中enum v4l2_buf_type type; //buffer的类型/* still image capture */  /* 静态图片的一些信息 */wait_queue_head_t still_queue;  //静态图片任务队列int still_counter;  //静态图片任务计数dma_addr_t still_buf[2];   //静态图片任务需要使用的两个buffer的地址存放在这个数组中void *still_buf_vaddr; /* overlay */  /* overlay的一些信息 */struct v4l2_window win; struct v4l2_framebuffer v4l2_fb; dma_addr_t vf_bufs[2]; void *vf_bufs_vaddr[2]; int vf_bufs_size[2]; dma_addr_t rot_vf_bufs[2]; void *rot_vf_bufs_vaddr[2]; int rot_vf_buf_size[2]; bool overlay_active; int output; struct fb_info *overlay_fb; int fb_origin_std; struct work_struct csi_work_struct; /* v4l2 format */  /* v4l2的一些格式信息 */struct v4l2_format v2f;  //这个结构体保存的是v4l2的格式信息,这些信息都应用程序中通过VIDIOC_S_FMT宏最后设置好保存在里面的,包括width,height,bytesperline,sizeimage等参数。struct v4l2_format input_fmt;/* camera in */  /* 摄像头输入的格式 */bool bswapenable; int rotation;/* for IPUv1 and IPUv3, this means encoder rotation */ int vf_rotation; /* viewfinder rotation only for IPUv1 and IPUv3 */ struct v4l2_mxc_offset offset; /* V4l2 control bit */  /* 一些控制信息 */int bright;  //亮度int hue; int contrast;  //对比度int saturation; int red; int green; int blue; int ae_mode; /* standard */ struct v4l2_streamparm streamparm; struct v4l2_standard standard; bool standard_autodetect;  /* crop */  /* crop的一些信息 */struct v4l2_rect crop_bounds;  //crop边界信息struct v4l2_rect crop_defrect;  //crop默认矩形的信息struct v4l2_rect crop_current;  //当前crop的信息/* 以下这几个函数指针分为三种 *//* encoding相关的函数指针 */int (*enc_update_eba) (void *private, dma_addr_t eba);   //更新cpmem中buffer地址的函数指针int (*enc_enable) (void *private);   //使能enc函数指针int (*enc_disable) (void *private);  //关闭enc函数指针int (*enc_enable_csi) (void *private);   //使能csi设备函数指针int (*enc_disable_csi) (void *private);  //关闭csi设备函数指针void (*enc_callback) (u32 mask, void *dev);  //中断处理函数指针/* viewfinder相关的函数指针,这几个函数都在mxc_v4l2_capture.c中的start_preview函数指定 */int (*vf_start_adc) (void *private); int (*vf_stop_adc) (void *private); int (*vf_start_sdc) (void *private); int (*vf_stop_sdc) (void *private); int (*vf_enable_csi) (void *private); int (*vf_disable_csi) (void *private); /* csi相关的函数指针 */int (*csi_start) (void *private); int (*csi_stop) (void *private); /* misc status flag */  /* 一些标记位 */bool overlay_on;  //是否打开overlay的标记位bool capture_on;  //是否打开capture的标记位,在streamon函数中置位int overlay_pid; int capture_pid; bool low_power;   //用于标记这个设备是否处于低电平状态,在 resume函数中设置为false,在suspend函数中设置为true,这个标记位与cam->power_queue队列一起使用。wait_queue_head_t power_queue;  //在resume函数中根据low_power 标志位来唤醒unsigned int ipu_id;   //ipu IDunsigned int csi;  //每个ipu可以拥有两个csi设备,用于区别哪一个csi设备,0或者1u8 mclk_source; bool mclk_on[2];/* two mclk sources at most now */ int current_input; //当前输入,在mxc_v4l2_capture.c中有一个mxc_capture_inputs []数组,驱动程序会根据这个 current_input这个数字作为下标从这个数组中索引。int local_buf_num; /* camera sensor interface */  /* CSI相关的信息 */struct camera_sensor *cam_sensor;/* old version */ struct v4l2_int_device *all_sensors[MXC_SENSOR_NUM]; struct v4l2_int_device *sensor;  //有关摄像头的信息都保存在这个结构体中,它为一个slave子设备struct v4l2_int_device *self;  //将cam->self结构体作为一个master主设备,cam->self->priv指向这个cam_data结构体int sensor_index; void *ipu; void *csi_soc; enum imx_v4l2_devtype devtype; /* v4l2 buf elements related to PxP DMA */ struct completion pxp_tx_cmpl; struct pxp_channel *pxp_chan; struct pxp_config_data pxp_conf; struct dma_async_tx_descriptor *txd; dma_cookie_t cookie; struct scatterlist sg[2]; } cam_data

0 0
原创粉丝点击