Hi,
This serie aims at:
- Updating HW up-sampling method according to the format type.
- Adding color-encoding properties if layer can support YUV format,
and updating HW YUV-RGB matrix state according to the color-encoding
properties.
This patch series depends on:
- https://patchwork.freedesktop.org/series/58710/
- https://patchwork.freedesktop.org/series/59000/
- https://patchwork.freedesktop.org/series/59002/
Lowry Li (Arm Technology China) (2):
drm/komeda: Update HW up-sampling on D71
drm/komeda: Enable color-encoding (YUV format) support
drivers/gpu/drm/arm/display/komeda/Makefile | 1 +
.../gpu/drm/arm/display/komeda/d71/d71_component.c | 35 +++++++++++
.../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 67 ++++++++++++++++++++++
.../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 17 ++++++
drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 13 +++++
5 files changed, 133 insertions(+)
create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
--
1.9.1
Updates HW up-sampling method according to the format type.
Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
---
.../gpu/drm/arm/display/komeda/d71/d71_component.c | 29 ++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
index f8846c6..dfc70f5 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
@@ -212,6 +212,35 @@ static void d71_layer_update(struct komeda_component *c,
malidp_write32(reg, BLK_P1_PTR_HIGH, upper_32_bits(addr));
}
+ if (fb->format->is_yuv) {
+ u32 upsampling = 0;
+
+ switch (kfb->format_caps->fourcc) {
+ case DRM_FORMAT_YUYV:
+ upsampling = fb->modifier ? LR_CHI422_BILINEAR :
+ LR_CHI422_REPLICATION;
+ break;
+ case DRM_FORMAT_UYVY:
+ upsampling = LR_CHI422_REPLICATION;
+ break;
+ case DRM_FORMAT_NV12:
+ case DRM_FORMAT_YUV420_8BIT:
+ case DRM_FORMAT_YUV420_10BIT:
+ case DRM_FORMAT_YUV420:
+ case DRM_FORMAT_P010:
+ /* these fmt support MPGE/JPEG both, here perfer JPEG*/
+ upsampling = LR_CHI420_JPEG;
+ break;
+ case DRM_FORMAT_X0L2:
+ upsampling = LR_CHI420_JPEG;
+ break;
+ default:
+ break;
+ }
+
+ malidp_write32(reg, LAYER_R_CONTROL, upsampling);
+ }
+
malidp_write32(reg, LAYER_FMT, kfb->format_caps->hw_id);
malidp_write32(reg, BLK_IN_SIZE, HV_SIZE(st->hsize, st->vsize));
--
1.9.1
Adds color-encoding properties if layer can support YUV format.
Updates HW YUV-RGB matrix state according to the color-encoding
properties.
Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
---
drivers/gpu/drm/arm/display/komeda/Makefile | 1 +
.../gpu/drm/arm/display/komeda/d71/d71_component.c | 6 ++
.../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 67 ++++++++++++++++++++++
.../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 17 ++++++
drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 13 +++++
5 files changed, 104 insertions(+)
create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile b/drivers/gpu/drm/arm/display/komeda/Makefile
index d7e29fc..73b8e8b 100644
--- a/drivers/gpu/drm/arm/display/komeda/Makefile
+++ b/drivers/gpu/drm/arm/display/komeda/Makefile
@@ -8,6 +8,7 @@ komeda-y := \
komeda_drv.o \
komeda_dev.o \
komeda_format_caps.o \
+ komeda_color_mgmt.o \
komeda_pipeline.o \
komeda_pipeline_state.o \
komeda_framebuffer.o \
diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
index dfc70f5..b85514b 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
@@ -10,6 +10,7 @@
#include "komeda_kms.h"
#include "malidp_io.h"
#include "komeda_framebuffer.h"
+#include "komeda_color_mgmt.h"
static void get_resources_id(u32 hw_id, u32 *pipe_id, u32 *comp_id)
{
@@ -239,6 +240,11 @@ static void d71_layer_update(struct komeda_component *c,
}
malidp_write32(reg, LAYER_R_CONTROL, upsampling);
+ malidp_write_group(reg, LAYER_YUV_RGB_COEFF0,
+ KOMEDA_N_YUV2RGB_COEFFS,
+ komeda_select_yuv2rgb_coeffs(
+ plane_st->color_encoding,
+ plane_st->color_range));
}
malidp_write32(reg, LAYER_FMT, kfb->format_caps->hw_id);
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
new file mode 100644
index 0000000..9d14a92
--- /dev/null
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+
+#include "komeda_color_mgmt.h"
+
+/* 10bit precision YUV2RGB matrix */
+static const s32 yuv2rgb_bt601_narrow[KOMEDA_N_YUV2RGB_COEFFS] = {
+ 1192, 0, 1634,
+ 1192, -401, -832,
+ 1192, 2066, 0,
+ 64, 512, 512
+};
+
+static const s32 yuv2rgb_bt601_wide[KOMEDA_N_YUV2RGB_COEFFS] = {
+ 1024, 0, 1436,
+ 1024, -352, -731,
+ 1024, 1815, 0,
+ 0, 512, 512
+};
+
+static const s32 yuv2rgb_bt709_narrow[KOMEDA_N_YUV2RGB_COEFFS] = {
+ 1192, 0, 1836,
+ 1192, -218, -546,
+ 1192, 2163, 0,
+ 64, 512, 512
+};
+
+static const s32 yuv2rgb_bt709_wide[KOMEDA_N_YUV2RGB_COEFFS] = {
+ 1024, 0, 1613,
+ 1024, -192, -479,
+ 1024, 1900, 0,
+ 0, 512, 512
+};
+
+static const s32 yuv2rgb_bt2020[KOMEDA_N_YUV2RGB_COEFFS] = {
+ 1024, 0, 1476,
+ 1024, -165, -572,
+ 1024, 1884, 0,
+ 0, 512, 512
+};
+
+const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range)
+{
+ bool narrow = color_range == DRM_COLOR_YCBCR_LIMITED_RANGE;
+ const s32 *coeffs;
+
+ switch (color_encoding) {
+ case DRM_COLOR_YCBCR_BT709:
+ coeffs = narrow ? yuv2rgb_bt709_narrow : yuv2rgb_bt709_wide;
+ break;
+ case DRM_COLOR_YCBCR_BT601:
+ coeffs = narrow ? yuv2rgb_bt601_narrow : yuv2rgb_bt601_wide;
+ break;
+ case DRM_COLOR_YCBCR_BT2020:
+ coeffs = yuv2rgb_bt2020;
+ break;
+ default:
+ coeffs = NULL;
+ break;
+ }
+
+ return coeffs;
+}
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
new file mode 100644
index 0000000..a2df218
--- /dev/null
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang <[email protected]>
+ *
+ */
+
+#ifndef _KOMEDA_COLOR_MGMT_H_
+#define _KOMEDA_COLOR_MGMT_H_
+
+#include <drm/drm_color_mgmt.h>
+
+#define KOMEDA_N_YUV2RGB_COEFFS 12
+
+const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range);
+
+#endif
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
index f344048..bcf30a7 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
@@ -135,6 +135,8 @@ static void komeda_plane_reset(struct drm_plane *plane)
state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
state->base.alpha = DRM_BLEND_ALPHA_OPAQUE;
state->base.zpos = kplane->layer->base.id;
+ state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
+ state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
plane->state = &state->base;
plane->state->plane = plane;
}
@@ -330,6 +332,17 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,
if (err)
goto cleanup;
+ err = drm_plane_create_color_properties(plane,
+ BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT709) |
+ BIT(DRM_COLOR_YCBCR_BT2020),
+ BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+ DRM_COLOR_YCBCR_BT601,
+ DRM_COLOR_YCBCR_LIMITED_RANGE);
+ if (err)
+ goto cleanup;
+
return 0;
cleanup:
komeda_plane_destroy(plane);
--
1.9.1
On Thu, May 16, 2019 at 02:13:09PM +0800, Lowry Li (Arm Technology China) wrote:
> Updates HW up-sampling method according to the format type.
>
> Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> ---
> .../gpu/drm/arm/display/komeda/d71/d71_component.c | 29 ++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> index f8846c6..dfc70f5 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -212,6 +212,35 @@ static void d71_layer_update(struct komeda_component *c,
> malidp_write32(reg, BLK_P1_PTR_HIGH, upper_32_bits(addr));
> }
>
> + if (fb->format->is_yuv) {
> + u32 upsampling = 0;
> +
> + switch (kfb->format_caps->fourcc) {
> + case DRM_FORMAT_YUYV:
> + upsampling = fb->modifier ? LR_CHI422_BILINEAR :
> + LR_CHI422_REPLICATION;
> + break;
> + case DRM_FORMAT_UYVY:
> + upsampling = LR_CHI422_REPLICATION;
> + break;
> + case DRM_FORMAT_NV12:
> + case DRM_FORMAT_YUV420_8BIT:
> + case DRM_FORMAT_YUV420_10BIT:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_P010:
> + /* these fmt support MPGE/JPEG both, here perfer JPEG*/
> + upsampling = LR_CHI420_JPEG;
> + break;
> + case DRM_FORMAT_X0L2:
> + upsampling = LR_CHI420_JPEG;
> + break;
> + default:
> + break;
> + }
> +
> + malidp_write32(reg, LAYER_R_CONTROL, upsampling);
> + }
> +
> malidp_write32(reg, LAYER_FMT, kfb->format_caps->hw_id);
> malidp_write32(reg, BLK_IN_SIZE, HV_SIZE(st->hsize, st->vsize));
>
> --
> 1.9.1
>
Reviewed-by: James Qian Wang (Arm Technology China) <[email protected]>
Looks good to me.
Thank you
On Thu, May 16, 2019 at 02:13:13PM +0800, Lowry Li (Arm Technology China) wrote:
> Adds color-encoding properties if layer can support YUV format.
> Updates HW YUV-RGB matrix state according to the color-encoding
> properties.
>
> Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> ---
> drivers/gpu/drm/arm/display/komeda/Makefile | 1 +
> .../gpu/drm/arm/display/komeda/d71/d71_component.c | 6 ++
> .../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 67 ++++++++++++++++++++++
> .../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 17 ++++++
> drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 13 +++++
> 5 files changed, 104 insertions(+)
> create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
> create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile b/drivers/gpu/drm/arm/display/komeda/Makefile
> index d7e29fc..73b8e8b 100644
> --- a/drivers/gpu/drm/arm/display/komeda/Makefile
> +++ b/drivers/gpu/drm/arm/display/komeda/Makefile
> @@ -8,6 +8,7 @@ komeda-y := \
> komeda_drv.o \
> komeda_dev.o \
> komeda_format_caps.o \
> + komeda_color_mgmt.o \
> komeda_pipeline.o \
> komeda_pipeline_state.o \
> komeda_framebuffer.o \
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> index dfc70f5..b85514b 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -10,6 +10,7 @@
> #include "komeda_kms.h"
> #include "malidp_io.h"
> #include "komeda_framebuffer.h"
> +#include "komeda_color_mgmt.h"
>
> static void get_resources_id(u32 hw_id, u32 *pipe_id, u32 *comp_id)
> {
> @@ -239,6 +240,11 @@ static void d71_layer_update(struct komeda_component *c,
> }
>
> malidp_write32(reg, LAYER_R_CONTROL, upsampling);
> + malidp_write_group(reg, LAYER_YUV_RGB_COEFF0,
> + KOMEDA_N_YUV2RGB_COEFFS,
> + komeda_select_yuv2rgb_coeffs(
> + plane_st->color_encoding,
> + plane_st->color_range));
> }
>
> malidp_write32(reg, LAYER_FMT, kfb->format_caps->hw_id);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
> new file mode 100644
> index 0000000..9d14a92
> --- /dev/null
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
> @@ -0,0 +1,67 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
> + * Author: James.Qian.Wang <[email protected]>
> + *
> + */
> +
> +#include "komeda_color_mgmt.h"
> +
> +/* 10bit precision YUV2RGB matrix */
> +static const s32 yuv2rgb_bt601_narrow[KOMEDA_N_YUV2RGB_COEFFS] = {
> + 1192, 0, 1634,
> + 1192, -401, -832,
> + 1192, 2066, 0,
> + 64, 512, 512
> +};
> +
> +static const s32 yuv2rgb_bt601_wide[KOMEDA_N_YUV2RGB_COEFFS] = {
> + 1024, 0, 1436,
> + 1024, -352, -731,
> + 1024, 1815, 0,
> + 0, 512, 512
> +};
> +
> +static const s32 yuv2rgb_bt709_narrow[KOMEDA_N_YUV2RGB_COEFFS] = {
> + 1192, 0, 1836,
> + 1192, -218, -546,
> + 1192, 2163, 0,
> + 64, 512, 512
> +};
> +
> +static const s32 yuv2rgb_bt709_wide[KOMEDA_N_YUV2RGB_COEFFS] = {
> + 1024, 0, 1613,
> + 1024, -192, -479,
> + 1024, 1900, 0,
> + 0, 512, 512
> +};
> +
> +static const s32 yuv2rgb_bt2020[KOMEDA_N_YUV2RGB_COEFFS] = {
> + 1024, 0, 1476,
> + 1024, -165, -572,
> + 1024, 1884, 0,
> + 0, 512, 512
> +};
> +
> +const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range)
> +{
> + bool narrow = color_range == DRM_COLOR_YCBCR_LIMITED_RANGE;
> + const s32 *coeffs;
> +
> + switch (color_encoding) {
> + case DRM_COLOR_YCBCR_BT709:
> + coeffs = narrow ? yuv2rgb_bt709_narrow : yuv2rgb_bt709_wide;
> + break;
> + case DRM_COLOR_YCBCR_BT601:
> + coeffs = narrow ? yuv2rgb_bt601_narrow : yuv2rgb_bt601_wide;
> + break;
> + case DRM_COLOR_YCBCR_BT2020:
> + coeffs = yuv2rgb_bt2020;
> + break;
> + default:
> + coeffs = NULL;
> + break;
> + }
> +
> + return coeffs;
> +}
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
> new file mode 100644
> index 0000000..a2df218
> --- /dev/null
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
> + * Author: James.Qian.Wang <[email protected]>
> + *
> + */
> +
> +#ifndef _KOMEDA_COLOR_MGMT_H_
> +#define _KOMEDA_COLOR_MGMT_H_
> +
> +#include <drm/drm_color_mgmt.h>
> +
> +#define KOMEDA_N_YUV2RGB_COEFFS 12
> +
> +const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range);
> +
> +#endif
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> index f344048..bcf30a7 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> @@ -135,6 +135,8 @@ static void komeda_plane_reset(struct drm_plane *plane)
> state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
> state->base.alpha = DRM_BLEND_ALPHA_OPAQUE;
> state->base.zpos = kplane->layer->base.id;
> + state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
> + state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
> plane->state = &state->base;
> plane->state->plane = plane;
> }
> @@ -330,6 +332,17 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,
> if (err)
> goto cleanup;
>
> + err = drm_plane_create_color_properties(plane,
> + BIT(DRM_COLOR_YCBCR_BT601) |
> + BIT(DRM_COLOR_YCBCR_BT709) |
> + BIT(DRM_COLOR_YCBCR_BT2020),
> + BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
> + BIT(DRM_COLOR_YCBCR_FULL_RANGE),
> + DRM_COLOR_YCBCR_BT601,
> + DRM_COLOR_YCBCR_LIMITED_RANGE);
> + if (err)
> + goto cleanup;
> +
> return 0;
> cleanup:
> komeda_plane_destroy(plane);
> --
> 1.9.1
>
Reviewed-by: James Qian Wang (Arm Technology China) <[email protected]>
Looks good to me
Thank you