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