From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6F22606A31A for ; Tue, 1 Dec 2026 04:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ka08dTz2 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5472E10E191; Tue, 1 Dec 2026 04:34:21 +0000 (UTC) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8735910E1A4 for ; Tue, 1 Dec 2026 04:34:14 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2f03f3631b2so56007515ad.2 for ; Mon, 30 Nov 2026 20:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796099654; x=1796704454; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5ldOWtJRlodwxfiGen66FPdSppnaO77Wf5EJDoWQVEk=; b=ka08dTz2ugUMCytjrIU1GTQvM24EifwJo0EyOdXn51V2v/k8gZdyb7O64NIqa7ZgCF uXWlxiq3PC8q0EbmNNmkSd5fWORA3XJblWhX5Oh/lcZF0xuF1ASDQ4B1Exu7yJjY+z3S IxhrrMtI8dMS1GtR5xpY4CJiFJxM8WWYbO/aOsTKDdzhex4/XkymoHOyIKAUtHKhUajE UbQCiPPeWyKN1zec/1q2uAk1hURhLaoPonoRvs9oP+rC/3JPtLE3YUhXioDQvNT2smp7 X17phCUiHb95Aff9V2tJQmUH/SI1DWiuZmCRbgyyheaTCk7skZd+tvdgBAk4MeB7YD4z z08A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796099654; x=1796704454; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=5ldOWtJRlodwxfiGen66FPdSppnaO77Wf5EJDoWQVEk=; b=yZTg4dwUr15l7T7LbGfzq4zlQIVeIVctSEXgXGk1uE3g9sPlh2hEVtI5wZR6yt3wWU RsWax1sDz5Qw7K9i+1ByVK65osMk4WRqKJ5HsfziGTOqWQ8KyQIT3nKDnuBCB3/Qzqja X5PrplLrSJ9VEgPXGUE+ffZ3fXC/h467XQpotv6JCPApm0B0melEZcfQtahF3Zz82iSG WwB0Rsdk3jWwwT0qEU0sOS7IWU8E74em46WGC5SE1FdzNZSDzs4dASLSULLWM2Wk3bUD S0hVyVQXySDPunStylJKXnQABLzZihPVM1jToY3vSFj0+10nHb/bixwQzwDWyZ3TIxVt xqYA== X-Forwarded-Encrypted: i=1; AL+hErHN6HdsZbz741g1r91JPWxie4CyVMe70npQkoQS3vIjsxtzSFBEQgPk5UtCaJ1o3rKNe3avo3AWUM0=@lists.freedesktop.org X-Gm-Message-State: APuU4Z+TRj/SIwSM8G/MazfnDtOcGovWSuYYeeg5A22ptuhEBS7/9koA vbhmx6rTQyqEClDgg7IBj3dMJJGKJ0pCHHZnSJV7VLFm/FSDq7N5FCyT X-Gm-Gg: AZFdTZcQqXUWUizcyxSUUyOo2EEMeJDiUWP13WzUsxk+YobYpWp5TrDwU9eQRG2JHpA zw+5EQZyR4JtDT1/1AnN49Dj7WWgFjuITvn5aGn28QNn3TZX4bBGvlpDGCcX3YZGTimX43EP6TO C10sL0ippS7UVkTtqeoJaxg2PnECJdLhcYvYZnTf5KJlReZeCtFesu/+xPx1zHsr5bHuLb+udLT wn8XHXW9w7g49L6kYbwmimocCdAsF9FKAXufc4QhnXZK+fmmmEfzhN3/pDFD9V0fmjK/eWVHfyI xNicixuMDTv3UJ/Fr592XJjHiYfZQU9iRbUWueGJoADTOu6UpSU39fLm2DwND1axviiKQ6DKwnx qxgRuZiyc738hdIpIjKqSxC53PbJxMnuSlV12XxhvuNZnmTla/cWm01ewRDcgb+rw0oOKBf7eQ9 xgvygppnjbeqMJ5A4VpIP2JhUEgrCT/ZAe39ewJxBAjnmUNShzV5MvgljmVVoBSSCsO7gTnykXB OyDpJrwzXNFsbY3bLRgYCuu/xGLZ5EnqqsJiavteoEayMrAACrVKj2pkojfZtIwE6PGowwQaoyk xgTVZ4XNovJOxVAcHZ5zxXvOThek+rc4p/2XcEWvurXaW6g3A0/UlwSnhH4kK0TEk0k6tkUvflZ biEY7I/GbsMFMhUoxw2Aw+F00mB/JletPAnWLeHsHtQ== X-Received: by 2002:a17:902:e802:b0:2ef:d9b8:469 with SMTP id d9443c01a7336-2f03f21e8b9mr337500605ad.43.1796099653899; Mon, 30 Nov 2026 20:34:13 -0800 (PST) Received: from NB150512.ADVANTECH.CORP (180-177-145-62.dynamic.kbronet.com.tw. [180.177.145.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f191464sm180000515ad.1.2026.11.30.20.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 20:34:13 -0800 (PST) From: Hsieh Hung-En To: neil.armstrong@linaro.org, jesszhan0024@gmail.com, dianders@chromium.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, hoegeun.kwon@samsung.com, human.hwang@samsung.com, dh09.lee@samsung.com, treding@nvidia.com, andrzej.hajda@intel.com, dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Hsieh Hung-En Subject: [PATCH 2/2] drm/panel: samsung-s6e3ha2: Use mipi_dsi_*_multi() functions Date: Tue, 1 Dec 2026 12:33:57 +0800 Message-ID: <20261201043357.2064027-3-hungen3108@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201043357.2064027-1-hungen3108@gmail.com> References: <20261201043357.2064027-1-hungen3108@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Replace the deprecated MIPI DSI DCS helpers and the custom s6e3ha2_dcs_write(), s6e3ha2_dcs_write_seq_static(), and s6e3ha2_call_write_func() wrappers with the mipi_dsi_*_multi() helpers, as suggested in Documentation/gpu/todo.rst. Convert the static command helpers to void functions taking a struct mipi_dsi_multi_context pointer, keeping their original names and command sequences intact. Use mipi_dsi_usleep_range() in s6e3ha2_panel_init(), while keeping plain msleep(40) in s6e3ha2_disable() and clearing accum_err between commands so SET_DISPLAY_OFF is still attempted if ENTER_SLEEP_MODE fails. Split the DSI brightness write sequence out of s6e3ha2_set_brightness() into s6e3ha2_apply_brightness() so that s6e3ha2_enable() can share its own mipi_dsi_multi_context. This skips brightness writes if any earlier command in s6e3ha2_enable() failed and propagates the first error. The range and bl_dev->props.power checks remain in s6e3ha2_set_brightness() for backlight core callers; when called from s6e3ha2_enable(), brightness is already bounded by backlight core and props.power is set to BACKLIGHT_POWER_REDUCED in prepare() and disable(), so behavior is unchanged. Removing bl_dev from s6e3ha2_update_gamma() also drops the redundant self-assignment of bl_dev->props.brightness. The _multi() helpers now log failed DCS transfers automatically; s6e3ha2_panel_init(), s6e3ha2_enable(), and s6e3ha2_set_brightness() previously did not log errors, and s6e3ha2_disable() no longer needs manual dev_err() calls. Signed-off-by: Hsieh Hung-En --- Notes: - Mechanically extracted all 29 static DCS command byte sequences from s6e3ha2_dcs_write_seq_static() before and mipi_dsi_dcs_write_seq_multi() after, verifying that every sequence and byte value matches identically. - Mechanically verified the call order in s6e3ha2_panel_init(), s6e3ha2_disable(), and s6e3ha2_enable(), and that s6e3ha2_apply_brightness() issues the exact same command sequence previously in s6e3ha2_set_brightness(). - For the two non-static writes, s6e3ha2_update_gamma() and s6e3ha2_set_vint() keep the same payload computation and only switch to mipi_dsi_dcs_write_buffer_multi() and mipi_dsi_dcs_write_var_seq_multi(). drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 289 ++++++++---------- 1 file changed, 123 insertions(+), 166 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c index 3a90b83002e5..01661428bfac 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c @@ -241,170 +241,129 @@ struct s6e3ha2 { const struct s6e3ha2_panel_desc *desc; }; -static int s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len) +static void s6e3ha2_test_key_on_f0(struct mipi_dsi_multi_context *dsi_ctx) { - struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); - - return mipi_dsi_dcs_write_buffer(dsi, data, len); -} - -#define s6e3ha2_dcs_write_seq_static(ctx, seq...) do { \ - static const u8 d[] = { seq }; \ - int ret; \ - ret = s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d)); \ - if (ret < 0) \ - return ret; \ -} while (0) - -#define s6e3ha2_call_write_func(ret, func) do { \ - ret = (func); \ - if (ret < 0) \ - return ret; \ -} while (0) - -static int s6e3ha2_test_key_on_f0(struct s6e3ha2 *ctx) -{ - s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf0, 0x5a, 0x5a); } -static int s6e3ha2_test_key_off_f0(struct s6e3ha2 *ctx) +static void s6e3ha2_test_key_off_f0(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0xa5, 0xa5); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf0, 0xa5, 0xa5); } -static int s6e3ha2_test_key_on_fc(struct s6e3ha2 *ctx) +static void s6e3ha2_test_key_on_fc(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfc, 0x5a, 0x5a); } -static int s6e3ha2_test_key_off_fc(struct s6e3ha2 *ctx) +static void s6e3ha2_test_key_off_fc(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0xa5, 0xa5); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfc, 0xa5, 0xa5); } -static int s6e3ha2_single_dsi_set(struct s6e3ha2 *ctx) +static void s6e3ha2_single_dsi_set(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67); - s6e3ha2_dcs_write_seq_static(ctx, 0xf9, 0x09); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf2, 0x67); + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf9, 0x09); } -static int s6e3ha2_freq_calibration(struct s6e3ha2 *ctx) +static void s6e3ha2_freq_calibration(struct mipi_dsi_multi_context *dsi_ctx, + enum s6e3ha2_type type) { - s6e3ha2_dcs_write_seq_static(ctx, 0xfd, 0x1c); - if (ctx->desc->type == HF2_TYPE) - s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67, 0x40, 0xc5); - s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20, 0x39); - s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0xa0); - s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20); + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfd, 0x1c); + if (type == HF2_TYPE) + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf2, 0x67, 0x40, 0xc5); + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0x20, 0x39); + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0xa0); + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0x20); - if (ctx->desc->type == HA2_TYPE) - s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62, - 0x40, 0x80, 0xc0, 0x28, 0x28, - 0x28, 0x28, 0x39, 0xc5); + if (type == HA2_TYPE) + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xce, 0x03, 0x3b, 0x12, + 0x62, 0x40, 0x80, 0xc0, 0x28, 0x28, + 0x28, 0x28, 0x39, 0xc5); else - s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x14, 0x6d, - 0x40, 0x80, 0xc0, 0x28, 0x28, - 0x28, 0x28, 0x39, 0xc5); - - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xce, 0x03, 0x3b, 0x14, + 0x6d, 0x40, 0x80, 0xc0, 0x28, 0x28, + 0x28, 0x28, 0x39, 0xc5); } -static int s6e3ha2_aor_control(struct s6e3ha2 *ctx) +static void s6e3ha2_aor_control(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb2, 0x03, 0x10); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb2, 0x03, 0x10); } -static int s6e3ha2_caps_elvss_set(struct s6e3ha2 *ctx) +static void s6e3ha2_caps_elvss_set(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb6, 0x9c, 0x0a); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb6, 0x9c, 0x0a); } -static int s6e3ha2_acl_off(struct s6e3ha2 *ctx) +static void s6e3ha2_acl_off(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0x55, 0x00); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x55, 0x00); } -static int s6e3ha2_acl_off_opr(struct s6e3ha2 *ctx) +static void s6e3ha2_acl_off_opr(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb5, 0x40); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb5, 0x40); } -static int s6e3ha2_test_global(struct s6e3ha2 *ctx) +static void s6e3ha2_test_global(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x07); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb0, 0x07); } -static int s6e3ha2_test(struct s6e3ha2 *ctx) +static void s6e3ha2_test(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb8, 0x19); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb8, 0x19); } -static int s6e3ha2_touch_hsync_on1(struct s6e3ha2 *ctx) +static void s6e3ha2_touch_hsync_on1(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xbd, 0x33, 0x11, 0x02, - 0x16, 0x02, 0x16); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xbd, 0x33, 0x11, 0x02, + 0x16, 0x02, 0x16); } -static int s6e3ha2_pentile_control(struct s6e3ha2 *ctx) +static void s6e3ha2_pentile_control(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8); } -static int s6e3ha2_poc_global(struct s6e3ha2 *ctx) +static void s6e3ha2_poc_global(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x20); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb0, 0x20); } -static int s6e3ha2_poc_setting(struct s6e3ha2 *ctx) +static void s6e3ha2_poc_setting(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x08); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0x08); } -static int s6e3ha2_pcd_set_off(struct s6e3ha2 *ctx) +static void s6e3ha2_pcd_set_off(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xcc, 0x40, 0x51); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xcc, 0x40, 0x51); } -static int s6e3ha2_err_fg_set(struct s6e3ha2 *ctx) +static void s6e3ha2_err_fg_set(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xed, 0x44); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xed, 0x44); } -static int s6e3ha2_hbm_off(struct s6e3ha2 *ctx) +static void s6e3ha2_hbm_off(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0x53, 0x00); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x53, 0x00); } -static int s6e3ha2_te_start_setting(struct s6e3ha2 *ctx) +static void s6e3ha2_te_start_setting(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xb9, 0x10, 0x09, 0xff, 0x00, 0x09); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb9, 0x10, 0x09, 0xff, 0x00, + 0x09); } -static int s6e3ha2_gamma_update(struct s6e3ha2 *ctx) +static void s6e3ha2_gamma_update(struct mipi_dsi_multi_context *dsi_ctx) { - s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x03); + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf7, 0x03); ndelay(100); /* need for 100ns delay */ - s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x00); - return 0; + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf7, 0x00); } static int s6e3ha2_get_brightness(struct backlight_device *bl_dev) @@ -412,15 +371,13 @@ static int s6e3ha2_get_brightness(struct backlight_device *bl_dev) return bl_dev->props.brightness; } -static int s6e3ha2_set_vint(struct s6e3ha2 *ctx) +static void s6e3ha2_set_vint(struct mipi_dsi_multi_context *dsi_ctx, + unsigned int brightness) { - struct backlight_device *bl_dev = ctx->bl_dev; - unsigned int brightness = bl_dev->props.brightness; - unsigned char data[] = { 0xf4, 0x8b, - vint_table[brightness * (S6E3HA2_VINT_STATUS_MAX - 1) / - S6E3HA2_MAX_BRIGHTNESS] }; + unsigned int idx = brightness * (S6E3HA2_VINT_STATUS_MAX - 1) / + S6E3HA2_MAX_BRIGHTNESS; - return s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data)); + mipi_dsi_dcs_write_var_seq_multi(dsi_ctx, 0xf4, 0x8b, vint_table[idx]); } static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness) @@ -429,28 +386,33 @@ static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness) S6E3HA2_MAX_BRIGHTNESS; } -static int s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness) +static void s6e3ha2_update_gamma(struct mipi_dsi_multi_context *dsi_ctx, + unsigned int brightness) { - struct backlight_device *bl_dev = ctx->bl_dev; unsigned int index = s6e3ha2_get_brightness_index(brightness); u8 data[S6E3HA2_GAMMA_CMD_CNT + 1] = { 0xca, }; - int ret; memcpy(data + 1, gamma_tbl + index, S6E3HA2_GAMMA_CMD_CNT); - s6e3ha2_call_write_func(ret, - s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data))); - - s6e3ha2_call_write_func(ret, s6e3ha2_gamma_update(ctx)); - bl_dev->props.brightness = brightness; + mipi_dsi_dcs_write_buffer_multi(dsi_ctx, data, ARRAY_SIZE(data)); + s6e3ha2_gamma_update(dsi_ctx); +} - return 0; +static void s6e3ha2_apply_brightness(struct mipi_dsi_multi_context *dsi_ctx, + unsigned int brightness) +{ + s6e3ha2_test_key_on_f0(dsi_ctx); + s6e3ha2_update_gamma(dsi_ctx, brightness); + s6e3ha2_aor_control(dsi_ctx); + s6e3ha2_set_vint(dsi_ctx, brightness); + s6e3ha2_test_key_off_f0(dsi_ctx); } static int s6e3ha2_set_brightness(struct backlight_device *bl_dev) { struct s6e3ha2 *ctx = bl_get_data(bl_dev); + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; unsigned int brightness = bl_dev->props.brightness; - int ret; if (brightness < S6E3HA2_MIN_BRIGHTNESS || brightness > bl_dev->props.max_brightness) { @@ -461,13 +423,9 @@ static int s6e3ha2_set_brightness(struct backlight_device *bl_dev) if (bl_dev->props.power > BACKLIGHT_POWER_REDUCED) return -EPERM; - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_f0(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_update_gamma(ctx, brightness)); - s6e3ha2_call_write_func(ret, s6e3ha2_aor_control(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_set_vint(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx)); + s6e3ha2_apply_brightness(&dsi_ctx, brightness); - return 0; + return dsi_ctx.accum_err; } static const struct backlight_ops s6e3ha2_bl_ops = { @@ -478,19 +436,19 @@ static const struct backlight_ops s6e3ha2_bl_ops = { static int s6e3ha2_panel_init(struct s6e3ha2 *ctx) { struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); - int ret; + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; - s6e3ha2_call_write_func(ret, mipi_dsi_dcs_exit_sleep_mode(dsi)); - usleep_range(5000, 6000); + mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx); + mipi_dsi_usleep_range(&dsi_ctx, 5000, 6000); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_f0(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_single_dsi_set(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_fc(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_freq_calibration(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_fc(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx)); + s6e3ha2_test_key_on_f0(&dsi_ctx); + s6e3ha2_single_dsi_set(&dsi_ctx); + s6e3ha2_test_key_on_fc(&dsi_ctx); + s6e3ha2_freq_calibration(&dsi_ctx, ctx->desc->type); + s6e3ha2_test_key_off_fc(&dsi_ctx); + s6e3ha2_test_key_off_f0(&dsi_ctx); - return 0; + return dsi_ctx.accum_err; } static int s6e3ha2_power_off(struct s6e3ha2 *ctx) @@ -502,15 +460,13 @@ static int s6e3ha2_disable(struct drm_panel *panel) { struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel); struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); - int ret; + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; - ret = mipi_dsi_dcs_enter_sleep_mode(dsi); - if (ret < 0) - dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret); + mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx); - ret = mipi_dsi_dcs_set_display_off(dsi); - if (ret < 0) - dev_err(ctx->dev, "failed to set display off: %d\n", ret); + /* Attempt to turn display off even if enter sleep mode failed. */ + dsi_ctx.accum_err = 0; + mipi_dsi_dcs_set_display_off_multi(&dsi_ctx); msleep(40); ctx->bl_dev->props.power = BACKLIGHT_POWER_REDUCED; @@ -572,43 +528,44 @@ static int s6e3ha2_enable(struct drm_panel *panel) { struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel); struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); - int ret; + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; /* common setting */ - s6e3ha2_call_write_func(ret, - mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK)); + mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_f0(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_fc(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_touch_hsync_on1(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_pentile_control(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_poc_global(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_poc_setting(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_fc(ctx)); + s6e3ha2_test_key_on_f0(&dsi_ctx); + s6e3ha2_test_key_on_fc(&dsi_ctx); + s6e3ha2_touch_hsync_on1(&dsi_ctx); + s6e3ha2_pentile_control(&dsi_ctx); + s6e3ha2_poc_global(&dsi_ctx); + s6e3ha2_poc_setting(&dsi_ctx); + s6e3ha2_test_key_off_fc(&dsi_ctx); /* pcd setting off for TB */ - s6e3ha2_call_write_func(ret, s6e3ha2_pcd_set_off(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_err_fg_set(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_te_start_setting(ctx)); + s6e3ha2_pcd_set_off(&dsi_ctx); + s6e3ha2_err_fg_set(&dsi_ctx); + s6e3ha2_te_start_setting(&dsi_ctx); /* brightness setting */ - s6e3ha2_call_write_func(ret, s6e3ha2_set_brightness(ctx->bl_dev)); - s6e3ha2_call_write_func(ret, s6e3ha2_aor_control(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_caps_elvss_set(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_gamma_update(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_acl_off(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_acl_off_opr(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_hbm_off(ctx)); + s6e3ha2_apply_brightness(&dsi_ctx, ctx->bl_dev->props.brightness); + s6e3ha2_aor_control(&dsi_ctx); + s6e3ha2_caps_elvss_set(&dsi_ctx); + s6e3ha2_gamma_update(&dsi_ctx); + s6e3ha2_acl_off(&dsi_ctx); + s6e3ha2_acl_off_opr(&dsi_ctx); + s6e3ha2_hbm_off(&dsi_ctx); /* elvss temp compensation */ - s6e3ha2_call_write_func(ret, s6e3ha2_test_global(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test(ctx)); - s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx)); + s6e3ha2_test_global(&dsi_ctx); + s6e3ha2_test(&dsi_ctx); + s6e3ha2_test_key_off_f0(&dsi_ctx); - s6e3ha2_call_write_func(ret, mipi_dsi_dcs_set_display_on(dsi)); - ctx->bl_dev->props.power = BACKLIGHT_POWER_ON; + mipi_dsi_dcs_set_display_on_multi(&dsi_ctx); - return 0; + if (!dsi_ctx.accum_err) + ctx->bl_dev->props.power = BACKLIGHT_POWER_ON; + + return dsi_ctx.accum_err; } static const struct drm_display_mode s6e3ha2_mode = { -- 2.43.0