aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>2018-11-23 04:24:50 -0500
committerMaxime Ripard <maxime.ripard@bootlin.com>2018-11-27 03:54:13 -0500
commit9579f9190487cc99ac280beda5da8ba7c3414b92 (patch)
tree7d3b9101b11eae580ca391b46fb7dae03e8751c8
parent47d0f9bdb190eccbd2d9f9b6a585ae64e48f8183 (diff)
drm/sun4i: frontend: Add proper definitions for format registers
This introduces proper definitions for the input and output format configuration registers instead of a macro and raw values in the code, with the intent to increase code readability and reduce indirections. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20181123092515.2511-19-paul.kocialkowski@bootlin.com
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_frontend.c14
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_frontend.h8
2 files changed, 10 insertions, 12 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c
index bb5977a466f3..a305b731b042 100644
--- a/drivers/gpu/drm/sun4i/sun4i_frontend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c
@@ -108,7 +108,7 @@ static int sun4i_frontend_drm_format_to_input_fmt(uint32_t fmt, u32 *val)
108{ 108{
109 switch (fmt) { 109 switch (fmt) {
110 case DRM_FORMAT_XRGB8888: 110 case DRM_FORMAT_XRGB8888:
111 *val = 5; 111 *val = SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB;
112 return 0; 112 return 0;
113 113
114 default: 114 default:
@@ -120,7 +120,7 @@ static int sun4i_frontend_drm_format_to_input_mode(uint32_t fmt, u32 *val)
120{ 120{
121 switch (fmt) { 121 switch (fmt) {
122 case DRM_FORMAT_XRGB8888: 122 case DRM_FORMAT_XRGB8888:
123 *val = 1; 123 *val = SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED;
124 return 0; 124 return 0;
125 125
126 default: 126 default:
@@ -132,7 +132,7 @@ static int sun4i_frontend_drm_format_to_input_sequence(uint32_t fmt, u32 *val)
132{ 132{
133 switch (fmt) { 133 switch (fmt) {
134 case DRM_FORMAT_XRGB8888: 134 case DRM_FORMAT_XRGB8888:
135 *val = 1; 135 *val = SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB;
136 return 0; 136 return 0;
137 137
138 default: 138 default:
@@ -144,7 +144,7 @@ static int sun4i_frontend_drm_format_to_output_fmt(uint32_t fmt, u32 *val)
144{ 144{
145 switch (fmt) { 145 switch (fmt) {
146 case DRM_FORMAT_XRGB8888: 146 case DRM_FORMAT_XRGB8888:
147 *val = 2; 147 *val = SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888;
148 return 0; 148 return 0;
149 149
150 default: 150 default:
@@ -218,9 +218,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
218 SUN4I_FRONTEND_BYPASS_CSC_EN); 218 SUN4I_FRONTEND_BYPASS_CSC_EN);
219 219
220 regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG, 220 regmap_write(frontend->regs, SUN4I_FRONTEND_INPUT_FMT_REG,
221 SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(in_mod_val) | 221 in_mod_val | in_fmt_val | in_ps_val);
222 SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(in_fmt_val) |
223 SUN4I_FRONTEND_INPUT_FMT_PS(in_ps_val));
224 222
225 /* 223 /*
226 * TODO: It look like the A31 and A80 at least will need the 224 * TODO: It look like the A31 and A80 at least will need the
@@ -228,7 +226,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
228 * ARGB8888). 226 * ARGB8888).
229 */ 227 */
230 regmap_write(frontend->regs, SUN4I_FRONTEND_OUTPUT_FMT_REG, 228 regmap_write(frontend->regs, SUN4I_FRONTEND_OUTPUT_FMT_REG,
231 SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(out_fmt_val)); 229 out_fmt_val);
232 230
233 return 0; 231 return 0;
234} 232}
diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.h b/drivers/gpu/drm/sun4i/sun4i_frontend.h
index a9cb908ced16..56bd5a3f9723 100644
--- a/drivers/gpu/drm/sun4i/sun4i_frontend.h
+++ b/drivers/gpu/drm/sun4i/sun4i_frontend.h
@@ -26,12 +26,12 @@
26#define SUN4I_FRONTEND_LINESTRD0_REG 0x040 26#define SUN4I_FRONTEND_LINESTRD0_REG 0x040
27 27
28#define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c 28#define SUN4I_FRONTEND_INPUT_FMT_REG 0x04c
29#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD(mod) ((mod) << 8) 29#define SUN4I_FRONTEND_INPUT_FMT_DATA_MOD_PACKED (1 << 8)
30#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT(fmt) ((fmt) << 4) 30#define SUN4I_FRONTEND_INPUT_FMT_DATA_FMT_RGB (5 << 4)
31#define SUN4I_FRONTEND_INPUT_FMT_PS(ps) (ps) 31#define SUN4I_FRONTEND_INPUT_FMT_DATA_PS_XRGB 1
32 32
33#define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c 33#define SUN4I_FRONTEND_OUTPUT_FMT_REG 0x05c
34#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT(fmt) (fmt) 34#define SUN4I_FRONTEND_OUTPUT_FMT_DATA_FMT_XRGB8888 2
35 35
36#define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100 36#define SUN4I_FRONTEND_CH0_INSIZE_REG 0x100
37#define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1))) 37#define SUN4I_FRONTEND_INSIZE(h, w) ((((h) - 1) << 16) | (((w) - 1)))