4 * Copyright (C) 2010 Texas Instruments.
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.
11 #ifndef OMAP_VOUTDEF_H
12 #define OMAP_VOUTDEF_H
14 #include <media/v4l2-ctrls.h>
15 #include <video/omapfb_dss.h>
16 #include <video/omapvrfb.h>
17 #include <linux/dmaengine.h>
24 #define YUYV_VRFB_BPP 2
25 #define RGB_VRFB_BPP 1
27 #define MAC_VRFB_CTXS 4
28 #define MAX_VOUT_DEV 2
30 #define MAX_DISPLAYS 10
31 #define MAX_MANAGERS 3
33 #define QQVGA_WIDTH 160
34 #define QQVGA_HEIGHT 120
36 /* Max Resolution supported by the driver */
37 #define VID_MAX_WIDTH 1280 /* Largest width */
38 #define VID_MAX_HEIGHT 720 /* Largest height */
40 /* Mimimum requirement is 2x2 for DSS */
41 #define VID_MIN_WIDTH 2
42 #define VID_MIN_HEIGHT 2
44 /* 2048 x 2048 is max res supported by OMAP display controller */
45 #define MAX_PIXELS_PER_LINE 2048
47 #define VRFB_TX_TIMEOUT 1000
48 #define VRFB_NUM_BUFS 4
50 /* Max buffer size tobe allocated during init */
51 #define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4)
53 enum dma_channel_state
{
59 * DSS understands rotation in 0, 1, 2, 3 context
60 * while V4L2 driver understands it as 0, 90, 180, 270
63 dss_rotation_0_degree
= 0,
64 dss_rotation_90_degree
= 1,
65 dss_rotation_180_degree
= 2,
66 dss_rotation_270_degree
= 3,
69 /* Enum for choosing rotation type for vout
70 * DSS2 doesn't understand no rotation as an
71 * option while V4L2 driver doesn't support
72 * rotation in the case where VRFB is not built in
75 enum vout_rotaion_type
{
81 * This structure is used to store the DMA transfer parameters
82 * for VRFB hidden buffer
85 struct dma_chan
*chan
;
86 struct dma_interleaved_template
*xt
;
90 wait_queue_head_t wait
;
93 struct omapvideo_info
{
96 struct omap_overlay
*overlays
[MAX_OVLS
];
97 enum vout_rotaion_type rotation_type
;
100 struct omap2video_device
{
105 struct v4l2_device v4l2_dev
;
106 struct omap_vout_device
*vouts
[MAX_VOUT_DEV
];
109 struct omap_dss_device
*displays
[MAX_DISPLAYS
];
111 struct omap_overlay
*overlays
[MAX_OVLS
];
113 struct omap_overlay_manager
*managers
[MAX_MANAGERS
];
116 /* per-device data structure */
117 struct omap_vout_device
{
119 struct omapvideo_info vid_info
;
120 struct video_device
*vfd
;
121 struct omap2video_device
*vid_dev
;
122 struct v4l2_ctrl_handler ctrl_handler
;
126 /* we don't allow to change image fmt/size once buffer has
129 int buffer_allocated
;
130 /* allow to reuse previously allocated buffer which is big enough */
132 /* keep buffer info across opens */
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
;
137 /* we don't allow to request new buffer when old buffers are
142 spinlock_t vbq_lock
; /* spinlock for videobuf queues */
143 unsigned long field_count
; /* field counter for videobuf_buffer */
145 /* non-NULL means streaming is in progress. */
148 struct v4l2_pix_format pix
;
149 struct v4l2_rect crop
;
150 struct v4l2_window win
;
151 struct v4l2_framebuffer fbuf
;
153 /* Lock to protect the shared data structures in ioctl */
156 enum dss_rotation rotation
;
160 int bpp
; /* bytes per pixel */
161 int vrfb_bpp
; /* bytes per pixel with respect to VRFB */
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
;
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
];
177 s32 tv_field1_offset
;
180 /* Buffer queue variables */
181 struct omap_vout_device
*vout
;
182 enum v4l2_buf_type type
;
183 struct videobuf_queue vbq
;
189 * Return true if rotation is 90 or 270
191 static inline int is_rotation_90_or_270(const struct omap_vout_device
*vout
)
193 return (vout
->rotation
== dss_rotation_90_degree
||
194 vout
->rotation
== dss_rotation_270_degree
);
198 * Return true if rotation is enabled
200 static inline int is_rotation_enabled(const struct omap_vout_device
*vout
)
202 return vout
->rotation
|| vout
->mirror
;
206 * Reverse the rotation degree if mirroring is enabled
208 static inline int calc_rotation(const struct omap_vout_device
*vout
)
211 return vout
->rotation
;
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
;
221 return dss_rotation_180_degree
;
225 void omap_vout_free_buffers(struct omap_vout_device
*vout
);
226 #endif /* ifndef OMAP_VOUTDEF_H */