From: Thierry Reding <thierry.reding@gmail.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>,
thomas.petazzoni@free-electrons.com, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 3/7] drm/tinydrm: Add MIPI DBI support
Date: Mon, 6 Feb 2017 12:53:47 +0100 [thread overview]
Message-ID: <20170206115347.GJ27607@ulmo.ba.sec> (raw)
In-Reply-To: <87efzbblq6.fsf@intel.com>
[-- Attachment #1: Type: text/plain, Size: 4662 bytes --]
On Mon, Feb 06, 2017 at 01:30:09PM +0200, Jani Nikula wrote:
> On Mon, 06 Feb 2017, Thierry Reding <thierry.reding@gmail.com> 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 <noralf@tronnes.org>
> >> ---
> >> 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.
> >
> >> diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c
> >> new file mode 100644
> >> index 0000000..5ded299
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
> >> @@ -0,0 +1,1005 @@
> >> +/*
> >> + * MIPI Display Bus Interface (DBI) LCD controller support
> >> + *
> >> + * Copyright 2016 Noralf Trønnes
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License as published by
> >> + * the Free Software Foundation; either version 2 of the License, or
> >> + * (at your option) any later version.
> >> + */
> >> +
> >> +#include <drm/tinydrm/mipi-dbi.h>
> >> +#include <drm/tinydrm/tinydrm-helpers.h>
> >> +#include <linux/debugfs.h>
> >> +#include <linux/dma-buf.h>
> >> +#include <linux/gpio/consumer.h>
> >> +#include <linux/module.h>
> >> +#include <linux/regulator/consumer.h>
> >> +#include <linux/spi/spi.h>
> >> +#include <video/mipi_display.h>
> >> +
> >> +#define MIPI_DBI_MAX_SPI_READ_SPEED 2000000 /* 2MHz */
> >> +
> >> +#define DCS_POWER_MODE_DISPLAY BIT(2)
> >> +#define DCS_POWER_MODE_DISPLAY_NORMAL_MODE BIT(3)
> >> +#define DCS_POWER_MODE_SLEEP_MODE BIT(4)
> >> +#define DCS_POWER_MODE_PARTIAL_MODE BIT(5)
> >> +#define DCS_POWER_MODE_IDLE_MODE BIT(6)
> >> +#define DCS_POWER_MODE_RESERVED_MASK (BIT(0) | BIT(1) | BIT(7))
> >
> > Should these perhaps be defined in include/video/mipi_display.h since
> > that already defines the MIPI_DCS_GET_POWER_MODE that this is used with?
>
> Agreed.
>
> >
> >> +/**
> >> + * mipi_dbi_command - MIPI DCS command with optional parameter(s)
> >> + * @mipi: MIPI structure
> >> + * @cmd: Command
> >> + * @seq...: Optional parameter(s)
> >> + *
> >> + * Send MIPI DCS command to the controller. Use mipi_dbi_command_read() for
> >> + * get/read.
> >> + *
> >> + * Returns:
> >> + * Zero on success, negative error code on failure.
> >> + */
> >> +#define mipi_dbi_command(mipi, cmd, seq...) \
> >> +({ \
> >> + u8 d[] = { seq }; \
> >> + mipi_dbi_command_buf(mipi, cmd, d, ARRAY_SIZE(d)); \
> >> +})
> >
> > I feel obligated to object to this because I objected to the same macro
> > when Andrzej wanted to add the same macro for MIPI DSI. But since I'm
> > apparently the only one that doesn't like this, maybe it's time for me
> > to embrace this.
>
> I think that's less interesting for MIPI DSI now that we have specific
> functions for most standard DCS commands anyway. That also avoids the
> need to have a list of read functions like here.
>
> I guess the question is if it feels like too much duplication to have
> the DCS commands as functions also for DBI. And whether it's worth
> trying to deduplicate DSI and DBI in this case, or if it gets just too
> confusing/complicated.
The problem with this is that we can't possible have all accesses
covered by specific functions. Most of the calls using this function or
macro are for panel-specific commands that often take an arbitrary
number of arguments.
I personally think that Maxime's implementation for ST7789V is somewhat
nicer, though it would require some more work for DSI and DBI to have it
all stashed into a single buffer for the transfer.
Anyway, my main concern with these is that we need to allow for proper
error handling, and the above correctly propagates error codes, so the
matter that it's a macro with a variable argument list and might store
potentially huge arrays on the stack could be addressed when they
become really problematic, rather than just annoying me because they
aren't pretty.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-02-06 11:53 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 16:03 [PATCH v3 0/7] drm: Add support for tiny LCD displays Noralf Trønnes
2017-01-31 16:03 ` [PATCH v3 1/7] drm: Add DRM " Noralf Trønnes
2017-01-31 16:23 ` Daniel Vetter
2017-01-31 18:01 ` Noralf Trønnes
2017-01-31 20:10 ` Daniel Vetter
2017-02-06 9:17 ` Thierry Reding
2017-02-06 19:23 ` Noralf Trønnes
2017-02-07 6:58 ` Daniel Vetter
2017-02-07 11:48 ` Thierry Reding
2017-02-06 10:12 ` Jani Nikula
2017-01-31 16:03 ` [PATCH v3 2/7] drm/tinydrm: Add helper functions Noralf Trønnes
2017-02-06 8:56 ` Thierry Reding
2017-02-06 9:09 ` Daniel Vetter
2017-02-06 9:35 ` Thierry Reding
[not found] ` <CAKMK7uHgW15EPpPSU2se7r89JCGD_oTvn9ZJptYaNJAWMKb9Fg@mail.gmail.com>
2017-02-06 11:08 ` Thierry Reding
2017-02-06 15:53 ` Daniel Vetter
2017-02-06 22:11 ` Noralf Trønnes
2017-02-07 11:38 ` Thierry Reding
2017-02-06 22:28 ` Dave Airlie
2017-02-07 7:00 ` Daniel Vetter
2017-02-07 11:11 ` Thierry Reding
2017-02-07 11:21 ` Daniel Vetter
2017-02-07 11:44 ` Thierry Reding
2017-02-07 13:23 ` Daniel Vetter
2017-02-06 22:55 ` Rob Herring
2017-02-07 7:08 ` Daniel Vetter
2017-02-06 10:10 ` Jani Nikula
2017-01-31 16:03 ` [PATCH v3 3/7] drm/tinydrm: Add MIPI DBI support Noralf Trønnes
2017-02-06 8:48 ` Thierry Reding
2017-02-06 11:30 ` Jani Nikula
2017-02-06 11:53 ` Thierry Reding [this message]
2017-02-06 12:34 ` Andrzej Hajda
2017-02-06 15:45 ` Noralf Trønnes
2017-02-06 11:25 ` Jani Nikula
2017-01-31 16:03 ` [PATCH v3 4/7] of: Add vendor prefix for Multi-Inno Noralf Trønnes
2017-01-31 16:03 ` [PATCH v3 5/7] dt-bindings: display: Add common rotation property Noralf Trønnes
2017-02-01 17:41 ` Rob Herring
2017-02-03 12:16 ` Noralf Trønnes
2017-02-06 7:10 ` Thierry Reding
2017-01-31 16:03 ` [PATCH v3 6/7] dt-bindings: Add Multi-Inno MI0283QT binding Noralf Trønnes
2017-02-01 17:42 ` Rob Herring
2017-01-31 16:03 ` [PATCH v3 7/7] drm/tinydrm: Add support for Multi-Inno MI0283QT display Noralf Trønnes
2017-02-06 8:25 ` Thierry Reding
2017-02-07 12:00 ` [PATCH v3 0/7] drm: Add support for tiny LCD displays Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170206115347.GJ27607@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=noralf@tronnes.org \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox