From d7d3217791bdc0a230aa4c7ca7e13f1fb3c861b2 Mon Sep 17 00:00:00 2001 From: Zhibin Huang Date: Fri, 9 Aug 2024 08:38:13 +0800 Subject: [PATCH] misc: rk628: bt1120: yc-swap and uv-swap property are also used in encoder The rk628's bt1120 encoder data type is yuv 4:2:2 packed format, i.e., it supports four types of packing (YUYV, YVYU, UYVY, and VYUY). The difference is that in the 16 lanel, there are 8 transmitting Y data, 8 transmitting UV data, and the UV data is transmitted alternately. Adding these two properties can support the packing method switching. For example: -- Assuming that these two properties are not configured, YUYV format will be used to transfer data by default. -- If you need to output YVYU format (i.e., the VU transfer order is reversed), you need to configure the bt1120-uv-swap property. -- If you need to output UYVY format (i.e., the Y and UV lane order is reversed), you need to configure the bt1120-yc-swap property. -- If you need to output VYUY format, both properties need to be configured; Type: Function Redmine ID: N/A Associated modifications: Ie1c54ac3fbc01d76d32eff8d2857f68339654b70 Test: N/A Signed-off-by: Zhibin Huang Change-Id: I25692e0713b68a8f9d7099086d00f927b9e26a02 --- drivers/misc/rk628/rk628.h | 1 + drivers/misc/rk628/rk628_rgb.c | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/misc/rk628/rk628.h b/drivers/misc/rk628/rk628.h index 2eba127a03c9..a5fc4a68331a 100644 --- a/drivers/misc/rk628/rk628.h +++ b/drivers/misc/rk628/rk628.h @@ -147,6 +147,7 @@ #define GRF_RGB_DEC_CON2 0x0048 #define GRF_RGB_ENC_CON 0x004c #define BT1120_UV_SWAP(x) HIWORD_UPDATE(x, 5, 5) +#define BT1120_YC_SWAP(x) HIWORD_UPDATE(x, 4, 4) #define ENC_DUALEDGE_EN(x) HIWORD_UPDATE(x, 3, 3) #define GRF_MIPI_LANE_DELAY_CON0 0x0050 #define GRF_MIPI_LANE_DELAY_CON1 0x0054 diff --git a/drivers/misc/rk628/rk628_rgb.c b/drivers/misc/rk628/rk628_rgb.c index 45df2ce09368..f99d9cf9b41b 100644 --- a/drivers/misc/rk628/rk628_rgb.c +++ b/drivers/misc/rk628/rk628_rgb.c @@ -22,12 +22,10 @@ int rk628_rgb_parse(struct rk628 *rk628, struct device_node *rgb_np) rk628->rgb.vccio_rgb = NULL; /* input/output: bt1120 */ - if ((rk628_input_is_bt1120(rk628) || rk628_output_is_bt1120(rk628)) && - of_property_read_bool(rk628->dev->of_node, "bt1120-dual-edge")) - rk628->rgb.bt1120_dual_edge = true; + if ((rk628_input_is_bt1120(rk628) || rk628_output_is_bt1120(rk628))) { + if (of_property_read_bool(rk628->dev->of_node, "bt1120-dual-edge")) + rk628->rgb.bt1120_dual_edge = true; - /* input: bt1120 */ - if (rk628_input_is_bt1120(rk628)) { if (of_property_read_bool(rk628->dev->of_node, "bt1120-yc-swap")) rk628->rgb.bt1120_yc_swap = true; @@ -397,7 +395,8 @@ static void rk628_bt1120_encoder_enable(struct rk628 *rk628) } } - val |= BT1120_UV_SWAP(1); + val |= rk628->rgb.bt1120_yc_swap ? BT1120_YC_SWAP(1) : BT1120_YC_SWAP(0); + val |= rk628->rgb.bt1120_uv_swap ? BT1120_UV_SWAP(1) : BT1120_UV_SWAP(0); rk628_i2c_write(rk628, GRF_RGB_ENC_CON, val); }