[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=FV=UvobraoZELdLmCmuu1u1RpFbzEuobyWRuCn45n1b4-XA@mail.gmail.com>
Date: Thu, 6 Jul 2023 14:16:22 -0700
From: Doug Anderson <dianders@...omium.org>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Ruihai Zhou <zhouruihai@...qin.corp-partner.google.com>,
Stephen Boyd <swboyd@...omium.org>,
Cong Yang <yangcong5@...qin.corp-partner.google.com>,
Jitao Shi <jitao.shi@...iatek.com>,
Neil Armstrong <neil.armstrong@...aro.org>,
Sam Ravnborg <sam@...nborg.org>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 4/4] drm/panel: ili9882t: Break out function for
switching page
Hi,
On Mon, Jul 3, 2023 at 6:22 AM Linus Walleij <linus.walleij@...aro.org> wrote:
>
> The ILI9882t has similarities with other Ilitek panels, such
> as the characteristic internal page switching code that uses
> the model number (0x98, 0x82) as parameter.
>
> We can clearly abstract out the page switching sequence from
> the initialization code.
>
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
> ---
> drivers/gpu/drm/panel/panel-ilitek-ili9882t.c | 54 ++++++++++++++++++---------
> 1 file changed, 37 insertions(+), 17 deletions(-)
This is nice, thanks!
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c b/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c
> index 20f3cc37fa83..c1a0f10fbaf7 100644
> --- a/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c
> +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c
> @@ -55,13 +55,33 @@ struct ili9882t {
> struct gpio_desc *enable_gpio;
> };
>
> +/* ILI9882-specific commands, add new commands as you decode them */
> +#define ILI9882T_DCS_SWITCH_PAGE 0xFF
> +
> +static int ili9882t_switch_page(struct mipi_dsi_device *dsi, u8 page)
> +{
> + u8 switch_cmd[] = {0x98, 0x82, 0x00};
> + int ret;
> +
> + switch_cmd[2] = page;
> +
> + ret = mipi_dsi_dcs_write(dsi, ILI9882T_DCS_SWITCH_PAGE, switch_cmd, 3);
nit: Instead of "3", "ARRAY_SIZE(switch_cmd)" would be more documenting.
> + if (ret) {
> + dev_err(&dsi->dev,
> + "error switching panel controller page (%d)\n", ret);
> + return ret;
> + }
> +
> + return 0;
This is a static function and you don't check the error code anywhere.
Why bother returning it?
...although in patch #1 I'm suggesting adding to the core the ability
to have a "sequence of sequences". If that makes sense then perhaps
the code below that uses this will be short enough that it won't look
bad to error check each call?
> static int starry_ili9882t_init(struct mipi_dsi_device *dsi)
> {
> int ret;
>
> msleep(5);
>
> - mipi_dsi_dcs_write_seq(dsi, 0xFF, 0x98, 0x82, 0x01);
> + ili9882t_switch_page(dsi, 0x01);
> mipi_dsi_dcs_write_seq(dsi, 0x00, 0x42);
> mipi_dsi_dcs_write_seq(dsi, 0x01, 0x11);
> mipi_dsi_dcs_write_seq(dsi, 0x02, 0x00);
> @@ -192,7 +212,7 @@ static int starry_ili9882t_init(struct mipi_dsi_device *dsi)
> mipi_dsi_dcs_write_seq(dsi, 0x8B, 0x07);
> mipi_dsi_dcs_write_seq(dsi, 0x8C, 0x07);
>
> - mipi_dsi_dcs_write_seq(dsi, 0xFF, 0x98, 0x82, 0x02);
> + ili9882t_switch_page(dsi, 0x02);
> mipi_dsi_dcs_write_seq(dsi, 0x29, 0x3A);
> mipi_dsi_dcs_write_seq(dsi, 0x2A, 0x3B);
>
> @@ -211,12 +231,12 @@ static int starry_ili9882t_init(struct mipi_dsi_device *dsi)
> mipi_dsi_dcs_write_seq(dsi, 0x5E, 0x40);
> mipi_dsi_dcs_write_seq(dsi, 0x84, 0x00);
>
> - mipi_dsi_dcs_write_seq(dsi, 0xFF, 0x98, 0x82, 0x03);
> + ili9882t_switch_page(dsi, 0x03);
> mipi_dsi_dcs_write_seq(dsi, 0x20, 0x01);
> mipi_dsi_dcs_write_seq(dsi, 0x21, 0x3C);
> mipi_dsi_dcs_write_seq(dsi, 0x22, 0xFA);
>
> - mipi_dsi_dcs_write_seq(dsi, 0xFF, 0x98, 0x82, 0x0A);
> + ili9882t_switch_page(dsi, 0x0a);
Super nitty: Even though Linux in general has hex constants in
lowercase, this driver seems to consistently use uppercase. You've
introduced a few inconsistencies here (and a few more below). Can you
make this consistent? Maybe do the upper-to-lower conversion as part
of your efforts to break the driver out?
-Doug
Powered by blists - more mailing lists