vpif_display.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 <media/videobuf2-dma-contig.h>
  19. #include <media/v4l2-device.h>
  20. #include "vpif.h"
  21. /* Macros */
  22. #define VPIF_DISPLAY_VERSION "0.0.2"
  23. #define VPIF_VALID_FIELD(field) \
  24. (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \
  25. (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \
  26. (V4L2_FIELD_SEQ_BT == field)))
  27. #define VPIF_DISPLAY_MAX_DEVICES (2)
  28. #define VPIF_SLICED_BUF_SIZE (256)
  29. #define VPIF_SLICED_MAX_SERVICES (3)
  30. #define VPIF_VIDEO_INDEX (0)
  31. #define VPIF_VBI_INDEX (1)
  32. #define VPIF_HBI_INDEX (2)
  33. /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/
  34. #define VPIF_NUMOBJECTS (1)
  35. /* Macros */
  36. #define ISALIGNED(a) (0 == ((a) & 7))
  37. /* enumerated data types */
  38. /* Enumerated data type to give id to each device per channel */
  39. enum vpif_channel_id {
  40. VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */
  41. VPIF_CHANNEL3_VIDEO, /* Channel3 Video */
  42. };
  43. /* structures */
  44. struct video_obj {
  45. enum v4l2_field buf_field;
  46. u32 latest_only; /* indicate whether to return
  47. * most recent displayed frame only */
  48. v4l2_std_id stdid; /* Currently selected or default
  49. * standard */
  50. struct v4l2_dv_timings dv_timings;
  51. };
  52. struct vpif_disp_buffer {
  53. struct vb2_buffer vb;
  54. struct list_head list;
  55. };
  56. struct common_obj {
  57. /* Buffer specific parameters */
  58. u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for
  59. * storing frames */
  60. u32 numbuffers; /* number of buffers */
  61. struct vpif_disp_buffer *cur_frm; /* Pointer pointing to current
  62. * vb2_buffer */
  63. struct vpif_disp_buffer *next_frm; /* Pointer pointing to next
  64. * vb2_buffer */
  65. enum v4l2_memory memory; /* This field keeps track of
  66. * type of buffer exchange
  67. * method user has selected */
  68. struct v4l2_format fmt; /* Used to store the format */
  69. struct vb2_queue buffer_queue; /* Buffer queue used in
  70. * video-buf */
  71. /* allocator-specific contexts for each plane */
  72. struct vb2_alloc_ctx *alloc_ctx;
  73. struct list_head dma_queue; /* Queue of filled frames */
  74. spinlock_t irqlock; /* Used in video-buf */
  75. /* channel specific parameters */
  76. struct mutex lock; /* lock used to access this
  77. * structure */
  78. u32 io_usrs; /* number of users performing
  79. * IO */
  80. u8 started; /* Indicates whether streaming
  81. * started */
  82. u32 ytop_off; /* offset of Y top from the
  83. * starting of the buffer */
  84. u32 ybtm_off; /* offset of Y bottom from the
  85. * starting of the buffer */
  86. u32 ctop_off; /* offset of C top from the
  87. * starting of the buffer */
  88. u32 cbtm_off; /* offset of C bottom from the
  89. * starting of the buffer */
  90. /* Function pointer to set the addresses */
  91. void (*set_addr) (unsigned long, unsigned long,
  92. unsigned long, unsigned long);
  93. u32 height;
  94. u32 width;
  95. };
  96. struct channel_obj {
  97. /* V4l2 specific parameters */
  98. struct video_device *video_dev; /* Identifies video device for
  99. * this channel */
  100. struct v4l2_prio_state prio; /* Used to keep track of state of
  101. * the priority */
  102. atomic_t usrs; /* number of open instances of
  103. * the channel */
  104. u32 field_id; /* Indicates id of the field
  105. * which is being displayed */
  106. u8 initialized; /* flag to indicate whether
  107. * encoder is initialized */
  108. u32 output_idx; /* Current output index */
  109. struct v4l2_subdev *sd; /* Current output subdev(may be NULL) */
  110. enum vpif_channel_id channel_id;/* Identifies channel */
  111. struct vpif_params vpifparams;
  112. struct common_obj common[VPIF_NUMOBJECTS];
  113. struct video_obj video;
  114. };
  115. /* File handle structure */
  116. struct vpif_fh {
  117. struct channel_obj *channel; /* pointer to channel object for
  118. * opened device */
  119. u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
  120. * is doing IO */
  121. enum v4l2_priority prio; /* Used to keep track priority of
  122. * this instance */
  123. u8 initialized; /* Used to keep track of whether this
  124. * file handle has initialized
  125. * channel or not */
  126. };
  127. /* vpif device structure */
  128. struct vpif_device {
  129. struct v4l2_device v4l2_dev;
  130. struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
  131. struct v4l2_subdev **sd;
  132. struct v4l2_async_notifier notifier;
  133. struct vpif_display_config *config;
  134. };
  135. struct vpif_config_params {
  136. u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  137. u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
  138. u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
  139. u32 video_limit[VPIF_DISPLAY_NUM_CHANNELS];
  140. u8 min_numbuffers;
  141. };
  142. #endif /* DAVINCIHD_DISPLAY_H */