vpbe_display.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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/v4l2-fh.h>
  19. #include <media/videobuf2-dma-contig.h>
  20. #include <media/davinci/vpbe_types.h>
  21. #include <media/davinci/vpbe_osd.h>
  22. #include <media/davinci/vpbe.h>
  23. #define VPBE_DISPLAY_MAX_DEVICES 2
  24. enum vpbe_display_device_id {
  25. VPBE_DISPLAY_DEVICE_0,
  26. VPBE_DISPLAY_DEVICE_1
  27. };
  28. #define VPBE_DISPLAY_DRV_NAME "vpbe-display"
  29. #define VPBE_DISPLAY_MAJOR_RELEASE 1
  30. #define VPBE_DISPLAY_MINOR_RELEASE 0
  31. #define VPBE_DISPLAY_BUILD 1
  32. #define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \
  33. (VPBE_DISPLAY_MINOR_RELEASE << 8) | \
  34. VPBE_DISPLAY_BUILD)
  35. #define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \
  36. (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field))
  37. /* Exp ratio numerator and denominator constants */
  38. #define VPBE_DISPLAY_H_EXP_RATIO_N 9
  39. #define VPBE_DISPLAY_H_EXP_RATIO_D 8
  40. #define VPBE_DISPLAY_V_EXP_RATIO_N 6
  41. #define VPBE_DISPLAY_V_EXP_RATIO_D 5
  42. /* Zoom multiplication factor */
  43. #define VPBE_DISPLAY_ZOOM_4X 4
  44. #define VPBE_DISPLAY_ZOOM_2X 2
  45. /* Structures */
  46. struct display_layer_info {
  47. int enable;
  48. /* Layer ID used by Display Manager */
  49. enum osd_layer id;
  50. struct osd_layer_config config;
  51. enum osd_zoom_factor h_zoom;
  52. enum osd_zoom_factor v_zoom;
  53. enum osd_h_exp_ratio h_exp;
  54. enum osd_v_exp_ratio v_exp;
  55. };
  56. struct vpbe_disp_buffer {
  57. struct vb2_buffer vb;
  58. struct list_head list;
  59. };
  60. /* vpbe display object structure */
  61. struct vpbe_layer {
  62. /* Pointer to the vpbe_display */
  63. struct vpbe_display *disp_dev;
  64. /* Pointer pointing to current v4l2_buffer */
  65. struct vpbe_disp_buffer *cur_frm;
  66. /* Pointer pointing to next v4l2_buffer */
  67. struct vpbe_disp_buffer *next_frm;
  68. /* videobuf specific parameters
  69. * Buffer queue used in video-buf
  70. */
  71. struct vb2_queue buffer_queue;
  72. /* allocator-specific contexts for each plane */
  73. struct vb2_alloc_ctx *alloc_ctx;
  74. /* Queue of filled frames */
  75. struct list_head dma_queue;
  76. /* Used in video-buf */
  77. spinlock_t irqlock;
  78. /* V4l2 specific parameters */
  79. /* Identifies video device for this layer */
  80. struct video_device video_dev;
  81. /* Used to store pixel format */
  82. struct v4l2_pix_format pix_fmt;
  83. enum v4l2_field buf_field;
  84. /* Video layer configuration params */
  85. struct display_layer_info layer_info;
  86. /* vpbe specific parameters
  87. * enable window for display
  88. */
  89. unsigned char window_enable;
  90. /* number of open instances of the layer */
  91. unsigned int usrs;
  92. /* Indicates id of the field which is being displayed */
  93. unsigned int field_id;
  94. /* Identifies device object */
  95. enum vpbe_display_device_id device_id;
  96. /* facilitation of ioctl ops lock by v4l2*/
  97. struct mutex opslock;
  98. u8 layer_first_int;
  99. };
  100. /* vpbe device structure */
  101. struct vpbe_display {
  102. /* layer specific parameters */
  103. /* lock for isr updates to buf layers*/
  104. spinlock_t dma_queue_lock;
  105. /* C-Plane offset from start of y-plane */
  106. unsigned int cbcr_ofst;
  107. struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
  108. struct vpbe_device *vpbe_dev;
  109. struct osd_state *osd_device;
  110. };
  111. struct buf_config_params {
  112. unsigned char min_numbuffers;
  113. unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
  114. unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
  115. unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
  116. };
  117. #endif /* VPBE_DISPLAY_H */