From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796099655; b=QRLXPJLA5ZCGvnSgVNgZZMvHFTzvuKNTDNsTMVGIefJlFsWHPKchX9tp3G1WXJ7g4cPB WZoZhfTraNjp1h+BZOpU97l5uafSgo9Tx0oVXftv/VCaseOmahGolAY73HHgm8jMaAtnb FYTHHmBDKOLxUZjoGFRb4XNU9BbrXsJr/RZXtMK7tdgaWFNfd+squRaZscT9xxl5Rpeel NPQfklkdFBpdin/898SYDgfj/MJfd68/IWc70DLG/eJjC2U1zV/MOSAa6O/roROTRsM8R mN8nauqE2ZN/r+VGUOGh8Y0f0QDitJj6pJnA68rkEcQb/2mAmzkzzoIMK/IaEKAtmYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796099655; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=5ldOWtJRlodwxfiGen66FPdSppnaO77Wf5EJDoWQVEk=; b=yuL2EjJZvOo+wmzxTAdPLR5W7OivlDEofpXKKYTndOHPwBEjFCKeqABvqWUBl/rffQ41 DMRO90qfd52FNpVlJ6purTtKYUWquXKIF3tym9zt52eePMRbizLi+J1HocvvYq/+Ba1Gc kJtZXzW8832HquiWo7TsHjCaHygfO2VR6zEOBSnk5Vx44SUO28bl/uDl+UvEe16l1geqc mVwhP0K9lVuNmeLb3hdnqlr3NLqxAds40L16WHIAJWCycVpZ5VCUnp7p2eV7jdRLt4nwb Tk4vSYBbkCS+h2tXhmjeORYAMCErrRDXlnoCTXFoHvHacLDteKpHcWV8reqOXcpfjWQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=QZz29Nwn; arc=none smtp.remote-ip=209.85.214.182 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FCD7606A32F for ; Tue, 1 Dec 2026 04:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9FCD7606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=QZz29Nwn Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2f0918f9e6cso36750725ad.1 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=vger.kernel.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=QZz29Nwnj5tsQAF4xdrAJIxTVAokOMz0g04GepMnqnrzCBzna5zbf49jAMb629BMCP hXIEbN6id8PmZ90HIsBqjtKxDqSkJtCX3oHyCJWjQTlfJFbLiz7WdyVhEJ1d5qOeEJNQ AwDauldFzCe6lNVdVizP7SXbfeB6QOLS16boha17pyrSQkTnn1sdMF7qGZt3CLRyf2JB qGOHoF1mVhgf+34QlVJe8TK4BzlkzfoyY3EAaS1fVJm2w/xtZyDSYrz9jhNdqqDcrki+ qeepIPuzINEpnu+DdUBdKGvS4sP2yGCDSmQemGjoORWOca4fcXBztV5Wj+A8meEW1fxz VXig== 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=anOrDq97+UQpVi+0TyQk6LdvWqRaEtzEbHXfPVDeNPpPYIVubcRD7v3eqZbNh8Y9QS Rl3tnaE1shxTUDToFLLA9KjcUeTG9LLmb2S4+mtQ2usS8/fBK8e7eyJcbYk0N8u+/3eL Wfv4J/QgeUspcqTHNoLbctK0HBa4wWOP18OtQaAAqInCex7bAw9ysIghB5wliPQ6AK8f 2ebmT6BilPSWmQGGQ0a1e4NPFdiwTpBJlx0m500HiBaPHhey5gr/qvNRQxE3YDYEM1CD EYlsrbtXDmPq5pww1uWHIGEBgSDRbxhwQY3Ziq0cwc9tVJ8lP+aEoaMv0WMsVawyPHbZ Jrww== X-Forwarded-Encrypted: i=1; AL+hErHof7G14ud9OPqAG3/Ee+vEWt92Qf5fXP+4/cLNSi01hmjkepC3PJ32FWmmGwFfzZxvDJxgqNHHr/sPrtc=@vger.kernel.org X-Gm-Message-State: APuU4Z8ItFBMURELgR8wrY3a6p7K2DxhAhF3IWdXELD/dezavakdLpMS wogVfuh8U/qz0VteLI4AqQBxQfkBeRhLf2s7l1l3zaDIbIyG2yU+L0P4 X-Gm-Gg: AZFdTZdJfE8zoq4kIA6dMUt1lw+IJrPUW3u6Rog2Hqiu20PngzKP5bYGSZ2tgNCnIwc cHlDYM50891VB815ED5WBraPBfTCWwgRZFxeoZmc3J2vgJtLL8rnXEmRiRJRd31CpOUZBVATAv5 9rd1Dgr2KUwo9u/BCdscwjg2IAQA1zOgAtljoIQwq8QHa6Ad43+EllDEfJ3Bf8Xe54LfMCRKIvN /GABC1Xs7EBDe5fDhRHcMGLNcVPpfVtheolf44ALg8GzWD2s5Bd+qqHUWO4oj8Valhcsahc5diV t6HQk3ek+Z41hrbdTco2U7EcA0lxBSkF9jZJZcl0q+mrd+VG+OmNCzKiDZbiEokcIWJ3KegfW6F B9p4D8jYZml1gdFAyOkY6RQVlCsyBAiioCB4Kk+480PagZGv8W72XW3aaNtQXS6uQZdkX7c+qCd mg+7LzKZwXkzfYSbyBe1vWuiLzRfdcnf7qaOs8oDrhRD+M4Bp6Ggo7Q788GeJh4zuox+BIW+ob+ LbteFm3Zs7tNSMScNRGM/Zjx2FzWrbFP/U/0DmYSNNg6bqZrnNqKqojHSlcttVOPqOUK75XDzpw 9F1ziiT5/cZlENDFNUW38u41OtJMaBjfQmCV1vYgcDECxay65ptbpZxYjdkHEy4AePgdbSanhr8 yrGWsLp82z5NoX8j41oW7V9cIFYT6hlaOhkQGvCMMNg== 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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