2 * Samsung S5P G2D - 2D Graphics Accelerator Driver
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * Kamil Debski, <k.debski@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version
18 #define w(x, a) writel((x), d->regs + (a))
19 #define r(a) readl(d->regs + (a))
21 /* g2d_reset clears all g2d registers */
22 void g2d_reset(struct g2d_dev
*d
)
27 void g2d_set_src_size(struct g2d_dev
*d
, struct g2d_frame
*f
)
32 w(f
->stride
& 0xFFFF, SRC_STRIDE_REG
);
34 n
= f
->o_height
& 0xFFF;
36 n
|= f
->o_width
& 0xFFF;
37 w(n
, SRC_LEFT_TOP_REG
);
39 n
= f
->bottom
& 0xFFF;
41 n
|= f
->right
& 0xFFF;
42 w(n
, SRC_RIGHT_BOTTOM_REG
);
44 w(f
->fmt
->hw
, SRC_COLOR_MODE_REG
);
47 void g2d_set_src_addr(struct g2d_dev
*d
, dma_addr_t a
)
49 w(a
, SRC_BASE_ADDR_REG
);
52 void g2d_set_dst_size(struct g2d_dev
*d
, struct g2d_frame
*f
)
57 w(f
->stride
& 0xFFFF, DST_STRIDE_REG
);
59 n
= f
->o_height
& 0xFFF;
61 n
|= f
->o_width
& 0xFFF;
62 w(n
, DST_LEFT_TOP_REG
);
64 n
= f
->bottom
& 0xFFF;
66 n
|= f
->right
& 0xFFF;
67 w(n
, DST_RIGHT_BOTTOM_REG
);
69 w(f
->fmt
->hw
, DST_COLOR_MODE_REG
);
72 void g2d_set_dst_addr(struct g2d_dev
*d
, dma_addr_t a
)
74 w(a
, DST_BASE_ADDR_REG
);
77 void g2d_set_rop4(struct g2d_dev
*d
, u32 r
)
82 void g2d_set_flip(struct g2d_dev
*d
, u32 r
)
84 w(r
, SRC_MSK_DIRECT_REG
);
87 void g2d_set_v41_stretch(struct g2d_dev
*d
, struct g2d_frame
*src
,
88 struct g2d_frame
*dst
)
90 w(DEFAULT_SCALE_MODE
, SRC_SCALE_CTRL_REG
);
92 /* inversed scaling factor: src is numerator */
93 w((src
->c_width
<< 16) / dst
->c_width
, SRC_XSCALE_REG
);
94 w((src
->c_height
<< 16) / dst
->c_height
, SRC_YSCALE_REG
);
97 void g2d_set_cmd(struct g2d_dev
*d
, u32 c
)
99 w(c
, BITBLT_COMMAND_REG
);
102 void g2d_start(struct g2d_dev
*d
)
105 if (d
->variant
->hw_rev
== TYPE_G2D_3X
)
106 w(0x7, CACHECTL_REG
);
108 /* Enable interrupt */
110 /* Start G2D engine */
111 w(1, BITBLT_START_REG
);
114 void g2d_clear_int(struct g2d_dev
*d
)