Subject: [PATCH] drm/komeda: Adds output-color format/depth support

From: "Lowry Li (Arm Technology China)" <[email protected]>

Sets color_depth according to connector->bpc.
Adds a new optional DT attribute "color-format" to represent a
preferred color formats for a specific pipeline, and the select order
is:
YCRCB420 > YCRCB422 > YCRCB444 > RGB444
The color-format can be anyone of these 4 format, one color-format not
only represent one format, but also include the lower formats, like

color-format preferred_color_formats
YCRCB420 YCRCB420 > YCRCB422 > YCRCB444 > RGB444
YCRCB422 YCRCB422 > YCRCB444 > RGB444
YCRCB444 YCRCB444 > RGB444
RGB444 RGB444

Then the final color_format is calculated by 3 steps:
1. calculate HW available formats.
avail_formats = connector_color_formats & improc->color_formats;
2. filter out un-preferred format.
avail_formats &= preferred_color_formats;
3. select the final format according to the preferred order.
color_format = BIT(__fls(aval_formats));

Changes since v1:
Rebased to the drm-misc-next branch.

Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
---
.../arm/display/komeda/d71/d71_component.c | 15 ++++++++-
.../gpu/drm/arm/display/komeda/komeda_crtc.c | 27 ++++++++++++++++
.../gpu/drm/arm/display/komeda/komeda_dev.c | 32 ++++++++++++++++++-
.../gpu/drm/arm/display/komeda/komeda_kms.h | 2 ++
.../drm/arm/display/komeda/komeda_pipeline.h | 3 ++
.../display/komeda/komeda_pipeline_state.c | 31 ++++++++++++++++++
.../arm/display/komeda/komeda_wb_connector.c | 5 +++
7 files changed, 113 insertions(+), 2 deletions(-)

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 c3d29c0b051b..7b374a3b911e 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
@@ -944,13 +944,26 @@ static void d71_improc_update(struct komeda_component *c,
{
struct komeda_improc_state *st = to_improc_st(state);
u32 __iomem *reg = c->reg;
- u32 index;
+ u32 index, mask = 0, ctrl = 0;

for_each_changed_input(state, index)
malidp_write32(reg, BLK_INPUT_ID0 + index * 4,
to_d71_input_id(state, index));

malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize));
+ malidp_write32(reg, IPS_DEPTH, st->color_depth);
+
+ mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
+
+ /* config color format */
+ if (st->color_format == DRM_COLOR_FORMAT_YCRCB420)
+ ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
+ else if (st->color_format == DRM_COLOR_FORMAT_YCRCB422)
+ ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422;
+ else if (st->color_format == DRM_COLOR_FORMAT_YCRCB444)
+ ctrl |= IPS_CTRL_YUV;
+
+ malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl);
}

static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf)
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 624d257da20f..38d5cb20e908 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -18,6 +18,33 @@
#include "komeda_dev.h"
#include "komeda_kms.h"

+void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
+ u32 *color_depths, u32 *color_formats)
+{
+ struct drm_connector *conn;
+ struct drm_connector_state *conn_st;
+ u32 conn_color_formats = ~0u;
+ int i, min_bpc = 31, conn_bpc = 0;
+
+ for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) {
+ if (conn_st->crtc != crtc_st->crtc)
+ continue;
+
+ conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8;
+ conn_color_formats &= conn->display_info.color_formats;
+
+ if (conn_bpc < min_bpc)
+ min_bpc = conn_bpc;
+ }
+
+ /* connector doesn't config any color_format, use RGB444 as default */
+ if (conn_color_formats == 0)
+ conn_color_formats = DRM_COLOR_FORMAT_RGB444;
+
+ *color_depths = GENMASK(conn_bpc, 0);
+ *color_formats = conn_color_formats;
+}
+
static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
{
u64 pxlclk, aclk;
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
index 9cbcd56e54cd..bee4633cdd9f 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
@@ -113,12 +113,34 @@ static struct attribute_group komeda_sysfs_attr_group = {
.attrs = komeda_sysfs_entries,
};

+static int to_color_format(const char *str)
+{
+ int format;
+
+ if (!strncmp(str, "RGB444", 7)) {
+ format = DRM_COLOR_FORMAT_RGB444;
+ } else if (!strncmp(str, "YCRCB444", 9)) {
+ format = DRM_COLOR_FORMAT_YCRCB444;
+ } else if (!strncmp(str, "YCRCB422", 9)) {
+ format = DRM_COLOR_FORMAT_YCRCB422;
+ } else if (!strncmp(str, "YCRCB420", 9)) {
+ format = DRM_COLOR_FORMAT_YCRCB420;
+ } else {
+ DRM_WARN("invalid color_format: %s, please set it to RGB444, YCRCB444, YCRCB422 or YCRCB420\n",
+ str);
+ format = DRM_COLOR_FORMAT_RGB444;
+ }
+
+ return format;
+}
+
static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
{
struct komeda_pipeline *pipe;
struct clk *clk;
u32 pipe_id;
- int ret = 0;
+ int ret = 0, color_format;
+ const char *str;

ret = of_property_read_u32(np, "reg", &pipe_id);
if (ret != 0 || pipe_id >= mdev->n_pipelines)
@@ -133,6 +155,14 @@ static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
}
pipe->pxlclk = clk;

+ /* fetch DT configured color-format, if not set, use RGB444 */
+ if (!of_property_read_string(np, "color-format", &str))
+ color_format = to_color_format(str);
+ else
+ color_format = DRM_COLOR_FORMAT_RGB444;
+
+ pipe->improc->preferred_color_formats = (color_format << 1) - 1;
+
/* enum ports */
pipe->of_output_links[0] =
of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
index 45c498e15e7a..456f3c435719 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
@@ -166,6 +166,8 @@ static inline bool has_flip_h(u32 rot)
return !!(rotation & DRM_MODE_REFLECT_X);
}

+void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
+ u32 *color_depths, u32 *color_formats);
unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);

int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
index a7a84e66549d..910d279ae48d 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
@@ -315,6 +315,8 @@ struct komeda_splitter_state {
struct komeda_improc {
struct komeda_component base;
u32 supported_color_formats; /* DRM_RGB/YUV444/YUV420*/
+ /* the preferred order is from MSB to LSB YUV420 --> RGB444 */
+ u32 preferred_color_formats;
u32 supported_color_depths; /* BIT(8) | BIT(10)*/
u8 supports_degamma : 1;
u8 supports_csc : 1;
@@ -323,6 +325,7 @@ struct komeda_improc {

struct komeda_improc_state {
struct komeda_component_state base;
+ u8 color_format, color_depth;
u16 hsize, vsize;
};

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
index ea26bc9c2d00..5526731f5a33 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
@@ -743,6 +743,7 @@ komeda_improc_validate(struct komeda_improc *improc,
struct komeda_data_flow_cfg *dflow)
{
struct drm_crtc *crtc = kcrtc_st->base.crtc;
+ struct drm_crtc_state *crtc_st = &kcrtc_st->base;
struct komeda_component_state *c_st;
struct komeda_improc_state *st;

@@ -756,6 +757,36 @@ komeda_improc_validate(struct komeda_improc *improc,
st->hsize = dflow->in_w;
st->vsize = dflow->in_h;

+ if (drm_atomic_crtc_needs_modeset(crtc_st)) {
+ u32 output_depths, output_formats;
+ u32 avail_depths, avail_formats;
+
+ komeda_crtc_get_color_config(crtc_st, &output_depths,
+ &output_formats);
+
+ avail_depths = output_depths & improc->supported_color_depths;
+ if (avail_depths == 0) {
+ DRM_DEBUG_ATOMIC("No available color depths, conn depths: 0x%x & display: 0x%x\n",
+ output_depths,
+ improc->supported_color_depths);
+ return -EINVAL;
+ }
+
+ avail_formats = output_formats &
+ improc->supported_color_formats &
+ improc->preferred_color_formats;
+ if (avail_formats == 0) {
+ DRM_DEBUG_ATOMIC("No available color_formats, conn formats 0x%x & display: 0x%x & preferred: 0x%x\n",
+ output_formats,
+ improc->supported_color_formats,
+ improc->preferred_color_formats);
+ return -EINVAL;
+ }
+
+ st->color_depth = __fls(avail_depths);
+ st->color_format = BIT(__fls(avail_formats));
+ }
+
komeda_component_add_input(&st->base, &dflow->input, 0);
komeda_component_set_output(&dflow->input, &improc->base, 0);

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
index 617e1f7b8472..49e5469ba48e 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
@@ -142,6 +142,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
struct komeda_dev *mdev = kms->base.dev_private;
struct komeda_wb_connector *kwb_conn;
struct drm_writeback_connector *wb_conn;
+ struct drm_display_info *info;
u32 *formats, n_formats = 0;
int err;

@@ -171,6 +172,10 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,

drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);

+ info = &kwb_conn->base.base.display_info;
+ info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
+ info->color_formats = kcrtc->master->improc->supported_color_formats;
+
kcrtc->wb_conn = kwb_conn;

return 0;
--
2.17.1


2019-09-20 19:12:55

by Mihail Atanassov

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

Hi Lowry,

On Friday, 20 September 2019 10:43:47 BST Lowry Li (Arm Technology China) wrote:
> From: "Lowry Li (Arm Technology China)" <[email protected]>
>
> Sets color_depth according to connector->bpc.
> Adds a new optional DT attribute "color-format" to represent a

I don't see the hunk with the updated doc for the DT binding.

> preferred color formats for a specific pipeline, and the select order
> is:
> YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> The color-format can be anyone of these 4 format, one color-format not
> only represent one format, but also include the lower formats, like
>
> color-format preferred_color_formats
> YCRCB420 YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> YCRCB422 YCRCB422 > YCRCB444 > RGB444
> YCRCB444 YCRCB444 > RGB444
> RGB444 RGB444
>
> Then the final color_format is calculated by 3 steps:
> 1. calculate HW available formats.
> avail_formats = connector_color_formats & improc->color_formats;
> 2. filter out un-preferred format.
> avail_formats &= preferred_color_formats;
> 3. select the final format according to the preferred order.
> color_format = BIT(__fls(aval_formats));
>
> Changes since v1:
> Rebased to the drm-misc-next branch.
>
> Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> ---
> .../arm/display/komeda/d71/d71_component.c | 15 ++++++++-
> .../gpu/drm/arm/display/komeda/komeda_crtc.c | 27 ++++++++++++++++
> .../gpu/drm/arm/display/komeda/komeda_dev.c | 32 ++++++++++++++++++-
> .../gpu/drm/arm/display/komeda/komeda_kms.h | 2 ++
> .../drm/arm/display/komeda/komeda_pipeline.h | 3 ++
> .../display/komeda/komeda_pipeline_state.c | 31 ++++++++++++++++++
> .../arm/display/komeda/komeda_wb_connector.c | 5 +++
> 7 files changed, 113 insertions(+), 2 deletions(-)
>
> 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 c3d29c0b051b..7b374a3b911e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -944,13 +944,26 @@ static void d71_improc_update(struct komeda_component *c,
> {
> struct komeda_improc_state *st = to_improc_st(state);
> u32 __iomem *reg = c->reg;
> - u32 index;
> + u32 index, mask = 0, ctrl = 0;
>
> for_each_changed_input(state, index)
> malidp_write32(reg, BLK_INPUT_ID0 + index * 4,
> to_d71_input_id(state, index));
>
> malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize));
> + malidp_write32(reg, IPS_DEPTH, st->color_depth);
> +
> + mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> +
> + /* config color format */
> + if (st->color_format == DRM_COLOR_FORMAT_YCRCB420)
> + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB422)
> + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422;
> + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB444)
> + ctrl |= IPS_CTRL_YUV;
> +
> + malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl);
> }
>
> static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf)
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 624d257da20f..38d5cb20e908 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -18,6 +18,33 @@
> #include "komeda_dev.h"
> #include "komeda_kms.h"
>
> +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> + u32 *color_depths, u32 *color_formats)
> +{
> + struct drm_connector *conn;
> + struct drm_connector_state *conn_st;
> + u32 conn_color_formats = ~0u;
> + int i, min_bpc = 31, conn_bpc = 0;
> +
> + for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) {
> + if (conn_st->crtc != crtc_st->crtc)
> + continue;
> +
> + conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8;
> + conn_color_formats &= conn->display_info.color_formats;
> +
> + if (conn_bpc < min_bpc)
> + min_bpc = conn_bpc;
> + }
> +
> + /* connector doesn't config any color_format, use RGB444 as default */
> + if (conn_color_formats == 0)
> + conn_color_formats = DRM_COLOR_FORMAT_RGB444;
> +
> + *color_depths = GENMASK(conn_bpc, 0);
> + *color_formats = conn_color_formats;
> +}
> +
> static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
> {
> u64 pxlclk, aclk;
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 9cbcd56e54cd..bee4633cdd9f 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -113,12 +113,34 @@ static struct attribute_group komeda_sysfs_attr_group = {
> .attrs = komeda_sysfs_entries,
> };
>
> +static int to_color_format(const char *str)
> +{
> + int format;
> +
> + if (!strncmp(str, "RGB444", 7)) {
> + format = DRM_COLOR_FORMAT_RGB444;
> + } else if (!strncmp(str, "YCRCB444", 9)) {
> + format = DRM_COLOR_FORMAT_YCRCB444;
> + } else if (!strncmp(str, "YCRCB422", 9)) {
> + format = DRM_COLOR_FORMAT_YCRCB422;
> + } else if (!strncmp(str, "YCRCB420", 9)) {
> + format = DRM_COLOR_FORMAT_YCRCB420;
> + } else {
> + DRM_WARN("invalid color_format: %s, please set it to RGB444, YCRCB444, YCRCB422 or YCRCB420\n",
> + str);
> + format = DRM_COLOR_FORMAT_RGB444;
> + }
> +
> + return format;
> +}
> +
> static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> {
> struct komeda_pipeline *pipe;
> struct clk *clk;
> u32 pipe_id;
> - int ret = 0;
> + int ret = 0, color_format;
> + const char *str;
>
> ret = of_property_read_u32(np, "reg", &pipe_id);
> if (ret != 0 || pipe_id >= mdev->n_pipelines)
> @@ -133,6 +155,14 @@ static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> }
> pipe->pxlclk = clk;
>
> + /* fetch DT configured color-format, if not set, use RGB444 */
> + if (!of_property_read_string(np, "color-format", &str))
> + color_format = to_color_format(str);
> + else
> + color_format = DRM_COLOR_FORMAT_RGB444;
> +
> + pipe->improc->preferred_color_formats = (color_format << 1) - 1;
> +
> /* enum ports */
> pipe->of_output_links[0] =
> of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> index 45c498e15e7a..456f3c435719 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> @@ -166,6 +166,8 @@ static inline bool has_flip_h(u32 rot)
> return !!(rotation & DRM_MODE_REFLECT_X);
> }
>
> +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> + u32 *color_depths, u32 *color_formats);
> unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);
>
> int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> index a7a84e66549d..910d279ae48d 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> @@ -315,6 +315,8 @@ struct komeda_splitter_state {
> struct komeda_improc {
> struct komeda_component base;
> u32 supported_color_formats; /* DRM_RGB/YUV444/YUV420*/
> + /* the preferred order is from MSB to LSB YUV420 --> RGB444 */
> + u32 preferred_color_formats;
> u32 supported_color_depths; /* BIT(8) | BIT(10)*/
> u8 supports_degamma : 1;
> u8 supports_csc : 1;
> @@ -323,6 +325,7 @@ struct komeda_improc {
>
> struct komeda_improc_state {
> struct komeda_component_state base;
> + u8 color_format, color_depth;
> u16 hsize, vsize;
> };
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> index ea26bc9c2d00..5526731f5a33 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> @@ -743,6 +743,7 @@ komeda_improc_validate(struct komeda_improc *improc,
> struct komeda_data_flow_cfg *dflow)
> {
> struct drm_crtc *crtc = kcrtc_st->base.crtc;
> + struct drm_crtc_state *crtc_st = &kcrtc_st->base;
> struct komeda_component_state *c_st;
> struct komeda_improc_state *st;
>
> @@ -756,6 +757,36 @@ komeda_improc_validate(struct komeda_improc *improc,
> st->hsize = dflow->in_w;
> st->vsize = dflow->in_h;
>
> + if (drm_atomic_crtc_needs_modeset(crtc_st)) {
> + u32 output_depths, output_formats;
> + u32 avail_depths, avail_formats;
> +
> + komeda_crtc_get_color_config(crtc_st, &output_depths,
> + &output_formats);
> +
> + avail_depths = output_depths & improc->supported_color_depths;
> + if (avail_depths == 0) {
> + DRM_DEBUG_ATOMIC("No available color depths, conn depths: 0x%x & display: 0x%x\n",
> + output_depths,
> + improc->supported_color_depths);
> + return -EINVAL;
> + }
> +
> + avail_formats = output_formats &
> + improc->supported_color_formats &
> + improc->preferred_color_formats;
> + if (avail_formats == 0) {
> + DRM_DEBUG_ATOMIC("No available color_formats, conn formats 0x%x & display: 0x%x & preferred: 0x%x\n",
> + output_formats,
> + improc->supported_color_formats,
> + improc->preferred_color_formats);
> + return -EINVAL;
> + }
> +
> + st->color_depth = __fls(avail_depths);
> + st->color_format = BIT(__fls(avail_formats));
> + }
> +
> komeda_component_add_input(&st->base, &dflow->input, 0);
> komeda_component_set_output(&dflow->input, &improc->base, 0);
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> index 617e1f7b8472..49e5469ba48e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> @@ -142,6 +142,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> struct komeda_dev *mdev = kms->base.dev_private;
> struct komeda_wb_connector *kwb_conn;
> struct drm_writeback_connector *wb_conn;
> + struct drm_display_info *info;
> u32 *formats, n_formats = 0;
> int err;
>
> @@ -171,6 +172,10 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
>
> drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
>
> + info = &kwb_conn->base.base.display_info;
> + info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
> + info->color_formats = kcrtc->master->improc->supported_color_formats;
> +
> kcrtc->wb_conn = kwb_conn;
>
> return 0;
>


--
Mihail



2019-09-24 17:02:42

by Brian Starkey

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

Hi Lowry,

On Fri, Sep 20, 2019 at 09:43:47AM +0000, Lowry Li (Arm Technology China) wrote:
> From: "Lowry Li (Arm Technology China)" <[email protected]>
>
> Sets color_depth according to connector->bpc.
> Adds a new optional DT attribute "color-format" to represent a
> preferred color formats for a specific pipeline, and the select order
> is:
> YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> The color-format can be anyone of these 4 format, one color-format not
> only represent one format, but also include the lower formats, like
>
> color-format preferred_color_formats
> YCRCB420 YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> YCRCB422 YCRCB422 > YCRCB444 > RGB444
> YCRCB444 YCRCB444 > RGB444
> RGB444 RGB444
>
> Then the final color_format is calculated by 3 steps:
> 1. calculate HW available formats.
> avail_formats = connector_color_formats & improc->color_formats;
> 2. filter out un-preferred format.
> avail_formats &= preferred_color_formats;
> 3. select the final format according to the preferred order.
> color_format = BIT(__fls(aval_formats));

Is there a specific use-case for the DT property for selecting color
format?

I think in general the color format should be determined according to
the rules in the CEA spec. There's also the drm_mode_is_420_only()
helper we can use to determine if YCBCR420 must be used. For the cases
where it's optional, I think we can default to RGB444.

Thanks,
-Brian

>
> Changes since v1:
> Rebased to the drm-misc-next branch.
>
> Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> ---
> .../arm/display/komeda/d71/d71_component.c | 15 ++++++++-
> .../gpu/drm/arm/display/komeda/komeda_crtc.c | 27 ++++++++++++++++
> .../gpu/drm/arm/display/komeda/komeda_dev.c | 32 ++++++++++++++++++-
> .../gpu/drm/arm/display/komeda/komeda_kms.h | 2 ++
> .../drm/arm/display/komeda/komeda_pipeline.h | 3 ++
> .../display/komeda/komeda_pipeline_state.c | 31 ++++++++++++++++++
> .../arm/display/komeda/komeda_wb_connector.c | 5 +++
> 7 files changed, 113 insertions(+), 2 deletions(-)
>
> 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 c3d29c0b051b..7b374a3b911e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -944,13 +944,26 @@ static void d71_improc_update(struct komeda_component *c,
> {
> struct komeda_improc_state *st = to_improc_st(state);
> u32 __iomem *reg = c->reg;
> - u32 index;
> + u32 index, mask = 0, ctrl = 0;
>
> for_each_changed_input(state, index)
> malidp_write32(reg, BLK_INPUT_ID0 + index * 4,
> to_d71_input_id(state, index));
>
> malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize));
> + malidp_write32(reg, IPS_DEPTH, st->color_depth);
> +
> + mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> +
> + /* config color format */
> + if (st->color_format == DRM_COLOR_FORMAT_YCRCB420)
> + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB422)
> + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422;
> + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB444)
> + ctrl |= IPS_CTRL_YUV;
> +
> + malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl);
> }
>
> static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf)
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 624d257da20f..38d5cb20e908 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -18,6 +18,33 @@
> #include "komeda_dev.h"
> #include "komeda_kms.h"
>
> +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> + u32 *color_depths, u32 *color_formats)
> +{
> + struct drm_connector *conn;
> + struct drm_connector_state *conn_st;
> + u32 conn_color_formats = ~0u;
> + int i, min_bpc = 31, conn_bpc = 0;
> +
> + for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) {
> + if (conn_st->crtc != crtc_st->crtc)
> + continue;
> +
> + conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8;
> + conn_color_formats &= conn->display_info.color_formats;
> +
> + if (conn_bpc < min_bpc)
> + min_bpc = conn_bpc;
> + }
> +
> + /* connector doesn't config any color_format, use RGB444 as default */
> + if (conn_color_formats == 0)
> + conn_color_formats = DRM_COLOR_FORMAT_RGB444;
> +
> + *color_depths = GENMASK(conn_bpc, 0);
> + *color_formats = conn_color_formats;
> +}
> +
> static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
> {
> u64 pxlclk, aclk;
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 9cbcd56e54cd..bee4633cdd9f 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -113,12 +113,34 @@ static struct attribute_group komeda_sysfs_attr_group = {
> .attrs = komeda_sysfs_entries,
> };
>
> +static int to_color_format(const char *str)
> +{
> + int format;
> +
> + if (!strncmp(str, "RGB444", 7)) {
> + format = DRM_COLOR_FORMAT_RGB444;
> + } else if (!strncmp(str, "YCRCB444", 9)) {
> + format = DRM_COLOR_FORMAT_YCRCB444;
> + } else if (!strncmp(str, "YCRCB422", 9)) {
> + format = DRM_COLOR_FORMAT_YCRCB422;
> + } else if (!strncmp(str, "YCRCB420", 9)) {
> + format = DRM_COLOR_FORMAT_YCRCB420;
> + } else {
> + DRM_WARN("invalid color_format: %s, please set it to RGB444, YCRCB444, YCRCB422 or YCRCB420\n",
> + str);
> + format = DRM_COLOR_FORMAT_RGB444;
> + }
> +
> + return format;
> +}
> +
> static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> {
> struct komeda_pipeline *pipe;
> struct clk *clk;
> u32 pipe_id;
> - int ret = 0;
> + int ret = 0, color_format;
> + const char *str;
>
> ret = of_property_read_u32(np, "reg", &pipe_id);
> if (ret != 0 || pipe_id >= mdev->n_pipelines)
> @@ -133,6 +155,14 @@ static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> }
> pipe->pxlclk = clk;
>
> + /* fetch DT configured color-format, if not set, use RGB444 */
> + if (!of_property_read_string(np, "color-format", &str))
> + color_format = to_color_format(str);
> + else
> + color_format = DRM_COLOR_FORMAT_RGB444;
> +
> + pipe->improc->preferred_color_formats = (color_format << 1) - 1;
> +
> /* enum ports */
> pipe->of_output_links[0] =
> of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> index 45c498e15e7a..456f3c435719 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> @@ -166,6 +166,8 @@ static inline bool has_flip_h(u32 rot)
> return !!(rotation & DRM_MODE_REFLECT_X);
> }
>
> +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> + u32 *color_depths, u32 *color_formats);
> unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);
>
> int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> index a7a84e66549d..910d279ae48d 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> @@ -315,6 +315,8 @@ struct komeda_splitter_state {
> struct komeda_improc {
> struct komeda_component base;
> u32 supported_color_formats; /* DRM_RGB/YUV444/YUV420*/
> + /* the preferred order is from MSB to LSB YUV420 --> RGB444 */
> + u32 preferred_color_formats;
> u32 supported_color_depths; /* BIT(8) | BIT(10)*/
> u8 supports_degamma : 1;
> u8 supports_csc : 1;
> @@ -323,6 +325,7 @@ struct komeda_improc {
>
> struct komeda_improc_state {
> struct komeda_component_state base;
> + u8 color_format, color_depth;
> u16 hsize, vsize;
> };
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> index ea26bc9c2d00..5526731f5a33 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> @@ -743,6 +743,7 @@ komeda_improc_validate(struct komeda_improc *improc,
> struct komeda_data_flow_cfg *dflow)
> {
> struct drm_crtc *crtc = kcrtc_st->base.crtc;
> + struct drm_crtc_state *crtc_st = &kcrtc_st->base;
> struct komeda_component_state *c_st;
> struct komeda_improc_state *st;
>
> @@ -756,6 +757,36 @@ komeda_improc_validate(struct komeda_improc *improc,
> st->hsize = dflow->in_w;
> st->vsize = dflow->in_h;
>
> + if (drm_atomic_crtc_needs_modeset(crtc_st)) {
> + u32 output_depths, output_formats;
> + u32 avail_depths, avail_formats;
> +
> + komeda_crtc_get_color_config(crtc_st, &output_depths,
> + &output_formats);
> +
> + avail_depths = output_depths & improc->supported_color_depths;
> + if (avail_depths == 0) {
> + DRM_DEBUG_ATOMIC("No available color depths, conn depths: 0x%x & display: 0x%x\n",
> + output_depths,
> + improc->supported_color_depths);
> + return -EINVAL;
> + }
> +
> + avail_formats = output_formats &
> + improc->supported_color_formats &
> + improc->preferred_color_formats;
> + if (avail_formats == 0) {
> + DRM_DEBUG_ATOMIC("No available color_formats, conn formats 0x%x & display: 0x%x & preferred: 0x%x\n",
> + output_formats,
> + improc->supported_color_formats,
> + improc->preferred_color_formats);
> + return -EINVAL;
> + }
> +
> + st->color_depth = __fls(avail_depths);
> + st->color_format = BIT(__fls(avail_formats));
> + }
> +
> komeda_component_add_input(&st->base, &dflow->input, 0);
> komeda_component_set_output(&dflow->input, &improc->base, 0);
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> index 617e1f7b8472..49e5469ba48e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> @@ -142,6 +142,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> struct komeda_dev *mdev = kms->base.dev_private;
> struct komeda_wb_connector *kwb_conn;
> struct drm_writeback_connector *wb_conn;
> + struct drm_display_info *info;
> u32 *formats, n_formats = 0;
> int err;
>
> @@ -171,6 +172,10 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
>
> drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
>
> + info = &kwb_conn->base.base.display_info;
> + info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
> + info->color_formats = kcrtc->master->improc->supported_color_formats;
> +
> kcrtc->wb_conn = kwb_conn;
>
> return 0;
> --
> 2.17.1
>

2019-09-24 17:06:37

by Ville Syrjälä

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

On Mon, Sep 23, 2019 at 12:16:12PM +0000, Brian Starkey wrote:
> Hi Lowry,
>
> On Fri, Sep 20, 2019 at 09:43:47AM +0000, Lowry Li (Arm Technology China) wrote:
> > From: "Lowry Li (Arm Technology China)" <[email protected]>
> >
> > Sets color_depth according to connector->bpc.
> > Adds a new optional DT attribute "color-format" to represent a
> > preferred color formats for a specific pipeline, and the select order
> > is:
> > YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> > The color-format can be anyone of these 4 format, one color-format not
> > only represent one format, but also include the lower formats, like
> >
> > color-format preferred_color_formats
> > YCRCB420 YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> > YCRCB422 YCRCB422 > YCRCB444 > RGB444
> > YCRCB444 YCRCB444 > RGB444
> > RGB444 RGB444
> >
> > Then the final color_format is calculated by 3 steps:
> > 1. calculate HW available formats.
> > avail_formats = connector_color_formats & improc->color_formats;
> > 2. filter out un-preferred format.
> > avail_formats &= preferred_color_formats;
> > 3. select the final format according to the preferred order.
> > color_format = BIT(__fls(aval_formats));
>
> Is there a specific use-case for the DT property for selecting color
> format?
>
> I think in general the color format should be determined according to
> the rules in the CEA spec. There's also the drm_mode_is_420_only()
> helper we can use to determine if YCBCR420 must be used. For the cases
> where it's optional, I think we can default to RGB444.

That is the policy we have in i915. We have a vague plan to add
a new property for the user to select the encoding explicitly
(which would also allow things like YCbCr 4:4:4), but IIRC no
one has actually sent a patch for that.

CTA-861 sort of seems to say that one should favor YCbCr over
RGB iff both sides support it, but I think RGB is probably the
better default because it means straight passthrough (minus the
annoying full->limit quantization range trickery).

--
Ville Syrj?l?
Intel

Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

Hi Mihail,
On Fri, Sep 20, 2019 at 10:03:38AM +0000, Mihail Atanassov wrote:
> Hi Lowry,
>
> On Friday, 20 September 2019 10:43:47 BST Lowry Li (Arm Technology China) wrote:
> > From: "Lowry Li (Arm Technology China)" <[email protected]>
> >
> > Sets color_depth according to connector->bpc.
> > Adds a new optional DT attribute "color-format" to represent a
>
> I don't see the hunk with the updated doc for the DT binding.

Thanks for the comment. We planed a new patch serie for DT binding
doc update, including output-color format, side by side, dual link and
etc.

Regards,
Lowry
> > preferred color formats for a specific pipeline, and the select order
> > is:
> > YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> > The color-format can be anyone of these 4 format, one color-format not
> > only represent one format, but also include the lower formats, like
> >
> > color-format preferred_color_formats
> > YCRCB420 YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> > YCRCB422 YCRCB422 > YCRCB444 > RGB444
> > YCRCB444 YCRCB444 > RGB444
> > RGB444 RGB444
> >
> > Then the final color_format is calculated by 3 steps:
> > 1. calculate HW available formats.
> > avail_formats = connector_color_formats & improc->color_formats;
> > 2. filter out un-preferred format.
> > avail_formats &= preferred_color_formats;
> > 3. select the final format according to the preferred order.
> > color_format = BIT(__fls(aval_formats));
> >
> > Changes since v1:
> > Rebased to the drm-misc-next branch.
> >
> > Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> > ---
> > .../arm/display/komeda/d71/d71_component.c | 15 ++++++++-
> > .../gpu/drm/arm/display/komeda/komeda_crtc.c | 27 ++++++++++++++++
> > .../gpu/drm/arm/display/komeda/komeda_dev.c | 32 ++++++++++++++++++-
> > .../gpu/drm/arm/display/komeda/komeda_kms.h | 2 ++
> > .../drm/arm/display/komeda/komeda_pipeline.h | 3 ++
> > .../display/komeda/komeda_pipeline_state.c | 31 ++++++++++++++++++
> > .../arm/display/komeda/komeda_wb_connector.c | 5 +++
> > 7 files changed, 113 insertions(+), 2 deletions(-)
> >
> > 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 c3d29c0b051b..7b374a3b911e 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > @@ -944,13 +944,26 @@ static void d71_improc_update(struct komeda_component *c,
> > {
> > struct komeda_improc_state *st = to_improc_st(state);
> > u32 __iomem *reg = c->reg;
> > - u32 index;
> > + u32 index, mask = 0, ctrl = 0;
> >
> > for_each_changed_input(state, index)
> > malidp_write32(reg, BLK_INPUT_ID0 + index * 4,
> > to_d71_input_id(state, index));
> >
> > malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize));
> > + malidp_write32(reg, IPS_DEPTH, st->color_depth);
> > +
> > + mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> > +
> > + /* config color format */
> > + if (st->color_format == DRM_COLOR_FORMAT_YCRCB420)
> > + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> > + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB422)
> > + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422;
> > + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB444)
> > + ctrl |= IPS_CTRL_YUV;
> > +
> > + malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl);
> > }
> >
> > static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf)
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > index 624d257da20f..38d5cb20e908 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > @@ -18,6 +18,33 @@
> > #include "komeda_dev.h"
> > #include "komeda_kms.h"
> >
> > +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> > + u32 *color_depths, u32 *color_formats)
> > +{
> > + struct drm_connector *conn;
> > + struct drm_connector_state *conn_st;
> > + u32 conn_color_formats = ~0u;
> > + int i, min_bpc = 31, conn_bpc = 0;
> > +
> > + for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) {
> > + if (conn_st->crtc != crtc_st->crtc)
> > + continue;
> > +
> > + conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8;
> > + conn_color_formats &= conn->display_info.color_formats;
> > +
> > + if (conn_bpc < min_bpc)
> > + min_bpc = conn_bpc;
> > + }
> > +
> > + /* connector doesn't config any color_format, use RGB444 as default */
> > + if (conn_color_formats == 0)
> > + conn_color_formats = DRM_COLOR_FORMAT_RGB444;
> > +
> > + *color_depths = GENMASK(conn_bpc, 0);
> > + *color_formats = conn_color_formats;
> > +}
> > +
> > static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
> > {
> > u64 pxlclk, aclk;
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> > index 9cbcd56e54cd..bee4633cdd9f 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> > @@ -113,12 +113,34 @@ static struct attribute_group komeda_sysfs_attr_group = {
> > .attrs = komeda_sysfs_entries,
> > };
> >
> > +static int to_color_format(const char *str)
> > +{
> > + int format;
> > +
> > + if (!strncmp(str, "RGB444", 7)) {
> > + format = DRM_COLOR_FORMAT_RGB444;
> > + } else if (!strncmp(str, "YCRCB444", 9)) {
> > + format = DRM_COLOR_FORMAT_YCRCB444;
> > + } else if (!strncmp(str, "YCRCB422", 9)) {
> > + format = DRM_COLOR_FORMAT_YCRCB422;
> > + } else if (!strncmp(str, "YCRCB420", 9)) {
> > + format = DRM_COLOR_FORMAT_YCRCB420;
> > + } else {
> > + DRM_WARN("invalid color_format: %s, please set it to RGB444, YCRCB444, YCRCB422 or YCRCB420\n",
> > + str);
> > + format = DRM_COLOR_FORMAT_RGB444;
> > + }
> > +
> > + return format;
> > +}
> > +
> > static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> > {
> > struct komeda_pipeline *pipe;
> > struct clk *clk;
> > u32 pipe_id;
> > - int ret = 0;
> > + int ret = 0, color_format;
> > + const char *str;
> >
> > ret = of_property_read_u32(np, "reg", &pipe_id);
> > if (ret != 0 || pipe_id >= mdev->n_pipelines)
> > @@ -133,6 +155,14 @@ static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> > }
> > pipe->pxlclk = clk;
> >
> > + /* fetch DT configured color-format, if not set, use RGB444 */
> > + if (!of_property_read_string(np, "color-format", &str))
> > + color_format = to_color_format(str);
> > + else
> > + color_format = DRM_COLOR_FORMAT_RGB444;
> > +
> > + pipe->improc->preferred_color_formats = (color_format << 1) - 1;
> > +
> > /* enum ports */
> > pipe->of_output_links[0] =
> > of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > index 45c498e15e7a..456f3c435719 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > @@ -166,6 +166,8 @@ static inline bool has_flip_h(u32 rot)
> > return !!(rotation & DRM_MODE_REFLECT_X);
> > }
> >
> > +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> > + u32 *color_depths, u32 *color_formats);
> > unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);
> >
> > int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > index a7a84e66549d..910d279ae48d 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > @@ -315,6 +315,8 @@ struct komeda_splitter_state {
> > struct komeda_improc {
> > struct komeda_component base;
> > u32 supported_color_formats; /* DRM_RGB/YUV444/YUV420*/
> > + /* the preferred order is from MSB to LSB YUV420 --> RGB444 */
> > + u32 preferred_color_formats;
> > u32 supported_color_depths; /* BIT(8) | BIT(10)*/
> > u8 supports_degamma : 1;
> > u8 supports_csc : 1;
> > @@ -323,6 +325,7 @@ struct komeda_improc {
> >
> > struct komeda_improc_state {
> > struct komeda_component_state base;
> > + u8 color_format, color_depth;
> > u16 hsize, vsize;
> > };
> >
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > index ea26bc9c2d00..5526731f5a33 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > @@ -743,6 +743,7 @@ komeda_improc_validate(struct komeda_improc *improc,
> > struct komeda_data_flow_cfg *dflow)
> > {
> > struct drm_crtc *crtc = kcrtc_st->base.crtc;
> > + struct drm_crtc_state *crtc_st = &kcrtc_st->base;
> > struct komeda_component_state *c_st;
> > struct komeda_improc_state *st;
> >
> > @@ -756,6 +757,36 @@ komeda_improc_validate(struct komeda_improc *improc,
> > st->hsize = dflow->in_w;
> > st->vsize = dflow->in_h;
> >
> > + if (drm_atomic_crtc_needs_modeset(crtc_st)) {
> > + u32 output_depths, output_formats;
> > + u32 avail_depths, avail_formats;
> > +
> > + komeda_crtc_get_color_config(crtc_st, &output_depths,
> > + &output_formats);
> > +
> > + avail_depths = output_depths & improc->supported_color_depths;
> > + if (avail_depths == 0) {
> > + DRM_DEBUG_ATOMIC("No available color depths, conn depths: 0x%x & display: 0x%x\n",
> > + output_depths,
> > + improc->supported_color_depths);
> > + return -EINVAL;
> > + }
> > +
> > + avail_formats = output_formats &
> > + improc->supported_color_formats &
> > + improc->preferred_color_formats;
> > + if (avail_formats == 0) {
> > + DRM_DEBUG_ATOMIC("No available color_formats, conn formats 0x%x & display: 0x%x & preferred: 0x%x\n",
> > + output_formats,
> > + improc->supported_color_formats,
> > + improc->preferred_color_formats);
> > + return -EINVAL;
> > + }
> > +
> > + st->color_depth = __fls(avail_depths);
> > + st->color_format = BIT(__fls(avail_formats));
> > + }
> > +
> > komeda_component_add_input(&st->base, &dflow->input, 0);
> > komeda_component_set_output(&dflow->input, &improc->base, 0);
> >
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > index 617e1f7b8472..49e5469ba48e 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > @@ -142,6 +142,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> > struct komeda_dev *mdev = kms->base.dev_private;
> > struct komeda_wb_connector *kwb_conn;
> > struct drm_writeback_connector *wb_conn;
> > + struct drm_display_info *info;
> > u32 *formats, n_formats = 0;
> > int err;
> >
> > @@ -171,6 +172,10 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> >
> > drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
> >
> > + info = &kwb_conn->base.base.display_info;
> > + info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
> > + info->color_formats = kcrtc->master->improc->supported_color_formats;
> > +
> > kcrtc->wb_conn = kwb_conn;
> >
> > return 0;
> >
>
>
> --
> Mihail
>
>

2019-09-26 00:39:22

by James Qian Wang

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

On Mon, Sep 23, 2019 at 12:16:12PM +0000, Brian Starkey wrote:
> Hi Lowry,
>
> On Fri, Sep 20, 2019 at 09:43:47AM +0000, Lowry Li (Arm Technology China) wrote:
> > From: "Lowry Li (Arm Technology China)" <[email protected]>
> >
> > Sets color_depth according to connector->bpc.
> > Adds a new optional DT attribute "color-format" to represent a
> > preferred color formats for a specific pipeline, and the select order
> > is:
> > YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> > The color-format can be anyone of these 4 format, one color-format not
> > only represent one format, but also include the lower formats, like
> >
> > color-format preferred_color_formats
> > YCRCB420 YCRCB420 > YCRCB422 > YCRCB444 > RGB444
> > YCRCB422 YCRCB422 > YCRCB444 > RGB444
> > YCRCB444 YCRCB444 > RGB444
> > RGB444 RGB444
> >
> > Then the final color_format is calculated by 3 steps:
> > 1. calculate HW available formats.
> > avail_formats = connector_color_formats & improc->color_formats;
> > 2. filter out un-preferred format.
> > avail_formats &= preferred_color_formats;
> > 3. select the final format according to the preferred order.
> > color_format = BIT(__fls(aval_formats));
>
> Is there a specific use-case for the DT property for selecting color
> format?

Hi Brian:

Since one monitor can support mutiple color-formats, this DT property
supply a way for user to select a specific one from this supported
color-formats.

> I think in general the color format should be determined according to
> the rules in the CEA spec. There's also the drm_mode_is_420_only()
> helper we can use to determine if YCBCR420 must be used. For the cases
> where it's optional, I think we can default to RGB444.

Yes, This selection depends on the real connector supported_color-formats,
I think you misunderstand this DT, this DT color-format is not for
specifying a real output format. but a way or select order for how to
select the final output format from the mutiple color-formats of a connector.

Like the DT color-format is "YCRCR420", it indicates a select order:
YUV420 > YUV422 > YUV444 > RGB444

We use this order to select the final output-format.

> > Then the final color_format is calculated by 3 steps:
> > 1. calculate HW available formats.
> > avail_formats = connector_color_formats & improc->color_formats;

NOTE: this connector_color_formats is
drm_connector->display_info.color_formats.

> > 2. filter out un-preferred format.
> > avail_formats &= preferred_color_formats;
> > 3. select the final format according to the preferred order.
> > color_format = BIT(__fls(aval_formats));

__fls here is used for selecting as order.

>
> Thanks,
> -Brian
>
> >
> > Changes since v1:
> > Rebased to the drm-misc-next branch.
> >
> > Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> > ---
> > .../arm/display/komeda/d71/d71_component.c | 15 ++++++++-
> > .../gpu/drm/arm/display/komeda/komeda_crtc.c | 27 ++++++++++++++++
> > .../gpu/drm/arm/display/komeda/komeda_dev.c | 32 ++++++++++++++++++-
> > .../gpu/drm/arm/display/komeda/komeda_kms.h | 2 ++
> > .../drm/arm/display/komeda/komeda_pipeline.h | 3 ++
> > .../display/komeda/komeda_pipeline_state.c | 31 ++++++++++++++++++
> > .../arm/display/komeda/komeda_wb_connector.c | 5 +++
> > 7 files changed, 113 insertions(+), 2 deletions(-)
> >
> > 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 c3d29c0b051b..7b374a3b911e 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > @@ -944,13 +944,26 @@ static void d71_improc_update(struct komeda_component *c,
> > {
> > struct komeda_improc_state *st = to_improc_st(state);
> > u32 __iomem *reg = c->reg;
> > - u32 index;
> > + u32 index, mask = 0, ctrl = 0;
> >
> > for_each_changed_input(state, index)
> > malidp_write32(reg, BLK_INPUT_ID0 + index * 4,
> > to_d71_input_id(state, index));
> >
> > malidp_write32(reg, BLK_SIZE, HV_SIZE(st->hsize, st->vsize));
> > + malidp_write32(reg, IPS_DEPTH, st->color_depth);
> > +
> > + mask |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> > +
> > + /* config color format */
> > + if (st->color_format == DRM_COLOR_FORMAT_YCRCB420)
> > + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422 | IPS_CTRL_CHD420;
> > + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB422)
> > + ctrl |= IPS_CTRL_YUV | IPS_CTRL_CHD422;
> > + else if (st->color_format == DRM_COLOR_FORMAT_YCRCB444)
> > + ctrl |= IPS_CTRL_YUV;
> > +
> > + malidp_write32_mask(reg, BLK_CONTROL, mask, ctrl);
> > }
> >
> > static void d71_improc_dump(struct komeda_component *c, struct seq_file *sf)
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > index 624d257da20f..38d5cb20e908 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > @@ -18,6 +18,33 @@
> > #include "komeda_dev.h"
> > #include "komeda_kms.h"
> >
> > +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> > + u32 *color_depths, u32 *color_formats)
> > +{
> > + struct drm_connector *conn;
> > + struct drm_connector_state *conn_st;
> > + u32 conn_color_formats = ~0u;
> > + int i, min_bpc = 31, conn_bpc = 0;
> > +
> > + for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) {
> > + if (conn_st->crtc != crtc_st->crtc)
> > + continue;
> > +
> > + conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8;
> > + conn_color_formats &= conn->display_info.color_formats;
> > +
> > + if (conn_bpc < min_bpc)
> > + min_bpc = conn_bpc;
> > + }
> > +
> > + /* connector doesn't config any color_format, use RGB444 as default */
> > + if (conn_color_formats == 0)
> > + conn_color_formats = DRM_COLOR_FORMAT_RGB444;
> > +
> > + *color_depths = GENMASK(conn_bpc, 0);
> > + *color_formats = conn_color_formats;
> > +}
> > +
> > static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
> > {
> > u64 pxlclk, aclk;
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> > index 9cbcd56e54cd..bee4633cdd9f 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> > @@ -113,12 +113,34 @@ static struct attribute_group komeda_sysfs_attr_group = {
> > .attrs = komeda_sysfs_entries,
> > };
> >
> > +static int to_color_format(const char *str)
> > +{
> > + int format;
> > +
> > + if (!strncmp(str, "RGB444", 7)) {
> > + format = DRM_COLOR_FORMAT_RGB444;
> > + } else if (!strncmp(str, "YCRCB444", 9)) {
> > + format = DRM_COLOR_FORMAT_YCRCB444;
> > + } else if (!strncmp(str, "YCRCB422", 9)) {
> > + format = DRM_COLOR_FORMAT_YCRCB422;
> > + } else if (!strncmp(str, "YCRCB420", 9)) {
> > + format = DRM_COLOR_FORMAT_YCRCB420;
> > + } else {
> > + DRM_WARN("invalid color_format: %s, please set it to RGB444, YCRCB444, YCRCB422 or YCRCB420\n",
> > + str);
> > + format = DRM_COLOR_FORMAT_RGB444;
> > + }
> > +
> > + return format;
> > +}
> > +
> > static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> > {
> > struct komeda_pipeline *pipe;
> > struct clk *clk;
> > u32 pipe_id;
> > - int ret = 0;
> > + int ret = 0, color_format;
> > + const char *str;
> >
> > ret = of_property_read_u32(np, "reg", &pipe_id);
> > if (ret != 0 || pipe_id >= mdev->n_pipelines)
> > @@ -133,6 +155,14 @@ static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
> > }
> > pipe->pxlclk = clk;
> >
> > + /* fetch DT configured color-format, if not set, use RGB444 */
> > + if (!of_property_read_string(np, "color-format", &str))
> > + color_format = to_color_format(str);
> > + else
> > + color_format = DRM_COLOR_FORMAT_RGB444;
> > +
> > + pipe->improc->preferred_color_formats = (color_format << 1) - 1;
> > +
> > /* enum ports */
> > pipe->of_output_links[0] =
> > of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > index 45c498e15e7a..456f3c435719 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> > @@ -166,6 +166,8 @@ static inline bool has_flip_h(u32 rot)
> > return !!(rotation & DRM_MODE_REFLECT_X);
> > }
> >
> > +void komeda_crtc_get_color_config(struct drm_crtc_state *crtc_st,
> > + u32 *color_depths, u32 *color_formats);
> > unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st);
> >
> > int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > index a7a84e66549d..910d279ae48d 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > @@ -315,6 +315,8 @@ struct komeda_splitter_state {
> > struct komeda_improc {
> > struct komeda_component base;
> > u32 supported_color_formats; /* DRM_RGB/YUV444/YUV420*/
> > + /* the preferred order is from MSB to LSB YUV420 --> RGB444 */
> > + u32 preferred_color_formats;
> > u32 supported_color_depths; /* BIT(8) | BIT(10)*/
> > u8 supports_degamma : 1;
> > u8 supports_csc : 1;
> > @@ -323,6 +325,7 @@ struct komeda_improc {
> >
> > struct komeda_improc_state {
> > struct komeda_component_state base;
> > + u8 color_format, color_depth;
> > u16 hsize, vsize;
> > };
> >
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > index ea26bc9c2d00..5526731f5a33 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > @@ -743,6 +743,7 @@ komeda_improc_validate(struct komeda_improc *improc,
> > struct komeda_data_flow_cfg *dflow)
> > {
> > struct drm_crtc *crtc = kcrtc_st->base.crtc;
> > + struct drm_crtc_state *crtc_st = &kcrtc_st->base;
> > struct komeda_component_state *c_st;
> > struct komeda_improc_state *st;
> >
> > @@ -756,6 +757,36 @@ komeda_improc_validate(struct komeda_improc *improc,
> > st->hsize = dflow->in_w;
> > st->vsize = dflow->in_h;
> >
> > + if (drm_atomic_crtc_needs_modeset(crtc_st)) {
> > + u32 output_depths, output_formats;
> > + u32 avail_depths, avail_formats;
> > +
> > + komeda_crtc_get_color_config(crtc_st, &output_depths,
> > + &output_formats);
> > +
> > + avail_depths = output_depths & improc->supported_color_depths;
> > + if (avail_depths == 0) {
> > + DRM_DEBUG_ATOMIC("No available color depths, conn depths: 0x%x & display: 0x%x\n",
> > + output_depths,
> > + improc->supported_color_depths);
> > + return -EINVAL;
> > + }
> > +
> > + avail_formats = output_formats &
> > + improc->supported_color_formats &
> > + improc->preferred_color_formats;
> > + if (avail_formats == 0) {
> > + DRM_DEBUG_ATOMIC("No available color_formats, conn formats 0x%x & display: 0x%x & preferred: 0x%x\n",
> > + output_formats,
> > + improc->supported_color_formats,
> > + improc->preferred_color_formats);
> > + return -EINVAL;
> > + }
> > +
> > + st->color_depth = __fls(avail_depths);
> > + st->color_format = BIT(__fls(avail_formats));
> > + }
> > +
> > komeda_component_add_input(&st->base, &dflow->input, 0);
> > komeda_component_set_output(&dflow->input, &improc->base, 0);
> >
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > index 617e1f7b8472..49e5469ba48e 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> > @@ -142,6 +142,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> > struct komeda_dev *mdev = kms->base.dev_private;
> > struct komeda_wb_connector *kwb_conn;
> > struct drm_writeback_connector *wb_conn;
> > + struct drm_display_info *info;
> > u32 *formats, n_formats = 0;
> > int err;
> >
> > @@ -171,6 +172,10 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
> >
> > drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
> >
> > + info = &kwb_conn->base.base.display_info;
> > + info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
> > + info->color_formats = kcrtc->master->improc->supported_color_formats;
> > +
> > kcrtc->wb_conn = kwb_conn;
> >
> > return 0;
> > --
> > 2.17.1
> >

2019-09-26 09:27:29

by Brian Starkey

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

Hi James,

On Tue, Sep 24, 2019 at 02:13:27AM +0000, james qian wang (Arm Technology China) wrote:
>
> Hi Brian:
>
> Since one monitor can support mutiple color-formats, this DT property
> supply a way for user to select a specific one from this supported
> color-formats.

Modifying DT is a _really_ user-unfriendly way of specifying
preferences. If we want a user to be able to pick a preferred format,
then it should probably be via the atomic API as Ville mentioned.

Cheers,
-Brian

2019-09-27 02:26:52

by James Qian Wang

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

On Wed, Sep 25, 2019 at 09:48:11AM +0000, Brian Starkey wrote:
> Hi James,
>
> On Tue, Sep 24, 2019 at 02:13:27AM +0000, james qian wang (Arm Technology China) wrote:
> >
> > Hi Brian:
> >
> > Since one monitor can support mutiple color-formats, this DT property
> > supply a way for user to select a specific one from this supported
> > color-formats.
>
> Modifying DT is a _really_ user-unfriendly way of specifying
> preferences. If we want a user to be able to pick a preferred format,
> then it should probably be via the atomic API as Ville mentioned.
>

Hi Brian:

Agree, a drm UPAI might be the best & right way for this.

I can raise a new thread/topic to discuss the "HOW TO", maybe after the
Chinese national day.

LAST:
what do you think about this patch:
- Just drop it, waiting for the new uapi
- or keep it, and replace it once new uapi is ready.

Thanks
James

> Cheers,
> -Brian

2019-09-30 10:41:42

by Brian Starkey

[permalink] [raw]
Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

On Fri, Sep 27, 2019 at 02:22:24AM +0000, james qian wang (Arm Technology China) wrote:
> On Wed, Sep 25, 2019 at 09:48:11AM +0000, Brian Starkey wrote:
> > Hi James,
> >
> > On Tue, Sep 24, 2019 at 02:13:27AM +0000, james qian wang (Arm Technology China) wrote:
> > >
> > > Hi Brian:
> > >
> > > Since one monitor can support mutiple color-formats, this DT property
> > > supply a way for user to select a specific one from this supported
> > > color-formats.
> >
> > Modifying DT is a _really_ user-unfriendly way of specifying
> > preferences. If we want a user to be able to pick a preferred format,
> > then it should probably be via the atomic API as Ville mentioned.
> >
>
> Hi Brian:
>
> Agree, a drm UPAI might be the best & right way for this.
>
> I can raise a new thread/topic to discuss the "HOW TO", maybe after the
> Chinese national day.
>
> LAST:
> what do you think about this patch:
> - Just drop it, waiting for the new uapi
> - or keep it, and replace it once new uapi is ready.

The bit-depth stuff is clear and non-controversial, so you could split
that out and merge it.

For the YUV stuff, I think it would be fine to merge the
implementation that we discussed here - force YUV for modes which must
be YUV, and leave the user-preference stuff for a later UAPI.

Thanks,
-Brian

>
> Thanks
> James
>
> > Cheers,
> > -Brian

Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

On Mon, Sep 30, 2019 at 10:36:27AM +0000, Brian Starkey wrote:
> On Fri, Sep 27, 2019 at 02:22:24AM +0000, james qian wang (Arm Technology China) wrote:
> > On Wed, Sep 25, 2019 at 09:48:11AM +0000, Brian Starkey wrote:
> > > Hi James,
> > >
> > > On Tue, Sep 24, 2019 at 02:13:27AM +0000, james qian wang (Arm Technology China) wrote:
> > > >
> > > > Hi Brian:
> > > >
> > > > Since one monitor can support mutiple color-formats, this DT property
> > > > supply a way for user to select a specific one from this supported
> > > > color-formats.
> > >
> > > Modifying DT is a _really_ user-unfriendly way of specifying
> > > preferences. If we want a user to be able to pick a preferred format,
> > > then it should probably be via the atomic API as Ville mentioned.
> > >
> >
> > Hi Brian:
> >
> > Agree, a drm UPAI might be the best & right way for this.
> >
> > I can raise a new thread/topic to discuss the "HOW TO", maybe after the
> > Chinese national day.
> >
> > LAST:
> > what do you think about this patch:
> > - Just drop it, waiting for the new uapi
> > - or keep it, and replace it once new uapi is ready.
>
> The bit-depth stuff is clear and non-controversial, so you could split
> that out and merge it.
>
> For the YUV stuff, I think it would be fine to merge the
> implementation that we discussed here - force YUV for modes which must
> be YUV, and leave the user-preference stuff for a later UAPI.
>
> Thanks,
> -Brian
>
Hi Brian,
We've split color depth out. Thanks for your comments.
https://patchwork.freedesktop.org/series/67730/

Regards,
Lowry
> >
> > Thanks
> > James
> >
> > > Cheers,
> > > -Brian

Subject: Re: [PATCH] drm/komeda: Adds output-color format/depth support

Hi Brian,
On Mon, Sep 30, 2019 at 10:36:27AM +0000, Brian Starkey wrote:
> On Fri, Sep 27, 2019 at 02:22:24AM +0000, james qian wang (Arm Technology China) wrote:
> > On Wed, Sep 25, 2019 at 09:48:11AM +0000, Brian Starkey wrote:
> > > Hi James,
> > >
> > > On Tue, Sep 24, 2019 at 02:13:27AM +0000, james qian wang (Arm Technology China) wrote:
> > > >
> > > > Hi Brian:
> > > >
> > > > Since one monitor can support mutiple color-formats, this DT property
> > > > supply a way for user to select a specific one from this supported
> > > > color-formats.
> > >
> > > Modifying DT is a _really_ user-unfriendly way of specifying
> > > preferences. If we want a user to be able to pick a preferred format,
> > > then it should probably be via the atomic API as Ville mentioned.
> > >
> >
> > Hi Brian:
> >
> > Agree, a drm UPAI might be the best & right way for this.
> >
> > I can raise a new thread/topic to discuss the "HOW TO", maybe after the
> > Chinese national day.
> >
> > LAST:
> > what do you think about this patch:
> > - Just drop it, waiting for the new uapi
> > - or keep it, and replace it once new uapi is ready.
>
> The bit-depth stuff is clear and non-controversial, so you could split
> that out and merge it.
>
> For the YUV stuff, I think it would be fine to merge the
> implementation that we discussed here - force YUV for modes which must
> be YUV, and leave the user-preference stuff for a later UAPI.
>
> Thanks,
> -Brian
This patch has been split to two patches and this will be dropped.
Output bit-depth : https://patchwork.freedesktop.org/series/67730/
Output color format: https://patchwork.freedesktop.org/series/68012/

Regards,
Lowry
> >
> > Thanks
> > James
> >
> > > Cheers,
> > > -Brian