Linux 3.12.5
[linux/fpc-iii.git] / include / media / davinci / vpbe_display.h
blob8dffffedbb590ecaf7a5454fad2d84d21a557ebb
1 /*
2 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
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.
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.
13 #ifndef VPBE_DISPLAY_H
14 #define VPBE_DISPLAY_H
16 /* Header files */
17 #include <linux/videodev2.h>
18 #include <media/v4l2-common.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>
24 #define VPBE_DISPLAY_MAX_DEVICES 2
26 enum vpbe_display_device_id {
27 VPBE_DISPLAY_DEVICE_0,
28 VPBE_DISPLAY_DEVICE_1
31 #define VPBE_DISPLAY_DRV_NAME "vpbe-display"
33 #define VPBE_DISPLAY_MAJOR_RELEASE 1
34 #define VPBE_DISPLAY_MINOR_RELEASE 0
35 #define VPBE_DISPLAY_BUILD 1
36 #define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \
37 (VPBE_DISPLAY_MINOR_RELEASE << 8) | \
38 VPBE_DISPLAY_BUILD)
40 #define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \
41 (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field))
43 /* Exp ratio numerator and denominator constants */
44 #define VPBE_DISPLAY_H_EXP_RATIO_N 9
45 #define VPBE_DISPLAY_H_EXP_RATIO_D 8
46 #define VPBE_DISPLAY_V_EXP_RATIO_N 6
47 #define VPBE_DISPLAY_V_EXP_RATIO_D 5
49 /* Zoom multiplication factor */
50 #define VPBE_DISPLAY_ZOOM_4X 4
51 #define VPBE_DISPLAY_ZOOM_2X 2
53 /* Structures */
54 struct display_layer_info {
55 int enable;
56 /* Layer ID used by Display Manager */
57 enum osd_layer id;
58 struct osd_layer_config config;
59 enum osd_zoom_factor h_zoom;
60 enum osd_zoom_factor v_zoom;
61 enum osd_h_exp_ratio h_exp;
62 enum osd_v_exp_ratio v_exp;
65 struct vpbe_disp_buffer {
66 struct vb2_buffer vb;
67 struct list_head list;
70 /* vpbe display object structure */
71 struct vpbe_layer {
72 /* number of buffers in fbuffers */
73 unsigned int numbuffers;
74 /* Pointer to the vpbe_display */
75 struct vpbe_display *disp_dev;
76 /* Pointer pointing to current v4l2_buffer */
77 struct vpbe_disp_buffer *cur_frm;
78 /* Pointer pointing to next v4l2_buffer */
79 struct vpbe_disp_buffer *next_frm;
80 /* videobuf specific parameters
81 * Buffer queue used in video-buf
83 struct vb2_queue buffer_queue;
84 /* allocator-specific contexts for each plane */
85 struct vb2_alloc_ctx *alloc_ctx;
86 /* Queue of filled frames */
87 struct list_head dma_queue;
88 /* Used in video-buf */
89 spinlock_t irqlock;
90 /* V4l2 specific parameters */
91 /* Identifies video device for this layer */
92 struct video_device video_dev;
93 /* This field keeps track of type of buffer exchange mechanism user
94 * has selected
96 enum v4l2_memory memory;
97 /* Used to keep track of state of the priority */
98 struct v4l2_prio_state prio;
99 /* Used to store pixel format */
100 struct v4l2_pix_format pix_fmt;
101 enum v4l2_field buf_field;
102 /* Video layer configuration params */
103 struct display_layer_info layer_info;
104 /* vpbe specific parameters
105 * enable window for display
107 unsigned char window_enable;
108 /* number of open instances of the layer */
109 unsigned int usrs;
110 /* number of users performing IO */
111 unsigned int io_usrs;
112 /* Indicates id of the field which is being displayed */
113 unsigned int field_id;
114 /* Indicates whether streaming started */
115 unsigned char started;
116 /* Identifies device object */
117 enum vpbe_display_device_id device_id;
118 /* facilitation of ioctl ops lock by v4l2*/
119 struct mutex opslock;
120 u8 layer_first_int;
123 /* vpbe device structure */
124 struct vpbe_display {
125 /* layer specific parameters */
126 /* lock for isr updates to buf layers*/
127 spinlock_t dma_queue_lock;
128 /* C-Plane offset from start of y-plane */
129 unsigned int cbcr_ofst;
130 struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
131 struct vpbe_device *vpbe_dev;
132 struct osd_state *osd_device;
135 /* File handle structure */
136 struct vpbe_fh {
137 /* vpbe device structure */
138 struct vpbe_display *disp_dev;
139 /* pointer to layer object for opened device */
140 struct vpbe_layer *layer;
141 /* Indicates whether this file handle is doing IO */
142 unsigned char io_allowed;
143 /* Used to keep track priority of this instance */
144 enum v4l2_priority prio;
147 struct buf_config_params {
148 unsigned char min_numbuffers;
149 unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
150 unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
151 unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
154 #endif /* VPBE_DISPLAY_H */