aboutsummaryrefslogtreecommitdiffstats
path: root/include/video
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2013-09-30 10:13:39 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2014-06-04 05:06:52 -0400
commit39b9004d1f626b88b775c7655d3f286e135dfec6 (patch)
tree3d439afd8cff80424b05b78aebe00e23b0ed6b7f /include/video
parentd1db0eea852497762cab43b905b879dfcd3b8987 (diff)
gpu: ipu-v3: Move i.MX IPUv3 core driver out of staging
The i.MX Image Processing Unit (IPU) contains a number of image processing blocks that sit right in the middle between DRM and V4L2. Some of the modules, such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS Sensor Interface (CSI) and their FIFOs could be assigned to either framework, but others, such as the dma controller (IDMAC) and image converter (IC) can be used by both. The IPUv3 core driver provides an internal API to access the modules, to be used by both DRM and V4L2 IPUv3 drivers. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/video')
-rw-r--r--include/video/imx-ipu-v3.h326
1 files changed, 326 insertions, 0 deletions
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
new file mode 100644
index 000000000000..c4d14ead5837
--- /dev/null
+++ b/include/video/imx-ipu-v3.h
@@ -0,0 +1,326 @@
1/*
2 * Copyright 2005-2009 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU Lesser General
5 * Public License. You may obtain a copy of the GNU Lesser General
6 * Public License Version 2.1 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/lgpl-license.html
9 * http://www.gnu.org/copyleft/lgpl.html
10 */
11
12#ifndef __DRM_IPU_H__
13#define __DRM_IPU_H__
14
15#include <linux/types.h>
16#include <linux/videodev2.h>
17#include <linux/bitmap.h>
18#include <linux/fb.h>
19
20struct ipu_soc;
21
22enum ipuv3_type {
23 IPUV3EX,
24 IPUV3M,
25 IPUV3H,
26};
27
28#define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3')
29
30/*
31 * Bitfield of Display Interface signal polarities.
32 */
33struct ipu_di_signal_cfg {
34 unsigned datamask_en:1;
35 unsigned interlaced:1;
36 unsigned odd_field_first:1;
37 unsigned clksel_en:1;
38 unsigned clkidle_en:1;
39 unsigned data_pol:1; /* true = inverted */
40 unsigned clk_pol:1; /* true = rising edge */
41 unsigned enable_pol:1;
42 unsigned Hsync_pol:1; /* true = active high */
43 unsigned Vsync_pol:1;
44
45 u16 width;
46 u16 height;
47 u32 pixel_fmt;
48 u16 h_start_width;
49 u16 h_sync_width;
50 u16 h_end_width;
51 u16 v_start_width;
52 u16 v_sync_width;
53 u16 v_end_width;
54 u32 v_to_h_sync;
55 unsigned long pixelclock;
56#define IPU_DI_CLKMODE_SYNC (1 << 0)
57#define IPU_DI_CLKMODE_EXT (1 << 1)
58 unsigned long clkflags;
59
60 u8 hsync_pin;
61 u8 vsync_pin;
62};
63
64enum ipu_color_space {
65 IPUV3_COLORSPACE_RGB,
66 IPUV3_COLORSPACE_YUV,
67 IPUV3_COLORSPACE_UNKNOWN,
68};
69
70struct ipuv3_channel;
71
72enum ipu_channel_irq {
73 IPU_IRQ_EOF = 0,
74 IPU_IRQ_NFACK = 64,
75 IPU_IRQ_NFB4EOF = 128,
76 IPU_IRQ_EOS = 192,
77};
78
79int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
80 enum ipu_channel_irq irq);
81
82#define IPU_IRQ_DP_SF_START (448 + 2)
83#define IPU_IRQ_DP_SF_END (448 + 3)
84#define IPU_IRQ_BG_SF_END IPU_IRQ_DP_SF_END,
85#define IPU_IRQ_DC_FC_0 (448 + 8)
86#define IPU_IRQ_DC_FC_1 (448 + 9)
87#define IPU_IRQ_DC_FC_2 (448 + 10)
88#define IPU_IRQ_DC_FC_3 (448 + 11)
89#define IPU_IRQ_DC_FC_4 (448 + 12)
90#define IPU_IRQ_DC_FC_6 (448 + 13)
91#define IPU_IRQ_VSYNC_PRE_0 (448 + 14)
92#define IPU_IRQ_VSYNC_PRE_1 (448 + 15)
93
94/*
95 * IPU Image DMA Controller (idmac) functions
96 */
97struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned channel);
98void ipu_idmac_put(struct ipuv3_channel *);
99
100int ipu_idmac_enable_channel(struct ipuv3_channel *channel);
101int ipu_idmac_disable_channel(struct ipuv3_channel *channel);
102int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
103
104void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
105 bool doublebuffer);
106void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
107
108/*
109 * IPU Display Controller (dc) functions
110 */
111struct ipu_dc;
112struct ipu_di;
113struct ipu_dc *ipu_dc_get(struct ipu_soc *ipu, int channel);
114void ipu_dc_put(struct ipu_dc *dc);
115int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced,
116 u32 pixel_fmt, u32 width);
117void ipu_dc_enable_channel(struct ipu_dc *dc);
118void ipu_dc_disable_channel(struct ipu_dc *dc);
119
120/*
121 * IPU Display Interface (di) functions
122 */
123struct ipu_di *ipu_di_get(struct ipu_soc *ipu, int disp);
124void ipu_di_put(struct ipu_di *);
125int ipu_di_disable(struct ipu_di *);
126int ipu_di_enable(struct ipu_di *);
127int ipu_di_get_num(struct ipu_di *);
128int ipu_di_init_sync_panel(struct ipu_di *, struct ipu_di_signal_cfg *sig);
129
130/*
131 * IPU Display Multi FIFO Controller (dmfc) functions
132 */
133struct dmfc_channel;
134int ipu_dmfc_enable_channel(struct dmfc_channel *dmfc);
135void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc);
136int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc,
137 unsigned long bandwidth_mbs, int burstsize);
138void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc);
139int ipu_dmfc_init_channel(struct dmfc_channel *dmfc, int width);
140struct dmfc_channel *ipu_dmfc_get(struct ipu_soc *ipu, int ipuv3_channel);
141void ipu_dmfc_put(struct dmfc_channel *dmfc);
142
143/*
144 * IPU Display Processor (dp) functions
145 */
146#define IPU_DP_FLOW_SYNC_BG 0
147#define IPU_DP_FLOW_SYNC_FG 1
148#define IPU_DP_FLOW_ASYNC0_BG 2
149#define IPU_DP_FLOW_ASYNC0_FG 3
150#define IPU_DP_FLOW_ASYNC1_BG 4
151#define IPU_DP_FLOW_ASYNC1_FG 5
152
153struct ipu_dp *ipu_dp_get(struct ipu_soc *ipu, unsigned int flow);
154void ipu_dp_put(struct ipu_dp *);
155int ipu_dp_enable_channel(struct ipu_dp *dp);
156void ipu_dp_disable_channel(struct ipu_dp *dp);
157int ipu_dp_setup_channel(struct ipu_dp *dp,
158 enum ipu_color_space in, enum ipu_color_space out);
159int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos);
160int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha,
161 bool bg_chan);
162
163#define IPU_CPMEM_WORD(word, ofs, size) ((((word) * 160 + (ofs)) << 8) | (size))
164
165#define IPU_FIELD_UBO IPU_CPMEM_WORD(0, 46, 22)
166#define IPU_FIELD_VBO IPU_CPMEM_WORD(0, 68, 22)
167#define IPU_FIELD_IOX IPU_CPMEM_WORD(0, 90, 4)
168#define IPU_FIELD_RDRW IPU_CPMEM_WORD(0, 94, 1)
169#define IPU_FIELD_SO IPU_CPMEM_WORD(0, 113, 1)
170#define IPU_FIELD_SLY IPU_CPMEM_WORD(1, 102, 14)
171#define IPU_FIELD_SLUV IPU_CPMEM_WORD(1, 128, 14)
172
173#define IPU_FIELD_XV IPU_CPMEM_WORD(0, 0, 10)
174#define IPU_FIELD_YV IPU_CPMEM_WORD(0, 10, 9)
175#define IPU_FIELD_XB IPU_CPMEM_WORD(0, 19, 13)
176#define IPU_FIELD_YB IPU_CPMEM_WORD(0, 32, 12)
177#define IPU_FIELD_NSB_B IPU_CPMEM_WORD(0, 44, 1)
178#define IPU_FIELD_CF IPU_CPMEM_WORD(0, 45, 1)
179#define IPU_FIELD_SX IPU_CPMEM_WORD(0, 46, 12)
180#define IPU_FIELD_SY IPU_CPMEM_WORD(0, 58, 11)
181#define IPU_FIELD_NS IPU_CPMEM_WORD(0, 69, 10)
182#define IPU_FIELD_SDX IPU_CPMEM_WORD(0, 79, 7)
183#define IPU_FIELD_SM IPU_CPMEM_WORD(0, 86, 10)
184#define IPU_FIELD_SCC IPU_CPMEM_WORD(0, 96, 1)
185#define IPU_FIELD_SCE IPU_CPMEM_WORD(0, 97, 1)
186#define IPU_FIELD_SDY IPU_CPMEM_WORD(0, 98, 7)
187#define IPU_FIELD_SDRX IPU_CPMEM_WORD(0, 105, 1)
188#define IPU_FIELD_SDRY IPU_CPMEM_WORD(0, 106, 1)
189#define IPU_FIELD_BPP IPU_CPMEM_WORD(0, 107, 3)
190#define IPU_FIELD_DEC_SEL IPU_CPMEM_WORD(0, 110, 2)
191#define IPU_FIELD_DIM IPU_CPMEM_WORD(0, 112, 1)
192#define IPU_FIELD_BNDM IPU_CPMEM_WORD(0, 114, 3)
193#define IPU_FIELD_BM IPU_CPMEM_WORD(0, 117, 2)
194#define IPU_FIELD_ROT IPU_CPMEM_WORD(0, 119, 1)
195#define IPU_FIELD_HF IPU_CPMEM_WORD(0, 120, 1)
196#define IPU_FIELD_VF IPU_CPMEM_WORD(0, 121, 1)
197#define IPU_FIELD_THE IPU_CPMEM_WORD(0, 122, 1)
198#define IPU_FIELD_CAP IPU_CPMEM_WORD(0, 123, 1)
199#define IPU_FIELD_CAE IPU_CPMEM_WORD(0, 124, 1)
200#define IPU_FIELD_FW IPU_CPMEM_WORD(0, 125, 13)
201#define IPU_FIELD_FH IPU_CPMEM_WORD(0, 138, 12)
202#define IPU_FIELD_EBA0 IPU_CPMEM_WORD(1, 0, 29)
203#define IPU_FIELD_EBA1 IPU_CPMEM_WORD(1, 29, 29)
204#define IPU_FIELD_ILO IPU_CPMEM_WORD(1, 58, 20)
205#define IPU_FIELD_NPB IPU_CPMEM_WORD(1, 78, 7)
206#define IPU_FIELD_PFS IPU_CPMEM_WORD(1, 85, 4)
207#define IPU_FIELD_ALU IPU_CPMEM_WORD(1, 89, 1)
208#define IPU_FIELD_ALBM IPU_CPMEM_WORD(1, 90, 3)
209#define IPU_FIELD_ID IPU_CPMEM_WORD(1, 93, 2)
210#define IPU_FIELD_TH IPU_CPMEM_WORD(1, 95, 7)
211#define IPU_FIELD_SL IPU_CPMEM_WORD(1, 102, 14)
212#define IPU_FIELD_WID0 IPU_CPMEM_WORD(1, 116, 3)
213#define IPU_FIELD_WID1 IPU_CPMEM_WORD(1, 119, 3)
214#define IPU_FIELD_WID2 IPU_CPMEM_WORD(1, 122, 3)
215#define IPU_FIELD_WID3 IPU_CPMEM_WORD(1, 125, 3)
216#define IPU_FIELD_OFS0 IPU_CPMEM_WORD(1, 128, 5)
217#define IPU_FIELD_OFS1 IPU_CPMEM_WORD(1, 133, 5)
218#define IPU_FIELD_OFS2 IPU_CPMEM_WORD(1, 138, 5)
219#define IPU_FIELD_OFS3 IPU_CPMEM_WORD(1, 143, 5)
220#define IPU_FIELD_SXYS IPU_CPMEM_WORD(1, 148, 1)
221#define IPU_FIELD_CRE IPU_CPMEM_WORD(1, 149, 1)
222#define IPU_FIELD_DEC_SEL2 IPU_CPMEM_WORD(1, 150, 1)
223
224struct ipu_cpmem_word {
225 u32 data[5];
226 u32 res[3];
227};
228
229struct ipu_ch_param {
230 struct ipu_cpmem_word word[2];
231};
232
233void ipu_ch_param_write_field(struct ipu_ch_param __iomem *base, u32 wbs, u32 v);
234u32 ipu_ch_param_read_field(struct ipu_ch_param __iomem *base, u32 wbs);
235struct ipu_ch_param __iomem *ipu_get_cpmem(struct ipuv3_channel *channel);
236void ipu_ch_param_dump(struct ipu_ch_param __iomem *p);
237
238static inline void ipu_ch_param_zero(struct ipu_ch_param __iomem *p)
239{
240 int i;
241 void __iomem *base = p;
242
243 for (i = 0; i < sizeof(*p) / sizeof(u32); i++)
244 writel(0, base + i * sizeof(u32));
245}
246
247static inline void ipu_cpmem_set_buffer(struct ipu_ch_param __iomem *p,
248 int bufnum, dma_addr_t buf)
249{
250 if (bufnum)
251 ipu_ch_param_write_field(p, IPU_FIELD_EBA1, buf >> 3);
252 else
253 ipu_ch_param_write_field(p, IPU_FIELD_EBA0, buf >> 3);
254}
255
256static inline void ipu_cpmem_set_resolution(struct ipu_ch_param __iomem *p,
257 int xres, int yres)
258{
259 ipu_ch_param_write_field(p, IPU_FIELD_FW, xres - 1);
260 ipu_ch_param_write_field(p, IPU_FIELD_FH, yres - 1);
261}
262
263static inline void ipu_cpmem_set_stride(struct ipu_ch_param __iomem *p,
264 int stride)
265{
266 ipu_ch_param_write_field(p, IPU_FIELD_SLY, stride - 1);
267}
268
269void ipu_cpmem_set_high_priority(struct ipuv3_channel *channel);
270
271struct ipu_rgb {
272 struct fb_bitfield red;
273 struct fb_bitfield green;
274 struct fb_bitfield blue;
275 struct fb_bitfield transp;
276 int bits_per_pixel;
277};
278
279struct ipu_image {
280 struct v4l2_pix_format pix;
281 struct v4l2_rect rect;
282 dma_addr_t phys;
283};
284
285int ipu_cpmem_set_format_passthrough(struct ipu_ch_param __iomem *p,
286 int width);
287
288int ipu_cpmem_set_format_rgb(struct ipu_ch_param __iomem *,
289 const struct ipu_rgb *rgb);
290
291static inline void ipu_cpmem_interlaced_scan(struct ipu_ch_param *p,
292 int stride)
293{
294 ipu_ch_param_write_field(p, IPU_FIELD_SO, 1);
295 ipu_ch_param_write_field(p, IPU_FIELD_ILO, stride / 8);
296 ipu_ch_param_write_field(p, IPU_FIELD_SLY, (stride * 2) - 1);
297};
298
299void ipu_cpmem_set_yuv_planar(struct ipu_ch_param __iomem *p, u32 pixel_format,
300 int stride, int height);
301void ipu_cpmem_set_yuv_interleaved(struct ipu_ch_param __iomem *p,
302 u32 pixel_format);
303void ipu_cpmem_set_yuv_planar_full(struct ipu_ch_param __iomem *p,
304 u32 pixel_format, int stride, int u_offset, int v_offset);
305int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, u32 pixelformat);
306int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
307 struct ipu_image *image);
308
309enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
310enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
311
312static inline void ipu_cpmem_set_burstsize(struct ipu_ch_param __iomem *p,
313 int burstsize)
314{
315 ipu_ch_param_write_field(p, IPU_FIELD_NPB, burstsize - 1);
316};
317
318struct ipu_client_platformdata {
319 int di;
320 int dc;
321 int dp;
322 int dmfc;
323 int dma[2];
324};
325
326#endif /* __DRM_IPU_H__ */