mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
To: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
Cc: thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de,
	matthias.bgg@gmail.com, weiqing.kong@mediatek.com,
	jitao.shi@mediatek.com, linux-pwm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com
Subject: Re: [PATCH 1/2] pwm: mtk-disp: Disable shadow registers before setting backlight values
Date: Thu, 26 Jan 2023 16:20:11 +0100	[thread overview]
Message-ID: <231dc0a2-c900-1c71-49e2-d9fe55bc8af1@collabora.com> (raw)
In-Reply-To: <20230126150203.dnsbw2l2fzyg3oi5@notapiano>

Il 26/01/23 16:06, Nícolas F. R. A. Prado ha scritto:
> On Mon, Jan 23, 2023 at 05:06:14PM +0100, AngeloGioacchino Del Regno wrote:
>> If shadow registers usage is not desired, disable that before performing
>> any write to CON0/1 registers in the .apply() callback, otherwise we may
>> lose clkdiv or period/width updates.
>>
>> Fixes: cd4b45ac449a ("pwm: Add MediaTek MT2701 display PWM driver support")
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> ---
>>   drivers/pwm/pwm-mtk-disp.c | 24 +++++++++++++-----------
>>   1 file changed, 13 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c
>> index 692a06121b28..82b430d881a2 100644
>> --- a/drivers/pwm/pwm-mtk-disp.c
>> +++ b/drivers/pwm/pwm-mtk-disp.c
>> @@ -138,6 +138,19 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>>   	high_width = mul_u64_u64_div_u64(state->duty_cycle, rate, div);
>>   	value = period | (high_width << PWM_HIGH_WIDTH_SHIFT);
>>   
>> +	if (mdp->data->bls_debug && !mdp->data->has_commit) {
>> +		/*
>> +		 * For MT2701, disable double buffer before writing register
> 
> Not necessarily part of this series, but I guess it would make sense to remove
> the "For MT2701". It's no longer exclusive to that SoC and the condition in the
> if above makes it clear when this happens.

Thanks for the review and test!

Anyway, for that "For MT2701", well, it ... should actually be exclusive to that
SoC (and some others) because, in reality, MT8183, MT8186, MT8192, MT8195 and
also almost all MediaTek smartphone SoCs do have shadow registers which we should
use for the backlight.

The bls_debug writes that we do are to disable writing to shadow registers and
performing commits because this driver does not (yet) support mtk_mutex handling.

The right thing to do here would be to grab a mtk_mutex, lock it, write shadow
registers, perform "backlighting adjustment magic" in mediatek_drm, commit, unlock.

Now, the "backlighting adjustment magic" is something that we do not support (yet?)
in mediatek_drm, and it's also not really easy to implement: part of that magic
needs RGB ALS readings and implementation of some more IP, which serves the purpose
of, for example, adjusting the backlight PWM while taking account of some GAMMA
adjustments to enhance readability of the screen in direct sunlight, or to decrease
(slightly) power consumption of a display lit at night.

So... the current way that we're using right now (which is disabling the shadow
registers and performing direct writes to working registers to atomically set the
backlight) is something that *should* disappear in *a* future in which that "magic"
gets somehow properly implemented.

This 9k lines mail, just to say that "For MT2701" is technically exclusive to that
SoC, between the number of supported SoCs of this driver :-P

Cheers!
Andlo

> 
> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 
> On MT8192 Asurada Spherion.
> 
> Thanks,
> Nícolas
> 


  reply	other threads:[~2023-01-26 15:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23 16:06 [PATCH 0/2] pwm: mtk-disp: Fix backlight configuration at boot AngeloGioacchino Del Regno
2023-01-23 16:06 ` [PATCH 1/2] pwm: mtk-disp: Disable shadow registers before setting backlight values AngeloGioacchino Del Regno
2023-01-26 15:06   ` Nícolas F. R. A. Prado
2023-01-26 15:20     ` AngeloGioacchino Del Regno [this message]
2023-01-23 16:06 ` [PATCH 2/2] pwm: mtk-disp: Configure double buffering before reading in .get_state() AngeloGioacchino Del Regno
2023-01-26 15:19   ` Nícolas F. R. A. Prado
2023-01-26 15:24     ` AngeloGioacchino Del Regno
2023-01-26 16:09       ` Nícolas F. R. A. Prado
2023-01-26 16:16         ` AngeloGioacchino Del Regno
2023-01-26 15:31 ` [PATCH 0/2] pwm: mtk-disp: Fix backlight configuration at boot Adrian Ratiu
2023-02-23 14:16 ` AngeloGioacchino Del Regno
2023-03-08 11:46   ` AngeloGioacchino Del Regno
2023-03-08 14:50     ` Greg Kroah-Hartman
2023-03-08 14:55       ` AngeloGioacchino Del Regno
2023-03-08 15:43         ` Greg Kroah-Hartman
2023-03-08 16:04           ` AngeloGioacchino Del Regno
2023-03-08 16:07           ` Uwe Kleine-König

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=231dc0a2-c900-1c71-49e2-d9fe55bc8af1@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=jitao.shi@mediatek.com \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nfraprado@collabora.com \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=weiqing.kong@mediatek.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

Powered by JetHome