vpfe_capture.h 5.6 KB

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