vpfe_capture.h 4.3 KB

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