dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: Fix crtc color management when doing suspend/resume
@ 2018-08-23 15:11 Alexandru Gheorghe
  2018-08-23 15:42 ` Brian Starkey
  2018-08-24  7:51 ` Maarten Lankhorst
  0 siblings, 2 replies; 5+ messages in thread
From: Alexandru Gheorghe @ 2018-08-23 15:11 UTC (permalink / raw)
  To: seanpaul, maarten.lankhorst, liviu.dudau, brian.starkey, airlied,
	dri-devel, gustavo, ayan.halder
  Cc: nd, Alexandru Gheorghe

When doing suspend/resume drivers usually use the
drm_atomic_helper_suspend/drm_atomic_helper_resume pair for saving the
state and then re-comitting it.

The problems is that drm_crtc_state has a bool field called
color_mgmt_changed, which mali-dp and other drivers uses it to detect
if coefficients need to be reprogrammed, but that never happens
because the save state has color_mgmt_changed set to 0.

Fix that by setting color_mgmt_changed to true if the crtc duplicated
state differs from the reset state.

Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 6dd5036545ec..e88aa62bc822 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3196,8 +3196,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
-	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 		state->crtcs[i].old_state = crtc->state;
+		new_crtc_state->color_mgmt_changed =
+			new_crtc_state->degamma_lut != crtc->state->degamma_lut ||
+			new_crtc_state->ctm != crtc->state->ctm ||
+			new_crtc_state->gamma_lut != crtc->state->gamma_lut;
+	}
 
 	for_each_new_connector_in_state(state, connector, new_conn_state, i)
 		state->connectors[i].old_state = connector->state;
-- 
2.18.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: Fix crtc color management when doing suspend/resume
  2018-08-23 15:11 [PATCH] drm: Fix crtc color management when doing suspend/resume Alexandru Gheorghe
@ 2018-08-23 15:42 ` Brian Starkey
  2018-08-24  7:51 ` Maarten Lankhorst
  1 sibling, 0 replies; 5+ messages in thread
From: Brian Starkey @ 2018-08-23 15:42 UTC (permalink / raw)
  To: Alexandru Gheorghe
  Cc: nd, airlied, liviu.dudau, dri-devel, seanpaul, ayan.halder

Hi Alex,

On Thu, Aug 23, 2018 at 04:11:17PM +0100, Alexandru Gheorghe wrote:
>When doing suspend/resume drivers usually use the
>drm_atomic_helper_suspend/drm_atomic_helper_resume pair for saving the
>state and then re-comitting it.
>
>The problems is that drm_crtc_state has a bool field called
>color_mgmt_changed, which mali-dp and other drivers uses it to detect
>if coefficients need to be reprogrammed, but that never happens
>because the save state has color_mgmt_changed set to 0.
>
>Fix that by setting color_mgmt_changed to true if the crtc duplicated
>state differs from the reset state.
>
>Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>

LGTM.

Reviewed-by: Brian Starkey <brian.starkey@arm.com>

>---
> drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>index 6dd5036545ec..e88aa62bc822 100644
>--- a/drivers/gpu/drm/drm_atomic_helper.c
>+++ b/drivers/gpu/drm/drm_atomic_helper.c
>@@ -3196,8 +3196,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
> 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
> 		state->planes[i].old_state = plane->state;
>
>-	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
>+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
> 		state->crtcs[i].old_state = crtc->state;
>+		new_crtc_state->color_mgmt_changed =
>+			new_crtc_state->degamma_lut != crtc->state->degamma_lut ||
>+			new_crtc_state->ctm != crtc->state->ctm ||
>+			new_crtc_state->gamma_lut != crtc->state->gamma_lut;
>+	}
>
> 	for_each_new_connector_in_state(state, connector, new_conn_state, i)
> 		state->connectors[i].old_state = connector->state;
>-- 
>2.18.0
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: Fix crtc color management when doing suspend/resume
  2018-08-23 15:11 [PATCH] drm: Fix crtc color management when doing suspend/resume Alexandru Gheorghe
  2018-08-23 15:42 ` Brian Starkey
@ 2018-08-24  7:51 ` Maarten Lankhorst
  2018-08-24  8:18   ` Alexandru-Cosmin Gheorghe
  1 sibling, 1 reply; 5+ messages in thread
From: Maarten Lankhorst @ 2018-08-24  7:51 UTC (permalink / raw)
  To: Alexandru Gheorghe, seanpaul, liviu.dudau, brian.starkey, airlied,
	dri-devel, gustavo, ayan.halder
  Cc: nd

Op 23-08-18 om 17:11 schreef Alexandru Gheorghe:
> When doing suspend/resume drivers usually use the
> drm_atomic_helper_suspend/drm_atomic_helper_resume pair for saving the
> state and then re-comitting it.
>
> The problems is that drm_crtc_state has a bool field called
> color_mgmt_changed, which mali-dp and other drivers uses it to detect
> if coefficients need to be reprogrammed, but that never happens
> because the save state has color_mgmt_changed set to 0.
>
> Fix that by setting color_mgmt_changed to true if the crtc duplicated
> state differs from the reset state.
>
> Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 6dd5036545ec..e88aa62bc822 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3196,8 +3196,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
>  	for_each_new_plane_in_state(state, plane, new_plane_state, i)
>  		state->planes[i].old_state = plane->state;
>  
> -	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
> +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
>  		state->crtcs[i].old_state = crtc->state;
> +		new_crtc_state->color_mgmt_changed =
> +			new_crtc_state->degamma_lut != crtc->state->degamma_lut ||
> +			new_crtc_state->ctm != crtc->state->ctm ||
> +			new_crtc_state->gamma_lut != crtc->state->gamma_lut;
Don't look at $obj->state please, use for_each_oldnew.

But it looks like we should set color_mgmt_changed in drm_atomic_helper_check_planes(),
(or check_modeset if we want to know color_mgmt_changed from the planes atomic_check() too.
The existing places that set color_mgmt_changed should be removed, because that check is now done in a single place. :)
>  	for_each_new_connector_in_state(state, connector, new_conn_state, i)
>  		state->connectors[i].old_state = connector->state;


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: Fix crtc color management when doing suspend/resume
  2018-08-24  7:51 ` Maarten Lankhorst
@ 2018-08-24  8:18   ` Alexandru-Cosmin Gheorghe
  2018-08-24  9:10     ` Maarten Lankhorst
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandru-Cosmin Gheorghe @ 2018-08-24  8:18 UTC (permalink / raw)
  To: Maarten Lankhorst
  Cc: nd, airlied, liviu.dudau, dri-devel, seanpaul, ayan.halder

Hi,

On Fri, Aug 24, 2018 at 09:51:03AM +0200, Maarten Lankhorst wrote:
> Op 23-08-18 om 17:11 schreef Alexandru Gheorghe:
> > When doing suspend/resume drivers usually use the
> > drm_atomic_helper_suspend/drm_atomic_helper_resume pair for saving the
> > state and then re-comitting it.
> >
> > The problems is that drm_crtc_state has a bool field called
> > color_mgmt_changed, which mali-dp and other drivers uses it to detect
> > if coefficients need to be reprogrammed, but that never happens
> > because the save state has color_mgmt_changed set to 0.
> >
> > Fix that by setting color_mgmt_changed to true if the crtc duplicated
> > state differs from the reset state.
> >
> > Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index 6dd5036545ec..e88aa62bc822 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -3196,8 +3196,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
> >  	for_each_new_plane_in_state(state, plane, new_plane_state, i)
> >  		state->planes[i].old_state = plane->state;
> >  
> > -	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
> > +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
> >  		state->crtcs[i].old_state = crtc->state;
> > +		new_crtc_state->color_mgmt_changed =
> > +			new_crtc_state->degamma_lut != crtc->state->degamma_lut ||
> > +			new_crtc_state->ctm != crtc->state->ctm ||
> > +			new_crtc_state->gamma_lut != crtc->state->gamma_lut;
> Don't look at $obj->state please, use for_each_oldnew.
> 
> But it looks like we should set color_mgmt_changed in drm_atomic_helper_check_planes(),
> (or check_modeset if we want to know color_mgmt_changed from the planes atomic_check() too.
> The existing places that set color_mgmt_changed should be removed, because that check is now done in a single place. :)

drm_atomic_helper_check_modeset was the first candidate for me as
well, I think that makes more sense than
drm_atomic_helper_check_planes, don't you think ?

> >  	for_each_new_connector_in_state(state, connector, new_conn_state, i)
> >  		state->connectors[i].old_state = connector->state;
> 

-- 
Cheers,
Alex G
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: Fix crtc color management when doing suspend/resume
  2018-08-24  8:18   ` Alexandru-Cosmin Gheorghe
@ 2018-08-24  9:10     ` Maarten Lankhorst
  0 siblings, 0 replies; 5+ messages in thread
From: Maarten Lankhorst @ 2018-08-24  9:10 UTC (permalink / raw)
  To: Alexandru-Cosmin Gheorghe
  Cc: nd, airlied, liviu.dudau, dri-devel, seanpaul, ayan.halder

Op 24-08-18 om 10:18 schreef Alexandru-Cosmin Gheorghe:
> Hi,
>
> On Fri, Aug 24, 2018 at 09:51:03AM +0200, Maarten Lankhorst wrote:
>> Op 23-08-18 om 17:11 schreef Alexandru Gheorghe:
>>> When doing suspend/resume drivers usually use the
>>> drm_atomic_helper_suspend/drm_atomic_helper_resume pair for saving the
>>> state and then re-comitting it.
>>>
>>> The problems is that drm_crtc_state has a bool field called
>>> color_mgmt_changed, which mali-dp and other drivers uses it to detect
>>> if coefficients need to be reprogrammed, but that never happens
>>> because the save state has color_mgmt_changed set to 0.
>>>
>>> Fix that by setting color_mgmt_changed to true if the crtc duplicated
>>> state differs from the reset state.
>>>
>>> Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
>>> ---
>>>  drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++-
>>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>>> index 6dd5036545ec..e88aa62bc822 100644
>>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>>> @@ -3196,8 +3196,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
>>>  	for_each_new_plane_in_state(state, plane, new_plane_state, i)
>>>  		state->planes[i].old_state = plane->state;
>>>  
>>> -	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
>>> +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
>>>  		state->crtcs[i].old_state = crtc->state;
>>> +		new_crtc_state->color_mgmt_changed =
>>> +			new_crtc_state->degamma_lut != crtc->state->degamma_lut ||
>>> +			new_crtc_state->ctm != crtc->state->ctm ||
>>> +			new_crtc_state->gamma_lut != crtc->state->gamma_lut;
>> Don't look at $obj->state please, use for_each_oldnew.
>>
>> But it looks like we should set color_mgmt_changed in drm_atomic_helper_check_planes(),
>> (or check_modeset if we want to know color_mgmt_changed from the planes atomic_check() too.
>> The existing places that set color_mgmt_changed should be removed, because that check is now done in a single place. :)
> drm_atomic_helper_check_modeset was the first candidate for me as
> well, I think that makes more sense than
> drm_atomic_helper_check_planes, don't you think ?
>
Either works for me.

~Maarten
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2018-08-24  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23 15:11 [PATCH] drm: Fix crtc color management when doing suspend/resume Alexandru Gheorghe
2018-08-23 15:42 ` Brian Starkey
2018-08-24  7:51 ` Maarten Lankhorst
2018-08-24  8:18   ` Alexandru-Cosmin Gheorghe
2018-08-24  9:10     ` Maarten Lankhorst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).