vpbe_display.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation version 2.
  7. *
  8. * This program is distributed WITHOUT ANY WARRANTY of any
  9. * kind, whether express or implied; without even the implied warranty
  10. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef VPBE_DISPLAY_H
  14. #define VPBE_DISPLAY_H
  15. /* Header files */
  16. #include <linux/videodev2.h>
  17. #include <media/v4l2-common.h>
  18. #include <media/videobuf-dma-contig.h>
  19. #include <media/davinci/vpbe_types.h>
  20. #include <media/davinci/vpbe_osd.h>
  21. #include <media/davinci/vpbe.h>
  22. #define VPBE_DISPLAY_MAX_DEVICES 2
  23. enum vpbe_display_device_id {
  24. VPBE_DISPLAY_DEVICE_0,
  25. VPBE_DISPLAY_DEVICE_1
  26. };
  27. #define VPBE_DISPLAY_DRV_NAME "vpbe-display"
  28. #define VPBE_DISPLAY_MAJOR_RELEASE 1
  29. #define VPBE_DISPLAY_MINOR_RELEASE 0
  30. #define VPBE_DISPLAY_BUILD 1
  31. #define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \
  32. (VPBE_DISPLAY_MINOR_RELEASE << 8) | \
  33. VPBE_DISPLAY_BUILD)
  34. #define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \
  35. (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field))
  36. /* Exp ratio numerator and denominator constants */
  37. #define VPBE_DISPLAY_H_EXP_RATIO_N 9
  38. #define VPBE_DISPLAY_H_EXP_RATIO_D 8
  39. #define VPBE_DISPLAY_V_EXP_RATIO_N 6
  40. #define VPBE_DISPLAY_V_EXP_RATIO_D 5
  41. /* Zoom multiplication factor */
  42. #define VPBE_DISPLAY_ZOOM_4X 4
  43. #define VPBE_DISPLAY_ZOOM_2X 2
  44. /* Structures */
  45. struct display_layer_info {
  46. int enable;
  47. /* Layer ID used by Display Manager */
  48. enum osd_layer id;
  49. struct osd_layer_config config;
  50. enum osd_zoom_factor h_zoom;
  51. enum osd_zoom_factor v_zoom;
  52. enum osd_h_exp_ratio h_exp;
  53. enum osd_v_exp_ratio v_exp;
  54. };
  55. /* vpbe display object structure */
  56. struct vpbe_layer {
  57. /* number of buffers in fbuffers */
  58. unsigned int numbuffers;
  59. /* Pointer to the vpbe_display */
  60. struct vpbe_display *disp_dev;
  61. /* Pointer pointing to current v4l2_buffer */
  62. struct videobuf_buffer *cur_frm;
  63. /* Pointer pointing to next v4l2_buffer */
  64. struct videobuf_buffer *next_frm;
  65. /* videobuf specific parameters
  66. * Buffer queue used in video-buf
  67. */
  68. struct videobuf_queue buffer_queue;
  69. /* Queue of filled frames */
  70. struct list_head dma_queue;
  71. /* Used in video-buf */
  72. spinlock_t irqlock;
  73. /* V4l2 specific parameters */
  74. /* Identifies video device for this layer */
  75. struct video_device video_dev;
  76. /* This field keeps track of type of buffer exchange mechanism user
  77. * has selected
  78. */
  79. enum v4l2_memory memory;
  80. /* Used to keep track of state of the priority */
  81. struct v4l2_prio_state prio;
  82. /* Used to store pixel format */
  83. struct v4l2_pix_format pix_fmt;
  84. enum v4l2_field buf_field;
  85. /* Video layer configuration params */
  86. struct display_layer_info layer_info;
  87. /* vpbe specific parameters
  88. * enable window for display
  89. */
  90. unsigned char window_enable;
  91. /* number of open instances of the layer */
  92. unsigned int usrs;
  93. /* number of users performing IO */
  94. unsigned int io_usrs;
  95. /* Indicates id of the field which is being displayed */
  96. unsigned int field_id;
  97. /* Indicates whether streaming started */
  98. unsigned char started;
  99. /* Identifies device object */
  100. enum vpbe_display_device_id device_id;
  101. /* facilitation of ioctl ops lock by v4l2*/
  102. struct mutex opslock;
  103. u8 layer_first_int;
  104. };
  105. /* vpbe device structure */
  106. struct vpbe_display {
  107. /* layer specific parameters */
  108. /* lock for isr updates to buf layers*/
  109. spinlock_t dma_queue_lock;
  110. /* C-Plane offset from start of y-plane */
  111. unsigned int cbcr_ofst;
  112. struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
  113. struct vpbe_device *vpbe_dev;
  114. struct osd_state *osd_device;
  115. };
  116. /* File handle structure */
  117. struct vpbe_fh {
  118. /* vpbe device structure */
  119. struct vpbe_display *disp_dev;
  120. /* pointer to layer object for opened device */
  121. struct vpbe_layer *layer;
  122. /* Indicates whether this file handle is doing IO */
  123. unsigned char io_allowed;
  124. /* Used to keep track priority of this instance */
  125. enum v4l2_priority prio;
  126. };
  127. struct buf_config_params {
  128. unsigned char min_numbuffers;
  129. unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
  130. unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
  131. unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
  132. };
  133. #endif /* VPBE_DISPLAY_H */