From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763222AbdJQTrC (ORCPT ); Tue, 17 Oct 2017 15:47:02 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:52202 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760002AbdJQTrB (ORCPT ); Tue, 17 Oct 2017 15:47:01 -0400 Date: Tue, 17 Oct 2017 21:46:59 +0200 From: Maxime Ripard To: Jonathan Liu Cc: David Airlie , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH] drm/sun4i: tcon: Add dithering support for RGB565/RGB666 LCD panels Message-ID: <20171017194659.5jaqjtgzemm76m6l@flea.lan> References: <20171017110946.18961-1-net147@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kpnhmpy4stwwpl2a" Content-Disposition: inline In-Reply-To: <20171017110946.18961-1-net147@gmail.com> User-Agent: NeoMutt/20171013 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --kpnhmpy4stwwpl2a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Oct 17, 2017 at 10:09:46PM +1100, Jonathan Liu wrote: > Dithering is supported on TCON channel 0 which is used for LCD panels. Expanding a bit the commit log would be great. What is dithering, why is this needed in the first place, what is it trying to fix, etc. > Signed-off-by: Jonathan Liu > --- > drivers/gpu/drm/sun4i/sun4i_tcon.c | 37 ++++++++++++++++++++++++++++++++= +++++ > drivers/gpu/drm/sun4i/sun4i_tcon.h | 18 +++++++++++++++++- > 2 files changed, 54 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/s= un4i_tcon.c > index 68751b999877..cf313ca858b3 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c > @@ -12,11 +12,13 @@ > =20 > #include > #include > +#include > #include > #include > #include > #include > #include > +#include > =20 > #include > =20 > @@ -168,7 +170,9 @@ void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, > struct drm_display_mode *mode) > { > unsigned int bp, hsync, vsync; > + u32 bus_format =3D 0; > u8 clk_delay; > + struct drm_connector *connector =3D tcon->panel->connector; You shouldn't access the connector directly, but instead use the current state associated to the encoder. > u32 val =3D 0; > =20 > /* Configure the dot clock */ > @@ -230,6 +234,39 @@ void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, > SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSIT= IVE, > val); > =20 > + if (connector->display_info.num_bus_formats) > + bus_format =3D connector->display_info.bus_formats[0]; > + > + switch (bus_format) { > + case MEDIA_BUS_FMT_RGB565_1X16: > + case MEDIA_BUS_FMT_RGB666_1X18: I guess that has more to do with the bit width than the actual media bus. I've created helper for both these two in my LVDS patch set, you might want to rebase on top of it. > + /* Enable dithering */ > + /* FIXME: Undocumented bits */ > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_SEED0_REG, 0x11111111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_SEED1_REG, 0x11111111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_SEED2_REG, 0x11111111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_SEED3_REG, 0x11111111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_SEED4_REG, 0x11111111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_SEED5_REG, 0x11111111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_TAB0_REG, 0x01010000); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_TAB1_REG, 0x15151111); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_TAB2_REG, 0x57575555); > + regmap_write(tcon->regs, SUN4I_TCON0_FRM_TAB3_REG, 0x7f7f7777); > + val =3D SUN4I_TCON0_FRM_CTL_ENABLE; > + > + if (bus_format =3D=3D MEDIA_BUS_FMT_RGB565_1X16) { > + val |=3D SUN4I_TCON0_FRM_CTL_MODE_R; > + val |=3D SUN4I_TCON0_FRM_CTL_MODE_B; > + } This can be moved to the first case in your switch, and just let it fall through. You won't have to do a comparison twice then. Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --kpnhmpy4stwwpl2a Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJZ5l4zAAoJEBx+YmzsjxAg4AIP/RCsWNnrYTVCBRHUop3JpVy4 DDxBeNJaqK9YQCkRckOlLiIsEyJarIHn5FwDYYQMFeNSJ1A9UrLwH8A7353LLr6/ eMhRLvwVIypGUh1yE2gkWQlM8YpdXYzP6RmWV42PMbFDsfoTXdqCrOhFsATgNsd4 LnD0vPecNTFijd9Qh/mbGZ0i9YKWzFSbgzZbsW0yjeKzAEeN1KaWuifW+gmTX8xY wOhjNvKUizPpaD3sRMVtRQB3Z1wWKASaX+MXy+NnWlrlD9lx9oOV9nWF5CIuYXzQ CEaTD4BEXseRJO0VhCYVa7C/uIz72KJxGZJGBN80ZwnRmy/og0hchulr4LDwpD0M aiTxV/L53AM3ATsvW5afXYT484BrmxWhWiAlRFAHzQHeTbUA15iLiztYiC8SwlnF E53Ia0tSMmk+yyv7osPcqAtGhYkFgFcAvaSSQuNuM0Vctot4kzxVyDJHWD+QpnCZ 2fA99npTKZgKGI+UHJfM/DMpYkLuTqYEXvJyiNNLPcoVMykB4JDYNTjg2aDdKF6I AjfD+LJ2fSpmlMcJUQG2ev6IZlYyedvG9NNGrv11xPPvhmKlzF3SQXUsF7m2fA68 ORGAbHySPll53IUteN0hLYrO13eT8NueoAOG1tcB9SurjtOYgKEo1Z7ledwKDbDw 7Y/FCvpHxwcDrr22obLU =hfYG -----END PGP SIGNATURE----- --kpnhmpy4stwwpl2a--