vpif_display.h 5.0 KB

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