Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbdGCLbQ (ORCPT ); Mon, 3 Jul 2017 07:31:16 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:42958 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752114AbdGCLbO (ORCPT ); Mon, 3 Jul 2017 07:31:14 -0400 Date: Mon, 3 Jul 2017 13:31:02 +0200 From: Boris Brezillon To: Peter Rosin Cc: linux-kernel@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, Alexandre Belloni , Nicolas Ferre , Daniel Vetter Subject: Re: [PATCH] drm: atmel-hlcdc: use a default gamma ramp if none is specified Message-ID: <20170703133102.5788d2f2@bbrezillon> In-Reply-To: <1499074930-10187-1-git-send-email-peda@axentia.se> References: <1499074930-10187-1-git-send-email-peda@axentia.se> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2160 Lines: 62 On Mon, 3 Jul 2017 11:42:10 +0200 Peter Rosin 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 > --- > 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; > } >