vpif_capture.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright (C) 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 VPIF_CAPTURE_H
  19. #define VPIF_CAPTURE_H
  20. #ifdef __KERNEL__
  21. /* Header files */
  22. #include <linux/videodev2.h>
  23. #include <media/v4l2-common.h>
  24. #include <media/v4l2-device.h>
  25. #include <media/videobuf-core.h>
  26. #include <media/videobuf2-dma-contig.h>
  27. #include <media/davinci/vpif_types.h>
  28. #include "vpif.h"
  29. /* Macros */
  30. #define VPIF_CAPTURE_VERSION "0.0.2"
  31. #define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \
  32. (V4L2_FIELD_NONE == field)) || \
  33. (((V4L2_FIELD_INTERLACED == field) || \
  34. (V4L2_FIELD_SEQ_TB == field)) || \
  35. (V4L2_FIELD_SEQ_BT == field)))
  36. #define VPIF_CAPTURE_MAX_DEVICES 2
  37. #define VPIF_VIDEO_INDEX 0
  38. #define VPIF_NUMBER_OF_OBJECTS 1
  39. /* Enumerated data type to give id to each device per channel */
  40. enum vpif_channel_id {
  41. VPIF_CHANNEL0_VIDEO = 0,
  42. VPIF_CHANNEL1_VIDEO,
  43. };
  44. struct video_obj {
  45. enum v4l2_field buf_field;
  46. /* Currently selected or default standard */
  47. v4l2_std_id stdid;
  48. u32 dv_preset;
  49. struct v4l2_bt_timings bt_timings;
  50. /* This is to track the last input that is passed to application */
  51. u32 input_idx;
  52. };
  53. struct vpif_cap_buffer {
  54. struct vb2_buffer vb;
  55. struct list_head list;
  56. };
  57. struct common_obj {
  58. /* Pointer pointing to current v4l2_buffer */
  59. struct vpif_cap_buffer *cur_frm;
  60. /* Pointer pointing to current v4l2_buffer */
  61. struct vpif_cap_buffer *next_frm;
  62. /*
  63. * This field keeps track of type of buffer exchange mechanism
  64. * user has selected
  65. */
  66. enum v4l2_memory memory;
  67. /* Used to store pixel format */
  68. struct v4l2_format fmt;
  69. /* Buffer queue used in video-buf */
  70. struct vb2_queue buffer_queue;
  71. /* allocator-specific contexts for each plane */
  72. struct vb2_alloc_ctx *alloc_ctx;
  73. /* Queue of filled frames */
  74. struct list_head dma_queue;
  75. /* Used in video-buf */
  76. spinlock_t irqlock;
  77. /* lock used to access this structure */
  78. struct mutex lock;
  79. /* number of users performing IO */
  80. u32 io_usrs;
  81. /* Indicates whether streaming started */
  82. u8 started;
  83. /* Function pointer to set the addresses */
  84. void (*set_addr) (unsigned long, unsigned long, unsigned long,
  85. unsigned long);
  86. /* offset where Y top starts from the starting of the buffer */
  87. u32 ytop_off;
  88. /* offset where Y bottom starts from the starting of the buffer */
  89. u32 ybtm_off;
  90. /* offset where C top starts from the starting of the buffer */
  91. u32 ctop_off;
  92. /* offset where C bottom starts from the starting of the buffer */
  93. u32 cbtm_off;
  94. /* Indicates width of the image data */
  95. u32 width;
  96. /* Indicates height of the image data */
  97. u32 height;
  98. };
  99. struct channel_obj {
  100. /* Identifies video device for this channel */
  101. struct video_device *video_dev;
  102. /* Used to keep track of state of the priority */
  103. struct v4l2_prio_state prio;
  104. /* number of open instances of the channel */
  105. int usrs;
  106. /* Indicates id of the field which is being displayed */
  107. u32 field_id;
  108. /* flag to indicate whether decoder is initialized */
  109. u8 initialized;
  110. /* Identifies channel */
  111. enum vpif_channel_id channel_id;
  112. /* index into sd table */
  113. int curr_sd_index;
  114. /* ptr to current sub device information */
  115. struct vpif_subdev_info *curr_subdev_info;
  116. /* vpif configuration params */
  117. struct vpif_params vpifparams;
  118. /* common object array */
  119. struct common_obj common[VPIF_NUMBER_OF_OBJECTS];
  120. /* video object */
  121. struct video_obj video;
  122. };
  123. /* File handle structure */
  124. struct vpif_fh {
  125. /* pointer to channel object for opened device */
  126. struct channel_obj *channel;
  127. /* Indicates whether this file handle is doing IO */
  128. u8 io_allowed[VPIF_NUMBER_OF_OBJECTS];
  129. /* Used to keep track priority of this instance */
  130. enum v4l2_priority prio;
  131. /* Used to indicate channel is initialize or not */
  132. u8 initialized;
  133. };
  134. struct vpif_device {
  135. struct v4l2_device v4l2_dev;
  136. struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS];
  137. struct v4l2_subdev **sd;
  138. };
  139. struct vpif_config_params {
  140. u8 min_numbuffers;
  141. u8 numbuffers[VPIF_CAPTURE_NUM_CHANNELS];
  142. s8 device_type;
  143. u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
  144. u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS];
  145. u8 default_device[VPIF_CAPTURE_NUM_CHANNELS];
  146. u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS];
  147. u8 max_device_type;
  148. };
  149. /* Struct which keeps track of the line numbers for the sliced vbi service */
  150. struct vpif_service_line {
  151. u16 service_id;
  152. u16 service_line[2];
  153. };
  154. #endif /* End of __KERNEL__ */
  155. #endif /* VPIF_CAPTURE_H */