Re: Linux support for a 7 segment LED display

From: Geert Uytterhoeven
Date: Fri Feb 23 2024 - 02:53:25 EST


Hi Pavel,

On Fri, Feb 23, 2024 at 8:47 AM Pavel Machek <pavel@xxxxxx> wrote:
> > > Right, but also with some additional properties, like
> > > - type of the indicator (7, 14, etc segments, for now we have only
> > > these two supported)
> > > - use-dot (+1 led per each digit)
> > > - characters (how many digits we have, so we need respective amount of GPIOs)
> > >
> > > With this it's indeed belongs directly to auxdisplay as we have almost
> > > everything is done already there.
> >
> > I've been playing about with this. I've got an auxdisplay driver that's
> > basically working (I won't bother spamming list with it yet). But I'm
> > wondering how I'd represent multiple characters. I kind of feel the
> > natural representation would be something like.
> >
> > led-7seg {
> > compatible = "generic,7-segment-on-gpio";
> > char-0 {
> > segment-gpios = <&gpio 0 GPIO_ACTIVE_LOW
> > &gpio 1 GPIO_ACTIVE_LOW
> > &gpio 2 GPIO_ACTIVE_LOW
> > &gpio 3 GPIO_ACTIVE_LOW
> > &gpio 4 GPIO_ACTIVE_LOW
> > &gpio 5 GPIO_ACTIVE_LOW
> > &gpio 6 GPIO_ACTIVE_LOW>;
> > };
> > char-1 {
> > segment-gpios = <&gpio 8 GPIO_ACTIVE_LOW
> > &gpio 9 GPIO_ACTIVE_LOW
> > &gpio 10 GPIO_ACTIVE_LOW
> > &gpio 11 GPIO_ACTIVE_LOW
> > &gpio 12 GPIO_ACTIVE_LOW
> > &gpio 13 GPIO_ACTIVE_LOW
> > &gpio 14 GPIO_ACTIVE_LOW>;
> > };
> > };
> >
> > But having those sub-nodes means I can't just use devm_gpiod_get_array()
> > instead I'd have to use device_for_each_child_node() and
> > devm_fwnode_gpiod_get_index(). Am I missing something? I could do away
> > with the sub-nodes and have properties like "segment-0-gpios",
> > "segment-1-gpios" but that feels awkward.
>
> One solution would be to treat separate digits as separata devices
> :-).

That's definitely an option, but would prevent you from having a
single display using auxdisplay/line-display.

> Other would be saying you don't have hardware for that, and make it
> someone else's future problem.

;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68korg

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds