All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Wick <sebastian.wick@redhat.com>
To: Joshua Ashton <joshua@froggi.es>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>,
	kernel-dev@igalia.com, Shashank Sharma <Shashank.Sharma@amd.com>,
	sunpeng.li@amd.com, Xinhui.Pan@amd.com,
	Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>,
	Xaver Hugl <xaver.hugl@gmail.com>,
	amd-gfx@lists.freedesktop.org,
	Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>,
	Melissa Wen <mwen@igalia.com>, Alex Hung <alex.hung@amd.com>,
	dri-devel@lists.freedesktop.org,
	Alex Deucher <alexander.deucher@amd.com>,
	christian.koenig@amd.com, sungjoon.kim@amd.com
Subject: Re: [PATCH 06/36] drm/amd/display: add CRTC driver-specific property for gamma TF
Date: Tue, 6 Jun 2023 18:26:55 +0200	[thread overview]
Message-ID: <CA+hFU4w3gwAaqvsiQW1Ns4ygi43ihn=iL7Y-Du_nH1RtKNP0sw@mail.gmail.com> (raw)
In-Reply-To: <47442442-794b-09da-4c70-1393344ce837@froggi.es>

On Tue, Jun 6, 2023 at 6:19 PM Joshua Ashton <joshua@froggi.es> wrote:
>
>
>
> On 6/1/23 20:17, Harry Wentland wrote:
> >
> >
> > On 5/23/23 18:14, Melissa Wen wrote:
> >> Hook up driver-specific atomic operations for managing AMD color
> >> properties and create AMD driver-specific color management properties
> >> and attach them according to HW capabilities defined by `struct
> >> dc_color_caps`. Add enumerated transfer function property to DRM CRTC
> >> gamma to convert to wire encoding with or without a user gamma LUT.
> >> Enumerated TFs are not supported yet by the DRM color pipeline,
> >> therefore, create a DRM enum list with the predefined TFs supported by
> >> the AMD display driver.
> >>
> >> Co-developed-by: Joshua Ashton <joshua@froggi.es>
> >> Signed-off-by: Joshua Ashton <joshua@froggi.es>
> >> Signed-off-by: Melissa Wen <mwen@igalia.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 36 ++++++++++
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  8 +++
> >>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 22 ++++++
> >>   .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c    | 72 ++++++++++++++++++-
> >>   4 files changed, 137 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >> index 389396eac222..88af075e6c18 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >> @@ -1247,6 +1247,38 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
> >>      return &amdgpu_fb->base;
> >>   }
> >>
> >> +static const struct drm_prop_enum_list drm_transfer_function_enum_list[] = {
> >> +    { DRM_TRANSFER_FUNCTION_DEFAULT, "Default" },
> >> +    { DRM_TRANSFER_FUNCTION_SRGB, "sRGB" },
> >> +    { DRM_TRANSFER_FUNCTION_BT709, "BT.709" },
> >> +    { DRM_TRANSFER_FUNCTION_PQ, "PQ (Perceptual Quantizer)" },
> >> +    { DRM_TRANSFER_FUNCTION_LINEAR, "Linear" },
> >> +    { DRM_TRANSFER_FUNCTION_UNITY, "Unity" },
> >> +    { DRM_TRANSFER_FUNCTION_HLG, "HLG (Hybrid Log Gamma)" },
> >> +    { DRM_TRANSFER_FUNCTION_GAMMA22, "Gamma 2.2" },
> >> +    { DRM_TRANSFER_FUNCTION_GAMMA24, "Gamma 2.4" },
> >> +    { DRM_TRANSFER_FUNCTION_GAMMA26, "Gamma 2.6" },
> >> +};
> >
> > Let's not use the DRM_/drm_ prefix here. It might clash later when
> > we introduce DRM_ core interfaces for enumerated transfer functions.
> >
> > We'll want to specify whether something is an EOTF or an inverse EOTF,
> > or possibly an OETF. Of course that wouldn't apply to "Linear" or
> > "Unity" (I'm assuming the two are the same?).
> >
> > EOTF = electro-optical transfer function
> > This is the transfer function to go from the encoded value to an
> > optical (linear) value.
> >
> > Inverse EOTF = simply the inverse of the EOTF
> > This is usually intended to go from an optical/linear space (which
> > might have been used for blending) back to the encoded values.
> >
> > OETF = opto-electronic transfer function
> > This is usually used for converting optical signals into encoded
> > values. Usually that's done on the camera side but I think HLG might
> > define the OETF instead of the EOTF. A bit fuzzy on that. If you're
> > unclear about HLG I recommend we don't include it yet.
> >
> > It would also be good to document a bit more what each of the TFs
> > mean, but I'm fine if that comes later with a "driver-agnostic"
> > API. The key thing to clarify is whether we have an EOTF or inv_EOTF,
> > i.e. whether we use the TF to go from encoded to optical or vice
> > versa.
>
> Whether we use the inverse or not is just determined per-block though.
>
> I think we should definitely document it per-block very explicitly
> (whether it is EOTF or inv EOTF) but I don't think we need to touch the
> enums here.

Either the drm prefix has to be removed or the enum variant names have
to be explicitly be the EOTF, OETF, inverse EOTF or inverse OETF.

> - Joshie 🐸✨
>
> >
> > I know DC is sloppy and doesn't define those but it will still use
> > them as either EOTF or inv_EOTF, based on which block they're being
> > programmed, if I'm not mistaken.
> >
> >> +
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +static int
> >> +amdgpu_display_create_color_properties(struct amdgpu_device *adev)
> >> +{
> >> +    struct drm_property *prop;
> >> +
> >> +    prop = drm_property_create_enum(adev_to_drm(adev),
> >> +                                    DRM_MODE_PROP_ENUM,
> >> +                                    "AMD_REGAMMA_TF",
> >> +                                    drm_transfer_function_enum_list,
> >> +                                    ARRAY_SIZE(drm_transfer_function_enum_list));
> >> +    if (!prop)
> >> +            return -ENOMEM;
> >> +    adev->mode_info.regamma_tf_property = prop;
> >> +
> >> +    return 0;
> >> +}
> >> +#endif
> >> +
> >
> > It'd be nice if we have this function and the above enum_list
> > in amdgpu_dm, possibly in amdgpu_dm_color.c. You could call it
> > directly after the amdgpu_display_modeset_create_prop() call in
> > amdgpu_dm_mode_config_init().
> >
> >>   const struct drm_mode_config_funcs amdgpu_mode_funcs = {
> >>      .fb_create = amdgpu_display_user_framebuffer_create,
> >>   };
> >> @@ -1323,6 +1355,10 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
> >>                      return -ENOMEM;
> >>      }
> >>
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +    if (amdgpu_display_create_color_properties(adev))
> >> +            return -ENOMEM;
> >> +#endif
> >>      return 0;
> >>   }
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> >> index b8633df418d4..881446c51b36 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> >> @@ -344,6 +344,14 @@ struct amdgpu_mode_info {
> >>      int                     disp_priority;
> >>      const struct amdgpu_display_funcs *funcs;
> >>      const enum drm_plane_type *plane_type;
> >> +
> >> +    /* Driver-private color mgmt props */
> >> +
> >> +    /* @regamma_tf_property: Transfer function for CRTC regamma
> >> +     * (post-blending). Possible values are defined by `enum
> >> +     * drm_transfer_function`.
> >> +     */
> >> +    struct drm_property *regamma_tf_property;
> >>   };
> >>
> >>   #define AMDGPU_MAX_BL_LEVEL 0xFF
> >> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> >> index 2e2413fd73a4..ad5ee28b83dc 100644
> >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> >> @@ -699,6 +699,20 @@ static inline void amdgpu_dm_set_mst_status(uint8_t *status,
> >>
> >>   extern const struct amdgpu_ip_block_version dm_ip_block;
> >>
> >> +enum drm_transfer_function {
> >> +    DRM_TRANSFER_FUNCTION_DEFAULT,
> >> +    DRM_TRANSFER_FUNCTION_SRGB,
> >> +    DRM_TRANSFER_FUNCTION_BT709,
> >> +    DRM_TRANSFER_FUNCTION_PQ,
> >> +    DRM_TRANSFER_FUNCTION_LINEAR,
> >> +    DRM_TRANSFER_FUNCTION_UNITY,
> >> +    DRM_TRANSFER_FUNCTION_HLG,
> >> +    DRM_TRANSFER_FUNCTION_GAMMA22,
> >> +    DRM_TRANSFER_FUNCTION_GAMMA24,
> >> +    DRM_TRANSFER_FUNCTION_GAMMA26,
> >> +    DRM_TRANSFER_FUNCTION_MAX,
> >> +};
> >> +
> >>   struct dm_plane_state {
> >>      struct drm_plane_state base;
> >>      struct dc_plane_state *dc_state;
> >> @@ -726,6 +740,14 @@ struct dm_crtc_state {
> >>      struct dc_info_packet vrr_infopacket;
> >>
> >>      int abm_level;
> >> +
> >> +        /**
> >> +     * @regamma_tf:
> >> +     *
> >> +     * Pre-defined transfer function for converting internal FB -> wire
> >> +     * encoding.
> >> +     */
> >> +    enum drm_transfer_function regamma_tf;
> >
> > Again, let's avoid a drm_ prefix. Maybe name all this amdgpu_ instead.
> >
> >>   };
> >>
> >>   #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
> >> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> >> index e3762e806617..1eb279d341c5 100644
> >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> >> @@ -229,7 +229,6 @@ static void dm_crtc_destroy_state(struct drm_crtc *crtc,
> >>      if (cur->stream)
> >>              dc_stream_release(cur->stream);
> >>
> >> -
> >
> > nit: stray newline
> >
> > Harry
> >
> >>      __drm_atomic_helper_crtc_destroy_state(state);
> >>
> >>
> >> @@ -263,6 +262,7 @@ static struct drm_crtc_state *dm_crtc_duplicate_state(struct drm_crtc *crtc)
> >>      state->freesync_config = cur->freesync_config;
> >>      state->cm_has_degamma = cur->cm_has_degamma;
> >>      state->cm_is_degamma_srgb = cur->cm_is_degamma_srgb;
> >> +    state->regamma_tf = cur->regamma_tf;
> >>      state->crc_skip_count = cur->crc_skip_count;
> >>      state->mpo_requested = cur->mpo_requested;
> >>      /* TODO Duplicate dc_stream after objects are stream object is flattened */
> >> @@ -299,6 +299,69 @@ static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
> >>   }
> >>   #endif
> >>
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +/**
> >> + * drm_crtc_additional_color_mgmt - enable additional color properties
> >> + * @crtc: DRM CRTC
> >> + *
> >> + * This function lets the driver enable the 3D LUT color correction property
> >> + * on a CRTC. This includes shaper LUT, 3D LUT and regamma TF. The shaper
> >> + * LUT and 3D LUT property is only attached if its size is not 0.
> >> + */
> >> +static void
> >> +dm_crtc_additional_color_mgmt(struct drm_crtc *crtc)
> >> +{
> >> +    struct amdgpu_device *adev = drm_to_adev(crtc->dev);
> >> +
> >> +    if(adev->dm.dc->caps.color.mpc.ogam_ram)
> >> +            drm_object_attach_property(&crtc->base,
> >> +                                       adev->mode_info.regamma_tf_property,
> >> +                                       DRM_TRANSFER_FUNCTION_DEFAULT);
> >> +}
> >> +
> >> +static int
> >> +amdgpu_dm_atomic_crtc_set_property(struct drm_crtc *crtc,
> >> +                               struct drm_crtc_state *state,
> >> +                               struct drm_property *property,
> >> +                               uint64_t val)
> >> +{
> >> +    struct amdgpu_device *adev = drm_to_adev(crtc->dev);
> >> +    struct dm_crtc_state *acrtc_state = to_dm_crtc_state(state);
> >> +
> >> +    if (property == adev->mode_info.regamma_tf_property) {
> >> +            if (acrtc_state->regamma_tf != val) {
> >> +                    acrtc_state->regamma_tf = val;
> >> +                    acrtc_state->base.color_mgmt_changed |= 1;
> >> +            }
> >> +    } else {
> >> +            drm_dbg_atomic(crtc->dev,
> >> +                           "[CRTC:%d:%s] unknown property [PROP:%d:%s]]\n",
> >> +                           crtc->base.id, crtc->name,
> >> +                           property->base.id, property->name);
> >> +            return -EINVAL;
> >> +    }
> >> +
> >> +    return 0;
> >> +}
> >> +
> >> +static int
> >> +amdgpu_dm_atomic_crtc_get_property(struct drm_crtc *crtc,
> >> +                               const struct drm_crtc_state *state,
> >> +                               struct drm_property *property,
> >> +                               uint64_t *val)
> >> +{
> >> +    struct amdgpu_device *adev = drm_to_adev(crtc->dev);
> >> +    struct dm_crtc_state *acrtc_state = to_dm_crtc_state(state);
> >> +
> >> +    if (property == adev->mode_info.regamma_tf_property)
> >> +            *val = acrtc_state->regamma_tf;
> >> +    else
> >> +            return -EINVAL;
> >> +
> >> +    return 0;
> >> +}
> >> +#endif
> >> +
> >>   /* Implemented only the options currently available for the driver */
> >>   static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
> >>      .reset = dm_crtc_reset_state,
> >> @@ -317,6 +380,10 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
> >>   #if defined(CONFIG_DEBUG_FS)
> >>      .late_register = amdgpu_dm_crtc_late_register,
> >>   #endif
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +    .atomic_set_property = amdgpu_dm_atomic_crtc_set_property,
> >> +    .atomic_get_property = amdgpu_dm_atomic_crtc_get_property,
> >> +#endif
> >>   };
> >>
> >>   static void dm_crtc_helper_disable(struct drm_crtc *crtc)
> >> @@ -480,6 +547,9 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
> >>
> >>      drm_mode_crtc_set_gamma_size(&acrtc->base, MAX_COLOR_LEGACY_LUT_ENTRIES);
> >>
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +    dm_crtc_additional_color_mgmt(&acrtc->base);
> >> +#endif
> >>      return 0;
> >>
> >>   fail:
> >
>


WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Wick <sebastian.wick@redhat.com>
To: Joshua Ashton <joshua@froggi.es>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>,
	kernel-dev@igalia.com, Shashank Sharma <Shashank.Sharma@amd.com>,
	sunpeng.li@amd.com, airlied@gmail.com, Xinhui.Pan@amd.com,
	Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>,
	Xaver Hugl <xaver.hugl@gmail.com>,
	amd-gfx@lists.freedesktop.org,
	Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>,
	Melissa Wen <mwen@igalia.com>, Alex Hung <alex.hung@amd.com>,
	dri-devel@lists.freedesktop.org, daniel@ffwll.ch,
	Simon Ser <contact@emersion.fr>,
	Alex Deucher <alexander.deucher@amd.com>,
	Harry Wentland <harry.wentland@amd.com>,
	christian.koenig@amd.com, sungjoon.kim@amd.com
Subject: Re: [PATCH 06/36] drm/amd/display: add CRTC driver-specific property for gamma TF
Date: Tue, 6 Jun 2023 18:26:55 +0200	[thread overview]
Message-ID: <CA+hFU4w3gwAaqvsiQW1Ns4ygi43ihn=iL7Y-Du_nH1RtKNP0sw@mail.gmail.com> (raw)
In-Reply-To: <47442442-794b-09da-4c70-1393344ce837@froggi.es>

On Tue, Jun 6, 2023 at 6:19 PM Joshua Ashton <joshua@froggi.es> wrote:
>
>
>
> On 6/1/23 20:17, Harry Wentland wrote:
> >
> >
> > On 5/23/23 18:14, Melissa Wen wrote:
> >> Hook up driver-specific atomic operations for managing AMD color
> >> properties and create AMD driver-specific color management properties
> >> and attach them according to HW capabilities defined by `struct
> >> dc_color_caps`. Add enumerated transfer function property to DRM CRTC
> >> gamma to convert to wire encoding with or without a user gamma LUT.
> >> Enumerated TFs are not supported yet by the DRM color pipeline,
> >> therefore, create a DRM enum list with the predefined TFs supported by
> >> the AMD display driver.
> >>
> >> Co-developed-by: Joshua Ashton <joshua@froggi.es>
> >> Signed-off-by: Joshua Ashton <joshua@froggi.es>
> >> Signed-off-by: Melissa Wen <mwen@igalia.com>
> >> ---
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 36 ++++++++++
> >>   drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  8 +++
> >>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 22 ++++++
> >>   .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c    | 72 ++++++++++++++++++-
> >>   4 files changed, 137 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >> index 389396eac222..88af075e6c18 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> >> @@ -1247,6 +1247,38 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
> >>      return &amdgpu_fb->base;
> >>   }
> >>
> >> +static const struct drm_prop_enum_list drm_transfer_function_enum_list[] = {
> >> +    { DRM_TRANSFER_FUNCTION_DEFAULT, "Default" },
> >> +    { DRM_TRANSFER_FUNCTION_SRGB, "sRGB" },
> >> +    { DRM_TRANSFER_FUNCTION_BT709, "BT.709" },
> >> +    { DRM_TRANSFER_FUNCTION_PQ, "PQ (Perceptual Quantizer)" },
> >> +    { DRM_TRANSFER_FUNCTION_LINEAR, "Linear" },
> >> +    { DRM_TRANSFER_FUNCTION_UNITY, "Unity" },
> >> +    { DRM_TRANSFER_FUNCTION_HLG, "HLG (Hybrid Log Gamma)" },
> >> +    { DRM_TRANSFER_FUNCTION_GAMMA22, "Gamma 2.2" },
> >> +    { DRM_TRANSFER_FUNCTION_GAMMA24, "Gamma 2.4" },
> >> +    { DRM_TRANSFER_FUNCTION_GAMMA26, "Gamma 2.6" },
> >> +};
> >
> > Let's not use the DRM_/drm_ prefix here. It might clash later when
> > we introduce DRM_ core interfaces for enumerated transfer functions.
> >
> > We'll want to specify whether something is an EOTF or an inverse EOTF,
> > or possibly an OETF. Of course that wouldn't apply to "Linear" or
> > "Unity" (I'm assuming the two are the same?).
> >
> > EOTF = electro-optical transfer function
> > This is the transfer function to go from the encoded value to an
> > optical (linear) value.
> >
> > Inverse EOTF = simply the inverse of the EOTF
> > This is usually intended to go from an optical/linear space (which
> > might have been used for blending) back to the encoded values.
> >
> > OETF = opto-electronic transfer function
> > This is usually used for converting optical signals into encoded
> > values. Usually that's done on the camera side but I think HLG might
> > define the OETF instead of the EOTF. A bit fuzzy on that. If you're
> > unclear about HLG I recommend we don't include it yet.
> >
> > It would also be good to document a bit more what each of the TFs
> > mean, but I'm fine if that comes later with a "driver-agnostic"
> > API. The key thing to clarify is whether we have an EOTF or inv_EOTF,
> > i.e. whether we use the TF to go from encoded to optical or vice
> > versa.
>
> Whether we use the inverse or not is just determined per-block though.
>
> I think we should definitely document it per-block very explicitly
> (whether it is EOTF or inv EOTF) but I don't think we need to touch the
> enums here.

Either the drm prefix has to be removed or the enum variant names have
to be explicitly be the EOTF, OETF, inverse EOTF or inverse OETF.

> - Joshie 🐸✨
>
> >
> > I know DC is sloppy and doesn't define those but it will still use
> > them as either EOTF or inv_EOTF, based on which block they're being
> > programmed, if I'm not mistaken.
> >
> >> +
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +static int
> >> +amdgpu_display_create_color_properties(struct amdgpu_device *adev)
> >> +{
> >> +    struct drm_property *prop;
> >> +
> >> +    prop = drm_property_create_enum(adev_to_drm(adev),
> >> +                                    DRM_MODE_PROP_ENUM,
> >> +                                    "AMD_REGAMMA_TF",
> >> +                                    drm_transfer_function_enum_list,
> >> +                                    ARRAY_SIZE(drm_transfer_function_enum_list));
> >> +    if (!prop)
> >> +            return -ENOMEM;
> >> +    adev->mode_info.regamma_tf_property = prop;
> >> +
> >> +    return 0;
> >> +}
> >> +#endif
> >> +
> >
> > It'd be nice if we have this function and the above enum_list
> > in amdgpu_dm, possibly in amdgpu_dm_color.c. You could call it
> > directly after the amdgpu_display_modeset_create_prop() call in
> > amdgpu_dm_mode_config_init().
> >
> >>   const struct drm_mode_config_funcs amdgpu_mode_funcs = {
> >>      .fb_create = amdgpu_display_user_framebuffer_create,
> >>   };
> >> @@ -1323,6 +1355,10 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
> >>                      return -ENOMEM;
> >>      }
> >>
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +    if (amdgpu_display_create_color_properties(adev))
> >> +            return -ENOMEM;
> >> +#endif
> >>      return 0;
> >>   }
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> >> index b8633df418d4..881446c51b36 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> >> @@ -344,6 +344,14 @@ struct amdgpu_mode_info {
> >>      int                     disp_priority;
> >>      const struct amdgpu_display_funcs *funcs;
> >>      const enum drm_plane_type *plane_type;
> >> +
> >> +    /* Driver-private color mgmt props */
> >> +
> >> +    /* @regamma_tf_property: Transfer function for CRTC regamma
> >> +     * (post-blending). Possible values are defined by `enum
> >> +     * drm_transfer_function`.
> >> +     */
> >> +    struct drm_property *regamma_tf_property;
> >>   };
> >>
> >>   #define AMDGPU_MAX_BL_LEVEL 0xFF
> >> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> >> index 2e2413fd73a4..ad5ee28b83dc 100644
> >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> >> @@ -699,6 +699,20 @@ static inline void amdgpu_dm_set_mst_status(uint8_t *status,
> >>
> >>   extern const struct amdgpu_ip_block_version dm_ip_block;
> >>
> >> +enum drm_transfer_function {
> >> +    DRM_TRANSFER_FUNCTION_DEFAULT,
> >> +    DRM_TRANSFER_FUNCTION_SRGB,
> >> +    DRM_TRANSFER_FUNCTION_BT709,
> >> +    DRM_TRANSFER_FUNCTION_PQ,
> >> +    DRM_TRANSFER_FUNCTION_LINEAR,
> >> +    DRM_TRANSFER_FUNCTION_UNITY,
> >> +    DRM_TRANSFER_FUNCTION_HLG,
> >> +    DRM_TRANSFER_FUNCTION_GAMMA22,
> >> +    DRM_TRANSFER_FUNCTION_GAMMA24,
> >> +    DRM_TRANSFER_FUNCTION_GAMMA26,
> >> +    DRM_TRANSFER_FUNCTION_MAX,
> >> +};
> >> +
> >>   struct dm_plane_state {
> >>      struct drm_plane_state base;
> >>      struct dc_plane_state *dc_state;
> >> @@ -726,6 +740,14 @@ struct dm_crtc_state {
> >>      struct dc_info_packet vrr_infopacket;
> >>
> >>      int abm_level;
> >> +
> >> +        /**
> >> +     * @regamma_tf:
> >> +     *
> >> +     * Pre-defined transfer function for converting internal FB -> wire
> >> +     * encoding.
> >> +     */
> >> +    enum drm_transfer_function regamma_tf;
> >
> > Again, let's avoid a drm_ prefix. Maybe name all this amdgpu_ instead.
> >
> >>   };
> >>
> >>   #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
> >> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> >> index e3762e806617..1eb279d341c5 100644
> >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
> >> @@ -229,7 +229,6 @@ static void dm_crtc_destroy_state(struct drm_crtc *crtc,
> >>      if (cur->stream)
> >>              dc_stream_release(cur->stream);
> >>
> >> -
> >
> > nit: stray newline
> >
> > Harry
> >
> >>      __drm_atomic_helper_crtc_destroy_state(state);
> >>
> >>
> >> @@ -263,6 +262,7 @@ static struct drm_crtc_state *dm_crtc_duplicate_state(struct drm_crtc *crtc)
> >>      state->freesync_config = cur->freesync_config;
> >>      state->cm_has_degamma = cur->cm_has_degamma;
> >>      state->cm_is_degamma_srgb = cur->cm_is_degamma_srgb;
> >> +    state->regamma_tf = cur->regamma_tf;
> >>      state->crc_skip_count = cur->crc_skip_count;
> >>      state->mpo_requested = cur->mpo_requested;
> >>      /* TODO Duplicate dc_stream after objects are stream object is flattened */
> >> @@ -299,6 +299,69 @@ static int amdgpu_dm_crtc_late_register(struct drm_crtc *crtc)
> >>   }
> >>   #endif
> >>
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +/**
> >> + * drm_crtc_additional_color_mgmt - enable additional color properties
> >> + * @crtc: DRM CRTC
> >> + *
> >> + * This function lets the driver enable the 3D LUT color correction property
> >> + * on a CRTC. This includes shaper LUT, 3D LUT and regamma TF. The shaper
> >> + * LUT and 3D LUT property is only attached if its size is not 0.
> >> + */
> >> +static void
> >> +dm_crtc_additional_color_mgmt(struct drm_crtc *crtc)
> >> +{
> >> +    struct amdgpu_device *adev = drm_to_adev(crtc->dev);
> >> +
> >> +    if(adev->dm.dc->caps.color.mpc.ogam_ram)
> >> +            drm_object_attach_property(&crtc->base,
> >> +                                       adev->mode_info.regamma_tf_property,
> >> +                                       DRM_TRANSFER_FUNCTION_DEFAULT);
> >> +}
> >> +
> >> +static int
> >> +amdgpu_dm_atomic_crtc_set_property(struct drm_crtc *crtc,
> >> +                               struct drm_crtc_state *state,
> >> +                               struct drm_property *property,
> >> +                               uint64_t val)
> >> +{
> >> +    struct amdgpu_device *adev = drm_to_adev(crtc->dev);
> >> +    struct dm_crtc_state *acrtc_state = to_dm_crtc_state(state);
> >> +
> >> +    if (property == adev->mode_info.regamma_tf_property) {
> >> +            if (acrtc_state->regamma_tf != val) {
> >> +                    acrtc_state->regamma_tf = val;
> >> +                    acrtc_state->base.color_mgmt_changed |= 1;
> >> +            }
> >> +    } else {
> >> +            drm_dbg_atomic(crtc->dev,
> >> +                           "[CRTC:%d:%s] unknown property [PROP:%d:%s]]\n",
> >> +                           crtc->base.id, crtc->name,
> >> +                           property->base.id, property->name);
> >> +            return -EINVAL;
> >> +    }
> >> +
> >> +    return 0;
> >> +}
> >> +
> >> +static int
> >> +amdgpu_dm_atomic_crtc_get_property(struct drm_crtc *crtc,
> >> +                               const struct drm_crtc_state *state,
> >> +                               struct drm_property *property,
> >> +                               uint64_t *val)
> >> +{
> >> +    struct amdgpu_device *adev = drm_to_adev(crtc->dev);
> >> +    struct dm_crtc_state *acrtc_state = to_dm_crtc_state(state);
> >> +
> >> +    if (property == adev->mode_info.regamma_tf_property)
> >> +            *val = acrtc_state->regamma_tf;
> >> +    else
> >> +            return -EINVAL;
> >> +
> >> +    return 0;
> >> +}
> >> +#endif
> >> +
> >>   /* Implemented only the options currently available for the driver */
> >>   static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
> >>      .reset = dm_crtc_reset_state,
> >> @@ -317,6 +380,10 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
> >>   #if defined(CONFIG_DEBUG_FS)
> >>      .late_register = amdgpu_dm_crtc_late_register,
> >>   #endif
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +    .atomic_set_property = amdgpu_dm_atomic_crtc_set_property,
> >> +    .atomic_get_property = amdgpu_dm_atomic_crtc_get_property,
> >> +#endif
> >>   };
> >>
> >>   static void dm_crtc_helper_disable(struct drm_crtc *crtc)
> >> @@ -480,6 +547,9 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
> >>
> >>      drm_mode_crtc_set_gamma_size(&acrtc->base, MAX_COLOR_LEGACY_LUT_ENTRIES);
> >>
> >> +#ifdef AMD_PRIVATE_COLOR
> >> +    dm_crtc_additional_color_mgmt(&acrtc->base);
> >> +#endif
> >>      return 0;
> >>
> >>   fail:
> >
>


  reply	other threads:[~2023-06-06 16:27 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 22:14 [PATCH 00/36] drm/amd/display: add AMD driver-specific properties for color mgmt Melissa Wen
2023-05-23 22:14 ` Melissa Wen
2023-05-23 22:14 ` [PATCH 01/36] drm/drm_mode_object: increase max objects to accommodate new color props Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:21   ` Simon Ser
2023-05-23 22:21     ` Simon Ser
2023-05-23 22:14 ` [PATCH 02/36] drm/drm_property: make replace_property_blob_from_id a DRM helper Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-25 14:48   ` Liviu Dudau
2023-05-25 14:48     ` Liviu Dudau
2023-05-23 22:14 ` [PATCH 03/36] drm/drm_plane: track color mgmt changes per plane Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 04/36] drm/amd/display: fix segment distribution for linear LUTs Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 05/36] drm/amd/display: fix the delta clamping for shaper LUT Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 06/36] drm/amd/display: add CRTC driver-specific property for gamma TF Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-24  8:24   ` Pekka Paalanen
2023-05-24  8:24     ` Pekka Paalanen
2023-05-25 15:32     ` Harry Wentland
2023-05-25 15:32       ` Harry Wentland
2023-05-25 19:43   ` kernel test robot
2023-05-25 19:43     ` kernel test robot
2023-06-01 19:17   ` Harry Wentland
2023-06-01 19:17     ` Harry Wentland
2023-06-06 16:18     ` Joshua Ashton
2023-06-06 16:18       ` Joshua Ashton
2023-06-06 16:26       ` Sebastian Wick [this message]
2023-06-06 16:26         ` Sebastian Wick
2023-06-06 16:57         ` Melissa Wen
2023-06-06 16:57           ` Melissa Wen
2023-06-06 20:03           ` Harry Wentland
2023-06-06 20:03             ` Harry Wentland
2023-06-06 17:14     ` Melissa Wen
2023-06-06 17:14       ` Melissa Wen
2023-05-23 22:14 ` [PATCH 07/36] drm/amd/display: add plane driver-specific properties for degamma LUT Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-06-01 19:24   ` Harry Wentland
2023-06-01 19:24     ` Harry Wentland
2023-06-06 17:15     ` Melissa Wen
2023-06-06 17:15       ` Melissa Wen
2023-06-10  5:34       ` Joshua Ashton
2023-06-10  5:34         ` Joshua Ashton
2023-05-23 22:14 ` [PATCH 08/36] drm/amd/display: add plane degamma TF driver-specific property Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-26  2:57   ` kernel test robot
2023-05-26  2:57     ` kernel test robot
2023-05-23 22:14 ` [PATCH 09/36] drm/amd/display: add plane HDR multiplier " Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-06-01 19:33   ` Harry Wentland
2023-06-01 19:33     ` Harry Wentland
2023-05-23 22:14 ` [PATCH 10/36] drm/amd/display: add plane 3D LUT driver-specific properties Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 11/36] drm/amd/display: add plane shaper " Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 12/36] drm/amd/display: add plane shaper TF driver-private property Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 13/36] drm/amd/display: add plane blend LUT and TF driver-specific properties Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 14/36] drm/amd/display: add comments to describe DM crtc color mgmt behavior Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:14 ` [PATCH 15/36] drm/amd/display: encapsulate atomic regamma operation Melissa Wen
2023-05-23 22:14   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 16/36] drm/amd/display: update lut3d and shaper lut to stream Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 17/36] drm/amd/display: copy 3D LUT settings from crtc state to stream_update Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 18/36] drm/amd/display: allow BYPASS 3D LUT but keep shaper LUT settings Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 19/36] drm/amd/display: handle MPC 3D LUT resources for a given context Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 20/36] drm/amd/display: dynamically acquire 3DLUT resources for color changes Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 21/36] drm/amd/display: add CRTC 3D LUT support Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-25  1:13   ` kernel test robot
2023-05-25  1:13     ` kernel test robot
2023-06-01 20:19   ` Harry Wentland
2023-06-01 20:19     ` Harry Wentland
2023-06-06 17:03     ` Melissa Wen
2023-06-06 17:03       ` Melissa Wen
2023-05-23 22:15 ` [PATCH 22/36] drm/amd/display: add CRTC shaper " Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 23/36] drm/amd/display: add CRTC regamma TF support Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 24/36] drm/amd/display: set sdr_ref_white_level to 80 for out_transfer_func Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 25/36] drm/amd/display: add CRTC shaper TF support Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 26/36] drm/amd/display: mark plane as needing reset if plane color mgmt changes Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 27/36] drm/amd/display: decouple steps for mapping CRTC degamma to DC plane Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 28/36] drm/amd/display: add support for plane degamma TF and LUT properties Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 29/36] drm/amd/display: reject atomic commit if setting both plane and CRTC degamma Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 30/36] drm/amd/display: add dc_fixpt_from_s3132 helper Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 31/36] drm/adm/display: add HDR multiplier support Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 32/36] drm/amd/display: program DPP shaper and 3D LUT if updated Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 33/36] drm/amd/display: add plane shaper/3D LUT and shaper TF support Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 34/36] drm/amd/display: handle empty LUTs in __set_input_tf Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 35/36] drm/amd/display: add DRM plane blend LUT and TF support Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-05-23 22:15 ` [PATCH 36/36] drm/amd/display: allow newer DC hardware to use degamma ROM for PQ/HLG Melissa Wen
2023-05-23 22:15   ` Melissa Wen
2023-06-02 15:10   ` Harry Wentland
2023-06-02 15:10     ` Harry Wentland
2023-05-29 22:55 ` [PATCH 00/36] drm/amd/display: add AMD driver-specific properties for color mgmt Dmitry Baryshkov
2023-05-29 22:55   ` Dmitry Baryshkov
2023-05-30  7:22   ` Pekka Paalanen
2023-05-30  7:22     ` Pekka Paalanen
2023-06-02 15:18 ` Harry Wentland
2023-06-02 15:18   ` Harry Wentland
2023-06-06 17:22   ` Melissa Wen
2023-06-06 17:22     ` Melissa Wen
2023-06-06 17:29     ` Melissa Wen
2023-06-06 17:29       ` Melissa Wen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+hFU4w3gwAaqvsiQW1Ns4ygi43ihn=iL7Y-Du_nH1RtKNP0sw@mail.gmail.com' \
    --to=sebastian.wick@redhat.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Shashank.Sharma@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=alex.hung@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=joshua@froggi.es \
    --cc=kernel-dev@igalia.com \
    --cc=mwen@igalia.com \
    --cc=nicholas.kazlauskas@amd.com \
    --cc=pekka.paalanen@collabora.com \
    --cc=sungjoon.kim@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=xaver.hugl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.