1
2
3
4
5
6
7
8
9
10
11#ifndef OMAP_VOUTDEF_H
12#define OMAP_VOUTDEF_H
13
14#include <media/v4l2-ctrls.h>
15#include <video/omapfb_dss.h>
16#include <video/omapvrfb.h>
17#include <linux/dmaengine.h>
18
19#define YUYV_BPP 2
20#define RGB565_BPP 2
21#define RGB24_BPP 3
22#define RGB32_BPP 4
23#define TILE_SIZE 32
24#define YUYV_VRFB_BPP 2
25#define RGB_VRFB_BPP 1
26#define MAX_CID 3
27#define MAC_VRFB_CTXS 4
28#define MAX_VOUT_DEV 2
29#define MAX_OVLS 3
30#define MAX_DISPLAYS 10
31#define MAX_MANAGERS 3
32
33#define QQVGA_WIDTH 160
34#define QQVGA_HEIGHT 120
35
36
37#define VID_MAX_WIDTH 1280
38#define VID_MAX_HEIGHT 720
39
40
41#define VID_MIN_WIDTH 2
42#define VID_MIN_HEIGHT 2
43
44
45#define MAX_PIXELS_PER_LINE 2048
46
47#define VRFB_TX_TIMEOUT 1000
48#define VRFB_NUM_BUFS 4
49
50
51#define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4)
52
53enum dma_channel_state {
54 DMA_CHAN_NOT_ALLOTED,
55 DMA_CHAN_ALLOTED,
56};
57
58
59
60
61
62enum dss_rotation {
63 dss_rotation_0_degree = 0,
64 dss_rotation_90_degree = 1,
65 dss_rotation_180_degree = 2,
66 dss_rotation_270_degree = 3,
67};
68
69
70
71
72
73
74
75enum vout_rotaion_type {
76 VOUT_ROT_NONE = 0,
77 VOUT_ROT_VRFB = 1,
78};
79
80
81
82
83
84struct vid_vrfb_dma {
85 struct dma_chan *chan;
86 struct dma_interleaved_template *xt;
87
88 int req_status;
89 int tx_status;
90 wait_queue_head_t wait;
91};
92
93struct omapvideo_info {
94 int id;
95 int num_overlays;
96 struct omap_overlay *overlays[MAX_OVLS];
97 enum vout_rotaion_type rotation_type;
98};
99
100struct omap2video_device {
101 struct mutex mtx;
102
103 int state;
104
105 struct v4l2_device v4l2_dev;
106 struct omap_vout_device *vouts[MAX_VOUT_DEV];
107
108 int num_displays;
109 struct omap_dss_device *displays[MAX_DISPLAYS];
110 int num_overlays;
111 struct omap_overlay *overlays[MAX_OVLS];
112 int num_managers;
113 struct omap_overlay_manager *managers[MAX_MANAGERS];
114};
115
116
117struct omap_vout_device {
118
119 struct omapvideo_info vid_info;
120 struct video_device *vfd;
121 struct omap2video_device *vid_dev;
122 struct v4l2_ctrl_handler ctrl_handler;
123 int vid;
124 int opened;
125
126
127
128
129 int buffer_allocated;
130
131 int buffer_size;
132
133 unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
134 unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
135 enum omap_color_mode dss_mode;
136
137
138
139
140 int mmap_count;
141
142 spinlock_t vbq_lock;
143 unsigned long field_count;
144
145
146 bool streaming;
147
148 struct v4l2_pix_format pix;
149 struct v4l2_rect crop;
150 struct v4l2_window win;
151 struct v4l2_framebuffer fbuf;
152
153
154 struct mutex lock;
155
156 enum dss_rotation rotation;
157 bool mirror;
158 int flicker_filter;
159
160 int bpp;
161 int vrfb_bpp;
162
163 struct vid_vrfb_dma vrfb_dma_tx;
164 unsigned int smsshado_phy_addr[MAC_VRFB_CTXS];
165 unsigned int smsshado_virt_addr[MAC_VRFB_CTXS];
166 struct vrfb vrfb_context[MAC_VRFB_CTXS];
167 bool vrfb_static_allocation;
168 unsigned int smsshado_size;
169 unsigned char pos;
170
171 int ps, vr_ps, line_length, first_int, field_id;
172 enum v4l2_memory memory;
173 struct videobuf_buffer *cur_frm, *next_frm;
174 struct list_head dma_queue;
175 u8 *queued_buf_addr[VIDEO_MAX_FRAME];
176 u32 cropped_offset;
177 s32 tv_field1_offset;
178 void *isr_handle;
179
180
181 struct omap_vout_device *vout;
182 enum v4l2_buf_type type;
183 struct videobuf_queue vbq;
184 int io_allowed;
185
186};
187
188
189
190
191static inline int is_rotation_90_or_270(const struct omap_vout_device *vout)
192{
193 return (vout->rotation == dss_rotation_90_degree ||
194 vout->rotation == dss_rotation_270_degree);
195}
196
197
198
199
200static inline int is_rotation_enabled(const struct omap_vout_device *vout)
201{
202 return vout->rotation || vout->mirror;
203}
204
205
206
207
208static inline int calc_rotation(const struct omap_vout_device *vout)
209{
210 if (!vout->mirror)
211 return vout->rotation;
212
213 switch (vout->rotation) {
214 case dss_rotation_90_degree:
215 return dss_rotation_270_degree;
216 case dss_rotation_270_degree:
217 return dss_rotation_90_degree;
218 case dss_rotation_180_degree:
219 return dss_rotation_0_degree;
220 default:
221 return dss_rotation_180_degree;
222 }
223}
224
225void omap_vout_free_buffers(struct omap_vout_device *vout);
226#endif
227