* [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified
@ 2017-07-03 9:42 Peter Rosin
2017-07-03 11:31 ` Boris Brezillon
0 siblings, 1 reply; 6+ messages in thread
From: Peter Rosin @ 2017-07-03 9:42 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Rosin, Boris Brezillon, David Airlie, dri-devel,
Alexandre Belloni, Nicolas Ferre, Daniel Vetter
At init and if the gamma_lut property is ever removed, the clut
registers must be programmed with a default gamma ramp instead of
being left in some unknown state.
Fixes: 364a7bf574eb ("drm: atmel-hlcdc: add support for 8-bit color lookup table mode")
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index b5bd9b0..0ccd93c 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -429,6 +429,14 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
ATMEL_HLCDC_LAYER_FORMAT_CFG, cfg);
}
+static void atmel_hlcdc_default_gamma_ramp(struct atmel_hlcdc_layer *layer)
+{
+ int idx;
+
+ for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++)
+ atmel_hlcdc_layer_write_clut(layer, idx, idx * 0x10101);
+}
+
static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane)
{
struct drm_crtc *crtc = plane->base.crtc;
@@ -438,9 +446,14 @@ static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane)
if (!crtc || !crtc->state)
return;
- if (!crtc->state->color_mgmt_changed || !crtc->state->gamma_lut)
+ if (!crtc->state->color_mgmt_changed)
return;
+ if (!crtc->state->gamma_lut) {
+ atmel_hlcdc_default_gamma_ramp(&plane->layer);
+ return;
+ }
+
lut = (struct drm_color_lut *)crtc->state->gamma_lut->data;
for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++, lut++) {
@@ -918,6 +931,8 @@ static int atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane,
0x40040890);
}
+ atmel_hlcdc_default_gamma_ramp(&plane->layer);
+
return 0;
}
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified 2017-07-03 9:42 [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified Peter Rosin @ 2017-07-03 11:31 ` Boris Brezillon 2017-07-03 11:53 ` Peter Rosin 0 siblings, 1 reply; 6+ messages in thread From: Boris Brezillon @ 2017-07-03 11:31 UTC (permalink / raw) To: Peter Rosin Cc: linux-kernel, David Airlie, dri-devel, Alexandre Belloni, Nicolas Ferre, Daniel Vetter On Mon, 3 Jul 2017 11:42:10 +0200 Peter Rosin <peda@axentia.se> wrote: > At init and if the gamma_lut property is ever removed, the clut > registers must be programmed with a default gamma ramp instead of > being left in some unknown state. > > Fixes: 364a7bf574eb ("drm: atmel-hlcdc: add support for 8-bit color lookup table mode") > Signed-off-by: Peter Rosin <peda@axentia.se> > --- > drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > index b5bd9b0..0ccd93c 100644 > --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > @@ -429,6 +429,14 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane, > ATMEL_HLCDC_LAYER_FORMAT_CFG, cfg); > } > > +static void atmel_hlcdc_default_gamma_ramp(struct atmel_hlcdc_layer *layer) > +{ > + int idx; > + > + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) > + atmel_hlcdc_layer_write_clut(layer, idx, idx * 0x10101); > +} > + > static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) > { > struct drm_crtc *crtc = plane->base.crtc; > @@ -438,9 +446,14 @@ static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) > if (!crtc || !crtc->state) > return; > > - if (!crtc->state->color_mgmt_changed || !crtc->state->gamma_lut) > + if (!crtc->state->color_mgmt_changed) > return; > > + if (!crtc->state->gamma_lut) { > + atmel_hlcdc_default_gamma_ramp(&plane->layer); Hm, I'd prefer to have state->gamma_lut properly initialized in atmel_hlcdc_crtc_reset(), this way you don't have to do that in the update path. > + return; > + } > + > lut = (struct drm_color_lut *)crtc->state->gamma_lut->data; > > for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++, lut++) { > @@ -918,6 +931,8 @@ static int atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane, > 0x40040890); > } > > + atmel_hlcdc_default_gamma_ramp(&plane->layer); > + > return 0; > } > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified 2017-07-03 11:31 ` Boris Brezillon @ 2017-07-03 11:53 ` Peter Rosin 2017-07-03 12:02 ` Boris Brezillon 0 siblings, 1 reply; 6+ messages in thread From: Peter Rosin @ 2017-07-03 11:53 UTC (permalink / raw) To: Boris Brezillon Cc: linux-kernel, David Airlie, dri-devel, Alexandre Belloni, Nicolas Ferre, Daniel Vetter On 2017-07-03 13:31, Boris Brezillon wrote: > On Mon, 3 Jul 2017 11:42:10 +0200 > Peter Rosin <peda@axentia.se> wrote: > >> At init and if the gamma_lut property is ever removed, the clut >> registers must be programmed with a default gamma ramp instead of >> being left in some unknown state. >> >> Fixes: 364a7bf574eb ("drm: atmel-hlcdc: add support for 8-bit color lookup table mode") >> Signed-off-by: Peter Rosin <peda@axentia.se> >> --- >> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 17 ++++++++++++++++- >> 1 file changed, 16 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c >> index b5bd9b0..0ccd93c 100644 >> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c >> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c >> @@ -429,6 +429,14 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane, >> ATMEL_HLCDC_LAYER_FORMAT_CFG, cfg); >> } >> >> +static void atmel_hlcdc_default_gamma_ramp(struct atmel_hlcdc_layer *layer) >> +{ >> + int idx; >> + >> + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) >> + atmel_hlcdc_layer_write_clut(layer, idx, idx * 0x10101); >> +} >> + >> static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) >> { >> struct drm_crtc *crtc = plane->base.crtc; >> @@ -438,9 +446,14 @@ static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) >> if (!crtc || !crtc->state) >> return; >> >> - if (!crtc->state->color_mgmt_changed || !crtc->state->gamma_lut) >> + if (!crtc->state->color_mgmt_changed) >> return; >> >> + if (!crtc->state->gamma_lut) { >> + atmel_hlcdc_default_gamma_ramp(&plane->layer); > > Hm, I'd prefer to have state->gamma_lut properly initialized in > atmel_hlcdc_crtc_reset(), this way you don't have to do that in the > update path. The gamma_lut property can be removed, so you have to handle it here anyway. No? Cheers, peda >> + return; >> + } >> + >> lut = (struct drm_color_lut *)crtc->state->gamma_lut->data; >> >> for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++, lut++) { >> @@ -918,6 +931,8 @@ static int atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane, >> 0x40040890); >> } >> >> + atmel_hlcdc_default_gamma_ramp(&plane->layer); >> + >> return 0; >> } >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified 2017-07-03 11:53 ` Peter Rosin @ 2017-07-03 12:02 ` Boris Brezillon 2017-07-03 20:59 ` Peter Rosin 0 siblings, 1 reply; 6+ messages in thread From: Boris Brezillon @ 2017-07-03 12:02 UTC (permalink / raw) To: Peter Rosin Cc: linux-kernel, David Airlie, dri-devel, Alexandre Belloni, Nicolas Ferre, Daniel Vetter On Mon, 3 Jul 2017 13:53:28 +0200 Peter Rosin <peda@axentia.se> wrote: > On 2017-07-03 13:31, Boris Brezillon wrote: > > On Mon, 3 Jul 2017 11:42:10 +0200 > > Peter Rosin <peda@axentia.se> wrote: > > > >> At init and if the gamma_lut property is ever removed, the clut > >> registers must be programmed with a default gamma ramp instead of > >> being left in some unknown state. > >> > >> Fixes: 364a7bf574eb ("drm: atmel-hlcdc: add support for 8-bit color lookup table mode") > >> Signed-off-by: Peter Rosin <peda@axentia.se> > >> --- > >> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 17 ++++++++++++++++- > >> 1 file changed, 16 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > >> index b5bd9b0..0ccd93c 100644 > >> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > >> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > >> @@ -429,6 +429,14 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane, > >> ATMEL_HLCDC_LAYER_FORMAT_CFG, cfg); > >> } > >> > >> +static void atmel_hlcdc_default_gamma_ramp(struct atmel_hlcdc_layer *layer) > >> +{ > >> + int idx; > >> + > >> + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) > >> + atmel_hlcdc_layer_write_clut(layer, idx, idx * 0x10101); > >> +} > >> + > >> static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) > >> { > >> struct drm_crtc *crtc = plane->base.crtc; > >> @@ -438,9 +446,14 @@ static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) > >> if (!crtc || !crtc->state) > >> return; > >> > >> - if (!crtc->state->color_mgmt_changed || !crtc->state->gamma_lut) > >> + if (!crtc->state->color_mgmt_changed) > >> return; > >> > >> + if (!crtc->state->gamma_lut) { > >> + atmel_hlcdc_default_gamma_ramp(&plane->layer); > > > > Hm, I'd prefer to have state->gamma_lut properly initialized in > > atmel_hlcdc_crtc_reset(), this way you don't have to do that in the > > update path. > > The gamma_lut property can be removed, so you have to handle it here anyway. No? Hm, what do you mean by removed? AFAICT, a property, once attached to a DRM object, exists until the DRM object is destroyed. The data attached to this property (here, the gamma_lut array) can be NULL, but once you have allocated the data container, it will be duplicated (and possibly updated) every time an atomic operation is triggered. By initializing this field in crtc->reset(), you enforce the default/reset state, which IIUC, is what you want here. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified 2017-07-03 12:02 ` Boris Brezillon @ 2017-07-03 20:59 ` Peter Rosin 2017-07-03 21:15 ` Boris Brezillon 0 siblings, 1 reply; 6+ messages in thread From: Peter Rosin @ 2017-07-03 20:59 UTC (permalink / raw) To: Boris Brezillon Cc: linux-kernel, David Airlie, dri-devel, Alexandre Belloni, Nicolas Ferre, Daniel Vetter On 2017-07-03 14:02, Boris Brezillon wrote: > On Mon, 3 Jul 2017 13:53:28 +0200 > Peter Rosin <peda@axentia.se> wrote: > >> On 2017-07-03 13:31, Boris Brezillon wrote: >>> On Mon, 3 Jul 2017 11:42:10 +0200 >>> Peter Rosin <peda@axentia.se> wrote: >>> >>>> At init and if the gamma_lut property is ever removed, the clut >>>> registers must be programmed with a default gamma ramp instead of >>>> being left in some unknown state. >>>> >>>> Fixes: 364a7bf574eb ("drm: atmel-hlcdc: add support for 8-bit color lookup table mode") >>>> Signed-off-by: Peter Rosin <peda@axentia.se> >>>> --- >>>> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 17 ++++++++++++++++- >>>> 1 file changed, 16 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c >>>> index b5bd9b0..0ccd93c 100644 >>>> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c >>>> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c >>>> @@ -429,6 +429,14 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane, >>>> ATMEL_HLCDC_LAYER_FORMAT_CFG, cfg); >>>> } >>>> >>>> +static void atmel_hlcdc_default_gamma_ramp(struct atmel_hlcdc_layer *layer) >>>> +{ >>>> + int idx; >>>> + >>>> + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) >>>> + atmel_hlcdc_layer_write_clut(layer, idx, idx * 0x10101); >>>> +} >>>> + >>>> static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) >>>> { >>>> struct drm_crtc *crtc = plane->base.crtc; >>>> @@ -438,9 +446,14 @@ static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) >>>> if (!crtc || !crtc->state) >>>> return; >>>> >>>> - if (!crtc->state->color_mgmt_changed || !crtc->state->gamma_lut) >>>> + if (!crtc->state->color_mgmt_changed) >>>> return; >>>> >>>> + if (!crtc->state->gamma_lut) { >>>> + atmel_hlcdc_default_gamma_ramp(&plane->layer); >>> >>> Hm, I'd prefer to have state->gamma_lut properly initialized in >>> atmel_hlcdc_crtc_reset(), this way you don't have to do that in the >>> update path. >> >> The gamma_lut property can be removed, so you have to handle it here anyway. No? > > Hm, what do you mean by removed? AFAICT, a property, once attached to > a DRM object, exists until the DRM object is destroyed. The data > attached to this property (here, the gamma_lut array) can be NULL, but > once you have allocated the data container, it will be duplicated (and > possibly updated) every time an atomic operation is triggered. By remove I meant someone somehow triggering a call like this: drm_atomic_crtc_set_property(crtc, ...->gamma_lut_property, 0); By the looks of it, that is not happening? But I'm not sure of that, and even if it's not happening today, that may change... > By initializing this field in crtc->reset(), you enforce the > default/reset state, which IIUC, is what you want here. Agreed, if it is not possible to remove/clear out the gamma_lut property, then the only thing needed is to initialize the hw clut registers to the linear ramp somewhere early. But is it indeed a fact that there is no way to clear out the gamma_lut prop? Cheers, peda ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified 2017-07-03 20:59 ` Peter Rosin @ 2017-07-03 21:15 ` Boris Brezillon 0 siblings, 0 replies; 6+ messages in thread From: Boris Brezillon @ 2017-07-03 21:15 UTC (permalink / raw) To: Peter Rosin, Daniel Vetter Cc: linux-kernel, David Airlie, dri-devel, Alexandre Belloni, Nicolas Ferre Le Mon, 3 Jul 2017 22:59:36 +0200, Peter Rosin <peda@axentia.se> a écrit : > On 2017-07-03 14:02, Boris Brezillon wrote: > > On Mon, 3 Jul 2017 13:53:28 +0200 > > Peter Rosin <peda@axentia.se> wrote: > > > >> On 2017-07-03 13:31, Boris Brezillon wrote: > >>> On Mon, 3 Jul 2017 11:42:10 +0200 > >>> Peter Rosin <peda@axentia.se> wrote: > >>> > >>>> At init and if the gamma_lut property is ever removed, the clut > >>>> registers must be programmed with a default gamma ramp instead of > >>>> being left in some unknown state. > >>>> > >>>> Fixes: 364a7bf574eb ("drm: atmel-hlcdc: add support for 8-bit color lookup table mode") > >>>> Signed-off-by: Peter Rosin <peda@axentia.se> > >>>> --- > >>>> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 17 ++++++++++++++++- > >>>> 1 file changed, 16 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > >>>> index b5bd9b0..0ccd93c 100644 > >>>> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > >>>> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c > >>>> @@ -429,6 +429,14 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane, > >>>> ATMEL_HLCDC_LAYER_FORMAT_CFG, cfg); > >>>> } > >>>> > >>>> +static void atmel_hlcdc_default_gamma_ramp(struct atmel_hlcdc_layer *layer) > >>>> +{ > >>>> + int idx; > >>>> + > >>>> + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) > >>>> + atmel_hlcdc_layer_write_clut(layer, idx, idx * 0x10101); > >>>> +} > >>>> + > >>>> static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) > >>>> { > >>>> struct drm_crtc *crtc = plane->base.crtc; > >>>> @@ -438,9 +446,14 @@ static void atmel_hlcdc_plane_update_clut(struct atmel_hlcdc_plane *plane) > >>>> if (!crtc || !crtc->state) > >>>> return; > >>>> > >>>> - if (!crtc->state->color_mgmt_changed || !crtc->state->gamma_lut) > >>>> + if (!crtc->state->color_mgmt_changed) > >>>> return; > >>>> > >>>> + if (!crtc->state->gamma_lut) { > >>>> + atmel_hlcdc_default_gamma_ramp(&plane->layer); > >>> > >>> Hm, I'd prefer to have state->gamma_lut properly initialized in > >>> atmel_hlcdc_crtc_reset(), this way you don't have to do that in the > >>> update path. > >> > >> The gamma_lut property can be removed, so you have to handle it here anyway. No? > > > > Hm, what do you mean by removed? AFAICT, a property, once attached to > > a DRM object, exists until the DRM object is destroyed. The data > > attached to this property (here, the gamma_lut array) can be NULL, but > > once you have allocated the data container, it will be duplicated (and > > possibly updated) every time an atomic operation is triggered. > > By remove I meant someone somehow triggering a call like this: > > drm_atomic_crtc_set_property(crtc, ...->gamma_lut_property, 0); > > By the looks of it, that is not happening? But I'm not sure of that, and > even if it's not happening today, that may change... Hm, that means someone would deliberately set an empty CLUT and still request to display something C8 formated? If you want my opinion, we should return -EINVAL if this happens. Using a default CLUT table to support C8 early in the boot is one thing, allowing one to explicitly discard the CLUT and expecting C8 to work properly sounds like a bad to me. > > > By initializing this field in crtc->reset(), you enforce the > > default/reset state, which IIUC, is what you want here. > > Agreed, if it is not possible to remove/clear out the gamma_lut property, > then the only thing needed is to initialize the hw clut registers to the > linear ramp somewhere early. Well, I don't know if we should prevent one from discarding the CLUT, but we should definitely prevent one from using C8 format when ->gamma_lut is NULL. > > But is it indeed a fact that there is no way to clear out the gamma_lut prop? You clearly showed it was possible, so I'd say no. Daniel, any opinion on this specific problem? ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-07-03 21:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-07-03 9:42 [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified Peter Rosin 2017-07-03 11:31 ` Boris Brezillon 2017-07-03 11:53 ` Peter Rosin 2017-07-03 12:02 ` Boris Brezillon 2017-07-03 20:59 ` Peter Rosin 2017-07-03 21:15 ` Boris Brezillon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome