/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
__KERNEL_RCSID(0, "$NetBSD: sony_acpi.c,v 1.24 2021/01/29 15:49:55 thorpej Exp $");
/*
* We assume that if the 'get' of the name as an integer is
* successful it is ok.
*/
if (acpi_eval_integer(sc->sc_node->ad_handle, buf, &acpi_val))
return AE_OK;
for (ptr = buf; *ptr; ptr++)
*ptr = tolower(*ptr);
aprint_naive(": Sony Miscellaneous Controller\n");
aprint_normal(": Sony Miscellaneous Controller\n");
sc->sc_node = aa->aa_node;
sc->sc_dev = self;
rv = AcpiWalkNamespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 100,
sony_acpi_find_pic, NULL, sc, NULL);
if (ACPI_FAILURE(rv))
aprint_error_dev(self, "couldn't walk namespace: %s\n",
AcpiFormatException(rv));
/*
* If we don't find an SNY6001 device, assume that we need the
* Fn key initialization sequence.
*/
if (sc->sc_has_pic == false)
sc->sc_quirks |= SONY_ACPI_QUIRK_FNINIT;
for (i = 0; i < SONY_PSW_LAST; i++)
if (sysmon_pswitch_register(&sc->sc_smpsw[i]) != 0) {
aprint_error_dev(self,
"couldn't register %s with sysmon\n",
sc->sc_smpsw[i].smpsw_name);
sc->sc_smpsw_valid = 0;
}
if (notify == SONY_NOTIFY_FnKeyEvent) {
rv = sony_acpi_eval_set_integer(hdl, "SN07", 0x202, &arg);
if (ACPI_FAILURE(rv))
return;
notify = arg & 0xff;
}
switch (notify) {
case SONY_NOTIFY_BrightnessDownPressed:
sony_acpi_brightness_down(dv);
break;
case SONY_NOTIFY_BrightnessUpPressed:
sony_acpi_brightness_up(dv);
break;
case SONY_NOTIFY_BrightnessDownReleased:
case SONY_NOTIFY_BrightnessUpReleased:
break;
case SONY_NOTIFY_SuspendPressed:
if (!sc->sc_smpsw_valid)
break;
sysmon_pswitch_event(&sc->sc_smpsw[SONY_PSW_SLEEP],
PSWITCH_EVENT_PRESSED);
break;
case SONY_NOTIFY_SuspendReleased:
break;
case SONY_NOTIFY_DisplaySwitchPressed:
if (!sc->sc_smpsw_valid)
break;
sysmon_pswitch_event(&sc->sc_smpsw[SONY_PSW_DISPLAY_CYCLE],
PSWITCH_EVENT_PRESSED);
break;
case SONY_NOTIFY_DisplaySwitchReleased:
break;
case SONY_NOTIFY_ZoomPressed:
if (!sc->sc_smpsw_valid)
break;
sysmon_pswitch_event(&sc->sc_smpsw[SONY_PSW_ZOOM],
PSWITCH_EVENT_PRESSED);
break;
case SONY_NOTIFY_ZoomReleased:
break;
default:
aprint_debug_dev(dv, "unknown notify event 0x%x\n", notify);
break;
}
}