linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Duje Mihanović" <duje.mihanovic@skole.hr>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Lee Jones <lee@kernel.org>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Jingoo Han <jingoohan1@gmail.com>, Pavel Machek <pavel@ucw.cz>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>, Helge Deller <deller@gmx.de>,
	Karel Balej <balejk@matfyz.cz>,
	~postmarketos/upstreaming@lists.sr.ht,
	dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org
Subject: Re: [PATCH v2 2/2] backlight: Add Kinetic KTD2801 driver
Date: Fri, 19 Jan 2024 17:36:37 +0100	[thread overview]
Message-ID: <13440257.uLZWGnKmhe@radijator> (raw)
In-Reply-To: <CACRpkdaUvmmbGUyQ-L_u8c73=Oz+qE88GXd1=cUY7r+PPttJbw@mail.gmail.com>

On Friday, January 19, 2024 10:02:33 AM CET Linus Walleij wrote:
> Hi Duje,
> 
> thanks for your patch!
> 
> On Thu, Jan 18, 2024 at 6:33 PM Duje Mihanović <duje.mihanovic@skole.hr> 
wrote:
> > Add driver for the Kinetic KTD2801 backlight driver.>
> > Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
> 
> Add some commit message?

Besides the usual short explanation of the hardware I'd also add a link to the 
datasheet in the commit message if that's appropriate.

> > +#include <linux/backlight.h>
> > +#include <linux/delay.h>
> > +#include <linux/gpio/consumer.h>
> > +#include <linux/of.h>
> 
> I don't think you need <linux/of.h>, the compatible table works without
> that (is in the device driver core).

Can confirm it compiles without.

> > +/* These values have been extracted from Samsung's driver. */
> > +#define KTD2801_EXPRESSWIRE_DETECT_DELAY_US    150
> > +#define KTD2801_EXPRESSWIRE_DETECT_US          270
> > +#define KTD2801_LOW_BIT_HIGH_TIME_US           5
> > +#define KTD2801_LOW_BIT_LOW_TIME_US            (4 *
> > KTD2801_HIGH_BIT_LOW_TIME_US) +#define KTD2801_HIGH_BIT_LOW_TIME_US        
> >   5
> > +#define KTD2801_HIGH_BIT_HIGH_TIME_US          (4 *
> > KTD2801_HIGH_BIT_LOW_TIME_US) +#define KTD2801_DATA_START_US               
> >   5
> > +#define KTD2801_END_OF_DATA_LOW_US             10
> > +#define KTD2801_END_OF_DATA_HIGH_US            350
> > +#define KTD2801_PWR_DOWN_DELAY_US              2600
> > +
> > +#define KTD2801_DEFAULT_BRIGHTNESS     100
> > +#define KTD2801_MAX_BRIGHTNESS         255
> > +
> > +struct ktd2801_backlight {
> > +       struct backlight_device *bd;
> > +       struct gpio_desc *gpiod;
> > +       bool was_on;
> > +};
> > +
> > +static int ktd2801_update_status(struct backlight_device *bd)
> > +{
> > +       struct ktd2801_backlight *ktd2801 = bl_get_data(bd);
> > +       u8 brightness = (u8) backlight_get_brightness(bd);
> > +
> > +       if (backlight_is_blank(bd)) {
> > +               gpiod_set_value(ktd2801->gpiod, 0);
> > +               udelay(KTD2801_PWR_DOWN_DELAY_US);
> 
> That's 2600 us, a pretty long delay in a hard loop or delay timer!
> 
> Can you use usleep_range() instead, at least for this one?

Sounds like a good idea. Should I also make that GPIO pulldown _cansleep while 
at it?

> > +       for (int i = 0; i < 8; i++) {
> > +               u8 next_bit = (brightness & 0x80) >> 7;
> 
> I would just:
> 
> #include <linux/bits.h>
> 
> bool next_bit = !!(brightness & BIT(7));

Will do.

Regards,
--
Duje




  reply	other threads:[~2024-01-19 16:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18 17:32 [PATCH v2 0/2] Kinetic KTD2801 backlight driver Duje Mihanović
2024-01-18 17:32 ` [PATCH v2 1/2] dt-bindings: backlight: add Kinetic KTD2801 binding Duje Mihanović
2024-01-19  8:48   ` Linus Walleij
2024-01-18 17:32 ` [PATCH v2 2/2] backlight: Add Kinetic KTD2801 driver Duje Mihanović
2024-01-19  9:02   ` Linus Walleij
2024-01-19 16:36     ` Duje Mihanović [this message]
2024-01-19 10:07   ` Daniel Thompson
2024-01-19 16:36     ` Duje Mihanović
2024-01-19 17:29   ` Christophe JAILLET
2024-01-19 17:36     ` Duje Mihanović

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=13440257.uLZWGnKmhe@radijator \
    --to=duje.mihanovic@skole.hr \
    --cc=balejk@matfyz.cz \
    --cc=conor+dt@kernel.org \
    --cc=daniel.thompson@linaro.org \
    --cc=deller@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --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).