aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/sun4i/sun4i_frontend.h
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2018-01-22 04:25:22 -0500
committerMaxime Ripard <maxime.ripard@free-electrons.com>2018-01-22 09:15:38 -0500
commitdd0421f47505bbbe30a4ce37b51a5c127b8754dc (patch)
treec098cb1c3d5d6458548832c42c8c5150d958b414 /drivers/gpu/drm/sun4i/sun4i_frontend.h
parent6b8562c86e249b6d46d3c1f02afe570368b01e67 (diff)
drm/sun4i: Add a driver for the display frontend
The display frontend is an hardware block that can be used to implement some more advanced features like hardware scaling or colorspace conversions. It can also be used to implement the output format of the VPU. Let's create a minimal driver for it that will only enable the hardware scaling features. Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Link: https://patchwork.freedesktop.org/patch/msgid/029cdc3478bf89d422f5e8d9e600baf5e48ce4db.1516613040.git-series.maxime.ripard@free-electrons.com
Diffstat (limited to 'drivers/gpu/drm/sun4i/sun4i_frontend.h')
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_frontend.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h
new file mode 100644
index 000000000000..02661ce81f3e
--- /dev/null
+++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h
@@ -0,0 +1,99 @@
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2017 Free Electrons
4 * Maxime Ripard <maxime.ripard@free-electrons.com>
5 */
6
7#ifndef _SUN4I_FRONTEND_H_
8#define _SUN4I_FRONTEND_H_
9
10#include <linux/list.h>
11
12#define SUN4I_FRONTEND_EN_REG 0x000
13#define SUN4I_FRONTEND_EN_EN BIT(0)
14
15#define SUN4I_FRONTEND_FRM_CTRL_REG 0x004
16#define SUN4I_FRONTEND_FRM_CTRL_COEF_ACCESS_CTRL BIT(23)
17#define SUN4I_FRONTEND_FRM_CTRL_FRM_START BIT(16)
18#define SUN4I_FRONTEND_FRM_CTRL_COEF_RDY BIT(1)
19#define SUN4I_FRONTEND_FRM_CTRL_REG_RDY BIT(0)
20
21#define SUN4I_FRONTEND_BYPASS_REG 0x008
22#define SUN4I_FRONTEND_BYPASS_CSC_EN BIT(1)
23
24#define SUN4I_FRONTEND_BUF_ADDR0_REG 0x020
25
26#define SUN4I_FRONTEND_LINESTRD0_REG 0x040
27
28#define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c
29#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(mod) ((mod) << 8)
30#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(fmt) ((fmt) << 4)
31#define SUN4I_FRONTEND_INPUT_FMT_PS(ps) (ps)
32
33#define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c
34#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(fmt) (fmt)
35
36#define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100
37#define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1)))
38
39#define SUN4I_FRONTEND_CH0_OUTSIZE_REG 0x104
40#define SUN4I_FRONTEND_OUTSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1)))
41
42#define SUN4I_FRONTEND_CH0_HORZFACT_REG 0x108
43#define SUN4I_FRONTEND_HORZFACT(i, f) (((i) << 16) | (f))
44
45#define SUN4I_FRONTEND_CH0_VERTFACT_REG 0x10c
46#define SUN4I_FRONTEND_VERTFACT(i, f) (((i) << 16) | (f))
47
48#define SUN4I_FRONTEND_CH0_HORZPHASE_REG 0x110
49#define SUN4I_FRONTEND_CH0_VERTPHASE0_REG 0x114
50#define SUN4I_FRONTEND_CH0_VERTPHASE1_REG 0x118
51
52#define SUN4I_FRONTEND_CH1_INSIZE_REG 0x200
53#define SUN4I_FRONTEND_CH1_OUTSIZE_REG 0x204
54#define SUN4I_FRONTEND_CH1_HORZFACT_REG 0x208
55#define SUN4I_FRONTEND_CH1_VERTFACT_REG 0x20c
56
57#define SUN4I_FRONTEND_CH1_HORZPHASE_REG 0x210
58#define SUN4I_FRONTEND_CH1_VERTPHASE0_REG 0x214
59#define SUN4I_FRONTEND_CH1_VERTPHASE1_REG 0x218
60
61#define SUN4I_FRONTEND_CH0_HORZCOEF0_REG(i) (0x400 + i * 4)
62#define SUN4I_FRONTEND_CH0_HORZCOEF1_REG(i) (0x480 + i * 4)
63#define SUN4I_FRONTEND_CH0_VERTCOEF_REG(i) (0x500 + i * 4)
64#define SUN4I_FRONTEND_CH1_HORZCOEF0_REG(i) (0x600 + i * 4)
65#define SUN4I_FRONTEND_CH1_HORZCOEF1_REG(i) (0x680 + i * 4)
66#define SUN4I_FRONTEND_CH1_VERTCOEF_REG(i) (0x700 + i * 4)
67
68struct clk;
69struct device_node;
70struct drm_plane;
71struct regmap;
72struct reset_control;
73
74struct sun4i_frontend {
75 struct list_head list;
76 struct device *dev;
77 struct device_node *node;
78
79 struct clk *bus_clk;
80 struct clk *mod_clk;
81 struct clk *ram_clk;
82 struct regmap *regs;
83 struct reset_control *reset;
84};
85
86extern const struct of_device_id sun4i_frontend_of_table[];
87
88int sun4i_frontend_init(struct sun4i_frontend *frontend);
89void sun4i_frontend_exit(struct sun4i_frontend *frontend);
90int sun4i_frontend_enable(struct sun4i_frontend *frontend);
91
92void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend,
93 struct drm_plane *plane);
94void sun4i_frontend_update_coord(struct sun4i_frontend *frontend,
95 struct drm_plane *plane);
96int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
97 struct drm_plane *plane, uint32_t out_fmt);
98
99#endif /* _SUN4I_FRONTEND_H_ */