vpif_display.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * VPIF display header file
  3. *
  4. * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed .as is. WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef DAVINCIHD_DISPLAY_H
  16. #define DAVINCIHD_DISPLAY_H
  17. /* Header files */
  18. #include <linux/videodev2.h>
  19. #include <media/v4l2-common.h>
  20. #include <media/v4l2-device.h>
  21. #include <media/videobuf-core.h>
  22. #include <media/videobuf2-dma-contig.h>
  23. #include <media/davinci/vpif_types.h>
  24. #include "vpif.h"
  25. /* Macros */
  26. #define VPIF_DISPLAY_VERSION "0.0.2"
  27. #define VPIF_VALID_FIELD(field) \
  28. (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \
  29. (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \
  30. (V4L2_FIELD_SEQ_BT == field)))
  31. #define VPIF_DISPLAY_MAX_DEVICES (2)
  32. #define VPIF_SLICED_BUF_SIZE (256)
  33. #define VPIF_SLICED_MAX_SERVICES (3)
  34. #define VPIF_VIDEO_INDEX (0)
  35. #define VPIF_VBI_INDEX (1)
  36. #define VPIF_HBI_INDEX (2)
  37. /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/
  38. #define VPIF_NUMOBJECTS (1)
  39. /* Macros */
  40. #define ISALIGNED(a) (0 == ((a) & 7))
  41. /* enumerated data types */
  42. /* Enumerated data type to give id to each device per channel */
  43. enum vpif_channel_id {
  44. VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */
  45. VPIF_CHANNEL3_VIDEO, /* Channel3 Video */
  46. };
  47. /* structures */
  48. struct video_obj {
  49. enum v4l2_field buf_field;
  50. u32 latest_only; /* indicate whether to return
  51. * most recent displayed frame only */
  52. v4l2_std_id stdid; /* Currently selected or default
  53. * standard */
  54. u32 dv_preset;
  55. struct v4l2_bt_timings bt_timings;
  56. u32 output_id; /* Current output id */
  57. };
  58. struct vbi_obj {
  59. int num_services;
  60. struct vpif_vbi_params vbiparams; /* vpif parameters for the raw
  61. * vbi data */
  62. };
  63. struct vpif_disp_buffer {
  64. struct vb2_buffer vb;
  65. struct list_head list;
  66. };
  67. struct common_obj {
  68. /* Buffer specific parameters */
  69. u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for
  70. * storing frames */
  71. u32 numbuffers; /* number of buffers */
  72. struct vpif_disp_buffer *cur_frm; /* Pointer pointing to current
  73. * vb2_buffer */
  74. struct vpif_disp_buffer *next_frm; /* Pointer pointing to next
  75. * vb2_buffer */
  76. enum v4l2_memory memory; /* This field keeps track of
  77. * type of buffer exchange
  78. * method user has selected */
  79. struct v4l2_format fmt; /* Used to store the format */
  80. struct vb2_queue buffer_queue; /* Buffer queue used in
  81. * video-buf */
  82. /* allocator-specific contexts for each plane */
  83. struct vb2_alloc_ctx *alloc_ctx;
  84. struct list_head dma_queue; /* Queue of filled frames */
  85. spinlock_t irqlock; /* Used in video-buf */
  86. /* channel specific parameters */
  87. struct mutex lock; /* lock used to access this
  88. * structure */
  89. u32 io_usrs; /* number of users performing
  90. * IO */
  91. u8 started; /* Indicates whether streaming
  92. * started */
  93. u32 ytop_off; /* offset of Y top from the
  94. * starting of the buffer */
  95. u32 ybtm_off; /* offset of Y bottom from the
  96. * starting of the buffer */
  97. u32 ctop_off; /* offset of C top from the
  98. * starting of the buffer */
  99. u32 cbtm_off; /* offset of C bottom from the
  100. * starting of the buffer */
  101. /* Function pointer to set the addresses */
  102. void (*set_addr) (unsigned long, unsigned long,
  103. unsigned long, unsigned long);
  104. u32 height;
  105. u32 width;
  106. };
  107. struct channel_obj {
  108. /* V4l2 specific parameters */
  109. struct video_device *video_dev; /* Identifies video device for
  110. * this channel */
  111. struct v4l2_prio_state prio; /* Used to keep track of state of
  112. * the priority */
  113. atomic_t usrs; /* number of open instances of
  114. * the channel */
  115. u32 field_id; /* Indicates id of the field
  116. * which is being displayed */
  117. u8 initialized; /* flag to indicate whether
  118. * encoder is initialized */
  119. enum vpif_channel_id channel_id;/* Identifies channel */
  120. struct vpif_params vpifparams;
  121. struct common_obj common[VPIF_NUMOBJECTS];
  122. struct video_obj video;
  123. struct vbi_obj vbi;
  124. };
  125. /* File handle structure */
  126. struct vpif_fh {
  127. struct channel_obj *channel; /* pointer to channel object for
  128. * opened device */
  129. u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
  130. * is doing IO */
  131. enum v4l2_priority prio; /* Used to keep track priority of
  132. * this instance */
  133. u8 initialized; /* Used to keep track of whether this
  134. * file handle has initialized
  135. * channel or not */
  136. };
  137. /* vpif device structure */
  138. struct vpif_device {
  139. struct v4l2_device v4l2_dev;
  140. struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
  141. struct v4l2_subdev **sd;
  142. };
  143. struct vpif_config_params {
  144. u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  145. u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  146. u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
  147. u32 video_limit[VPIF_DISPLAY_NUM_CHANNELS];
  148. u8 min_numbuffers;
  149. };
  150. /* Struct which keeps track of the line numbers for the sliced vbi service */
  151. struct vpif_service_line {
  152. u16 service_id;
  153. u16 service_line[2];
  154. u16 enc_service_id;
  155. u8 bytestowrite;
  156. };
  157. #endif /* DAVINCIHD_DISPLAY_H */