blob: f80fe13b0d4dfd4081fd72845f9f7b31abf6bb6b [file] [log] [blame]
Sascha Haueraecfbdb2012-09-21 10:07:49 +02001/*
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>
Sascha Haueraecfbdb2012-09-21 10:07:49 +020019
20struct ipu_soc;
21
22enum ipuv3_type {
23 IPUV3EX,
24 IPUV3M,
25 IPUV3H,
26};
27
Philipp Zabel7f4392a2014-02-25 12:43:41 +010028#define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3')
29
Sascha Haueraecfbdb2012-09-21 10:07:49 +020030/*
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;
Philipp Zabel2ea42602013-04-08 18:04:35 +020059
60 u8 hsync_pin;
61 u8 vsync_pin;
Sascha Haueraecfbdb2012-09-21 10:07:49 +020062};
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
Philipp Zabel861a50c2014-04-14 23:53:16 +020079int ipu_map_irq(struct ipu_soc *ipu, int irq);
Sascha Haueraecfbdb2012-09-21 10:07:49 +020080int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
81 enum ipu_channel_irq irq);
82
83#define IPU_IRQ_DP_SF_START (448 + 2)
84#define IPU_IRQ_DP_SF_END (448 + 3)
85#define IPU_IRQ_BG_SF_END IPU_IRQ_DP_SF_END,
86#define IPU_IRQ_DC_FC_0 (448 + 8)
87#define IPU_IRQ_DC_FC_1 (448 + 9)
88#define IPU_IRQ_DC_FC_2 (448 + 10)
89#define IPU_IRQ_DC_FC_3 (448 + 11)
90#define IPU_IRQ_DC_FC_4 (448 + 12)
91#define IPU_IRQ_DC_FC_6 (448 + 13)
92#define IPU_IRQ_VSYNC_PRE_0 (448 + 14)
93#define IPU_IRQ_VSYNC_PRE_1 (448 + 15)
94
95/*
Steve Longerbeamba079752014-06-25 18:05:30 -070096 * IPU Common functions
97 */
98void ipu_set_csi_src_mux(struct ipu_soc *ipu, int csi_id, bool mipi_csi2);
99void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi);
100
101/*
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200102 * IPU Image DMA Controller (idmac) functions
103 */
104struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned channel);
105void ipu_idmac_put(struct ipuv3_channel *);
106
107int ipu_idmac_enable_channel(struct ipuv3_channel *channel);
108int ipu_idmac_disable_channel(struct ipuv3_channel *channel);
Sascha Hauerfb822a32013-10-10 16:18:41 +0200109int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200110
111void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
112 bool doublebuffer);
Philipp Zabele9046092012-05-16 17:28:29 +0200113int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200114void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
115
116/*
Steve Longerbeam7d2691d2014-06-25 18:05:47 -0700117 * IPU Channel Parameter Memory (cpmem) functions
118 */
119struct ipu_rgb {
120 struct fb_bitfield red;
121 struct fb_bitfield green;
122 struct fb_bitfield blue;
123 struct fb_bitfield transp;
124 int bits_per_pixel;
125};
126
127struct ipu_image {
128 struct v4l2_pix_format pix;
129 struct v4l2_rect rect;
130 dma_addr_t phys;
131};
132
133void ipu_cpmem_zero(struct ipuv3_channel *ch);
134void ipu_cpmem_set_resolution(struct ipuv3_channel *ch, int xres, int yres);
135void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride);
136void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch);
137void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf);
138void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
139void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
140int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch,
141 const struct ipu_rgb *rgb);
142int ipu_cpmem_set_format_passthrough(struct ipuv3_channel *ch, int width);
143void ipu_cpmem_set_yuv_interleaved(struct ipuv3_channel *ch, u32 pixel_format);
144void ipu_cpmem_set_yuv_planar_full(struct ipuv3_channel *ch,
145 u32 pixel_format, int stride,
146 int u_offset, int v_offset);
147void ipu_cpmem_set_yuv_planar(struct ipuv3_channel *ch,
148 u32 pixel_format, int stride, int height);
149int ipu_cpmem_set_fmt(struct ipuv3_channel *ch, u32 drm_fourcc);
150int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image);
151
152/*
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200153 * IPU Display Controller (dc) functions
154 */
155struct ipu_dc;
156struct ipu_di;
157struct ipu_dc *ipu_dc_get(struct ipu_soc *ipu, int channel);
158void ipu_dc_put(struct ipu_dc *dc);
159int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced,
160 u32 pixel_fmt, u32 width);
Philipp Zabel1e6d4862014-04-14 23:53:23 +0200161void ipu_dc_enable(struct ipu_soc *ipu);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200162void ipu_dc_enable_channel(struct ipu_dc *dc);
163void ipu_dc_disable_channel(struct ipu_dc *dc);
Philipp Zabel1e6d4862014-04-14 23:53:23 +0200164void ipu_dc_disable(struct ipu_soc *ipu);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200165
166/*
167 * IPU Display Interface (di) functions
168 */
169struct ipu_di *ipu_di_get(struct ipu_soc *ipu, int disp);
170void ipu_di_put(struct ipu_di *);
171int ipu_di_disable(struct ipu_di *);
172int ipu_di_enable(struct ipu_di *);
173int ipu_di_get_num(struct ipu_di *);
174int ipu_di_init_sync_panel(struct ipu_di *, struct ipu_di_signal_cfg *sig);
175
176/*
177 * IPU Display Multi FIFO Controller (dmfc) functions
178 */
179struct dmfc_channel;
180int ipu_dmfc_enable_channel(struct dmfc_channel *dmfc);
181void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc);
182int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc,
183 unsigned long bandwidth_mbs, int burstsize);
184void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc);
185int ipu_dmfc_init_channel(struct dmfc_channel *dmfc, int width);
186struct dmfc_channel *ipu_dmfc_get(struct ipu_soc *ipu, int ipuv3_channel);
187void ipu_dmfc_put(struct dmfc_channel *dmfc);
188
189/*
190 * IPU Display Processor (dp) functions
191 */
192#define IPU_DP_FLOW_SYNC_BG 0
193#define IPU_DP_FLOW_SYNC_FG 1
194#define IPU_DP_FLOW_ASYNC0_BG 2
195#define IPU_DP_FLOW_ASYNC0_FG 3
196#define IPU_DP_FLOW_ASYNC1_BG 4
197#define IPU_DP_FLOW_ASYNC1_FG 5
198
199struct ipu_dp *ipu_dp_get(struct ipu_soc *ipu, unsigned int flow);
200void ipu_dp_put(struct ipu_dp *);
Philipp Zabel285bbb02014-04-14 23:53:20 +0200201int ipu_dp_enable(struct ipu_soc *ipu);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200202int ipu_dp_enable_channel(struct ipu_dp *dp);
203void ipu_dp_disable_channel(struct ipu_dp *dp);
Philipp Zabel285bbb02014-04-14 23:53:20 +0200204void ipu_dp_disable(struct ipu_soc *ipu);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200205int ipu_dp_setup_channel(struct ipu_dp *dp,
206 enum ipu_color_space in, enum ipu_color_space out);
207int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos);
208int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha,
209 bool bg_chan);
210
Philipp Zabel35de9252012-05-09 16:59:01 +0200211/*
Philipp Zabel3f5a8a92012-05-22 17:08:48 +0200212 * IPU CMOS Sensor Interface (csi) functions
213 */
214int ipu_csi_enable(struct ipu_soc *ipu, int csi);
215int ipu_csi_disable(struct ipu_soc *ipu, int csi);
216
217/*
Philipp Zabel35de9252012-05-09 16:59:01 +0200218 * IPU Sensor Multiple FIFO Controller (SMFC) functions
219 */
Philipp Zabel3f5a8a92012-05-22 17:08:48 +0200220int ipu_smfc_enable(struct ipu_soc *ipu);
221int ipu_smfc_disable(struct ipu_soc *ipu);
Philipp Zabel35de9252012-05-09 16:59:01 +0200222int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id);
223int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize);
224
Philipp Zabel7cb17792013-10-10 16:18:38 +0200225enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200226enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
227
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200228struct ipu_client_platformdata {
Philipp Zabeld6ca8ca2012-05-23 17:08:19 +0200229 int csi;
Sascha Haueraecfbdb2012-09-21 10:07:49 +0200230 int di;
231 int dc;
232 int dp;
233 int dmfc;
234 int dma[2];
235};
236
237#endif /* __DRM_IPU_H__ */