vpif_display.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * DM646x 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 <linux/version.h>
  20. #include <media/v4l2-common.h>
  21. #include <media/v4l2-device.h>
  22. #include <media/videobuf-core.h>
  23. #include <media/videobuf-dma-contig.h>
  24. #include "vpif.h"
  25. /* Macros */
  26. #define VPIF_MAJOR_RELEASE (0)
  27. #define VPIF_MINOR_RELEASE (0)
  28. #define VPIF_BUILD (1)
  29. #define VPIF_DISPLAY_VERSION_CODE \
  30. ((VPIF_MAJOR_RELEASE << 16) | (VPIF_MINOR_RELEASE << 8) | VPIF_BUILD)
  31. #define VPIF_VALID_FIELD(field) \
  32. (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \
  33. (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \
  34. (V4L2_FIELD_SEQ_BT == field)))
  35. #define VPIF_DISPLAY_MAX_DEVICES (2)
  36. #define VPIF_SLICED_BUF_SIZE (256)
  37. #define VPIF_SLICED_MAX_SERVICES (3)
  38. #define VPIF_VIDEO_INDEX (0)
  39. #define VPIF_VBI_INDEX (1)
  40. #define VPIF_HBI_INDEX (2)
  41. /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/
  42. #define VPIF_NUMOBJECTS (1)
  43. /* Macros */
  44. #define ISALIGNED(a) (0 == ((a) & 7))
  45. /* enumerated data types */
  46. /* Enumerated data type to give id to each device per channel */
  47. enum vpif_channel_id {
  48. VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */
  49. VPIF_CHANNEL3_VIDEO, /* Channel3 Video */
  50. };
  51. /* structures */
  52. struct video_obj {
  53. enum v4l2_field buf_field;
  54. u32 latest_only; /* indicate whether to return
  55. * most recent displayed frame only */
  56. v4l2_std_id stdid; /* Currently selected or default
  57. * standard */
  58. u32 dv_preset;
  59. struct v4l2_bt_timings bt_timings;
  60. u32 output_id; /* Current output id */
  61. };
  62. struct vbi_obj {
  63. int num_services;
  64. struct vpif_vbi_params vbiparams; /* vpif parameters for the raw
  65. * vbi data */
  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 videobuf_buffer *cur_frm; /* Pointer pointing to current
  73. * videobuf_buffer */
  74. struct videobuf_buffer *next_frm; /* Pointer pointing to next
  75. * videobuf_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 videobuf_queue buffer_queue; /* Buffer queue used in
  81. * video-buf */
  82. struct list_head dma_queue; /* Queue of filled frames */
  83. spinlock_t irqlock; /* Used in video-buf */
  84. /* channel specific parameters */
  85. struct mutex lock; /* lock used to access this
  86. * structure */
  87. u32 io_usrs; /* number of users performing
  88. * IO */
  89. u8 started; /* Indicates whether streaming
  90. * started */
  91. u32 ytop_off; /* offset of Y top from the
  92. * starting of the buffer */
  93. u32 ybtm_off; /* offset of Y bottom from the
  94. * starting of the buffer */
  95. u32 ctop_off; /* offset of C top from the
  96. * starting of the buffer */
  97. u32 cbtm_off; /* offset of C bottom from the
  98. * starting of the buffer */
  99. /* Function pointer to set the addresses */
  100. void (*set_addr) (unsigned long, unsigned long,
  101. unsigned long, unsigned long);
  102. u32 height;
  103. u32 width;
  104. };
  105. struct channel_obj {
  106. /* V4l2 specific parameters */
  107. struct video_device *video_dev; /* Identifies video device for
  108. * this channel */
  109. struct v4l2_prio_state prio; /* Used to keep track of state of
  110. * the priority */
  111. atomic_t usrs; /* number of open instances of
  112. * the channel */
  113. u32 field_id; /* Indicates id of the field
  114. * which is being displayed */
  115. u8 initialized; /* flag to indicate whether
  116. * encoder is initialized */
  117. enum vpif_channel_id channel_id;/* Identifies channel */
  118. struct vpif_params vpifparams;
  119. struct common_obj common[VPIF_NUMOBJECTS];
  120. struct video_obj video;
  121. struct vbi_obj vbi;
  122. };
  123. /* File handle structure */
  124. struct vpif_fh {
  125. struct channel_obj *channel; /* pointer to channel object for
  126. * opened device */
  127. u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
  128. * is doing IO */
  129. enum v4l2_priority prio; /* Used to keep track priority of
  130. * this instance */
  131. u8 initialized; /* Used to keep track of whether this
  132. * file handle has initialized
  133. * channel or not */
  134. };
  135. /* vpif device structure */
  136. struct vpif_device {
  137. struct v4l2_device v4l2_dev;
  138. struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
  139. struct v4l2_subdev **sd;
  140. };
  141. struct vpif_config_params {
  142. u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  143. u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  144. u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
  145. u8 min_numbuffers;
  146. };
  147. /* Struct which keeps track of the line numbers for the sliced vbi service */
  148. struct vpif_service_line {
  149. u16 service_id;
  150. u16 service_line[2];
  151. u16 enc_service_id;
  152. u8 bytestowrite;
  153. };
  154. #endif /* DAVINCIHD_DISPLAY_H */