mirror of
https://github.com/armbian/build.git
synced 2025-08-15 15:46:58 +02:00
122 lines
4.3 KiB
Diff
122 lines
4.3 KiB
Diff
From 18890b5c9dbf9270b7f0e42875d6b8bd14ee6624 Mon Sep 17 00:00:00 2001
|
|
From: Jernej Skrabec <jernej.skrabec@gmail.com>
|
|
Date: Sun, 29 Sep 2024 22:04:46 +1300
|
|
Subject: drm: sun4i: de2/de3: refactor mixer initialisation
|
|
|
|
Now that the DE variant can be selected by enum, take the oppportunity
|
|
to factor out some common initialisation code to a separate function.
|
|
|
|
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
|
|
Signed-off-by: Ryan Walklin <ryan@testtoast.com>
|
|
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
|
|
---
|
|
drivers/gpu/drm/sun4i/sun8i_mixer.c | 64 +++++++++++++++--------------
|
|
1 file changed, 34 insertions(+), 30 deletions(-)
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
index 16e018aa4aae..18745af08954 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
@@ -468,6 +468,38 @@ static int sun8i_mixer_of_get_id(struct device_node *node)
|
|
return of_ep.id;
|
|
}
|
|
|
|
+static void sun8i_mixer_init(struct sun8i_mixer *mixer)
|
|
+{
|
|
+ unsigned int base = sun8i_blender_base(mixer);
|
|
+ int plane_cnt, i;
|
|
+
|
|
+ /* Enable the mixer */
|
|
+ regmap_write(mixer->engine.regs, SUN8I_MIXER_GLOBAL_CTL,
|
|
+ SUN8I_MIXER_GLOBAL_CTL_RT_EN);
|
|
+
|
|
+ /* Set background color to black */
|
|
+ regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_BKCOLOR(base),
|
|
+ SUN8I_MIXER_BLEND_COLOR_BLACK);
|
|
+
|
|
+ /*
|
|
+ * Set fill color of bottom plane to black. Generally not needed
|
|
+ * except when VI plane is at bottom (zpos = 0) and enabled.
|
|
+ */
|
|
+ regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
|
|
+ SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0));
|
|
+ regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_FCOLOR(base, 0),
|
|
+ SUN8I_MIXER_BLEND_COLOR_BLACK);
|
|
+
|
|
+ plane_cnt = mixer->cfg->vi_num + mixer->cfg->ui_num;
|
|
+ for (i = 0; i < plane_cnt; i++)
|
|
+ regmap_write(mixer->engine.regs,
|
|
+ SUN8I_MIXER_BLEND_MODE(base, i),
|
|
+ SUN8I_MIXER_BLEND_MODE_DEF);
|
|
+
|
|
+ regmap_update_bits(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
|
|
+ SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK, 0);
|
|
+}
|
|
+
|
|
static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
void *data)
|
|
{
|
|
@@ -476,8 +508,6 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
struct sun4i_drv *drv = drm->dev_private;
|
|
struct sun8i_mixer *mixer;
|
|
void __iomem *regs;
|
|
- unsigned int base;
|
|
- int plane_cnt;
|
|
int i, ret;
|
|
|
|
/*
|
|
@@ -581,8 +611,6 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
|
|
list_add_tail(&mixer->engine.list, &drv->engine_list);
|
|
|
|
- base = sun8i_blender_base(mixer);
|
|
-
|
|
/* Reset registers and disable unused sub-engines */
|
|
if (mixer->cfg->de_type == sun8i_mixer_de3) {
|
|
for (i = 0; i < DE3_MIXER_UNIT_SIZE; i += 4)
|
|
@@ -598,7 +626,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
regmap_write(mixer->engine.regs, SUN50I_MIXER_FMT_EN, 0);
|
|
regmap_write(mixer->engine.regs, SUN50I_MIXER_CDC0_EN, 0);
|
|
regmap_write(mixer->engine.regs, SUN50I_MIXER_CDC1_EN, 0);
|
|
- } else {
|
|
+ } else if (mixer->cfg->de_type == sun8i_mixer_de2) {
|
|
for (i = 0; i < DE2_MIXER_UNIT_SIZE; i += 4)
|
|
regmap_write(mixer->engine.regs, i, 0);
|
|
|
|
@@ -611,31 +639,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
regmap_write(mixer->engine.regs, SUN8I_MIXER_DCSC_EN, 0);
|
|
}
|
|
|
|
- /* Enable the mixer */
|
|
- regmap_write(mixer->engine.regs, SUN8I_MIXER_GLOBAL_CTL,
|
|
- SUN8I_MIXER_GLOBAL_CTL_RT_EN);
|
|
-
|
|
- /* Set background color to black */
|
|
- regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_BKCOLOR(base),
|
|
- SUN8I_MIXER_BLEND_COLOR_BLACK);
|
|
-
|
|
- /*
|
|
- * Set fill color of bottom plane to black. Generally not needed
|
|
- * except when VI plane is at bottom (zpos = 0) and enabled.
|
|
- */
|
|
- regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
|
|
- SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0));
|
|
- regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_FCOLOR(base, 0),
|
|
- SUN8I_MIXER_BLEND_COLOR_BLACK);
|
|
-
|
|
- plane_cnt = mixer->cfg->vi_num + mixer->cfg->ui_num;
|
|
- for (i = 0; i < plane_cnt; i++)
|
|
- regmap_write(mixer->engine.regs,
|
|
- SUN8I_MIXER_BLEND_MODE(base, i),
|
|
- SUN8I_MIXER_BLEND_MODE_DEF);
|
|
-
|
|
- regmap_update_bits(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
|
|
- SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK, 0);
|
|
+ sun8i_mixer_init(mixer);
|
|
|
|
return 0;
|
|
|
|
--
|
|
2.35.3
|
|
|