dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Jagan Teki <jagan@edgeble.ai>
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Rob Herring <robh+dt@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH v2 4/4] drm: panel: Add Jadard JD9365DA-H3 DSI panel
Date: Tue, 13 Sep 2022 15:41:55 +0200	[thread overview]
Message-ID: <CACRpkdZHu+_ffZEiJrY=aq2YbJGvTA87UP5xn0NzAketGS0EEw@mail.gmail.com> (raw)
In-Reply-To: <20220908135940.299324-4-jagan@edgeble.ai>

On Thu, Sep 8, 2022 at 4:00 PM Jagan Teki <jagan@edgeble.ai> wrote:

> Jadard JD9365DA-H3 is WUXGA MIPI DSI panel and it support TFT
> dot matrix LCD with 800RGBx1280 dots at maximum.
>
> Add support for it.
>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Jagan Teki <jagan@edgeble.ai>

I wrote to Jadard and asked for a datasheet. They didn't even answer,
how rude.

> +#define _INIT_CMD_DCS(...)                                     \
> +       {                                                       \
> +               .type   = CMD_TYPE_DCS,                         \
> +               .data   = (char[]){__VA_ARGS__},                \
> +               .len    = sizeof((char[]){__VA_ARGS__})         \
> +       }                                                       \
> +
> +#define _INIT_CMD_DELAY(...)                                   \
> +       {                                                       \
> +               .type   = CMD_TYPE_DELAY,                       \
> +               .data   = (char[]){__VA_ARGS__},                \
> +               .len    = sizeof((char[]){__VA_ARGS__})         \
> +       }                                                       \

I think the _MACRO namespace (macros starting with underscore)
is reserved for the compiler.

Just call them something unique if you have to do this, such as
JD9365_INIT_CMD_DCS()

But I think you should do something more elaborate here, see
below.

> +static const struct jadard_init_cmd cz101b4001_init_cmds[] = {
> +       _INIT_CMD_DELAY(10),
> +
> +       _INIT_CMD_DCS(0xE0, 0x00),
> +       _INIT_CMD_DCS(0xE1, 0x93),
> +       _INIT_CMD_DCS(0xE2, 0x65),
> +       _INIT_CMD_DCS(0xE3, 0xF8),
> +       _INIT_CMD_DCS(0x80, 0x03),
> +       _INIT_CMD_DCS(0xE0, 0x01),

That's what we call a jam table.
(...)
> +       _INIT_CMD_DCS(0xE7, 0x0C),
> +
> +       _INIT_CMD_DELAY(120),

You introduce _INIT_CMD_DELAY() for a delay just before and
after the init sequence. Just open code these delays instead.

Then you can drop the .type field from the DCS sequences because
there is just one type.


> +       for (i = 0; i < desc->num_init_cmds; i++) {
> +               const struct jadard_init_cmd *cmd = &desc->init_cmds[i];
> +
> +               switch (cmd->type) {
> +               case CMD_TYPE_DELAY:
> +                       msleep(cmd->data[0]);
> +                       err = 0;
> +                       break;
> +               case CMD_TYPE_DCS:
> +                       err = mipi_dsi_dcs_write(dsi, cmd->data[0],
> +                                                cmd->len <= 1 ? NULL : &cmd->data[1],
> +                                                cmd->len - 1);
> +                       break;
> +               default:
> +                       err = -EINVAL;
> +               }
> +
> +               if (err < 0) {
> +                       DRM_DEV_ERROR(dev, "failed to write CMD#0x%x\n", cmd->data[0]);
> +                       return err;
> +               }
> +       }

So add explicit delays before and after this for-loop.

But then you probably see that after that you can simply replace this entire
for-loop with mipi_dsi_dcs_write_seq() so do that.

Grep in the kernel tree for examples of mipi_dsi_dcs_write_seq().

Yours,
Linus Walleij

  parent reply	other threads:[~2022-09-13 13:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220908135940.299324-1-jagan@edgeble.ai>
2022-09-08 13:59 ` [PATCH v2 3/4] dt-bindings: display: Document Jadard JD9365DA-H3 DSI panel Jagan Teki
2022-09-08 14:06   ` Krzysztof Kozlowski
2022-09-08 13:59 ` [PATCH v2 4/4] drm: panel: Add " Jagan Teki
2022-09-08 15:03   ` Dave Stevenson
2022-09-12 19:20     ` Jagan Teki
2022-09-13 13:41   ` Linus Walleij [this message]
2022-09-13 14:07     ` Jagan Teki

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='CACRpkdZHu+_ffZEiJrY=aq2YbJGvTA87UP5xn0NzAketGS0EEw@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jagan@edgeble.ai \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=robh+dt@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).