summaryrefslogtreecommitdiffstats
path: root/drivers/auxdisplay/ht16k33.c
Commit message (Collapse)AuthorAgeFilesLines
* auxdisplay: ht16k33: remove superfluous header filesMianhan Liu2021-10-221-1/+0
| | | | | | | | | | | ht16k33.c doesn't use any macro or function declared in linux/slab.h. Thus, these files can be removed from ht16k33.c safely without affecting the compilation. Signed-off-by: Mianhan Liu <liumh1@shanghaitech.edu.cn> Acked-by: Robin van der Gracht <robin@protonic.nl> [reworded] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Make use of device propertiesGeert Uytterhoeven2021-10-211-15/+12
| | | | | | | | | | | | The device property API allows drivers to gather device resources from different sources, such as ACPI, and lift the dependency on Device Tree. Convert the driver to unleash the power of the device property API. Suggested-by: Marek BehĂșn <kabel@kernel.org> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Add LED supportGeert Uytterhoeven2021-10-211-16/+110
| | | | | | | | | | | | | | | | | Instantiate a single LED based on the "led" subnode in DT. This allows the user to control display brightness and blinking (backed by hardware support) through the LED class API and triggers, and exposes the display color. The LED will be named "auxdisplay:<color>:<function>". When running in dot-matrix mode and if no "led" subnode is found, the driver falls back to the traditional backlight mode, to preserve backwards compatibility. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Marek BehĂșn <kabel@kernel.org> Reviewed-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Add support for segment displaysGeert Uytterhoeven2021-10-211-7/+189
| | | | | | | | | | | | | | The Holtek HT16K33 LED controller is not only used for driving dot-matrix displays, but also for driving segment displays. Add support for 4-digit 7-segment and quad 14-segment alphanumeric displays, like the Adafruit 7-segment and 14-segment display backpack and FeatherWing expansion boards. Use the character line display core support to display a message, which will be scrolled if it doesn't fit. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Extract frame buffer probingGeert Uytterhoeven2021-10-211-48/+53
| | | | | | | | | | | | Extract all frame buffer (including backlight) probing into ht16k33_fbdev_probe(). Call ht16k33_fbdev_probe() after ht16k33_keypad_probe(), as the latter does not need any manual cleanup in the probe error path. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Extract ht16k33_brightness_set()Geert Uytterhoeven2021-10-211-6/+19
| | | | | | | | | Extract brightness handling into a helper function, so it can be called from multiple places. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Move delayed workGeert Uytterhoeven2021-10-211-8/+7
| | | | | | | | | Move delayed_work from ht16k33_fbdev to ht16k33_priv, as it is not specific to dot-matrix displays, but common to all display types. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Add helper variable devGeert Uytterhoeven2021-10-211-21/+22
| | | | | | | | | This driver has many users of "client->dev". Add shorthands to simplify the code. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Convert to simple i2c probe functionGeert Uytterhoeven2021-10-211-3/+2
| | | | | | | | | ht16k33_probe() does not use the passed i2c_device_id, so the driver can be converted trivially to the new-style of i2c probing. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Remove unneeded error check in keypad probe()Geert Uytterhoeven2021-10-211-5/+1
| | | | | | | | | There is no need to check the return code of input_register_device(), just propagate it to the caller. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Use HT16K33_FB_SIZE in ht16k33_initialize()Geert Uytterhoeven2021-10-211-1/+1
| | | | | | | | | | Use the existing HT16K33_FB_SIZE definition instead of open-coding the same calculation using an hardcoded value. While at it, restore reverse Christmas tree variable declaration order. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Fix frame buffer device blankingGeert Uytterhoeven2021-10-211-0/+10
| | | | | | | | | | | | | | | | | As the ht16k33 frame buffer sub-driver does not register an fb_ops.fb_blank() handler, blanking does not work: $ echo 1 > /sys/class/graphics/fb0/blank sh: write error: Invalid argument Fix this by providing a handler that always returns zero, to make sure blank events will be sent to the actual device handling the backlight. Reported-by: Robin van der Gracht <robin@protonic.nl> Suggested-by: Robin van der Gracht <robin@protonic.nl> Fixes: 8992da44c6805d53 ("auxdisplay: ht16k33: Driver for LED controller") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Connect backlight to fbdevGeert Uytterhoeven2021-10-211-28/+28
| | | | | | | | | | | | Currently /sys/class/graphics/fb0/bl_curve is not accessible (-ENODEV), as the driver does not connect the backlight to the frame buffer device. Fix this moving backlight initialization up, and filling in fb_info.bl_dev. Fixes: 8992da44c6805d53 ("auxdisplay: ht16k33: Driver for LED controller") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: ht16k33: Fix refresh rate handlingGeert Uytterhoeven2021-01-251-2/+1
| | | | | | | | | Drop the call to msecs_to_jiffies(), as "HZ / fbdev->refresh_rate" is already the number of jiffies to wait. Fixes: 8992da44c6805d53 ("auxdisplay: ht16k33: Driver for LED controller") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* dt-bindings: auxdisplay: ht16k33: Keyscan function should be optionalRobin van der Gracht2021-01-251-8/+6
| | | | | | | | | | | | Keyscan should be optional to support simple LED matrix displays (output only). Reported-by: Michael Kaplan <M.KAPLAN@evva.com> Signed-off-by: Robin van der Gracht <robin@protonic.nl> [geert: Rebased] Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
* auxdisplay: constify fb opsJani Nikula2019-12-111-1/+1
| | | | | | | | | | | | | Now that the fbops member of struct fb_info is const, we can start making the ops const as well. Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com> Cc: Robin van der Gracht <robin@protonic.nl> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/31c18e3ce9d6962aabda4799b3051039ff591c92.1575390741.git.jani.nikula@intel.com
* auxdisplay: ht16k33: Make ht16k33_fb_fix and ht16k33_fb_var constantNishka Dasgupta2019-08-201-2/+2
| | | | | | | | | | | | | The static structures ht16k33_fb_fix and ht16k33_fb_var, of types fb_fix_screeninfo and fb_var_screeninfo respectively, are not used except to be copied into other variables. Hence make both of them constant to prevent unintended modification. Issue found with Coccinelle. Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
* auxdisplay/ht16k33.c: Convert to use vm_map_pages_zero()Souptick Joarder2019-06-201-2/+2
| | | | | | | | | | | | | | | While using mmap, the incorrect values of length and vm_pgoff are ignored and this driver goes ahead with mapping fbdev.buffer to user vma. Convert vm_insert_pages() to use vm_map_pages_zero(). We could later "fix" these drivers to behave according to the normal vm_pgoff offsetting simply by removing the _zero suffix on the function name and if that causes regressions, it gives us an easy way to revert. Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
* auxdisplay: ht16k33: fix potential user-after-free on module unloadMiguel Ojeda2019-02-151-1/+1
| | | | | | | | | | | | | | | | | | | On module unload/remove, we need to ensure that work does not run after we have freed resources. Concretely, cancel_delayed_work() may return while the callback function is still running. From kernel/workqueue.c: The work callback function may still be running on return, unless it returns true and the work doesn't re-arm itself. Explicitly flush or use cancel_delayed_work_sync() to wait on it. Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/ Reported-by: Sven Van Asbroeck <thesven73@gmail.com> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com> Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
* auxdisplay: Replace licenses with SPDX identifiersMiguel Ojeda2018-04-121-9/+1
| | | | | | | | | Cc: Philippe Ombredanne <pombredanne@nexb.com> Acked-by: Willy Tarreau <w@1wt.eu> Acked-by: Linus Walleij <triad@dflund.se> Acked-by: Robin van der Gracht <robin@protonic.nl> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
* auxdisplay: ht16k33: use le16_to_cpup() to fetch LE16 dataDmitry Torokhov2017-04-081-4/+8
| | | | | | | | | | The data read from the device is 3 little-endian words, so let's annotate them as such and use le16_to_cpu() to convert them to host endianness - it might turn out to be a bit more performant, and it expresses the conversion more clearly. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* auxdisplay: ht16k33: don't access uninitialized dataArnd Bergmann2017-04-081-1/+7
| | | | | | | | | | | | | | | | | | | | gcc-7.0.1 points out that we copy uninitialized data from the stack into a per-device structure: drivers/auxdisplay/ht16k33.c: In function 'ht16k33_keypad_irq_thread': arch/x86/include/asm/string_32.h:78:16: error: 'new_state' may be used uninitialized in this function [-Werror=maybe-uninitialized] arch/x86/include/asm/string_32.h:79:22: error: '*((void *)&new_state+4)' may be used uninitialized in this function [-Werror=maybe-uninitialized] The access is harmless because we never read the data, but we are better off not doing this, so this changes the code to only copy the data that was actually initialized. To make sure we don't overflow the stack with an incorrect DT, we also need to add a sanity checkin the probe function. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Robin van der Gracht <robin@protonic.nl> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* auxdisplay: ht16k33: remove private workqueueDmitry Torokhov2017-02-101-15/+5
| | | | | | | | | | There is no need for the driver to use private workqueue, standard system workqueue should suffice as they are going to use the same worker pool anyway. Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* auxdisplay: ht16k33: rework input device initializationDmitry Torokhov2017-02-101-153/+145
| | | | | | | | | | | | | | | | | | | | This patch fixes following issues in input device (keypad) handling: - requesting IRQ before allocating and initializing parts of the device that can be referenced from IRQ handler is racy, even if we try to disable interrupt after requesting it. Let's move allocations around so that everything is ready by the time we request IRQ. - using threaded interrupt handler to schedule a work item it sub-optimal. Disabling and then re-enabling interrupts in work item and in open/close methods is prone to races and exactly the reason theraded interrupts were introduced. Let's use the infrastructure properly and keep scanning the matrix array in IRQ thread, stopping when there are no keys, or when told to do so. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* auxdisplay: ht16k33: do not try to free fbdevDmitry Torokhov2017-02-101-3/+1
| | | | | | | | | 'fbdev' is allocated as part of larger ht16k33_priv structure; trying to free it will cause troubles. Acked-by: Robin van der Gracht <robin@protonic.nl> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* auxdisplay: ht16k33: Driver for LED controllerRobin van der Gracht2016-11-101-0/+563
Added a driver for the Holtek HT16K33 LED controller with keyscan. Signed-off-by: Robin van der Gracht <robin@protonic.nl> CC: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>