mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2024-12-15 19:09:46 +00:00
221 lines
6.4 KiB
Diff
221 lines
6.4 KiB
Diff
From 9a4784752427c56839353f09446c5344a3b84641 Mon Sep 17 00:00:00 2001
|
|
From: Jernej Skrabec <jernej.skrabec@siol.net>
|
|
Date: Tue, 18 Feb 2020 23:19:48 +0100
|
|
Subject: [PATCH 08/23] drm/sun4i: de2/de3: Merge CSC functions into one
|
|
|
|
Merging both function into one lets this one decide on it's own if CSC
|
|
should be enabled or not. Currently heuristics for that is pretty simple
|
|
- enable it for YUV formats and disable for RGB. However, DE3 can have
|
|
whole pipeline in RGB or YUV format. YUV pipeline will be supported in
|
|
later commits.
|
|
|
|
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
|
|
---
|
|
drivers/gpu/drm/sun4i/sun8i_csc.c | 89 ++++++++++----------------
|
|
drivers/gpu/drm/sun4i/sun8i_csc.h | 9 ++-
|
|
drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 11 +---
|
|
3 files changed, 40 insertions(+), 69 deletions(-)
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_csc.c b/drivers/gpu/drm/sun4i/sun8i_csc.c
|
|
index 6ebd1c3aa3ab..0dcbc0866ae8 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_csc.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_csc.c
|
|
@@ -107,23 +107,28 @@ static const u32 yuv2rgb_de3[2][3][12] = {
|
|
},
|
|
};
|
|
|
|
-static void sun8i_csc_set_coefficients(struct regmap *map, u32 base,
|
|
- enum format_type fmt_type,
|
|
- enum drm_color_encoding encoding,
|
|
- enum drm_color_range range)
|
|
+static void sun8i_csc_setup(struct regmap *map, u32 base,
|
|
+ enum format_type fmt_type,
|
|
+ enum drm_color_encoding encoding,
|
|
+ enum drm_color_range range)
|
|
{
|
|
+ u32 base_reg, val;
|
|
const u32 *table;
|
|
- u32 base_reg;
|
|
int i;
|
|
|
|
table = yuv2rgb[range][encoding];
|
|
|
|
switch (fmt_type) {
|
|
+ case FORMAT_TYPE_RGB:
|
|
+ val = 0;
|
|
+ break;
|
|
case FORMAT_TYPE_YUV:
|
|
+ val = SUN8I_CSC_CTRL_EN;
|
|
base_reg = SUN8I_CSC_COEFF(base, 0);
|
|
regmap_bulk_write(map, base_reg, table, 12);
|
|
break;
|
|
case FORMAT_TYPE_YVU:
|
|
+ val = SUN8I_CSC_CTRL_EN;
|
|
for (i = 0; i < 12; i++) {
|
|
if ((i & 3) == 1)
|
|
base_reg = SUN8I_CSC_COEFF(base, i + 1);
|
|
@@ -135,28 +140,37 @@ static void sun8i_csc_set_coefficients(struct regmap *map, u32 base,
|
|
}
|
|
break;
|
|
default:
|
|
+ val = 0;
|
|
DRM_WARN("Wrong CSC mode specified.\n");
|
|
return;
|
|
}
|
|
+
|
|
+ regmap_write(map, SUN8I_CSC_CTRL(base), val);
|
|
}
|
|
|
|
-static void sun8i_de3_ccsc_set_coefficients(struct regmap *map, int layer,
|
|
- enum format_type fmt_type,
|
|
- enum drm_color_encoding encoding,
|
|
- enum drm_color_range range)
|
|
+static void sun8i_de3_ccsc_setup(struct regmap *map, int layer,
|
|
+ enum format_type fmt_type,
|
|
+ enum drm_color_encoding encoding,
|
|
+ enum drm_color_range range)
|
|
{
|
|
+ u32 addr, val, mask;
|
|
const u32 *table;
|
|
- u32 addr;
|
|
int i;
|
|
|
|
+ mask = SUN50I_MIXER_BLEND_CSC_CTL_EN(layer);
|
|
table = yuv2rgb_de3[range][encoding];
|
|
|
|
switch (fmt_type) {
|
|
+ case FORMAT_TYPE_RGB:
|
|
+ val = 0;
|
|
+ break;
|
|
case FORMAT_TYPE_YUV:
|
|
+ val = mask;
|
|
addr = SUN50I_MIXER_BLEND_CSC_COEFF(DE3_BLD_BASE, layer, 0);
|
|
regmap_bulk_write(map, addr, table, 12);
|
|
break;
|
|
case FORMAT_TYPE_YVU:
|
|
+ val = mask;
|
|
for (i = 0; i < 12; i++) {
|
|
if ((i & 3) == 1)
|
|
addr = SUN50I_MIXER_BLEND_CSC_COEFF(DE3_BLD_BASE,
|
|
@@ -173,67 +187,30 @@ static void sun8i_de3_ccsc_set_coefficients(struct regmap *map, int layer,
|
|
}
|
|
break;
|
|
default:
|
|
+ val = 0;
|
|
DRM_WARN("Wrong CSC mode specified.\n");
|
|
return;
|
|
}
|
|
-}
|
|
-
|
|
-static void sun8i_csc_enable(struct regmap *map, u32 base, bool enable)
|
|
-{
|
|
- u32 val;
|
|
-
|
|
- if (enable)
|
|
- val = SUN8I_CSC_CTRL_EN;
|
|
- else
|
|
- val = 0;
|
|
-
|
|
- regmap_update_bits(map, SUN8I_CSC_CTRL(base), SUN8I_CSC_CTRL_EN, val);
|
|
-}
|
|
-
|
|
-static void sun8i_de3_ccsc_enable(struct regmap *map, int layer, bool enable)
|
|
-{
|
|
- u32 val, mask;
|
|
-
|
|
- mask = SUN50I_MIXER_BLEND_CSC_CTL_EN(layer);
|
|
-
|
|
- if (enable)
|
|
- val = mask;
|
|
- else
|
|
- val = 0;
|
|
|
|
regmap_update_bits(map, SUN50I_MIXER_BLEND_CSC_CTL(DE3_BLD_BASE),
|
|
mask, val);
|
|
}
|
|
|
|
-void sun8i_csc_set_ccsc_coefficients(struct sun8i_mixer *mixer, int layer,
|
|
- enum format_type fmt_type,
|
|
- enum drm_color_encoding encoding,
|
|
- enum drm_color_range range)
|
|
+void sun8i_csc_set_ccsc(struct sun8i_mixer *mixer, int layer,
|
|
+ enum format_type fmt_type,
|
|
+ enum drm_color_encoding encoding,
|
|
+ enum drm_color_range range)
|
|
{
|
|
u32 base;
|
|
|
|
if (mixer->cfg->is_de3) {
|
|
- sun8i_de3_ccsc_set_coefficients(mixer->engine.regs, layer,
|
|
- fmt_type, encoding, range);
|
|
+ sun8i_de3_ccsc_setup(mixer->engine.regs, layer,
|
|
+ fmt_type, encoding, range);
|
|
return;
|
|
}
|
|
|
|
base = ccsc_base[mixer->cfg->ccsc][layer];
|
|
|
|
- sun8i_csc_set_coefficients(mixer->engine.regs, base,
|
|
- fmt_type, encoding, range);
|
|
-}
|
|
-
|
|
-void sun8i_csc_enable_ccsc(struct sun8i_mixer *mixer, int layer, bool enable)
|
|
-{
|
|
- u32 base;
|
|
-
|
|
- if (mixer->cfg->is_de3) {
|
|
- sun8i_de3_ccsc_enable(mixer->engine.regs, layer, enable);
|
|
- return;
|
|
- }
|
|
-
|
|
- base = ccsc_base[mixer->cfg->ccsc][layer];
|
|
-
|
|
- sun8i_csc_enable(mixer->engine.regs, base, enable);
|
|
+ sun8i_csc_setup(mixer->engine.regs, base,
|
|
+ fmt_type, encoding, range);
|
|
}
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_csc.h b/drivers/gpu/drm/sun4i/sun8i_csc.h
|
|
index 7322770f39f0..b7546e06e315 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_csc.h
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_csc.h
|
|
@@ -28,10 +28,9 @@ enum format_type {
|
|
FORMAT_TYPE_YVU,
|
|
};
|
|
|
|
-void sun8i_csc_set_ccsc_coefficients(struct sun8i_mixer *mixer, int layer,
|
|
- enum format_type fmt_type,
|
|
- enum drm_color_encoding encoding,
|
|
- enum drm_color_range range);
|
|
-void sun8i_csc_enable_ccsc(struct sun8i_mixer *mixer, int layer, bool enable);
|
|
+void sun8i_csc_set_ccsc(struct sun8i_mixer *mixer, int layer,
|
|
+ enum format_type fmt_type,
|
|
+ enum drm_color_encoding encoding,
|
|
+ enum drm_color_range range);
|
|
|
|
#endif
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
|
|
index 76e2d3ec0a78..6ee3790a2a81 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
|
|
@@ -281,14 +281,9 @@ static int sun8i_vi_layer_update_formats(struct sun8i_mixer *mixer, int channel,
|
|
SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_MASK, val);
|
|
|
|
fmt_type = sun8i_vi_layer_get_format_type(fmt);
|
|
- if (fmt_type != FORMAT_TYPE_RGB) {
|
|
- sun8i_csc_set_ccsc_coefficients(mixer, channel, fmt_type,
|
|
- state->color_encoding,
|
|
- state->color_range);
|
|
- sun8i_csc_enable_ccsc(mixer, channel, true);
|
|
- } else {
|
|
- sun8i_csc_enable_ccsc(mixer, channel, false);
|
|
- }
|
|
+ sun8i_csc_set_ccsc(mixer, channel, fmt_type,
|
|
+ state->color_encoding,
|
|
+ state->color_range);
|
|
|
|
if (!fmt->is_yuv)
|
|
val = SUN8I_MIXER_CHAN_VI_LAYER_ATTR_RGB_MODE;
|
|
--
|
|
2.42.0
|
|
|