The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/acpi_support/acpi_sony.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2004 Takanori Watanabe
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/8.4/sys/dev/acpi_support/acpi_sony.c 205262 2010-03-17 20:39:21Z gavin $");
   29 
   30 #include "opt_acpi.h"
   31 #include <sys/param.h>
   32 #include <sys/kernel.h>
   33 #include <sys/bus.h>
   34 
   35 #include <contrib/dev/acpica/include/acpi.h>
   36 
   37 #include "acpi_if.h"
   38 #include <sys/module.h>
   39 #include <dev/acpica/acpivar.h>
   40 #include <sys/sysctl.h>
   41 
   42 #define _COMPONENT      ACPI_OEM
   43 ACPI_MODULE_NAME("Sony")
   44 
   45 #define ACPI_SONY_GET_PID "GPID"
   46 
   47 /*
   48  * SNY5001
   49  *   This is the ACPI handle for the "Sony Notebook Control" driver under
   50  *   Windows.
   51  *   It provides several methods within the ACPI namespace, including:
   52  *  [GS]BRT [GS]PBR [GS]CTR [GS]PCR [GS]CMI [CDPW GCDP]? GWDP PWAK PWRN 
   53  *
   54  * SNY6001
   55  *   This is the ACPI handle for the "Sony Programmable I/O" driver under
   56  *   Windows.
   57  *   It is not yet supported by this driver, but provides control over the
   58  *   power to the bluetooth, built-in camera and HSDPA modem devices in some
   59  *   laptops, and also allows some control of the fan speed.
   60  */
   61 
   62 struct acpi_sony_softc {
   63         int pid;
   64 };
   65 static struct acpi_sony_name_list
   66 {
   67         char *nodename;
   68         char *getmethod;
   69         char *setmethod;
   70         char *comment;
   71 } acpi_sony_oids[] = {
   72         { "brightness", "GBRT", "SBRT", "Display Brightness"},
   73         { "brightness_default", "GPBR", "SPBR", "Default Display Brightness"},
   74         { "contrast", "GCTR", "SCTR", "Display Contrast"},
   75         { "bass_gain", "GMGB", "SMGB", "Multimedia Bass Gain"},
   76         { "pcr", "GPCR", "SPCR", "???"},
   77 #if 0
   78         { "cmi", "GCMI", "SCMI", "???"},
   79 #endif
   80         { "wdp", "GWDP", NULL, "???"},
   81         { "cdp", "GCDP", "CDPW", "CD Power"},  /*shares [\GL03]&0x8 flag*/
   82         { "azp", "GAZP", "AZPW", "Audio Power"}, 
   83         { "lnp", "GLNP", "LNPW", "LAN Power"},
   84         { NULL, NULL, NULL }
   85 };
   86 
   87 static int      acpi_sony_probe(device_t dev);
   88 static int      acpi_sony_attach(device_t dev);
   89 static int      acpi_sony_detach(device_t dev);
   90 static int      sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS);
   91 
   92 static device_method_t acpi_sony_methods[] = {
   93         /* Device interface */
   94         DEVMETHOD(device_probe, acpi_sony_probe),
   95         DEVMETHOD(device_attach, acpi_sony_attach),
   96         DEVMETHOD(device_detach, acpi_sony_detach),
   97 
   98         {0, 0}
   99 };
  100 
  101 static driver_t acpi_sony_driver = {
  102         "acpi_sony",
  103         acpi_sony_methods,
  104         sizeof(struct acpi_sony_softc),
  105 };
  106 
  107 static devclass_t acpi_sony_devclass;
  108 
  109 DRIVER_MODULE(acpi_sony, acpi, acpi_sony_driver, acpi_sony_devclass,
  110               0, 0);
  111 MODULE_DEPEND(acpi_sony, acpi, 1, 1, 1);
  112 static char    *sny_id[] = {"SNY5001", NULL};
  113 
  114 static int
  115 acpi_sony_probe(device_t dev)
  116 {
  117         int ret = ENXIO;
  118 
  119         if (ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id)) {
  120                 device_set_desc(dev, "Sony notebook controller");
  121                 ret = 0;
  122         }
  123         return (ret);
  124 }
  125 
  126 static int
  127 acpi_sony_attach(device_t dev)
  128 {
  129         struct acpi_sony_softc *sc;
  130         int i;
  131 
  132         sc = device_get_softc(dev);
  133         acpi_GetInteger(acpi_get_handle(dev), ACPI_SONY_GET_PID, &sc->pid);
  134         device_printf(dev, "PID %x\n", sc->pid);
  135         for (i = 0 ; acpi_sony_oids[i].nodename != NULL; i++){
  136                 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
  137                     SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
  138                     i, acpi_sony_oids[i].nodename , CTLTYPE_INT |
  139                     ((acpi_sony_oids[i].setmethod)? CTLFLAG_RW: CTLFLAG_RD),
  140                     dev, i, sysctl_acpi_sony_gen_handler, "I",
  141                     acpi_sony_oids[i].comment);
  142         }
  143         return (0);
  144 }
  145 
  146 static int 
  147 acpi_sony_detach(device_t dev)
  148 {
  149         return (0);
  150 }
  151 
  152 #if 0
  153 static int
  154 acpi_sony_suspend(device_t dev)
  155 {
  156         struct acpi_sony_softc *sc = device_get_softc(dev);
  157         return (0);
  158 }
  159 
  160 static int
  161 acpi_sony_resume(device_t dev)
  162 {
  163         return (0);
  164 }
  165 #endif
  166 
  167 static int 
  168 sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS)
  169 {
  170         device_t        dev = arg1;
  171         int     function = oidp->oid_arg2;
  172         int             error = 0, val;
  173 
  174         acpi_GetInteger(acpi_get_handle(dev),
  175             acpi_sony_oids[function].getmethod, &val);
  176         error = sysctl_handle_int(oidp, &val, 0, req);
  177         if (error || !req->newptr || !acpi_sony_oids[function].setmethod)
  178                 return (error);
  179         acpi_SetInteger(acpi_get_handle(dev),
  180             acpi_sony_oids[function].setmethod, val);
  181         return (0);
  182 }

Cache object: ab3d769a931c95a96e59c8f57fa14d9a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.