blob: 31e6261b2c49b57faf84790fa2fc6ec000d8b56b [file] [log] [blame]
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -03001/*
2 * omap_voutdef.h
3 *
4 * Copyright (C) 2010 Texas Instruments.
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#ifndef OMAP_VOUTDEF_H
12#define OMAP_VOUTDEF_H
13
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030014#include <video/omapdss.h>
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030015
16#define YUYV_BPP 2
17#define RGB565_BPP 2
18#define RGB24_BPP 3
19#define RGB32_BPP 4
20#define TILE_SIZE 32
21#define YUYV_VRFB_BPP 2
22#define RGB_VRFB_BPP 1
23#define MAX_CID 3
24#define MAC_VRFB_CTXS 4
25#define MAX_VOUT_DEV 2
26#define MAX_OVLS 3
27#define MAX_DISPLAYS 3
28#define MAX_MANAGERS 3
29
archit tanejaa137ac82011-06-14 03:54:45 -030030#define QQVGA_WIDTH 160
31#define QQVGA_HEIGHT 120
32
33/* Max Resolution supported by the driver */
34#define VID_MAX_WIDTH 1280 /* Largest width */
35#define VID_MAX_HEIGHT 720 /* Largest height */
36
37/* Mimimum requirement is 2x2 for DSS */
38#define VID_MIN_WIDTH 2
39#define VID_MIN_HEIGHT 2
40
41/* 2048 x 2048 is max res supported by OMAP display controller */
42#define MAX_PIXELS_PER_LINE 2048
43
44#define VRFB_TX_TIMEOUT 1000
45#define VRFB_NUM_BUFS 4
46
47/* Max buffer size tobe allocated during init */
48#define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4)
49
50enum dma_channel_state {
51 DMA_CHAN_NOT_ALLOTED,
52 DMA_CHAN_ALLOTED,
53};
54
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030055/* Enum for Rotation
56 * DSS understands rotation in 0, 1, 2, 3 context
57 * while V4L2 driver understands it as 0, 90, 180, 270
58 */
59enum dss_rotation {
60 dss_rotation_0_degree = 0,
61 dss_rotation_90_degree = 1,
62 dss_rotation_180_degree = 2,
63 dss_rotation_270_degree = 3,
64};
65/*
66 * This structure is used to store the DMA transfer parameters
67 * for VRFB hidden buffer
68 */
69struct vid_vrfb_dma {
70 int dev_id;
71 int dma_ch;
72 int req_status;
73 int tx_status;
74 wait_queue_head_t wait;
75};
76
77struct omapvideo_info {
78 int id;
79 int num_overlays;
80 struct omap_overlay *overlays[MAX_OVLS];
81};
82
83struct omap2video_device {
84 struct mutex mtx;
85
86 int state;
87
88 struct v4l2_device v4l2_dev;
89 struct omap_vout_device *vouts[MAX_VOUT_DEV];
90
91 int num_displays;
92 struct omap_dss_device *displays[MAX_DISPLAYS];
93 int num_overlays;
94 struct omap_overlay *overlays[MAX_OVLS];
95 int num_managers;
96 struct omap_overlay_manager *managers[MAX_MANAGERS];
97};
98
99/* per-device data structure */
100struct omap_vout_device {
101
102 struct omapvideo_info vid_info;
103 struct video_device *vfd;
104 struct omap2video_device *vid_dev;
105 int vid;
106 int opened;
107
108 /* we don't allow to change image fmt/size once buffer has
109 * been allocated
110 */
111 int buffer_allocated;
112 /* allow to reuse previously allocated buffer which is big enough */
113 int buffer_size;
114 /* keep buffer info across opens */
115 unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
116 unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
117 enum omap_color_mode dss_mode;
118
119 /* we don't allow to request new buffer when old buffers are
120 * still mmaped
121 */
122 int mmap_count;
123
124 spinlock_t vbq_lock; /* spinlock for videobuf queues */
125 unsigned long field_count; /* field counter for videobuf_buffer */
126
127 /* non-NULL means streaming is in progress. */
128 bool streaming;
129
130 struct v4l2_pix_format pix;
131 struct v4l2_rect crop;
132 struct v4l2_window win;
133 struct v4l2_framebuffer fbuf;
134
135 /* Lock to protect the shared data structures in ioctl */
136 struct mutex lock;
137
138 /* V4L2 control structure for different control id */
139 struct v4l2_control control[MAX_CID];
140 enum dss_rotation rotation;
141 bool mirror;
142 int flicker_filter;
143 /* V4L2 control structure for different control id */
144
145 int bpp; /* bytes per pixel */
146 int vrfb_bpp; /* bytes per pixel with respect to VRFB */
147
148 struct vid_vrfb_dma vrfb_dma_tx;
149 unsigned int smsshado_phy_addr[MAC_VRFB_CTXS];
150 unsigned int smsshado_virt_addr[MAC_VRFB_CTXS];
151 struct vrfb vrfb_context[MAC_VRFB_CTXS];
152 bool vrfb_static_allocation;
153 unsigned int smsshado_size;
154 unsigned char pos;
155
156 int ps, vr_ps, line_length, first_int, field_id;
157 enum v4l2_memory memory;
158 struct videobuf_buffer *cur_frm, *next_frm;
159 struct list_head dma_queue;
160 u8 *queued_buf_addr[VIDEO_MAX_FRAME];
161 u32 cropped_offset;
162 s32 tv_field1_offset;
163 void *isr_handle;
164
165 /* Buffer queue variables */
166 struct omap_vout_device *vout;
167 enum v4l2_buf_type type;
168 struct videobuf_queue vbq;
169 int io_allowed;
170
171};
archit tanejaa137ac82011-06-14 03:54:45 -0300172
173/*
174 * Return true if rotation is 90 or 270
175 */
176static inline int rotate_90_or_270(const struct omap_vout_device *vout)
177{
178 return (vout->rotation == dss_rotation_90_degree ||
179 vout->rotation == dss_rotation_270_degree);
180}
181
182/*
183 * Return true if rotation is enabled
184 */
185static inline int rotation_enabled(const struct omap_vout_device *vout)
186{
187 return vout->rotation || vout->mirror;
188}
189
190/*
191 * Reverse the rotation degree if mirroring is enabled
192 */
193static inline int calc_rotation(const struct omap_vout_device *vout)
194{
195 if (!vout->mirror)
196 return vout->rotation;
197
198 switch (vout->rotation) {
199 case dss_rotation_90_degree:
200 return dss_rotation_270_degree;
201 case dss_rotation_270_degree:
202 return dss_rotation_90_degree;
203 case dss_rotation_180_degree:
204 return dss_rotation_0_degree;
205 default:
206 return dss_rotation_180_degree;
207 }
208}
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -0300209#endif /* ifndef OMAP_VOUTDEF_H */