summaryrefslogtreecommitdiff
path: root/sys/scsi
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 /sys/scsi
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@
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/cd.c39
1 files changed, 37 insertions, 2 deletions
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