diff options
| author | Steve Longerbeam <slongerbeam@gmail.com> | 2014-06-25 21:05:47 -0400 |
|---|---|---|
| committer | Philipp Zabel <p.zabel@pengutronix.de> | 2014-08-18 08:17:41 -0400 |
| commit | 7d2691da901d71ff62ad974510ea7149b391bdfe (patch) | |
| tree | c86091bbb9219ebe50196a2bab3250b0bc869fa2 /include | |
| parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) | |
gpu: ipu-v3: Add ipu-cpmem unit
Move channel parameter memory setup functions and macros into a new
submodule ipu-cpmem. In the process, cleanup arguments to the functions
to take a channel pointer instead of a pointer into cpmem for that
channel. That allows the structure of the parameter memory to be
private to ipu-cpmem.c.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'include')
| -rw-r--r-- | include/video/imx-ipu-v3.h | 188 |
1 files changed, 36 insertions, 152 deletions
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index 3e43e22cdff9..ef64b66b18df 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h | |||
| @@ -108,6 +108,42 @@ int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel); | |||
| 108 | void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num); | 108 | void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num); |
| 109 | 109 | ||
| 110 | /* | 110 | /* |
| 111 | * IPU Channel Parameter Memory (cpmem) functions | ||
| 112 | */ | ||
| 113 | struct ipu_rgb { | ||
| 114 | struct fb_bitfield red; | ||
| 115 | struct fb_bitfield green; | ||
| 116 | struct fb_bitfield blue; | ||
| 117 | struct fb_bitfield transp; | ||
| 118 | int bits_per_pixel; | ||
| 119 | }; | ||
| 120 | |||
| 121 | struct ipu_image { | ||
| 122 | struct v4l2_pix_format pix; | ||
| 123 | struct v4l2_rect rect; | ||
| 124 | dma_addr_t phys; | ||
| 125 | }; | ||
| 126 | |||
| 127 | void ipu_cpmem_zero(struct ipuv3_channel *ch); | ||
| 128 | void ipu_cpmem_set_resolution(struct ipuv3_channel *ch, int xres, int yres); | ||
| 129 | void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride); | ||
| 130 | void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch); | ||
| 131 | void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf); | ||
| 132 | void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride); | ||
| 133 | void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize); | ||
| 134 | int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch, | ||
| 135 | const struct ipu_rgb *rgb); | ||
| 136 | int ipu_cpmem_set_format_passthrough(struct ipuv3_channel *ch, int width); | ||
| 137 | void ipu_cpmem_set_yuv_interleaved(struct ipuv3_channel *ch, u32 pixel_format); | ||
| 138 | void ipu_cpmem_set_yuv_planar_full(struct ipuv3_channel *ch, | ||
| 139 | u32 pixel_format, int stride, | ||
| 140 | int u_offset, int v_offset); | ||
| 141 | void ipu_cpmem_set_yuv_planar(struct ipuv3_channel *ch, | ||
| 142 | u32 pixel_format, int stride, int height); | ||
| 143 | int ipu_cpmem_set_fmt(struct ipuv3_channel *ch, u32 drm_fourcc); | ||
| 144 | int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image); | ||
| 145 | |||
| 146 | /* | ||
| 111 | * IPU Display Controller (dc) functions | 147 | * IPU Display Controller (dc) functions |
| 112 | */ | 148 | */ |
| 113 | struct ipu_dc; | 149 | struct ipu_dc; |
| @@ -180,161 +216,9 @@ int ipu_smfc_disable(struct ipu_soc *ipu); | |||
| 180 | int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id); | 216 | int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id); |
| 181 | int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize); | 217 | int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize); |
| 182 | 218 | ||
| 183 | #define IPU_CPMEM_WORD(word, ofs, size) ((((word) * 160 + (ofs)) << 8) | (size)) | ||
| 184 | |||
| 185 | #define IPU_FIELD_UBO IPU_CPMEM_WORD(0, 46, 22) | ||
| 186 | #define IPU_FIELD_VBO IPU_CPMEM_WORD(0, 68, 22) | ||
| 187 | #define IPU_FIELD_IOX IPU_CPMEM_WORD(0, 90, 4) | ||
| 188 | #define IPU_FIELD_RDRW IPU_CPMEM_WORD(0, 94, 1) | ||
| 189 | #define IPU_FIELD_SO IPU_CPMEM_WORD(0, 113, 1) | ||
| 190 | #define IPU_FIELD_SLY IPU_CPMEM_WORD(1, 102, 14) | ||
| 191 | #define IPU_FIELD_SLUV IPU_CPMEM_WORD(1, 128, 14) | ||
| 192 | |||
| 193 | #define IPU_FIELD_XV IPU_CPMEM_WORD(0, 0, 10) | ||
| 194 | #define IPU_FIELD_YV IPU_CPMEM_WORD(0, 10, 9) | ||
| 195 | #define IPU_FIELD_XB IPU_CPMEM_WORD(0, 19, 13) | ||
| 196 | #define IPU_FIELD_YB IPU_CPMEM_WORD(0, 32, 12) | ||
| 197 | #define IPU_FIELD_NSB_B IPU_CPMEM_WORD(0, 44, 1) | ||
| 198 | #define IPU_FIELD_CF IPU_CPMEM_WORD(0, 45, 1) | ||
| 199 | #define IPU_FIELD_SX IPU_CPMEM_WORD(0, 46, 12) | ||
| 200 | #define IPU_FIELD_SY IPU_CPMEM_WORD(0, 58, 11) | ||
| 201 | #define IPU_FIELD_NS IPU_CPMEM_WORD(0, 69, 10) | ||
| 202 | #define IPU_FIELD_SDX IPU_CPMEM_WORD(0, 79, 7) | ||
| 203 | #define IPU_FIELD_SM IPU_CPMEM_WORD(0, 86, 10) | ||
| 204 | #define IPU_FIELD_SCC IPU_CPMEM_WORD(0, 96, 1) | ||
| 205 | #define IPU_FIELD_SCE IPU_CPMEM_WORD(0, 97, 1) | ||
| 206 | #define IPU_FIELD_SDY IPU_CPMEM_WORD(0, 98, 7) | ||
| 207 | #define IPU_FIELD_SDRX IPU_CPMEM_WORD(0, 105, 1) | ||
| 208 | #define IPU_FIELD_SDRY IPU_CPMEM_WORD(0, 106, 1) | ||
| 209 | #define IPU_FIELD_BPP IPU_CPMEM_WORD(0, 107, 3) | ||
| 210 | #define IPU_FIELD_DEC_SEL IPU_CPMEM_WORD(0, 110, 2) | ||
| 211 | #define IPU_FIELD_DIM IPU_CPMEM_WORD(0, 112, 1) | ||
| 212 | #define IPU_FIELD_BNDM IPU_CPMEM_WORD(0, 114, 3) | ||
| 213 | #define IPU_FIELD_BM IPU_CPMEM_WORD(0, 117, 2) | ||
| 214 | #define IPU_FIELD_ROT IPU_CPMEM_WORD(0, 119, 1) | ||
| 215 | #define IPU_FIELD_HF IPU_CPMEM_WORD(0, 120, 1) | ||
| 216 | #define IPU_FIELD_VF IPU_CPMEM_WORD(0, 121, 1) | ||
| 217 | #define IPU_FIELD_THE IPU_CPMEM_WORD(0, 122, 1) | ||
| 218 | #define IPU_FIELD_CAP IPU_CPMEM_WORD(0, 123, 1) | ||
| 219 | #define IPU_FIELD_CAE IPU_CPMEM_WORD(0, 124, 1) | ||
| 220 | #define IPU_FIELD_FW IPU_CPMEM_WORD(0, 125, 13) | ||
| 221 | #define IPU_FIELD_FH IPU_CPMEM_WORD(0, 138, 12) | ||
| 222 | #define IPU_FIELD_EBA0 IPU_CPMEM_WORD(1, 0, 29) | ||
| 223 | #define IPU_FIELD_EBA1 IPU_CPMEM_WORD(1, 29, 29) | ||
| 224 | #define IPU_FIELD_ILO IPU_CPMEM_WORD(1, 58, 20) | ||
| 225 | #define IPU_FIELD_NPB IPU_CPMEM_WORD(1, 78, 7) | ||
| 226 | #define IPU_FIELD_PFS IPU_CPMEM_WORD(1, 85, 4) | ||
| 227 | #define IPU_FIELD_ALU IPU_CPMEM_WORD(1, 89, 1) | ||
| 228 | #define IPU_FIELD_ALBM IPU_CPMEM_WORD(1, 90, 3) | ||
| 229 | #define IPU_FIELD_ID IPU_CPMEM_WORD(1, 93, 2) | ||
| 230 | #define IPU_FIELD_TH IPU_CPMEM_WORD(1, 95, 7) | ||
| 231 | #define IPU_FIELD_SL IPU_CPMEM_WORD(1, 102, 14) | ||
| 232 | #define IPU_FIELD_WID0 IPU_CPMEM_WORD(1, 116, 3) | ||
| 233 | #define IPU_FIELD_WID1 IPU_CPMEM_WORD(1, 119, 3) | ||
| 234 | #define IPU_FIELD_WID2 IPU_CPMEM_WORD(1, 122, 3) | ||
| 235 | #define IPU_FIELD_WID3 IPU_CPMEM_WORD(1, 125, 3) | ||
| 236 | #define IPU_FIELD_OFS0 IPU_CPMEM_WORD(1, 128, 5) | ||
| 237 | #define IPU_FIELD_OFS1 IPU_CPMEM_WORD(1, 133, 5) | ||
| 238 | #define IPU_FIELD_OFS2 IPU_CPMEM_WORD(1, 138, 5) | ||
| 239 | #define IPU_FIELD_OFS3 IPU_CPMEM_WORD(1, 143, 5) | ||
| 240 | #define IPU_FIELD_SXYS IPU_CPMEM_WORD(1, 148, 1) | ||
| 241 | #define IPU_FIELD_CRE IPU_CPMEM_WORD(1, 149, 1) | ||
| 242 | #define IPU_FIELD_DEC_SEL2 IPU_CPMEM_WORD(1, 150, 1) | ||
| 243 | |||
| 244 | struct ipu_cpmem_word { | ||
| 245 | u32 data[5]; | ||
| 246 | u32 res[3]; | ||
| 247 | }; | ||
| 248 | |||
| 249 | struct ipu_ch_param { | ||
| 250 | struct ipu_cpmem_word word[2]; | ||
| 251 | }; | ||
| 252 | |||
| 253 | void ipu_ch_param_write_field(struct ipu_ch_param __iomem *base, u32 wbs, u32 v); | ||
| 254 | u32 ipu_ch_param_read_field(struct ipu_ch_param __iomem *base, u32 wbs); | ||
| 255 | struct ipu_ch_param __iomem *ipu_get_cpmem(struct ipuv3_channel *channel); | ||
| 256 | void ipu_ch_param_dump(struct ipu_ch_param __iomem *p); | ||
| 257 | |||
| 258 | static inline void ipu_ch_param_zero(struct ipu_ch_param __iomem *p) | ||
| 259 | { | ||
| 260 | int i; | ||
| 261 | void __iomem *base = p; | ||
| 262 | |||
| 263 | for (i = 0; i < sizeof(*p) / sizeof(u32); i++) | ||
| 264 | writel(0, base + i * sizeof(u32)); | ||
| 265 | } | ||
| 266 | |||
| 267 | static inline void ipu_cpmem_set_buffer(struct ipu_ch_param __iomem *p, | ||
| 268 | int bufnum, dma_addr_t buf) | ||
| 269 | { | ||
| 270 | if (bufnum) | ||
| 271 | ipu_ch_param_write_field(p, IPU_FIELD_EBA1, buf >> 3); | ||
| 272 | else | ||
| 273 | ipu_ch_param_write_field(p, IPU_FIELD_EBA0, buf >> 3); | ||
| 274 | } | ||
| 275 | |||
| 276 | static inline void ipu_cpmem_set_resolution(struct ipu_ch_param __iomem *p, | ||
| 277 | int xres, int yres) | ||
| 278 | { | ||
| 279 | ipu_ch_param_write_field(p, IPU_FIELD_FW, xres - 1); | ||
| 280 | ipu_ch_param_write_field(p, IPU_FIELD_FH, yres - 1); | ||
| 281 | } | ||
| 282 | |||
| 283 | static inline void ipu_cpmem_set_stride(struct ipu_ch_param __iomem *p, | ||
| 284 | int stride) | ||
| 285 | { | ||
| 286 | ipu_ch_param_write_field(p, IPU_FIELD_SLY, stride - 1); | ||
| 287 | } | ||
| 288 | |||
| 289 | void ipu_cpmem_set_high_priority(struct ipuv3_channel *channel); | ||
| 290 | |||
| 291 | struct ipu_rgb { | ||
| 292 | struct fb_bitfield red; | ||
| 293 | struct fb_bitfield green; | ||
| 294 | struct fb_bitfield blue; | ||
| 295 | struct fb_bitfield transp; | ||
| 296 | int bits_per_pixel; | ||
| 297 | }; | ||
| 298 | |||
| 299 | struct ipu_image { | ||
| 300 | struct v4l2_pix_format pix; | ||
| 301 | struct v4l2_rect rect; | ||
| 302 | dma_addr_t phys; | ||
| 303 | }; | ||
| 304 | |||
| 305 | int ipu_cpmem_set_format_passthrough(struct ipu_ch_param __iomem *p, | ||
| 306 | int width); | ||
| 307 | |||
| 308 | int ipu_cpmem_set_format_rgb(struct ipu_ch_param __iomem *, | ||
| 309 | const struct ipu_rgb *rgb); | ||
| 310 | |||
| 311 | static inline void ipu_cpmem_interlaced_scan(struct ipu_ch_param *p, | ||
| 312 | int stride) | ||
| 313 | { | ||
| 314 | ipu_ch_param_write_field(p, IPU_FIELD_SO, 1); | ||
| 315 | ipu_ch_param_write_field(p, IPU_FIELD_ILO, stride / 8); | ||
| 316 | ipu_ch_param_write_field(p, IPU_FIELD_SLY, (stride * 2) - 1); | ||
| 317 | }; | ||
| 318 | |||
| 319 | void ipu_cpmem_set_yuv_planar(struct ipu_ch_param __iomem *p, u32 pixel_format, | ||
| 320 | int stride, int height); | ||
| 321 | void ipu_cpmem_set_yuv_interleaved(struct ipu_ch_param __iomem *p, | ||
| 322 | u32 pixel_format); | ||
| 323 | void ipu_cpmem_set_yuv_planar_full(struct ipu_ch_param __iomem *p, | ||
| 324 | u32 pixel_format, int stride, int u_offset, int v_offset); | ||
| 325 | int ipu_cpmem_set_fmt(struct ipu_ch_param __iomem *cpmem, u32 pixelformat); | ||
| 326 | int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem, | ||
| 327 | struct ipu_image *image); | ||
| 328 | |||
| 329 | enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc); | 219 | enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc); |
| 330 | enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat); | 220 | enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat); |
| 331 | 221 | ||
| 332 | static inline void ipu_cpmem_set_burstsize(struct ipu_ch_param __iomem *p, | ||
| 333 | int burstsize) | ||
| 334 | { | ||
| 335 | ipu_ch_param_write_field(p, IPU_FIELD_NPB, burstsize - 1); | ||
| 336 | }; | ||
| 337 | |||
| 338 | struct ipu_client_platformdata { | 222 | struct ipu_client_platformdata { |
| 339 | int csi; | 223 | int csi; |
| 340 | int di; | 224 | int di; |
