Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150488479
D21746.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D21746.diff
View Options
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -8,6 +8,7 @@
acpi.4 \
${_acpi_asus.4} \
${_acpi_asus_wmi.4} \
+ ${_acpi_cros_kblt.4} \
${_acpi_cros_tbmc.4} \
${_acpi_dock.4} \
${_acpi_fujitsu.4} \
@@ -776,6 +777,7 @@
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
_acpi_asus.4= acpi_asus.4
_acpi_asus_wmi.4= acpi_asus_wmi.4
+_acpi_cros_kblt.4= acpi_cros_kblt.4
_acpi_cros_tbmc.4= acpi_cros_tbmc.4
_acpi_dock.4= acpi_dock.4
_acpi_fujitsu.4=acpi_fujitsu.4
diff --git a/share/man/man4/acpi_cros_kblt.4 b/share/man/man4/acpi_cros_kblt.4
new file mode 100644
--- /dev/null
+++ b/share/man/man4/acpi_cros_kblt.4
@@ -0,0 +1,68 @@
+.\" Copyright (c) 2023 Val Packett
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd February 4, 2023
+.Dt ACPI_CROS_KBLT 4
+.Os
+.Sh NAME
+.Nm acpi_cros_kblt
+.Nd "ACPI keyboard backlight driver for Chromebooks"
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following lines in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device acpi_cros_kblt"
+.Cd "device backlight"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+acpi_cros_kblt_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for keyboard backlight control for ChromeOS laptops.
+.Pp
+The
+.Pa /dev/backlight/backlightX
+device presents the keyboard to the
+.Xr backlight 8
+utility.
+.Sh SEE ALSO
+.Xr acpi 4 ,
+.Xr backlight 8
+.Sh HISTORY
+The
+.Nm
+device driver first appeared in
+.Fx 14.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Val Packett Aq Mt val@packett.cool
diff --git a/sys/conf/files b/sys/conf/files
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -784,6 +784,7 @@
dev/acpi_support/acpi_wmi.c optional acpi_wmi acpi
dev/acpi_support/acpi_asus.c optional acpi_asus acpi
dev/acpi_support/acpi_asus_wmi.c optional acpi_asus_wmi acpi
+dev/acpi_support/acpi_cros_kblt.c optional acpi_cros_kblt acpi
dev/acpi_support/acpi_cros_tbmc.c optional acpi_cros_tbmc acpi
dev/acpi_support/acpi_fujitsu.c optional acpi_fujitsu acpi
dev/acpi_support/acpi_hp.c optional acpi_hp acpi
diff --git a/sys/dev/acpi_support/acpi_cros_kblt.c b/sys/dev/acpi_support/acpi_cros_kblt.c
new file mode 100644
--- /dev/null
+++ b/sys/dev/acpi_support/acpi_cros_kblt.c
@@ -0,0 +1,174 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Val Packett <val@packett.cool>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "opt_acpi.h"
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <machine/cpufunc.h>
+
+#include <dev/backlight/backlight.h>
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+#include "acpi_if.h"
+#include "backlight_if.h"
+#include <sys/module.h>
+#include <dev/acpica/acpivar.h>
+
+ACPI_MODULE_NAME("CROS_KBLT")
+
+struct acpi_cros_kblt_softc {
+ device_t dev;
+ ACPI_HANDLE handle;
+ int val;
+
+ struct cdev *cdev;
+};
+
+static int
+acpi_cros_kblt_resume(device_t dev)
+{
+ struct acpi_cros_kblt_softc *sc = device_get_softc(dev);
+
+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+ if (ACPI_FAILURE(acpi_SetInteger(sc->handle, "KBCM", sc->val))) {
+ device_printf(sc->dev, "'KBCM' ACPI method failed\n");
+ return (ENXIO);
+ }
+
+ return (0);
+}
+
+static char *cros_kblt_ids[] = {"GOOG0002", NULL};
+
+static int
+acpi_cros_kblt_probe(device_t dev)
+{
+ int err;
+
+ if (acpi_disabled("cros_kblt") ||
+ device_get_unit(dev) != 0)
+ return (ENXIO);
+
+ err = ACPI_ID_PROBE(device_get_parent(dev), dev, cros_kblt_ids, NULL);
+
+ if (err <= 0)
+ device_set_desc(dev, "Chromebook Keyboard Backlight Control");
+
+ return (err);
+}
+
+static int
+acpi_cros_kblt_attach(device_t dev)
+{
+ struct acpi_cros_kblt_softc *sc = device_get_softc(dev);
+
+ sc->dev = dev;
+ sc->handle = acpi_get_handle(dev);
+
+ if (ACPI_FAILURE(acpi_GetInteger(sc->handle, "KBQC", &sc->val))) {
+ device_printf(sc->dev, "'KBQC' ACPI method failed\n");
+ return (ENXIO);
+ }
+
+ sc->cdev = backlight_register("acpi_cros_kblt", dev);
+ if (sc->cdev == NULL)
+ device_printf(dev, "Cannot register as a backlight\n");
+
+ return (0);
+}
+
+static int
+acpi_cros_kblt_update_status(device_t dev, struct backlight_props *props)
+{
+ struct acpi_cros_kblt_softc *sc = device_get_softc(dev);
+ sc->val = props->brightness;
+
+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+ if (ACPI_FAILURE(acpi_SetInteger(sc->handle, "KBCM", sc->val))) {
+ device_printf(sc->dev, "'KBCM' ACPI method failed\n");
+ return (ENXIO);
+ }
+
+ return (0);
+}
+
+static int
+acpi_cros_kblt_get_status(device_t dev, struct backlight_props *props)
+{
+ struct acpi_cros_kblt_softc *sc = device_get_softc(dev);
+
+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+ if (ACPI_FAILURE(acpi_GetInteger(sc->handle, "KBQC", &sc->val))) {
+ device_printf(sc->dev, "'KBQC' ACPI method failed\n");
+ return (ENXIO);
+ }
+
+ props->brightness = sc->val;
+ props->nlevels = 0;
+
+ return (0);
+}
+
+static int
+acpi_cros_kblt_get_info(device_t dev, struct backlight_info *info)
+{
+ info->type = BACKLIGHT_TYPE_KEYBOARD;
+ strlcpy(info->name, "Chromebook Keyboard", BACKLIGHTMAXNAMELENGTH);
+
+ return (0);
+}
+
+static device_method_t acpi_cros_kblt_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, acpi_cros_kblt_probe),
+ DEVMETHOD(device_attach, acpi_cros_kblt_attach),
+ DEVMETHOD(device_resume, acpi_cros_kblt_resume),
+
+ /* Backlight interface */
+ DEVMETHOD(backlight_update_status, acpi_cros_kblt_update_status),
+ DEVMETHOD(backlight_get_status, acpi_cros_kblt_get_status),
+ DEVMETHOD(backlight_get_info, acpi_cros_kblt_get_info),
+
+ DEVMETHOD_END
+};
+
+static driver_t acpi_cros_kblt_driver = {
+ "acpi_cros_kblt",
+ acpi_cros_kblt_methods,
+ sizeof(struct acpi_cros_kblt_softc),
+};
+
+DRIVER_MODULE(acpi_cros_kblt, acpi, acpi_cros_kblt_driver, 0, 0);
+MODULE_DEPEND(acpi_cros_kblt, acpi, 1, 1, 1);
diff --git a/sys/modules/acpi/Makefile b/sys/modules/acpi/Makefile
--- a/sys/modules/acpi/Makefile
+++ b/sys/modules/acpi/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
-SUBDIR= acpi_asus acpi_asus_wmi acpi_cros_tbmc acpi_dock acpi_fujitsu acpi_hp \
+SUBDIR= acpi_asus acpi_asus_wmi acpi_cros_kblt acpi_cros_tbmc \
+ acpi_dock acpi_fujitsu acpi_hp \
acpi_ged acpi_ibm acpi_panasonic acpi_sony acpi_toshiba \
acpi_video acpi_wmi aibs
diff --git a/sys/modules/acpi/acpi_cros_kblt/Makefile b/sys/modules/acpi/acpi_cros_kblt/Makefile
new file mode 100644
--- /dev/null
+++ b/sys/modules/acpi/acpi_cros_kblt/Makefile
@@ -0,0 +1,5 @@
+.PATH: ${SRCTOP}/sys/dev/acpi_support
+KMOD= acpi_cros_kblt
+SRCS= acpi_cros_kblt.c opt_acpi.h device_if.h bus_if.h acpi_if.h backlight_if.h
+
+.include <bsd.kmod.mk>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 2, 4:00 PM (9 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30728718
Default Alt Text
D21746.diff (9 KB)
Attached To
Mode
D21746: acpi_cros_kblt: New driver for Chromebook keyboard backlight control
Attached
Detach File
Event Timeline
Log In to Comment