Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751659AbdG2TSO (ORCPT ); Sat, 29 Jul 2017 15:18:14 -0400 Received: from vern.gendns.com ([206.190.152.46]:50976 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751593AbdG2TSH (ORCPT ); Sat, 29 Jul 2017 15:18:07 -0400 From: David Lechner To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , David Airlie , Rob Herring , Mark Rutland , Sekhar Nori , Kevin Hilman , linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] drm/tinydrm: Add parameter for MIPI DCS pixel format Date: Sat, 29 Jul 2017 14:17:45 -0500 Message-Id: <1501355870-13960-2-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501355870-13960-1-git-send-email-david@lechnology.com> References: <1501355870-13960-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5993 Lines: 162 This adds a parameter for MIPI DCS pixel format to mipi_dbi_init(). This is in preparation for supporting displays that don't use a 16bpp memory layout. Signed-off-by: David Lechner --- drivers/gpu/drm/tinydrm/mi0283qt.c | 3 ++- drivers/gpu/drm/tinydrm/mipi-dbi.c | 21 ++++++++++++++++++--- include/drm/tinydrm/mipi-dbi.h | 7 ++++++- include/video/mipi_display.h | 14 ++++++++------ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c index 482ff1c3..2680dab 100644 --- a/drivers/gpu/drm/tinydrm/mi0283qt.c +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c @@ -196,7 +196,8 @@ static int mi0283qt_probe(struct spi_device *spi) device_property_read_u32(dev, "rotation", &rotation); ret = mipi_dbi_spi_init(spi, mipi, dc, &mi0283qt_pipe_funcs, - &mi0283qt_driver, &mi0283qt_mode, rotation); + &mi0283qt_driver, &mi0283qt_mode, + MIPI_DCS_PIXEL_FMT_16BIT, rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index c83eeb7..7d49366 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -336,6 +336,7 @@ static const uint32_t mipi_dbi_formats[] = { * @pipe_funcs: Display pipe functions * @driver: DRM driver * @mode: Display mode + * @pixel_fmt: The display memory's pixel format * @rotation: Initial rotation in degrees Counter Clock Wise * * This function initializes a &mipi_dbi structure and it's underlying @@ -352,15 +353,26 @@ static const uint32_t mipi_dbi_formats[] = { int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi, const struct drm_simple_display_pipe_funcs *pipe_funcs, struct drm_driver *driver, - const struct drm_display_mode *mode, unsigned int rotation) + const struct drm_display_mode *mode, + enum mipi_dcs_pixel_format pixel_fmt, unsigned int rotation) { - size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16); struct tinydrm_device *tdev = &mipi->tinydrm; + size_t bufsize; int ret; if (!mipi->command) return -EINVAL; + switch (pixel_fmt) { + case MIPI_DCS_PIXEL_FMT_16BIT: + bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16); + break; + default: + DRM_ERROR("Pixel format is not supported\n"); + return -EINVAL; + } + mipi->pixel_fmt = pixel_fmt; + mutex_init(&mipi->cmdlock); mipi->tx_buf = devm_kmalloc(dev, bufsize, GFP_KERNEL); @@ -781,6 +793,7 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *mipi, u8 cmd, * @pipe_funcs: Display pipe functions * @driver: DRM driver * @mode: Display mode + * @pixel_fmt: The display memory's pixel format * @rotation: Initial rotation in degrees Counter Clock Wise * * This function sets &mipi_dbi->command, enables &mipi->read_commands for the @@ -803,6 +816,7 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, const struct drm_simple_display_pipe_funcs *pipe_funcs, struct drm_driver *driver, const struct drm_display_mode *mode, + enum mipi_dcs_pixel_format pixel_fmt, unsigned int rotation) { size_t tx_size = tinydrm_spi_max_transfer_size(spi, 0); @@ -849,7 +863,8 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *mipi, return -ENOMEM; } - return mipi_dbi_init(dev, mipi, pipe_funcs, driver, mode, rotation); + return mipi_dbi_init(dev, mipi, pipe_funcs, driver, mode, pixel_fmt, + rotation); } EXPORT_SYMBOL(mipi_dbi_spi_init); diff --git a/include/drm/tinydrm/mipi-dbi.h b/include/drm/tinydrm/mipi-dbi.h index d137b16..dda100c 100644 --- a/include/drm/tinydrm/mipi-dbi.h +++ b/include/drm/tinydrm/mipi-dbi.h @@ -13,6 +13,7 @@ #define __LINUX_MIPI_DBI_H #include +#include