Message ID | 20240301014203.2033844-1-chris.packham@alliedtelesis.co.nz |
---|---|
Headers | show |
Series | auxdisplay: 7 segment LED display | expand |
On Fri, Mar 01, 2024 at 02:42:00PM +1300, Chris Packham wrote: > Add a driver for a 7-segment LED display. At the moment only one > character is supported but it should be possible to expand this to > support more characters and/or 14-segment displays in the future. ... > + * Driver for a 7 segment LED display 7-segment ... > + * The GPIOs are wired to the 7 segments in a clockwise fashion starting from > + * the top. Not exactly. They can wire them as they wish, we just need to agree on the sequence of the segments in DT to be mapped to the 7-segment diagram. ... > + * -a- > + * | | > + * f b > + * | | > + * -g- > + * | | > + * e c > + * | | > + * -d- I would drop this as it's available in UAPI header... ... > +#include <linux/bitmap.h> > +#include <linux/container_of.h> > +#include <linux/errno.h> > +#include <linux/gpio/consumer.h> > +#include <linux/mod_devicetable.h> > +#include <linux/module.h> > +#include <linux/platform_device.h> > +#include <linux/types.h> > +#include <linux/workqueue.h> ...which you forgot to include here. ... > +static void seg_led_update(struct work_struct *work) > +{ > + struct seg_led_priv *priv = container_of(work, struct seg_led_priv, work.work); > + struct linedisp *linedisp = &priv->linedisp; > + struct linedisp_map *map = linedisp->map; > + DECLARE_BITMAP(values, 8); > + bitmap_zero(values, 8); Why do you need this zeroing? > + bitmap_set_value8(values, map_to_seg7(&map->map.seg7, linedisp->buf[0]), 0); > + > + gpiod_set_array_value_cansleep(priv->segment_gpios->ndescs, priv->segment_gpios->desc, > + priv->segment_gpios->info, values); > +}
On Fri, Mar 01, 2024 at 02:42:02PM +1300, Chris Packham wrote: > The Allied Telesis x530 products have a 7-segment LED display which is > used for node identification when the devices are stacked. Represent > this as a generic-gpio-7seg device. Isn't it called differently now? ... Will need an Ack from the respective maintainers.
On Fri, Mar 01, 2024 at 02:42:03PM +1300, Chris Packham wrote: > Use the dot on the 7-segment LED block to indicate USB access on the > x530. As I said, I'm not going to apply this even with Acks. The problem here as I see it is the future decision on how DP should behave like. If you put this into DT, we will to support this to the end of the platform. So, drop this from the next version. You may try afterwards to apply it via different routes (will be not my problem :-).
On Fri, Mar 01, 2024 at 02:41:59PM +1300, Chris Packham wrote: > This series adds a driver for a 7 segment LED display. > > I haven't had a chance to look at the gpio changes that'd be required to > have multiple characters as subnodes. I wanted to get the code that > addressed Andy and Rob's comments out before my weekend. Thank you for the update! Almost fine, one more iteration needed for some minor fixes.
Hi Andy, On Fri, Mar 1, 2024 at 7:24 PM Andy Shevchenko <andy@kernel.org> wrote: > On Fri, Mar 01, 2024 at 02:42:03PM +1300, Chris Packham wrote: > > Use the dot on the 7-segment LED block to indicate USB access on the > > x530. > > As I said, I'm not going to apply this even with Acks. I guess you should not apply any of the dts patches to the auxdisplay tree anyway? > The problem here as I see it is the future decision on how DP should > behave like. If you put this into DT, we will to support this to the end > of the platform. As there exist 7-seg displays (and wirings) with and without DP, the 7-seg driver and DT bindings should handle both cases. How to wire/use the DP LED is up to the hardware designer / DTS writer. I agree it's a thin boundary between hardware description and software policy, though. Is that your main concern? > So, drop this from the next version. You may try afterwards to apply it via > different routes (will be not my problem :-). Exactly ;-) Gr{oetje,eeting}s, Geert
On 2/03/24 07:18, Andy Shevchenko wrote: >> +static void seg_led_update(struct work_struct *work) >> +{ >> + struct seg_led_priv *priv = container_of(work, struct seg_led_priv,http://scanmail.trustwave.com/?c=20988&d=iZzi5b3S-TQCft9iEXDE69U9UtY0-7GANk9t1WkCxg&u=http%3a%2f%2fwork%2ework%29%3b >> + struct linedisp *linedisp = &priv->linedisp; >> + struct linedisp_map *map = linedisp->map; >> + DECLARE_BITMAP(values, 8); >> + bitmap_zero(values, 8); > Why do you need this zeroing? > >> + bitmap_set_value8(values, map_to_seg7(&map->map.seg7, linedisp->buf[0]), 0); >> + Without the zeroing above GCC complains about use of a potentially uninitialized variable here. I think because bitmap_set_value8() does &= and |=. >> + gpiod_set_array_value_cansleep(priv->segment_gpios->ndescs, priv->segment_gpios->desc, >> + priv->segment_gpios->info, values); >> +}
On 3/03/24 22:48, Geert Uytterhoeven wrote: > Hi Andy, > > On Fri, Mar 1, 2024 at 7:24 PM Andy Shevchenko <andy@kernel.org> wrote: >> On Fri, Mar 01, 2024 at 02:42:03PM +1300, Chris Packham wrote: >>> Use the dot on the 7-segment LED block to indicate USB access on the >>> x530. >> As I said, I'm not going to apply this even with Acks. I'll drop this one for the next round. > I guess you should not apply any of the dts patches to the > auxdisplay tree anyway? That's OK by me. I've just been including them so there is an in-tree user of the driver. It also shows how I've been testing things. I can send them via the ARM maintainers once the dust settles on the first two patches. > >> The problem here as I see it is the future decision on how DP should >> behave like. If you put this into DT, we will to support this to the end >> of the platform. > As there exist 7-seg displays (and wirings) with and without DP, > the 7-seg driver and DT bindings should handle both cases. How to > wire/use the DP LED is up to the hardware designer / DTS writer. > > I agree it's a thin boundary between hardware description and software > policy, though. Is that your main concern? In this specific case I'd justify the (ab)use of the DP LED on this product as an optimization so we don't have to find board space for a separate LED to indicate USB activity. I do have an idea for handling the DP for the more general case. Basically if 8 segment GPIOs are supplied we can use a slightly different segment map (map7plus1?) so that characters that are better represented as dots use that instead.
+Cc: Rasmus, Yury On Sun, Mar 3, 2024 at 9:58 PM Chris Packham <Chris.Packham@alliedtelesis.co.nz> wrote: > On 2/03/24 07:18, Andy Shevchenko wrote: ... > >> + DECLARE_BITMAP(values, 8); > >> + bitmap_zero(values, 8); > > Why do you need this zeroing? > > > >> + bitmap_set_value8(values, map_to_seg7(&map->map.seg7, linedisp->buf[0]), 0); > Without the zeroing above GCC complains about use of a potentially > uninitialized variable here. I think because bitmap_set_value8() does &= > and |=. Hmm... Rasmus, Yury, do we have any ideas how to get rid of this redundancy?
On Sun, Mar 3, 2024 at 11:48 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > On Fri, Mar 1, 2024 at 7:24 PM Andy Shevchenko <andy@kernel.org> wrote: > > On Fri, Mar 01, 2024 at 02:42:03PM +1300, Chris Packham wrote: > > > Use the dot on the 7-segment LED block to indicate USB access on the > > > x530. > > > > As I said, I'm not going to apply this even with Acks. > > I guess you should not apply any of the dts patches to the > auxdisplay tree anyway? I think it depends. If we got maintainers' Acks, etc, why not? If DT maintainers think otherwise, then no, we shouldn't. > > The problem here as I see it is the future decision on how DP should > > behave like. If you put this into DT, we will to support this to the end > > of the platform. > > As there exist 7-seg displays (and wirings) with and without DP, > the 7-seg driver and DT bindings should handle both cases. How to > wire/use the DP LED is up to the hardware designer / DTS writer. Right. But my personal statistics for now is: 100% has DP (out of about a dozen of different chip + LED combinations). What's yours? > I agree it's a thin boundary between hardware description and software > policy, though. Is that your main concern? I believe so. Because if we mark DP for use for something else, it makes it much harder to re-use it as dot/comma later on.
On Sun, Mar 03, 2024 at 10:35:03PM +0200, Andy Shevchenko wrote: > +Cc: Rasmus, Yury > > On Sun, Mar 3, 2024 at 9:58 PM Chris Packham > <Chris.Packham@alliedtelesis.co.nz> wrote: > > On 2/03/24 07:18, Andy Shevchenko wrote: > > ... > > > >> + DECLARE_BITMAP(values, 8); > > >> + bitmap_zero(values, 8); > > > Why do you need this zeroing? > > > > > >> + bitmap_set_value8(values, map_to_seg7(&map->map.seg7, linedisp->buf[0]), 0); > > > Without the zeroing above GCC complains about use of a potentially > > uninitialized variable here. I think because bitmap_set_value8() does &= > > and |=. > > Hmm... Rasmus, Yury, do we have any ideas how to get rid of this redundancy? DECLARE_BITMAP(values, 8) = { 0 };
On 2/03/24 07:18, Andy Shevchenko wrote: > I would drop this as it's available in UAPI header... > > ... > >> +#include <linux/bitmap.h> >> +#include <linux/container_of.h> >> +#include <linux/errno.h> >> +#include <linux/gpio/consumer.h> >> +#include <linux/mod_devicetable.h> >> +#include <linux/module.h> >> +#include <linux/platform_device.h> >> +#include <linux/types.h> >> +#include <linux/workqueue.h> > ...which you forgot to include here. > > ... Actually do I need to? I'm not using anything in map_to_7segment.h, that's all taken care of in the line-display code.
On 4/03/24 13:45, Chris Packham wrote: > > On 2/03/24 07:18, Andy Shevchenko wrote: >> I would drop this as it's available in UAPI header... >> >> ... >> >>> +#include <linux/bitmap.h> >>> +#include <linux/container_of.h> >>> +#include <linux/errno.h> >>> +#include <linux/gpio/consumer.h> >>> +#include <linux/mod_devicetable.h> >>> +#include <linux/module.h> >>> +#include <linux/platform_device.h> >>> +#include <linux/types.h> >>> +#include <linux/workqueue.h> >> ...which you forgot to include here. >> >> ... > Actually do I need to? I'm not using anything in map_to_7segment.h, > that's all taken care of in the line-display code. Oops no I still need it for map_to_seg7().
Hi Andy, On Sun, Mar 3, 2024 at 9:43 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Sun, Mar 3, 2024 at 11:48 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > On Fri, Mar 1, 2024 at 7:24 PM Andy Shevchenko <andy@kernel.org> wrote: > > > The problem here as I see it is the future decision on how DP should > > > behave like. If you put this into DT, we will to support this to the end > > > of the platform. > > > > As there exist 7-seg displays (and wirings) with and without DP, > > the 7-seg driver and DT bindings should handle both cases. How to > > wire/use the DP LED is up to the hardware designer / DTS writer. > > Right. But my personal statistics for now is: 100% has DP (out of > about a dozen of different chip + LED combinations). What's yours? It's indeed hard to find contemporary 7-segment LED assemblies that lack the DP. But they do exist[1]. There's also no guarantee that the DP is wired. And don't forget custom or home-built assemblies using discrete LEDs, especially for huge displays (e.g. using one LED-strip per segment). So IMHO it would be a bad idea to make the DP mandatory. [1] https://www.alibaba.com/product-detail/CC-CA-188-led-display-0_60626228913.html Gr{oetje,eeting}s, Geert
On Mon, Mar 4, 2024 at 11:57 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > On Sun, Mar 3, 2024 at 9:43 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: ... > So IMHO it would be a bad idea to make the DP mandatory. But I'm not talking about making it mandatory, I'm talking about the DP to be used as DP when it _is_ present and wired. If current platform wants to use DP for something else, I'm pretty much worried that this is the right thing to do.
Hi Andy, On Mon, Mar 4, 2024 at 7:17 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Mon, Mar 4, 2024 at 11:57 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > On Sun, Mar 3, 2024 at 9:43 PM Andy Shevchenko > > <andy.shevchenko@gmail.com> wrote: > > ... > > > So IMHO it would be a bad idea to make the DP mandatory. > > But I'm not talking about making it mandatory, I'm talking about the OK. > DP to be used as DP when it _is_ present and wired. If current > platform wants to use DP for something else, I'm pretty much worried > that this is the right thing to do. There is not much we can do about that. People can already model such displays as individual LEDs, too. And in some sense, the auxdisplay/linedisp driver for "generic-gpio-7seg" imposes a policy, too. What if people want to e.g. use 4 7-seg displays to show a continuously running snake? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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
On Mon, Mar 04, 2024 at 08:01:58PM +0100, Geert Uytterhoeven wrote: > On Mon, Mar 4, 2024 at 7:17 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: > > On Mon, Mar 4, 2024 at 11:57 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > > On Sun, Mar 3, 2024 at 9:43 PM Andy Shevchenko > > > <andy.shevchenko@gmail.com> wrote: ... > > > So IMHO it would be a bad idea to make the DP mandatory. > > > > But I'm not talking about making it mandatory, I'm talking about the > > OK. > > > DP to be used as DP when it _is_ present and wired. If current > > platform wants to use DP for something else, I'm pretty much worried > > that this is the right thing to do. > > There is not much we can do about that. People can already model > such displays as individual LEDs, too. > And in some sense, the auxdisplay/linedisp driver for > "generic-gpio-7seg" imposes a policy, too. Does it? It's exactly targeting very specific HW configuration. The only question here is DP. > What if people want to e.g. use 4 7-seg displays to show a continuously > running snake? We have an ABI to update a "character" mapping, so it's possible to do, but it is not a main purpose of line display library. Free running 7-segment display does probably belong to LED framework in that sense (as just represents a 7 LEDs that user configured in a specific way in the physical world). In such case it's just the 7 LEDs on a single PCB. If you consider these limits as "policy", okay, but it's _hardware driven_ one, and not software.