Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 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> |
Steve Longerbeam | 2ffd48f | 2014-08-19 10:52:40 -0700 | [diff] [blame^] | 19 | #include <media/v4l2-mediabus.h> |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 20 | |
| 21 | struct ipu_soc; |
| 22 | |
| 23 | enum ipuv3_type { |
| 24 | IPUV3EX, |
| 25 | IPUV3M, |
| 26 | IPUV3H, |
| 27 | }; |
| 28 | |
Philipp Zabel | 7f4392a | 2014-02-25 12:43:41 +0100 | [diff] [blame] | 29 | #define IPU_PIX_FMT_GBR24 v4l2_fourcc('G', 'B', 'R', '3') |
| 30 | |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 31 | /* |
| 32 | * Bitfield of Display Interface signal polarities. |
| 33 | */ |
| 34 | struct ipu_di_signal_cfg { |
| 35 | unsigned datamask_en:1; |
| 36 | unsigned interlaced:1; |
| 37 | unsigned odd_field_first:1; |
| 38 | unsigned clksel_en:1; |
| 39 | unsigned clkidle_en:1; |
| 40 | unsigned data_pol:1; /* true = inverted */ |
| 41 | unsigned clk_pol:1; /* true = rising edge */ |
| 42 | unsigned enable_pol:1; |
| 43 | unsigned Hsync_pol:1; /* true = active high */ |
| 44 | unsigned Vsync_pol:1; |
| 45 | |
| 46 | u16 width; |
| 47 | u16 height; |
| 48 | u32 pixel_fmt; |
| 49 | u16 h_start_width; |
| 50 | u16 h_sync_width; |
| 51 | u16 h_end_width; |
| 52 | u16 v_start_width; |
| 53 | u16 v_sync_width; |
| 54 | u16 v_end_width; |
| 55 | u32 v_to_h_sync; |
| 56 | unsigned long pixelclock; |
| 57 | #define IPU_DI_CLKMODE_SYNC (1 << 0) |
| 58 | #define IPU_DI_CLKMODE_EXT (1 << 1) |
| 59 | unsigned long clkflags; |
Philipp Zabel | 2ea4260 | 2013-04-08 18:04:35 +0200 | [diff] [blame] | 60 | |
| 61 | u8 hsync_pin; |
| 62 | u8 vsync_pin; |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 63 | }; |
| 64 | |
Steve Longerbeam | 2ffd48f | 2014-08-19 10:52:40 -0700 | [diff] [blame^] | 65 | /* |
| 66 | * Enumeration of CSI destinations |
| 67 | */ |
| 68 | enum ipu_csi_dest { |
| 69 | IPU_CSI_DEST_IDMAC, /* to memory via SMFC */ |
| 70 | IPU_CSI_DEST_IC, /* to Image Converter */ |
| 71 | IPU_CSI_DEST_VDIC, /* to VDIC */ |
| 72 | }; |
| 73 | |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 74 | enum ipu_color_space { |
| 75 | IPUV3_COLORSPACE_RGB, |
| 76 | IPUV3_COLORSPACE_YUV, |
| 77 | IPUV3_COLORSPACE_UNKNOWN, |
| 78 | }; |
| 79 | |
| 80 | struct ipuv3_channel; |
| 81 | |
| 82 | enum ipu_channel_irq { |
| 83 | IPU_IRQ_EOF = 0, |
| 84 | IPU_IRQ_NFACK = 64, |
| 85 | IPU_IRQ_NFB4EOF = 128, |
| 86 | IPU_IRQ_EOS = 192, |
| 87 | }; |
| 88 | |
Philipp Zabel | 861a50c | 2014-04-14 23:53:16 +0200 | [diff] [blame] | 89 | int ipu_map_irq(struct ipu_soc *ipu, int irq); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 90 | int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel, |
| 91 | enum ipu_channel_irq irq); |
| 92 | |
| 93 | #define IPU_IRQ_DP_SF_START (448 + 2) |
| 94 | #define IPU_IRQ_DP_SF_END (448 + 3) |
| 95 | #define IPU_IRQ_BG_SF_END IPU_IRQ_DP_SF_END, |
| 96 | #define IPU_IRQ_DC_FC_0 (448 + 8) |
| 97 | #define IPU_IRQ_DC_FC_1 (448 + 9) |
| 98 | #define IPU_IRQ_DC_FC_2 (448 + 10) |
| 99 | #define IPU_IRQ_DC_FC_3 (448 + 11) |
| 100 | #define IPU_IRQ_DC_FC_4 (448 + 12) |
| 101 | #define IPU_IRQ_DC_FC_6 (448 + 13) |
| 102 | #define IPU_IRQ_VSYNC_PRE_0 (448 + 14) |
| 103 | #define IPU_IRQ_VSYNC_PRE_1 (448 + 15) |
| 104 | |
| 105 | /* |
Steve Longerbeam | ba07975 | 2014-06-25 18:05:30 -0700 | [diff] [blame] | 106 | * IPU Common functions |
| 107 | */ |
| 108 | void ipu_set_csi_src_mux(struct ipu_soc *ipu, int csi_id, bool mipi_csi2); |
| 109 | void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi); |
| 110 | |
| 111 | /* |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 112 | * IPU Image DMA Controller (idmac) functions |
| 113 | */ |
| 114 | struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned channel); |
| 115 | void ipu_idmac_put(struct ipuv3_channel *); |
| 116 | |
| 117 | int ipu_idmac_enable_channel(struct ipuv3_channel *channel); |
| 118 | int ipu_idmac_disable_channel(struct ipuv3_channel *channel); |
Sascha Hauer | fb822a3 | 2013-10-10 16:18:41 +0200 | [diff] [blame] | 119 | int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 120 | |
| 121 | void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel, |
| 122 | bool doublebuffer); |
Philipp Zabel | e904609 | 2012-05-16 17:28:29 +0200 | [diff] [blame] | 123 | int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 124 | void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num); |
| 125 | |
| 126 | /* |
Steve Longerbeam | 7d2691d | 2014-06-25 18:05:47 -0700 | [diff] [blame] | 127 | * IPU Channel Parameter Memory (cpmem) functions |
| 128 | */ |
| 129 | struct ipu_rgb { |
| 130 | struct fb_bitfield red; |
| 131 | struct fb_bitfield green; |
| 132 | struct fb_bitfield blue; |
| 133 | struct fb_bitfield transp; |
| 134 | int bits_per_pixel; |
| 135 | }; |
| 136 | |
| 137 | struct ipu_image { |
| 138 | struct v4l2_pix_format pix; |
| 139 | struct v4l2_rect rect; |
| 140 | dma_addr_t phys; |
| 141 | }; |
| 142 | |
| 143 | void ipu_cpmem_zero(struct ipuv3_channel *ch); |
| 144 | void ipu_cpmem_set_resolution(struct ipuv3_channel *ch, int xres, int yres); |
| 145 | void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride); |
| 146 | void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch); |
| 147 | void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf); |
| 148 | void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride); |
| 149 | void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize); |
| 150 | int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch, |
| 151 | const struct ipu_rgb *rgb); |
| 152 | int ipu_cpmem_set_format_passthrough(struct ipuv3_channel *ch, int width); |
| 153 | void ipu_cpmem_set_yuv_interleaved(struct ipuv3_channel *ch, u32 pixel_format); |
| 154 | void ipu_cpmem_set_yuv_planar_full(struct ipuv3_channel *ch, |
| 155 | u32 pixel_format, int stride, |
| 156 | int u_offset, int v_offset); |
| 157 | void ipu_cpmem_set_yuv_planar(struct ipuv3_channel *ch, |
| 158 | u32 pixel_format, int stride, int height); |
| 159 | int ipu_cpmem_set_fmt(struct ipuv3_channel *ch, u32 drm_fourcc); |
| 160 | int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image); |
| 161 | |
| 162 | /* |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 163 | * IPU Display Controller (dc) functions |
| 164 | */ |
| 165 | struct ipu_dc; |
| 166 | struct ipu_di; |
| 167 | struct ipu_dc *ipu_dc_get(struct ipu_soc *ipu, int channel); |
| 168 | void ipu_dc_put(struct ipu_dc *dc); |
| 169 | int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced, |
| 170 | u32 pixel_fmt, u32 width); |
Philipp Zabel | 1e6d486 | 2014-04-14 23:53:23 +0200 | [diff] [blame] | 171 | void ipu_dc_enable(struct ipu_soc *ipu); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 172 | void ipu_dc_enable_channel(struct ipu_dc *dc); |
| 173 | void ipu_dc_disable_channel(struct ipu_dc *dc); |
Philipp Zabel | 1e6d486 | 2014-04-14 23:53:23 +0200 | [diff] [blame] | 174 | void ipu_dc_disable(struct ipu_soc *ipu); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 175 | |
| 176 | /* |
| 177 | * IPU Display Interface (di) functions |
| 178 | */ |
| 179 | struct ipu_di *ipu_di_get(struct ipu_soc *ipu, int disp); |
| 180 | void ipu_di_put(struct ipu_di *); |
| 181 | int ipu_di_disable(struct ipu_di *); |
| 182 | int ipu_di_enable(struct ipu_di *); |
| 183 | int ipu_di_get_num(struct ipu_di *); |
| 184 | int ipu_di_init_sync_panel(struct ipu_di *, struct ipu_di_signal_cfg *sig); |
| 185 | |
| 186 | /* |
| 187 | * IPU Display Multi FIFO Controller (dmfc) functions |
| 188 | */ |
| 189 | struct dmfc_channel; |
| 190 | int ipu_dmfc_enable_channel(struct dmfc_channel *dmfc); |
| 191 | void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc); |
| 192 | int ipu_dmfc_alloc_bandwidth(struct dmfc_channel *dmfc, |
| 193 | unsigned long bandwidth_mbs, int burstsize); |
| 194 | void ipu_dmfc_free_bandwidth(struct dmfc_channel *dmfc); |
| 195 | int ipu_dmfc_init_channel(struct dmfc_channel *dmfc, int width); |
| 196 | struct dmfc_channel *ipu_dmfc_get(struct ipu_soc *ipu, int ipuv3_channel); |
| 197 | void ipu_dmfc_put(struct dmfc_channel *dmfc); |
| 198 | |
| 199 | /* |
| 200 | * IPU Display Processor (dp) functions |
| 201 | */ |
| 202 | #define IPU_DP_FLOW_SYNC_BG 0 |
| 203 | #define IPU_DP_FLOW_SYNC_FG 1 |
| 204 | #define IPU_DP_FLOW_ASYNC0_BG 2 |
| 205 | #define IPU_DP_FLOW_ASYNC0_FG 3 |
| 206 | #define IPU_DP_FLOW_ASYNC1_BG 4 |
| 207 | #define IPU_DP_FLOW_ASYNC1_FG 5 |
| 208 | |
| 209 | struct ipu_dp *ipu_dp_get(struct ipu_soc *ipu, unsigned int flow); |
| 210 | void ipu_dp_put(struct ipu_dp *); |
Philipp Zabel | 285bbb0 | 2014-04-14 23:53:20 +0200 | [diff] [blame] | 211 | int ipu_dp_enable(struct ipu_soc *ipu); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 212 | int ipu_dp_enable_channel(struct ipu_dp *dp); |
| 213 | void ipu_dp_disable_channel(struct ipu_dp *dp); |
Philipp Zabel | 285bbb0 | 2014-04-14 23:53:20 +0200 | [diff] [blame] | 214 | void ipu_dp_disable(struct ipu_soc *ipu); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 215 | int ipu_dp_setup_channel(struct ipu_dp *dp, |
| 216 | enum ipu_color_space in, enum ipu_color_space out); |
| 217 | int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos); |
| 218 | int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha, |
| 219 | bool bg_chan); |
| 220 | |
Philipp Zabel | 35de925 | 2012-05-09 16:59:01 +0200 | [diff] [blame] | 221 | /* |
Philipp Zabel | 3f5a8a9 | 2012-05-22 17:08:48 +0200 | [diff] [blame] | 222 | * IPU CMOS Sensor Interface (csi) functions |
| 223 | */ |
Steve Longerbeam | 2ffd48f | 2014-08-19 10:52:40 -0700 | [diff] [blame^] | 224 | struct ipu_csi; |
| 225 | int ipu_csi_init_interface(struct ipu_csi *csi, |
| 226 | struct v4l2_mbus_config *mbus_cfg, |
| 227 | struct v4l2_mbus_framefmt *mbus_fmt); |
| 228 | bool ipu_csi_is_interlaced(struct ipu_csi *csi); |
| 229 | void ipu_csi_get_window(struct ipu_csi *csi, struct v4l2_rect *w); |
| 230 | void ipu_csi_set_window(struct ipu_csi *csi, struct v4l2_rect *w); |
| 231 | void ipu_csi_set_test_generator(struct ipu_csi *csi, bool active, |
| 232 | u32 r_value, u32 g_value, u32 b_value, |
| 233 | u32 pix_clk); |
| 234 | int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc, |
| 235 | struct v4l2_mbus_framefmt *mbus_fmt); |
| 236 | int ipu_csi_set_skip_smfc(struct ipu_csi *csi, u32 skip, |
| 237 | u32 max_ratio, u32 id); |
| 238 | int ipu_csi_set_dest(struct ipu_csi *csi, enum ipu_csi_dest csi_dest); |
| 239 | int ipu_csi_enable(struct ipu_csi *csi); |
| 240 | int ipu_csi_disable(struct ipu_csi *csi); |
| 241 | struct ipu_csi *ipu_csi_get(struct ipu_soc *ipu, int id); |
| 242 | void ipu_csi_put(struct ipu_csi *csi); |
| 243 | void ipu_csi_dump(struct ipu_csi *csi); |
Philipp Zabel | 3f5a8a9 | 2012-05-22 17:08:48 +0200 | [diff] [blame] | 244 | |
| 245 | /* |
Philipp Zabel | 35de925 | 2012-05-09 16:59:01 +0200 | [diff] [blame] | 246 | * IPU Sensor Multiple FIFO Controller (SMFC) functions |
| 247 | */ |
Philipp Zabel | 3f5a8a9 | 2012-05-22 17:08:48 +0200 | [diff] [blame] | 248 | int ipu_smfc_enable(struct ipu_soc *ipu); |
| 249 | int ipu_smfc_disable(struct ipu_soc *ipu); |
Philipp Zabel | 35de925 | 2012-05-09 16:59:01 +0200 | [diff] [blame] | 250 | int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id); |
| 251 | int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize); |
| 252 | |
Philipp Zabel | 7cb1779 | 2013-10-10 16:18:38 +0200 | [diff] [blame] | 253 | enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc); |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 254 | enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat); |
| 255 | |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 256 | struct ipu_client_platformdata { |
Philipp Zabel | d6ca8ca | 2012-05-23 17:08:19 +0200 | [diff] [blame] | 257 | int csi; |
Sascha Hauer | aecfbdb | 2012-09-21 10:07:49 +0200 | [diff] [blame] | 258 | int di; |
| 259 | int dc; |
| 260 | int dp; |
| 261 | int dmfc; |
| 262 | int dma[2]; |
| 263 | }; |
| 264 | |
| 265 | #endif /* __DRM_IPU_H__ */ |