vpif_display.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 output_id; /* Current output id */
  59. };
  60. struct vbi_obj {
  61. int num_services;
  62. struct vpif_vbi_params vbiparams; /* vpif parameters for the raw
  63. * vbi data */
  64. };
  65. struct common_obj {
  66. /* Buffer specific parameters */
  67. u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for
  68. * storing frames */
  69. u32 numbuffers; /* number of buffers */
  70. struct videobuf_buffer *cur_frm; /* Pointer pointing to current
  71. * videobuf_buffer */
  72. struct videobuf_buffer *next_frm; /* Pointer pointing to next
  73. * videobuf_buffer */
  74. enum v4l2_memory memory; /* This field keeps track of
  75. * type of buffer exchange
  76. * method user has selected */
  77. struct v4l2_format fmt; /* Used to store the format */
  78. struct videobuf_queue buffer_queue; /* Buffer queue used in
  79. * video-buf */
  80. struct list_head dma_queue; /* Queue of filled frames */
  81. spinlock_t irqlock; /* Used in video-buf */
  82. /* channel specific parameters */
  83. struct mutex lock; /* lock used to access this
  84. * structure */
  85. u32 io_usrs; /* number of users performing
  86. * IO */
  87. u8 started; /* Indicates whether streaming
  88. * started */
  89. u32 ytop_off; /* offset of Y top from the
  90. * starting of the buffer */
  91. u32 ybtm_off; /* offset of Y bottom from the
  92. * starting of the buffer */
  93. u32 ctop_off; /* offset of C top from the
  94. * starting of the buffer */
  95. u32 cbtm_off; /* offset of C bottom from the
  96. * starting of the buffer */
  97. /* Function pointer to set the addresses */
  98. void (*set_addr) (unsigned long, unsigned long,
  99. unsigned long, unsigned long);
  100. u32 height;
  101. u32 width;
  102. };
  103. struct channel_obj {
  104. /* V4l2 specific parameters */
  105. struct video_device *video_dev; /* Identifies video device for
  106. * this channel */
  107. struct v4l2_prio_state prio; /* Used to keep track of state of
  108. * the priority */
  109. atomic_t usrs; /* number of open instances of
  110. * the channel */
  111. u32 field_id; /* Indicates id of the field
  112. * which is being displayed */
  113. u8 initialized; /* flag to indicate whether
  114. * encoder is initialized */
  115. enum vpif_channel_id channel_id;/* Identifies channel */
  116. struct vpif_params vpifparams;
  117. struct common_obj common[VPIF_NUMOBJECTS];
  118. struct video_obj video;
  119. struct vbi_obj vbi;
  120. };
  121. /* File handle structure */
  122. struct vpif_fh {
  123. struct channel_obj *channel; /* pointer to channel object for
  124. * opened device */
  125. u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
  126. * is doing IO */
  127. enum v4l2_priority prio; /* Used to keep track priority of
  128. * this instance */
  129. u8 initialized; /* Used to keep track of whether this
  130. * file handle has initialized
  131. * channel or not */
  132. };
  133. /* vpif device structure */
  134. struct vpif_device {
  135. struct v4l2_device v4l2_dev;
  136. struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
  137. struct v4l2_subdev **sd;
  138. };
  139. struct vpif_config_params {
  140. u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  141. u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  142. u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
  143. u8 min_numbuffers;
  144. };
  145. /* Struct which keeps track of the line numbers for the sliced vbi service */
  146. struct vpif_service_line {
  147. u16 service_id;
  148. u16 service_line[2];
  149. u16 enc_service_id;
  150. u8 bytestowrite;
  151. };
  152. #endif /* DAVINCIHD_DISPLAY_H */