vpif_display.h 5.1 KB

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