vpbe_display.h 3.4 KB

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