From patchwork Sat Jul 29 19:17:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 9870071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D68536038F for ; Sat, 29 Jul 2017 19:19:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8523286A8 for ; Sat, 29 Jul 2017 19:19:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCCC3287C3; Sat, 29 Jul 2017 19:19:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3220F287A9 for ; Sat, 29 Jul 2017 19:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbdG2TSK (ORCPT ); Sat, 29 Jul 2017 15:18:10 -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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=w0beLGCemBIEzALhISd2WTpBkiczr/EHWIbn3+SPtPk=; b=coNRtsvihmb2cXzj1CTYacG7h x0mjhepod7o4hyNLsmC9BLn7pPTx0FfjMrmlSIFXkoSnepv7XOEUTbzzcsZ4JUmgsrlhHoetY9Izy XDTqnMhhREN6xpKMykTxYc9ZWDj8TXilhZ9DnZytZroUY4Y7xkr8W0xwdlCcxhyCi9iyHX/t9aSYC pcBfDNvOQ5cU+BZuLGdm9fAXel6Jrj7AL67ZzVMkN8UtewjcpV1fedUIWpPyeExwpLtWHi7GCWuON x+cXly7lqh10u7HghmBP6io0WbW9iKlGKc29LMViSKCkihzsa0rAR1g7zEk+xyqAXbaIgzpgyvYjb 2pofhpX1g==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:58148 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89) (envelope-from ) id 1dbXCt-000DrP-Gh; Sat, 29 Jul 2017 15:15:23 -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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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