FreeBSD Bugzilla – Attachment 179379 Details for
Bug 216552
[new driver] acpi_asus_als: driver for the ambient light sensor on ASUS laptops
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
add man page for the driver
acpi_asus_als.patch (text/plain), 11.16 KB, created by
Henry Hu
on 2017-01-28 18:12:01 UTC
(
hide
)
Description:
add man page for the driver
Filename:
MIME Type:
Creator:
Henry Hu
Created:
2017-01-28 18:12:01 UTC
Size:
11.16 KB
patch
obsolete
>Index: share/man/man4/Makefile >=================================================================== >--- share/man/man4/Makefile (revision 311464) >+++ share/man/man4/Makefile (working copy) >@@ -9,6 +9,7 @@ > aacraid.4 \ > acpi.4 \ > ${_acpi_asus.4} \ >+ ${_acpi_asus_als.4} \ > ${_acpi_asus_wmi.4} \ > ${_acpi_dock.4} \ > ${_acpi_fujitsu.4} \ >@@ -757,6 +758,7 @@ > > .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" > _acpi_asus.4= acpi_asus.4 >+_acpi_asus_als.4= acpi_asus_als.4 > _acpi_asus_wmi.4= acpi_asus_wmi.4 > _acpi_dock.4= acpi_dock.4 > _acpi_fujitsu.4=acpi_fujitsu.4 >Index: share/man/man4/acpi_asus_als.4 >=================================================================== >--- share/man/man4/acpi_asus_als.4 (nonexistent) >+++ share/man/man4/acpi_asus_als.4 (working copy) >@@ -0,0 +1,93 @@ >+.\" >+.\" Copyright (c) 2017 Henry Hu <henry.hu.sh@gmail.com> >+.\" All rights reserved. >+.\" >+.\" 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. >+.\" >+.\" $FreeBSD$ >+.\" >+.Dd January 28, 2017 >+.Dt ACPI_ASUS_ALS 4 >+.Os >+.Sh NAME >+.Nm acpi_asus_als >+.Nd Asus Ambient Light Sensor >+.Sh SYNOPSIS >+To compile this driver into the kernel, >+place the following line in your >+kernel configuration file: >+.Bd -ragged -offset indent >+.Cd "device acpi_asus_als" >+.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_asus_als_load="YES" >+.Ed >+.Sh DESCRIPTION >+The >+.Nm >+driver provides support for the ambient light sensor found on recent Asus >+laptops. >+It allows one to use the >+.Xr sysctl 8 >+interface to get the ambient light value from the sensor. >+The sensor can be controlled through a WMI call. See >+.Xr acpi_asus_wmi 4 >+for details. >+.Sh SYSCTL VARIABLES >+The following sysctls are currently implemented: >+.Bl -tag -width indent >+.It Va hw.acpi.asus_als.light >+The ambient light value, in 0.01 lux. >+.Sh SEE ALSO >+.Xr acpi 4 , >+.Xr acpi_asus 4 , >+.Xr acpi_asus_wmi 4 , >+.Xr sysctl 8 >+.Rs >+.%T Asus Zenbook Ambient Light Sensor Driver >+.%U https://github.com/victorenator/als >+.Re >+.Sh HISTORY >+The >+.Nm >+driver first appeared in >+.Fx 12 . >+.Sh AUTHORS >+.An -nosplit >+The >+.Nm >+driver and this manual page were written by >+.An Henry Hu Aq Mt henry.hu.sh@gmail.com . >+.Pp >+Inspiration came from the >+.Em Asus Zenbook Ambient Light Sensor Driver >+started by >+.An Viktar VaÅÄkieviÄ >+which maintains a driver implementing this >+functionality as a >+.Tn Linux >+module. >+ > >Property changes on: share/man/man4/acpi_asus_als.4 >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:keywords >## -0,0 +1 ## >+FreeBSD=%H >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Index: sys/dev/acpi_support/acpi_asus_als.c >=================================================================== >--- sys/dev/acpi_support/acpi_asus_als.c (nonexistent) >+++ sys/dev/acpi_support/acpi_asus_als.c (working copy) >@@ -0,0 +1,203 @@ >+/*- >+ * Copyright (c) 2017 Henry Hu <henry.hu.sh@gmail.com> >+ * All rights reserved. >+ * >+ * 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 <sys/cdefs.h> >+__FBSDID("$FreeBSD$"); >+ >+/* >+ * Driver for the ambient light sensor found on recent Asus laptops. Inspired >+ * by the als project which implements the same functionality for Linux. >+ * >+ * <https://github.com/victorenator/als> >+ * >+ * May also work on other laptops. >+ */ >+ >+#include "opt_acpi.h" >+#include <sys/param.h> >+#include <sys/kernel.h> >+#include <sys/module.h> >+#include <sys/bus.h> >+ >+#include <contrib/dev/acpica/include/acpi.h> >+#include <contrib/dev/acpica/include/accommon.h> >+ >+#include <dev/acpica/acpivar.h> >+ >+#define _COMPONENT ACPI_OEM >+ACPI_MODULE_NAME("ASUS-ALS") >+ >+struct acpi_asus_als_softc { >+ device_t dev; >+ ACPI_HANDLE handle; >+ >+ struct sysctl_ctx_list sysctl_ctx; >+ struct sysctl_oid *sysctl_tree; >+}; >+ >+ACPI_SERIAL_DECL(asus_als, "ACPI ASUS ambient light"); >+ >+static int acpi_asus_als_probe(device_t dev); >+static int acpi_asus_als_attach(device_t dev); >+static int acpi_asus_als_detach(device_t dev); >+ >+static int acpi_asus_als_sysctl(SYSCTL_HANDLER_ARGS); >+static int acpi_asus_als_sysctl_get(struct acpi_asus_als_softc *sc); >+ >+static device_method_t acpi_asus_als_methods[] = { >+ DEVMETHOD(device_probe, acpi_asus_als_probe), >+ DEVMETHOD(device_attach, acpi_asus_als_attach), >+ DEVMETHOD(device_detach, acpi_asus_als_detach), >+ >+ { 0, 0 } >+}; >+ >+static driver_t acpi_asus_als_driver = { >+ "acpi_asus_als", >+ acpi_asus_als_methods, >+ sizeof(struct acpi_asus_als_softc) >+}; >+ >+static devclass_t acpi_asus_als_devclass; >+ >+DRIVER_MODULE(acpi_asus_als, acpi, acpi_asus_als_driver, >+ acpi_asus_als_devclass, 0, 0); >+MODULE_DEPEND(acpi_asus_als, acpi, 1, 1, 1); >+ >+static int >+acpi_asus_als_probe(device_t dev) >+{ >+ static char *asus_ids[] = { "ACPI0008", NULL }; >+ >+ struct acpi_asus_als_softc *sc; >+ char *rstr; >+ >+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >+ >+ if (acpi_disabled("asus_als")) >+ return (ENXIO); >+ >+ /* Check if ambient light sensor is present. */ >+ rstr = ACPI_ID_PROBE(device_get_parent(dev), dev, asus_ids); >+ if (rstr == NULL) { >+ return (ENXIO); >+ } >+ >+ sc = device_get_softc(dev); >+ sc->dev = dev; >+ sc->handle = acpi_get_handle(dev); >+ >+ device_set_desc_copy(dev, "ASUS ambient light sensor"); >+ >+ return 0; >+} >+ >+static int >+acpi_asus_als_attach(device_t dev) >+{ >+ struct acpi_asus_als_softc *sc; >+ struct acpi_softc *acpi_sc; >+ >+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >+ >+ sc = device_get_softc(dev); >+ acpi_sc = acpi_device_get_parent_softc(dev); >+ >+ sysctl_ctx_init(&sc->sysctl_ctx); >+ sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, >+ SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), >+ OID_AUTO, "asus_als", CTLFLAG_RD, 0, ""); >+ >+ SYSCTL_ADD_PROC(&sc->sysctl_ctx, >+ SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, >+ "light", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_ANYBODY, >+ sc, 0, acpi_asus_als_sysctl, "I", "Ambient light value"); >+ >+ return (0); >+} >+ >+static int >+acpi_asus_als_detach(device_t dev) >+{ >+ struct acpi_asus_als_softc *sc; >+ >+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >+ >+ sc = device_get_softc(dev); >+ >+ sysctl_ctx_free(&sc->sysctl_ctx); >+ >+ return (0); >+} >+ >+static int >+acpi_asus_als_sysctl(SYSCTL_HANDLER_ARGS) >+{ >+ struct acpi_asus_als_softc *sc; >+ int value; >+ int error = 0; >+ >+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >+ >+ sc = (struct acpi_asus_als_softc *)oidp->oid_arg1; >+ >+ ACPI_SERIAL_BEGIN(asus_als); >+ >+ value = acpi_asus_als_sysctl_get(sc); >+ error = sysctl_handle_int(oidp, &value, 0, req); >+ >+ ACPI_SERIAL_END(asus_als); >+ >+ return (error); >+} >+ >+static int >+acpi_asus_als_sysctl_get(struct acpi_asus_als_softc *sc) >+{ >+ ACPI_BUFFER Buf; >+ ACPI_OBJECT *Obj; >+ int value = 0; >+ >+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >+ ACPI_SERIAL_ASSERT(asus_als); >+ >+ Buf.Pointer = NULL; >+ Buf.Length = ACPI_ALLOCATE_BUFFER; >+ >+ /* Calls _ALI to get the value. */ >+ AcpiEvaluateObject(sc->handle, "_ALI", NULL, &Buf); >+ Obj = Buf.Pointer; >+ >+ if (Obj->Type != ACPI_TYPE_INTEGER) { >+ device_printf(sc->dev, "_ALI returned non-integer\n"); >+ } else { >+ value = Obj->Integer.Value; >+ } >+ >+ AcpiOsFree(Buf.Pointer); >+ >+ return (value); >+} > >Property changes on: sys/dev/acpi_support/acpi_asus_als.c >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:keywords >## -0,0 +1 ## >+FreeBSD=%H >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Index: sys/modules/acpi/Makefile >=================================================================== >--- sys/modules/acpi/Makefile (revision 312929) >+++ sys/modules/acpi/Makefile (working copy) >@@ -2,6 +2,6 @@ > > SUBDIR= acpi_asus acpi_asus_wmi acpi_dock acpi_fujitsu acpi_hp \ > acpi_ibm acpi_panasonic acpi_sony acpi_toshiba \ >- acpi_video acpi_wmi aibs >+ acpi_video acpi_wmi aibs acpi_asus_als > > .include <bsd.subdir.mk> >Index: sys/modules/acpi/acpi_asus_als/Makefile >=================================================================== >--- sys/modules/acpi/acpi_asus_als/Makefile (nonexistent) >+++ sys/modules/acpi/acpi_asus_als/Makefile (working copy) >@@ -0,0 +1,8 @@ >+# $FreeBSD$ >+ >+.PATH: ${.CURDIR}/../../../dev/acpi_support >+ >+KMOD= acpi_asus_als >+SRCS= acpi_asus_als.c opt_acpi.h acpi_if.h device_if.h bus_if.h >+ >+.include <bsd.kmod.mk> > >Property changes on: sys/modules/acpi/acpi_asus_als/Makefile >___________________________________________________________________ >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:keywords >## -0,0 +1 ## >+FreeBSD=%H >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 216552
:
179378
| 179379