vpfe_capture.h 4.8 KB

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