* [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, harry.wentland, tzimmermann, sunpeng.li,
maarten.lankhorst, Sebastian Wick, mripard, Melissa Wen,
Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
Hello, this series is based on the RFC sent by Melssa Wen:
"[RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface"
https://lore.kernel.org/dri-devel/20230109143846.1966301-1-mwen@igalia.com/
that introduces CRTC properties to control 3D LUT operations.
The R-Car DU peripheral has a post-blending color management pipeline (CMM)
composed by (in order of processing) a 3D LUT a 1D LUT and a Color conversion
unit.
The CMM driver already supported operating the 1D LUT, this series add support
for the cubic LUT (named CLU).
I've been made aware by Melissa and Pekka that the focus of upstream for
color management properties is now on the definition of the "Plane color
pipeline" properties
https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
Unfortunately the model there proposed doesn't match the R-Car DU hardware which
has color management at the post-blending level and not per plane (I've cc-ed
all the receivers of that series, just in case).
The user-space interface has been validated with dedicated unit tests for
the R-Car DU test suite (kms-test) which are available at:
https://git.sr.ht/~jmondi_/kms-test
The series validates the usage of the HW interface in the hope of re-starting
discussions and interests in the definition of CRTC color management
properties.
Thanks
j
Alex Hung (1):
drm: Add 3D LUT mode and its attributes
Jacopo Mondi (1):
drm: rcar-du: crtc: Enable 3D LUT
Kieran Bingham (2):
drm: rcar-du: cmm: Provide 3D-CLU support
drm: rcar-du: kms: Configure the CLU
Laurent Pinchart (1):
drm: rcar-du: cmm: Refactor LUT configuration
Melissa Wen (4):
drm/drm_color_mgmt: add shaper LUT to color mgmt properties
drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
drm/drm_color_mgmt: add function to create 3D LUT modes supported
drm/drm_color_mgmt: add function to attach 3D LUT props
drivers/gpu/drm/drm_atomic_state_helper.c | 7 ++
drivers/gpu/drm/drm_atomic_uapi.c | 24 ++++
drivers/gpu/drm/drm_color_mgmt.c | 113 +++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 5 +
drivers/gpu/drm/drm_mode_config.c | 21 ++++
drivers/gpu/drm/rcar-du/rcar_cmm.c | 127 ++++++++++++++++------
drivers/gpu/drm/rcar-du/rcar_cmm.h | 36 +++++-
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 68 +++++++++---
include/drm/drm_color_mgmt.h | 7 ++
include/drm/drm_crtc.h | 32 +++++-
include/drm/drm_mode_config.h | 25 +++++
include/drm/drm_mode_object.h | 2 +-
include/uapi/drm/drm_mode.h | 17 +++
13 files changed, 428 insertions(+), 56 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 33+ messages in thread
* [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
Hello, this series is based on the RFC sent by Melssa Wen:
"[RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface"
https://lore.kernel.org/dri-devel/20230109143846.1966301-1-mwen@igalia.com/
that introduces CRTC properties to control 3D LUT operations.
The R-Car DU peripheral has a post-blending color management pipeline (CMM)
composed by (in order of processing) a 3D LUT a 1D LUT and a Color conversion
unit.
The CMM driver already supported operating the 1D LUT, this series add support
for the cubic LUT (named CLU).
I've been made aware by Melissa and Pekka that the focus of upstream for
color management properties is now on the definition of the "Plane color
pipeline" properties
https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
Unfortunately the model there proposed doesn't match the R-Car DU hardware which
has color management at the post-blending level and not per plane (I've cc-ed
all the receivers of that series, just in case).
The user-space interface has been validated with dedicated unit tests for
the R-Car DU test suite (kms-test) which are available at:
https://git.sr.ht/~jmondi_/kms-test
The series validates the usage of the HW interface in the hope of re-starting
discussions and interests in the definition of CRTC color management
properties.
Thanks
j
Alex Hung (1):
drm: Add 3D LUT mode and its attributes
Jacopo Mondi (1):
drm: rcar-du: crtc: Enable 3D LUT
Kieran Bingham (2):
drm: rcar-du: cmm: Provide 3D-CLU support
drm: rcar-du: kms: Configure the CLU
Laurent Pinchart (1):
drm: rcar-du: cmm: Refactor LUT configuration
Melissa Wen (4):
drm/drm_color_mgmt: add shaper LUT to color mgmt properties
drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
drm/drm_color_mgmt: add function to create 3D LUT modes supported
drm/drm_color_mgmt: add function to attach 3D LUT props
drivers/gpu/drm/drm_atomic_state_helper.c | 7 ++
drivers/gpu/drm/drm_atomic_uapi.c | 24 ++++
drivers/gpu/drm/drm_color_mgmt.c | 113 +++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 5 +
drivers/gpu/drm/drm_mode_config.c | 21 ++++
drivers/gpu/drm/rcar-du/rcar_cmm.c | 127 ++++++++++++++++------
drivers/gpu/drm/rcar-du/rcar_cmm.h | 36 +++++-
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 68 +++++++++---
include/drm/drm_color_mgmt.h | 7 ++
include/drm/drm_crtc.h | 32 +++++-
include/drm/drm_mode_config.h | 25 +++++
include/drm/drm_mode_object.h | 2 +-
include/uapi/drm/drm_mode.h | 17 +++
13 files changed, 428 insertions(+), 56 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 33+ messages in thread
* [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, tzimmermann, sunpeng.li, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, alexander.deucher, christian.koenig,
Joshua Ashton
Hello, this series is based on the RFC sent by Melssa Wen:
"[RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface"
https://lore.kernel.org/dri-devel/20230109143846.1966301-1-mwen@igalia.com/
that introduces CRTC properties to control 3D LUT operations.
The R-Car DU peripheral has a post-blending color management pipeline (CMM)
composed by (in order of processing) a 3D LUT a 1D LUT and a Color conversion
unit.
The CMM driver already supported operating the 1D LUT, this series add support
for the cubic LUT (named CLU).
I've been made aware by Melissa and Pekka that the focus of upstream for
color management properties is now on the definition of the "Plane color
pipeline" properties
https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
Unfortunately the model there proposed doesn't match the R-Car DU hardware which
has color management at the post-blending level and not per plane (I've cc-ed
all the receivers of that series, just in case).
The user-space interface has been validated with dedicated unit tests for
the R-Car DU test suite (kms-test) which are available at:
https://git.sr.ht/~jmondi_/kms-test
The series validates the usage of the HW interface in the hope of re-starting
discussions and interests in the definition of CRTC color management
properties.
Thanks
j
Alex Hung (1):
drm: Add 3D LUT mode and its attributes
Jacopo Mondi (1):
drm: rcar-du: crtc: Enable 3D LUT
Kieran Bingham (2):
drm: rcar-du: cmm: Provide 3D-CLU support
drm: rcar-du: kms: Configure the CLU
Laurent Pinchart (1):
drm: rcar-du: cmm: Refactor LUT configuration
Melissa Wen (4):
drm/drm_color_mgmt: add shaper LUT to color mgmt properties
drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
drm/drm_color_mgmt: add function to create 3D LUT modes supported
drm/drm_color_mgmt: add function to attach 3D LUT props
drivers/gpu/drm/drm_atomic_state_helper.c | 7 ++
drivers/gpu/drm/drm_atomic_uapi.c | 24 ++++
drivers/gpu/drm/drm_color_mgmt.c | 113 +++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 5 +
drivers/gpu/drm/drm_mode_config.c | 21 ++++
drivers/gpu/drm/rcar-du/rcar_cmm.c | 127 ++++++++++++++++------
drivers/gpu/drm/rcar-du/rcar_cmm.h | 36 +++++-
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 68 +++++++++---
include/drm/drm_color_mgmt.h | 7 ++
include/drm/drm_crtc.h | 32 +++++-
include/drm/drm_mode_config.h | 25 +++++
include/drm/drm_mode_object.h | 2 +-
include/uapi/drm/drm_mode.h | 17 +++
13 files changed, 428 insertions(+), 56 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 33+ messages in thread
* [RFC 1/9] drm: Add 3D LUT mode and its attributes
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Alex Hung,
Jonas Ådahl, Uma Shankar, harry.wentland, tzimmermann,
sunpeng.li, maarten.lankhorst, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan,
xaver.hugl, linux-renesas-soc, daniel, alexander.deucher,
christian.koenig, Joshua Ashton
From: Alex Hung <alex.hung@amd.com>
A struct is defined for 3D LUT modes to be supported by hardware.
The elements includes lut_size, lut_stride, bit_depth, color_format
and flags.
Note: A patchset "IGT tests for pre-blending 3D LUT interfaces" for this
proposal is sent to IGT mailing list.
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
include/uapi/drm/drm_mode.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 43691058d28f..3b40694259c7 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -854,6 +854,23 @@ struct drm_color_lut {
__u16 reserved;
};
+/*
+ * struct drm_mode_lut3d_mode - 3D LUT mode information.
+ * @lut_size: number of valid points on every dimension of 3D LUT.
+ * @lut_stride: number of points on every dimension of 3D LUT.
+ * @bit_depth: number of bits of RGB. If color_mode defines entries with higher
+ * bit_depth the least significant bits will be truncated.
+ * @color_format: fourcc values, ex. DRM_FORMAT_XRGB16161616 or DRM_FORMAT_XBGR16161616.
+ * @flags: flags for hardware-sepcific features
+ */
+struct drm_mode_lut3d_mode {
+ __u16 lut_size;
+ __u16 lut_stride[3];
+ __u16 bit_depth;
+ __u32 color_format;
+ __u32 flags;
+};
+
/**
* struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
*
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 1/9] drm: Add 3D LUT mode and its attributes
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc, Alex Hung
From: Alex Hung <alex.hung@amd.com>
A struct is defined for 3D LUT modes to be supported by hardware.
The elements includes lut_size, lut_stride, bit_depth, color_format
and flags.
Note: A patchset "IGT tests for pre-blending 3D LUT interfaces" for this
proposal is sent to IGT mailing list.
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
include/uapi/drm/drm_mode.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 43691058d28f..3b40694259c7 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -854,6 +854,23 @@ struct drm_color_lut {
__u16 reserved;
};
+/*
+ * struct drm_mode_lut3d_mode - 3D LUT mode information.
+ * @lut_size: number of valid points on every dimension of 3D LUT.
+ * @lut_stride: number of points on every dimension of 3D LUT.
+ * @bit_depth: number of bits of RGB. If color_mode defines entries with higher
+ * bit_depth the least significant bits will be truncated.
+ * @color_format: fourcc values, ex. DRM_FORMAT_XRGB16161616 or DRM_FORMAT_XBGR16161616.
+ * @flags: flags for hardware-sepcific features
+ */
+struct drm_mode_lut3d_mode {
+ __u16 lut_size;
+ __u16 lut_stride[3];
+ __u16 bit_depth;
+ __u32 color_format;
+ __u32 flags;
+};
+
/**
* struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
*
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 1/9] drm: Add 3D LUT mode and its attributes
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Alex Hung,
Jonas Ådahl, Uma Shankar, tzimmermann, sunpeng.li,
Sebastian Wick, mripard, Melissa Wen, Jacopo Mondi,
Pekka Paalanen, Xinhui.Pan, xaver.hugl, linux-renesas-soc,
alexander.deucher, christian.koenig, Joshua Ashton
From: Alex Hung <alex.hung@amd.com>
A struct is defined for 3D LUT modes to be supported by hardware.
The elements includes lut_size, lut_stride, bit_depth, color_format
and flags.
Note: A patchset "IGT tests for pre-blending 3D LUT interfaces" for this
proposal is sent to IGT mailing list.
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
include/uapi/drm/drm_mode.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 43691058d28f..3b40694259c7 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -854,6 +854,23 @@ struct drm_color_lut {
__u16 reserved;
};
+/*
+ * struct drm_mode_lut3d_mode - 3D LUT mode information.
+ * @lut_size: number of valid points on every dimension of 3D LUT.
+ * @lut_stride: number of points on every dimension of 3D LUT.
+ * @bit_depth: number of bits of RGB. If color_mode defines entries with higher
+ * bit_depth the least significant bits will be truncated.
+ * @color_format: fourcc values, ex. DRM_FORMAT_XRGB16161616 or DRM_FORMAT_XBGR16161616.
+ * @flags: flags for hardware-sepcific features
+ */
+struct drm_mode_lut3d_mode {
+ __u16 lut_size;
+ __u16 lut_stride[3];
+ __u16 bit_depth;
+ __u32 color_format;
+ __u32 flags;
+};
+
/**
* struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
*
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 2/9] drm/drm_color_mgmt: add shaper LUT to color mgmt properties
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, harry.wentland, tzimmermann, sunpeng.li,
maarten.lankhorst, Sebastian Wick, mripard, Melissa Wen,
Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
Shaper LUT is used to shape the content after blending, i.e.,
de-linearize or normalize space before applying a 3D LUT color
correction. In the next patch, we add 3D LUT property to DRM color
management after this shaper LUT and before the current gamma LUT.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 4 ++++
drivers/gpu/drm/drm_atomic_uapi.c | 10 ++++++++++
drivers/gpu/drm/drm_color_mgmt.c | 18 ++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 3 +++
drivers/gpu/drm/drm_mode_config.c | 14 ++++++++++++++
include/drm/drm_crtc.h | 14 ++++++++++++--
include/drm/drm_mode_config.h | 12 ++++++++++++
include/drm/drm_mode_object.h | 2 +-
8 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 784e63d70a42..b75dcf2aa881 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -141,8 +141,11 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->degamma_lut);
if (state->ctm)
drm_property_blob_get(state->ctm);
+ if (state->shaper_lut)
+ drm_property_blob_get(state->shaper_lut);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
+
state->mode_changed = false;
state->active_changed = false;
state->planes_changed = false;
@@ -214,6 +217,7 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->mode_blob);
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
+ drm_property_blob_put(state->shaper_lut);
drm_property_blob_put(state->gamma_lut);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d867e7f9f2cd..d006e4934ba2 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -430,6 +430,14 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
+ } else if (property == config->shaper_lut_property) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->shaper_lut,
+ val,
+ -1, sizeof(struct drm_color_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
} else if (property == config->gamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->gamma_lut,
@@ -481,6 +489,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
else if (property == config->ctm_property)
*val = (state->ctm) ? state->ctm->base.id : 0;
+ else if (property == config->shaper_lut_property)
+ *val = (state->shaper_lut) ? state->shaper_lut->base.id : 0;
else if (property == config->gamma_lut_property)
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index d021497841b8..cf6a998b4298 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -69,6 +69,24 @@
* boot-up state too. Drivers can access the blob for the color conversion
* matrix through &drm_crtc_state.ctm.
*
+ * “SHAPER_LUT”:
+ * Blob property to set the shaper lut shaping pixel data after the color
+ * transformation matrix and before applying 3D Lookup Table (3D LUT). It
+ * can be used to delinearize content to get an effective 3D LUT mapping.
+ * The data is interpreted as an array of &struct drm_color_lut elements.
+ *
+ * Setting this to NULL (blob property value set to 0) means the output
+ * color is identical to the input color. This is generally the driver
+ * boot-up state too. Drivers can access this blob through
+ * &drm_crtc_state.gamma_lut.
+ *
+ * “SHAPER_LUT_SIZE”:
+ * Unsigned range property to give the size of the shaper lookup table to
+ * be set on the SHAPER_LUT property (the size depends on the underlying
+ * hardware). If drivers support multiple LUT sizes then they should
+ * publish the largest size, and sub-sample smaller sized LUTs
+ * appropriately.
+ *
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
* after the transformation matrix to data sent to the connector. The
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9978147bbc8a..a4ecb25fcfa0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -962,8 +962,11 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
replaced = drm_property_replace_blob(&crtc_state->degamma_lut,
NULL);
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
+ replaced |= drm_property_replace_blob(&crtc_state->shaper_lut,
+ NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
gamma_lut);
+
crtc_state->color_mgmt_changed |= replaced;
}
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..e288bc4815ab 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -353,6 +353,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.ctm_property = prop;
+ prop = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB,
+ "SHAPER_LUT", 0);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.shaper_lut_property = prop;
+
+ prop = drm_property_create_range(dev,
+ DRM_MODE_PROP_IMMUTABLE,
+ "SHAPER_LUT_SIZE", 0, UINT_MAX);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.shaper_lut_size_property = prop;
+
prop = drm_property_create(dev,
DRM_MODE_PROP_BLOB,
"GAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8e1cbc75143e..7f289e0153aa 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -152,8 +152,9 @@ struct drm_crtc_state {
bool zpos_changed : 1;
/**
* @color_mgmt_changed: Color management properties have changed
- * (@gamma_lut, @degamma_lut or @ctm). Used by the atomic helpers and
- * drivers to steer the atomic commit control flow.
+ * (@shaper_lut, @gamma_lut, @degamma_lut or @ctm). Used by
+ * the atomic helpers and drivers to steer the atomic commit control
+ * flow.
*/
bool color_mgmt_changed : 1;
@@ -279,6 +280,15 @@ struct drm_crtc_state {
*/
struct drm_property_blob *gamma_lut;
+ /**
+ * @shaper_lut:
+ *
+ * Lookup table used to de-linearize pixel data for gamma correction.
+ * See drm_crtc_enable_color_mgmt(). The blob (if not NULL) is an array
+ * of &struct drm_color_lut.
+ */
+ struct drm_property_blob *shaper_lut;
+
/**
* @target_vblank:
*
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 973119a9176b..0ad06ec8abec 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -808,6 +808,18 @@ struct drm_mode_config {
* degamma LUT.
*/
struct drm_property *ctm_property;
+
+ /**
+ * @shaper_lut_property: Optional CRTC property to set the shaper LUT used to
+ * convert colors before 3D LUT conversion.
+ */
+ struct drm_property *shaper_lut_property;
+ /**
+ * @shaper_lut_size_property: Optional CRTC property for the size of the
+ * shaper LUT as supported by the driver (read-only).
+ */
+ struct drm_property *shaper_lut_size_property;
+
/**
* @gamma_lut_property: Optional CRTC property to set the LUT used to
* convert the colors, after the CTM matrix, to the gamma space of the
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 912f1e415685..5e75b51936e6 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -60,7 +60,7 @@ struct drm_mode_object {
void (*free_cb)(struct kref *kref);
};
-#define DRM_OBJECT_MAX_PROPERTY 24
+#define DRM_OBJECT_MAX_PROPERTY 26
/**
* struct drm_object_properties - property tracking for &drm_mode_object
*/
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 2/9] drm/drm_color_mgmt: add shaper LUT to color mgmt properties
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
From: Melissa Wen <mwen@igalia.com>
Shaper LUT is used to shape the content after blending, i.e.,
de-linearize or normalize space before applying a 3D LUT color
correction. In the next patch, we add 3D LUT property to DRM color
management after this shaper LUT and before the current gamma LUT.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 4 ++++
drivers/gpu/drm/drm_atomic_uapi.c | 10 ++++++++++
drivers/gpu/drm/drm_color_mgmt.c | 18 ++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 3 +++
drivers/gpu/drm/drm_mode_config.c | 14 ++++++++++++++
include/drm/drm_crtc.h | 14 ++++++++++++--
include/drm/drm_mode_config.h | 12 ++++++++++++
include/drm/drm_mode_object.h | 2 +-
8 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 784e63d70a42..b75dcf2aa881 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -141,8 +141,11 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->degamma_lut);
if (state->ctm)
drm_property_blob_get(state->ctm);
+ if (state->shaper_lut)
+ drm_property_blob_get(state->shaper_lut);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
+
state->mode_changed = false;
state->active_changed = false;
state->planes_changed = false;
@@ -214,6 +217,7 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->mode_blob);
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
+ drm_property_blob_put(state->shaper_lut);
drm_property_blob_put(state->gamma_lut);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d867e7f9f2cd..d006e4934ba2 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -430,6 +430,14 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
+ } else if (property == config->shaper_lut_property) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->shaper_lut,
+ val,
+ -1, sizeof(struct drm_color_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
} else if (property == config->gamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->gamma_lut,
@@ -481,6 +489,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
else if (property == config->ctm_property)
*val = (state->ctm) ? state->ctm->base.id : 0;
+ else if (property == config->shaper_lut_property)
+ *val = (state->shaper_lut) ? state->shaper_lut->base.id : 0;
else if (property == config->gamma_lut_property)
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index d021497841b8..cf6a998b4298 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -69,6 +69,24 @@
* boot-up state too. Drivers can access the blob for the color conversion
* matrix through &drm_crtc_state.ctm.
*
+ * “SHAPER_LUT”:
+ * Blob property to set the shaper lut shaping pixel data after the color
+ * transformation matrix and before applying 3D Lookup Table (3D LUT). It
+ * can be used to delinearize content to get an effective 3D LUT mapping.
+ * The data is interpreted as an array of &struct drm_color_lut elements.
+ *
+ * Setting this to NULL (blob property value set to 0) means the output
+ * color is identical to the input color. This is generally the driver
+ * boot-up state too. Drivers can access this blob through
+ * &drm_crtc_state.gamma_lut.
+ *
+ * “SHAPER_LUT_SIZE”:
+ * Unsigned range property to give the size of the shaper lookup table to
+ * be set on the SHAPER_LUT property (the size depends on the underlying
+ * hardware). If drivers support multiple LUT sizes then they should
+ * publish the largest size, and sub-sample smaller sized LUTs
+ * appropriately.
+ *
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
* after the transformation matrix to data sent to the connector. The
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9978147bbc8a..a4ecb25fcfa0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -962,8 +962,11 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
replaced = drm_property_replace_blob(&crtc_state->degamma_lut,
NULL);
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
+ replaced |= drm_property_replace_blob(&crtc_state->shaper_lut,
+ NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
gamma_lut);
+
crtc_state->color_mgmt_changed |= replaced;
}
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..e288bc4815ab 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -353,6 +353,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.ctm_property = prop;
+ prop = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB,
+ "SHAPER_LUT", 0);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.shaper_lut_property = prop;
+
+ prop = drm_property_create_range(dev,
+ DRM_MODE_PROP_IMMUTABLE,
+ "SHAPER_LUT_SIZE", 0, UINT_MAX);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.shaper_lut_size_property = prop;
+
prop = drm_property_create(dev,
DRM_MODE_PROP_BLOB,
"GAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8e1cbc75143e..7f289e0153aa 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -152,8 +152,9 @@ struct drm_crtc_state {
bool zpos_changed : 1;
/**
* @color_mgmt_changed: Color management properties have changed
- * (@gamma_lut, @degamma_lut or @ctm). Used by the atomic helpers and
- * drivers to steer the atomic commit control flow.
+ * (@shaper_lut, @gamma_lut, @degamma_lut or @ctm). Used by
+ * the atomic helpers and drivers to steer the atomic commit control
+ * flow.
*/
bool color_mgmt_changed : 1;
@@ -279,6 +280,15 @@ struct drm_crtc_state {
*/
struct drm_property_blob *gamma_lut;
+ /**
+ * @shaper_lut:
+ *
+ * Lookup table used to de-linearize pixel data for gamma correction.
+ * See drm_crtc_enable_color_mgmt(). The blob (if not NULL) is an array
+ * of &struct drm_color_lut.
+ */
+ struct drm_property_blob *shaper_lut;
+
/**
* @target_vblank:
*
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 973119a9176b..0ad06ec8abec 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -808,6 +808,18 @@ struct drm_mode_config {
* degamma LUT.
*/
struct drm_property *ctm_property;
+
+ /**
+ * @shaper_lut_property: Optional CRTC property to set the shaper LUT used to
+ * convert colors before 3D LUT conversion.
+ */
+ struct drm_property *shaper_lut_property;
+ /**
+ * @shaper_lut_size_property: Optional CRTC property for the size of the
+ * shaper LUT as supported by the driver (read-only).
+ */
+ struct drm_property *shaper_lut_size_property;
+
/**
* @gamma_lut_property: Optional CRTC property to set the LUT used to
* convert the colors, after the CTM matrix, to the gamma space of the
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 912f1e415685..5e75b51936e6 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -60,7 +60,7 @@ struct drm_mode_object {
void (*free_cb)(struct kref *kref);
};
-#define DRM_OBJECT_MAX_PROPERTY 24
+#define DRM_OBJECT_MAX_PROPERTY 26
/**
* struct drm_object_properties - property tracking for &drm_mode_object
*/
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 2/9] drm/drm_color_mgmt: add shaper LUT to color mgmt properties
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, tzimmermann, sunpeng.li, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
Shaper LUT is used to shape the content after blending, i.e.,
de-linearize or normalize space before applying a 3D LUT color
correction. In the next patch, we add 3D LUT property to DRM color
management after this shaper LUT and before the current gamma LUT.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 4 ++++
drivers/gpu/drm/drm_atomic_uapi.c | 10 ++++++++++
drivers/gpu/drm/drm_color_mgmt.c | 18 ++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 3 +++
drivers/gpu/drm/drm_mode_config.c | 14 ++++++++++++++
include/drm/drm_crtc.h | 14 ++++++++++++--
include/drm/drm_mode_config.h | 12 ++++++++++++
include/drm/drm_mode_object.h | 2 +-
8 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 784e63d70a42..b75dcf2aa881 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -141,8 +141,11 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->degamma_lut);
if (state->ctm)
drm_property_blob_get(state->ctm);
+ if (state->shaper_lut)
+ drm_property_blob_get(state->shaper_lut);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
+
state->mode_changed = false;
state->active_changed = false;
state->planes_changed = false;
@@ -214,6 +217,7 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->mode_blob);
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
+ drm_property_blob_put(state->shaper_lut);
drm_property_blob_put(state->gamma_lut);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d867e7f9f2cd..d006e4934ba2 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -430,6 +430,14 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
+ } else if (property == config->shaper_lut_property) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->shaper_lut,
+ val,
+ -1, sizeof(struct drm_color_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
} else if (property == config->gamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->gamma_lut,
@@ -481,6 +489,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
else if (property == config->ctm_property)
*val = (state->ctm) ? state->ctm->base.id : 0;
+ else if (property == config->shaper_lut_property)
+ *val = (state->shaper_lut) ? state->shaper_lut->base.id : 0;
else if (property == config->gamma_lut_property)
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index d021497841b8..cf6a998b4298 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -69,6 +69,24 @@
* boot-up state too. Drivers can access the blob for the color conversion
* matrix through &drm_crtc_state.ctm.
*
+ * “SHAPER_LUT”:
+ * Blob property to set the shaper lut shaping pixel data after the color
+ * transformation matrix and before applying 3D Lookup Table (3D LUT). It
+ * can be used to delinearize content to get an effective 3D LUT mapping.
+ * The data is interpreted as an array of &struct drm_color_lut elements.
+ *
+ * Setting this to NULL (blob property value set to 0) means the output
+ * color is identical to the input color. This is generally the driver
+ * boot-up state too. Drivers can access this blob through
+ * &drm_crtc_state.gamma_lut.
+ *
+ * “SHAPER_LUT_SIZE”:
+ * Unsigned range property to give the size of the shaper lookup table to
+ * be set on the SHAPER_LUT property (the size depends on the underlying
+ * hardware). If drivers support multiple LUT sizes then they should
+ * publish the largest size, and sub-sample smaller sized LUTs
+ * appropriately.
+ *
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
* after the transformation matrix to data sent to the connector. The
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9978147bbc8a..a4ecb25fcfa0 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -962,8 +962,11 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
replaced = drm_property_replace_blob(&crtc_state->degamma_lut,
NULL);
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
+ replaced |= drm_property_replace_blob(&crtc_state->shaper_lut,
+ NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
gamma_lut);
+
crtc_state->color_mgmt_changed |= replaced;
}
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..e288bc4815ab 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -353,6 +353,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.ctm_property = prop;
+ prop = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB,
+ "SHAPER_LUT", 0);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.shaper_lut_property = prop;
+
+ prop = drm_property_create_range(dev,
+ DRM_MODE_PROP_IMMUTABLE,
+ "SHAPER_LUT_SIZE", 0, UINT_MAX);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.shaper_lut_size_property = prop;
+
prop = drm_property_create(dev,
DRM_MODE_PROP_BLOB,
"GAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8e1cbc75143e..7f289e0153aa 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -152,8 +152,9 @@ struct drm_crtc_state {
bool zpos_changed : 1;
/**
* @color_mgmt_changed: Color management properties have changed
- * (@gamma_lut, @degamma_lut or @ctm). Used by the atomic helpers and
- * drivers to steer the atomic commit control flow.
+ * (@shaper_lut, @gamma_lut, @degamma_lut or @ctm). Used by
+ * the atomic helpers and drivers to steer the atomic commit control
+ * flow.
*/
bool color_mgmt_changed : 1;
@@ -279,6 +280,15 @@ struct drm_crtc_state {
*/
struct drm_property_blob *gamma_lut;
+ /**
+ * @shaper_lut:
+ *
+ * Lookup table used to de-linearize pixel data for gamma correction.
+ * See drm_crtc_enable_color_mgmt(). The blob (if not NULL) is an array
+ * of &struct drm_color_lut.
+ */
+ struct drm_property_blob *shaper_lut;
+
/**
* @target_vblank:
*
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 973119a9176b..0ad06ec8abec 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -808,6 +808,18 @@ struct drm_mode_config {
* degamma LUT.
*/
struct drm_property *ctm_property;
+
+ /**
+ * @shaper_lut_property: Optional CRTC property to set the shaper LUT used to
+ * convert colors before 3D LUT conversion.
+ */
+ struct drm_property *shaper_lut_property;
+ /**
+ * @shaper_lut_size_property: Optional CRTC property for the size of the
+ * shaper LUT as supported by the driver (read-only).
+ */
+ struct drm_property *shaper_lut_size_property;
+
/**
* @gamma_lut_property: Optional CRTC property to set the LUT used to
* convert the colors, after the CTM matrix, to the gamma space of the
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 912f1e415685..5e75b51936e6 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -60,7 +60,7 @@ struct drm_mode_object {
void (*free_cb)(struct kref *kref);
};
-#define DRM_OBJECT_MAX_PROPERTY 24
+#define DRM_OBJECT_MAX_PROPERTY 26
/**
* struct drm_object_properties - property tracking for &drm_mode_object
*/
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 3/9] drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, harry.wentland, tzimmermann, sunpeng.li,
maarten.lankhorst, Sebastian Wick, mripard, Melissa Wen,
Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
Add 3D LUT for gammar correction using a 3D lookup table. The position
in the color correction pipeline where 3D LUT is applied depends on hw
design, being after CTM or gamma. If just after CTM, a shaper lut must
be set to shape the content for a non-linear space. That details should
be handled by the driver according to its color capabilities.
--
v3:
- refactor CRTC 3D LUT API to use Alex Hung proposal for planes
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 3 +++
drivers/gpu/drm/drm_atomic_uapi.c | 14 ++++++++++++++
drivers/gpu/drm/drm_color_mgmt.c | 19 +++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 2 ++
drivers/gpu/drm/drm_mode_config.c | 7 +++++++
include/drm/drm_crtc.h | 20 +++++++++++++++++++-
include/drm/drm_mode_config.h | 13 +++++++++++++
include/drm/drm_mode_object.h | 2 +-
8 files changed, 78 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index b75dcf2aa881..0d5ceb5c654c 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -143,6 +143,8 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->ctm);
if (state->shaper_lut)
drm_property_blob_get(state->shaper_lut);
+ if (state->lut3d)
+ drm_property_blob_get(state->lut3d);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
@@ -218,6 +220,7 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
drm_property_blob_put(state->shaper_lut);
+ drm_property_blob_put(state->lut3d);
drm_property_blob_put(state->gamma_lut);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d006e4934ba2..1f02022e45b3 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -438,6 +438,16 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
+ } else if (property == config->lut3d_property) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->lut3d,
+ val,
+ -1, sizeof(struct drm_color_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
+ } else if (property == config->lut3d_mode_property) {
+ state->lut3d_mode = val;
} else if (property == config->gamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->gamma_lut,
@@ -491,6 +501,10 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->ctm) ? state->ctm->base.id : 0;
else if (property == config->shaper_lut_property)
*val = (state->shaper_lut) ? state->shaper_lut->base.id : 0;
+ else if (property == config->lut3d_property)
+ *val = (state->lut3d) ? state->lut3d->base.id : 0;
+ else if (property == config->lut3d_mode_property)
+ *val = state->lut3d_mode;
else if (property == config->gamma_lut_property)
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index cf6a998b4298..f92633b3b67e 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -87,6 +87,25 @@
* publish the largest size, and sub-sample smaller sized LUTs
* appropriately.
*
+ * “LUT3D”:
+ * Blob property to set the 3D LUT mapping pixel data after the color
+ * transformation matrix and before gamma 1D lut correction. The
+ * data is interpreted as an array of &struct drm_color_lut elements.
+ * Hardware might choose not to use the full precision of the LUT
+ * elements.
+ *
+ * Setting this to NULL (blob property value set to 0) means a the output
+ * color is identical to the input color. This is generally the driver
+ * boot-up state too. Drivers can access this blob through
+ * &drm_crtc_state.gamma_lut.
+ *
+ * “LUT3D_MODE”:
+ * Enum property to give the mode of the 3D lookup table to be set on the
+ * LUT3D property. A mode specifies size, stride, bit depth and color
+ * format and depends on the underlying hardware). If drivers support
+ * multiple 3D LUT modes, they should be declared in a array of
+ * drm_color_lut3d_mode and they will be advertised as an enum.
+ *
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
* after the transformation matrix to data sent to the connector. The
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a4ecb25fcfa0..fd76de50bb79 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -964,6 +964,8 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
replaced |= drm_property_replace_blob(&crtc_state->shaper_lut,
NULL);
+ replaced |= drm_property_replace_blob(&crtc_state->lut3d,
+ NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
gamma_lut);
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index e288bc4815ab..b82a7cb2a8f7 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -367,6 +367,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.shaper_lut_size_property = prop;
+ prop = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB,
+ "LUT3D", 0);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.lut3d_property = prop;
+
prop = drm_property_create(dev,
DRM_MODE_PROP_BLOB,
"GAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 7f289e0153aa..805a50c36a70 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -152,7 +152,7 @@ struct drm_crtc_state {
bool zpos_changed : 1;
/**
* @color_mgmt_changed: Color management properties have changed
- * (@shaper_lut, @gamma_lut, @degamma_lut or @ctm). Used by
+ * (@shaper_lut, @lut3d, @gamma_lut, @degamma_lut or @ctm). Used by
* the atomic helpers and drivers to steer the atomic commit control
* flow.
*/
@@ -289,6 +289,24 @@ struct drm_crtc_state {
*/
struct drm_property_blob *shaper_lut;
+ /**
+ * @lut3d:
+ *
+ * 3D Lookup table for converting pixel data. Position where it takes
+ * place depends on hw design, after @ctm or @gamma_lut. See
+ * drm_crtc_enable_color_mgmt(). The blob (if not NULL) is an array of
+ * &struct drm_color_lut.
+ */
+ struct drm_property_blob *lut3d;
+
+ /**
+ * @lut3d_mode:
+ * This is a blob_id and exposes the platform capabilities wrt
+ * various 3dlut. This also helps user select a 3dlut mode amongst
+ * the supported ones.
+ */
+ u32 lut3d_mode;
+
/**
* @target_vblank:
*
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 0ad06ec8abec..0baf6354f757 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -820,6 +820,19 @@ struct drm_mode_config {
*/
struct drm_property *shaper_lut_size_property;
+ /**
+ * @lut3d_property: Optional CRTC property to set the 3D LUT used to
+ * convert colors; before or after gamma conversion depends on hw
+ * design. A shaper LUT can be used to delinearize content before apply
+ * 3D LUT correction.
+ */
+ struct drm_property *lut3d_property;
+ /**
+ * @lut3d_mode_property: Optional CRTC property to describe 3D LUT modes
+ * supported by the driver.
+ */
+ struct drm_property *lut3d_mode_property;
+
/**
* @gamma_lut_property: Optional CRTC property to set the LUT used to
* convert the colors, after the CTM matrix, to the gamma space of the
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 5e75b51936e6..d39ee21f26db 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -60,7 +60,7 @@ struct drm_mode_object {
void (*free_cb)(struct kref *kref);
};
-#define DRM_OBJECT_MAX_PROPERTY 26
+#define DRM_OBJECT_MAX_PROPERTY 28
/**
* struct drm_object_properties - property tracking for &drm_mode_object
*/
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 3/9] drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
From: Melissa Wen <mwen@igalia.com>
Add 3D LUT for gammar correction using a 3D lookup table. The position
in the color correction pipeline where 3D LUT is applied depends on hw
design, being after CTM or gamma. If just after CTM, a shaper lut must
be set to shape the content for a non-linear space. That details should
be handled by the driver according to its color capabilities.
--
v3:
- refactor CRTC 3D LUT API to use Alex Hung proposal for planes
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 3 +++
drivers/gpu/drm/drm_atomic_uapi.c | 14 ++++++++++++++
drivers/gpu/drm/drm_color_mgmt.c | 19 +++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 2 ++
drivers/gpu/drm/drm_mode_config.c | 7 +++++++
include/drm/drm_crtc.h | 20 +++++++++++++++++++-
include/drm/drm_mode_config.h | 13 +++++++++++++
include/drm/drm_mode_object.h | 2 +-
8 files changed, 78 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index b75dcf2aa881..0d5ceb5c654c 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -143,6 +143,8 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->ctm);
if (state->shaper_lut)
drm_property_blob_get(state->shaper_lut);
+ if (state->lut3d)
+ drm_property_blob_get(state->lut3d);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
@@ -218,6 +220,7 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
drm_property_blob_put(state->shaper_lut);
+ drm_property_blob_put(state->lut3d);
drm_property_blob_put(state->gamma_lut);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d006e4934ba2..1f02022e45b3 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -438,6 +438,16 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
+ } else if (property == config->lut3d_property) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->lut3d,
+ val,
+ -1, sizeof(struct drm_color_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
+ } else if (property == config->lut3d_mode_property) {
+ state->lut3d_mode = val;
} else if (property == config->gamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->gamma_lut,
@@ -491,6 +501,10 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->ctm) ? state->ctm->base.id : 0;
else if (property == config->shaper_lut_property)
*val = (state->shaper_lut) ? state->shaper_lut->base.id : 0;
+ else if (property == config->lut3d_property)
+ *val = (state->lut3d) ? state->lut3d->base.id : 0;
+ else if (property == config->lut3d_mode_property)
+ *val = state->lut3d_mode;
else if (property == config->gamma_lut_property)
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index cf6a998b4298..f92633b3b67e 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -87,6 +87,25 @@
* publish the largest size, and sub-sample smaller sized LUTs
* appropriately.
*
+ * “LUT3D”:
+ * Blob property to set the 3D LUT mapping pixel data after the color
+ * transformation matrix and before gamma 1D lut correction. The
+ * data is interpreted as an array of &struct drm_color_lut elements.
+ * Hardware might choose not to use the full precision of the LUT
+ * elements.
+ *
+ * Setting this to NULL (blob property value set to 0) means a the output
+ * color is identical to the input color. This is generally the driver
+ * boot-up state too. Drivers can access this blob through
+ * &drm_crtc_state.gamma_lut.
+ *
+ * “LUT3D_MODE”:
+ * Enum property to give the mode of the 3D lookup table to be set on the
+ * LUT3D property. A mode specifies size, stride, bit depth and color
+ * format and depends on the underlying hardware). If drivers support
+ * multiple 3D LUT modes, they should be declared in a array of
+ * drm_color_lut3d_mode and they will be advertised as an enum.
+ *
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
* after the transformation matrix to data sent to the connector. The
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a4ecb25fcfa0..fd76de50bb79 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -964,6 +964,8 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
replaced |= drm_property_replace_blob(&crtc_state->shaper_lut,
NULL);
+ replaced |= drm_property_replace_blob(&crtc_state->lut3d,
+ NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
gamma_lut);
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index e288bc4815ab..b82a7cb2a8f7 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -367,6 +367,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.shaper_lut_size_property = prop;
+ prop = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB,
+ "LUT3D", 0);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.lut3d_property = prop;
+
prop = drm_property_create(dev,
DRM_MODE_PROP_BLOB,
"GAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 7f289e0153aa..805a50c36a70 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -152,7 +152,7 @@ struct drm_crtc_state {
bool zpos_changed : 1;
/**
* @color_mgmt_changed: Color management properties have changed
- * (@shaper_lut, @gamma_lut, @degamma_lut or @ctm). Used by
+ * (@shaper_lut, @lut3d, @gamma_lut, @degamma_lut or @ctm). Used by
* the atomic helpers and drivers to steer the atomic commit control
* flow.
*/
@@ -289,6 +289,24 @@ struct drm_crtc_state {
*/
struct drm_property_blob *shaper_lut;
+ /**
+ * @lut3d:
+ *
+ * 3D Lookup table for converting pixel data. Position where it takes
+ * place depends on hw design, after @ctm or @gamma_lut. See
+ * drm_crtc_enable_color_mgmt(). The blob (if not NULL) is an array of
+ * &struct drm_color_lut.
+ */
+ struct drm_property_blob *lut3d;
+
+ /**
+ * @lut3d_mode:
+ * This is a blob_id and exposes the platform capabilities wrt
+ * various 3dlut. This also helps user select a 3dlut mode amongst
+ * the supported ones.
+ */
+ u32 lut3d_mode;
+
/**
* @target_vblank:
*
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 0ad06ec8abec..0baf6354f757 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -820,6 +820,19 @@ struct drm_mode_config {
*/
struct drm_property *shaper_lut_size_property;
+ /**
+ * @lut3d_property: Optional CRTC property to set the 3D LUT used to
+ * convert colors; before or after gamma conversion depends on hw
+ * design. A shaper LUT can be used to delinearize content before apply
+ * 3D LUT correction.
+ */
+ struct drm_property *lut3d_property;
+ /**
+ * @lut3d_mode_property: Optional CRTC property to describe 3D LUT modes
+ * supported by the driver.
+ */
+ struct drm_property *lut3d_mode_property;
+
/**
* @gamma_lut_property: Optional CRTC property to set the LUT used to
* convert the colors, after the CTM matrix, to the gamma space of the
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 5e75b51936e6..d39ee21f26db 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -60,7 +60,7 @@ struct drm_mode_object {
void (*free_cb)(struct kref *kref);
};
-#define DRM_OBJECT_MAX_PROPERTY 26
+#define DRM_OBJECT_MAX_PROPERTY 28
/**
* struct drm_object_properties - property tracking for &drm_mode_object
*/
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 3/9] drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, tzimmermann, sunpeng.li, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
Add 3D LUT for gammar correction using a 3D lookup table. The position
in the color correction pipeline where 3D LUT is applied depends on hw
design, being after CTM or gamma. If just after CTM, a shaper lut must
be set to shape the content for a non-linear space. That details should
be handled by the driver according to its color capabilities.
--
v3:
- refactor CRTC 3D LUT API to use Alex Hung proposal for planes
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 3 +++
drivers/gpu/drm/drm_atomic_uapi.c | 14 ++++++++++++++
drivers/gpu/drm/drm_color_mgmt.c | 19 +++++++++++++++++++
drivers/gpu/drm/drm_fb_helper.c | 2 ++
drivers/gpu/drm/drm_mode_config.c | 7 +++++++
include/drm/drm_crtc.h | 20 +++++++++++++++++++-
include/drm/drm_mode_config.h | 13 +++++++++++++
include/drm/drm_mode_object.h | 2 +-
8 files changed, 78 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index b75dcf2aa881..0d5ceb5c654c 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -143,6 +143,8 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->ctm);
if (state->shaper_lut)
drm_property_blob_get(state->shaper_lut);
+ if (state->lut3d)
+ drm_property_blob_get(state->lut3d);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
@@ -218,6 +220,7 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
drm_property_blob_put(state->shaper_lut);
+ drm_property_blob_put(state->lut3d);
drm_property_blob_put(state->gamma_lut);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d006e4934ba2..1f02022e45b3 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -438,6 +438,16 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
+ } else if (property == config->lut3d_property) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->lut3d,
+ val,
+ -1, sizeof(struct drm_color_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
+ } else if (property == config->lut3d_mode_property) {
+ state->lut3d_mode = val;
} else if (property == config->gamma_lut_property) {
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->gamma_lut,
@@ -491,6 +501,10 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->ctm) ? state->ctm->base.id : 0;
else if (property == config->shaper_lut_property)
*val = (state->shaper_lut) ? state->shaper_lut->base.id : 0;
+ else if (property == config->lut3d_property)
+ *val = (state->lut3d) ? state->lut3d->base.id : 0;
+ else if (property == config->lut3d_mode_property)
+ *val = state->lut3d_mode;
else if (property == config->gamma_lut_property)
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index cf6a998b4298..f92633b3b67e 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -87,6 +87,25 @@
* publish the largest size, and sub-sample smaller sized LUTs
* appropriately.
*
+ * “LUT3D”:
+ * Blob property to set the 3D LUT mapping pixel data after the color
+ * transformation matrix and before gamma 1D lut correction. The
+ * data is interpreted as an array of &struct drm_color_lut elements.
+ * Hardware might choose not to use the full precision of the LUT
+ * elements.
+ *
+ * Setting this to NULL (blob property value set to 0) means a the output
+ * color is identical to the input color. This is generally the driver
+ * boot-up state too. Drivers can access this blob through
+ * &drm_crtc_state.gamma_lut.
+ *
+ * “LUT3D_MODE”:
+ * Enum property to give the mode of the 3D lookup table to be set on the
+ * LUT3D property. A mode specifies size, stride, bit depth and color
+ * format and depends on the underlying hardware). If drivers support
+ * multiple 3D LUT modes, they should be declared in a array of
+ * drm_color_lut3d_mode and they will be advertised as an enum.
+ *
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
* after the transformation matrix to data sent to the connector. The
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a4ecb25fcfa0..fd76de50bb79 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -964,6 +964,8 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
replaced |= drm_property_replace_blob(&crtc_state->shaper_lut,
NULL);
+ replaced |= drm_property_replace_blob(&crtc_state->lut3d,
+ NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
gamma_lut);
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index e288bc4815ab..b82a7cb2a8f7 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -367,6 +367,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
return -ENOMEM;
dev->mode_config.shaper_lut_size_property = prop;
+ prop = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB,
+ "LUT3D", 0);
+ if (!prop)
+ return -ENOMEM;
+ dev->mode_config.lut3d_property = prop;
+
prop = drm_property_create(dev,
DRM_MODE_PROP_BLOB,
"GAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 7f289e0153aa..805a50c36a70 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -152,7 +152,7 @@ struct drm_crtc_state {
bool zpos_changed : 1;
/**
* @color_mgmt_changed: Color management properties have changed
- * (@shaper_lut, @gamma_lut, @degamma_lut or @ctm). Used by
+ * (@shaper_lut, @lut3d, @gamma_lut, @degamma_lut or @ctm). Used by
* the atomic helpers and drivers to steer the atomic commit control
* flow.
*/
@@ -289,6 +289,24 @@ struct drm_crtc_state {
*/
struct drm_property_blob *shaper_lut;
+ /**
+ * @lut3d:
+ *
+ * 3D Lookup table for converting pixel data. Position where it takes
+ * place depends on hw design, after @ctm or @gamma_lut. See
+ * drm_crtc_enable_color_mgmt(). The blob (if not NULL) is an array of
+ * &struct drm_color_lut.
+ */
+ struct drm_property_blob *lut3d;
+
+ /**
+ * @lut3d_mode:
+ * This is a blob_id and exposes the platform capabilities wrt
+ * various 3dlut. This also helps user select a 3dlut mode amongst
+ * the supported ones.
+ */
+ u32 lut3d_mode;
+
/**
* @target_vblank:
*
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 0ad06ec8abec..0baf6354f757 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -820,6 +820,19 @@ struct drm_mode_config {
*/
struct drm_property *shaper_lut_size_property;
+ /**
+ * @lut3d_property: Optional CRTC property to set the 3D LUT used to
+ * convert colors; before or after gamma conversion depends on hw
+ * design. A shaper LUT can be used to delinearize content before apply
+ * 3D LUT correction.
+ */
+ struct drm_property *lut3d_property;
+ /**
+ * @lut3d_mode_property: Optional CRTC property to describe 3D LUT modes
+ * supported by the driver.
+ */
+ struct drm_property *lut3d_mode_property;
+
/**
* @gamma_lut_property: Optional CRTC property to set the LUT used to
* convert the colors, after the CTM matrix, to the gamma space of the
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 5e75b51936e6..d39ee21f26db 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -60,7 +60,7 @@ struct drm_mode_object {
void (*free_cb)(struct kref *kref);
};
-#define DRM_OBJECT_MAX_PROPERTY 26
+#define DRM_OBJECT_MAX_PROPERTY 28
/**
* struct drm_object_properties - property tracking for &drm_mode_object
*/
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 4/9] drm/drm_color_mgmt: add function to create 3D LUT modes supported
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, harry.wentland, tzimmermann, sunpeng.li,
maarten.lankhorst, Sebastian Wick, mripard, Melissa Wen,
Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
DRM color function to create modes for lut3d mode property from an array
of drm_color_lut3d_mode modes supported by the HW and advertise to
userspace. Userspace can get the description of a specific mode in the
enum list from its blob data.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 43 +++++++++++++++++++++++++++++++-
include/drm/drm_color_mgmt.h | 4 +++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index f92633b3b67e..6ce48007cdd4 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -104,7 +104,7 @@
* LUT3D property. A mode specifies size, stride, bit depth and color
* format and depends on the underlying hardware). If drivers support
* multiple 3D LUT modes, they should be declared in a array of
- * drm_color_lut3d_mode and they will be advertised as an enum.
+ * drm_mode_lut3d_mode and they will be advertised as an enum.
*
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
@@ -228,6 +228,47 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_enable_color_mgmt);
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+ const struct drm_mode_lut3d_mode modes[],
+ unsigned int num_modes)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property_blob *blob;
+ struct drm_property *prop;
+ char *name;
+ int ret;
+
+ if (dev->mode_config.lut3d_mode_property)
+ return 0;
+
+ prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, "LUT3D_MODE", num_modes);
+ if (!prop)
+ return -EINVAL;
+
+ for (int i = 0; i < num_modes; i++) {
+ blob = drm_property_create_blob(dev, sizeof(modes[i]), &modes[i]);
+ if (IS_ERR(blob))
+ return PTR_ERR(blob);
+
+ name = kasprintf(GFP_KERNEL, "lut3d_%d_%dbit",
+ modes[i].lut_size, modes[i].bit_depth);
+ if (!name)
+ return -ENOMEM;
+
+ ret = drm_property_add_enum(prop, blob->base.id, name);
+ if (ret) {
+ drm_property_blob_put(blob);
+ kfree(name);
+ return ret;
+ }
+ kfree(name);
+ }
+ dev->mode_config.lut3d_mode_property = prop;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+
/**
* drm_mode_crtc_set_gamma_size - set the gamma table size
* @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 81c298488b0c..af9305925572 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -59,6 +59,10 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
bool has_ctm,
uint gamma_lut_size);
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+ const struct drm_mode_lut3d_mode modes[],
+ unsigned int num_modes);
+
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 4/9] drm/drm_color_mgmt: add function to create 3D LUT modes supported
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
From: Melissa Wen <mwen@igalia.com>
DRM color function to create modes for lut3d mode property from an array
of drm_color_lut3d_mode modes supported by the HW and advertise to
userspace. Userspace can get the description of a specific mode in the
enum list from its blob data.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 43 +++++++++++++++++++++++++++++++-
include/drm/drm_color_mgmt.h | 4 +++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index f92633b3b67e..6ce48007cdd4 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -104,7 +104,7 @@
* LUT3D property. A mode specifies size, stride, bit depth and color
* format and depends on the underlying hardware). If drivers support
* multiple 3D LUT modes, they should be declared in a array of
- * drm_color_lut3d_mode and they will be advertised as an enum.
+ * drm_mode_lut3d_mode and they will be advertised as an enum.
*
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
@@ -228,6 +228,47 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_enable_color_mgmt);
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+ const struct drm_mode_lut3d_mode modes[],
+ unsigned int num_modes)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property_blob *blob;
+ struct drm_property *prop;
+ char *name;
+ int ret;
+
+ if (dev->mode_config.lut3d_mode_property)
+ return 0;
+
+ prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, "LUT3D_MODE", num_modes);
+ if (!prop)
+ return -EINVAL;
+
+ for (int i = 0; i < num_modes; i++) {
+ blob = drm_property_create_blob(dev, sizeof(modes[i]), &modes[i]);
+ if (IS_ERR(blob))
+ return PTR_ERR(blob);
+
+ name = kasprintf(GFP_KERNEL, "lut3d_%d_%dbit",
+ modes[i].lut_size, modes[i].bit_depth);
+ if (!name)
+ return -ENOMEM;
+
+ ret = drm_property_add_enum(prop, blob->base.id, name);
+ if (ret) {
+ drm_property_blob_put(blob);
+ kfree(name);
+ return ret;
+ }
+ kfree(name);
+ }
+ dev->mode_config.lut3d_mode_property = prop;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+
/**
* drm_mode_crtc_set_gamma_size - set the gamma table size
* @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 81c298488b0c..af9305925572 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -59,6 +59,10 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
bool has_ctm,
uint gamma_lut_size);
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+ const struct drm_mode_lut3d_mode modes[],
+ unsigned int num_modes);
+
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 4/9] drm/drm_color_mgmt: add function to create 3D LUT modes supported
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, tzimmermann, sunpeng.li, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
DRM color function to create modes for lut3d mode property from an array
of drm_color_lut3d_mode modes supported by the HW and advertise to
userspace. Userspace can get the description of a specific mode in the
enum list from its blob data.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 43 +++++++++++++++++++++++++++++++-
include/drm/drm_color_mgmt.h | 4 +++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index f92633b3b67e..6ce48007cdd4 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -104,7 +104,7 @@
* LUT3D property. A mode specifies size, stride, bit depth and color
* format and depends on the underlying hardware). If drivers support
* multiple 3D LUT modes, they should be declared in a array of
- * drm_color_lut3d_mode and they will be advertised as an enum.
+ * drm_mode_lut3d_mode and they will be advertised as an enum.
*
* “GAMMA_LUT”:
* Blob property to set the gamma lookup table (LUT) mapping pixel data
@@ -228,6 +228,47 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_enable_color_mgmt);
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+ const struct drm_mode_lut3d_mode modes[],
+ unsigned int num_modes)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_property_blob *blob;
+ struct drm_property *prop;
+ char *name;
+ int ret;
+
+ if (dev->mode_config.lut3d_mode_property)
+ return 0;
+
+ prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, "LUT3D_MODE", num_modes);
+ if (!prop)
+ return -EINVAL;
+
+ for (int i = 0; i < num_modes; i++) {
+ blob = drm_property_create_blob(dev, sizeof(modes[i]), &modes[i]);
+ if (IS_ERR(blob))
+ return PTR_ERR(blob);
+
+ name = kasprintf(GFP_KERNEL, "lut3d_%d_%dbit",
+ modes[i].lut_size, modes[i].bit_depth);
+ if (!name)
+ return -ENOMEM;
+
+ ret = drm_property_add_enum(prop, blob->base.id, name);
+ if (ret) {
+ drm_property_blob_put(blob);
+ kfree(name);
+ return ret;
+ }
+ kfree(name);
+ }
+ dev->mode_config.lut3d_mode_property = prop;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+
/**
* drm_mode_crtc_set_gamma_size - set the gamma table size
* @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 81c298488b0c..af9305925572 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -59,6 +59,10 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
bool has_ctm,
uint gamma_lut_size);
+int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
+ const struct drm_mode_lut3d_mode modes[],
+ unsigned int num_modes);
+
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 5/9] drm/drm_color_mgmt: add function to attach 3D LUT props
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, harry.wentland, tzimmermann, sunpeng.li,
maarten.lankhorst, Sebastian Wick, mripard, Melissa Wen,
Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
If the driver supports user 3D LUT then it calls a drm function to
attach 3D LUT related properties according to HW caps.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 35 ++++++++++++++++++++++++++++++++
include/drm/drm_color_mgmt.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 6ce48007cdd4..06503f693ecd 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -269,6 +269,41 @@ int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+/**
+ * drm_crtc_enable_lut3d - enable 3D LUT properties
+ * @crtc: DRM CRTC
+ * @shaper_lut_size: the size of shaper lut
+ *
+ * This function lets the driver enable the 3D LUT color correction property
+ * on a CRTC. This includes 3D LUT and also a shaper LUT, if set. The shaper
+ * LUT property is only attached if its size is not 0 and 3D LUT is set, being
+ * therefore optional.
+ */
+void drm_crtc_enable_lut3d(struct drm_crtc *crtc,
+ uint shaper_lut_size)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_mode_config *config = &dev->mode_config;
+
+ if (!config->lut3d_mode_property)
+ return;
+
+ drm_object_attach_property(&crtc->base,
+ config->lut3d_property, 0);
+ drm_object_attach_property(&crtc->base,
+ config->lut3d_mode_property, 0);
+
+ if (!shaper_lut_size)
+ return;
+
+ drm_object_attach_property(&crtc->base,
+ config->shaper_lut_property, 0);
+ drm_object_attach_property(&crtc->base,
+ config->shaper_lut_size_property,
+ shaper_lut_size);
+}
+EXPORT_SYMBOL(drm_crtc_enable_lut3d);
+
/**
* drm_mode_crtc_set_gamma_size - set the gamma table size
* @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index af9305925572..db2026dc825e 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -63,6 +63,9 @@ int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
const struct drm_mode_lut3d_mode modes[],
unsigned int num_modes);
+void drm_crtc_enable_lut3d(struct drm_crtc *crtc,
+ uint shaper_lut_size);
+
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 5/9] drm/drm_color_mgmt: add function to attach 3D LUT props
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
From: Melissa Wen <mwen@igalia.com>
If the driver supports user 3D LUT then it calls a drm function to
attach 3D LUT related properties according to HW caps.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 35 ++++++++++++++++++++++++++++++++
include/drm/drm_color_mgmt.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 6ce48007cdd4..06503f693ecd 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -269,6 +269,41 @@ int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+/**
+ * drm_crtc_enable_lut3d - enable 3D LUT properties
+ * @crtc: DRM CRTC
+ * @shaper_lut_size: the size of shaper lut
+ *
+ * This function lets the driver enable the 3D LUT color correction property
+ * on a CRTC. This includes 3D LUT and also a shaper LUT, if set. The shaper
+ * LUT property is only attached if its size is not 0 and 3D LUT is set, being
+ * therefore optional.
+ */
+void drm_crtc_enable_lut3d(struct drm_crtc *crtc,
+ uint shaper_lut_size)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_mode_config *config = &dev->mode_config;
+
+ if (!config->lut3d_mode_property)
+ return;
+
+ drm_object_attach_property(&crtc->base,
+ config->lut3d_property, 0);
+ drm_object_attach_property(&crtc->base,
+ config->lut3d_mode_property, 0);
+
+ if (!shaper_lut_size)
+ return;
+
+ drm_object_attach_property(&crtc->base,
+ config->shaper_lut_property, 0);
+ drm_object_attach_property(&crtc->base,
+ config->shaper_lut_size_property,
+ shaper_lut_size);
+}
+EXPORT_SYMBOL(drm_crtc_enable_lut3d);
+
/**
* drm_mode_crtc_set_gamma_size - set the gamma table size
* @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index af9305925572..db2026dc825e 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -63,6 +63,9 @@ int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
const struct drm_mode_lut3d_mode modes[],
unsigned int num_modes);
+void drm_crtc_enable_lut3d(struct drm_crtc *crtc,
+ uint shaper_lut_size);
+
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 5/9] drm/drm_color_mgmt: add function to attach 3D LUT props
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, tzimmermann, sunpeng.li, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, alexander.deucher, christian.koenig,
Joshua Ashton
From: Melissa Wen <mwen@igalia.com>
If the driver supports user 3D LUT then it calls a drm function to
attach 3D LUT related properties according to HW caps.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 35 ++++++++++++++++++++++++++++++++
include/drm/drm_color_mgmt.h | 3 +++
2 files changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 6ce48007cdd4..06503f693ecd 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -269,6 +269,41 @@ int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
}
EXPORT_SYMBOL(drm_crtc_create_lut3d_mode_property);
+/**
+ * drm_crtc_enable_lut3d - enable 3D LUT properties
+ * @crtc: DRM CRTC
+ * @shaper_lut_size: the size of shaper lut
+ *
+ * This function lets the driver enable the 3D LUT color correction property
+ * on a CRTC. This includes 3D LUT and also a shaper LUT, if set. The shaper
+ * LUT property is only attached if its size is not 0 and 3D LUT is set, being
+ * therefore optional.
+ */
+void drm_crtc_enable_lut3d(struct drm_crtc *crtc,
+ uint shaper_lut_size)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_mode_config *config = &dev->mode_config;
+
+ if (!config->lut3d_mode_property)
+ return;
+
+ drm_object_attach_property(&crtc->base,
+ config->lut3d_property, 0);
+ drm_object_attach_property(&crtc->base,
+ config->lut3d_mode_property, 0);
+
+ if (!shaper_lut_size)
+ return;
+
+ drm_object_attach_property(&crtc->base,
+ config->shaper_lut_property, 0);
+ drm_object_attach_property(&crtc->base,
+ config->shaper_lut_size_property,
+ shaper_lut_size);
+}
+EXPORT_SYMBOL(drm_crtc_enable_lut3d);
+
/**
* drm_mode_crtc_set_gamma_size - set the gamma table size
* @crtc: CRTC to set the gamma table size for
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index af9305925572..db2026dc825e 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -63,6 +63,9 @@ int drm_crtc_create_lut3d_mode_property(struct drm_crtc *crtc,
const struct drm_mode_lut3d_mode modes[],
unsigned int num_modes);
+void drm_crtc_enable_lut3d(struct drm_crtc *crtc,
+ uint shaper_lut_size);
+
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 6/9] drm: rcar-du: cmm: Refactor LUT configuration
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Laurent Pinchart, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, harry.wentland, tzimmermann,
sunpeng.li, maarten.lankhorst, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan,
xaver.hugl, linux-renesas-soc, daniel, alexander.deucher,
christian.koenig, Joshua Ashton
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To prepare for CLU support, expend the CMM API exposed to the DU driver
to separate the LUT table pointer from the LUT update decision. This
will be required, as we will need to update the LUT and CLU
independently.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.c | 60 ++++++++++++--------------
drivers/gpu/drm/rcar-du/rcar_cmm.h | 19 +++++---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 22 +++++++---
3 files changed, 55 insertions(+), 46 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.c b/drivers/gpu/drm/rcar-du/rcar_cmm.c
index e2a67dda4658..df768a9afb72 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.c
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.c
@@ -42,23 +42,33 @@ static inline void rcar_cmm_write(struct rcar_cmm *rcmm, u32 reg, u32 data)
iowrite32(data, rcmm->base + reg);
}
-/*
- * rcar_cmm_lut_write() - Scale the DRM LUT table entries to hardware precision
- * and write to the CMM registers
- * @rcmm: Pointer to the CMM device
- * @drm_lut: Pointer to the DRM LUT table
- */
-static void rcar_cmm_lut_write(struct rcar_cmm *rcmm,
- const struct drm_color_lut *drm_lut)
+static void rcar_cmm_lut_configure(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
{
- unsigned int i;
+ bool enable = !!table;
+
+ if (rcmm->lut.enabled != enable) {
+ rcar_cmm_write(rcmm, CM2_LUT_CTRL,
+ enable ? CM2_LUT_CTRL_LUT_EN : 0);
+ rcmm->lut.enabled = enable;
+ }
- for (i = 0; i < CM2_LUT_SIZE; ++i) {
- u32 entry = drm_color_lut_extract(drm_lut[i].red, 8) << 16
- | drm_color_lut_extract(drm_lut[i].green, 8) << 8
- | drm_color_lut_extract(drm_lut[i].blue, 8);
+ if (table) {
+ unsigned int i;
- rcar_cmm_write(rcmm, CM2_LUT_TBL(i), entry);
+ /*
+ * Scale the DRM LUT table entries to the hardware precision
+ * and program it.
+ */
+ for (i = 0; i < CM2_LUT_SIZE; ++i) {
+ const struct drm_color_lut *lut = &table[i];
+
+ u32 entry = drm_color_lut_extract(lut->red, 8) << 16
+ | drm_color_lut_extract(lut->green, 8) << 8
+ | drm_color_lut_extract(lut->blue, 8);
+
+ rcar_cmm_write(rcmm, CM2_LUT_TBL(i), entry);
+ }
}
}
@@ -83,23 +93,8 @@ int rcar_cmm_setup(struct platform_device *pdev,
{
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
- /* Disable LUT if no table is provided. */
- if (!config->lut.table) {
- if (rcmm->lut.enabled) {
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0);
- rcmm->lut.enabled = false;
- }
-
- return 0;
- }
-
- /* Enable LUT and program the new gamma table values. */
- if (!rcmm->lut.enabled) {
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, CM2_LUT_CTRL_LUT_EN);
- rcmm->lut.enabled = true;
- }
-
- rcar_cmm_lut_write(rcmm, config->lut.table);
+ if (config->lut.update)
+ rcar_cmm_lut_configure(rcmm, config->lut.table);
return 0;
}
@@ -144,8 +139,7 @@ void rcar_cmm_disable(struct platform_device *pdev)
{
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0);
- rcmm->lut.enabled = false;
+ rcar_cmm_lut_configure(rcmm, NULL);
pm_runtime_put(&pdev->dev);
}
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 628072acc98b..375a3b9c3db3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -13,16 +13,23 @@
struct drm_color_lut;
struct platform_device;
+/**
+ * struct rcar_cmm_table_config - CMM LUT configuration
+ * @update: When true, update the LUT configuration.
+ * @table: Table data. The LUT is enabled if non-NULL, and disabled
+ * otherwise. The value is ignored if @update is false.
+ */
+struct rcar_cmm_table_config {
+ bool update;
+ struct drm_color_lut *table;
+};
+
/**
* struct rcar_cmm_config - CMM configuration
- *
- * @lut: 1D-LUT configuration
- * @lut.table: 1D-LUT table entries. Disable LUT operations when NULL
+ * @lut: 1D-LUT configuration
*/
struct rcar_cmm_config {
- struct {
- struct drm_color_lut *table;
- } lut;
+ struct rcar_cmm_table_config lut;
};
#if IS_ENABLED(CONFIG_DRM_RCAR_CMM)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index d6d29be6b4f4..a2d477dc5a51 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -537,17 +537,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
return 0;
}
-static void rcar_du_cmm_setup(struct drm_crtc *crtc)
+static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
+ const struct drm_crtc_state *old_state,
+ const struct drm_crtc_state *new_state)
{
- struct drm_property_blob *drm_lut = crtc->state->gamma_lut;
- struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
struct rcar_cmm_config cmm_config = {};
if (!rcrtc->cmm)
return;
- if (drm_lut)
- cmm_config.lut.table = (struct drm_color_lut *)drm_lut->data;
+ if (!old_state ||
+ !old_state->gamma_lut != !new_state->gamma_lut ||
+ (old_state->gamma_lut && new_state->gamma_lut &&
+ old_state->gamma_lut->base.id != new_state->gamma_lut->base.id)) {
+ cmm_config.lut.update = true;
+ cmm_config.lut.table = new_state->gamma_lut
+ ? new_state->gamma_lut->data : NULL;
+ }
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
@@ -794,7 +800,7 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
* after the DU channel has been activated. Investigate the impact
* of this restriction on the first displayed frame.
*/
- rcar_du_cmm_setup(crtc);
+ rcar_du_cmm_setup(rcrtc, NULL, crtc->state);
}
static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -844,6 +850,8 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_atomic_state *state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
+ crtc);
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
WARN_ON(!crtc->state->enable);
@@ -864,7 +872,7 @@ static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
/* If the active state changed, we let .atomic_enable handle CMM. */
if (crtc->state->color_mgmt_changed && !crtc->state->active_changed)
- rcar_du_cmm_setup(crtc);
+ rcar_du_cmm_setup(rcrtc, old_state, crtc->state);
if (rcar_du_has(rcrtc->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
rcar_du_vsp_atomic_begin(rcrtc);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 6/9] drm: rcar-du: cmm: Refactor LUT configuration
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc, Laurent Pinchart
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To prepare for CLU support, expend the CMM API exposed to the DU driver
to separate the LUT table pointer from the LUT update decision. This
will be required, as we will need to update the LUT and CLU
independently.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.c | 60 ++++++++++++--------------
drivers/gpu/drm/rcar-du/rcar_cmm.h | 19 +++++---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 22 +++++++---
3 files changed, 55 insertions(+), 46 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.c b/drivers/gpu/drm/rcar-du/rcar_cmm.c
index e2a67dda4658..df768a9afb72 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.c
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.c
@@ -42,23 +42,33 @@ static inline void rcar_cmm_write(struct rcar_cmm *rcmm, u32 reg, u32 data)
iowrite32(data, rcmm->base + reg);
}
-/*
- * rcar_cmm_lut_write() - Scale the DRM LUT table entries to hardware precision
- * and write to the CMM registers
- * @rcmm: Pointer to the CMM device
- * @drm_lut: Pointer to the DRM LUT table
- */
-static void rcar_cmm_lut_write(struct rcar_cmm *rcmm,
- const struct drm_color_lut *drm_lut)
+static void rcar_cmm_lut_configure(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
{
- unsigned int i;
+ bool enable = !!table;
+
+ if (rcmm->lut.enabled != enable) {
+ rcar_cmm_write(rcmm, CM2_LUT_CTRL,
+ enable ? CM2_LUT_CTRL_LUT_EN : 0);
+ rcmm->lut.enabled = enable;
+ }
- for (i = 0; i < CM2_LUT_SIZE; ++i) {
- u32 entry = drm_color_lut_extract(drm_lut[i].red, 8) << 16
- | drm_color_lut_extract(drm_lut[i].green, 8) << 8
- | drm_color_lut_extract(drm_lut[i].blue, 8);
+ if (table) {
+ unsigned int i;
- rcar_cmm_write(rcmm, CM2_LUT_TBL(i), entry);
+ /*
+ * Scale the DRM LUT table entries to the hardware precision
+ * and program it.
+ */
+ for (i = 0; i < CM2_LUT_SIZE; ++i) {
+ const struct drm_color_lut *lut = &table[i];
+
+ u32 entry = drm_color_lut_extract(lut->red, 8) << 16
+ | drm_color_lut_extract(lut->green, 8) << 8
+ | drm_color_lut_extract(lut->blue, 8);
+
+ rcar_cmm_write(rcmm, CM2_LUT_TBL(i), entry);
+ }
}
}
@@ -83,23 +93,8 @@ int rcar_cmm_setup(struct platform_device *pdev,
{
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
- /* Disable LUT if no table is provided. */
- if (!config->lut.table) {
- if (rcmm->lut.enabled) {
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0);
- rcmm->lut.enabled = false;
- }
-
- return 0;
- }
-
- /* Enable LUT and program the new gamma table values. */
- if (!rcmm->lut.enabled) {
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, CM2_LUT_CTRL_LUT_EN);
- rcmm->lut.enabled = true;
- }
-
- rcar_cmm_lut_write(rcmm, config->lut.table);
+ if (config->lut.update)
+ rcar_cmm_lut_configure(rcmm, config->lut.table);
return 0;
}
@@ -144,8 +139,7 @@ void rcar_cmm_disable(struct platform_device *pdev)
{
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0);
- rcmm->lut.enabled = false;
+ rcar_cmm_lut_configure(rcmm, NULL);
pm_runtime_put(&pdev->dev);
}
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 628072acc98b..375a3b9c3db3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -13,16 +13,23 @@
struct drm_color_lut;
struct platform_device;
+/**
+ * struct rcar_cmm_table_config - CMM LUT configuration
+ * @update: When true, update the LUT configuration.
+ * @table: Table data. The LUT is enabled if non-NULL, and disabled
+ * otherwise. The value is ignored if @update is false.
+ */
+struct rcar_cmm_table_config {
+ bool update;
+ struct drm_color_lut *table;
+};
+
/**
* struct rcar_cmm_config - CMM configuration
- *
- * @lut: 1D-LUT configuration
- * @lut.table: 1D-LUT table entries. Disable LUT operations when NULL
+ * @lut: 1D-LUT configuration
*/
struct rcar_cmm_config {
- struct {
- struct drm_color_lut *table;
- } lut;
+ struct rcar_cmm_table_config lut;
};
#if IS_ENABLED(CONFIG_DRM_RCAR_CMM)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index d6d29be6b4f4..a2d477dc5a51 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -537,17 +537,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
return 0;
}
-static void rcar_du_cmm_setup(struct drm_crtc *crtc)
+static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
+ const struct drm_crtc_state *old_state,
+ const struct drm_crtc_state *new_state)
{
- struct drm_property_blob *drm_lut = crtc->state->gamma_lut;
- struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
struct rcar_cmm_config cmm_config = {};
if (!rcrtc->cmm)
return;
- if (drm_lut)
- cmm_config.lut.table = (struct drm_color_lut *)drm_lut->data;
+ if (!old_state ||
+ !old_state->gamma_lut != !new_state->gamma_lut ||
+ (old_state->gamma_lut && new_state->gamma_lut &&
+ old_state->gamma_lut->base.id != new_state->gamma_lut->base.id)) {
+ cmm_config.lut.update = true;
+ cmm_config.lut.table = new_state->gamma_lut
+ ? new_state->gamma_lut->data : NULL;
+ }
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
@@ -794,7 +800,7 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
* after the DU channel has been activated. Investigate the impact
* of this restriction on the first displayed frame.
*/
- rcar_du_cmm_setup(crtc);
+ rcar_du_cmm_setup(rcrtc, NULL, crtc->state);
}
static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -844,6 +850,8 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_atomic_state *state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
+ crtc);
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
WARN_ON(!crtc->state->enable);
@@ -864,7 +872,7 @@ static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
/* If the active state changed, we let .atomic_enable handle CMM. */
if (crtc->state->color_mgmt_changed && !crtc->state->active_changed)
- rcar_du_cmm_setup(crtc);
+ rcar_du_cmm_setup(rcrtc, old_state, crtc->state);
if (rcar_du_has(rcrtc->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
rcar_du_vsp_atomic_begin(rcrtc);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 6/9] drm: rcar-du: cmm: Refactor LUT configuration
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Laurent Pinchart, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, tzimmermann, sunpeng.li,
Sebastian Wick, mripard, Melissa Wen, Jacopo Mondi,
Pekka Paalanen, Xinhui.Pan, xaver.hugl, linux-renesas-soc,
alexander.deucher, christian.koenig, Joshua Ashton
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To prepare for CLU support, expend the CMM API exposed to the DU driver
to separate the LUT table pointer from the LUT update decision. This
will be required, as we will need to update the LUT and CLU
independently.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.c | 60 ++++++++++++--------------
drivers/gpu/drm/rcar-du/rcar_cmm.h | 19 +++++---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 22 +++++++---
3 files changed, 55 insertions(+), 46 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.c b/drivers/gpu/drm/rcar-du/rcar_cmm.c
index e2a67dda4658..df768a9afb72 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.c
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.c
@@ -42,23 +42,33 @@ static inline void rcar_cmm_write(struct rcar_cmm *rcmm, u32 reg, u32 data)
iowrite32(data, rcmm->base + reg);
}
-/*
- * rcar_cmm_lut_write() - Scale the DRM LUT table entries to hardware precision
- * and write to the CMM registers
- * @rcmm: Pointer to the CMM device
- * @drm_lut: Pointer to the DRM LUT table
- */
-static void rcar_cmm_lut_write(struct rcar_cmm *rcmm,
- const struct drm_color_lut *drm_lut)
+static void rcar_cmm_lut_configure(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
{
- unsigned int i;
+ bool enable = !!table;
+
+ if (rcmm->lut.enabled != enable) {
+ rcar_cmm_write(rcmm, CM2_LUT_CTRL,
+ enable ? CM2_LUT_CTRL_LUT_EN : 0);
+ rcmm->lut.enabled = enable;
+ }
- for (i = 0; i < CM2_LUT_SIZE; ++i) {
- u32 entry = drm_color_lut_extract(drm_lut[i].red, 8) << 16
- | drm_color_lut_extract(drm_lut[i].green, 8) << 8
- | drm_color_lut_extract(drm_lut[i].blue, 8);
+ if (table) {
+ unsigned int i;
- rcar_cmm_write(rcmm, CM2_LUT_TBL(i), entry);
+ /*
+ * Scale the DRM LUT table entries to the hardware precision
+ * and program it.
+ */
+ for (i = 0; i < CM2_LUT_SIZE; ++i) {
+ const struct drm_color_lut *lut = &table[i];
+
+ u32 entry = drm_color_lut_extract(lut->red, 8) << 16
+ | drm_color_lut_extract(lut->green, 8) << 8
+ | drm_color_lut_extract(lut->blue, 8);
+
+ rcar_cmm_write(rcmm, CM2_LUT_TBL(i), entry);
+ }
}
}
@@ -83,23 +93,8 @@ int rcar_cmm_setup(struct platform_device *pdev,
{
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
- /* Disable LUT if no table is provided. */
- if (!config->lut.table) {
- if (rcmm->lut.enabled) {
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0);
- rcmm->lut.enabled = false;
- }
-
- return 0;
- }
-
- /* Enable LUT and program the new gamma table values. */
- if (!rcmm->lut.enabled) {
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, CM2_LUT_CTRL_LUT_EN);
- rcmm->lut.enabled = true;
- }
-
- rcar_cmm_lut_write(rcmm, config->lut.table);
+ if (config->lut.update)
+ rcar_cmm_lut_configure(rcmm, config->lut.table);
return 0;
}
@@ -144,8 +139,7 @@ void rcar_cmm_disable(struct platform_device *pdev)
{
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
- rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0);
- rcmm->lut.enabled = false;
+ rcar_cmm_lut_configure(rcmm, NULL);
pm_runtime_put(&pdev->dev);
}
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 628072acc98b..375a3b9c3db3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -13,16 +13,23 @@
struct drm_color_lut;
struct platform_device;
+/**
+ * struct rcar_cmm_table_config - CMM LUT configuration
+ * @update: When true, update the LUT configuration.
+ * @table: Table data. The LUT is enabled if non-NULL, and disabled
+ * otherwise. The value is ignored if @update is false.
+ */
+struct rcar_cmm_table_config {
+ bool update;
+ struct drm_color_lut *table;
+};
+
/**
* struct rcar_cmm_config - CMM configuration
- *
- * @lut: 1D-LUT configuration
- * @lut.table: 1D-LUT table entries. Disable LUT operations when NULL
+ * @lut: 1D-LUT configuration
*/
struct rcar_cmm_config {
- struct {
- struct drm_color_lut *table;
- } lut;
+ struct rcar_cmm_table_config lut;
};
#if IS_ENABLED(CONFIG_DRM_RCAR_CMM)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index d6d29be6b4f4..a2d477dc5a51 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -537,17 +537,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
return 0;
}
-static void rcar_du_cmm_setup(struct drm_crtc *crtc)
+static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
+ const struct drm_crtc_state *old_state,
+ const struct drm_crtc_state *new_state)
{
- struct drm_property_blob *drm_lut = crtc->state->gamma_lut;
- struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
struct rcar_cmm_config cmm_config = {};
if (!rcrtc->cmm)
return;
- if (drm_lut)
- cmm_config.lut.table = (struct drm_color_lut *)drm_lut->data;
+ if (!old_state ||
+ !old_state->gamma_lut != !new_state->gamma_lut ||
+ (old_state->gamma_lut && new_state->gamma_lut &&
+ old_state->gamma_lut->base.id != new_state->gamma_lut->base.id)) {
+ cmm_config.lut.update = true;
+ cmm_config.lut.table = new_state->gamma_lut
+ ? new_state->gamma_lut->data : NULL;
+ }
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
@@ -794,7 +800,7 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
* after the DU channel has been activated. Investigate the impact
* of this restriction on the first displayed frame.
*/
- rcar_du_cmm_setup(crtc);
+ rcar_du_cmm_setup(rcrtc, NULL, crtc->state);
}
static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -844,6 +850,8 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc *crtc,
static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_atomic_state *state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
+ crtc);
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
WARN_ON(!crtc->state->enable);
@@ -864,7 +872,7 @@ static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
/* If the active state changed, we let .atomic_enable handle CMM. */
if (crtc->state->color_mgmt_changed && !crtc->state->active_changed)
- rcar_du_cmm_setup(crtc);
+ rcar_du_cmm_setup(rcrtc, old_state, crtc->state);
if (rcar_du_has(rcrtc->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
rcar_du_vsp_atomic_begin(rcrtc);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 7/9] drm: rcar-du: cmm: Provide 3D-CLU support
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Laurent Pinchart, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, harry.wentland, tzimmermann,
sunpeng.li, maarten.lankhorst, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan,
xaver.hugl, linux-renesas-soc, daniel, alexander.deucher,
christian.koenig, Joshua Ashton
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
The CMM module provides a three-dimensional cubic look up table that
converts three-color-component data into desired three color components
by use of a lookup table.
While the 1D-LUT can only control each of three color components
separately, the 3D-CLU can be used for specific color adjustment.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.c | 71 +++++++++++++++++++++++++++++-
drivers/gpu/drm/rcar-du/rcar_cmm.h | 11 +++--
2 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.c b/drivers/gpu/drm/rcar-du/rcar_cmm.c
index df768a9afb72..defedfaf8f56 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.c
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.c
@@ -17,9 +17,18 @@
#define CM2_LUT_CTRL 0x0000
#define CM2_LUT_CTRL_LUT_EN BIT(0)
+
+#define CM2_CLU_CTRL 0x0100
+#define CM2_CLU_CTRL_CLU_EN BIT(0)
+#define CM2_CLU_CTRL_MVS BIT(24)
+#define CM2_CLU_CTRL_AAI BIT(28)
+
#define CM2_LUT_TBL_BASE 0x0600
#define CM2_LUT_TBL(__i) (CM2_LUT_TBL_BASE + (__i) * 4)
+#define CM2_CLU_ADDR 0x0a00
+#define CM2_CLU_DATA 0x0a04
+
struct rcar_cmm {
void __iomem *base;
@@ -30,6 +39,10 @@ struct rcar_cmm {
struct {
bool enabled;
} lut;
+
+ struct {
+ bool enabled;
+ } clu;
};
static inline int rcar_cmm_read(struct rcar_cmm *rcmm, u32 reg)
@@ -72,13 +85,63 @@ static void rcar_cmm_lut_configure(struct rcar_cmm *rcmm,
}
}
+static void rcar_cmm_clu_program(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
+{
+ unsigned int i;
+
+ /* Utilise CM2_CLU_CTRL_AAI (auto-increment). */
+ rcar_cmm_write(rcmm, CM2_CLU_ADDR, 0);
+
+ for (i = 0; i < CM2_CLU_SIZE; ++i) {
+ const struct drm_color_lut *lut = &table[i];
+
+ u32 entry = drm_color_lut_extract(lut->red, 8) << 16
+ | drm_color_lut_extract(lut->green, 8) << 8
+ | drm_color_lut_extract(lut->blue, 8);
+
+ rcar_cmm_write(rcmm, CM2_CLU_DATA, entry);
+ }
+}
+
+static void rcar_cmm_clu_configure(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
+{
+ static const u32 clu_ctrl = CM2_CLU_CTRL_AAI | CM2_CLU_CTRL_MVS
+ | CM2_CLU_CTRL_CLU_EN;
+ bool enable = !!table;
+
+ if (rcmm->clu.enabled != enable) {
+ /*
+ * This is the first run of the CLU. We need to program
+ * the CLU data before enabling the peripheral.
+ */
+ if (enable) {
+ rcar_cmm_write(rcmm, CM2_CLU_CTRL, CM2_CLU_CTRL_AAI);
+ rcar_cmm_clu_program(rcmm, table);
+ }
+
+ rcar_cmm_write(rcmm, CM2_CLU_CTRL, enable ? clu_ctrl : 0);
+ rcmm->clu.enabled = enable;
+
+ return;
+ }
+
+ /*
+ * CLU already enabled, but the 3D LUT has been updated; re-program
+ * the data table with the new values.
+ */
+ if (table)
+ rcar_cmm_clu_program(rcmm, table);
+}
+
/*
* rcar_cmm_setup() - Configure the CMM unit
* @pdev: The platform device associated with the CMM instance
* @config: The CMM unit configuration
*
- * Configure the CMM unit with the given configuration. Currently enabling,
- * disabling and programming of the 1-D LUT unit is supported.
+ * Configure the CMM unit with the given configuration, handling both the
+ * 1-D LUT and the 3-D CLU.
*
* As rcar_cmm_setup() accesses the CMM registers the unit should be powered
* and its functional clock enabled. To guarantee this, before any call to
@@ -96,6 +159,9 @@ int rcar_cmm_setup(struct platform_device *pdev,
if (config->lut.update)
rcar_cmm_lut_configure(rcmm, config->lut.table);
+ if (config->clu.update)
+ rcar_cmm_clu_configure(rcmm, config->clu.table);
+
return 0;
}
EXPORT_SYMBOL_GPL(rcar_cmm_setup);
@@ -140,6 +206,7 @@ void rcar_cmm_disable(struct platform_device *pdev)
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
rcar_cmm_lut_configure(rcmm, NULL);
+ rcar_cmm_clu_configure(rcmm, NULL);
pm_runtime_put(&pdev->dev);
}
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 375a3b9c3db3..277b9e4d9cc4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -9,14 +9,15 @@
#define __RCAR_CMM_H__
#define CM2_LUT_SIZE 256
+#define CM2_CLU_SIZE (17 * 17 * 17)
struct drm_color_lut;
struct platform_device;
/**
- * struct rcar_cmm_table_config - CMM LUT configuration
- * @update: When true, update the LUT configuration.
- * @table: Table data. The LUT is enabled if non-NULL, and disabled
+ * struct rcar_cmm_table_config - CMM LUT and CLU configuration
+ * @update: When true, update the LUT or CLU configuration.
+ * @table: Table data. The LUT or CLU is enabled if non-NULL, and disabled
* otherwise. The value is ignored if @update is false.
*/
struct rcar_cmm_table_config {
@@ -26,10 +27,12 @@ struct rcar_cmm_table_config {
/**
* struct rcar_cmm_config - CMM configuration
- * @lut: 1D-LUT configuration
+ * @lut: 1D LUT configuration
+ * @clu: 3D (cubic) LUT configuration
*/
struct rcar_cmm_config {
struct rcar_cmm_table_config lut;
+ struct rcar_cmm_table_config clu;
};
#if IS_ENABLED(CONFIG_DRM_RCAR_CMM)
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 7/9] drm: rcar-du: cmm: Provide 3D-CLU support
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc, Laurent Pinchart
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
The CMM module provides a three-dimensional cubic look up table that
converts three-color-component data into desired three color components
by use of a lookup table.
While the 1D-LUT can only control each of three color components
separately, the 3D-CLU can be used for specific color adjustment.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.c | 71 +++++++++++++++++++++++++++++-
drivers/gpu/drm/rcar-du/rcar_cmm.h | 11 +++--
2 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.c b/drivers/gpu/drm/rcar-du/rcar_cmm.c
index df768a9afb72..defedfaf8f56 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.c
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.c
@@ -17,9 +17,18 @@
#define CM2_LUT_CTRL 0x0000
#define CM2_LUT_CTRL_LUT_EN BIT(0)
+
+#define CM2_CLU_CTRL 0x0100
+#define CM2_CLU_CTRL_CLU_EN BIT(0)
+#define CM2_CLU_CTRL_MVS BIT(24)
+#define CM2_CLU_CTRL_AAI BIT(28)
+
#define CM2_LUT_TBL_BASE 0x0600
#define CM2_LUT_TBL(__i) (CM2_LUT_TBL_BASE + (__i) * 4)
+#define CM2_CLU_ADDR 0x0a00
+#define CM2_CLU_DATA 0x0a04
+
struct rcar_cmm {
void __iomem *base;
@@ -30,6 +39,10 @@ struct rcar_cmm {
struct {
bool enabled;
} lut;
+
+ struct {
+ bool enabled;
+ } clu;
};
static inline int rcar_cmm_read(struct rcar_cmm *rcmm, u32 reg)
@@ -72,13 +85,63 @@ static void rcar_cmm_lut_configure(struct rcar_cmm *rcmm,
}
}
+static void rcar_cmm_clu_program(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
+{
+ unsigned int i;
+
+ /* Utilise CM2_CLU_CTRL_AAI (auto-increment). */
+ rcar_cmm_write(rcmm, CM2_CLU_ADDR, 0);
+
+ for (i = 0; i < CM2_CLU_SIZE; ++i) {
+ const struct drm_color_lut *lut = &table[i];
+
+ u32 entry = drm_color_lut_extract(lut->red, 8) << 16
+ | drm_color_lut_extract(lut->green, 8) << 8
+ | drm_color_lut_extract(lut->blue, 8);
+
+ rcar_cmm_write(rcmm, CM2_CLU_DATA, entry);
+ }
+}
+
+static void rcar_cmm_clu_configure(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
+{
+ static const u32 clu_ctrl = CM2_CLU_CTRL_AAI | CM2_CLU_CTRL_MVS
+ | CM2_CLU_CTRL_CLU_EN;
+ bool enable = !!table;
+
+ if (rcmm->clu.enabled != enable) {
+ /*
+ * This is the first run of the CLU. We need to program
+ * the CLU data before enabling the peripheral.
+ */
+ if (enable) {
+ rcar_cmm_write(rcmm, CM2_CLU_CTRL, CM2_CLU_CTRL_AAI);
+ rcar_cmm_clu_program(rcmm, table);
+ }
+
+ rcar_cmm_write(rcmm, CM2_CLU_CTRL, enable ? clu_ctrl : 0);
+ rcmm->clu.enabled = enable;
+
+ return;
+ }
+
+ /*
+ * CLU already enabled, but the 3D LUT has been updated; re-program
+ * the data table with the new values.
+ */
+ if (table)
+ rcar_cmm_clu_program(rcmm, table);
+}
+
/*
* rcar_cmm_setup() - Configure the CMM unit
* @pdev: The platform device associated with the CMM instance
* @config: The CMM unit configuration
*
- * Configure the CMM unit with the given configuration. Currently enabling,
- * disabling and programming of the 1-D LUT unit is supported.
+ * Configure the CMM unit with the given configuration, handling both the
+ * 1-D LUT and the 3-D CLU.
*
* As rcar_cmm_setup() accesses the CMM registers the unit should be powered
* and its functional clock enabled. To guarantee this, before any call to
@@ -96,6 +159,9 @@ int rcar_cmm_setup(struct platform_device *pdev,
if (config->lut.update)
rcar_cmm_lut_configure(rcmm, config->lut.table);
+ if (config->clu.update)
+ rcar_cmm_clu_configure(rcmm, config->clu.table);
+
return 0;
}
EXPORT_SYMBOL_GPL(rcar_cmm_setup);
@@ -140,6 +206,7 @@ void rcar_cmm_disable(struct platform_device *pdev)
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
rcar_cmm_lut_configure(rcmm, NULL);
+ rcar_cmm_clu_configure(rcmm, NULL);
pm_runtime_put(&pdev->dev);
}
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 375a3b9c3db3..277b9e4d9cc4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -9,14 +9,15 @@
#define __RCAR_CMM_H__
#define CM2_LUT_SIZE 256
+#define CM2_CLU_SIZE (17 * 17 * 17)
struct drm_color_lut;
struct platform_device;
/**
- * struct rcar_cmm_table_config - CMM LUT configuration
- * @update: When true, update the LUT configuration.
- * @table: Table data. The LUT is enabled if non-NULL, and disabled
+ * struct rcar_cmm_table_config - CMM LUT and CLU configuration
+ * @update: When true, update the LUT or CLU configuration.
+ * @table: Table data. The LUT or CLU is enabled if non-NULL, and disabled
* otherwise. The value is ignored if @update is false.
*/
struct rcar_cmm_table_config {
@@ -26,10 +27,12 @@ struct rcar_cmm_table_config {
/**
* struct rcar_cmm_config - CMM configuration
- * @lut: 1D-LUT configuration
+ * @lut: 1D LUT configuration
+ * @clu: 3D (cubic) LUT configuration
*/
struct rcar_cmm_config {
struct rcar_cmm_table_config lut;
+ struct rcar_cmm_table_config clu;
};
#if IS_ENABLED(CONFIG_DRM_RCAR_CMM)
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 7/9] drm: rcar-du: cmm: Provide 3D-CLU support
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Laurent Pinchart, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, tzimmermann, sunpeng.li,
Sebastian Wick, mripard, Melissa Wen, Jacopo Mondi,
Pekka Paalanen, Xinhui.Pan, xaver.hugl, linux-renesas-soc,
alexander.deucher, christian.koenig, Joshua Ashton
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
The CMM module provides a three-dimensional cubic look up table that
converts three-color-component data into desired three color components
by use of a lookup table.
While the 1D-LUT can only control each of three color components
separately, the 3D-CLU can be used for specific color adjustment.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.c | 71 +++++++++++++++++++++++++++++-
drivers/gpu/drm/rcar-du/rcar_cmm.h | 11 +++--
2 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.c b/drivers/gpu/drm/rcar-du/rcar_cmm.c
index df768a9afb72..defedfaf8f56 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.c
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.c
@@ -17,9 +17,18 @@
#define CM2_LUT_CTRL 0x0000
#define CM2_LUT_CTRL_LUT_EN BIT(0)
+
+#define CM2_CLU_CTRL 0x0100
+#define CM2_CLU_CTRL_CLU_EN BIT(0)
+#define CM2_CLU_CTRL_MVS BIT(24)
+#define CM2_CLU_CTRL_AAI BIT(28)
+
#define CM2_LUT_TBL_BASE 0x0600
#define CM2_LUT_TBL(__i) (CM2_LUT_TBL_BASE + (__i) * 4)
+#define CM2_CLU_ADDR 0x0a00
+#define CM2_CLU_DATA 0x0a04
+
struct rcar_cmm {
void __iomem *base;
@@ -30,6 +39,10 @@ struct rcar_cmm {
struct {
bool enabled;
} lut;
+
+ struct {
+ bool enabled;
+ } clu;
};
static inline int rcar_cmm_read(struct rcar_cmm *rcmm, u32 reg)
@@ -72,13 +85,63 @@ static void rcar_cmm_lut_configure(struct rcar_cmm *rcmm,
}
}
+static void rcar_cmm_clu_program(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
+{
+ unsigned int i;
+
+ /* Utilise CM2_CLU_CTRL_AAI (auto-increment). */
+ rcar_cmm_write(rcmm, CM2_CLU_ADDR, 0);
+
+ for (i = 0; i < CM2_CLU_SIZE; ++i) {
+ const struct drm_color_lut *lut = &table[i];
+
+ u32 entry = drm_color_lut_extract(lut->red, 8) << 16
+ | drm_color_lut_extract(lut->green, 8) << 8
+ | drm_color_lut_extract(lut->blue, 8);
+
+ rcar_cmm_write(rcmm, CM2_CLU_DATA, entry);
+ }
+}
+
+static void rcar_cmm_clu_configure(struct rcar_cmm *rcmm,
+ const struct drm_color_lut *table)
+{
+ static const u32 clu_ctrl = CM2_CLU_CTRL_AAI | CM2_CLU_CTRL_MVS
+ | CM2_CLU_CTRL_CLU_EN;
+ bool enable = !!table;
+
+ if (rcmm->clu.enabled != enable) {
+ /*
+ * This is the first run of the CLU. We need to program
+ * the CLU data before enabling the peripheral.
+ */
+ if (enable) {
+ rcar_cmm_write(rcmm, CM2_CLU_CTRL, CM2_CLU_CTRL_AAI);
+ rcar_cmm_clu_program(rcmm, table);
+ }
+
+ rcar_cmm_write(rcmm, CM2_CLU_CTRL, enable ? clu_ctrl : 0);
+ rcmm->clu.enabled = enable;
+
+ return;
+ }
+
+ /*
+ * CLU already enabled, but the 3D LUT has been updated; re-program
+ * the data table with the new values.
+ */
+ if (table)
+ rcar_cmm_clu_program(rcmm, table);
+}
+
/*
* rcar_cmm_setup() - Configure the CMM unit
* @pdev: The platform device associated with the CMM instance
* @config: The CMM unit configuration
*
- * Configure the CMM unit with the given configuration. Currently enabling,
- * disabling and programming of the 1-D LUT unit is supported.
+ * Configure the CMM unit with the given configuration, handling both the
+ * 1-D LUT and the 3-D CLU.
*
* As rcar_cmm_setup() accesses the CMM registers the unit should be powered
* and its functional clock enabled. To guarantee this, before any call to
@@ -96,6 +159,9 @@ int rcar_cmm_setup(struct platform_device *pdev,
if (config->lut.update)
rcar_cmm_lut_configure(rcmm, config->lut.table);
+ if (config->clu.update)
+ rcar_cmm_clu_configure(rcmm, config->clu.table);
+
return 0;
}
EXPORT_SYMBOL_GPL(rcar_cmm_setup);
@@ -140,6 +206,7 @@ void rcar_cmm_disable(struct platform_device *pdev)
struct rcar_cmm *rcmm = platform_get_drvdata(pdev);
rcar_cmm_lut_configure(rcmm, NULL);
+ rcar_cmm_clu_configure(rcmm, NULL);
pm_runtime_put(&pdev->dev);
}
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 375a3b9c3db3..277b9e4d9cc4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -9,14 +9,15 @@
#define __RCAR_CMM_H__
#define CM2_LUT_SIZE 256
+#define CM2_CLU_SIZE (17 * 17 * 17)
struct drm_color_lut;
struct platform_device;
/**
- * struct rcar_cmm_table_config - CMM LUT configuration
- * @update: When true, update the LUT configuration.
- * @table: Table data. The LUT is enabled if non-NULL, and disabled
+ * struct rcar_cmm_table_config - CMM LUT and CLU configuration
+ * @update: When true, update the LUT or CLU configuration.
+ * @table: Table data. The LUT or CLU is enabled if non-NULL, and disabled
* otherwise. The value is ignored if @update is false.
*/
struct rcar_cmm_table_config {
@@ -26,10 +27,12 @@ struct rcar_cmm_table_config {
/**
* struct rcar_cmm_config - CMM configuration
- * @lut: 1D-LUT configuration
+ * @lut: 1D LUT configuration
+ * @clu: 3D (cubic) LUT configuration
*/
struct rcar_cmm_config {
struct rcar_cmm_table_config lut;
+ struct rcar_cmm_table_config clu;
};
#if IS_ENABLED(CONFIG_DRM_RCAR_CMM)
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 8/9] drm: rcar-du: kms: Configure the CLU
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Laurent Pinchart, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, harry.wentland, tzimmermann,
sunpeng.li, maarten.lankhorst, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan,
xaver.hugl, linux-renesas-soc, daniel, alexander.deucher,
christian.koenig, Joshua Ashton
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Link the DRM 3D-CLU configuration to the CMM setup configuration.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index a2d477dc5a51..895a23161f7b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -521,19 +521,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
struct drm_crtc_state *state)
{
struct drm_property_blob *drm_lut = state->gamma_lut;
+ struct drm_property_blob *drm_clu = state->lut3d;
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
struct device *dev = rcrtc->dev->dev;
- if (!drm_lut)
- return 0;
-
- /* We only accept fully populated LUT tables. */
- if (drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
+ /* We only accept fully populated LUTs. */
+ if (drm_lut && drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
dev_err(dev, "invalid gamma lut size: %zu bytes\n",
drm_lut->length);
return -EINVAL;
}
+ if (drm_clu && drm_color_lut_size(drm_clu) != CM2_CLU_SIZE) {
+ dev_err(dev, "invalid cubic lut size: %zu bytes\n",
+ drm_clu->length);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -555,6 +559,15 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
? new_state->gamma_lut->data : NULL;
}
+ if (!old_state ||
+ !old_state->lut3d != !new_state->lut3d ||
+ (old_state->lut3d && new_state->lut3d &&
+ old_state->lut3d->base.id != new_state->lut3d->base.id)) {
+ cmm_config.clu.update = true;
+ cmm_config.clu.table = new_state->lut3d
+ ? new_state->lut3d->data : NULL;
+ }
+
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 8/9] drm: rcar-du: kms: Configure the CLU
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc, Laurent Pinchart
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Link the DRM 3D-CLU configuration to the CMM setup configuration.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index a2d477dc5a51..895a23161f7b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -521,19 +521,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
struct drm_crtc_state *state)
{
struct drm_property_blob *drm_lut = state->gamma_lut;
+ struct drm_property_blob *drm_clu = state->lut3d;
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
struct device *dev = rcrtc->dev->dev;
- if (!drm_lut)
- return 0;
-
- /* We only accept fully populated LUT tables. */
- if (drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
+ /* We only accept fully populated LUTs. */
+ if (drm_lut && drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
dev_err(dev, "invalid gamma lut size: %zu bytes\n",
drm_lut->length);
return -EINVAL;
}
+ if (drm_clu && drm_color_lut_size(drm_clu) != CM2_CLU_SIZE) {
+ dev_err(dev, "invalid cubic lut size: %zu bytes\n",
+ drm_clu->length);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -555,6 +559,15 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
? new_state->gamma_lut->data : NULL;
}
+ if (!old_state ||
+ !old_state->lut3d != !new_state->lut3d ||
+ (old_state->lut3d && new_state->lut3d &&
+ old_state->lut3d->base.id != new_state->lut3d->base.id)) {
+ cmm_config.clu.update = true;
+ cmm_config.clu.table = new_state->lut3d
+ ? new_state->lut3d->data : NULL;
+ }
+
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 8/9] drm: rcar-du: kms: Configure the CLU
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Laurent Pinchart, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, tzimmermann, sunpeng.li,
Sebastian Wick, mripard, Melissa Wen, Jacopo Mondi,
Pekka Paalanen, Xinhui.Pan, xaver.hugl, linux-renesas-soc,
alexander.deucher, christian.koenig, Joshua Ashton
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Link the DRM 3D-CLU configuration to the CMM setup configuration.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index a2d477dc5a51..895a23161f7b 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -521,19 +521,23 @@ static int rcar_du_cmm_check(struct drm_crtc *crtc,
struct drm_crtc_state *state)
{
struct drm_property_blob *drm_lut = state->gamma_lut;
+ struct drm_property_blob *drm_clu = state->lut3d;
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
struct device *dev = rcrtc->dev->dev;
- if (!drm_lut)
- return 0;
-
- /* We only accept fully populated LUT tables. */
- if (drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
+ /* We only accept fully populated LUTs. */
+ if (drm_lut && drm_color_lut_size(drm_lut) != CM2_LUT_SIZE) {
dev_err(dev, "invalid gamma lut size: %zu bytes\n",
drm_lut->length);
return -EINVAL;
}
+ if (drm_clu && drm_color_lut_size(drm_clu) != CM2_CLU_SIZE) {
+ dev_err(dev, "invalid cubic lut size: %zu bytes\n",
+ drm_clu->length);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -555,6 +559,15 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
? new_state->gamma_lut->data : NULL;
}
+ if (!old_state ||
+ !old_state->lut3d != !new_state->lut3d ||
+ (old_state->lut3d && new_state->lut3d &&
+ old_state->lut3d->base.id != new_state->lut3d->base.id)) {
+ cmm_config.clu.update = true;
+ cmm_config.clu.table = new_state->lut3d
+ ? new_state->lut3d->data : NULL;
+ }
+
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 9/9] drm: rcar-du: crtc: Enable 3D LUT
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 8:10 ` Jacopo Mondi
-1 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, airlied, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, harry.wentland, tzimmermann, sunpeng.li,
maarten.lankhorst, Sebastian Wick, mripard, Melissa Wen,
Jacopo Mondi, Pekka Paalanen, Simon Ser, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
Enable the 3D LUT in rcar_du_crtc by first creating a property for
the supported 3d lut modes and by calling the drm_crtc_enable_lut3d()
helper.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.h | 14 ++++++++++++++
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 +++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 277b9e4d9cc4..eed9e480a96f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -8,6 +8,8 @@
#ifndef __RCAR_CMM_H__
#define __RCAR_CMM_H__
+#include <drm/drm_fourcc.h>
+
#define CM2_LUT_SIZE 256
#define CM2_CLU_SIZE (17 * 17 * 17)
@@ -43,6 +45,16 @@ void rcar_cmm_disable(struct platform_device *pdev);
int rcar_cmm_setup(struct platform_device *pdev,
const struct rcar_cmm_config *config);
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = {
+ {
+ .lut_size = 17,
+ .lut_stride = {17, 17, 17},
+ .bit_depth = 8,
+ .color_format = DRM_FORMAT_XRGB16161616,
+ .flags = 0,
+ },
+};
#else
static inline int rcar_cmm_init(struct platform_device *pdev)
{
@@ -63,6 +75,8 @@ static inline int rcar_cmm_setup(struct platform_device *pdev,
{
return 0;
}
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = { };
#endif /* IS_ENABLED(CONFIG_DRM_RCAR_CMM) */
#endif /* __RCAR_CMM_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 895a23161f7b..126083d226d2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -571,6 +571,24 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
+static int rcar_du_cmm_enable_color_mgmt(struct rcar_du_crtc *rcrtc)
+{
+ struct drm_crtc *crtc = &rcrtc->crtc;
+ int ret;
+
+ drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
+ drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+
+ ret = drm_crtc_create_lut3d_mode_property(crtc, rcar_cmm_3dlut_modes,
+ ARRAY_SIZE(rcar_cmm_3dlut_modes));
+ if (ret)
+ return ret;
+
+ drm_crtc_enable_lut3d(crtc, 0);
+
+ return 0;
+}
+
/* -----------------------------------------------------------------------------
* Start/Stop and Suspend/Resume
*/
@@ -1355,8 +1373,9 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
rcrtc->cmm = rcdu->cmms[swindex];
rgrp->cmms_mask |= BIT(hwindex % 2);
- drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
- drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+ ret = rcar_du_cmm_enable_color_mgmt(rcrtc);
+ if (ret)
+ return ret;
}
drm_crtc_helper_add(crtc, &crtc_helper_funcs);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 9/9] drm: rcar-du: crtc: Enable 3D LUT
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Jacopo Mondi, Simon Ser, Pekka Paalanen, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
Enable the 3D LUT in rcar_du_crtc by first creating a property for
the supported 3d lut modes and by calling the drm_crtc_enable_lut3d()
helper.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.h | 14 ++++++++++++++
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 +++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 277b9e4d9cc4..eed9e480a96f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -8,6 +8,8 @@
#ifndef __RCAR_CMM_H__
#define __RCAR_CMM_H__
+#include <drm/drm_fourcc.h>
+
#define CM2_LUT_SIZE 256
#define CM2_CLU_SIZE (17 * 17 * 17)
@@ -43,6 +45,16 @@ void rcar_cmm_disable(struct platform_device *pdev);
int rcar_cmm_setup(struct platform_device *pdev,
const struct rcar_cmm_config *config);
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = {
+ {
+ .lut_size = 17,
+ .lut_stride = {17, 17, 17},
+ .bit_depth = 8,
+ .color_format = DRM_FORMAT_XRGB16161616,
+ .flags = 0,
+ },
+};
#else
static inline int rcar_cmm_init(struct platform_device *pdev)
{
@@ -63,6 +75,8 @@ static inline int rcar_cmm_setup(struct platform_device *pdev,
{
return 0;
}
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = { };
#endif /* IS_ENABLED(CONFIG_DRM_RCAR_CMM) */
#endif /* __RCAR_CMM_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 895a23161f7b..126083d226d2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -571,6 +571,24 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
+static int rcar_du_cmm_enable_color_mgmt(struct rcar_du_crtc *rcrtc)
+{
+ struct drm_crtc *crtc = &rcrtc->crtc;
+ int ret;
+
+ drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
+ drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+
+ ret = drm_crtc_create_lut3d_mode_property(crtc, rcar_cmm_3dlut_modes,
+ ARRAY_SIZE(rcar_cmm_3dlut_modes));
+ if (ret)
+ return ret;
+
+ drm_crtc_enable_lut3d(crtc, 0);
+
+ return 0;
+}
+
/* -----------------------------------------------------------------------------
* Start/Stop and Suspend/Resume
*/
@@ -1355,8 +1373,9 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
rcrtc->cmm = rcdu->cmms[swindex];
rgrp->cmms_mask |= BIT(hwindex % 2);
- drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
- drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+ ret = rcar_du_cmm_enable_color_mgmt(rcrtc);
+ if (ret)
+ return ret;
}
drm_crtc_helper_add(crtc, &crtc_helper_funcs);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [RFC 9/9] drm: rcar-du: crtc: Enable 3D LUT
@ 2023-06-21 8:10 ` Jacopo Mondi
0 siblings, 0 replies; 33+ messages in thread
From: Jacopo Mondi @ 2023-06-21 8:10 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, aleixpol,
Rodrigo.Siqueira, amd-gfx, wayland-devel, Jonas Ådahl,
Uma Shankar, tzimmermann, sunpeng.li, Sebastian Wick, mripard,
Melissa Wen, Jacopo Mondi, Pekka Paalanen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, alexander.deucher, christian.koenig,
Joshua Ashton
Enable the 3D LUT in rcar_du_crtc by first creating a property for
the supported 3d lut modes and by calling the drm_crtc_enable_lut3d()
helper.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/gpu/drm/rcar-du/rcar_cmm.h | 14 ++++++++++++++
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 +++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 277b9e4d9cc4..eed9e480a96f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -8,6 +8,8 @@
#ifndef __RCAR_CMM_H__
#define __RCAR_CMM_H__
+#include <drm/drm_fourcc.h>
+
#define CM2_LUT_SIZE 256
#define CM2_CLU_SIZE (17 * 17 * 17)
@@ -43,6 +45,16 @@ void rcar_cmm_disable(struct platform_device *pdev);
int rcar_cmm_setup(struct platform_device *pdev,
const struct rcar_cmm_config *config);
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = {
+ {
+ .lut_size = 17,
+ .lut_stride = {17, 17, 17},
+ .bit_depth = 8,
+ .color_format = DRM_FORMAT_XRGB16161616,
+ .flags = 0,
+ },
+};
#else
static inline int rcar_cmm_init(struct platform_device *pdev)
{
@@ -63,6 +75,8 @@ static inline int rcar_cmm_setup(struct platform_device *pdev,
{
return 0;
}
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = { };
#endif /* IS_ENABLED(CONFIG_DRM_RCAR_CMM) */
#endif /* __RCAR_CMM_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 895a23161f7b..126083d226d2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -571,6 +571,24 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
}
+static int rcar_du_cmm_enable_color_mgmt(struct rcar_du_crtc *rcrtc)
+{
+ struct drm_crtc *crtc = &rcrtc->crtc;
+ int ret;
+
+ drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
+ drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+
+ ret = drm_crtc_create_lut3d_mode_property(crtc, rcar_cmm_3dlut_modes,
+ ARRAY_SIZE(rcar_cmm_3dlut_modes));
+ if (ret)
+ return ret;
+
+ drm_crtc_enable_lut3d(crtc, 0);
+
+ return 0;
+}
+
/* -----------------------------------------------------------------------------
* Start/Stop and Suspend/Resume
*/
@@ -1355,8 +1373,9 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
rcrtc->cmm = rcdu->cmms[swindex];
rgrp->cmms_mask |= BIT(hwindex % 2);
- drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
- drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+ ret = rcar_du_cmm_enable_color_mgmt(rcrtc);
+ if (ret)
+ return ret;
}
drm_crtc_helper_add(crtc, &crtc_helper_funcs);
--
2.40.1
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support
2023-06-21 8:10 ` Jacopo Mondi
(?)
@ 2023-06-21 10:33 ` Pekka Paalanen
-1 siblings, 0 replies; 33+ messages in thread
From: Pekka Paalanen @ 2023-06-21 10:33 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, Laurent Pinchart,
airlied, aleixpol, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, harry.wentland, tzimmermann,
sunpeng.li, maarten.lankhorst, Sebastian Wick, mripard,
Melissa Wen, Simon Ser, Xinhui.Pan, xaver.hugl, linux-renesas-soc,
Kieran Bingham, daniel, alexander.deucher, christian.koenig,
Joshua Ashton
[-- Attachment #1: Type: text/plain, Size: 3919 bytes --]
On Wed, 21 Jun 2023 10:10:22 +0200
Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote:
> Hello, this series is based on the RFC sent by Melssa Wen:
> "[RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface"
> https://lore.kernel.org/dri-devel/20230109143846.1966301-1-mwen@igalia.com/
> that introduces CRTC properties to control 3D LUT operations.
>
> The R-Car DU peripheral has a post-blending color management pipeline (CMM)
> composed by (in order of processing) a 3D LUT a 1D LUT and a Color conversion
> unit.
>
> The CMM driver already supported operating the 1D LUT, this series add support
> for the cubic LUT (named CLU).
>
> I've been made aware by Melissa and Pekka that the focus of upstream for
> color management properties is now on the definition of the "Plane color
> pipeline" properties
> https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
>
> Unfortunately the model there proposed doesn't match the R-Car DU hardware which
> has color management at the post-blending level and not per plane (I've cc-ed
> all the receivers of that series, just in case).
Hi,
what are the actual use cases for post-blending color pipelines?
The pre-blending per-plane color pipelines are important for future
Wayland compositors, and post-blending is probably mostly about just
encoding for the sink (applying some inverse EOTF), so I've been
wondering why the post-blending color hardware seems to be so prevalent
and well-developed compared to pre-blending.
Is the idea that composition happens in a standard fixed color space,
and the post-blending color pipeline converts that to sink-native color
space?
If so, how do systems get their input content into the composition
space first?
Or is all this just a side-effect of caring about color on a single
plane, and not care at all how other planes with other kinds of content
will look? (e.g. TV broadcast vs. sub-titles, program guide, OSD)
Thanks,
pq
> The user-space interface has been validated with dedicated unit tests for
> the R-Car DU test suite (kms-test) which are available at:
> https://git.sr.ht/~jmondi_/kms-test
>
> The series validates the usage of the HW interface in the hope of re-starting
> discussions and interests in the definition of CRTC color management
> properties.
>
> Thanks
> j
>
> Alex Hung (1):
> drm: Add 3D LUT mode and its attributes
>
> Jacopo Mondi (1):
> drm: rcar-du: crtc: Enable 3D LUT
>
> Kieran Bingham (2):
> drm: rcar-du: cmm: Provide 3D-CLU support
> drm: rcar-du: kms: Configure the CLU
>
> Laurent Pinchart (1):
> drm: rcar-du: cmm: Refactor LUT configuration
>
> Melissa Wen (4):
> drm/drm_color_mgmt: add shaper LUT to color mgmt properties
> drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
> drm/drm_color_mgmt: add function to create 3D LUT modes supported
> drm/drm_color_mgmt: add function to attach 3D LUT props
>
> drivers/gpu/drm/drm_atomic_state_helper.c | 7 ++
> drivers/gpu/drm/drm_atomic_uapi.c | 24 ++++
> drivers/gpu/drm/drm_color_mgmt.c | 113 +++++++++++++++++++
> drivers/gpu/drm/drm_fb_helper.c | 5 +
> drivers/gpu/drm/drm_mode_config.c | 21 ++++
> drivers/gpu/drm/rcar-du/rcar_cmm.c | 127 ++++++++++++++++------
> drivers/gpu/drm/rcar-du/rcar_cmm.h | 36 +++++-
> drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 68 +++++++++---
> include/drm/drm_color_mgmt.h | 7 ++
> include/drm/drm_crtc.h | 32 +++++-
> include/drm/drm_mode_config.h | 25 +++++
> include/drm/drm_mode_object.h | 2 +-
> include/uapi/drm/drm_mode.h | 17 +++
> 13 files changed, 428 insertions(+), 56 deletions(-)
>
> --
> 2.40.1
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support
@ 2023-06-21 10:33 ` Pekka Paalanen
0 siblings, 0 replies; 33+ messages in thread
From: Pekka Paalanen @ 2023-06-21 10:33 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Laurent Pinchart, Kieran Bingham, Simon Ser, Jonas Ådahl,
xaver.hugl, Melissa Wen, wayland-devel, mdaenzer, Uma Shankar,
Victoria Brekenfeld, aleixpol, Sebastian Wick, Joshua Ashton,
airlied, alexander.deucher, christian.koenig, daniel,
harry.wentland, maarten.lankhorst, mripard, Rodrigo.Siqueira,
sunpeng.li, tzimmermann, Xinhui.Pan, DRI Development, amd-gfx,
linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 3919 bytes --]
On Wed, 21 Jun 2023 10:10:22 +0200
Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote:
> Hello, this series is based on the RFC sent by Melssa Wen:
> "[RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface"
> https://lore.kernel.org/dri-devel/20230109143846.1966301-1-mwen@igalia.com/
> that introduces CRTC properties to control 3D LUT operations.
>
> The R-Car DU peripheral has a post-blending color management pipeline (CMM)
> composed by (in order of processing) a 3D LUT a 1D LUT and a Color conversion
> unit.
>
> The CMM driver already supported operating the 1D LUT, this series add support
> for the cubic LUT (named CLU).
>
> I've been made aware by Melissa and Pekka that the focus of upstream for
> color management properties is now on the definition of the "Plane color
> pipeline" properties
> https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
>
> Unfortunately the model there proposed doesn't match the R-Car DU hardware which
> has color management at the post-blending level and not per plane (I've cc-ed
> all the receivers of that series, just in case).
Hi,
what are the actual use cases for post-blending color pipelines?
The pre-blending per-plane color pipelines are important for future
Wayland compositors, and post-blending is probably mostly about just
encoding for the sink (applying some inverse EOTF), so I've been
wondering why the post-blending color hardware seems to be so prevalent
and well-developed compared to pre-blending.
Is the idea that composition happens in a standard fixed color space,
and the post-blending color pipeline converts that to sink-native color
space?
If so, how do systems get their input content into the composition
space first?
Or is all this just a side-effect of caring about color on a single
plane, and not care at all how other planes with other kinds of content
will look? (e.g. TV broadcast vs. sub-titles, program guide, OSD)
Thanks,
pq
> The user-space interface has been validated with dedicated unit tests for
> the R-Car DU test suite (kms-test) which are available at:
> https://git.sr.ht/~jmondi_/kms-test
>
> The series validates the usage of the HW interface in the hope of re-starting
> discussions and interests in the definition of CRTC color management
> properties.
>
> Thanks
> j
>
> Alex Hung (1):
> drm: Add 3D LUT mode and its attributes
>
> Jacopo Mondi (1):
> drm: rcar-du: crtc: Enable 3D LUT
>
> Kieran Bingham (2):
> drm: rcar-du: cmm: Provide 3D-CLU support
> drm: rcar-du: kms: Configure the CLU
>
> Laurent Pinchart (1):
> drm: rcar-du: cmm: Refactor LUT configuration
>
> Melissa Wen (4):
> drm/drm_color_mgmt: add shaper LUT to color mgmt properties
> drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
> drm/drm_color_mgmt: add function to create 3D LUT modes supported
> drm/drm_color_mgmt: add function to attach 3D LUT props
>
> drivers/gpu/drm/drm_atomic_state_helper.c | 7 ++
> drivers/gpu/drm/drm_atomic_uapi.c | 24 ++++
> drivers/gpu/drm/drm_color_mgmt.c | 113 +++++++++++++++++++
> drivers/gpu/drm/drm_fb_helper.c | 5 +
> drivers/gpu/drm/drm_mode_config.c | 21 ++++
> drivers/gpu/drm/rcar-du/rcar_cmm.c | 127 ++++++++++++++++------
> drivers/gpu/drm/rcar-du/rcar_cmm.h | 36 +++++-
> drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 68 +++++++++---
> include/drm/drm_color_mgmt.h | 7 ++
> include/drm/drm_crtc.h | 32 +++++-
> include/drm/drm_mode_config.h | 25 +++++
> include/drm/drm_mode_object.h | 2 +-
> include/uapi/drm/drm_mode.h | 17 +++
> 13 files changed, 428 insertions(+), 56 deletions(-)
>
> --
> 2.40.1
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support
@ 2023-06-21 10:33 ` Pekka Paalanen
0 siblings, 0 replies; 33+ messages in thread
From: Pekka Paalanen @ 2023-06-21 10:33 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Victoria Brekenfeld, DRI Development, mdaenzer, Laurent Pinchart,
aleixpol, Rodrigo.Siqueira, amd-gfx, wayland-devel,
Jonas Ådahl, Uma Shankar, tzimmermann, sunpeng.li,
Sebastian Wick, mripard, Melissa Wen, Xinhui.Pan, xaver.hugl,
linux-renesas-soc, Kieran Bingham, alexander.deucher,
christian.koenig, Joshua Ashton
[-- Attachment #1: Type: text/plain, Size: 3919 bytes --]
On Wed, 21 Jun 2023 10:10:22 +0200
Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote:
> Hello, this series is based on the RFC sent by Melssa Wen:
> "[RFC PATCH v2 00/18] Add DRM CRTC 3D LUT interface"
> https://lore.kernel.org/dri-devel/20230109143846.1966301-1-mwen@igalia.com/
> that introduces CRTC properties to control 3D LUT operations.
>
> The R-Car DU peripheral has a post-blending color management pipeline (CMM)
> composed by (in order of processing) a 3D LUT a 1D LUT and a Color conversion
> unit.
>
> The CMM driver already supported operating the 1D LUT, this series add support
> for the cubic LUT (named CLU).
>
> I've been made aware by Melissa and Pekka that the focus of upstream for
> color management properties is now on the definition of the "Plane color
> pipeline" properties
> https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
>
> Unfortunately the model there proposed doesn't match the R-Car DU hardware which
> has color management at the post-blending level and not per plane (I've cc-ed
> all the receivers of that series, just in case).
Hi,
what are the actual use cases for post-blending color pipelines?
The pre-blending per-plane color pipelines are important for future
Wayland compositors, and post-blending is probably mostly about just
encoding for the sink (applying some inverse EOTF), so I've been
wondering why the post-blending color hardware seems to be so prevalent
and well-developed compared to pre-blending.
Is the idea that composition happens in a standard fixed color space,
and the post-blending color pipeline converts that to sink-native color
space?
If so, how do systems get their input content into the composition
space first?
Or is all this just a side-effect of caring about color on a single
plane, and not care at all how other planes with other kinds of content
will look? (e.g. TV broadcast vs. sub-titles, program guide, OSD)
Thanks,
pq
> The user-space interface has been validated with dedicated unit tests for
> the R-Car DU test suite (kms-test) which are available at:
> https://git.sr.ht/~jmondi_/kms-test
>
> The series validates the usage of the HW interface in the hope of re-starting
> discussions and interests in the definition of CRTC color management
> properties.
>
> Thanks
> j
>
> Alex Hung (1):
> drm: Add 3D LUT mode and its attributes
>
> Jacopo Mondi (1):
> drm: rcar-du: crtc: Enable 3D LUT
>
> Kieran Bingham (2):
> drm: rcar-du: cmm: Provide 3D-CLU support
> drm: rcar-du: kms: Configure the CLU
>
> Laurent Pinchart (1):
> drm: rcar-du: cmm: Refactor LUT configuration
>
> Melissa Wen (4):
> drm/drm_color_mgmt: add shaper LUT to color mgmt properties
> drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt
> drm/drm_color_mgmt: add function to create 3D LUT modes supported
> drm/drm_color_mgmt: add function to attach 3D LUT props
>
> drivers/gpu/drm/drm_atomic_state_helper.c | 7 ++
> drivers/gpu/drm/drm_atomic_uapi.c | 24 ++++
> drivers/gpu/drm/drm_color_mgmt.c | 113 +++++++++++++++++++
> drivers/gpu/drm/drm_fb_helper.c | 5 +
> drivers/gpu/drm/drm_mode_config.c | 21 ++++
> drivers/gpu/drm/rcar-du/rcar_cmm.c | 127 ++++++++++++++++------
> drivers/gpu/drm/rcar-du/rcar_cmm.h | 36 +++++-
> drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 68 +++++++++---
> include/drm/drm_color_mgmt.h | 7 ++
> include/drm/drm_crtc.h | 32 +++++-
> include/drm/drm_mode_config.h | 25 +++++
> include/drm/drm_mode_object.h | 2 +-
> include/uapi/drm/drm_mode.h | 17 +++
> 13 files changed, 428 insertions(+), 56 deletions(-)
>
> --
> 2.40.1
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2023-06-21 15:39 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 8:10 [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 1/9] drm: Add 3D LUT mode and its attributes Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 2/9] drm/drm_color_mgmt: add shaper LUT to color mgmt properties Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 3/9] drm/drm_color_mgmt: add 3D LUT props to DRM color mgmt Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 4/9] drm/drm_color_mgmt: add function to create 3D LUT modes supported Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 5/9] drm/drm_color_mgmt: add function to attach 3D LUT props Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 6/9] drm: rcar-du: cmm: Refactor LUT configuration Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 7/9] drm: rcar-du: cmm: Provide 3D-CLU support Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 8/9] drm: rcar-du: kms: Configure the CLU Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` [RFC 9/9] drm: rcar-du: crtc: Enable 3D LUT Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 8:10 ` Jacopo Mondi
2023-06-21 10:33 ` [RFC 0/9] drm: rcar-du: cmm: Enable 3D LUT support Pekka Paalanen
2023-06-21 10:33 ` Pekka Paalanen
2023-06-21 10:33 ` Pekka Paalanen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.