1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Samsung S5P G2D - 2D Graphics Accelerator Driver
5 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
6 * Kamil Debski, <k.debski@samsung.com>
14 #define w(x, a) writel((x), d->regs + (a))
15 #define r(a) readl(d->regs + (a))
17 /* g2d_reset clears all g2d registers */
18 void g2d_reset(struct g2d_dev
*d
)
23 void g2d_set_src_size(struct g2d_dev
*d
, struct g2d_frame
*f
)
28 w(f
->stride
& 0xFFFF, SRC_STRIDE_REG
);
30 n
= f
->o_height
& 0xFFF;
32 n
|= f
->o_width
& 0xFFF;
33 w(n
, SRC_LEFT_TOP_REG
);
35 n
= f
->bottom
& 0xFFF;
37 n
|= f
->right
& 0xFFF;
38 w(n
, SRC_RIGHT_BOTTOM_REG
);
40 w(f
->fmt
->hw
, SRC_COLOR_MODE_REG
);
43 void g2d_set_src_addr(struct g2d_dev
*d
, dma_addr_t a
)
45 w(a
, SRC_BASE_ADDR_REG
);
48 void g2d_set_dst_size(struct g2d_dev
*d
, struct g2d_frame
*f
)
53 w(f
->stride
& 0xFFFF, DST_STRIDE_REG
);
55 n
= f
->o_height
& 0xFFF;
57 n
|= f
->o_width
& 0xFFF;
58 w(n
, DST_LEFT_TOP_REG
);
60 n
= f
->bottom
& 0xFFF;
62 n
|= f
->right
& 0xFFF;
63 w(n
, DST_RIGHT_BOTTOM_REG
);
65 w(f
->fmt
->hw
, DST_COLOR_MODE_REG
);
68 void g2d_set_dst_addr(struct g2d_dev
*d
, dma_addr_t a
)
70 w(a
, DST_BASE_ADDR_REG
);
73 void g2d_set_rop4(struct g2d_dev
*d
, u32 r
)
78 void g2d_set_flip(struct g2d_dev
*d
, u32 r
)
80 w(r
, SRC_MSK_DIRECT_REG
);
83 void g2d_set_v41_stretch(struct g2d_dev
*d
, struct g2d_frame
*src
,
84 struct g2d_frame
*dst
)
86 w(DEFAULT_SCALE_MODE
, SRC_SCALE_CTRL_REG
);
88 /* inversed scaling factor: src is numerator */
89 w((src
->c_width
<< 16) / dst
->c_width
, SRC_XSCALE_REG
);
90 w((src
->c_height
<< 16) / dst
->c_height
, SRC_YSCALE_REG
);
93 void g2d_set_cmd(struct g2d_dev
*d
, u32 c
)
95 w(c
, BITBLT_COMMAND_REG
);
98 void g2d_start(struct g2d_dev
*d
)
101 if (d
->variant
->hw_rev
== TYPE_G2D_3X
)
102 w(0x7, CACHECTL_REG
);
104 /* Enable interrupt */
106 /* Start G2D engine */
107 w(1, BITBLT_START_REG
);
110 void g2d_clear_int(struct g2d_dev
*d
)