From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796038946; b=TbNg3vF+YVGwyeXmjWNgAU0bGf4ikzsON3MgC3zA8oxJINb/hRAjJtS/oywrMpKfg1QW FMc8DCxlHT/mEm5x9heitbj/LlCdK8qDD69z6lcr6Hzect02DFfcGrmC14nY44GfUGlWk cye3aJfuDpEvIQeVhKBYSsicj4VQBNw+Hs5+CKWHibikaeE9rGU9uvbZ1tZIgN/GXlPsG A5N38aEFNoMICoJfFTK0agwHS76yzF8vTHyfpEWZTyLlxvVT70wKP7Wh7z1prxLmRcAE6 XcuoSMTB5tWRsEsurXPV+KNiJDZh+6ymaXYpaQ+hY0WN4ZbNI8QnfIstak1XKmFYCbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796038946; 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=LYuOJTtauctG5i82XYjL605dOVEGNfGoEWLQO13pvmM=; b=PO/nphJoGmlrtn6gCJ+8pxm+PGVl888l9LvWrKNqjuT+v+X8d6pAcJ5PVjvxeHNF9nQi 1VfUZUi/yTlxmze+SSxhBin3sLd6K/RdTBQyiZm1T3FWPoyHmcj9xLGRxVjdHuUAFmfaS aFkLbFknWonjmzHRl4Gz3haDOEiuM0jSufrDBT6Y+38bVYOp+04TnKagZSa+5eS5F73s2 2MMBFxcxyq8E7C/38hQlEkzuR3sz5iCdVUwFyv5iI5PLEwEZt6UH1K2IOfIy1rP8kTR0s IQt8vV/WYGjO4NTi+8TRcoTgStQjH3HRwRJFRsQPt7kDGsuRv7D7o2dR+RlNX1rm6Jg== 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=X6YsGihF; arc=none smtp.remote-ip=209.85.218.54 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 D60AF606A6AD for ; Mon, 30 Nov 2026 11:42:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D60AF606A6AD 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=X6YsGihF Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-c50aaad19fbso1109353266b.0 for ; Mon, 30 Nov 2026 03:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796038944; x=1796643744; 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=LYuOJTtauctG5i82XYjL605dOVEGNfGoEWLQO13pvmM=; b=X6YsGihFAvhp+IJeBVUvON6JQpiOzhJWc1nlsxSIkgGVyqvIevCZkN4NhoEt8uD9jJ 4NSNKL4DdLjCei7yfMyOOJLPlpvE8TAYwXLa9Bc4f2EHfnkONzH2dmzuqRPsriS9/kVn lUCN3qUagk1VHAiywbviHj1zt87CBpNe3xTmYvSnhSaxzBzWQk5kwPCArmtkUe5JUQBN 0/U3TuOH9kPuXHccPzsUtsFIyJgqn5jV1INHqryTjTLZNlGdkK6JGBsAHYE39o7R4DdQ PlHGW6198qXyeFU6APAusjJIlDPvYAdRHjext1SO8rIYW/1aUgPyLPC5CmFekreXxIdb deDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796038944; x=1796643744; 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=LYuOJTtauctG5i82XYjL605dOVEGNfGoEWLQO13pvmM=; b=MlZXJjC3f7Mhw5dEK6gWeR8oFMf8KDEwGgT580ng++gDdaS9CgbfU2PnVnh8Vt2qC7 EYguvPc6+/DiGVNhCySEJwQeAZeqUhTrKM90qJOGryoRtqmDSSuPO+/5/Fmr5ypxcrSy fQpVpwa7idyItXDtMASl54FwISV1mXhK5PJ6rwVR0xJeYii4b0e6c7qmoBcUqWPjG+cG yxYX4SZV79jXjsVLpRjN0Adpkou+q4pICV/5SHVdNKlU0+aKAp9Zei8ohJp4x0sVehjq wN1Cr7WUKeIc4dtISNbvTgvn0QSL8CBp+oMDp8CpqQT/uhIbZipIly0LbThv5v5OBjMf Ua3Q== X-Forwarded-Encrypted: i=1; AL+hErHBm2qbyMXUtst7TRNHOXNPcULL2vz0PCgP0E49S+ylBWIc25xuRNRo77LGhuKbcjE/bbKqZiQdvodEaqA=@vger.kernel.org X-Gm-Message-State: APuU4Z+GOdwDR+B8Me/RH5bpchcX6kWoTMnFFBxg2EowlQU98oFoUm/E wB0hyQfZmEkJc6H+HjREwgtWZe74ay8ayiXT909WIVSbwnfWabTzL+jw X-Gm-Gg: AZFdTZeKAyHMxuX8TO/LTsSw4sDDNUX4lfCgpVPLa1LzuhNmfEsRJAakvz0XAK1H9s7 UC2Z0VHaDgCh+In7fA1xqwS8QAv8qZnuNdfJCcP9UTYDkL3GDeFbE1Ea6YfLabVoaLVmTIowOSK cyWWt190EWY6qDRf6f0476Ie6M8EYS933lwobxL/VJhCkmGZrPARqyCJ4C0iLaEr+aPpJtAlfc4 bx82OQM3LiPDIHDMkEFbiLyPZedp/90Ifm8ngcW6jT9KT1AUtX2EgqttTmJ/qeaYeyP4qxwike/ AyRFnNZDLxumO/pRsbGVMd37o1Ju0p1r8n7neCj2svpeb2TR5h6fS5CQgjLE07RCwTNTJi//O7Q QHN0xVNnMYAeqseQwO8G+fA7gjkMd5geHubWe5oxNLgt8kGgPCcPoecRivIHz5cRgeqpeMAtf27 zzMqkVbcha2joAY3QdviqPTGABqinmS1OeufUUTFakt8kWTmW1MUyTviFIsj+0c9BcsgViX0BCR mE5oJZWdUqy6gPJAMLRMDRzH7PGPq1xB1UZ4afoL1U671IWwvLiUlSYwUR5ZLHh+hyoCTUfo/ru GFjKeMI7muvpe5/pFq/yDu4vX8vPkttMmeWZ1Dk5WUyZMkMy+R/LCPVnhZ+Z885BGFTcbuCCWzU cnCubxt1gdysKpN8J2YuGOBRpucvPU8BP X-Received: by 2002:a17:907:8e86:b0:c51:8e78:2a3b with SMTP id a640c23a62f3a-c518e7839demr1673161966b.44.1796038944108; Mon, 30 Nov 2026 03:42:24 -0800 (PST) Received: from xeon ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afc73d3sm1139733466b.64.2026.11.30.03.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 03:42:23 -0800 (PST) From: Svyatoslav Ryhel To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thierry Reding , Jonathan Hunter , Neil Armstrong , Jessica Zhang , Mikko Perttunen , Svyatoslav Ryhel Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 05/13] drm/panel: panel-lg-lh400wv3: Convert to mipi_dbi_write_seq_multi() Date: Mon, 30 Nov 2026 13:41:46 +0200 Message-ID: <20261130114155.72920-6-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130114155.72920-1-clamor95@gmail.com> References: <20261130114155.72920-1-clamor95@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 Switch from the internal panel command-sending macro to a generic one to improve code reuse. Reviewed-by: Mikko Perttunen Signed-off-by: Svyatoslav Ryhel --- drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 91 ++++++++++------------- 1 file changed, 40 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c index 6fe9654a7c3e8..f2dad3a6a2b7e 100644 --- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c +++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c @@ -34,19 +34,6 @@ static inline struct lg_lh400wv3 *to_lg_lh400wv3(struct drm_panel *panel) return container_of(panel, struct lg_lh400wv3, panel); } -#define panel_dbi_command(priv, cmd, seq...) \ -({ \ - const u8 d[] = { seq }; \ - struct drm_panel *panel = &(priv)->panel; \ - struct mipi_dbi_device *dbidev = (priv)->dbidev; \ - struct device *dev = panel->dev; \ - int ret; \ - ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \ - if (ret) \ - dev_err_ratelimited(dev, "error %d when sending command %#02x\n", ret, cmd); \ - ret; \ -}) - static int lg_lh400wv3_prepare(struct drm_panel *panel) { struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel); @@ -73,57 +60,59 @@ static int lg_lh400wv3_prepare(struct drm_panel *panel) static int lg_lh400wv3_enable(struct drm_panel *panel) { struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel); - - panel_dbi_command(priv, MIPI_DCS_EXIT_INVERT_MODE); - panel_dbi_command(priv, MIPI_DCS_SET_TEAR_ON); - - panel_dbi_command(priv, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT | - MIPI_DCS_PIXEL_FMT_24BIT << 4); - - panel_dbi_command(priv, 0xb2, 0x00, 0xc8); - panel_dbi_command(priv, 0xb3, 0x00); - panel_dbi_command(priv, 0xb4, 0x04); - panel_dbi_command(priv, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20); - panel_dbi_command(priv, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8); - panel_dbi_command(priv, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00); - - panel_dbi_command(priv, 0xc0, 0x01, 0x11); - panel_dbi_command(priv, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04); - panel_dbi_command(priv, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49); - panel_dbi_command(priv, 0xc5, 0x65); - panel_dbi_command(priv, 0xc6, 0x41, 0x63); - - panel_dbi_command(priv, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04); - panel_dbi_command(priv, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04); - panel_dbi_command(priv, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04); - panel_dbi_command(priv, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04); - panel_dbi_command(priv, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04); - panel_dbi_command(priv, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04); - - panel_dbi_command(priv, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf); - panel_dbi_command(priv, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f); - - panel_dbi_command(priv, MIPI_DCS_EXIT_SLEEP_MODE); + struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev }; + + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_INVERT_MODE); + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_TEAR_ON); + + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_24BIT | + MIPI_DCS_PIXEL_FMT_24BIT << 4); + + mipi_dbi_write_seq_multi(&ctx, 0xb2, 0x00, 0xc8); + mipi_dbi_write_seq_multi(&ctx, 0xb3, 0x00); + mipi_dbi_write_seq_multi(&ctx, 0xb4, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xb5, 0x42, 0x10, 0x10, 0x00, 0x20); + mipi_dbi_write_seq_multi(&ctx, 0xb6, 0x0b, 0x0f, 0x3c, 0x13, 0x13, 0xe8); + mipi_dbi_write_seq_multi(&ctx, 0xb7, 0x4c, 0x06, 0x0c, 0x00, 0x00); + + mipi_dbi_write_seq_multi(&ctx, 0xc0, 0x01, 0x11); + mipi_dbi_write_seq_multi(&ctx, 0xc3, 0x07, 0x03, 0x04, 0x04, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xc4, 0x12, 0x24, 0x18, 0x18, 0x02, 0x49); + mipi_dbi_write_seq_multi(&ctx, 0xc5, 0x65); + mipi_dbi_write_seq_multi(&ctx, 0xc6, 0x41, 0x63); + + mipi_dbi_write_seq_multi(&ctx, 0xd0, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xd1, 0x00, 0x46, 0x74, 0x32, 0x1d, 0x03, 0x51, 0x15, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xd2, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xd3, 0x00, 0x46, 0x74, 0x32, 0x1f, 0x03, 0x51, 0x15, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xd4, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04); + mipi_dbi_write_seq_multi(&ctx, 0xd5, 0x01, 0x46, 0x74, 0x25, 0x00, 0x03, 0x51, 0x15, 0x04); + + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0xdf); + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_PAGE_ADDRESS, 0x00, 0x00, 0x03, 0x1f); + + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_EXIT_SLEEP_MODE); msleep(120); - panel_dbi_command(priv, MIPI_DCS_WRITE_MEMORY_START); - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_ON); + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_WRITE_MEMORY_START); + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_ON); - return 0; + return ctx.accum_err; } static int lg_lh400wv3_disable(struct drm_panel *panel) { struct lg_lh400wv3 *priv = to_lg_lh400wv3(panel); + struct mipi_dbi_multi_context ctx = { .dbidev = priv->dbidev }; - panel_dbi_command(priv, MIPI_DCS_SET_DISPLAY_OFF); - panel_dbi_command(priv, MIPI_DCS_ENTER_SLEEP_MODE); + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_SET_DISPLAY_OFF); + mipi_dbi_write_seq_multi(&ctx, MIPI_DCS_ENTER_SLEEP_MODE); msleep(150); - panel_dbi_command(priv, 0xc1, 0x01); + mipi_dbi_write_seq_multi(&ctx, 0xc1, 0x01); usleep_range(10000, 11000); - return 0; + return ctx.accum_err; } static int lg_lh400wv3_unprepare(struct drm_panel *panel) -- 2.53.0