vpfe_capture.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * Copyright (C) 2008-2009 Texas Instruments Inc
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef _VPFE_CAPTURE_H
  19. #define _VPFE_CAPTURE_H
  20. #ifdef __KERNEL__
  21. /* Header files */
  22. #include <media/v4l2-dev.h>
  23. #include <linux/videodev2.h>
  24. #include <linux/clk.h>
  25. #include <linux/i2c.h>
  26. #include <media/v4l2-fh.h>
  27. #include <media/v4l2-ioctl.h>
  28. #include <media/v4l2-device.h>
  29. #include <media/videobuf-dma-contig.h>
  30. #include <media/davinci/vpfe_types.h>
  31. #define VPFE_CAPTURE_NUM_DECODERS 5
  32. /* Macros */
  33. #define VPFE_MAJOR_RELEASE 0
  34. #define VPFE_MINOR_RELEASE 0
  35. #define VPFE_BUILD 1
  36. #define VPFE_CAPTURE_VERSION_CODE ((VPFE_MAJOR_RELEASE << 16) | \
  37. (VPFE_MINOR_RELEASE << 8) | \
  38. VPFE_BUILD)
  39. #define CAPTURE_DRV_NAME "vpfe-capture"
  40. struct vpfe_pixel_format {
  41. struct v4l2_fmtdesc fmtdesc;
  42. /* bytes per pixel */
  43. int bpp;
  44. };
  45. struct vpfe_std_info {
  46. int active_pixels;
  47. int active_lines;
  48. /* current frame format */
  49. int frame_format;
  50. };
  51. struct vpfe_route {
  52. u32 input;
  53. u32 output;
  54. };
  55. struct vpfe_subdev_info {
  56. /* Sub device name */
  57. char name[32];
  58. /* Sub device group id */
  59. int grp_id;
  60. /* Number of inputs supported */
  61. int num_inputs;
  62. /* inputs available at the sub device */
  63. struct v4l2_input *inputs;
  64. /* Sub dev routing information for each input */
  65. struct vpfe_route *routes;
  66. /* check if sub dev supports routing */
  67. int can_route;
  68. /* ccdc bus/interface configuration */
  69. struct vpfe_hw_if_param ccdc_if_params;
  70. /* i2c subdevice board info */
  71. struct i2c_board_info board_info;
  72. };
  73. struct vpfe_config {
  74. /* Number of sub devices connected to vpfe */
  75. int num_subdevs;
  76. /* i2c bus adapter no */
  77. int i2c_adapter_id;
  78. /* information about each subdev */
  79. struct vpfe_subdev_info *sub_devs;
  80. /* evm card info */
  81. char *card_name;
  82. /* ccdc name */
  83. char *ccdc;
  84. /* vpfe clock */
  85. struct clk *vpssclk;
  86. struct clk *slaveclk;
  87. /* Function for Clearing the interrupt */
  88. void (*clr_intr)(int vdint);
  89. };
  90. struct vpfe_device {
  91. /* V4l2 specific parameters */
  92. /* Identifies video device for this channel */
  93. struct video_device video_dev;
  94. /* sub devices */
  95. struct v4l2_subdev **sd;
  96. /* vpfe cfg */
  97. struct vpfe_config *cfg;
  98. /* V4l2 device */
  99. struct v4l2_device v4l2_dev;
  100. /* parent device */
  101. struct device *pdev;
  102. /* number of open instances of the channel */
  103. u32 usrs;
  104. /* Indicates id of the field which is being displayed */
  105. u32 field_id;
  106. /* flag to indicate whether decoder is initialized */
  107. u8 initialized;
  108. /* current interface type */
  109. struct vpfe_hw_if_param vpfe_if_params;
  110. /* ptr to currently selected sub device */
  111. struct vpfe_subdev_info *current_subdev;
  112. /* current input at the sub device */
  113. int current_input;
  114. /* Keeps track of the information about the standard */
  115. struct vpfe_std_info std_info;
  116. /* std index into std table */
  117. int std_index;
  118. /* CCDC IRQs used when CCDC/ISIF output to SDRAM */
  119. unsigned int ccdc_irq0;
  120. unsigned int ccdc_irq1;
  121. /* number of buffers in fbuffers */
  122. u32 numbuffers;
  123. /* List of buffer pointers for storing frames */
  124. u8 *fbuffers[VIDEO_MAX_FRAME];
  125. /* Pointer pointing to current v4l2_buffer */
  126. struct videobuf_buffer *cur_frm;
  127. /* Pointer pointing to next v4l2_buffer */
  128. struct videobuf_buffer *next_frm;
  129. /*
  130. * This field keeps track of type of buffer exchange mechanism
  131. * user has selected
  132. */
  133. enum v4l2_memory memory;
  134. /* Used to store pixel format */
  135. struct v4l2_format fmt;
  136. /*
  137. * used when IMP is chained to store the crop window which
  138. * is different from the image window
  139. */
  140. struct v4l2_rect crop;
  141. /* Buffer queue used in video-buf */
  142. struct videobuf_queue buffer_queue;
  143. /* Queue of filled frames */
  144. struct list_head dma_queue;
  145. /* Used in video-buf */
  146. spinlock_t irqlock;
  147. /* IRQ lock for DMA queue */
  148. spinlock_t dma_queue_lock;
  149. /* lock used to access this structure */
  150. struct mutex lock;
  151. /* number of users performing IO */
  152. u32 io_usrs;
  153. /* Indicates whether streaming started */
  154. u8 started;
  155. /*
  156. * offset where second field starts from the starting of the
  157. * buffer for field separated YCbCr formats
  158. */
  159. u32 field_off;
  160. };
  161. /* File handle structure */
  162. struct vpfe_fh {
  163. struct v4l2_fh fh;
  164. struct vpfe_device *vpfe_dev;
  165. /* Indicates whether this file handle is doing IO */
  166. u8 io_allowed;
  167. };
  168. struct vpfe_config_params {
  169. u8 min_numbuffers;
  170. u8 numbuffers;
  171. u32 min_bufsize;
  172. u32 device_bufsize;
  173. };
  174. #endif /* End of __KERNEL__ */
  175. /**
  176. * VPFE_CMD_S_CCDC_RAW_PARAMS - EXPERIMENTAL IOCTL to set raw capture params
  177. * This can be used to configure modules such as defect pixel correction,
  178. * color space conversion, culling etc. This is an experimental ioctl that
  179. * will change in future kernels. So use this ioctl with care !
  180. * TODO: This is to be split into multiple ioctls and also explore the
  181. * possibility of extending the v4l2 api to include this
  182. **/
  183. #define VPFE_CMD_S_CCDC_RAW_PARAMS _IOW('V', BASE_VIDIOC_PRIVATE + 1, \
  184. void *)
  185. #endif /* _DAVINCI_VPFE_H */