[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a8c59d2c-4c4f-4eb8-a371-03c1169c479e@linaro.org>
Date: Mon, 4 Aug 2025 17:16:18 +0200
From: neil.armstrong@...aro.org
To: Heiko Stuebner <heiko@...ech.de>
Cc: quic_jesszhan@...cinc.com, maarten.lankhorst@...ux.intel.com,
mripard@...nel.org, tzimmermann@...e.de, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, hjc@...k-chips.com,
andy.yan@...k-chips.com, andyshrk@....com, nicolas.frattaroli@...labora.com,
dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org
Subject: Re: [PATCH 03/13] drm/panel: ilitek-ili9881c: convert (un-)prepare to
mipi_dsi_multi_context
On 07/07/2025 18:48, Heiko Stuebner wrote:
> This saves some lines for error handling.
>
> For the address mode change, that value is always an u8, so switching
> to dcs_write_buffer function should be appropriate.
>
> Signed-off-by: Heiko Stuebner <heiko@...ech.de>
> ---
> drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 66 ++++++-------------
> 1 file changed, 21 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> index a20b52181ea0..154eea5f4d77 100644
> --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> @@ -1239,33 +1239,24 @@ static inline struct ili9881c *panel_to_ili9881c(struct drm_panel *panel)
> * So before any attempt at sending a command or data, we have to be
> * sure if we're in the right page or not.
> */
> -static int ili9881c_switch_page(struct ili9881c *ctx, u8 page)
> +static void ili9881c_switch_page(struct mipi_dsi_multi_context *mctx, u8 page)
> {
> u8 buf[4] = { 0xff, 0x98, 0x81, page };
> - int ret;
> -
> - ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
> - if (ret < 0)
> - return ret;
>
> - return 0;
> + mipi_dsi_dcs_write_buffer_multi(mctx, buf, sizeof(buf));
> }
>
> -static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
> +static void ili9881c_send_cmd_data(struct mipi_dsi_multi_context *mctx, u8 cmd, u8 data)
> {
> u8 buf[2] = { cmd, data };
> - int ret;
>
> - ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
> - if (ret < 0)
> - return ret;
> -
> - return 0;
> + mipi_dsi_dcs_write_buffer_multi(mctx, buf, sizeof(buf));
> }
>
> static int ili9881c_prepare(struct drm_panel *panel)
> {
> struct ili9881c *ctx = panel_to_ili9881c(panel);
> + struct mipi_dsi_multi_context mctx = { .dsi = ctx->dsi };
> unsigned int i;
> int ret;
>
> @@ -1286,54 +1277,39 @@ static int ili9881c_prepare(struct drm_panel *panel)
> const struct ili9881c_instr *instr = &ctx->desc->init[i];
>
> if (instr->op == ILI9881C_SWITCH_PAGE)
> - ret = ili9881c_switch_page(ctx, instr->arg.page);
> + ili9881c_switch_page(&mctx, instr->arg.page);
> else if (instr->op == ILI9881C_COMMAND)
> - ret = ili9881c_send_cmd_data(ctx, instr->arg.cmd.cmd,
> - instr->arg.cmd.data);
> -
> - if (ret)
> - goto disable_power;
> - }
> -
> - ret = ili9881c_switch_page(ctx, 0);
> - if (ret)
> - return ret;
> -
> - if (ctx->address_mode) {
> - ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_ADDRESS_MODE,
> - &ctx->address_mode,
> - sizeof(ctx->address_mode));
> - if (ret < 0)
> - goto disable_power;
> + ili9881c_send_cmd_data(&mctx, instr->arg.cmd.cmd,
> + instr->arg.cmd.data);
> }
>
> - ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
> - if (ret)
> - goto disable_power;
> -
> - ret = mipi_dsi_dcs_exit_sleep_mode(ctx->dsi);
> - if (ret)
> - goto disable_power;
> + ili9881c_switch_page(&mctx, 0);
>
> - msleep(120);
> + if (ctx->address_mode)
> + ili9881c_send_cmd_data(&mctx, MIPI_DCS_SET_ADDRESS_MODE,
> + ctx->address_mode);
>
> - ret = mipi_dsi_dcs_set_display_on(ctx->dsi);
> - if (ret)
> + mipi_dsi_dcs_set_tear_on_multi(&mctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
> + mipi_dsi_dcs_exit_sleep_mode_multi(&mctx);
> + mipi_dsi_msleep(&mctx, 120);
> + mipi_dsi_dcs_set_display_on_multi(&mctx);
> + if (mctx.accum_err)
> goto disable_power;
>
> return 0;
>
> disable_power:
> regulator_disable(ctx->power);
> - return ret;
> + return mctx.accum_err;
> }
>
> static int ili9881c_unprepare(struct drm_panel *panel)
> {
> struct ili9881c *ctx = panel_to_ili9881c(panel);
> + struct mipi_dsi_multi_context mctx = { .dsi = ctx->dsi };
>
> - mipi_dsi_dcs_set_display_off(ctx->dsi);
> - mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
> + mipi_dsi_dcs_set_display_off_multi(&mctx);
> + mipi_dsi_dcs_enter_sleep_mode_multi(&mctx);
> regulator_disable(ctx->power);
> gpiod_set_value_cansleep(ctx->reset, 1);
>
Reviewed-by: Neil Armstrong <neil.armstrong@...aro.org>
Powered by blists - more mailing lists