summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2009-01-10 18:01:00 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2009-01-10 18:01:00 +0000
commit932ba32ffa8d09ad85b44c4b77fde39c16a5c679 (patch)
tree65a77324204e778fb2a468416f3360581e6a48ff
parentc2006b615cdfd70352e28e50f7a94af153dc5177 (diff)
Add support for the volume buttons and for the eject button found
on apple laptops. The eject button will only eject the disc when it's not used by anything. ok miod@
-rw-r--r--sys/arch/macppc/dev/abtn.c36
-rw-r--r--sys/scsi/cd.c39
2 files changed, 65 insertions, 10 deletions
diff --git a/sys/arch/macppc/dev/abtn.c b/sys/arch/macppc/dev/abtn.c
index 37e0c77dc70..6b021e0d5b6 100644
--- a/sys/arch/macppc/dev/abtn.c
+++ b/sys/arch/macppc/dev/abtn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abtn.c,v 1.11 2006/01/18 23:21:17 miod Exp $ */
+/* $OpenBSD: abtn.c,v 1.12 2009/01/10 18:00:59 robert Exp $ */
/* $NetBSD: abtn.c,v 1.1 1999/07/12 17:48:26 tsubai Exp $ */
/*-
@@ -31,6 +31,7 @@
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
+#include <sys/workq.h>
#include <machine/bus.h>
@@ -39,6 +40,10 @@
#include <dev/adb/adb.h>
+#include "audio.h"
+#include "cd.h"
+#include "wskbd.h"
+
#define ABTN_HANDLER_ID 31
struct abtn_softc {
@@ -53,6 +58,13 @@ int abtn_match(struct device *, void *, void *);
void abtn_attach(struct device *, struct device *, void *);
void abtn_adbcomplete(caddr_t, caddr_t, int);
+#if NWSKBD > 0
+extern int cd_eject(void);
+#if NAUDIO > 0
+extern int wskbd_set_mixervolume(long dir);
+#endif
+#endif
+
struct cfattach abtn_ca = {
sizeof(struct abtn_softc), abtn_match, abtn_attach
};
@@ -112,32 +124,40 @@ abtn_adbcomplete(caddr_t buffer, caddr_t data, int adb_command)
of_setbrightness(brightness);
break;
-#ifdef DEBUG
+#if NAUDIO > 0 && NWSKBD > 0
case 0x08: /* mute */
case 0x01: /* mute, AV hardware */
+ workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
+ (void *)(long)0, NULL);
+ break;
case 0x07: /* decrease volume */
case 0x02: /* decrease volume, AV hardware */
+ workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
+ (void *)(long)-1, NULL);
+ break;
case 0x06: /* increase volume */
case 0x03: /* increase volume, AV hardware */
- /* Need callback to do something with these */
+ workq_add_task(NULL, 0, (workq_fn)wskbd_set_mixervolume,
+ (void *)(long)1, NULL);
break;
-
+#endif
case 0x0c: /* mirror display key */
/* Need callback to do something with this */
break;
-
+#if NWSKBD > 0 && NCD > 0
case 0x0b: /* eject tray */
- /* Need callback to do something with this */
+ workq_add_task(NULL, 0, (workq_fn)cd_eject, NULL, NULL);
break;
-
+#endif
case 0x7f: /* numlock */
/* Need callback to do something with this */
break;
default:
+#ifdef DEBUG
if ((cmd & ~0x7f) == 0)
printf("unknown ADB button 0x%x\n", cmd);
- break;
#endif
+ break;
}
}
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index a796cfac311..d50e5db0787 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.144 2008/08/01 01:44:20 dlg Exp $ */
+/* $OpenBSD: cd.c,v 1.145 2009/01/10 18:00:59 robert Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -74,7 +74,7 @@
#include <scsi/scsiconf.h>
-#include <ufs/ffs/fs.h> /* for BBSIZE and SBSIZE */
+#include <ufs/ffs/fs.h> /* for BBSIZE and SBSIZE */
#define CDOUTSTANDING 4
@@ -126,6 +126,10 @@ int dvd_read_struct(struct cd_softc *, union dvd_struct *);
void cd_powerhook(int why, void *arg);
+#if defined(__macppc__)
+int cd_eject(void);
+#endif
+
struct cfattach cd_ca = {
sizeof(struct cd_softc), cdmatch, cdattach,
cddetach, cdactivate
@@ -1968,3 +1972,34 @@ cd_kill_buffers(struct cd_softc *cd)
}
splx(s);
}
+
+#if defined(__macppc__)
+int
+cd_eject(void)
+{
+ struct cd_softc *cd;
+ int error = 0;
+
+ if (cd_cd.cd_ndevs == 0 || (cd = cd_cd.cd_devs[0]) == NULL)
+ return (ENXIO);
+
+ if ((error = cdlock(cd)) != 0)
+ return (error);
+
+ if (cd->sc_dk.dk_openmask == 0) {
+ cd->sc_link->flags |= SDEV_EJECTING;
+
+ scsi_prevent(cd->sc_link, PR_ALLOW,
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY |
+ SCSI_SILENT | SCSI_IGNORE_MEDIA_CHANGE);
+ cd->sc_link->flags &= ~SDEV_MEDIA_LOADED;
+
+ scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0);
+
+ cd->sc_link->flags &= ~SDEV_EJECTING;
+ }
+ cdunlock(cd);
+
+ return (error);
+}
+#endif