1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
9 #include <linux/videodev2.h>
10 #include <media/v4l2-common.h>
11 #include <media/v4l2-fh.h>
12 #include <media/videobuf2-v4l2.h>
13 #include <media/videobuf2-dma-contig.h>
14 #include <media/davinci/vpbe_types.h>
15 #include <media/davinci/vpbe_osd.h>
16 #include <media/davinci/vpbe.h>
18 #define VPBE_DISPLAY_MAX_DEVICES 2
20 enum vpbe_display_device_id {
21 VPBE_DISPLAY_DEVICE_0,
25 #define VPBE_DISPLAY_DRV_NAME "vpbe-display"
27 #define VPBE_DISPLAY_MAJOR_RELEASE 1
28 #define VPBE_DISPLAY_MINOR_RELEASE 0
29 #define VPBE_DISPLAY_BUILD 1
30 #define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \
31 (VPBE_DISPLAY_MINOR_RELEASE << 8) | \
34 #define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \
35 (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
43 /* Zoom multiplication factor */
44 #define VPBE_DISPLAY_ZOOM_4X 4
45 #define VPBE_DISPLAY_ZOOM_2X 2
48 struct display_layer_info {
50 /* Layer ID used by Display Manager */
52 struct osd_layer_config config;
53 enum osd_zoom_factor h_zoom;
54 enum osd_zoom_factor v_zoom;
55 enum osd_h_exp_ratio h_exp;
56 enum osd_v_exp_ratio v_exp;
59 struct vpbe_disp_buffer {
60 struct vb2_v4l2_buffer vb;
61 struct list_head list;
64 /* vpbe display object structure */
66 /* Pointer to the vpbe_display */
67 struct vpbe_display *disp_dev;
68 /* Pointer pointing to current v4l2_buffer */
69 struct vpbe_disp_buffer *cur_frm;
70 /* Pointer pointing to next v4l2_buffer */
71 struct vpbe_disp_buffer *next_frm;
72 /* videobuf specific parameters
73 * Buffer queue used in video-buf
75 struct vb2_queue buffer_queue;
76 /* Queue of filled frames */
77 struct list_head dma_queue;
78 /* Used in video-buf */
80 /* V4l2 specific parameters */
81 /* Identifies video device for this layer */
82 struct video_device video_dev;
83 /* Used to store pixel format */
84 struct v4l2_pix_format pix_fmt;
85 enum v4l2_field buf_field;
86 /* Video layer configuration params */
87 struct display_layer_info layer_info;
88 /* vpbe specific parameters
89 * enable window for display
91 unsigned char window_enable;
92 /* number of open instances of the layer */
94 /* Indicates id of the field which is being displayed */
95 unsigned int field_id;
96 /* Identifies device object */
97 enum vpbe_display_device_id device_id;
98 /* facilitation of ioctl ops lock by v4l2*/
103 /* vpbe device structure */
104 struct vpbe_display {
105 /* layer specific parameters */
106 /* lock for isr updates to buf layers*/
107 spinlock_t dma_queue_lock;
108 /* C-Plane offset from start of y-plane */
109 unsigned int cbcr_ofst;
110 struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
111 struct vpbe_device *vpbe_dev;
112 struct osd_state *osd_device;
115 struct buf_config_params {
116 unsigned char min_numbuffers;
117 unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
118 unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
119 unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
122 #endif /* VPBE_DISPLAY_H */