All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/amd/display: Switch the custom "max bpc" property to the DRM prop
@ 2019-05-22 16:00 Nicholas Kazlauskas
       [not found] ` <20190522160055.26665-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Kazlauskas @ 2019-05-22 16:00 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Leo Li, Harry Wentland, Nicholas Kazlauskas

[Why]
The custom "max bpc" property was added to limit color depth while the
DRM one was still being merged. It's been a few kernel versions since
then and this TODO was still sticking around.

[How]
Attach the DRM max bpc property to the connector and drop all of our
custom property management. Set the max bpc to 8 by default since
DRM defaults to the max in the range which would be 16 in this case.

No behavioral changes are intended with this patch, it should just be
a refactor.

Cc: Leo Li <sunpeng.li@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  2 --
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 29 ++++++++-----------
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  1 -
 4 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 4e944737b708..767ee6991ef4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -631,10 +631,6 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
 					 amdgpu_dither_enum_list, sz);
 
 	if (amdgpu_device_has_dc_support(adev)) {
-		adev->mode_info.max_bpc_property =
-			drm_property_create_range(adev->ddev, 0, "max bpc", 8, 16);
-		if (!adev->mode_info.max_bpc_property)
-			return -ENOMEM;
 		adev->mode_info.abm_level_property =
 			drm_property_create_range(adev->ddev, 0,
 						"abm level", 0, 4);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index c7940af42f76..8bda00ce8816 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -332,8 +332,6 @@ struct amdgpu_mode_info {
 	struct drm_property *audio_property;
 	/* FMT dithering */
 	struct drm_property *dither_property;
-	/* maximum number of bits per channel for monitor color */
-	struct drm_property *max_bpc_property;
 	/* Adaptive Backlight Modulation (power feature) */
 	struct drm_property *abm_level_property;
 	/* it is used to allow enablement of freesync mode */
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 4a1755bce96c..b8e88209ef5d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3040,14 +3040,14 @@ static void update_stream_scaling_settings(const struct drm_display_mode *mode,
 static enum dc_color_depth
 convert_color_depth_from_display_info(const struct drm_connector *connector)
 {
-	struct dm_connector_state *dm_conn_state =
-		to_dm_connector_state(connector->state);
 	uint32_t bpc = connector->display_info.bpc;
 
-	/* TODO: Remove this when there's support for max_bpc in drm */
-	if (dm_conn_state && bpc > dm_conn_state->max_bpc)
-		/* Round down to nearest even number. */
-		bpc = dm_conn_state->max_bpc - (dm_conn_state->max_bpc & 1);
+	/* TODO: Use passed in state instead of the current state. */
+	if (connector->state) {
+		bpc = connector->state->max_bpc;
+		/* Round down to the nearest even number. */
+		bpc = bpc - (bpc & 1);
+	}
 
 	switch (bpc) {
 	case 0:
@@ -3689,9 +3689,6 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
 	} else if (property == adev->mode_info.underscan_property) {
 		dm_new_state->underscan_enable = val;
 		ret = 0;
-	} else if (property == adev->mode_info.max_bpc_property) {
-		dm_new_state->max_bpc = val;
-		ret = 0;
 	} else if (property == adev->mode_info.abm_level_property) {
 		dm_new_state->abm_level = val;
 		ret = 0;
@@ -3743,9 +3740,6 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
 	} else if (property == adev->mode_info.underscan_property) {
 		*val = dm_state->underscan_enable;
 		ret = 0;
-	} else if (property == adev->mode_info.max_bpc_property) {
-		*val = dm_state->max_bpc;
-		ret = 0;
 	} else if (property == adev->mode_info.abm_level_property) {
 		*val = dm_state->abm_level;
 		ret = 0;
@@ -3808,7 +3802,6 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
 		state->underscan_enable = false;
 		state->underscan_hborder = 0;
 		state->underscan_vborder = 0;
-		state->max_bpc = 8;
 
 		__drm_atomic_helper_connector_reset(connector, &state->base);
 	}
@@ -3835,7 +3828,6 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 	new_state->underscan_enable = state->underscan_enable;
 	new_state->underscan_hborder = state->underscan_hborder;
 	new_state->underscan_vborder = state->underscan_vborder;
-	new_state->max_bpc = state->max_bpc;
 
 	return &new_state->base;
 }
@@ -4756,9 +4748,12 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 	drm_object_attach_property(&aconnector->base.base,
 				adev->mode_info.underscan_vborder_property,
 				0);
-	drm_object_attach_property(&aconnector->base.base,
-				adev->mode_info.max_bpc_property,
-				0);
+
+	drm_connector_attach_max_bpc_property(&aconnector->base, 8, 16);
+
+	/* This defaults to the max in the range, but we want 8bpc. */
+	aconnector->base.state->max_bpc = 8;
+	aconnector->base.state->max_requested_bpc = 8;
 
 	if (connector_type == DRM_MODE_CONNECTOR_eDP &&
 	    dc_is_dmcu_initialized(adev->dm.dc)) {
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 2cbc26f5d6a6..3395f2e4d564 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -304,7 +304,6 @@ struct dm_connector_state {
 	enum amdgpu_rmx_type scaling;
 	uint8_t underscan_vborder;
 	uint8_t underscan_hborder;
-	uint8_t max_bpc;
 	bool underscan_enable;
 	bool freesync_enable;
 	bool freesync_capable;
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] drm/amd/display: Use new connector state when getting color depth
       [not found] ` <20190522160055.26665-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2019-05-22 16:00   ` Nicholas Kazlauskas
       [not found]     ` <20190522160055.26665-2-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Kazlauskas @ 2019-05-22 16:00 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Leo Li, Harry Wentland, Nicholas Kazlauskas

[Why]
The current state on the connector is queried when getting the max bpc
rather than the new state. This means that a new max bpc value can only
currently take effect on the commit *after* it changes.

The new state should be passed in instead.

[How]
Pass down the dm_state as drm state to where we do color depth lookup.

The passed in state can still be NULL when called from
amdgpu_dm_connector_mode_valid, so make sure that we have reasonable
defaults in place. That should probably be addressed at some point.

This change now (correctly) causes a modeset to occur when changing the
max bpc for a connector.

v2: Drop extra TODO.

Cc: Leo Li <sunpeng.li@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 27 ++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b8e88209ef5d..fd0421794e0f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3038,13 +3038,13 @@ static void update_stream_scaling_settings(const struct drm_display_mode *mode,
 }
 
 static enum dc_color_depth
-convert_color_depth_from_display_info(const struct drm_connector *connector)
+convert_color_depth_from_display_info(const struct drm_connector *connector,
+				      const struct drm_connector_state *state)
 {
 	uint32_t bpc = connector->display_info.bpc;
 
-	/* TODO: Use passed in state instead of the current state. */
-	if (connector->state) {
-		bpc = connector->state->max_bpc;
+	if (state) {
+		bpc = state->max_bpc;
 		/* Round down to the nearest even number. */
 		bpc = bpc - (bpc & 1);
 	}
@@ -3165,11 +3165,12 @@ static void adjust_colour_depth_from_display_info(struct dc_crtc_timing *timing_
 
 }
 
-static void
-fill_stream_properties_from_drm_display_mode(struct dc_stream_state *stream,
-					     const struct drm_display_mode *mode_in,
-					     const struct drm_connector *connector,
-					     const struct dc_stream_state *old_stream)
+static void fill_stream_properties_from_drm_display_mode(
+	struct dc_stream_state *stream,
+	const struct drm_display_mode *mode_in,
+	const struct drm_connector *connector,
+	const struct drm_connector_state *connector_state,
+	const struct dc_stream_state *old_stream)
 {
 	struct dc_crtc_timing *timing_out = &stream->timing;
 	const struct drm_display_info *info = &connector->display_info;
@@ -3192,7 +3193,7 @@ fill_stream_properties_from_drm_display_mode(struct dc_stream_state *stream,
 
 	timing_out->timing_3d_format = TIMING_3D_FORMAT_NONE;
 	timing_out->display_color_depth = convert_color_depth_from_display_info(
-			connector);
+		connector, connector_state);
 	timing_out->scan_type = SCANNING_TYPE_NODATA;
 	timing_out->hdmi_vic = 0;
 
@@ -3389,6 +3390,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 {
 	struct drm_display_mode *preferred_mode = NULL;
 	struct drm_connector *drm_connector;
+	const struct drm_connector_state *con_state =
+		dm_state ? &dm_state->base : NULL;
 	struct dc_stream_state *stream = NULL;
 	struct drm_display_mode mode = *drm_mode;
 	bool native_mode_found = false;
@@ -3461,10 +3464,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 	*/
 	if (!scale || mode_refresh != preferred_refresh)
 		fill_stream_properties_from_drm_display_mode(stream,
-			&mode, &aconnector->base, NULL);
+			&mode, &aconnector->base, con_state, NULL);
 	else
 		fill_stream_properties_from_drm_display_mode(stream,
-			&mode, &aconnector->base, old_stream);
+			&mode, &aconnector->base, con_state, old_stream);
 
 	update_stream_scaling_settings(&mode, dm_state, stream);
 
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] drm/amd/display: Use new connector state when getting color depth
       [not found]     ` <20190522160055.26665-2-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2019-05-22 18:04       ` Harry Wentland
  0 siblings, 0 replies; 3+ messages in thread
From: Harry Wentland @ 2019-05-22 18:04 UTC (permalink / raw)
  To: Kazlauskas, Nicholas, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Li, Sun peng (Leo), Wentland, Harry

On 2019-05-22 12:00 p.m., Nicholas Kazlauskas wrote:
> [CAUTION: External Email]
> 
> [Why]
> The current state on the connector is queried when getting the max bpc
> rather than the new state. This means that a new max bpc value can only
> currently take effect on the commit *after* it changes.
> 
> The new state should be passed in instead.
> 
> [How]
> Pass down the dm_state as drm state to where we do color depth lookup.
> 
> The passed in state can still be NULL when called from
> amdgpu_dm_connector_mode_valid, so make sure that we have reasonable
> defaults in place. That should probably be addressed at some point.
> 
> This change now (correctly) causes a modeset to occur when changing the
> max bpc for a connector.
> 
> v2: Drop extra TODO.
> 
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Series is
Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 27 ++++++++++---------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index b8e88209ef5d..fd0421794e0f 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3038,13 +3038,13 @@ static void update_stream_scaling_settings(const struct drm_display_mode *mode,
>  }
> 
>  static enum dc_color_depth
> -convert_color_depth_from_display_info(const struct drm_connector *connector)
> +convert_color_depth_from_display_info(const struct drm_connector *connector,
> +                                     const struct drm_connector_state *state)
>  {
>         uint32_t bpc = connector->display_info.bpc;
> 
> -       /* TODO: Use passed in state instead of the current state. */
> -       if (connector->state) {
> -               bpc = connector->state->max_bpc;
> +       if (state) {
> +               bpc = state->max_bpc;
>                 /* Round down to the nearest even number. */
>                 bpc = bpc - (bpc & 1);
>         }
> @@ -3165,11 +3165,12 @@ static void adjust_colour_depth_from_display_info(struct dc_crtc_timing *timing_
> 
>  }
> 
> -static void
> -fill_stream_properties_from_drm_display_mode(struct dc_stream_state *stream,
> -                                            const struct drm_display_mode *mode_in,
> -                                            const struct drm_connector *connector,
> -                                            const struct dc_stream_state *old_stream)
> +static void fill_stream_properties_from_drm_display_mode(
> +       struct dc_stream_state *stream,
> +       const struct drm_display_mode *mode_in,
> +       const struct drm_connector *connector,
> +       const struct drm_connector_state *connector_state,
> +       const struct dc_stream_state *old_stream)
>  {
>         struct dc_crtc_timing *timing_out = &stream->timing;
>         const struct drm_display_info *info = &connector->display_info;
> @@ -3192,7 +3193,7 @@ fill_stream_properties_from_drm_display_mode(struct dc_stream_state *stream,
> 
>         timing_out->timing_3d_format = TIMING_3D_FORMAT_NONE;
>         timing_out->display_color_depth = convert_color_depth_from_display_info(
> -                       connector);
> +               connector, connector_state);
>         timing_out->scan_type = SCANNING_TYPE_NODATA;
>         timing_out->hdmi_vic = 0;
> 
> @@ -3389,6 +3390,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  {
>         struct drm_display_mode *preferred_mode = NULL;
>         struct drm_connector *drm_connector;
> +       const struct drm_connector_state *con_state =
> +               dm_state ? &dm_state->base : NULL;
>         struct dc_stream_state *stream = NULL;
>         struct drm_display_mode mode = *drm_mode;
>         bool native_mode_found = false;
> @@ -3461,10 +3464,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>         */
>         if (!scale || mode_refresh != preferred_refresh)
>                 fill_stream_properties_from_drm_display_mode(stream,
> -                       &mode, &aconnector->base, NULL);
> +                       &mode, &aconnector->base, con_state, NULL);
>         else
>                 fill_stream_properties_from_drm_display_mode(stream,
> -                       &mode, &aconnector->base, old_stream);
> +                       &mode, &aconnector->base, con_state, old_stream);
> 
>         update_stream_scaling_settings(&mode, dm_state, stream);
> 
> --
> 2.17.1
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-22 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 16:00 [PATCH v2 1/2] drm/amd/display: Switch the custom "max bpc" property to the DRM prop Nicholas Kazlauskas
     [not found] ` <20190522160055.26665-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-05-22 16:00   ` [PATCH v2 2/2] drm/amd/display: Use new connector state when getting color depth Nicholas Kazlauskas
     [not found]     ` <20190522160055.26665-2-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-05-22 18:04       ` Harry Wentland

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.