blob: 80c79fabdf95b463b49743515488d18c7fafed9b [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
Hans Verkuil77430f02016-07-03 07:33:33 -030014#include <media/v4l2-ctrls.h>
Peter Ujfalusi781a1622016-05-27 15:51:03 +030015#include <video/omapfb_dss.h>
Tomi Valkeinen6a1c9f62012-10-08 14:52:24 +030016#include <video/omapvrfb.h>
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030017
18#define YUYV_BPP 2
19#define RGB565_BPP 2
20#define RGB24_BPP 3
21#define RGB32_BPP 4
22#define TILE_SIZE 32
23#define YUYV_VRFB_BPP 2
24#define RGB_VRFB_BPP 1
25#define MAX_CID 3
26#define MAC_VRFB_CTXS 4
27#define MAX_VOUT_DEV 2
28#define MAX_OVLS 3
Archit Tanejacfb128e2011-09-28 10:49:28 -030029#define MAX_DISPLAYS 10
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030030#define MAX_MANAGERS 3
31
archit tanejaa137ac82011-06-14 03:54:45 -030032#define QQVGA_WIDTH 160
33#define QQVGA_HEIGHT 120
34
35/* Max Resolution supported by the driver */
36#define VID_MAX_WIDTH 1280 /* Largest width */
37#define VID_MAX_HEIGHT 720 /* Largest height */
38
39/* Mimimum requirement is 2x2 for DSS */
40#define VID_MIN_WIDTH 2
41#define VID_MIN_HEIGHT 2
42
43/* 2048 x 2048 is max res supported by OMAP display controller */
44#define MAX_PIXELS_PER_LINE 2048
45
46#define VRFB_TX_TIMEOUT 1000
47#define VRFB_NUM_BUFS 4
48
49/* Max buffer size tobe allocated during init */
50#define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4)
51
52enum dma_channel_state {
53 DMA_CHAN_NOT_ALLOTED,
54 DMA_CHAN_ALLOTED,
55};
56
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030057/* Enum for Rotation
58 * DSS understands rotation in 0, 1, 2, 3 context
59 * while V4L2 driver understands it as 0, 90, 180, 270
60 */
61enum dss_rotation {
62 dss_rotation_0_degree = 0,
63 dss_rotation_90_degree = 1,
64 dss_rotation_180_degree = 2,
65 dss_rotation_270_degree = 3,
66};
archit taneja445e2582011-06-14 03:54:47 -030067
68/* Enum for choosing rotation type for vout
69 * DSS2 doesn't understand no rotation as an
70 * option while V4L2 driver doesn't support
71 * rotation in the case where VRFB is not built in
72 * the kernel
73 */
74enum vout_rotaion_type {
75 VOUT_ROT_NONE = 0,
76 VOUT_ROT_VRFB = 1,
77};
78
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030079/*
80 * This structure is used to store the DMA transfer parameters
81 * for VRFB hidden buffer
82 */
83struct vid_vrfb_dma {
84 int dev_id;
85 int dma_ch;
86 int req_status;
87 int tx_status;
88 wait_queue_head_t wait;
89};
90
91struct omapvideo_info {
92 int id;
93 int num_overlays;
94 struct omap_overlay *overlays[MAX_OVLS];
archit taneja445e2582011-06-14 03:54:47 -030095 enum vout_rotaion_type rotation_type;
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -030096};
97
98struct omap2video_device {
99 struct mutex mtx;
100
101 int state;
102
103 struct v4l2_device v4l2_dev;
104 struct omap_vout_device *vouts[MAX_VOUT_DEV];
105
106 int num_displays;
107 struct omap_dss_device *displays[MAX_DISPLAYS];
108 int num_overlays;
109 struct omap_overlay *overlays[MAX_OVLS];
110 int num_managers;
111 struct omap_overlay_manager *managers[MAX_MANAGERS];
112};
113
114/* per-device data structure */
115struct omap_vout_device {
116
117 struct omapvideo_info vid_info;
118 struct video_device *vfd;
119 struct omap2video_device *vid_dev;
Hans Verkuil77430f02016-07-03 07:33:33 -0300120 struct v4l2_ctrl_handler ctrl_handler;
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -0300121 int vid;
122 int opened;
123
124 /* we don't allow to change image fmt/size once buffer has
125 * been allocated
126 */
127 int buffer_allocated;
128 /* allow to reuse previously allocated buffer which is big enough */
129 int buffer_size;
130 /* keep buffer info across opens */
131 unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
132 unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
133 enum omap_color_mode dss_mode;
134
135 /* we don't allow to request new buffer when old buffers are
136 * still mmaped
137 */
138 int mmap_count;
139
140 spinlock_t vbq_lock; /* spinlock for videobuf queues */
141 unsigned long field_count; /* field counter for videobuf_buffer */
142
143 /* non-NULL means streaming is in progress. */
144 bool streaming;
145
146 struct v4l2_pix_format pix;
147 struct v4l2_rect crop;
148 struct v4l2_window win;
149 struct v4l2_framebuffer fbuf;
150
151 /* Lock to protect the shared data structures in ioctl */
152 struct mutex lock;
153
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -0300154 enum dss_rotation rotation;
155 bool mirror;
156 int flicker_filter;
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -0300157
158 int bpp; /* bytes per pixel */
159 int vrfb_bpp; /* bytes per pixel with respect to VRFB */
160
161 struct vid_vrfb_dma vrfb_dma_tx;
162 unsigned int smsshado_phy_addr[MAC_VRFB_CTXS];
163 unsigned int smsshado_virt_addr[MAC_VRFB_CTXS];
164 struct vrfb vrfb_context[MAC_VRFB_CTXS];
165 bool vrfb_static_allocation;
166 unsigned int smsshado_size;
167 unsigned char pos;
168
169 int ps, vr_ps, line_length, first_int, field_id;
170 enum v4l2_memory memory;
171 struct videobuf_buffer *cur_frm, *next_frm;
172 struct list_head dma_queue;
173 u8 *queued_buf_addr[VIDEO_MAX_FRAME];
174 u32 cropped_offset;
175 s32 tv_field1_offset;
176 void *isr_handle;
177
178 /* Buffer queue variables */
179 struct omap_vout_device *vout;
180 enum v4l2_buf_type type;
181 struct videobuf_queue vbq;
182 int io_allowed;
183
184};
archit tanejaa137ac82011-06-14 03:54:45 -0300185
186/*
187 * Return true if rotation is 90 or 270
188 */
archit tanejab3668882011-06-14 03:54:46 -0300189static inline int is_rotation_90_or_270(const struct omap_vout_device *vout)
archit tanejaa137ac82011-06-14 03:54:45 -0300190{
191 return (vout->rotation == dss_rotation_90_degree ||
192 vout->rotation == dss_rotation_270_degree);
193}
194
195/*
196 * Return true if rotation is enabled
197 */
archit tanejab3668882011-06-14 03:54:46 -0300198static inline int is_rotation_enabled(const struct omap_vout_device *vout)
archit tanejaa137ac82011-06-14 03:54:45 -0300199{
200 return vout->rotation || vout->mirror;
201}
202
203/*
204 * Reverse the rotation degree if mirroring is enabled
205 */
206static inline int calc_rotation(const struct omap_vout_device *vout)
207{
208 if (!vout->mirror)
209 return vout->rotation;
210
211 switch (vout->rotation) {
212 case dss_rotation_90_degree:
213 return dss_rotation_270_degree;
214 case dss_rotation_270_degree:
215 return dss_rotation_90_degree;
216 case dss_rotation_180_degree:
217 return dss_rotation_0_degree;
218 default:
219 return dss_rotation_180_degree;
220 }
221}
archit taneja445e2582011-06-14 03:54:47 -0300222
223void omap_vout_free_buffers(struct omap_vout_device *vout);
Vaibhav Hiremath5c7ab632010-04-11 10:41:49 -0300224#endif /* ifndef OMAP_VOUTDEF_H */