diff --git a/include/cdio/scsi_mmc.h b/include/cdio/scsi_mmc.h index 65814bb6..5d894f83 100644 --- a/include/cdio/scsi_mmc.h +++ b/include/cdio/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.4 2004/06/26 01:08:46 rocky Exp $ + $Id: scsi_mmc.h,v 1.5 2004/06/27 22:00:08 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -48,6 +48,18 @@ #define CDIO_MMC_GPCMD_READ_CD 0xbe #define CDIO_MMC_GPCMD_READ_MSF 0xb9 + +/*! Page codes for MODE SENSE and MODE SET. */ +#define CDIO_MMC_R_W_ERROR_PAGE 0x01 +#define CDIO_MMC_WRITE_PARMS_PAGE 0x05 +#define CDIO_MMC_AUDIO_CTL_PAGE 0x0e +#define CDIO_MMC_POWER_PAGE 0x1a +#define CDIO_MMC_FAULT_FAIL_PAGE 0x1c +#define CDIO_MMC_TO_PROTECT_PAGE 0x1d +#define CDIO_MMC_CAPABILITIES_PAGE 0x2a +#define CDIO_MMC_ALL_PAGES 0x3f + + /*! This is listed as optional in ATAPI 2.6, but is (curiously) missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji Table 377 as an MMC command for SCSi devices though... Most ATAPI @@ -81,4 +93,11 @@ #define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(rec, val) \ rec[9] = val; +/*! + On input A MODE_SENSE command was issued and we have the results + in p. We interpret this and return a bit mask set according to the + capabilities. + */ +cdio_drive_cap_t cdio_get_drive_cap_mmc(const uint8_t *p); + #endif /* __SCSI_MMC_H__ */ diff --git a/lib/FreeBSD/freebsd_cam.c b/lib/FreeBSD/freebsd_cam.c index ba126baf..83d8b3ee 100644 --- a/lib/FreeBSD/freebsd_cam.c +++ b/lib/FreeBSD/freebsd_cam.c @@ -1,5 +1,5 @@ /* - $Id: freebsd_cam.c,v 1.13 2004/06/25 20:49:56 rocky Exp $ + $Id: freebsd_cam.c,v 1.14 2004/06/27 22:00:09 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.13 2004/06/25 20:49:56 rocky Exp $"; +static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.14 2004/06/27 22:00:09 rocky Exp $"; #ifdef HAVE_FREEBSD_CDROM @@ -173,7 +173,7 @@ static cdio_drive_cap_t get_drive_cap_freebsd_cam (img_private_t *env) { int32_t i_drivetype = 0; - char buf[192] = { 0, }; + uint8_t buf[192] = { 0, }; int rc; memset(&env->ccb, 0, sizeof(env->ccb)); @@ -188,7 +188,8 @@ get_drive_cap_freebsd_cam (img_private_t *env) /* Initialize my_scsi_cdb as a Mode Select(6) */ CDIO_MMC_SET_COMMAND(env->ccb.csio.cdb_io.cdb_bytes, CDIO_MMC_MODE_SENSE); env->ccb.csio.cdb_io.cdb_bytes[1] = 0x0; - env->ccb.csio.cdb_io.cdb_bytes[2] = 0x2a; /* MODE_PAGE_CAPABILITIES*/ + /* use ALL_PAGES?*/ + env->ccb.csio.cdb_io.cdb_bytes[2] = CDIO_MMC_CAPABILITIES_PAGE; env->ccb.csio.cdb_io.cdb_bytes[3] = 0; /* Not used */ env->ccb.csio.cdb_io.cdb_bytes[4] = 128; env->ccb.csio.cdb_io.cdb_bytes[5] = 0; /* Not used */ @@ -202,19 +203,7 @@ get_drive_cap_freebsd_cam (img_private_t *env) if(rc == 0) { unsigned int n=buf[3]+4; - /* Reader? */ - if (buf[n+5] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_AUDIO; - if (buf[n+2] & 0x02) i_drivetype |= CDIO_DRIVE_CAP_CD_RW; - if (buf[n+2] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_DVD; - - /* Writer? */ - if (buf[n+3] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_R; - if (buf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_CAP_DVD_R; - if (buf[n+3] & 0x20) i_drivetype |= CDIO_DRIVE_CAP_DVD_RAM; - - if (buf[n+6] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_OPEN_TRAY; - if (buf[n+6] >> 5 != 0) i_drivetype |= CDIO_DRIVE_CAP_CLOSE_TRAY; - + i_drivetype |= cdio_get_drive_cap_mmc(&(buf[n])); } else { i_drivetype = CDIO_DRIVE_CAP_CD_AUDIO | CDIO_DRIVE_CAP_UNKNOWN; } diff --git a/lib/MSWindows/aspi32.c b/lib/MSWindows/aspi32.c index 811c6b52..3793c19a 100644 --- a/lib/MSWindows/aspi32.c +++ b/lib/MSWindows/aspi32.c @@ -1,5 +1,5 @@ /* - $Id: aspi32.c,v 1.10 2004/06/27 15:29:22 rocky Exp $ + $Id: aspi32.c,v 1.11 2004/06/27 22:00:10 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: aspi32.c,v 1.10 2004/06/27 15:29:22 rocky Exp $"; +static const char _rcsid[] = "$Id: aspi32.c,v 1.11 2004/06/27 22:00:10 rocky Exp $"; #include #include @@ -708,7 +708,7 @@ get_drive_cap_aspi (const _img_private_t *env) /* Operation code */ CDIO_MMC_SET_COMMAND(ssc.CDBByte, CDIO_MMC_MODE_SENSE_10); ssc.CDBByte[1] = 0x0; - ssc.CDBByte[2] = 0x3F; /* try narrower 0x2a "mode-page" ? */ + ssc.CDBByte[2] = CDIO_MMC_ALL_PAGES; ssc.CDBByte[7] = 0x01; ssc.CDBByte[8] = 0x00; @@ -751,19 +751,7 @@ get_drive_cap_aspi (const _img_private_t *env) /* Don't handle theses yet. */ break; case CDRCAPS: - /* Reader? */ - if (p[5] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_AUDIO; - if (p[2] & 0x02) i_drivetype |= CDIO_DRIVE_CAP_CD_RW; - if (p[2] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_DVD; - - /* Writer? */ - if (p[3] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_R; - if (p[3] & 0x10) i_drivetype |= CDIO_DRIVE_CAP_DVD_R; - if (p[3] & 0x20) i_drivetype |= CDIO_DRIVE_CAP_DVD_RAM; - - if (p[6] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_OPEN_TRAY; - if (p[6] >> 5 != 0) - i_drivetype |= CDIO_DRIVE_CAP_CLOSE_TRAY; + i_drivetype |= cdio_get_drive_cap_mmc(p); break; default: ; } diff --git a/lib/Makefile.am b/lib/Makefile.am index aaf763ee..79dada8d 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.39 2004/06/23 09:25:30 rocky Exp $ +# $Id: Makefile.am,v 1.40 2004/06/27 22:00:09 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -85,6 +85,7 @@ libcdio_sources = \ MSWindows/win32.c \ MSWindows/win32.h \ sector.c \ + scsi_mmc.c \ util.c lib_LTLIBRARIES = libcdio.la libiso9660.la