Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/fdt If the backlight node does not have an enable gp...



details:   https://anonhg.NetBSD.org/src/rev/7f6441bdb86b
branches:  trunk
changeset: 968157:7f6441bdb86b
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jan 04 12:09:54 2020 +0000

description:
If the backlight node does not have an enable gpio, set the lowest duty
cycle to turn the display off instead.

diffstat:

 sys/dev/fdt/pwm_backlight.c |  29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diffs (89 lines):

diff -r 03d17becba68 -r 7f6441bdb86b sys/dev/fdt/pwm_backlight.c
--- a/sys/dev/fdt/pwm_backlight.c       Sat Jan 04 12:08:32 2020 +0000
+++ b/sys/dev/fdt/pwm_backlight.c       Sat Jan 04 12:09:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pwm_backlight.c,v 1.5 2020/01/01 12:55:03 jmcneill Exp $ */
+/* $NetBSD: pwm_backlight.c,v 1.6 2020/01/04 12:09:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.5 2020/01/01 12:55:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pwm_backlight.c,v 1.6 2020/01/04 12:09:54 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -48,6 +48,7 @@
 
        u_int                   *sc_levels;
        u_int                   sc_nlevels;
+       u_int                   sc_curlevel;
 
        char                    *sc_levelstr;
 
@@ -131,6 +132,8 @@
                pwm_backlight_set(sc, default_level);
        }
 
+       sc->sc_curlevel = pwm_backlight_get(sc);
+
        pwm_backlight_sysctl_init(sc);
        pwm_backlight_pmf_init(sc);
 }
@@ -247,12 +250,21 @@
 }
 
 static void
+pwm_backlight_enable(struct pwm_backlight_softc *sc, int enable)
+{
+       if (sc->sc_pin)
+               fdtbus_gpio_write(sc->sc_pin, enable);
+       else
+               pwm_backlight_set(sc, enable ? sc->sc_curlevel : 0);
+}
+
+static void
 pwm_backlight_display_on(device_t dev)
 {
        struct pwm_backlight_softc * const sc = device_private(dev);
 
-       if (sc->sc_pin && sc->sc_lid_state)
-               fdtbus_gpio_write(sc->sc_pin, 1);
+       if (sc->sc_lid_state)
+               pwm_backlight_enable(sc, 1);
 }
 
 static void
@@ -260,8 +272,7 @@
 {
        struct pwm_backlight_softc * const sc = device_private(dev);
 
-       if (sc->sc_pin)
-               fdtbus_gpio_write(sc->sc_pin, 0);
+       pwm_backlight_enable(sc, 0);
 }
 
 static void
@@ -271,8 +282,7 @@
 
        sc->sc_lid_state = true;
 
-       if (sc->sc_pin)
-               fdtbus_gpio_write(sc->sc_pin, 1);
+       pwm_backlight_enable(sc, 1);
 }
 
 static void
@@ -282,8 +292,7 @@
 
        sc->sc_lid_state = false;
 
-       if (sc->sc_pin)
-               fdtbus_gpio_write(sc->sc_pin, 0);
+       pwm_backlight_enable(sc, 0);
 }
 
 static void



Home | Main Index | Thread Index | Old Index