From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754488AbdBFPqB (ORCPT ); Mon, 6 Feb 2017 10:46:01 -0500 Received: from smtp.domeneshop.no ([194.63.252.55]:46053 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754232AbdBFPpy (ORCPT ); Mon, 6 Feb 2017 10:45:54 -0500 Subject: Re: [PATCH v3 3/7] drm/tinydrm: Add MIPI DBI support To: Andrzej Hajda , Thierry Reding , Jani Nikula , Maxime Ripard References: <20170131160319.9695-1-noralf@tronnes.org> <20170131160319.9695-4-noralf@tronnes.org> <20170206084848.GC27607@ulmo.ba.sec> <87efzbblq6.fsf@intel.com> <20170206115347.GJ27607@ulmo.ba.sec> <6fe746a0-07dd-5d45-fa90-f4c092178ac1@samsung.com> Cc: thomas.petazzoni@free-electrons.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= Message-ID: Date: Mon, 6 Feb 2017 16:45:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <6fe746a0-07dd-5d45-fa90-f4c092178ac1@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Adding Maxime) Den 06.02.2017 13.34, skrev Andrzej Hajda: > On 06.02.2017 12:53, Thierry Reding wrote: >> On Mon, Feb 06, 2017 at 01:30:09PM +0200, Jani Nikula wrote: >>> On Mon, 06 Feb 2017, Thierry Reding wrote: >>>> On Tue, Jan 31, 2017 at 05:03:15PM +0100, Noralf Trønnes wrote: >>>>> Add support for MIPI DBI compatible controllers. >>>>> Interface type C option 1 and 3 are supported (SPI). >>>>> >>>>> Signed-off-by: Noralf Trønnes >>>>> --- >>>>> Documentation/gpu/tinydrm.rst | 12 + >>>>> drivers/gpu/drm/tinydrm/Kconfig | 3 + >>>>> drivers/gpu/drm/tinydrm/Makefile | 3 + >>>>> drivers/gpu/drm/tinydrm/mipi-dbi.c | 1005 ++++++++++++++++++++++++++++++++++++ >>>>> include/drm/tinydrm/mipi-dbi.h | 107 ++++ >>>>> 5 files changed, 1130 insertions(+) >>>>> create mode 100644 drivers/gpu/drm/tinydrm/mipi-dbi.c >>>>> create mode 100644 include/drm/tinydrm/mipi-dbi.h >>>> Any reason why this is in the tinydrm subdirectory? Looks like this >>>> could be useful to drivers outside of it. I did consider having it outside, but I couldn't find any users in drm that could benefit from it (there is one backlight driver). But now there's Maxime's panel driver. How about something like this: (I have not included the framebuffer dirty function since it will only be used in tinydrm anyway) include/drm/drm_mipi_dbi.h: struct mipi_dbi_device; /** * mipi_dbi_dcs_write - MIPI DCS command with optional parameter(s) * @dbi: MIPI DBI structure * @cmd: Command * @seq...: Optional parameter(s) * * Send MIPI DCS command to the controller. Use mipi_dbi_dcs_read_buffer() for * get/read commands. * * Returns: * Zero on success, negative error code on failure. */ #define mipi_dbi_dcs_write(dbi, cmd, seq...) \ ({ \ const u8 d[] = { seq }; \ BUILD_BUG_ON_MSG(ARRAY_SIZE(d) > 64, "DCS sequence too big for stack");\ mipi_dbi_dcs_write_buffer(dbi, cmd, d, ARRAY_SIZE(d)); \ }) ... drivers/gpu/drm/drm_mipi_dbi.c: struct mipi_dbi_device { struct mutex lock; int (*write)(struct mipi_dbi_device *dbi, u8 cmd, const u8 *par, size_t num); int (*read)(struct mipi_dbi_device *dbi, u8 cmd, u8 *par, size_t num); bool swap16; }; /* MIPI DBI Type C options 1 and 3 */ struct mipi_dbi_spi_device { struct mipi_dbi_device dbi; struct spi_device *spi; struct gpio_desc *dc; }; /* * MIPI DBI Type B - Intel 8080 type parallel bus * I need this to fully convert staging/fbtft to drm */ struct mipi_dbi_i80_device { struct mipi_dbi_device dbi; struct device *dev; struct gpio_desc *cs; struct gpio_desc *dc; struct gpio_desc *wr; struct gpio_descs *db; }; /** * mipi_dbi_get_swap16 - Is byteswapping 16-bit pixel data needed? * @dbi: MIPI DBI device * * Byte swapping 16-bit pixel data is necessary if the bus can't support 16-bit * big endian transfers (e.g. if SPI can only do 8-bit and the machine is * little endian). This applies to the MIPI_DCS_WRITE_MEMORY_START command. * * Returns: * True if it's neccesary to swap bytes, false otherwise. */ bool mipi_dbi_get_swap16(struct mipi_dbi_device *dbi) { return dbi->swap16; } /** * mipi_dbi_spi_init - Initialize MIPI DBI SPI device * @spi: SPI device * @dc: D/C gpio (optional) * @writeonly: True if it's not possible to read from the controller. * * If @dc is set, a Type C Option 3 interface is assumed, if not * Type C Option 1 (9-bit). * * If the SPI master driver doesn't support the necessary bits per word, * the following transformation is used: * * - 9-bit: reorder buffer as 9x 8-bit words, padded with no-op command. * - 16-bit (pixel data): if machine is big endian send as 8-bit, if little * endian the user is responsible for swapping the bytes. * See mipi_dbi_get_swap_pixel_bytes(). * * Returns: * Pointer to &mipi_dbi_device on success, ERR_PTR on failure. */ struct mipi_dbi_device *mipi_dbi_spi_init(struct spi_device *spi, struct gpio_desc *dc, bool writeonly) { ... } struct mipi_dbi_device *mipi_dbi_i80_init(...) Noralf.