Lines Matching +full:no +full:- +full:1 +full:- +full:8 +full:- +full:v

1 // SPDX-License-Identifier: GPL-2.0-only
14 #include <video/imx-ipu-v3.h>
16 #include "ipu-prv.h"
19 #define IPU_PRE_NUM_SCANLINES 8
23 #define IPU_PRE_CTRL_ENABLE (1 << 0)
24 #define IPU_PRE_CTRL_BLOCK_EN (1 << 1)
25 #define IPU_PRE_CTRL_BLOCK_16 (1 << 2)
26 #define IPU_PRE_CTRL_SDW_UPDATE (1 << 4)
27 #define IPU_PRE_CTRL_VFLIP (1 << 5)
28 #define IPU_PRE_CTRL_SO (1 << 6)
29 #define IPU_PRE_CTRL_INTERLACED_FIELD (1 << 7)
30 #define IPU_PRE_CTRL_HANDSHAKE_EN (1 << 8)
31 #define IPU_PRE_CTRL_HANDSHAKE_LINE_NUM(v) ((v & 0x3) << 9) argument
32 #define IPU_PRE_CTRL_HANDSHAKE_ABORT_SKIP_EN (1 << 11)
33 #define IPU_PRE_CTRL_EN_REPEAT (1 << 28)
34 #define IPU_PRE_CTRL_TPR_REST_SEL (1 << 29)
35 #define IPU_PRE_CTRL_CLKGATE (1 << 30)
36 #define IPU_PRE_CTRL_SFTRST (1 << 31)
43 #define IPU_PRE_TPR_CTRL_TILE_FORMAT(v) ((v & 0xff) << 0) argument
45 #define IPU_PRE_TPR_CTRL_TILE_FORMAT_16_BIT (1 << 0)
46 #define IPU_PRE_TPR_CTRL_TILE_FORMAT_SPLIT_BUF (1 << 4)
47 #define IPU_PRE_TPR_CTRL_TILE_FORMAT_SINGLE_BUF (1 << 5)
48 #define IPU_PRE_TPR_CTRL_TILE_FORMAT_SUPER_TILED (1 << 6)
51 #define IPU_PRE_PREF_ENG_CTRL_PREFETCH_EN (1 << 0)
52 #define IPU_PRE_PREF_ENG_CTRL_RD_NUM_BYTES(v) ((v & 0x7) << 1) argument
53 #define IPU_PRE_PREF_ENG_CTRL_INPUT_ACTIVE_BPP(v) ((v & 0x3) << 4) argument
54 #define IPU_PRE_PREF_ENG_CTRL_INPUT_PIXEL_FORMAT(v) ((v & 0x7) << 8) argument
55 #define IPU_PRE_PREF_ENG_CTRL_SHIFT_BYPASS (1 << 11)
56 #define IPU_PRE_PREF_ENG_CTRL_FIELD_INVERSE (1 << 12)
57 #define IPU_PRE_PREF_ENG_CTRL_PARTIAL_UV_SWAP (1 << 14)
58 #define IPU_PRE_PREF_ENG_CTRL_TPR_COOR_OFFSET_EN (1 << 15)
61 #define IPU_PRE_PREFETCH_ENG_INPUT_SIZE_WIDTH(v) ((v & 0xffff) << 0) argument
62 #define IPU_PRE_PREFETCH_ENG_INPUT_SIZE_HEIGHT(v) ((v & 0xffff) << 16) argument
65 #define IPU_PRE_PREFETCH_ENG_PITCH_Y(v) ((v & 0xffff) << 0) argument
66 #define IPU_PRE_PREFETCH_ENG_PITCH_UV(v) ((v & 0xffff) << 16) argument
69 #define IPU_PRE_STORE_ENG_CTRL_STORE_EN (1 << 0)
70 #define IPU_PRE_STORE_ENG_CTRL_WR_NUM_BYTES(v) ((v & 0x7) << 1) argument
71 #define IPU_PRE_STORE_ENG_CTRL_OUTPUT_ACTIVE_BPP(v) ((v & 0x3) << 4) argument
78 #define IPU_PRE_STORE_ENG_STATUS_STORE_FIFO_FULL (1 << 30)
79 #define IPU_PRE_STORE_ENG_STATUS_STORE_FIELD (1 << 31)
82 #define IPU_PRE_STORE_ENG_SIZE_INPUT_WIDTH(v) ((v & 0xffff) << 0) argument
83 #define IPU_PRE_STORE_ENG_SIZE_INPUT_HEIGHT(v) ((v & 0xffff) << 16) argument
86 #define IPU_PRE_STORE_ENG_PITCH_OUT_PITCH(v) ((v & 0xffff) << 0) argument
125 of_parse_phandle(dev->of_node, name, index); in ipu_pre_lookup_by_phandle()
130 if (pre_node == pre->dev->of_node) { in ipu_pre_lookup_by_phandle()
132 device_link_add(dev, pre->dev, in ipu_pre_lookup_by_phandle()
146 if (pre->cur.in_use) in ipu_pre_get()
147 return -EBUSY; in ipu_pre_get()
150 writel(0, pre->regs + IPU_PRE_CTRL); in ipu_pre_get()
157 writel(val, pre->regs + IPU_PRE_CTRL); in ipu_pre_get()
159 pre->cur.in_use = true; in ipu_pre_get()
165 writel(IPU_PRE_CTRL_SFTRST, pre->regs + IPU_PRE_CTRL); in ipu_pre_put()
167 pre->cur.in_use = false; in ipu_pre_put()
173 if (pre->cur.modifier == DRM_FORMAT_MOD_LINEAR) in ipu_pre_update_safe_window()
174 pre->cur.safe_window_end = pre->cur.height - 2; in ipu_pre_update_safe_window()
176 pre->cur.safe_window_end = DIV_ROUND_UP(pre->cur.height, 4) - 1; in ipu_pre_update_safe_window()
184 val = readl(pre->regs + IPU_PRE_TPR_CTRL); in ipu_pre_configure_modifier()
191 if (pre->cur.cpp == 2) in ipu_pre_configure_modifier()
194 writel(val, pre->regs + IPU_PRE_TPR_CTRL); in ipu_pre_configure_modifier()
197 pre->cur.ctrl &= ~IPU_PRE_CTRL_BLOCK_EN; in ipu_pre_configure_modifier()
199 pre->cur.ctrl |= IPU_PRE_CTRL_BLOCK_EN; in ipu_pre_configure_modifier()
201 pre->cur.modifier = modifier; in ipu_pre_configure_modifier()
209 u32 active_bpp = info->cpp[0] >> 1; in ipu_pre_configure()
212 pre->cur.bufaddr = bufaddr; in ipu_pre_configure()
213 pre->cur.height = height; in ipu_pre_configure()
214 pre->cur.cpp = info->cpp[0]; in ipu_pre_configure()
215 pre->cur.ctrl = readl(pre->regs + IPU_PRE_CTRL); in ipu_pre_configure()
220 writel(bufaddr, pre->regs + IPU_PRE_CUR_BUF); in ipu_pre_configure()
221 writel(bufaddr, pre->regs + IPU_PRE_NEXT_BUF); in ipu_pre_configure()
228 writel(val, pre->regs + IPU_PRE_PREFETCH_ENG_CTRL); in ipu_pre_configure()
232 writel(val, pre->regs + IPU_PRE_PREFETCH_ENG_INPUT_SIZE); in ipu_pre_configure()
235 writel(val, pre->regs + IPU_PRE_PREFETCH_ENG_PITCH); in ipu_pre_configure()
240 writel(val, pre->regs + IPU_PRE_STORE_ENG_CTRL); in ipu_pre_configure()
244 writel(val, pre->regs + IPU_PRE_STORE_ENG_SIZE); in ipu_pre_configure()
247 writel(val, pre->regs + IPU_PRE_STORE_ENG_PITCH); in ipu_pre_configure()
249 writel(pre->buffer_paddr, pre->regs + IPU_PRE_STORE_ENG_ADDR); in ipu_pre_configure()
253 pre->cur.ctrl |= IPU_PRE_CTRL_EN_REPEAT | IPU_PRE_CTRL_ENABLE; in ipu_pre_configure()
254 writel(pre->cur.ctrl | IPU_PRE_CTRL_SDW_UPDATE, in ipu_pre_configure()
255 pre->regs + IPU_PRE_CTRL); in ipu_pre_configure()
260 if (bufaddr == pre->cur.bufaddr && in ipu_pre_update()
261 modifier == pre->cur.modifier) in ipu_pre_update()
264 writel(bufaddr, pre->regs + IPU_PRE_NEXT_BUF); in ipu_pre_update()
265 pre->cur.bufaddr = bufaddr; in ipu_pre_update()
267 if (modifier != pre->cur.modifier) in ipu_pre_update()
275 dev_warn(pre->dev, "timeout waiting for PRE safe window\n"); in ipu_pre_update()
279 val = readl(pre->regs + IPU_PRE_STORE_ENG_STATUS); in ipu_pre_update()
285 current_yblock < pre->cur.safe_window_end) in ipu_pre_update()
292 writel(pre->cur.ctrl | IPU_PRE_CTRL_SDW_UPDATE, in ipu_pre_update()
293 pre->regs + IPU_PRE_CTRL); in ipu_pre_update()
301 return !!(readl_relaxed(pre->regs + IPU_PRE_CTRL) & in ipu_pre_update_pending()
307 return (u32)pre->buffer_paddr; in ipu_pre_get_baddr()
312 struct device *dev = &pdev->dev; in ipu_pre_probe()
317 return -ENOMEM; in ipu_pre_probe()
319 pre->regs = devm_platform_ioremap_resource(pdev, 0); in ipu_pre_probe()
320 if (IS_ERR(pre->regs)) in ipu_pre_probe()
321 return PTR_ERR(pre->regs); in ipu_pre_probe()
323 pre->clk_axi = devm_clk_get(dev, "axi"); in ipu_pre_probe()
324 if (IS_ERR(pre->clk_axi)) in ipu_pre_probe()
325 return PTR_ERR(pre->clk_axi); in ipu_pre_probe()
327 pre->iram = of_gen_pool_get(dev->of_node, "fsl,iram", 0); in ipu_pre_probe()
328 if (!pre->iram) in ipu_pre_probe()
329 return -EPROBE_DEFER; in ipu_pre_probe()
333 * but as there is no other user of this IRAM region and we can fit all in ipu_pre_probe()
334 * max sized buffers into it, there is no need yet. in ipu_pre_probe()
336 pre->buffer_virt = gen_pool_dma_alloc(pre->iram, IPU_PRE_MAX_WIDTH * in ipu_pre_probe()
338 &pre->buffer_paddr); in ipu_pre_probe()
339 if (!pre->buffer_virt) in ipu_pre_probe()
340 return -ENOMEM; in ipu_pre_probe()
342 clk_prepare_enable(pre->clk_axi); in ipu_pre_probe()
344 pre->dev = dev; in ipu_pre_probe()
347 list_add(&pre->list, &ipu_pre_list); in ipu_pre_probe()
359 list_del(&pre->list); in ipu_pre_remove()
360 available_pres--; in ipu_pre_remove()
363 clk_disable_unprepare(pre->clk_axi); in ipu_pre_remove()
365 if (pre->buffer_virt) in ipu_pre_remove()
366 gen_pool_free(pre->iram, (unsigned long)pre->buffer_virt, in ipu_pre_remove()
371 { .compatible = "fsl,imx6qp-pre", },
379 .name = "imx-ipu-pre",