From 53bb5de3d65e23a9abdce802759bfef5e8a480ba Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 24 Apr 2004 11:48:37 +0000 Subject: [PATCH] More drive capability fixups. (Not sure about win32 fixes yet though.) --- include/cdio/cdio.h | 22 +++++++++++++--------- lib/MSWindows/ioctl.c | 28 +++++++++++++--------------- lib/MSWindows/win32.c | 7 ++++--- lib/scsi_mmc.h | 4 +++- src/cd-info.c | 26 +++++++++++++------------- 5 files changed, 46 insertions(+), 41 deletions(-) diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index 885cb7b6..423060ae 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.40 2004/04/24 04:49:26 rocky Exp $ + $Id: cdio.h,v 1.41 2004/04/24 11:48:37 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -59,19 +59,23 @@ have only partial information or are not completely certain */ -#define CDIO_DRIVE_FILE 0x1000 /**< drive is really a file, i.e a - CD file image */ -#define CDIO_DRIVE_CD_R 0x2000 /**< drive is a CD-R */ -#define CDIO_DRIVE_CD_RW 0x4000 /**< drive is a CD-RW */ -#define CDIO_DRIVE_DVD 0x8000 /**< drive is a DVD */ +#define CDIO_DRIVE_CD_AUDIO 0x100 /**< drive can play CD audio */ +#define CDIO_DRIVE_CD_R 0x2000 /**< drive can write CD-R */ +#define CDIO_DRIVE_CD_RW 0x4000 /**< drive can write CD-RW */ +#define CDIO_DRIVE_DVD 0x8000 /**< drive can read DVD */ #define CDIO_DRIVE_DVD_R 0x10000 /**< drive can write DVD-R */ #define CDIO_DRIVE_DVD_RAM 0x20000 /**< drive can write DVD-RAM */ +#define CDIO_DRIVE_FILE 0x80000 /**< drive is really a file, i.e a + CD file image */ -#define CDIO_DRIVE_CD_READER (CDIO_DRIVE_CD_R|CDIO_DRIVE_CD_RW) -#define CDIO_DRIVE_CD_WRITER (CDIO_DRIVE_RW) +#define CDIO_DRIVE_CD_WRITER (CDIO_DRIVE_CD_R|CDIO_DRIVE_CD_RW) +/**< Has some sort of CD writer ability */ + +#define CDIO_DRIVE_CD (CDIO_DRIVE_CD_AUDIO|CDIO_DRIVE_CD_WRITER) +/**< Has some sort of CD ability */ -#define CDIO_DRIVE_DVD_READER (CDIO_DRIVE_DVD|CDIO_DRIVE_DVD_R|CDIO_DRIVE_DVD_RAM) #define CDIO_DRIVE_DVD_WRITER (CDIO_DRIVE_DVD_R|CDIO_DRIVE_DVD_RAM) +/**< Has some sort of DVD writer ability */ #ifdef __cplusplus extern "C" { diff --git a/lib/MSWindows/ioctl.c b/lib/MSWindows/ioctl.c index 9eae0779..697099ec 100644 --- a/lib/MSWindows/ioctl.c +++ b/lib/MSWindows/ioctl.c @@ -1,5 +1,5 @@ /* - $Id: ioctl.c,v 1.6 2004/04/24 04:46:33 rocky Exp $ + $Id: ioctl.c,v 1.7 2004/04/24 11:48:37 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: ioctl.c,v 1.6 2004/04/24 04:46:33 rocky Exp $"; +static const char _rcsid[] = "$Id: ioctl.c,v 1.7 2004/04/24 11:48:37 rocky Exp $"; #include #include @@ -454,7 +454,7 @@ win32ioctl_get_drive_cap (const void *env) { memset(&sptwb,0, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS)); - sptwb.Spt.Length = sizeof(SCSI_PASS_THROUGH); + sptwb.Spt.Length = sizeof(SCSI_PASS_THROUGH); sptwb.Spt.PathId = 0; sptwb.Spt.TargetId = 1; sptwb.Spt.Lun = 0; @@ -467,10 +467,12 @@ win32ioctl_get_drive_cap (const void *env) { offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,DataBuf); sptwb.Spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,SenseBuf); - sptwb.Spt.Cdb[0] = SCSIOP_MODE_SENSE; - sptwb.Spt.Cdb[1] = 0x08; /* target doesn't return block descriptors */ - sptwb.Spt.Cdb[2] = MODE_PAGE_CAPABILITIES; - sptwb.Spt.Cdb[4] = 192; + sptwb.Spt.Cdb[0] = CDIO_MMC_MODE_SENSE; + sptwb.Spt.Cdb[1] = 0x08; /* doesn't return block descriptors */ + sptwb.Spt.Cdb[2] = 0x2a; /*MODE_PAGE_CAPABILITIES*/; + sptwb.Spt.Cdb[3] = 0; /* Not used */ + sptwb.Spt.Cdb[4] = 128; + sptwb.Spt.Cdb[5] = 0; /* Not used */ length = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,DataBuf) + sptwb.Spt.DataTransferLength; @@ -483,23 +485,19 @@ win32ioctl_get_drive_cap (const void *env) { &returned, FALSE) ) { - /* Reader */ - if (sptwb.DataBuf[6] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R; + /* Reader? */ + i_drivetype |= CDIO_DRIVE_CD_AUDIO; if (sptwb.DataBuf[6] & 0x02) i_drivetype |= CDIO_DRIVE_CD_RW; if (sptwb.DataBuf[6] & 0x08) i_drivetype |= CDIO_DRIVE_DVD; - if (sptwb.DataBuf[6] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_R; - if (sptwb.DataBuf[6] & 0x20) i_drivetype |= CDIO_DRIVE_DVD_RAM; - /* Writer */ + /* Writer? */ if (sptwb.DataBuf[7] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R; - if (sptwb.DataBuf[7] & 0x02) i_drivetype |= CDIO_DRIVE_CD_RW; - if (sptwb.DataBuf[7] & 0x08) i_drivetype |= CDIO_DRIVE_DVD; if (sptwb.DataBuf[7] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_R; if (sptwb.DataBuf[7] & 0x20) i_drivetype |= CDIO_DRIVE_DVD_RAM; return i_drivetype; } else { - i_drivetype = CDIO_DRIVE_CD_R | CDIO_DRIVE_UNKNOWN; + i_drivetype = CDIO_DRIVE_CD_AUDIO | CDIO_DRIVE_UNKNOWN; } return CDIO_DRIVE_ERROR; } diff --git a/lib/MSWindows/win32.c b/lib/MSWindows/win32.c index 4382c732..85888916 100644 --- a/lib/MSWindows/win32.c +++ b/lib/MSWindows/win32.c @@ -1,5 +1,5 @@ /* - $Id: win32.c,v 1.5 2004/04/24 04:46:33 rocky Exp $ + $Id: win32.c,v 1.6 2004/04/24 11:48:37 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: win32.c,v 1.5 2004/04/24 04:46:33 rocky Exp $"; +static const char _rcsid[] = "$Id: win32.c,v 1.6 2004/04/24 11:48:37 rocky Exp $"; #include #include @@ -596,8 +596,9 @@ cdio_get_default_device_win32(void) bool cdio_is_device_win32(const char *source_name) { - unsigned int len = strlen(source_name); + unsigned int len; + len = strlen(source_name); if (NULL == source_name) return false; #ifdef HAVE_WIN32_CDROM diff --git a/lib/scsi_mmc.h b/lib/scsi_mmc.h index 40f80399..fc89830d 100644 --- a/lib/scsi_mmc.h +++ b/lib/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.4 2003/09/20 12:34:02 rocky Exp $ + $Id: scsi_mmc.h,v 1.5 2004/04/24 11:48:37 rocky Exp $ Copyright (C) 2003 Rocky Bernstein @@ -36,6 +36,8 @@ /* The generic packet command opcodes for CD/DVD Logical Units, * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ +#define CDIO_MMC_MODE_SENSE_10 0x5a +#define CDIO_MMC_MODE_SENSE 0x1a #define CDIO_MMC_GPCMD_READ_CD 0xbe #define CDIO_MMC_GPCMD_READ_10 0x28 #define CDIO_MMC_GPCMD_READ_12 0xa8 diff --git a/src/cd-info.c b/src/cd-info.c index 47d0aeb9..00847821 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.55 2004/04/24 04:48:06 rocky Exp $ + $Id: cd-info.c,v 1.56 2004/04/24 11:48:37 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -837,21 +837,21 @@ main(int argc, const char *argv[]) if (CDIO_DRIVE_FILE == i_drive_cap) { printf("Disc-image file\n"); } else { - printf("CD Reader : %s\n", - i_drive_cap & CDIO_DRIVE_CD_READER ? "Yes" : "No"); - printf(" CD-R : %s\n", + printf("Compact Disc : %s\n", + i_drive_cap & CDIO_DRIVE_CD ? "Yes" : "No"); + printf(" Can play audio : %s\n", + i_drive_cap & CDIO_DRIVE_CD_AUDIO ? "Yes" : "No"); + printf(" Can write CD-R : %s\n", i_drive_cap & CDIO_DRIVE_CD_R ? "Yes" : "No"); - printf(" CD-RW : %s\n\n", - i_drive_cap & CDIO_DRIVE_CD_RW ? "Yes" : "No"); + printf(" Can write CD-RW : %s\n\n", + i_drive_cap & CDIO_DRIVE_CD_RW ? "Yes" : "No"); - printf("DVD Reader : %s\n", - i_drive_cap & CDIO_DRIVE_DVD_READER ? "Yes" : "No"); - printf(" DVD-ROM : %s\n", - i_drive_cap & CDIO_DRIVE_DVD ? "Yes" : "No"); - printf(" DVD-R : %s\n", + printf("Digital Versital Disc: %s\n", + i_drive_cap & CDIO_DRIVE_DVD ? "Yes" : "No"); + printf(" Can write DVD-R : %s\n", i_drive_cap & CDIO_DRIVE_DVD_R ? "Yes" : "No"); - printf(" DVD_RAM : %s\n", - i_drive_cap & CDIO_DRIVE_DVD_RAM ? "Yes" : "No"); + printf(" Can write DVD-RAM : %s\n", + i_drive_cap & CDIO_DRIVE_DVD_RAM ? "Yes" : "No"); } if (CDIO_DRIVE_UNKNOWN == i_drive_cap) { printf("Not sure about drive properties\n\n");