|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: giovanni (qgiovanni
gmail.com)
Date: Mon Oct 20 2008 - 02:03:22 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I was suggested to put the patch (from netbsd) here.
it's for amd64 so for i386 after applying the patch you need to add
acpisony* at acpi?
in /usr/src/sys/arch/i386/conf/GENERIC
it has been tested (i386/amd64) w/ vaio vgn c1sh model so
it would be nice to know if it works for other models too
brighteness keys on VGN (may be PCG too) models are mapped as:
Fn+F6 increase
Fn+F5 decrease
cd /usr/src/sys
patch -s < acpisony.diff
rebuild, reboot
dmesg | grep acpisony
acpisony0 at acpi0
Index: arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.243
diff -u -p -u -p -r1.243 GENERIC
--- arch/amd64/conf/GENERIC 15 Oct 2008 15:05:04 -0000 1.243
+++ arch/amd64/conf/GENERIC 16 Oct 2008 08:00:12 -0000

-49,6 +49,7 
acpiec* at acpi?
acpiprt* at acpi?
acpitz* at acpi?
acpithinkpad* at acpi?
+acpisony* at acpi?
ipmi0 at mainbus? disable # IPMI
Index: dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.125
diff -u -p -u -p -r1.125 acpi.c
--- dev/acpi/acpi.c 2 Jul 2008 03:14:54 -0000 1.125
+++ dev/acpi/acpi.c 16 Oct 2008 08:00:29 -0000

-1997,6 +1997,8 
acpi_foundhid(struct aml_node *node, voi
aaa.aaa_name = "acpiasus";
else if (!strcmp(dev, ACPI_DEV_THINKPAD))
aaa.aaa_name = "acpithinkpad";
+ else if (!strcmp(dev, ACPI_DEV_SONY))
+ aaa.aaa_name = "acpisony";
if (aaa.aaa_name)
config_found(self, &aaa, acpi_print);
Index: dev/acpi/acpireg.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpireg.h,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 acpireg.h
--- dev/acpi/acpireg.h 24 Jun 2008 08:24:57 -0000 1.15
+++ dev/acpi/acpireg.h 16 Oct 2008 08:00:31 -0000

-486,5 +486,6 
struct acpi_facs {
#define ACPI_DEV_FFB "FIXEDBUTTON" /* Fixed Feature Button */
#define ACPI_DEV_ASUS "ASUS010" /* ASUS Hotkeys */
#define ACPI_DEV_THINKPAD "IBM0068" /* ThinkPad support */
+#define ACPI_DEV_SONY "SNY5001" /* Vaio support */
#endif /* !_DEV_ACPI_ACPIREG_H_ */
Index: dev/acpi/acpisony.c
===================================================================
RCS file: dev/acpi/acpisony.c
diff -N dev/acpi/acpisony.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dev/acpi/acpisony.c 16 Oct 2008 08:00:31 -0000

-0,0 +1,281 
+/* $NetBSD: sony_acpi.c,v 1.5 2008/03/26 18:35:17 xtraeme Exp $ */
+
+/*-
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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/param.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpidev.h>
+#include <dev/acpi/amltypes.h>
+#include <dev/acpi/dsdt.h>
+
+#define SONY_NOTIFY_FNKEYEVENT 0X92
+#define SONY_NOTIFY_BRIGHTNESSDOWNPRESSED 0x85
+#define SONY_NOTIFY_BRIGHTNESSDOWNRELEASED 0x05
+#define SONY_NOTIFY_BRIGHTNESSUPPRESSED 0x86
+#define SONY_NOTIFY_BRIGHTNESSUPRELEASED 0x06
+#define SONY_NOTIFY_DISPLAYSWITCHPRESSED 0x87
+#define SONY_NOTIFY_DISPLAYSWITCHRELEASED 0x07
+#define SONY_NOTIFY_ZOOMPRESSED 0X8A
+#define SONY_NOTIFY_ZOOMRELEASED 0X0A
+#define SONY_NOTIFY_SUSPENDPRESSED 0X8C
+#define SONY_NOTIFY_SUSPENDRELEASED 0X0C
+
+struct acpisony_softc {
+ struct device sc_dev;
+ struct acpi_softc *sc_acpi;
+ struct aml_node *sc_devnode;
+ unsigned char sc_has_pic;
+};
+
+int acpisony_match(struct device *, void *, void *);
+void acpisony_attach(struct device *, struct device *, void *);
+int acpisony_notify(struct aml_node *, int, void *);
+void acpisony_brightness_down(struct acpisony_softc *);
+void acpisony_brightness_up(struct acpisony_softc *);
+void acpisony_quirk_setup(struct acpisony_softc *);
+void acpisony_eval_set(struct acpisony_softc *, const char *, int);
+int acpisony_foundpic(struct aml_node *, void *);
+
+extern struct aml_node aml_root;
+
+struct cfattach acpisony_ca = {
+ sizeof(struct acpisony_softc), acpisony_match, acpisony_attach
+};
+
+struct cfdriver acpisony_cd = {
+ NULL, "acpisony", DV_DULL
+};
+
+int
+acpisony_match(struct device *parent, void *match, void *aux)
+{
+ struct acpi_attach_args *aa = aux;
+ struct cfdata *cf = match;
+
+ if (aa->aaa_name == NULL ||
+ strcmp(aa->aaa_name, cf->cf_driver->cd_name) != 0 ||
+ aa->aaa_table != NULL)
+ return 0;
+
+ return 1;
+}
+
+int
+acpisony_foundpic(struct aml_node *node, void *arg)
+{
+ struct acpisony_softc *sc = (struct acpisony_softc *)arg;
+ struct aml_value res;
+ const char *dev;
+
+ if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) == 0) {
+
+ switch (res.type) {
+ case AML_OBJTYPE_STRING:
+ dev = res.v_string;
+ break;
+ case AML_OBJTYPE_INTEGER:
+ dev = aml_eisaid(aml_val2int(&res));
+ break;
+ default:
+ dev = "unknown";
+ break;
+ }
+
+ if (!strcmp(dev, "SNY6001"))
+ sc->sc_has_pic = 1;
+ }
+
+ aml_freevalue(&res);
+
+ return 0;
+}
+
+void
+acpisony_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct acpisony_softc *sc = (struct acpisony_softc *)self;
+ struct acpi_attach_args *aa = aux;
+
+ sc->sc_acpi = (struct acpi_softc *)parent;
+ sc->sc_devnode = aa->aaa_node;
+
+ printf("\n");
+
+ aml_find_node(&aml_root, "_HID", acpisony_foundpic, sc);
+
+ if (!sc->sc_has_pic)
+ acpisony_quirk_setup(sc);
+
+ aml_register_notify(sc->sc_devnode, aa->aaa_dev,
+ acpisony_notify, sc, ACPIDEV_NOPOLL);
+}
+
+
+int
+acpisony_notify(struct aml_node *node, int notify, void *arg)
+{
+ struct acpisony_softc *sc = arg;
+ struct aml_value res, res2;
+ int val;
+
+ if (notify == SONY_NOTIFY_FNKEYEVENT) {
+ bzero(&res, sizeof(res));
+ res.type = AML_OBJTYPE_INTEGER;
+ res.v_integer = 0x202;
+
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "SN07", 1, &res, &res2))
+ dnprintf(20, "%s: error evaluating SN07", DEVNAME(sc));
+
+ val = aml_val2int(&res2);
+ aml_freevalue(&res);
+ aml_freevalue(&res2);
+
+ notify = val & 0xff;
+ }
+
+ switch (notify) {
+ case SONY_NOTIFY_BRIGHTNESSDOWNPRESSED:
+ acpisony_brightness_down(sc);
+ break;
+ case SONY_NOTIFY_BRIGHTNESSUPPRESSED:
+ acpisony_brightness_up(sc);
+ break;
+ case SONY_NOTIFY_BRIGHTNESSDOWNRELEASED:
+ case SONY_NOTIFY_BRIGHTNESSUPRELEASED:
+ break;
+ case SONY_NOTIFY_DISPLAYSWITCHPRESSED:
+ case SONY_NOTIFY_DISPLAYSWITCHRELEASED:
+ break;
+ case SONY_NOTIFY_ZOOMPRESSED:
+ case SONY_NOTIFY_ZOOMRELEASED:
+ break;
+ case SONY_NOTIFY_SUSPENDPRESSED:
+ case SONY_NOTIFY_SUSPENDRELEASED:
+ break;
+ default:
+ printf("%s: unknown event 0x%02x\n", DEVNAME(sc), notify);
+ break;
+ }
+
+ return 0;
+}
+
+void
+acpisony_brightness_up(struct acpisony_softc *sc)
+{
+ struct aml_value res;
+ int arg;
+
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GBRT", 0, NULL, &res)) {
+ dnprintf(10, "%s: GBRT error reading brightness", DEVNAME(sc));
+ goto err;
+ }
+
+ arg = aml_val2int(&res);
+
+ if (++arg >= 8)
+ arg = 8;
+
+ bzero(&res, sizeof(res));
+ res.type = AML_OBJTYPE_INTEGER;
+ res.v_integer = arg;
+
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "SBRT", 1, &res, NULL))
+ dnprintf(10, "%s: SBRT error setting brightness to %d\n", DEVNAME(sc), arg);
+
+err:
+ aml_freevalue(&res);
+}
+
+
+void
+acpisony_brightness_down(struct acpisony_softc *sc)
+{
+ struct aml_value res;
+ int arg;
+
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GBRT", 0, NULL, &res)) {
+ dnprintf(10, "%s: GBRT error reading brightness", DEVNAME(sc));
+ goto err;
+ }
+
+ arg = aml_val2int(&res);
+
+ if (--arg <= 0)
+ arg = 0;
+
+ bzero(&res, sizeof(res));
+ res.type = AML_OBJTYPE_INTEGER;
+ res.v_integer = arg;
+
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "SBRT", 1, &res, NULL))
+ dnprintf(10, "%s: SBRT error setting brightness to %d\n", DEVNAME(sc), arg);
+
+err:
+ aml_freevalue(&res);
+}
+
+void
+acpisony_quirk_setup(struct acpisony_softc *sc)
+{
+ /* Initialize extra Fn keys */
+ acpisony_eval_set(sc, "SN02", 0x04);
+ acpisony_eval_set(sc, "SN07", 0x02);
+ acpisony_eval_set(sc, "SN02", 0x10);
+ acpisony_eval_set(sc, "SN07", 0x00);
+ acpisony_eval_set(sc, "SN03", 0x02);
+ acpisony_eval_set(sc, "SN07", 0x101);
+}
+
+void
+acpisony_eval_set(struct acpisony_softc *sc, const char *method, int val)
+{
+ struct aml_value res;
+
+ bzero(&res, sizeof(res));
+ res.type = AML_OBJTYPE_INTEGER;
+ res.v_integer = val;
+
+ if (aml_evalname(sc->sc_acpi, sc->sc_devnode, method, 1, &res, NULL))
+ dnprintf(10, "%s: %s error evaluating to %d\n", DEVNAME(sc), method, val);
+
+ aml_freevalue(&res);
+}
Index: dev/acpi/files.acpi
===================================================================
RCS file: /cvs/src/sys/dev/acpi/files.acpi,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 files.acpi
--- dev/acpi/files.acpi 2 Jul 2008 03:14:54 -0000 1.20
+++ dev/acpi/files.acpi 16 Oct 2008 08:00:31 -0000

-80,3 +80,9 
file dev/acpi/acpithinkpad.c acpithinkp
device acpivideo
attach acpivideo at acpi
file dev/acpi/acpivideo.c acpivideo
+
+# Sony Vaio support
+device acpisony
+attach acpisony at acpi
+file dev/acpi/acpisony.c acpisony
+
--
see ya,
giovanni
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]