This series enable CRTC color-mgmt for komeda driver, for current komeda HW
which only supports color conversion and forward gamma for CRTC.
This series actually are regrouped from:
- drm/komeda: Enable layer/plane color-mgmt:
https://patchwork.freedesktop.org/series/60893/
- drm/komeda: Enable CRTC color-mgmt
https://patchwork.freedesktop.org/series/61370/
For removing the dependence on:
- https://patchwork.freedesktop.org/series/30876/
Lowry Li (Arm Technology China) (1):
drm/komeda: Adds gamma and color-transform support for DOU-IPS
james qian wang (Arm Technology China) (3):
drm/komeda: Add a new helper drm_color_ctm_s31_32_to_qm_n()
drm/komeda: Add drm_lut_to_fgamma_coeffs()
drm/komeda: Add drm_ctm_to_coeffs()
v2:
Move the fixpoint conversion function s31_32_to_q2_12() to drm core
as a shared helper.
.../arm/display/komeda/d71/d71_component.c | 24 +++++++
.../arm/display/komeda/komeda_color_mgmt.c | 66 +++++++++++++++++++
.../arm/display/komeda/komeda_color_mgmt.h | 10 ++-
.../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 +
.../drm/arm/display/komeda/komeda_pipeline.h | 3 +
.../display/komeda/komeda_pipeline_state.c | 6 ++
drivers/gpu/drm/drm_color_mgmt.c | 23 +++++++
include/drm/drm_color_mgmt.h | 2 +
8 files changed, 135 insertions(+), 1 deletion(-)
--
2.20.1
This function is for converting drm_color_ctm matrix to komeda hardware
required required Q2.12 2's complement CSC matrix.
v2:
Move the fixpoint conversion function s31_32_to_q2_12() to drm core
as a shared helper.
Signed-off-by: james qian wang (Arm Technology China) <[email protected]>
---
.../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 14 ++++++++++++++
.../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
index c180ce70c26c..ad668accbdf4 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
@@ -117,3 +117,17 @@ void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs)
{
drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl));
}
+
+void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs)
+{
+ struct drm_color_ctm *ctm;
+ u32 i;
+
+ if (!ctm_blob)
+ return;
+
+ ctm = ctm_blob->data;
+
+ for (i = 0; i < KOMEDA_N_CTM_COEFFS; i++)
+ coeffs[i] = drm_color_ctm_s31_32_to_qm_n(ctm->matrix[i], 2, 12);
+}
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
index 08ab69281648..2f4668466112 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
@@ -18,6 +18,7 @@
#define KOMEDA_N_CTM_COEFFS 9
void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs);
+void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs);
const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range);
--
2.20.1
From: "Lowry Li (Arm Technology China)" <[email protected]>
Adds gamma and color-transform support for DOU-IPS.
Adds two caps members fgamma_coeffs and ctm_coeffs to komeda_improc_state.
If color management changed, set gamma and color-transform accordingly.
Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
---
.../arm/display/komeda/d71/d71_component.c | 24 +++++++++++++++++++
.../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
.../drm/arm/display/komeda/komeda_pipeline.h | 3 +++
.../display/komeda/komeda_pipeline_state.c | 6 +++++
4 files changed, 35 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 c3d29c0b051b..e7e5a8e4430e 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
@@ -942,15 +942,39 @@ static int d71_merger_init(struct d71_dev *d71,
static void d71_improc_update(struct komeda_component *c,
struct komeda_component_state *state)
{
+ struct drm_crtc_state *crtc_st = state->crtc->state;
struct komeda_improc_state *st = to_improc_st(state);
+ struct d71_pipeline *pipe = to_d71_pipeline(c->pipeline);
u32 __iomem *reg = c->reg;
u32 index;
+ u32 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));
+
+ if (crtc_st->color_mgmt_changed) {
+ mask |= IPS_CTRL_FT | IPS_CTRL_RGB;
+
+ if (crtc_st->gamma_lut) {
+ malidp_write_group(pipe->dou_ft_coeff_addr, FT_COEFF0,
+ KOMEDA_N_GAMMA_COEFFS,
+ st->fgamma_coeffs);
+ ctrl |= IPS_CTRL_FT; /* enable gamma */
+ }
+
+ if (crtc_st->ctm) {
+ malidp_write_group(reg, IPS_RGB_RGB_COEFF0,
+ KOMEDA_N_CTM_COEFFS,
+ st->ctm_coeffs);
+ ctrl |= IPS_CTRL_RGB; /* enable gamut */
+ }
+ }
+
+ if (mask)
+ 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 9beeda04818b..406b9d0ca058 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -590,6 +590,8 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms,
crtc->port = kcrtc->master->of_output_port;
+ drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE);
+
return err;
}
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
index b322f52ba8f2..c5ab8096c85d 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
@@ -11,6 +11,7 @@
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include "malidp_utils.h"
+#include "komeda_color_mgmt.h"
#define KOMEDA_MAX_PIPELINES 2
#define KOMEDA_PIPELINE_MAX_LAYERS 4
@@ -324,6 +325,8 @@ struct komeda_improc {
struct komeda_improc_state {
struct komeda_component_state base;
u16 hsize, vsize;
+ u32 fgamma_coeffs[KOMEDA_N_GAMMA_COEFFS];
+ u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS];
};
/* display timing controller */
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 0ba9c6aa3708..4a40b37eb1a6 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
@@ -756,6 +756,12 @@ komeda_improc_validate(struct komeda_improc *improc,
st->hsize = dflow->in_w;
st->vsize = dflow->in_h;
+ if (kcrtc_st->base.color_mgmt_changed) {
+ drm_lut_to_fgamma_coeffs(kcrtc_st->base.gamma_lut,
+ st->fgamma_coeffs);
+ drm_ctm_to_coeffs(kcrtc_st->base.ctm, st->ctm_coeffs);
+ }
+
komeda_component_add_input(&st->base, &dflow->input, 0);
komeda_component_set_output(&dflow->input, &improc->base, 0);
--
2.20.1
On Friday, 11 October 2019 06:45:42 BST james qian wang (Arm Technology China) wrote:
> This function is for converting drm_color_ctm matrix to komeda hardware
> required required Q2.12 2's complement CSC matrix.
>
> v2:
> Move the fixpoint conversion function s31_32_to_q2_12() to drm core
> as a shared helper.
>
> Signed-off-by: james qian wang (Arm Technology China) <[email protected]>
> ---
> .../gpu/drm/arm/display/komeda/komeda_color_mgmt.c | 14 ++++++++++++++
> .../gpu/drm/arm/display/komeda/komeda_color_mgmt.h | 1 +
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
> index c180ce70c26c..ad668accbdf4 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.c
> @@ -117,3 +117,17 @@ void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs)
> {
> drm_lut_to_coeffs(lut_blob, coeffs, sector_tbl, ARRAY_SIZE(sector_tbl));
> }
> +
> +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs)
[nit] Could do with an extra const or two on the drm_property_blob,
otherwise...
> +{
> + struct drm_color_ctm *ctm;
> + u32 i;
> +
> + if (!ctm_blob)
> + return;
> +
> + ctm = ctm_blob->data;
> +
> + for (i = 0; i < KOMEDA_N_CTM_COEFFS; i++)
> + coeffs[i] = drm_color_ctm_s31_32_to_qm_n(ctm->matrix[i], 2, 12);
> +}
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
> index 08ab69281648..2f4668466112 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_color_mgmt.h
> @@ -18,6 +18,7 @@
> #define KOMEDA_N_CTM_COEFFS 9
>
> void drm_lut_to_fgamma_coeffs(struct drm_property_blob *lut_blob, u32 *coeffs);
> +void drm_ctm_to_coeffs(struct drm_property_blob *ctm_blob, u32 *coeffs);
>
> const s32 *komeda_select_yuv2rgb_coeffs(u32 color_encoding, u32 color_range);
>
>
...
Reviewed-by: Mihail Atanassov <[email protected]>
--
Mihail
Hi James, Lowry,
On Friday, 11 October 2019 06:45:50 BST james qian wang (Arm Technology China) wrote:
> From: "Lowry Li (Arm Technology China)" <[email protected]>
>
> Adds gamma and color-transform support for DOU-IPS.
> Adds two caps members fgamma_coeffs and ctm_coeffs to komeda_improc_state.
> If color management changed, set gamma and color-transform accordingly.
>
> Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> ---
> .../arm/display/komeda/d71/d71_component.c | 24 +++++++++++++++++++
> .../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
> .../drm/arm/display/komeda/komeda_pipeline.h | 3 +++
> .../display/komeda/komeda_pipeline_state.c | 6 +++++
> 4 files changed, 35 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 c3d29c0b051b..e7e5a8e4430e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -942,15 +942,39 @@ static int d71_merger_init(struct d71_dev *d71,
> static void d71_improc_update(struct komeda_component *c,
> struct komeda_component_state *state)
> {
> + struct drm_crtc_state *crtc_st = state->crtc->state;
I'm not sure it's a good idea to introduce a dependency on drm state
so far down in the HW funcs, is there a good reason for the direct prod?
> struct komeda_improc_state *st = to_improc_st(state);
> + struct d71_pipeline *pipe = to_d71_pipeline(c->pipeline);
> u32 __iomem *reg = c->reg;
> u32 index;
> + u32 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));
> +
> + if (crtc_st->color_mgmt_changed) {
> + mask |= IPS_CTRL_FT | IPS_CTRL_RGB;
> +
> + if (crtc_st->gamma_lut) {
> + malidp_write_group(pipe->dou_ft_coeff_addr, FT_COEFF0,
> + KOMEDA_N_GAMMA_COEFFS,
> + st->fgamma_coeffs);
> + ctrl |= IPS_CTRL_FT; /* enable gamma */
> + }
> +
> + if (crtc_st->ctm) {
> + malidp_write_group(reg, IPS_RGB_RGB_COEFF0,
> + KOMEDA_N_CTM_COEFFS,
> + st->ctm_coeffs);
> + ctrl |= IPS_CTRL_RGB; /* enable gamut */
> + }
> + }
> +
> + if (mask)
> + 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 9beeda04818b..406b9d0ca058 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -590,6 +590,8 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms,
>
> crtc->port = kcrtc->master->of_output_port;
>
> + drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE);
> +
> return err;
> }
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> index b322f52ba8f2..c5ab8096c85d 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> @@ -11,6 +11,7 @@
> #include <drm/drm_atomic.h>
> #include <drm/drm_atomic_helper.h>
> #include "malidp_utils.h"
> +#include "komeda_color_mgmt.h"
>
> #define KOMEDA_MAX_PIPELINES 2
> #define KOMEDA_PIPELINE_MAX_LAYERS 4
> @@ -324,6 +325,8 @@ struct komeda_improc {
> struct komeda_improc_state {
> struct komeda_component_state base;
> u16 hsize, vsize;
> + u32 fgamma_coeffs[KOMEDA_N_GAMMA_COEFFS];
> + u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS];
> };
>
> /* display timing controller */
> 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 0ba9c6aa3708..4a40b37eb1a6 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> @@ -756,6 +756,12 @@ komeda_improc_validate(struct komeda_improc *improc,
> st->hsize = dflow->in_w;
> st->vsize = dflow->in_h;
>
> + if (kcrtc_st->base.color_mgmt_changed) {
> + drm_lut_to_fgamma_coeffs(kcrtc_st->base.gamma_lut,
> + st->fgamma_coeffs);
> + drm_ctm_to_coeffs(kcrtc_st->base.ctm, st->ctm_coeffs);
> + }
> +
> komeda_component_add_input(&st->base, &dflow->input, 0);
> komeda_component_set_output(&dflow->input, &improc->base, 0);
>
>
--
Mihail
Hi Mihail,
On Fri, Oct 11, 2019 at 08:54:03AM +0000, Mihail Atanassov wrote:
> Hi James, Lowry,
>
> On Friday, 11 October 2019 06:45:50 BST james qian wang (Arm Technology China) wrote:
> > From: "Lowry Li (Arm Technology China)" <[email protected]>
> >
> > Adds gamma and color-transform support for DOU-IPS.
> > Adds two caps members fgamma_coeffs and ctm_coeffs to komeda_improc_state.
> > If color management changed, set gamma and color-transform accordingly.
> >
> > Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> > ---
> > .../arm/display/komeda/d71/d71_component.c | 24 +++++++++++++++++++
> > .../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
> > .../drm/arm/display/komeda/komeda_pipeline.h | 3 +++
> > .../display/komeda/komeda_pipeline_state.c | 6 +++++
> > 4 files changed, 35 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 c3d29c0b051b..e7e5a8e4430e 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > @@ -942,15 +942,39 @@ static int d71_merger_init(struct d71_dev *d71,
> > static void d71_improc_update(struct komeda_component *c,
> > struct komeda_component_state *state)
> > {
> > + struct drm_crtc_state *crtc_st = state->crtc->state;
> I'm not sure it's a good idea to introduce a dependency on drm state
> so far down in the HW funcs, is there a good reason for the direct prod?
We dicussed about this before. To decide using this way is to avoid of
duplicated state between DRM and Komeda.
Regards,
Lowry
> > struct komeda_improc_state *st = to_improc_st(state);
> > + struct d71_pipeline *pipe = to_d71_pipeline(c->pipeline);
> > u32 __iomem *reg = c->reg;
> > u32 index;
> > + u32 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));
> > +
> > + if (crtc_st->color_mgmt_changed) {
> > + mask |= IPS_CTRL_FT | IPS_CTRL_RGB;
> > +
> > + if (crtc_st->gamma_lut) {
> > + malidp_write_group(pipe->dou_ft_coeff_addr, FT_COEFF0,
> > + KOMEDA_N_GAMMA_COEFFS,
> > + st->fgamma_coeffs);
> > + ctrl |= IPS_CTRL_FT; /* enable gamma */
> > + }
> > +
> > + if (crtc_st->ctm) {
> > + malidp_write_group(reg, IPS_RGB_RGB_COEFF0,
> > + KOMEDA_N_CTM_COEFFS,
> > + st->ctm_coeffs);
> > + ctrl |= IPS_CTRL_RGB; /* enable gamut */
> > + }
> > + }
> > +
> > + if (mask)
> > + 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 9beeda04818b..406b9d0ca058 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > @@ -590,6 +590,8 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms,
> >
> > crtc->port = kcrtc->master->of_output_port;
> >
> > + drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE);
> > +
> > return err;
> > }
> >
> > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > index b322f52ba8f2..c5ab8096c85d 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > @@ -11,6 +11,7 @@
> > #include <drm/drm_atomic.h>
> > #include <drm/drm_atomic_helper.h>
> > #include "malidp_utils.h"
> > +#include "komeda_color_mgmt.h"
> >
> > #define KOMEDA_MAX_PIPELINES 2
> > #define KOMEDA_PIPELINE_MAX_LAYERS 4
> > @@ -324,6 +325,8 @@ struct komeda_improc {
> > struct komeda_improc_state {
> > struct komeda_component_state base;
> > u16 hsize, vsize;
> > + u32 fgamma_coeffs[KOMEDA_N_GAMMA_COEFFS];
> > + u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS];
> > };
> >
> > /* display timing controller */
> > 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 0ba9c6aa3708..4a40b37eb1a6 100644
> > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > @@ -756,6 +756,12 @@ komeda_improc_validate(struct komeda_improc *improc,
> > st->hsize = dflow->in_w;
> > st->vsize = dflow->in_h;
> >
> > + if (kcrtc_st->base.color_mgmt_changed) {
> > + drm_lut_to_fgamma_coeffs(kcrtc_st->base.gamma_lut,
> > + st->fgamma_coeffs);
> > + drm_ctm_to_coeffs(kcrtc_st->base.ctm, st->ctm_coeffs);
> > + }
> > +
> > komeda_component_add_input(&st->base, &dflow->input, 0);
> > komeda_component_set_output(&dflow->input, &improc->base, 0);
> >
> >
>
>
> --
> Mihail
>
>
On Friday, 11 October 2019 11:12:51 BST Lowry Li (Arm Technology China) wrote:
> Hi Mihail,
> On Fri, Oct 11, 2019 at 08:54:03AM +0000, Mihail Atanassov wrote:
> > Hi James, Lowry,
> >
> > On Friday, 11 October 2019 06:45:50 BST james qian wang (Arm Technology China) wrote:
> > > From: "Lowry Li (Arm Technology China)" <[email protected]>
> > >
> > > Adds gamma and color-transform support for DOU-IPS.
> > > Adds two caps members fgamma_coeffs and ctm_coeffs to komeda_improc_state.
> > > If color management changed, set gamma and color-transform accordingly.
> > >
> > > Signed-off-by: Lowry Li (Arm Technology China) <[email protected]>
> > > ---
> > > .../arm/display/komeda/d71/d71_component.c | 24 +++++++++++++++++++
> > > .../gpu/drm/arm/display/komeda/komeda_crtc.c | 2 ++
> > > .../drm/arm/display/komeda/komeda_pipeline.h | 3 +++
> > > .../display/komeda/komeda_pipeline_state.c | 6 +++++
> > > 4 files changed, 35 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 c3d29c0b051b..e7e5a8e4430e 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> > > @@ -942,15 +942,39 @@ static int d71_merger_init(struct d71_dev *d71,
> > > static void d71_improc_update(struct komeda_component *c,
> > > struct komeda_component_state *state)
> > > {
> > > + struct drm_crtc_state *crtc_st = state->crtc->state;
> > I'm not sure it's a good idea to introduce a dependency on drm state
> > so far down in the HW funcs, is there a good reason for the direct prod?
> We dicussed about this before. To decide using this way is to avoid of
> duplicated state between DRM and Komeda.
Fair, r-b me.
>
> Regards,
> Lowry
> > > struct komeda_improc_state *st = to_improc_st(state);
> > > + struct d71_pipeline *pipe = to_d71_pipeline(c->pipeline);
> > > u32 __iomem *reg = c->reg;
> > > u32 index;
> > > + u32 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));
> > > +
> > > + if (crtc_st->color_mgmt_changed) {
> > > + mask |= IPS_CTRL_FT | IPS_CTRL_RGB;
> > > +
> > > + if (crtc_st->gamma_lut) {
> > > + malidp_write_group(pipe->dou_ft_coeff_addr, FT_COEFF0,
> > > + KOMEDA_N_GAMMA_COEFFS,
> > > + st->fgamma_coeffs);
> > > + ctrl |= IPS_CTRL_FT; /* enable gamma */
> > > + }
> > > +
> > > + if (crtc_st->ctm) {
> > > + malidp_write_group(reg, IPS_RGB_RGB_COEFF0,
> > > + KOMEDA_N_CTM_COEFFS,
> > > + st->ctm_coeffs);
> > > + ctrl |= IPS_CTRL_RGB; /* enable gamut */
> > > + }
> > > + }
> > > +
> > > + if (mask)
> > > + 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 9beeda04818b..406b9d0ca058 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> > > @@ -590,6 +590,8 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms,
> > >
> > > crtc->port = kcrtc->master->of_output_port;
> > >
> > > + drm_crtc_enable_color_mgmt(crtc, 0, true, KOMEDA_COLOR_LUT_SIZE);
> > > +
> > > return err;
> > > }
> > >
> > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > > index b322f52ba8f2..c5ab8096c85d 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h
> > > @@ -11,6 +11,7 @@
> > > #include <drm/drm_atomic.h>
> > > #include <drm/drm_atomic_helper.h>
> > > #include "malidp_utils.h"
> > > +#include "komeda_color_mgmt.h"
> > >
> > > #define KOMEDA_MAX_PIPELINES 2
> > > #define KOMEDA_PIPELINE_MAX_LAYERS 4
> > > @@ -324,6 +325,8 @@ struct komeda_improc {
> > > struct komeda_improc_state {
> > > struct komeda_component_state base;
> > > u16 hsize, vsize;
> > > + u32 fgamma_coeffs[KOMEDA_N_GAMMA_COEFFS];
> > > + u32 ctm_coeffs[KOMEDA_N_CTM_COEFFS];
> > > };
> > >
> > > /* display timing controller */
> > > 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 0ba9c6aa3708..4a40b37eb1a6 100644
> > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> > > @@ -756,6 +756,12 @@ komeda_improc_validate(struct komeda_improc *improc,
> > > st->hsize = dflow->in_w;
> > > st->vsize = dflow->in_h;
> > >
> > > + if (kcrtc_st->base.color_mgmt_changed) {
> > > + drm_lut_to_fgamma_coeffs(kcrtc_st->base.gamma_lut,
> > > + st->fgamma_coeffs);
> > > + drm_ctm_to_coeffs(kcrtc_st->base.ctm, st->ctm_coeffs);
> > > + }
> > > +
> > > komeda_component_add_input(&st->base, &dflow->input, 0);
> > > komeda_component_set_output(&dflow->input, &improc->base, 0);
> > >
> > >
> >
> >
>
--
Mihail