Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp893128lqj; Mon, 3 Jun 2024 04:22:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8M8IzxCKj0UXak/raXmP7ld3PRjPZgq82tJAgXWPn7urep1d6K8yEfFh/R1W0zKR7n8oHlda2QL6UOh1OUDUxJt+wycMvpByzqixt1Q== X-Google-Smtp-Source: AGHT+IEH78rd+YyY9u2bpYP9CVRtyV8VWolm0IDRHMaTl3MYB2P1TnIbGDUr8kE4ehgr4U+irAsZ X-Received: by 2002:a17:906:1c85:b0:a68:c564:46ea with SMTP id a640c23a62f3a-a68c5644cf6mr340243666b.46.1717413744343; Mon, 03 Jun 2024 04:22:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717413743; cv=pass; d=google.com; s=arc-20160816; b=UBQAyr1tXs+opY34WSMhDV9dlGxLPxCyWM944Uvyeizk256h6avxUhrKAuM8jvGnkj EXc8FaDpC2KFnAIJ4rP9QX6z5b8PxeOt4LGbL/3JnAHcQEftZhUc+j4JdGsuYVafjXLr E0brugwvZI8wMehDxw/ilLsjyFJ49AGvNpW1QRdlAG8WqS3tcW1cCnPGB5bwFSVK05kU DnPmFX+RnK95XkUWwO+OmOXXhwmsvzn5fPGJeJUm+VlLZ8ocb/bY5dmTcdwCKNmozDLC wTmGtuiPV3uSbP1iHam8QeuoqJU8u6hFw5sIEA8GbFC/a2rqaNDn3fsbGjUy1z9Y74Bn bwxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=gWbafQbRX/FPSVQoHR5AwuwkaIUn1zpIMuihK1Tckmo=; fh=Qca4uQclYGuGPeDwTz2ScN6SL0ZrdS/m01vAP+BwSac=; b=kD9ypW5s7ALQDWwqyR7q9AejZz8GtRglyTfIRpuBDtd0FpKEXPbU3hSFjVgxTXEo4U 5YHnKMwgtPuzXcpUhgOUiumy6E5D05Pm2clw+0BLfJKuWlDGgkp1789s97TCYzWMoTUq /RED9jtBGsdScT+Ol3QLOvWYkf5e7LxiKYFwfxIVPz706y0OxrNqQFeqzR6xF38T4j4t dKaKEI4WoJiYenK2zCyjHwdOpcUtXPiHbEmk8CNXh25kRSZ3FupL9jkjPpeaqt7Jzzvj javPwsCQp0blhLUvgDkPDIMw8xs4db8+P7aJOC2BIZ4Yzdk3Qdthu8vDbRzzAg/L7meY y5EA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TorMvBC/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a691cbdab10si54734166b.45.2024.06.03.04.22.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 04:22:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TorMvBC/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7F2691F239FF for ; Mon, 3 Jun 2024 11:22:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFB7584E07; Mon, 3 Jun 2024 11:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TorMvBC/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F0301366; Mon, 3 Jun 2024 11:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717413716; cv=none; b=B9RglZOZD5fI9J+l3Rbnu1TR/Phd01b0nfE3/wcOT9B+deiv+QiPIabApl66tN59yyJhIZq5ibB0t5anrerLMPG2pmwToe+LMCe8cBE7xITr82+6+YS74BcAFmTemmIkJ7cWuzF88xZJdWAxL/NQgxuiqtyTI98zJEJjL+fTiAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717413716; c=relaxed/simple; bh=7UX3J5e5E3yJhVnzO2R0Knd3rHf/1Fq06HVnhnimb4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cb88602NE4NFNkZPOTy5zZ8eHwzOPnciVjs1S7Bb0Ob6+ZtT+PdmvkizThF5XZHUzOsAXc3+FipeZKPkv7kLPPSuDB0hns2Qr1rd/vhjMxJWh28dwXTCpDRZ6fGZDd7rKVW+DYIFqttUuCSBpFItYtEJfAhgOvbkjAsCK73h6rI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TorMvBC/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id B0391C4AF0C; Mon, 3 Jun 2024 11:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717413715; bh=7UX3J5e5E3yJhVnzO2R0Knd3rHf/1Fq06HVnhnimb4g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TorMvBC/jBXbL5/e/ChgBGUV/j8nhzDH6eDtACzDJu9JJ/WA5Lyz2g5EmUwkcijJM jc6q8aDmdM1cdcTW5XjB8fIItfkmIMh+BOb8yAI/3pvlO+flMsOkgwpUg3NxcAu1yl bqLBKHwPwFHsy0fXUgAPx/NZm1p2kCQAgrIbtWRHJ5mpeBYRhHE/OW2K39pVK7pWuy DGAiq0ybGxW+LMdqoK+NbFEQjeh4CDNW8VrA1028Oi9JB5H4d3FoxfEI3HsAnOj+KD aydUR1Mr0xVw6U05n8+8LsRyHKQZCLsUfKJTdqjyJ5zsDE0qKUF6oLsPypOx2IvqCM FJomMEejG1iJw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8051C25B76; Mon, 3 Jun 2024 11:21:55 +0000 (UTC) From: =?utf-8?q?Noralf_Tr=C3=B8nnes_via_B4_Relay?= Date: Mon, 03 Jun 2024 13:21:34 +0200 Subject: [PATCH v3 3/5] drm/mipi-dbi: Make bits per word configurable for pixel transfers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240603-panel-mipi-dbi-rgb666-v3-3-59ed53ca73da@tronnes.org> References: <20240603-panel-mipi-dbi-rgb666-v3-0-59ed53ca73da@tronnes.org> In-Reply-To: <20240603-panel-mipi-dbi-rgb666-v3-0-59ed53ca73da@tronnes.org> To: Neil Armstrong , Jessica Zhang , Sam Ravnborg , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Krzysztof Kozlowski , Conor Dooley , David Lechner Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kamlesh Gurudasani , Tommaso Merciai , =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717413714; l=2428; i=noralf@tronnes.org; s=20221122; h=from:subject:message-id; bh=2flwvCUCMIpaCCor65BL4jAzjD5dEqEbPGB1PCkTkDg=; b=VmTUnh6jvTrxK39T+su2w9JqEXLPGMzKwnuczuySvYQ05IYdjdUMISTb8ePvGcKRgTcdzTo5f R9SwqlY362fA4+XK2eYx1pY7DowaXaK7fjm6x2khLWWcfHFH2jiAbGP X-Developer-Key: i=noralf@tronnes.org; a=ed25519; pk=0o9is4iddvvlrY3yON5SVtAbgPnVs0LfQsjfqR2Hvz8= X-Endpoint-Received: by B4 Relay for noralf@tronnes.org/20221122 with auth_id=8 X-Original-From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= Reply-To: noralf@tronnes.org From: Noralf Trønnes This prepares for supporting other pixel formats than RGB565. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_mipi_dbi.c | 14 ++++++++++---- include/drm/drm_mipi_dbi.h | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c index fa8aba6dc81c..77f8a828d6e0 100644 --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -1079,7 +1079,7 @@ static int mipi_dbi_typec1_command_read(struct mipi_dbi *dbi, u8 *cmd, static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd, u8 *parameters, size_t num) { - unsigned int bpw = (*cmd == MIPI_DCS_WRITE_MEMORY_START) ? 16 : 8; + unsigned int bpw = 8; int ret; if (mipi_dbi_command_is_read(dbi, *cmd)) @@ -1091,6 +1091,9 @@ static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd, if (ret || !num) return ret; + if (*cmd == MIPI_DCS_WRITE_MEMORY_START) + bpw = dbi->write_memory_bpw; + return mipi_dbi_spi1_transfer(dbi, 1, parameters, num, bpw); } @@ -1184,8 +1187,8 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd, if (ret || !num) return ret; - if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !dbi->swap_bytes) - bpw = 16; + if (*cmd == MIPI_DCS_WRITE_MEMORY_START) + bpw = dbi->write_memory_bpw; spi_bus_lock(spi->controller); gpiod_set_value_cansleep(dbi->dc, 1); @@ -1256,12 +1259,15 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi, dbi->spi = spi; dbi->read_commands = mipi_dbi_dcs_read_commands; + dbi->write_memory_bpw = 16; if (dc) { dbi->command = mipi_dbi_typec3_command; dbi->dc = dc; - if (!spi_is_bpw_supported(spi, 16)) + if (!spi_is_bpw_supported(spi, 16)) { + dbi->write_memory_bpw = 8; dbi->swap_bytes = true; + } } else { dbi->command = mipi_dbi_typec1_command; dbi->tx_buf9_len = SZ_16K; diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h index e8e0f8d39f3a..b36596efdcc3 100644 --- a/include/drm/drm_mipi_dbi.h +++ b/include/drm/drm_mipi_dbi.h @@ -56,6 +56,11 @@ struct mipi_dbi { */ struct spi_device *spi; + /** + * @write_memory_bpw: Bits per word used on a MIPI_DCS_WRITE_MEMORY_START transfer + */ + unsigned int write_memory_bpw; + /** * @dc: Optional D/C gpio. */ -- 2.45.1