From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5C65C43381 for ; Thu, 14 Mar 2019 15:42:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FFE220811 for ; Thu, 14 Mar 2019 15:42:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gEvSRr+t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FFE220811 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sPQbNn199/7X7QQsLhtHuhyxS1SAypOwkDl7dVG4oLk=; b=gEvSRr+tsT3c6dWa8aGG6vAWE ncISFXP/6jMFZmu/9GpgGVavTKlCiSbaXiOVOfC5DejEM3ADXLKBd/dZuHM8wJzP8Im7HrSGFrvcQ Av/h2yE+s9VlA8hDMu5w9jlkDOLX7sadOE2Crl/jZp/EdRJkVYSr/PT7k+6n9pNpWJv+eta3LqpZW ZofUGgypCE7Ler1einXUEWWdPQkmG15V1H0pCP6ulob8HOvXY7gJm5M7vA/cENZmdzPtFdCYB819E rqXu/vhm9TZbre4Yt6lCVn7Agn8g+Rpu21BhLN6QszDepBxskpkNu8V1yZToFAkj6FkSgvlGxv5sO GICQZTF2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4SUr-0005xD-ME; Thu, 14 Mar 2019 15:42:17 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4SUo-0005wd-95 for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2019 15:42:16 +0000 X-Originating-IP: 185.94.189.187 Received: from localhost (unknown [185.94.189.187]) (Authenticated sender: maxime.ripard@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id DEDB624000C; Thu, 14 Mar 2019 15:42:03 +0000 (UTC) Date: Thu, 14 Mar 2019 16:42:03 +0100 From: Maxime Ripard To: Vasily Khoruzhick Subject: Re: [RFC PATCH] drm/sun4i: Implement gamma correction Message-ID: <20190314154203.7fixwajcplie5l3j@flea> References: <20190314025838.5867-1-anarsoul@gmail.com> MIME-Version: 1.0 In-Reply-To: <20190314025838.5867-1-anarsoul@gmail.com> User-Agent: NeoMutt/20180716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190314_084214_619132_43EA3068 X-CRM114-Status: GOOD ( 21.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, Daniel Vetter , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============3234186825648602957==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============3234186825648602957== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tgmbhkap6sjmtrfp" Content-Disposition: inline --tgmbhkap6sjmtrfp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Vasily, On Wed, Mar 13, 2019 at 07:58:38PM -0700, Vasily Khoruzhick wrote: > Add support for gamma corretion to sun4i TCON driver. Its LUT has 256 > entries and can be updated only when gamma correction is disabled. >=20 > Signed-off-by: Vasily Khoruzhick It's not really clear to me what you expect a comment on? Maxime > --- > drivers/gpu/drm/sun4i/sun4i_crtc.c | 15 ++++++++++++++ > drivers/gpu/drm/sun4i/sun4i_tcon.c | 33 ++++++++++++++++++++++++++++++ > drivers/gpu/drm/sun4i/sun4i_tcon.h | 12 ++++++++++- > 3 files changed, 59 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/s= un4i_crtc.c > index 3eedf335a935..719259d09632 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c > +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c > @@ -101,6 +101,20 @@ static void sun4i_crtc_atomic_flush(struct drm_crtc = *crtc, > drm_crtc_send_vblank_event(crtc, event); > spin_unlock_irq(&crtc->dev->event_lock); > } > + > + if (crtc->state->color_mgmt_changed) { > + if (crtc->state->gamma_lut) { > + /* LUT can be only updated when gamma correction is > + * disabled > + */ > + sun4i_tcon_enable_gamma(scrtc->tcon, false); > + sun4i_tcon_load_gamma_lut(scrtc->tcon, > + crtc->state->gamma_lut->data); > + sun4i_tcon_enable_gamma(scrtc->tcon, true); > + } else > + sun4i_tcon_enable_gamma(scrtc->tcon, false); > + } > + > } > =20 > static void sun4i_crtc_atomic_disable(struct drm_crtc *crtc, > @@ -184,6 +198,7 @@ static const struct drm_crtc_funcs sun4i_crtc_funcs = =3D { > .set_config =3D drm_atomic_helper_set_config, > .enable_vblank =3D sun4i_crtc_enable_vblank, > .disable_vblank =3D sun4i_crtc_disable_vblank, > + .gamma_set =3D drm_atomic_helper_legacy_gamma_set, > }; > =20 > struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm, > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/s= un4i_tcon.c > index cf45d0f940f9..3f5f9d4f54a6 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c > @@ -215,6 +215,34 @@ void sun4i_tcon_enable_vblank(struct sun4i_tcon *tco= n, bool enable) > } > EXPORT_SYMBOL(sun4i_tcon_enable_vblank); > =20 > +void sun4i_tcon_load_gamma_lut(struct sun4i_tcon *tcon, > + struct drm_color_lut *lut) > +{ > + int i; > + > + for (i =3D 0; i < SUN4I_TCON_GAMMA_LUT_SIZE; i++) { > + u32 r, g, b; > + > + r =3D drm_color_lut_extract(lut[i].red, 8); > + g =3D drm_color_lut_extract(lut[i].green, 8); > + b =3D drm_color_lut_extract(lut[i].blue, 8); > + > + regmap_write(tcon->regs, SUN4I_TCON_GAMMA_TABLE_REG + 4 * i, > + SUN4I_TCON_GAMMA_TABLE_R(r) | > + SUN4I_TCON_GAMMA_TABLE_G(g) | > + SUN4I_TCON_GAMMA_TABLE_B(b)); > + } > +} > +EXPORT_SYMBOL(sun4i_tcon_load_gamma_lut); > + > +void sun4i_tcon_enable_gamma(struct sun4i_tcon *tcon, bool enable) > +{ > + regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG, > + SUN4I_TCON_GCTL_GAMMA_ENABLE, > + enable ? SUN4I_TCON_GCTL_GAMMA_ENABLE : 0); > +} > +EXPORT_SYMBOL(sun4i_tcon_enable_gamma); > + > /* > * This function is a helper for TCON output muxing. The TCON output > * muxing control register in earlier SoCs (without the TCON TOP block) > @@ -1261,6 +1289,11 @@ static int sun4i_tcon_bind(struct device *dev, str= uct device *master, > =20 > list_add_tail(&tcon->list, &drv->tcon_list); > =20 > + drm_mode_crtc_set_gamma_size(&tcon->crtc->crtc, > + SUN4I_TCON_GAMMA_LUT_SIZE); > + drm_crtc_enable_color_mgmt(&tcon->crtc->crtc, 0, false, > + tcon->crtc->crtc.gamma_size); > + > return 0; > =20 > err_free_dotclock: > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/s= un4i_tcon.h > index 84cfb1952ff7..68a29e49e426 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h > @@ -22,6 +22,7 @@ > =20 > #define SUN4I_TCON_GCTL_REG 0x0 > #define SUN4I_TCON_GCTL_TCON_ENABLE BIT(31) > +#define SUN4I_TCON_GCTL_GAMMA_ENABLE BIT(30) > #define SUN4I_TCON_GCTL_IOMAP_MASK BIT(0) > #define SUN4I_TCON_GCTL_IOMAP_TCON1 (1 << 0) > #define SUN4I_TCON_GCTL_IOMAP_TCON0 (0 << 0) > @@ -215,7 +216,13 @@ > #define SUN4I_TCON1_FILL_BEG2_REG 0x31c > #define SUN4I_TCON1_FILL_END2_REG 0x320 > #define SUN4I_TCON1_FILL_DATA2_REG 0x324 > -#define SUN4I_TCON1_GAMMA_TABLE_REG 0x400 > + > +#define SUN4I_TCON_GAMMA_TABLE_REG 0x400 > +#define SUN4I_TCON_GAMMA_TABLE_B(x) ((x) & 0xff) > +#define SUN4I_TCON_GAMMA_TABLE_G(x) (((x) & 0xff) << 8) > +#define SUN4I_TCON_GAMMA_TABLE_R(x) (((x) & 0xff) << 16) > + > +#define SUN4I_TCON_GAMMA_LUT_SIZE 256 > =20 > #define SUN4I_TCON_MAX_CHANNELS 2 > =20 > @@ -278,6 +285,9 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon, > const struct drm_display_mode *mode); > void sun4i_tcon_set_status(struct sun4i_tcon *crtc, > const struct drm_encoder *encoder, bool enable); > +void sun4i_tcon_load_gamma_lut(struct sun4i_tcon *tcon, > + struct drm_color_lut *lut); > +void sun4i_tcon_enable_gamma(struct sun4i_tcon *tcon, bool enable); > =20 > extern const struct of_device_id sun4i_tcon_of_table[]; > =20 > --=20 > 2.21.0 >=20 --=20 Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --tgmbhkap6sjmtrfp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXIp2SwAKCRDj7w1vZxhR xSnbAP9ZiYBt1fgCp+KW1N+OWLfacqrrgWPEWsI4Mqlhstt55AD9FXYVo74SWFUO pq01CNG+Ci/cAN7u77wT3jaxgL7qvQc= =TuHd -----END PGP SIGNATURE----- --tgmbhkap6sjmtrfp-- --===============3234186825648602957== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============3234186825648602957==--