Commit 9682dee9 authored by Lowry Li (Arm Technology China)'s avatar Lowry Li (Arm Technology China) Committed by Liviu Dudau

drm/komeda: Enable color-encoding (YUV format) support

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: default avatarLowry Li (Arm Technology China) <lowry.li@arm.com>
Reviewed-by: default avatarJames Qian Wang (Arm Technology China) <james.qian.wang@arm.com>
Signed-off-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
parent 97e659d4
...@@ -8,6 +8,7 @@ komeda-y := \ ...@@ -8,6 +8,7 @@ komeda-y := \
komeda_drv.o \ komeda_drv.o \
komeda_dev.o \ komeda_dev.o \
komeda_format_caps.o \ komeda_format_caps.o \
komeda_color_mgmt.o \
komeda_pipeline.o \ komeda_pipeline.o \
komeda_pipeline_state.o \ komeda_pipeline_state.o \
komeda_framebuffer.o \ komeda_framebuffer.o \
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "komeda_kms.h" #include "komeda_kms.h"
#include "malidp_io.h" #include "malidp_io.h"
#include "komeda_framebuffer.h" #include "komeda_framebuffer.h"
#include "komeda_color_mgmt.h"
static void get_resources_id(u32 hw_id, u32 *pipe_id, u32 *comp_id) 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, ...@@ -239,6 +240,11 @@ static void d71_layer_update(struct komeda_component *c,
} }
malidp_write32(reg, LAYER_R_CONTROL, upsampling); 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); malidp_write32(reg, LAYER_FMT, kfb->format_caps->hw_id);
......
// SPDX-License-Identifier: GPL-2.0
/*
* (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
* Author: James.Qian.Wang <james.qian.wang@arm.com>
*
*/
#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;
}
/* SPDX-License-Identifier: GPL-2.0 */
/*
* (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
* Author: James.Qian.Wang <james.qian.wang@arm.com>
*
*/
#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
...@@ -137,6 +137,8 @@ static void komeda_plane_reset(struct drm_plane *plane) ...@@ -137,6 +137,8 @@ static void komeda_plane_reset(struct drm_plane *plane)
state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
state->base.alpha = DRM_BLEND_ALPHA_OPAQUE; state->base.alpha = DRM_BLEND_ALPHA_OPAQUE;
state->base.zpos = kplane->layer->base.id; 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 = &state->base;
plane->state->plane = plane; plane->state->plane = plane;
} }
...@@ -332,6 +334,17 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, ...@@ -332,6 +334,17 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,
if (err) if (err)
goto cleanup; 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; return 0;
cleanup: cleanup:
komeda_plane_destroy(plane); komeda_plane_destroy(plane);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment