aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s5p-g2d/g2d-hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/s5p-g2d/g2d-hw.c')
-rw-r--r--drivers/media/video/s5p-g2d/g2d-hw.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/drivers/media/video/s5p-g2d/g2d-hw.c b/drivers/media/video/s5p-g2d/g2d-hw.c
new file mode 100644
index 00000000000..39937cf03c8
--- /dev/null
+++ b/drivers/media/video/s5p-g2d/g2d-hw.c
@@ -0,0 +1,104 @@
1/*
2 * Samsung S5P G2D - 2D Graphics Accelerator Driver
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * Kamil Debski, <k.debski@samsung.com>
6 *
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
11 */
12
13#include <linux/io.h>
14
15#include "g2d.h"
16#include "g2d-regs.h"
17
18#define w(x, a) writel((x), d->regs + (a))
19#define r(a) readl(d->regs + (a))
20
21/* g2d_reset clears all g2d registers */
22void g2d_reset(struct g2d_dev *d)
23{
24 w(1, SOFT_RESET_REG);
25}
26
27void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f)
28{
29 u32 n;
30
31 w(f->stride & 0xFFFF, SRC_STRIDE_REG);
32
33 n = f->o_height & 0xFFF;
34 n <<= 16;
35 n |= f->o_width & 0xFFF;
36 w(n, SRC_LEFT_TOP_REG);
37
38 n = f->bottom & 0xFFF;
39 n <<= 16;
40 n |= f->right & 0xFFF;
41 w(n, SRC_RIGHT_BOTTOM_REG);
42
43 w(f->fmt->hw, SRC_COLOR_MODE_REG);
44}
45
46void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a)
47{
48 w(a, SRC_BASE_ADDR_REG);
49}
50
51void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f)
52{
53 u32 n;
54
55 w(f->stride & 0xFFFF, DST_STRIDE_REG);
56
57 n = f->o_height & 0xFFF;
58 n <<= 16;
59 n |= f->o_width & 0xFFF;
60 w(n, DST_LEFT_TOP_REG);
61
62 n = f->bottom & 0xFFF;
63 n <<= 16;
64 n |= f->right & 0xFFF;
65 w(n, DST_RIGHT_BOTTOM_REG);
66
67 w(f->fmt->hw, DST_COLOR_MODE_REG);
68}
69
70void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a)
71{
72 w(a, DST_BASE_ADDR_REG);
73}
74
75void g2d_set_rop4(struct g2d_dev *d, u32 r)
76{
77 w(r, ROP4_REG);
78}
79
80u32 g2d_cmd_stretch(u32 e)
81{
82 e &= 1;
83 return e << 4;
84}
85
86void g2d_set_cmd(struct g2d_dev *d, u32 c)
87{
88 w(c, BITBLT_COMMAND_REG);
89}
90
91void g2d_start(struct g2d_dev *d)
92{
93 /* Clear cache */
94 w(0x7, CACHECTL_REG);
95 /* Enable interrupt */
96 w(1, INTEN_REG);
97 /* Start G2D engine */
98 w(1, BITBLT_START_REG);
99}
100
101void g2d_clear_int(struct g2d_dev *d)
102{
103 w(1, INTC_PEND_REG);
104}