Home
        LSP 2.10 Davinci Linux VPFE Capture Driver
         Contents
1.         consider that TVP7002 is the current decoder     tvp7002_params params   ret   IOCTL fd  VPFE_CMD_S_DECODER_PARAMS   amp params     if ret      perror   VPFE_CMD_G_DECODER_PARAMS An      close  fd     return  1           LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview  2 2 5 26 Set CCDC Parameters   This IOCTL is used to set CCDC parameters    IOCTL  VPFE_S_CCDC_PARAMS    It takes void  as an input argument which ultimately points to the ccdc_param structure instance     Example   struct ccdc_param params     initialize the CCDC parameters   ret   IOCTL fd  VPFE_S_CCDC_PARAMS   amp params     if ret     perror   VPFE_S_CCDC_PARAMS n      close  fd    return  1     2 2 5 27 Get CCDC Parameters  This IOCTL is used to get CCDC parameters   IOCTL  VPFE_G_CCDC_PARAMS    It takes void  as an output argument which ultimately points to the ccdc_param structure instance   Example     struct ccdc_param params   ret   IOCTL fd  VPFE_G_CCDC_PARAMS   amp params     if ret      perror   VPFE_G_CCDC_PARAMS n       close  fd     return  1     2 2 5 28 Configure TVP 5146 Parameters  Replaced with Get Set decoder parameters as shown in Section 2 2 5 24 and Section 2 2 5 25     2 2 5 29 Set MT9T001 Parameters    This IOCTL is for backward compatibility  This calls setparam   call from MT9T001 MT9T031 driver if it is  the current decoder     IOCTL  VPFE_CMD_S_MT9T001_PARAMS    Example      
2.        SPRUGP6   June 2009    Submit Documentation Feedback    LSP 2 10 Davinci Linux VPFE Capture Driver 15    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    2 2 5    IOCTLs Handling    2 2 5 1 Query Capabilities    This IOCTL is used to identify kernel devices compatible with V4L2 specification and to obtain information  about individual hardware capabilities     IOCTL  VIDIOC_QUERYCAP    Capabilities can be like video capture  V4L2_CAP_VIDEO_CAPTURE  or streaming   V4L2_CAP_STREAMING  capabilities     It takes pointer to v412_capability structure as an argument  Capabilities can be accessed by capabilities  field of v412_capability structure     Example     struct v412_capability capability   ret   IOCTL fd  VIDIOC_QUERYCAP   amp capability    if ret     printf   Cannot do QUERYCAP n      return  1      if  capability capabilities  amp  V4L2_CAP_VIDEO_CAPTURE     printf   Capture capability is supported n        if  capability capabilities  amp  V4L2_CAP_STREAMING     printf  Streaming is supported n            2 2 5 2 Input Enumeration    This IOCTL is used to enumerate the information of available inputs  analog interface     IOCTL  VIDIOC_ENUMINPUT   It includes information like name of input type  supported standards for that input type    Application will provide the index number for which it wants the information  as part of v4l2_input structure     Index with value zero indicates first input type of first decoder that has been registered at the time of  modu
3.      VPFE  interface Internal    Image  CCDC ISIF A  Processing  Raw Bayer  RGB or  YUV data       SDRAM SDRAM    VPFE provides an input interface for external imaging peripherals such as image sensors  video decoders  etc  VPFE can process Raw Bayer RGB data from an image sensor such as Micron s MT9T001 and  convert to viewable formats such as UYVY using the image processing hardware in the VPFE  lt can also  process Raw YUV data from a video decoder device such as TVP5146 or TVP7002     VPFE consists of two main blocks     e CCD controller  CCDC   This has been renamed to Image Sensor Interface  ISIF  in DM365 but refers  to the same  This block pre process input data before saving to SDRAM or passing it to the Image  processing block  Pre processing is applicable only for raw Bayer RGB data from a sensor  Examples  of pre processing includes defect pixel correction  a law compression  color space conversion  data  formatting etc    e Image Processing  IMP   This block is responsible for doing image tuning on a raw Bayer RGB data  output from CCDC ISIF or from SDRAM and upscale downscale the output to a desired resolution  In  DM6446  this block consists of Preview Engine and Resizer  More features have been added to VPFE  in newer SoCs to help in image processing and the same is renamed to Image Pipe  IPIPE  in DM355  and DM365  Image processing unit has a pipeline of modules each of which modifies the image based  on parameters configured in these modules     LSP 2 10 Dav
4.    For this  VINTO is configured to occur at VD  This will generate the frame and field interrupts to align with  the frame and field start  VINT1 is configured to occur at midway in the frame     For interlaced scan  frame interrupt coincides with the top field  first field  interrupt and bottom field   second field  interrupt happens at the middle of frame interrupts  For progressive scan  only frame  interrupts happens  VINT1 is configured to happens at midway between frame interrupts for progressive  scans     Figure 5 illustrates the relationship between the first interrupt and incoming data in case of frame interrupt     Figure 5  Interrupt Handling Timing Diagram    CPU Kicks the VPFE Module          28    i  1  1  l  l Aa A ne    top field n  bottom field n  top field n 1  bottom field n 1  top field n 2  bottom field n 2     frame n 1  capture frame n 2  time   1 I I l I l l   I I I 1 I l 1   I I I I Li I I   y y y y y y y  1st Frame Bottom 2nd Bottom 3rd Bottom 4th  Insterrupt Field Frame Field Frame Field Frame    output start  Interrupt Interrupt Interrupt Interrupt Interrupt Interrupt    This is the sequence    1  VPFE Capture driver attaches  vpfe_isr   routine to process VINTO and vdint1_isr   to process VINT1  interrupts    2  When application call STREAMON IOCTL  vpfe driver calls configure   function from the ccdc hw  interface to configure CCDC  As part of this  CCDC module configures VINTO and VINT1  if  progressive scan     3  The address of the first fra
5.    check the respective ccdc header file for details           Support for following CCDC pre processing modules are available on DM365  These modules can be  configured through the above IOCTL call   e Defect Pixel Correction  e Color Space Conversion  e Linearization  e Culling  e A Law and DPCM compression  e Black Clamp  4 2 2 CCDC Control  Following control IDs  defined in davinci_vpfe h  are available for CCDC control loctls   e VPFE_CCDC_CID_R_GAIN     Adjustment of Gain for R  e VPFE_CCDC_CID_GR_GAIN   Adjustment of Gain for Gr  e VPFE_CCDC_CID_GB_GAIN     Adjustment of Gain for Gb  e VPFE_CCDC_CID_B_ GAIN     Adjustment of Gain for B  e VPFE_CCDC_CID_OFFSET   Offset adjustment  SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 35    Submit Documentation Feedback    User  4 2 3    4 2 4    36    Interface    MT9T001    I  TEXAS  INSTRUMENTS    www ti com  Parameter Structure    include file is mt9t001 h    struct mt9t001_params    v412_std_id std   int inputids   struct mt9t001_format_params format   struct mt9t001_rgb_gain rgb gain   struct mt9t001_black_level_calibration black_calib          Fields   std  inputidx  format  rgb_gain  black _calib    Standard of MT9T001   Index of input of MT9T001 device   Standard specific MT9T001 parameters  See mt9001 h for details   RGB gain parameters  See mt9001 h for details    Black level calibration value  See mt9001 h for details     MT9P031 Parameter Structure  include file is mt9p031 h    struct mt9p031_params  
6.    int   queryctrl   struct v412_queryctrl  qctrl        Set SoC control      int   setcontrol   struct v412_control  ctrl        Get SoC control      int   getcontrol   struct v412_control  ctrl        Pointer to function to set current standard info     int   setstd   char  std        Pointer to function to get current standard info     int   getstd_info   struct ccdc_std_info  std_info         Pointer to function to set frame buffer address     void   setfbaddr   unsigned long addr        Pointer to function to get field id      int   getfid   void        Pointer to deinitialize function      int   deinitialize   void                  2 2 4 2 Image Processing Unit Configuration    Image processing exposes two interfaces  defined in imp_hw_interface h  to configure the IPIPE and  Resizer  One interface is used by previewer 8 Resizer driver   See Previewer Resizer Driver User manual  for details   The other interface is used by VPFE capture driver to configure parameters like width  height   pixel format  resize ratio etc when user invokes ioctls  The IPIPE modules on DM355 and DM365  implements the interface functions  Following are the set of functions exposed by IPIPE module to vpfe  capture driver     Example 2  Functions Exposed by IPIPE to VPFE Capture Driver       struct imp_hw_interface         Name of the image processor hardware     char  name        update output buffer address for a channel     if config is NULL  the shared config is assumed     this is used only
7.   consider that MT9T001 MT9T031 is the current decoder     mt9t001 params params     initialize the mt9t001 parameters   ret   IOCTL fd  VPFE_CMD_S_MT9T001_PARAMS   amp params     if ret      perror   VPFE_CMD_S_MT9T001_PARAMS n       close  fd     return  1           SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 27  Submit Documentation Feedback    I  TEXAS    INSTRUMENTS  Driver Overview www ti com    2 2 5 30 Get MT9T001 Parameters    2 2 6    This IOCTL is for backward compatibility  Driver provides functionality to fetch parameters of  MT9T001 MT9TO31  if it is a current decoder     IOCTL  VPFE_CMD_G_MT9T001_PARAMS    It takes void  as an output argument which ultimately points to the structure to the mt9t001_params  structure instance     Example        consider that MT9T001 is the current decoder     mt9t001_params params   ret   IOCTL fd  VPFE_CMD_G_MT9T001_PARAMS  params    if  ret      perror   VPFE_CMD_G_MT9T001_PARAMS n       close  fd     return  1           ISR Handling    CCDC has three interrupt registers    VINTO  VINT1 and VINT2  They can be programmed to occur at any  instance relative to VD signal from the hardware  In the VPFE driver  interrupts are used to mark a frame  capture is complete and schedule next frame for capture and also release the frame to application   Different interrupts are used for this purpose based on whether the capture happens from output of CCDC  or output of Resizer     2 2 6 1 Output From CCDC  Data Flow Path 1  
8.   v412_std_id std   int inputidx     struct   struct   struct   struct        Fields  std  inputidx  format  rgb_gain  test_pat  misc_cfg    LSP 2 10 Davinci Linux VPFE Capture Driver    mt9p031_format_params format   mt9p031_rgb_gain rgb_gain   mt9p031_test_pat test_pat   mt9p031_misc_cfg misc_cfg     Standard of MT9P031   Index of input of MT9P031 device   Standard specific MT9T001 parameters  See mt9p031 h for details   RGB gain parameters  See mt9p031 h for details    Test pattern to replace real image data  See mt9p031 h for details   Miscellaneous parameters  See mt9p031 h for details     SPRUGP6   June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com User Interface    4 2 5 TVP5146 Parameter Structure  include file is tvp514x h    struct tvp514x_params    v412_std_id std   int inputidx   struct v412_format fmt         Fields   std Standard of TVP5146   inputidx Index of input of TVP5146 device   fmt VBI format  not supported in VPFE Capture driver     4 2 6 TVP7002 Parameter Structure  include file is tvp7002 h    struct tvp7002_params     v412_std_id std    int inputidx    struct alc_filter alc    struct tvp7002_gain gain    struct tvp7002 offset offset    struct tvp7002_format_params format         Fields   std Standard of TVP7002   inputidx Index of input of TVP7002 device   alc ALC filter params  See tvp7002 h for details    gain Structure for gain information  See tvp7002 h for details    offset Structure for offset brightness  informatio
9.  2009 LSP 2 10 Davinci Linux VPFE Capture Driver 25  Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    2 2 5 23 Get Priority    This IOCTL is used to get priority for file descriptor   IOCTL  VIDIOC_G_PRIORITY    It will take pointer to instance of v4l2_priority structure as an output parameter   Example     enum v412 priority priority   ret   IOCTL fd  VIDIOC_G_PRIORITY   amp priority    if ret     perror   VIDIOC_G_PRIORITY n      close  fd    return  1      If  priority    V4L2_PRIORITY_DEFAULT   Printf   Default Priorityin       2 2 5 24 Get Decoder Parameters    This IOCTL is used to get parameters of current decoder which are specific to respective decoder and can  not be got with v4l2 ioctls     IOCTL  VPFE_CMD_G_DECODER_PARAMS    It takes void  as an output argument which ultimately points to the structure to the decoder set_params  structure instance     Example        consider that TVP7002 is the current decoder     tvp7002_params params   ret   IOCTL fd  VPFE_CMD_G_DECODER_PARAMS   amp params     if ret      perror   VPFE_CMD_G_DECODER_PARAMS An      close  fd     return  1           2 2 5 25 Set Decoder Parameters    26    This IOCTL is used to set parameters of current decoder which are specific to respective decoder and can  not be set with v4l2 ioctls     IOCTL  VPIF_CMD_S_DECODER_PARAMS    It takes void  as an output argument which ultimately points to the structure to the decoder set_params  structure instance     Example
10.  BUF TYPE VIDEO CAPTURE   ret   IOCTL  fd  VIDIOC_G_FMT   amp fmt    if ret      perror   VIDIOC_G_FMT n       close  fd     return  1        2 2 5 12 Try Format  This IOCTL is used to validate the format for current decoder   IOCTL  VIDIOC_TRY_FMT  Driver will adjust the parameter as required by the hardware   It will take pointer to instance of v4l2_format structure as an input parameter     Format type will be set as V4L2_BUF_TYPE_VIDEO_CAPTURE for capture driver  v4l2_ format structure  contains parameters like Pixel format  size of image  bytes per line  field type        Example     struct v412 format fmt   fmt type   V4L2_BUF_TYPE_VIDEO_CAPTURE   fmt fmt pix pixelformat   V4L2_PIX_FMT_UYVY   fmt fmt pix width   720   fmt fmt pix height   480   fmt fmt pix field   V4L2_FIELD_INTERLACED   ret   IOCTL fd  VIDIOC_TRY_FMT   amp fmt    if ret      perror   VIDIOC_TRY_FMT An      close  fd     return  1           Parameters are adjusted by driver as given in Table 2     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 21  Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    2 2 5 13 Set Stream Parameters    This IOCTL is used to change the fps from 60 to 30 for 720P 60fps capture from TVP7002  This is only  added as a work around to support 720P 30fps     IOCTL  VIDIOC_S_PARM    Example   struct v412 streamparm param   param type   VAL2 BUF TYPE VIDEO CAPTURE        param parm capture timeperframe numerator   1   param parm captu
11.  Bayer Pattern GrRBGb     8 bit   This is  V4L2 PIX FMT_ YUYV  A Law compressed or DPCM compressed based on compression algorithm V4L2_ PIX_FMT_NV12    selected in CCDC configuration   V4L2_PIX_FMT_UYVY  V4L2_PIX_FMT_NV12        1  Pixel formats shown in italics require data flow path 2 to be configured in the driver        Example   struct v412_fmtdesc fmt   i   0   while 1     fmt index   i   ret   ioctl fd  VIDIOC_ENUM FMT  amp  fmt    if  ret     break      printf   description    s n  fmt description     if fmt type    V4L2_BUF_TYPE_VIDEO_CAPTURE   printf   Video capture type n     if fmt pixelformat    V4L2_PIX_FMT_UYVY   printf   V4L2_PIX_FMT_UYVY n      itt      SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 19    Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Driver Overview www ti com  2 2 5 10 Set Format   This IOCTL is used to set format for current decoder    IOCTL  VIDIOC_S_ FMT    Driver will validate the input parameters  Driver will return an error if parameters are not valid otherwise  driver will configure these parameters     It will take pointer to instance of v4l2_format structure as an input parameter  Format type will be set as   V4L2 BUF_TYPE_VIDEO_CAPTURE for capture driver  v4l2_ format structure contains parameters like  Pixel format  size of image  bytes per line  field type  Driver will adjust the width and height to match with  the hardware           Note  If the preview Resizer is configured in the continuous mode  call
12.  Pointer to function to try format      int   tryformat   struct v412 pix format  argp        Pointer to function to set buffer type      int   set_buftype   enum ccdc_buftype buf_type        Pointer to function to get buffer type      int   get_buftype   enum ccdc_buftype  buf_type        Pointer to function to set frame format                   int   set_frame_format   enum ccdc_frmfmt frm_fmt        Pointer to function to get frame format     int   get_frame_format   enum ccdc_frmfmt  frm_fmt        Pointer to function to set buffer type     int   get_pixelformat   unsigned int  pixfmt       Pointer to function to get pixel format  Uses V4L2 type     in   ixelform nsign in ixfmt     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 13    Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    Example 1  CCDC Device Interface  continued           Pointer to function to set image window       int   set_image_window   struct v412_rect  win       Pointer to function to set image window     int   get_image_window   struct v412_rect  win         Pointer to function to set line length     int   set_line_length   unsigned int len        Pointer to function to get line length     int   get_line_length   unsigned int  len        Pointer to function to set crop window     int   setcropwindow   struct v412_rect  win       Pointer to function to get crop window     int   getcropwindow   struct v412_rect  win            Query SoC control IDs   
13.  if ret      perror   VIDIOC_QBUF n       close  fd     return  1           Or    struct v412 buffer buf   buf type   V4L2_BUF_TYPE_VIDEO_CAPTURE   buf memory   V4L2_MEMORY_USERPTR   buf index   0      length of the buffer  Calculated based on CCDC RSZ A output    image size that is reported by driver in S_FMT sizeimage  Second    output  RSZ B output  image size is equal to    width   height   bpp  these parameters    are set in Resizer device for output2  bpp depends on pixel format    set in output2 structure              buf length   first output image size    second output image size   ret   ioctl fd  VIDIOC_QBUF     amp buf    if ret     perror   VIDIOC_QBUF n      close  fd      return  1     2 2 5 19 Dequeue Buffer    24    This IOCTL is used to dequeue the buffer in buffer queue   IOCTL  VIDIOC_DQBUF    Application has to specify buffer type  V4L2_BUF TYPE VIDEO _CAPTURE  and memory type   V4L2_MEMORY_MMAP or V4L2 MEMORY_USERPTR  at the time of dequeueing     If this IOCTL is called with the file descriptor  with which VIDIOC_REQBUFS is not been done  driver will  return an error        Driver will enqueue buffer  if buffer queue is not empty     If channel is opened in non blocking mode  this IOCTL call will return immediately if there is no buffer in  queue     It will take pointer to instance of v4l2_ buffer structure as an output parameter     Example     struct v412 buffer buf   buf type   V4L2_BUF_TYPE_VIDEO_CAPTURE   buf type   V4L2_MEMORY_MMAP   ret   IOCTL f
14.  in single shot mode   E   int   update_inbuf_address   void  config  unsigned int address        update output buffer address for a channel     if config is NULL  the shared config is assumed   mf  int   update_outbufl_address   void  config  unsigned int address       update output buffer address for a channel     if config is NULL  the shared config is assumed          m f  int   update_outbuf2_address   void  config  unsigned int address       enable or disable hw     void   enable   unsigned char en  void  config                enable or disable Resizer to allow frame by frame resize in    continuous mode             14 LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS    INSTRUMENTS    www ti com    Driver Overview       Example 2  Functions Exposed by IPIPE to VPFE Capture Driver  continued                void   enable_resize   int en        setup hardware for processing  if config is NULL     shared channel is assumed    Ey  int   hw_setup   struct device  dev  void  config       Get preview irq numbers     void   get_preview_irq   struct irq numbers  irq       Get resize irq numbers     void   get_rsz_irq   struct irq numbers  irq         Get configuration state of Resizer in continuous mode     unsigned int   get_resizer_config_state   void        Get configuration state of previewer in continuous mode     unsigned int   get_previewer_config_state   void            Below APIs assume we are using shared configurat
15.  mapped to first input of second  decoder  and so on     That is  if the first registered decoder is TVP5146 and the second is MT9T031  and both are supporting  one type of input  then if the application will pass 0 as an input index  it will enumerate the input of  TVP5146 and for input index 1  it will enumerate the input of MT9T001     Example     int index   1   ret   IOCTL fd  VIDIOC_S_INPUT   amp index     if ret      perror   VIDIOC_S_INPUT n       close  fd     return  1     2 2 5 4 Get Input  This IOCTL is used to get input type  analog interface type    IOCTL  VIDIOC_G_INPUT  It will call current video decoder   s getinput function to get the current input used by the capture driver     Application will provide the index number as an output argument  In this IOCTL call  parameters of current  decoder will be reset to default value  So this IOCTL should be called before doing any modification to the  default parameters     Example     int input   ret   IOCTL  fd  VIDIOC_G_INPUT   amp input    if ret      perror   VIDIOC_G_INPUT n       close  fd     return  1l     2 2 5 5 Standard Enumeration    This IOCTL is used to enumerate the information regarding video standards  which are possible for the  current input of current decoder     IOCTL  VIDIOC_ENUMSTD    It provides information like standard name  standard id defined at V4L2 header files  some new standards  are added in respective decoder header files  which were not available in standard V4L2 header files     an
16.  of 32    By default  the driver allocates three buffers for the device  The buffer size is 1920 x 1080 x 2   640 x  480 x 2    If the application is requesting the user pointer buffer exchange mechanism  then it must request a  minimum of three buffers    If you have specified less than three and greater than zero buffers at the time of inserting the driver   the driver allocates three buffers  If you have specified zero buffers  the driver assumes the use of the  user pointer buffer exchange mechanism    If you have specified the buffer size as less than the buffer size required to store an NTSC image at  the time of the insertion of the driver  the driver assumes minimum buffer size    If you have specified an incorrect device_type at the time of the insertion of the driver  the driver  assumes zero values for the device_type    In continuous mode  with interlaced scan input  only the second field of the input data is used for  capture at Resizer and is scaled up by 2x to preserve the height  So in this mode  the video is  de interlaced at the driver and hence both fields are not available     LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009    Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com    2 Driver Overview    2 1 Driver Architecture    Driver Overview    Following block diagram shows basic architecture of the VPFE capture Driver     Figure 3  Basic Architecture of the VPFE Capture Driver    Capture and Image Processing Application    
17.  the driver and platform device    Upon probing  the following are done     e Initialize the channel data structures  e Allocate video device and register video device with v4l2 framework    Opening and Closing of Driver    The device can be opened using open call from application with device name and mode of operation as  parameters  Application can open the driver in either blocking mode or non blocking mode  If the channel  is opened in non blocking mode  driver calls  call to DQBUF  will return to application without waiting for  request completion     During open    driver also selects a decoder from the available decoders based on the bootargs and  initialize the same  Using the default standard on the decoder  the channel parameters are configured   This also sets the channel initialized state if everything is successful     The driver will support single I O instance and multiple control instances of each of the channels     The file descriptor with which VIDIOC_REQBUFS IOCTL is called  will become I O instance  And rest will  be control instances     Application can simply call the close function with file handle to close a specific device  Application should  close all the control channels before closing an I O channel        Note  When using data flow path 2 in the capture driver  make sure to open and configure the  previewer and Resizer devices in continuous mode prior to opening the capture device           call to open a video capture logical channel in blockin
18. 4 LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback                         IA TEXAS  INSTRUMENTS  www ti com User Interface  4 User Interface  4 1 API  VPFE capture driver is a V4L2 device  Please refer V4L2 specification for the details of IOCTL calls   Please refer the design section for the IOCTL calls supported   4 2 Data Structures  4 2 1 CCDC Configuration  VPFE Capture driver provides VPFE_CMD_S_CCDC_PARAMS to set CCDC configuration and  VPFE_CMD_G_CCDC_PARAMS to get CCDC configuration  Driver calls setparams   at the ccdc hw  interface to pass the parameters to CCDC module and calls getparams   to get the parameters  Old  IOCTLS  VPFE_CMD_CONFIG_CCDC_RAW  amp  VPFE_CMD_CONFIG_CCDC_YCBCR are supported for  backward compatibility   Application includes ccdc_xxx h  example ccdc_davinci c for DM6446  ccdc_dm355 c for DM355 and so  on  if it needs to configure CCDC  Usually this is required only for Raw bayer capture to enable and  configure CCDC modules such as Defect Pixel Correction  A Law compression  Color Space Conversion  etc  For YCbCr capture standard v4l2 loctls suffice   Following high level data structures are used by application to configure CCDC    struct ccdc_config_params_raw       fields of this structure varies from SoC to Soc     check the respective ccdc header file for details           Following structure used for YCbCr capture   struct ccdc_params_ycbcr       fields of this structure varies from SoC to Soc  
19. 7 Request Buffer Structure for V4 2 coa ad dede dedans 37  4 2 8 Butter Structure tor VaL2 ii aaa 38  4 2 9 Query Capability Structure for VA ca 39  4 2 10 Inp  t Struciure tor VA isaac cos 39  4 2 11 Standard Structure for VAL ssns e a i OE a E 40  4 2 12 Format Description Structure for V4L2        cece ece eee eee eee eee eee ee eee enna seen eee eee nee eae eneeneeneee 40  4 2 13 Format  Structure  for VLZ muii an a E EE a a AEE S 41  4 2 14 Query Control Structure for VdlB    oomocccccccconnnncnnnnnncnnnannrnnrnnnannrnnrnnnrnnnnnrnnnrnnnnnnanes 41  4 2 15 Control  Structure for V  L2 cocinas a ccamaeawecsadiocadeis ciate A sine 42  4 3 Enumerations and Dee iris 42  4 3 1 Possible Standards for Different Decoders                               sisi 42  5 Driver      EE pds boats ca dab al ee deee a a da Ee 43  6 Build and Installation  ciiisean a A aa NENE aea 44  6 1 BUIIG eps  EE EE ERE EEA AEE a 44  SPRUGP6 June 2009 Table of Contents 3    Submit Documentation Feedback    13 TEXAS  INSTRUMENTS  www ti com  6 2 Installation rra a A a da a a 45  7 Example  APpliCAtIONS        lt  lt  miii rr a seer a a 46  4 Contents SPRUGP6 June 2009    Submit Documentation Feedback    IA TEXAS  INSTRUMENTS  www ti com  List of Figures  1 Simplified Architecture Of VPR E ca a iaa 6  2 DM365 EVM Configuration for Video Capture     occocccocccnconcnnccnncnnnanenanennncnnnnnnnnernnnrnnannranennnrnnnnnns 7  3 Basic Architecture of the VPFE Capture Driver    eee eeeeeeeeeeeeeeeeeneeenaseeeeee
20. FE Capture Driver SPRUGP6 June 2009    Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com    User Interface    4 2 9 Query Capability Structure for V4L2    struct v412_capability         ___u8 driver 16    ___u8 card 32    ___u8 bus_info 32    ___u32 version   __u32 capabilities   1132 reserved 4            Relevant Fields for VPFE Capture Driver    driver   card   bus_ info  version  capabilities    ccdc capture   DaVinci EVM   Platform   Version code for VPFE capture module   V4L2 CAP_VIDEO_CAPTURE or V4L2_CAP_STREAMING    4 2 10 Input Structure for V4L2    struct v412_input      u32   u8   u32   u32   __u32  v412_std_id     u32   __u32          name  32      audioset     status   reserved 4      Relevant Fields for VPFE Capture Driver    index    name  std    SPRUGP6   June 2009    Index with value zero indicates first input type of first decoder that has been  registered at the time of module insertion  and after possible inputs for first  decoder  next index from application will be mapped to first input of second  decoder  and so on    For example  if first registered decoder is TVP5146 and second is MT9T001   and both are supporting one type of input  then if application will pass 0 as an  input index  it will enumerate input of TVP5146 and for input index 1  it will  enumerate input of MT9T001     Name of video input    Every video input supports one or more different video standards  This field is  a set of all supported standards     LSP 2 10 Davin
21. Idev video0       V4L2  Driver    Decoder  Driver     dev imp_previewer    Linux Kernel       Previewer    VPFE    Capture  Driver           dev imp_resizer    EVM Board    VPFE Capture driver exposes the capabilities of the hardware to applications using the standard V4L2  interface  Applications will be able to use a V4L2 device  video0  to capture frames from a image sensor  or video decoder connected to VPFE  There are two main data flow paths available in the driver    1  Input interface to SDRAM through CCDC  This path is available on all supported SoCs    2  Input interface to CCDC to Image Processing Unit and then output from Resizer  This is available only  on DM355 and DM365  The Resizer on these devices have two outputs  one full resolution image   RSZ A  and another smaller resolution image  RSZ B   Typically  this helps in previewing one image   usually of a smaller resolution  to a display device and the other  full resolution  for encoding  The  Driver piggy backs the second image at the end of first image in the buffer when the same is    de queued from the device     To support the data path 2  capture driver requires that the IPIPE  amp  Resizer hardware are configured to  operate in the continuous mode through the previewer and Resizer device  Previewer driver drives IPIPE  and Resizer driver drives Resizer hardware respectively  Please refer Previewer Resizer User Manual for  details on these drivers  Once these hardware configuration is complete  Capture 
22. LSP 2 10 Davinci Linux VPFE Capture Driver    User s Guide    I  TEXAS    INSTRUMENTS       Literature Number  SPRUGP6  June 2009    SPRUGP6 June 2009  Submit Documentation Feedback    13 TEXAS  INSTRUMENTS  Contents  1 INTO UICTON  iss seicrs aceite ae ns saidiein aaa A ail arse nin eae ala mdeceee ESE oise annees 6  1 1 EVM Configuration for Video CA a 7  1 2 Supported FOALS ci E ea 8  1 3 COnStraintS rennir daii a A A A 8  2 Driver Overview inci aaa 9  2 1 A crina E ES 9  2 2 DOS invernada 10  2 2 1 Ta 4  le a E 11  2 2 2 Opening and Closing of Driver       ooccccccccnnccnncnonancnancnnncnonnncnncnncnnncnncnannronanenancnnnnns 11  2 2 3 Buffer Management AAA 11  2 2 4 Gontiguration and Controlar ira 13  2 2 5 JOC MESH NGI iria ni Midi needed esas eevee Senn 16  2 2 6 ISR HandIiINgssssssssseeaseseessnnesrenanencaennenniennan A siennes sine 28  3 POTTADIMITY isi oi coria ii A einen eee tenant eee toma einai 30  3 1 nn AA donnee onde nee tee esans 30  3 1 1 Data Structures and API for Decoder Interface    30  3 1 2 SUPPOSE Decoders RER is 33  3 1 3 Adding New Decoder SUP DOM icctesscssccvceconinewaievibae comuienedeb ed EEEE 34  4 User INTC ACS ic iii aa 35  4 1 AP Msi A nin ana ail ointment iv 35  4 2 Data MU a 35  4 2 1 CGDC Configuration Li in 35  4 2 2 ECDOC Mii 35  4 2 3 MT9T001 Parameter St  clU O asicinii a aa EE E 36  4 2 4 MT9P031 Parameter StruiGtlrescccicecessitendsicad aaa 36  4 2 5 TVP5146 Parameter Strict iria ia 37  4 2 6 TVP7002 Parameter S TUCU Sii A 37  4 2 
23. MEMORY_USERPTR  at the time of queuing     If this IOCTL is called with the file descriptor  with which VIDIOC_REQBUFS is not been done  driver will  return an error        Driver will enqueue buffer  if buffer queue is not empty  If queue is empty then driver will directly write  buffer address to hardware registers     It will take pointer to instance of v4l2_ buffer structure as an input parameter     When data flow path 2 is used  there are two output images available in the buffer  First output image size  is calculated based on width  height and pixel format set through S_FMT  Second output image from  RSZ B is available at the end of first output image  So its offset is sizeimage reported by driver in S_FMT  adjusted to 32 byte boundary as follows     e Offset of second output image in the de queued buffer is calculated as  round32  width height bpp   For VGA with UYVY pixel format used for first output  this is  round32  640 480 2   That is  Offset is 614400     e Offset of C plane in the buffer for pixel format NV12 is calculated as round32  width height   For  VGA  with UYVY pixel format  this is round32  640 480   That is  Offset is 307200 bytes     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 23  Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    Examples     struct v412 buffer buf   buf type   V4L2_BUF_TYPE_VIDEO_CAPTURE   buf memory   V4L2_MEMORY_MMAP   buf index   0   ret   IOCTL  fd  VIDIOC_QBUF   amp buf   
24. Mapping Kernel Space Address to User Space    Mapping of the kernel buffer to the user space can be done via mmap  User can pass buffer size and  physical address of buffer for getting the user space address      allocate buffer by VIDIOC_REQBUFS          query the buffer using VIDIOC_QUERYBUF          addr hold the user space address      Int addr    Addr   mmap NULL  buffer size PROT_READ   PROT_WRITE  MAP_SHARED   fd  buffer m offset        buffer m offset is same as returned from VIDIOC_QUERYBUF       LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview  2 2 4 Configuration and Control    This block is responsible for configuring the CCDC and Image processing hardware for capture   Application configures and control the hardware using IOCTL calls  This is done prior to starting streaming  on the device and de queuing the frames  To configure the hardware to implement data flow path  1 and   2  the driver needs to configures CCDC and Image processing Unit  IPIPE and Resizer      VPFE capture driver uses CCDC hw interface  defined ccdc_hw_if h  to configure CCDC and use imp hw  interface  defined in imp_hw_if h  to configure IPIPE and Resizer     2 2 4 1 CCDC Configuration    VPFE driver uses functions defined at the CCDC hw interface  ccdc_hw_if h  to configure CCDC ona  specific SoC  By using these interface functions  the CCDC module conceal the differences in the CCDC  across d
25. NTS    www ti com    SPRUGP6   June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Files    5 Driver Files  Table 3 lists the files for the VPFE Capture driver     Table 3  VPFE Capture Driver Files                                           Filename Location in Linux Tree Description   davinci_vpfe c drivers media video davinci  VPFE capture driver  bridge driver    ccdc_davinci c drivers media video davinci  CCDC module for DM6446   ccdc_dm355 c drivers media video davinci  CCDC module for DM355   ccdc_dm365 c drivers media video davinci  CCDC module for DM365   ccdc_common c drivers media video davinci  Modules that provide timing information for configuring CCDC for  a specific standard    mt9t001 c drivers media video davinci  Decoder module for MT9T001 MT9T031   mt9p031 c drivers media video davinci  Decoder module for MT9P031   tvp514x c drivers media video davinci  Decoder module for TVP5146  Can support TVP5147 as well    tvp7002 c drivers media video davinci  Decoder module for TVP7002   davinci_vpfe h include media davinci  Header file for VPFE Capture driver   ccdc_hw_if h include media davinci  Interface for CCDC module configuration   ccdc_davinci h  include media davinci  Header files required to configure CCDC from application    ccdc_dm355 h   ccdc_dm365 h                         ccdc_common h include media davinci  Types for CCDC timing information   vpfe_types h include media davinci  vpfe types definitions   mt9t001 h incl
26. application        Example        structure to store buffer request parameters     struct v412_requestbuffers reqbuf     reqbuf count   numbuffers   reqbuf type   V4L2_BUF_TYPE_VIDEO_CAPTURE   reqbuf memory   V4L2_MEMORY_MMAP        ret   IOCTL fd   VIDIOC_REQBUFS   amp reqbuf    if ret     printf   cannot allocate memory n     close  fd    return  1          If data flow path 2 is used and Resizer output2 is also enabled  then make sure the frame buffer allocated  should be large enough to hold both images  output1 RSZ A and output2 RSZ B   For MMAP  the kernel  allocates memory to hold both outputs  For USERPTR  this is the responsibility of the application     2  Getting Physical Address   This IOCTL is used to get Physical address of the allocated buffer   IOCTL  VIDIOC_QUERYBUFS    It takes a pointer to instance of v4l2_buffer structure as an argument     User has to specify buffer type  V4L2_BUF_TYPE_VIDEO_CAPTURE   buffer index and memory type   V4L2_MEMORY_MMAP  at the time of querying     Example      allocate buffer by VIDIOC_REQBUFS             structure to query the physical address of allocated buffer     struct v412 buffer buffer     buffer index 0     buffer index for querying  0     buffer  type V4L2_BUF_TYPE_VIDEO_CAPTURE   buffer memory   V4L2_MEMORY_MMAP        if  IOCTL fd  VIDIOC_QUERYBUF   amp buffer      1     printf   buffer query error  n     close  fd    exit   1         The buffer m offset will contain the physical address returned from driver   3  
27. apture drivers as dynamic modules       Use menuconfig to navigate Kconfig tree to Video Capture Adapters menu as shown in Figure 7  Use the  space bar to select the driver to be built as a dynamic module  indicated by M   Save the configuration  and build the kernel image  Once this is complete  build the drivers using the make modules command     Figure 7  VPFE Capture Drivers Selection as a Dynamic Module       Device Drivers  gt   Multimedia devices  gt      lt   gt Video For Linux    Video Capture Adapters  gt         Video Capture Adapters     lt M gt  Davinci Video Capture   lt M gt  DM365 CCDC ISIF HW module   lt M gt  TVP5146 video decoder   lt M gt  MT9T001 Sensor    lt M gt  MT9P031 Sensor    lt M gt  TVP7002 video decoder          44 LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    13 TEXAS  INSTRUMENTS  www ti com Build and Installation  6 2 Installation   The module parameters referred here can be applied as Kernel boot argument as well by adding a   davinci_capture  prefix to it  for example  davinci_capture device_type 1   To use continuous mode  apply   following boot argument   module parameter for image processing  imp  module  depending on how the  module is built into the kernel image     For DM355   dm355_imp oper_mode 0   For DM365   dm365_imp oper_mode 0   Following examples show dynamic insertion and removal of VPFE Capture Device Driver     gt insmod davinci_capture_driver ko device_type 0 channel0_numbuf
28. ci Linux VPFE Capture Driver 39    Submit Documentation Feedback    4 2 11    4 2 12    I  TEXAS       INSTRUMENTS  User Interface www ti com  Standard Structure for V4L2  struct v412 standard     ___u32 index   v412_std_id ids  ___u8 name 24    struct v412_fract frameperiod     Frames  not fields     ___u32 framelines   u32 reserved 4        typedef __u64 v412_std_id   struct v412_fract    132 numerator   ___u32 denominator       Relevant Fields for VPFE Capture Driver  index Index of the supported standards  id Standard id  Supported standards are mentioned in enumerations and define  section   name Name of the standard  frameperiod numerator Numerator value to set particular frame rate for standard   frameperiod denominator Denominator value to set particular frame rate for standard   framelines Total lines per frame including blanking   Format Description Structure for V4L2  struct v412_fmtdesc      _ 32 index     Format number     enum v412_buf_type type     buffer type     __u32 flags   ___u8 description 32      Description string     ___u32 pixelformat     Format fourcc     __u32 reserved 4        Relevant Fields for VPFE Capture Driver  index Index of the supported formats  type Type of the data stream  V4L2_BUF_TYPE_VIDEO_CAPTURE   description Description of the format  a NUL terminated ASCII string  This information is  intended for the user   pixelformat The image format identifier   LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009    40    Submit Docum
29. ci Linux VPFE Capture Driver SPRUGP6 June 2009    Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Portability  3 1 1 2   Standard Ops Structure       standard ops structure     struct standard_ops    int count     int   enumstd  struct v412 standard   argp  void  dec             int   querystd   v412_std_id  argp  void  dec     int   setstd   v412_std_id  argp  void  dec     int   getstd   v412_std_id  argp  void  dec          standard_ops  count Indicates number of standard supported for particular decoder on particular channel   enumstd   This is the function for standard enumeration   Described in Design section    querystd   This is the function for standard detection   Described in Design section    setstd   This is the function for setting the standard   Described in Design section    getstd   This is the function for setting the standard   Described in Design section      3 1 1 3 Control Ops Structure       control ops structure     struct control_ops    int count     int   queryctrl   struct v412_queryctrl  argp  void  dec    int   setcontrol   struct v412_control  argp  void  dec    int   getcontrol   struct v412_control  argp  void  dec            control_ops       count Indicates number of control supported for particular decoder on particular channel     queryctrl   This is the function for query control   Described in Design section   dec contains the  pointer to decoder_device structure which points to the decoder instance of current  channe
30. d     return  1           Note  When using the USERPTR based buffer exchange  the application fills in bytesperline   sizeimage  pixel format and field  The driver calculates the width and height  and returns the  same to the application        20 LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview    The driver makes adjusts the parameters as follows     Table 2  Parameter Adjustments       Parameter Description       height Minimum height is 1 line for progressive scan and 2 lines for interlaced scan   Maximum height is active lines of the standard selected  for data path 1  or height of QXGA  resolution  1536 lines for data flow path 2       width Minimum width is 32 bpp  bytes per pixel    Maximum width is maximum active pixels of the standard selected  for data flow path 1  or line  size of the IPIPE  1344 pixels for DM355 or 2176 for DM365      bytesperline Multiple of 32       2 2 5 11 Get Format  This IOCTL is used to get format for current decoder   IOCTL  VIDIOC_G_FMT  Driver will provide format parameters in the structure pointer passed as an argument     It will take pointer to instance of v4l2_ format structure as an input parameter  Format type will be set as  V4L2 BUF TYPE VIDEO CAPTURE for capture driver  v4l2_ format structure contains parameters like  Pixel format  size of image  bytes per line  field type        Example     struct v412 format fmt   fmt type   VAL2
31. d  VIDIOC_DQBUF  buf    if ret      perror   VIDIOC_DQBUF n       close  fd     return  1        LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview  2 2 5 20 Stream On   This IOCTL is used to start video capture functionality    IOCTL  VIDIOC_STREAMON    If this IOCTL is called with the file descriptor  with which VIDIOC_REQBUFS is not been done  driver will  return an error     If streaming is already started  this IOCTL call will return an error     Example   ret   IOCTL fd  VIDIOC_STREAMON  NULL    if ret     perror   VIDIOC_STREAMON An     close  fd      return  1     2 2 5 21 Stream Off  This IOCTL is used to stop video capture functionality   IOCTL  VIDIOC_STREAMOFF    If this IOCTL is called with the file descriptor  with which VIDIOC_REQBUFS is not been done  driver will  return an error     If streaming is yet not started  this IOCTL call will return an error     Example   ret   IOCTL fd  VIDIOC_STREAMOFF  NULL    if ret     perror  VIDIOC_STREAMOFF An     close  fd    return  1     2 2 5 22 Set Priority  This IOCTL is used to set priority for file descriptor   IOCTL  VIDIOC_S PRIORITY  It will take pointer to instance of v412 priority structure as an intput parameter     Example     enum v412 priority priority   V4L2_PRIORITY_DEFAULT   ret   IOCTL fd  VIDIOC_S_PRIORITY   amp priority    if ret      perror   VIDIOC_S_PRIORITYAn      close  fd     return  1     SPRUGP6 June
32. d numerator and denominator values for frame period and frame lines     It takes index as an argument as a part of v4l2_standard structure  If index value exceeds the number of  standards supported by current decoder  it will give error     Example   struct v412 standard standard   i  0   while 1     standard index   i   ret   ioctl fd  VIDIOC_ENUMSTD   amp standard     if ret     break      SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 17    Submit Documentation Feedback    I  TEXAS    INSTRUMENTS  Driver Overview www ti com  printf  name    s n  std name     printf   std    x n    unsigned long  std id    printf  framelines    d n  std framelines     printf   numerator    d n  std frameperiod numerator     printf   denominator    d n  std frameperiod denominator       itt     2 2 5 6 Example Standard Detection    This IOCTL is used to detect the current video standard set in current decoder   IOCTL  VIDIOC_QUERYSTD    It provides information like standard name  standard id defined at V4L2 header files  some new standards  are added in respective decoder header files  which were not available in standard V4L2 header files     and numerator and denominator values for frame period and frame lines     Driver will call current decoder   s function internally  which has been initialized  to detect the current  standard set in hardware  Support of this IOCTL depends on decoder device  whether it can detect  standard or not     That is  MT9Txxx decoder has no mechani
33. driver will be able to use  it do on the fly  continuous mode  image tuning and scaling     SPRUGP6 June 2009  Submit Documentation Feedback    LSP 2 10 Davinci Linux VPFE Capture Driver 9    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    2 2 Design    10    Figure 4 shows the detailed design of the VPFE Capture Driver     Figure 4  VPFE Capture Driver Detailed Design    Application            Char Driver V4L2 Driver Interface  Interface                                           Configuration  and Control  Hardware  Open Close  Driver  VPFE Capture  Driver  SES        int   l  bebe Initialization   A do  ITA Rd Channel and IE  A   Device l  SS  Unregister Device   A   1  Specific       eevee   IconfigurationKy  SR Processing   ccpc     7          Control and  Configuration    VPFE Capture V4L2 Layer             Initialize  Devices with  Default Values    Configuration of Devices                HW Interface Layer    TVP5146 TVP7002 MT9T001  Driver Driver Driver         CCDC TVP5146 TVP7002 MT9T001 INTC  Hardware Decoder Decoder CMOS Sensor Interrupt                  LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    l    TEXAS    INSTRUMENTS    www ti com Driver Overview    2 2 1    2 2 2    2 2 3    Initialization    At initialization the driver does the following    e Initializes the CCDC for the default configuration parameters  e Allocates vpfe_obj that holds channel configuration   e Allocates frame buffers   e Registers
34. eeeenaeenaeees 9  4 VPFE Capture Driver Detailed DesiON inicie due 10  5 Interrupt Handling Timing Diagram                  eee ence eeee eee eeeeeeeeeneeeneeeeeneeeeeeeeneeeeeeeenneeeneeennes 28  6 VPFE Capture Drivers Selection as a Static Module                                    sisi 44  7 VPFE Capture Drivers Selection as a Dynamic Module                                eee eee e eee eeeeeeeaeeeeneee 44  List of Tables  1 Pixel Formats Supported by VIDIOC_ENUM_FM1           cceeeeeee eee ence eee eee eee tees eeeneeeeaeeeeeeeeeeeeeees 19  2 Parameter Adjustments                      eens EEE E E 21  3 VPFE Capt  re Driver ElleS coco a a ches ce a 43  SPRUGP6 June 2009 List of Figures 5    Submit Documentation Feedback    User s Guide  I pee SPRUGP6 June 2009    LSP 2 10 Davinci Linux VPFE Capture Driver    Introduction    VPFE Capture driver is a V4L2 device driver for capturing video frames from a Raw Bayer RGB or Raw  YUV data source    VPFE Capture driver described in this document is applicable to following DaVinci SoCs    e DM6446   e DM355   e DM365   A simplified architecture  simplified for the sake of describing the driver  of the Video Processing Front  End  VPFE  as applicable to the driver is shown in Figure 1  Only functional IPs that are directly controlled    by the VPFE capture driver is shown in the diagram  Please refer respective VPFE Hardware PRG for  more details on the VPFE available on a particular SoC     Figure 1  Simplified Architecture of VPFE  
35. entation Feedback    1  TEXAS  INSTRUMENTS    www ti com    User Interface    4 2 13 Format Structure for V4L2    struct v412_format      enum v412_buf_type  union         type     struct v412_pix_format pix   struct v412 window win   struct v412 vbi format vbi       fmt       struct v412 pix_ format     __u32      32    32  enum v412_field     _u32   JU32    width   height   pixelformat   field   bytesperline   sizeimage     enum v412_colorspace colorspace     __u32        Relevant Fields for VPFE  type   fmt pix pixelformat  fmt pix field  fmt pix bytesperline  fmt pix sizeimage    priv     Capture Driver    Type of the data stream  V4L2_BUF_TYPE_VIDEO_CAPTURE   The pixel format       The field order of the image in the buffer  Distance in bytes between the leftmost pixels in two adjacent lines   Size in bytes of the buffer to hold a complete image  set by the driver     4 2 14 Query Control Structure for V4L2    struct v412 queryctrl     __u32  enum v412_ ctrl_ type  ___u8  __832  __832  __s32  __832  __u32  __u32        Relevant Fields for VPFE  id  type    name  minimum  maximum  default value    SPRUGP6 June 2009  Submit Documentation Feedback      d    type    name  32      Whatever     minimum     Note signedness     maximum    step    default_value    flags    reserved 2      Capture Driver    Identifies the control  set by the application     Type of control  V4L2_CTRL_TYPE_INTEGER   V4L2 CTRL_TYPE_BOOLEAN etc     Name of control    Minimum value  inclusive  lt is s
36. fers 3 channel0_bufsize 691200   In the above    device type   0     Mt0T001 is the default decoder    device type   1     TVP5146 is the default decoder    device_type   2  gt  MT9T031 is the default decoder    device_type   3  gt  MTOP031 is the default decoder    device_type   4     TVP7002 is the default decoder    channel0_numbuffers   0     Driver buffer count is zero    1  lt   Numbuffers  lt   3     Three driver buffers are allocated  Use this when the USERPTR  buffer exchange mechanism is used so that buffers are not  pre allocated in the driver    3  lt  Numbuffers     Allocated driver buffer count is numbuffers    If channel _numbuffers is not   specified  three driver buffers are   allocated    To remove the module  use this command    gt rmmod davinci_capture_driver  To insert remove ccdc module  use this command    gt insmod ccdc_common ko   gt insmod ccdc_xxx ko  where xxx stands for davinci or dm355 or dm365    gt rmmod ccdc_xxx   gt rmmod ccdc_common  To insert remove TVP514x module  use this command    gt insmod tvp514x ko   gt rmmod tvp514x  To insert remove TVP7002 module  use this command    gt insmod tvp7002 ko   gt rmmod tvp7002  To insert remove MT9T001 module  use this command    gt insmod mt9t001 ko   gt rmmod mt9t001  To insert remove MT9P031 module  use this command    gt insmod mt9p031 ko   gt rmmod mt 9p031  SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 45    Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Example Applica
37. g mode     video0fd_blocking  open    dev video0   O_RDWR         call to open a video capture logical channel in non blocking mode     video0fd_nonblocking  open    dev video0   O_RDWR   O_NONBLOCK          closing of channels       close  video0fd_blocking    close  video0fd nonblocking      Buffer Management    The driver allows two different types of memory allocation modes   e Driver buffer mode  e User buffer mode    For driver buffer mode  application can request memory from driver by calling VIDIOC_REQBUFS  In case  of user buffer  application needs to allocate physically contiguous memory using some other mechanism in  user space  In driver buffer mode  maximum number of buffers is limited to VIDEO MAX FRAME  defined  in driver header files      Here are the major steps to be performed by application for buffer allocation   1  Allocating Memory   This IOCTL is used to allocate memory for frame buffers    IOCTL  VIDIOC_REQBUFS    It takes a pointer to instance of v4l2_requestbuffers structure as an argument     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 11  Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Driver Overview www ti com    12    The user can specify the buffer type  V4L2_BUF_TYPE_VIDEO_CAPTURE   number of buffers and  memory type  V4L2_MEMORY_MMAP  at the time of buffer allocation     The file descriptor which will call VIDIOC_REQBUFS IOCTL  will be considered as I O instance   Constraint  This IOCTL can be called only once from 
38. ifferent SoCs and provides an uniform way to configure the CCDC hardware for capture   Following are the functions available at the interface  To Support a new SoC  a CCDC module is  developed that implements these functions  All of the CCDC modules are developed using this interface     Example 1  CCDC Device Interface             CCDC device interface  mf     struct ccdc_hw_interface         CCDC device name     char  name        Pointer to initialize function to initialize ccdce device     int   initialize   void       Set of functions pointers for control related functions     Use queryctrl of decoder interface to check if it is a decoder    control id  If not passed to ccdc to process it    void   enable   int en       Pointer to function to enable or disable ccdc     u32   reset   void       reset sbl  only for 6446     void   enable_out_to_sdram   int en       Pointer to function to set hw frame type     int   set_hw_if type   enum ccdc_hw_if_type iface       get interface parameters     int   get_hw_if_params   struct ccdc_hw_if_param  param        Set Get parameters in CCDC        Pointer to function to set parameters  Used    for implementing VPFE_S_CCDC_PARAMS  m f  int   setparams   void  params        Pointer to function to get parameter  Used    for implementing VPFE_G_CCDC_PARAMS          e  int   getparams   void  params        Pointer to function to configure ccdc     int   configure   void         Set of functions pointers for format related functions       
39. igned   Maximum value  inclusive  It is signed   The default value of the control     LSP 2 10 Davinci Linux VPFE Capture Driver 41    User Interface  4 2 15 Control Structure for V4L2    struct v412_control     ___u32 id   832 value         Relevant Fields for VPFE Capture Driver    id Identifies the control  set by the application   value Value for corresponding control     4 3 Enumerations and Defines    4 3 1 Possible Standards for Different Decoders  Use respective header files                                                                                            MT9T001  define V4L2_STD_MT9T001_VGA_30FPS  define V4L2_STD_MT9T001_480p_30FPS  define V4L2_STD_MT9T001_576p_25FPS  define V4L2_STD_MT9T001_720p_30FPS  define V4L2_STD_MT9T001_1080p_18FPS  define V4L2_STD_MT9T001_QXGA_12FPS  MT9P031  define V4L2_STD_MT9P031_VGA_30FPS  define V4L2_STD_MT9P031_480p_30FPS  define V4L2_STD_MT9P031_576p_25FPS  define V4L2_STD_MT9P031_720p_30FPS  define V4L2_STD_MT9P031_720p_60FPS  define V4L2_STD_MT9P031_960p_30FPS  define V4L2_STD_MT9P031_1080p_30FPS  define V4L2_STD_MT9P031_1080p_25FPS  define V4L2_STD_MT9P031_SXGA_30FPS  define V4L2_STD_MT9P031_UXGA_30FPS  define V4L2_STD_MT9P031_QXGA_15FPS  TVP5146  define V4L2_STD_525_60  define V4L2_STD_625_50  define VPFE_STD_AUTO  define VPFE_STD_625_50_SQP  define VPFE_STD_525_60_SQP  define VPFE_STD_AUTO_SOP  TVP7002  define V4L2_STD_720P_60  define V412_STD_10801_60    42 LSP 2 10 Davinci Linux VPFE Capture Driver    I  TEXAS  INSTRUME
40. inci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    l    TEXAS    INSTRUMENTS    www ti com Introduction    1 1    Examples of image tuning modules include White Balance  Noise filter  RGB to RGB converter  Edge  enhancement  Gamma Correction etc  Please refer VPFE hardware user guide for more details on  these modules  Resizer hardware is used to upscale or downscale the image to a desired resolution   DM6446 has one Resizer output where as in DM355 and DM365  there are 2 Resizers acting on the  same video input  RSZ A  amp  RSZ B  there by producing 2 output resolutions  VPFE capture driver  would require image processing unit to do image tuning and for upscale or downscale the image  before being written to SDRAM  For chaining the image processing modules in the data path from  CCDC ISIF  IPIPE must be configured to work in continuous mode     VPFE Capture driver can configure VPFE to output data from CCDC ISIF or from the output of Resizer in  Image Processing Module  Not available on DM6446      EVM Configuration for Video Capture    Figure 2 shows the high level configuration of the DM365 EVM that enables video capture using VPFE   The EVM configuration of DM6446 and DM355 are similar except they do not have TVP7002 to do HD  video capture  VPFE provides a Raw Bayer parallel interface as well as 8 16 bit YCbCr interface to  connect a variety of video peripheral to do video capture  See the VPFE hardware PRG for the interface  specification
41. ing VIDIOC_S_ FMT IOCTL  with a pixel format marked italic in Table 1 will use data flow path 2  i e data is output from  Resizer   In this mode  when capturing interlaced video  only second field is captured to  buffer and is scaled up by 2 to get the required height  So the resulting video is  de interlaced  This mean real interlaced capture is not supported in continuous mode        Examples     For using MMAP     struct v412 format fmt   memset   amp fmt  0  sizeof  fmt      fmt type   V4L2_BUF_TYPE_VIDEO_CAPTURE   fmt fmt pix pixelformat   V4L2_PIX_FMT_UYVY   fmt fmt pix width   720   fmt fmt pix height   480   fmt fmt pix field   V4L2 FIELD _INTERLACED   ret   ioctl fd  VIDIOC_S_FMT   amp fmt    if ret      perror   VIDIOC_S_FMT n       close  fd     return  1           Note  When using the MMAP based buffer exchange  the application fills in the width  height  pixel  format and field  The driver calculates bytesperline and sizeimage  and returns the same to  the application        For using USERPTR     struct v412 format fmt   memset   amp fmt  0  sizeof  fmt      fmt type   V4L2_BUF_TYPE_VIDEO_CAPTURE   fmt fmt pix pixelformat   V4L2_PIX_FMT_UYVY   fmt fmt pix bytesperline   720 2     adjust this to be multiple of 32  fmt fmt pix sizeimage   fmt fmt pix bytesperline   480      Driver calculates width and height based on the above     fmt fmt pix field   V4L2_FIELD_INTERLACED   ret   ioctl fd  VIDIOC_S_FMT   amp fmt    if ret      perror   VIDIOC_S_FMT n       close  f
42. intf   name    s n  ctrl name     printf  min    d max    d step    d default    d n    ctrl minimum  ctrl maximum  ctrl step  ctrl default_value       LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview  2 2 5 16 Set Control   This IOCTL is used to set the value for particular control in current decoder    IOCTL  VIDIOC_S_ CTRL    If the control command specified by Id is not supported in current decoder  driver will return an error  It will  take pointer to instance of v4l2_control structure as an input parameter     Example     struct v412 control ctrl   ctrl id   V4L2_CID_GAIN   ctrl value   5   ret   IOCTL fd  VIDIOC_S_CTRL   amp ctrl    if ret     perror  VIDIOC_S_CTRL n      close  fd    return  1     2 2 5 17 Get Control  This IOCTL is used to get the value for particular control in current decoder   IOCTL  VIDIOC_G_CTRL    If the control command specified by Id is not supported in current decoder  driver will return an error  It will  take pointer to instance of v4l2_control structure as an output parameter     Example     v412_std_id ctrl   ret   IOCTL fd  VIDIOC_G_CTRL  ctrl    if ret     perror   VIDIOC_G_CTRL An     close  fd    return  1     2 2 5 18 Queue Buffer  This IOCTL is used to enqueue the buffer in buffer queue   IOCTL  VIDIOC_QBUF    Application has to specify buffer type  V4L2_BUF_TYPE_VIDEO_CAPTURE   buffer index and memory  type  V4L2 MEMORY_MMAP or V4L2_ 
43. ion since     oper mode is continuous  These are called from vpfe capture driver   7      Set the input crop window at the IMP interface and IMP       int   set_input_win   struct imp_window  win       Get current input crop window param at the IMP     int   get_input_win   struct imp_window  win         Set interface parameter at IPIPEIF  Only valid for DM360     int   set_hw_if_param   struct ccdc_hw_if_param  param        Set input pixel format       int   set_in_pixel_format   enum imp_pix_formats pix_fmt        set output pixel format     int   set_out_pixel_format   enum imp_pix_formats pix_fmt         0   interleaved  1   field seperated      int   set_buftype   unsigned char buf_type         0   interlaced  1   progressive      int   set_frame_format   unsigned char frm_fmt        Set the output window at the IMP  output selection    done by out_sel  0   output 1 and 1   output 2    mf  int   set_output_win   struct imp_window  win       Get output enable disable status     int   get_output_state   unsigned char out_sel         Get output line lenght     int   get_line_length   unsigned char out_sel       Get the output image height       int   get_image_height   unsigned char out_sel       Get current output window param at the IMP     int   get_output_win   struct imp_window  win       get maximum output width of rsz a or rsz_b    int   get_max_output_width   int rsz        get maximum output height of rsa a or rsz b     int   get_max_output_height   int rsz        
44. l  lt takes v4l2_querycontrol instance as an output argument  It will validate  passed control id  if it is valid one  it will filled information regarding that control into  structure     setcontrol   This is the function for setting the particular control value  dec contains the pointer to  decoder device structure which points to the decoder instance of current channel  It  takes v4l2_ control instance as an input argument  It will validate passed control id and  value  and if it is valid combination  will set the value in decoder     getcontrol   This is the function for getting the value for particular control  dec contains the pointer to  decoder device structure which points to the decoder instance of current channel  It  takes v4l2_control instance as an output argument  It will validate passed control id  if it  is valid  it will fill value for that control id in structure     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 31  Submit Documentation Feedback    I  TEXAS       INSTRUMENTS  Portability www ti com  3 1 1 4 Input Ops Structure     input ops structure     struct input_ops    int  count   int   enuminput   struct v412_input   argp  void  dec    int   setinput   int  argp  void  dec    int   getinput   int  argp  void  dec        input_ops  count Indicates number of input supported for particular decoder on particular channel   enuminput   This is the function for input enumeration  dec contains the pointer to decoder device  structure which poi
45. le insertion  and after possible inputs for first decoder  next index from application will be mapped to  first input of second decoder  and so on     That is  if the first registered decoder is TVP5146 and the second is MT9T031  and both are supporting  one type of input  then if the application will pass 0 as an input index  it will enumerate the input of  TVP5146 and for input index 1  it will enumerate the input of MT9T031     The following are the names used to represent various inputs to the driver     TVP5146 COMPOSITE and SVIDEO  TVP7002 COMPONENT  MT9TO31 MT9TO01 RAW  MT9P031 RAW 1  Example   struct v412_input input   i   0   while 1     input index   i   ret   IOCTL fd  VIDIOC_ENUMINPUT   amp input     if ret     break      printf  name    s n  input name     printf  std    x n    unsigned long  input std    itt      LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009    Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview  2 2 5 3 Set Input   This IOCTL is used to set input type  analog interface type     IOCTL  VIDIOC_S_INPUT    In order to accomplish this  driver will de initialize the current decoder and initialize the decoder for which  input index is provided  Application will provide the index number as an argument  Index with value zero  indicates first input type of first decoder that has been registered at the time of module insertion  and after  possible inputs for first decoder  next index from application will be
46. ll occur     2 2 6 2 Output From Resizer  Data Flow Path 2     Interrupt handling is concerned  this is similar to the case when data is output from CCDC  Driver needs to  decide when to mark a frame buffer has completed capture and when to schedule next frame for capture     RSZ_INT_DMA  for DM365  or  IPIPE_INT1_SDR  interrupt happens when the Resizer output image is  written to SDRAM  So this interrupt handling is used to free up current frame buffer and schedule next  frame buffer for capture  The buffer address is written to Resizer register as part of this interrupt handling   The assumption is that this interrupt will occur before next frame data arrive at the Resizer   vpfe_imp_dma_isr   is attached to handle this interrupt     The current frame is marked as complete at VINT2 which is configured to occur at the end of the frame   height 1   vpfe_isr   is attached to INT2 interrupt handling     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 29  Submit Documentation Feedback    Portability  3 Portability    3 1 Decoders    I  TEXAS  INSTRUMENTS    www ti com    3 1 1 Data Structures and API for Decoder Interface    3 1 1 1 Decode Device Structure       decoder device structure      struct decoder_device    u8 name  DECODER_MAX_NAME     vid_capture_interface_type if_type   int channel_id   u32 capabilities   int   initialize   void  dec      struct  struct  struct  struct  struct    standard_ops  std_ops   control _ ops  ctrl_ops   input_ops  input_ops   fo
47. me is configured in CCDC when application calls VIDIOC_STREAMON  IOCTL    4  As shown in the above figure  the first interrupt comes  when CCDC starts storing frame in the  SDRAM     LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    www ti com Driver Overview    5  Driver will configure address for the next frame in CCDC registers when interrupt for the first  bottom   field is received  For the even field interrupt  it just marks that capture is completed for the current  frame     6  After single frame capture interrupt  driver will get system time using jiffies timer  This time will be  capture time for particular frame  Application can get this empty buffer with capture time by calling  1OCtl with VIDIOC_DQBUF command    7  If there is only single buffer in the incoming queue of the driver  driver will not update CCDC registers  and CCDC will capture same frame until application calls VIDIOC_QBUF IOCtl  In the VIDIOC_QBUF  IOCtl  driver will set the address of buffer to be queued in the CCDC registers if the buffer queue is  empty and if the CCDC device is currently capturing the bottom field  Otherwise the buffer is queued   So when the next interrupt comes  buffer is already available to the device for capture  There is a  restriction here  If application does not call VIDIOC_QBUF IOCtl after the buffer queue becomes empty  and before the next interrupt  same frame will get captured i e  frame drop wi
48. n  See tvp7002 h for details   format Structure for tvp7002 format params     4 2 7 Request Buffer Structure for V4L2    struct v412_requestbuffers            ___u32 count   enum v412_buf_type type   enum v412_memory memory   ___u32 reserved 2        Fields  count Number of buffers requested  type V4L2_BUF_TYPE_VIDEO_CAPTURE  memory V4L2_MEMORY_MMAP or V4L2_ MEMORY_USERPTR  SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 37    Submit Documentation Feedback    I  TEXAS       INSTRUMENTS  User Interface www ti com  4 2 8 Buffer Structure for V4L2  struct v412_buffer        u32 index   enum v412_buf_type type   __u32 bytesused   u32 flags   enum v412_field field   struct timeval timestamp   struct v412_timecode timecode   ___u32 sequence      memory location     enum v412_memory memory   union    ___u32 offset   unsigned long userptr     m   _u32 length   ___u32 input   ___u32 reserved       Relevant Fields for VPFE Capture Driver  index Index of the buffer  type Type of the data stream  V4L2_BUF_TYPE_VIDEO_CAPTURE  memory V4L2 MEMORY_MMAP or V4L2 MEMORY _USERPTR  bytesused The number of bytes occupied by the data in the buffer   field The field order of the image in the buffer  m userptr When memory is V4L2_ MEMORY_USERPTR this is a pointer to the buffer in  virtual memory  set by the application   m offset When memory is V4L2_ MEMORY_MMAP this is the offset of the buffer from  the start of the device memory   length Size of the buffer  38 LSP 2 10 Davinci Linux VP
49. nts to the decoder instance of current channel  It takes v4l2_input as  an output argument  It contains index field  as per value of it  structure will be filled   setinput   This is the function for setting the input  dec contains the pointer to decoder_device  structure which points to the decoder instance of current channel  It takes input index as  an input argument and as per value of it  input will be set in decoder   getinput   This function will detect  input is present or not  dec contains the pointer to    decoder_device structure which points to the decoder instance of current channel  It  takes input index as an output argument and it will be filled with the current input value     3 1 1 5 Format Ops Structure       format ops structure     struct format_ops     int count    int   enumformat    int   tryformat   int   setformat   int   getformat     struct v412_fmtdesc  argp  void  dec    struct v412 format  argp  void  dec   struct v412 format  argp  void  dec           struct v412 format  argp  void  dec                 r       r        format_ops       count Indicates number of format supported for particular decoder on particular channel     enumformat   This is the function for format enumeration  dec contains the pointer to decoder device  structure which points to the decoder instance of current channel  It takes v412 fmtdesc  as an output argument and index is one of the fields of it  As per value of index  structure  will be filled  Structure contains inf
50. oder_device structure  which points to the decoder instance of current channel     3 1 1 7 vpif_register_decoder Function    int vpif_register_decoder  struct decoder_device  decoder       Decoder will call this function from module_entry function  at the time of module insertion  It will register  itself to VPFE module     3 1 1 8 vpif_unregister_decoder Function  int vpif_unregister_decoder  struct decoder_device  decoder       Decoder will call this function from module_exit function  at the time of module insertion  It will unregister  itself to VPFE module     3 1 2 Supported Decoders    The following decoders are supported in this release    e TVP5146  driver module tvp514x  ch     e TVP7002  driver module tvp7002  ch    Tested only on DM365    e MT9TO01 MT9T031  driver module mt9t001  ch     e MT9P031  driver module mt9p031  ch     All these drivers are developed using the decoder interface described earlier  The decoder specific    commands  like std  input  param etc  are passed directly by VPFE capture driver to the currently active  decoder     SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 33  Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Portability www ti com  3 1 3 Adding New Decoder Support    VPFE capture driver is made such that if new decoder needs to be supported  it can be done by  implementing some standard functions  One common vid_decoder_if h file is available describing the  interface for new decoder  To develop a new decode
51. ormation like buffer type for the format  description  string  and pixel format     tryformat   This is the function for trying the format  to check whether it is valid or not  dec contains  the pointer to decoder_device structure which points to the decoder instance of current  channel  lt takes v4l2_ format as an input argument  It will validate the passed value in  structure     setformat   This is the function to set new format  dec contains the pointer to decoder_device  structure which points to the decoder instance of current channel  It takes v4l2_format as  an input argument  It will validate it and then set it as a current format     getformat   This is the function to get current format  dec contains the pointer to decoder_device  structure which points to the decoder instance of current channel  It takes v4l2_format as  an output argument  It will be filled with the current format values     32 LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS    INSTRUMENTS  www ti com Portability    3 1 1 6   Parameter Ops Structure       Parameters ops structure     struct param_ops         int   setparams   void  params  void  dec    int   getparams   void  params  void  dec        param_ops  setparams   It is to set device parameters  dec contains the pointer to decoder device structure    which points to the decoder instance of current channel     getparams   It is to get device parameters  dec contains the pointer to dec
52. r driver  use existing drivers  that is close enough to  the driver being written  as template  To support a new decoder following additional changes required in  addition to developing a decoder module     e In ccdc_common c timing information for different standards are defined  Each timing information is  tagged by a name  So when adding new standards to the decoder  make sure to use an existing tag or  if new  add it to this file as well  Update also  define CCDC_CHO_MAX_MODES     e Make sure to use appropriate interface type  If existing interface types are re used  then it might work  with out any change  VPFE Capture driver reads the interface type from the decoder and pass it to  CCDC for configuration  Current driver has tested BT 656  BT 1120 and Raw capture interfaces  If a  different interface is to be configured  check the ccdc_xxx c  xxx refers to SoC  example ccdc_dm355 c  for DM355  module  configure   function to verify if the required settings in CCDC is done for the  interface being used    e Currently davinci_vpfe h defines Maximum number of decoders supported as 5    define  VPFE_CAPTURE_NUM_DECODERS 5   For a specific system  if one or more decoder is not used   the same can be compiled out using configuration variable available for the decoder  Remember to  change the above constant if number of decoders in the system crosses 5    e Define decoder type constant in davinci_vpfe h and add it to vpfe_open   and vpfe_init   functions in  davinci_vpfe c    3
53. re timeperframe denominator    ret   IOCTL fd  VIDIOC_S_PARM   amp param     if ret      perror   VIDIOC_S_PARM An      close  fd     return  1     303    2 2 5 14 Get Stream Parameters    This IOCTL is used to get the current stream params when doing capture from TVP7002  This is only  added as a work around to support 720P 30fps     IOCTL  VIDIOC_G_PARM  Example     struct v412 streamparm param   param type   V4L2_BUF_TYPE_VIDEO_CAPTURE   param parm capture timeperframe numerator   1   param parm capture timeperframe denominator   30   ret   IOCTL fd  VIDIOC_G_PARM   amp param     if ret      perror   VIDIOC_G_PARM An      close  fd     return  1             printf  parm numerator    d n    param parm capture timeperframe numerator     printf   parm denominator    d n      param parm capture timeperframe denominator       2 2 5 15 Query Control    22    This IOCTL is used to get the information of control commands supported by current decoder   IOCTL  VIDIOC_QUERYCTRL    Driver will fill Id member in this structure  with the control id defined in V4L2 header file  for which  information is needed     If the control command specified by Id is not supported in current decoder  driver will return an error   It will take pointer to instance of v4l2_queryctrl structure as an output parameter     Example     struct v412_queryctrl ctrl   ctrl id   V4L2_CID_GAIN   ret   IOCTL fd  VIDIOC_QUERYCTRL     ctrl    if ret     perror   VIDIOC_QUERYCTRL An     close  fd    return  1      pr
54. rmat_ops  fmt_ops    param_ops  params_ops     int   deinitialize   void  dec     int   read_vbi_data   struct v412_sliced_vbi_ data  void  dec     int   get_sliced_vbi_cap struct v412_sliced_vbi_cap  cap   void  dec            decoder device    name  if_type  channel_id  capabilities    Function Pointers    initialize   function    deinitialize   function       Name of decoder  For example  MT9T001    ORing of different interface types supported by this decoder  For example   INTERFACE_TYPE_BT656  INTERFACE_TYPE_BT1120  INTERFACE_TYPE_RAW   INTERFACE_TYPE_YCBCR_SYNC_8  INTERFACE_TYPE_YCBCR_SYNC_16   INTERFACE_TYPE_YCBCR_SYNC_10BIT     It indicates for which channel id  this decoder instance is used   It indicates VBI is supported or not     e Any new decoder needs to define certain functions  and store these function pointers  in decoder_device structure     e VPFE keeps instance of decoder_device structure for each registered decoders   e VPFE will call these functions  as per requirement   e While calling  VPFE will pass pointer to respective decoder_device structure object     e VPFE gets this object at the time of decoder registration  Decoder will register itself  to VPFE module at the time of module insertion     This function will be called whenever decoder needs to be initialized   Its prototype is  int initialize void  dec     This function will be called whenever decoder needs to be deinitialized   Its prototype is  int deinitialize void  dec      30 LSP 2 10 Davin
55. s  Outputs from various peripherals are multiplexed using CPLD  This allows for the driver to  dynamically connect VPFE to one of the peripheral output to do video capture     The VPFE capture driver uses this logic to allow dynamic switching of input on request from the  application  The diagram also shows the label used by driver to name each of the input supported by the  input peripherals  Note that RAW is the name used to represent the camera sensor input  Additional  camera inputs are represented by RAW 1  RAW 2 etc        Figure 2  DM365 EVM Configuration for Video Capture       SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 7  Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Introduction www ti com  Supported Features  Following are the main features     1 2    1 3    8    The driver can be used statically or dynamically    Supports one video device  Video0     Supports single I O instance and multiple control instances    Supports buffer access mechanism through memory mapping as well as user pointers     Supports dynamic switching among input interfaces and various resolutions with some necessary  restrictions wherever applicable     Supports capture to SDRAM from CCDC or from Resizer  for DM355  amp  DM365      Constraints    Following are the constraints for the Capture driver     Dynamic switching of resolution and dynamic switching of interfaces is not supported when streaming  is on    VPFE input output buffer addresses must be a multiple
56. sm to detect the standard  It takes Pointer to v4l2_std_id  instance as an output argument  Standard ids are defined at V4L2 header files  some new standards are  added in respective decoder header files  which were not available in standard V4L2 header files      Example     v412_std_id std   ret   ioctl fd  VIDIOC_QUERYSTD   amp std    if  ret     perror  G_INPUT n      close  fd    return  1      printf   std    x n    unsigned long  std      2 2 5 7 Set Standard    This IOCTL is used to set the standard in current decoder   IOCTL  VIDIOC_S STD    If the standard is not supported by current decoder  driver will give error  It takes Pointer to v4l2_std_id  instance as an input argument     Standard ids are defined at V4L2 header files  some new standards are added in respective decoder  header files  which were not available in standard V4L2 header files      Example     v412_std_id std   V4L2_STD_525_60   ret   IOCTL fd  VIDIOC_S_STD   amp std    if ret      perror  S_STD n      close  fd     return  1     2 2 5 8 Get Standard    This IOCTL is used to get the current standard in current decoder   IOCTL  VIDIOC_G_STD  It takes Pointer to v4l2_std_id instance as an output argument     Standard ids are defined at V4L2 header files  some new standards are added in respective decoder  header files  which were not available in standard V4L2 header files      LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    1  TEXAS  INSTRUMENTS    ww
57. tions www ti com  Module initialization order  If ipipe modules are built as dynamic  do insmod of the modules prior to below steps     Insmod order   insmod ccdc_common ko   insmod ccdc_dm365 ko  use platform specific module here   insmod davinci_capture ko device_type 1   insmod mt9t001 ko   insmod mt9p031 ko   insmod tvp514x ko   insmod tvp7002 ko    Do rmmod in the reverse order     NOOR ON  gt     7 Example Applications    Please refer the readme txt files under v4l2 and previewer_resizer folder of example directory for sample  applications  v4l2 shows video capture and display using vpfe capture driver and davinci display driver   previewer_resizer folder shows examples for doing capture  preview   resize and display in single shot as  well as continuous  on the fly  mode of operation of the image processing block     46 LSP 2 10 Davinci Linux VPFE Capture Driver SPRUGP6 June 2009  Submit Documentation Feedback    
58. ude media davinci  Header file to include MT9T001 31 specific standards and  structures   mt9p031 h include media davinci  Header file to include MT9P03131 specific standards and  structures   tvp5146 h include media davinci  Header file to include TVP51476 specific standards and  structures   tvp7002 h include media davinci  Header file to include TVP7002 specific standards and  structures   SPRUGP6 June 2009 LSP 2 10 Davinci Linux VPFE Capture Driver 43    Submit Documentation Feedback    I  TEXAS  INSTRUMENTS    Build and Installation www ti com    6 Build and Installation    6 1 Build Steps  Access to the VPFE capture is provided through the  dev video0 device file   Following steps describe the procedure to build VPFE capture drivers as static modules in Kernel     Use menuconfig to navigate Kconfig tree to Video Capture Adapters menu as shown in Figure 6  Use the  space bar to select the driver to be built as a static module  indicated by        Figure 6  VPFE Capture Drivers Selection as a Static Module       Device Drivers  gt     Multimedia devices  gt      lt   gt Video For Linux    Video Capture Adapters  gt         Video Capture Adapters     lt   gt  Davinci Video Capture   lt   gt  DM365 CCDC ISIF HW module   lt   gt  TVP5146 video decoder   lt   gt  MT9T001 Sensor    lt   gt  MT9P031 Sensor    lt   gt  TVP7002 video decoder          This enables VPFE Capture driver Support in kernel  Now build kernel image   Following steps describe the procedure to build VPFE c
59. w ti com Driver Overview    Example     v412_std_id std   ret   ioctl fd  VIDIOC_G_STD   amp std    if ret      perror  G_STD n      close  fd     return  1        printf  std    x n    unsigned long  std      2 2 5 9 Format Enumeration    This IOCTL is used to enumerate the information of format  width  heght  bytesperline  image size  pixel  format etc   those are supported by current decoder     IOCTL  VIDIOC_ENUM_FMT    As per current decoder   s interface type  INTERFACE_TYPE_RAW  INTERFACE_TYPE_BT656   INTERFACE_TYPE_BT1120   it will fill the structure     It will take pointer to instance of v4l2_fmtdesc structure as an output parameter   If data flow path 2 is used  it will enumerate pixel format that are available at the output of the Resizer   Following are the pixel formats supported       Table 1  Pixel Formats Supported by VIDIOC_ENUM_FMT        soc Raw Bayer Data Input Raw YCbCr  YUV  Input    DM6446 V4L2_PIX_FMT_SBGGR16  Raw Mode     Bayer Pattern GrRBGb     16 bit  V4L2_PIX_FMT_UYVY  V4L2_PIX_FMT_SBGGR8  Raw Mode     Bayer Pattern GrRBGb     8 bit   This is    V4L2_PIX_FMT_YUYV  A Law compressed     DM355 V4L2_PIX_FMT_SBGGR16  Raw Mode     Bayer Pattern GrRBGb     16 bit  V4L2_PIX_FMT_UYVY  V4L2_PIX_FMT_SBGGR8  Raw Mode     Bayer Pattern GrRBGb     8 bit   This is    V4L2_PIX_FMT_YUYV  A Law compressed   V4L2_PIX_FMT_UYVY                DM365 V4L2_PIX_FMT_SBGGR16  Raw Mode     Bayer Pattern GrRBGb     16 bit  V4L2_PIX_FMT_UYVY  V4L2_PIX_FMT_SBGGR8  Raw Mode    
    
Download Pdf Manuals
 
 
    
Related Search
    
Related Contents
USER MANUAL  conseil municipal des jeunes conseil municipal des jeunes  Onkyo HTP-240 Home Theater System User Manual  こちらからお読みください。  Installation Guide  Balkenmäher - AL-KO  LibOpenCIF    hd5 Safety User Manual  Mode d`emploi 559 01 Tube compteur à fenêtre pour rayonnements    Copyright © All rights reserved. 
   Failed to retrieve file