From: Jakob Hauser <jahau@rocketmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
Jessica Zhang <quic_jesszhan@quicinc.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
Andrzej Hajda <andrzej.hajda@intel.com>,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v3 4/5] drm/panel: samsung-s6e88a0-ams427ap24: Add brightness control
Date: Sat, 26 Oct 2024 12:47:17 +0200 [thread overview]
Message-ID: <6e4768d1-929e-4700-82bd-2e247b68de1f@rocketmail.com> (raw)
In-Reply-To: <CACRpkdYOgymfjOD3cAMXt7u8SH0vvVzwt75gamJvXuyyjdsMPw@mail.gmail.com>
Hi Linus,
On 25.10.24 21:27, Linus Walleij wrote:
...
> On Thu, Oct 24, 2024 at 5:18 AM Jakob Hauser <jahau@rocketmail.com> wrote:
>> +static const int s6e88a0_ams427ap24_br_to_cd[NUM_STEPS_CANDELA] = {
>
> (...)
>> + /* brightness till, candela */
>
> Brightness to candela conversion table? Edit comment?
In the downstream driver there is a table with four columns:
<idx> <from> <till> <candella>.
https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L341-L397
The first column is a counter, the second and third is the
from-till-range of brightness steps that correspond to the forth column
of candela identifier.
In the patch here I only adopted the third and forth column, because the
others were not necessary. The comment "brightness till, candela" was
intended to label those two columns.
To make it more clear, I could add the keyword "columns" and the column
"brightness from".
/* columns: brightness from, brightness till, candela */
/* 0 */ 10, /* 10CD */
/* 11 */ 11, /* 11CD */
/* 12 */ 12, /* 12CD */
/* 13 */ 13, /* 13CD */
/* 14 */ 14, /* 14CD */
...
/* 30 */ 30, /* 39CD */
/* 31 */ 32, /* 41CD */
/* 33 */ 34, /* 44CD */
/* 35 */ 36, /* 47CD */
...
/* 92 */ 97, /* 126CD */
/* 98 */ 104, /* 134CD */
/* 105 */ 110, /* 143CD */
/* 111 */ 118, /* 152CD */
...
/* 182 */ 205, /* 249CD */
/* 206 */ 234, /* 265CD */
/* 235 */ 254, /* 282CD */
/* 255 */ 255, /* 300CD */
>> +static const u8 s6e88a0_ams427ap24_aid[NUM_STEPS_AID][SEQ_LENGTH_AID] = {
>
> If you know that the sequence 0xb2, 0x40, 0x08, 0x20 means "set AID"
> (or is it AOR??) you can #define
>
> #define S6E88A0_SET_AID 0xb2
Thanks to Alexey Min, who looked this up, I can say:
"The PWM mechanism used on Samsung displays is called AOR (AMOLED off
ratio), the related function on the kernel driver is called AID (AMOLED
impulsive driving)."
source: xdaforums
The downstream driver of ams427ap24 uses the "aid" labeling, therefore I
stick to that. (Interestingly the older downstream driver ams427ap01
uses the "aor" labeling.)
> Then make a small buffer:
>
> u8 set_aid[5] = { S6E88A0_SET_AID, 0x40, 0x08, 0x20, 0x00, 0x00 };
>
> then you can strip the first three bytes from the entire table,
> just copy in the two relevant bytes into set_aor[]
> and send that.
Ok, I'll try to implement that. The size of the second array dimension
of that table will then become [SEQ_LENGTH_AID - 3].
...
>> +static int s6e88a0_ams427ap24_set_brightness(struct backlight_device *bd)
>> +{
>> + struct s6e88a0_ams427ap24 *ctx = bl_get_data(bd);
>> + struct mipi_dsi_device *dsi = ctx->dsi;
>> + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
>> + struct device *dev = &dsi->dev;
>> + int brightness = bd->props.brightness;
>> + int candela_enum;
>> + u8 b2[SEQ_LENGTH_AID + 1];
>> + u8 b6[SEQ_LENGTH_ELVSS + 1];
>> + u8 ca[SEQ_LENGTH_GAMMA + 1];
>
> Rename them to something like my suggestions so we understand what it is
> all about. It seems the infrastructure for what I suggested is mostly already
> there.
These defines are intended to be the sequence length of the payload for
commands aid, elvss and gamma. The naming makes sense to me.
The "+ 1" became necessary because when changing the DCS commands to
multi type I ran into the issue that there is one for
"mipi_dsi_dcs_write_seq" and one for "mipi_dsi_dcs_write_buffer"... but
none for "mipi_dsi_dcs_write" :( So I had to convert those into
"mipi_dsi_dcs_write_buffer"+multi, thus including the command register
value into the payload string.
...
>> + if (candela_enum <= CANDELA_111CD) {
>> + memcpy(&b6[1], s6e88a0_ams427ap24_elvss[0], SEQ_LENGTH_ELVSS);
>> + } else {
>> + memcpy(&b6[1], s6e88a0_ams427ap24_elvss[candela_enum - CANDELA_111CD],
>> + SEQ_LENGTH_ELVSS);
>> + }
>> +
>> + /* get gamma */
>> + ca[0] = 0xca;
>
> #define S6E88A0_SET_GAMMA 0xca
As stated in my reply on patch 3, I would like to avoid those defines
because firstly the naming becomes arbitrary and secondly it spoils the
readability of the larger DCS command blocks due to necessary line breaks.
In this specific case here a define would make sense. But I can hardly
implement it here without doing it elsewhere. Therefore I would like to
keep that as it is.
...
>> + mipi_dsi_dcs_write_buffer_multi(&dsi_ctx, b2, ARRAY_SIZE(b2));
>> + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x55, 0x00);
>
> 0x55 is MIPI_DCS_WRITE_POWER_SAVE in <video/mipi_display.h>
It's the only one that could be used from <video/mipi_display.h>.
Though "MIPI_DCS_WRITE_POWER_SAVE, 0x00" doesn't say much. In the
downstream driver there are four levels of ACL:
0x55, 0x00 -> ACL off
0x55, 0x01 -> default ACL 15 %
0x55, 0x02 -> ACL 30 %, also corresponds to the "ACL on" command
0x55, 0x03 -> doesn't seem to be used
https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/video/msm/mdss/samsung/S6E88A0_AMS427AP24/dsi_panel_S6E88A0_AMS427AP24_qhd_octa_video.dtsi#L275-L281
I would prefer to stay at 0x55 and add comment "acl off". Embedded in a
block of other DCS commands with plain command register values and
single line comments appended, as proposed in my reply on patch 3, it
looks more readable and descriptive in the context of the other commands.
Kind regards,
Jakob
next prev parent reply other threads:[~2024-10-26 11:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 3:18 [PATCH v3 0/5] Add new panel driver Samsung S6E88A0-AMS427AP24 Jakob Hauser
2024-10-24 3:18 ` [PATCH v3 1/5] dt-bindings: display: panel: Move flip properties to panel-common Jakob Hauser
2024-10-25 16:25 ` Linus Walleij
2024-10-24 3:18 ` [PATCH v3 2/5] dt-bindings: display: panel: Add Samsung S6E88A0-AMS427AP24 Jakob Hauser
2024-10-25 16:24 ` Linus Walleij
2024-10-24 3:18 ` [PATCH v3 3/5] drm/panel: samsung-s6e88a0-ams427ap24: Add initial driver Jakob Hauser
2024-10-25 16:36 ` Linus Walleij
2024-10-26 8:51 ` Jakob Hauser
2024-10-24 3:18 ` [PATCH v3 4/5] drm/panel: samsung-s6e88a0-ams427ap24: Add brightness control Jakob Hauser
2024-10-25 19:27 ` Linus Walleij
2024-10-26 10:47 ` Jakob Hauser [this message]
2024-10-24 3:18 ` [PATCH v3 5/5] drm/panel: samsung-s6e88a0-ams427ap24: Add flip option Jakob Hauser
2024-10-25 19:32 ` Linus Walleij
2024-10-26 11:13 ` Jakob Hauser
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=6e4768d1-929e-4700-82bd-2e247b68de1f@rocketmail.com \
--to=jahau@rocketmail.com \
--cc=andrzej.hajda@intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=quic_jesszhan@quicinc.com \
--cc=robh@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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).