Use generic SCSI MMC code for getting drive capabilities.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: aspi32.c,v 1.48 2004/08/10 03:03:27 rocky Exp $
|
$Id: aspi32.c,v 1.49 2004/08/27 04:12:29 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: aspi32.c,v 1.48 2004/08/10 03:03:27 rocky Exp $";
|
static const char _rcsid[] = "$Id: aspi32.c,v 1.49 2004/08/27 04:12:29 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -762,68 +762,6 @@ wnaspi32_eject_media (void *user_data) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
|
||||||
Return the the kind of drive capabilities of device.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
get_drive_cap_aspi (const _img_private_t *p_env,
|
|
||||||
cdio_drive_read_cap_t *p_read_cap,
|
|
||||||
cdio_drive_write_cap_t *p_write_cap,
|
|
||||||
cdio_drive_misc_cap_t *p_misc_cap)
|
|
||||||
{
|
|
||||||
scsi_mmc_cdb_t cdb = {{0, }};
|
|
||||||
uint8_t buf[256] = { 0, };
|
|
||||||
int i_status;
|
|
||||||
|
|
||||||
/* Set up passthrough command */
|
|
||||||
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_10);
|
|
||||||
cdb.field[1] = 0x0;
|
|
||||||
cdb.field[2] = CDIO_MMC_ALL_PAGES;
|
|
||||||
cdb.field[7] = 0x01;
|
|
||||||
cdb.field[8] = 0x00;
|
|
||||||
|
|
||||||
i_status = run_scsi_cmd_aspi(p_env, OP_TIMEOUT_MS,
|
|
||||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
|
||||||
&cdb, SCSI_MMC_DATA_READ,
|
|
||||||
sizeof(buf), buf);
|
|
||||||
if (0 == i_status) {
|
|
||||||
uint8_t *p;
|
|
||||||
int lenData = ((unsigned int)buf[0] << 8) + buf[1];
|
|
||||||
uint8_t *pMax = buf + 256;
|
|
||||||
|
|
||||||
*p_read_cap = 0;
|
|
||||||
*p_write_cap = 0;
|
|
||||||
*p_misc_cap = 0;
|
|
||||||
|
|
||||||
/* set to first sense mask, and then walk through the masks */
|
|
||||||
p = buf + 8;
|
|
||||||
while( (p < &(buf[2+lenData])) && (p < pMax) ) {
|
|
||||||
uint8_t which;
|
|
||||||
|
|
||||||
which = p[0] & 0x3F;
|
|
||||||
switch( which )
|
|
||||||
{
|
|
||||||
case CDIO_MMC_AUDIO_CTL_PAGE:
|
|
||||||
case CDIO_MMC_R_W_ERROR_PAGE:
|
|
||||||
case CDIO_MMC_CDR_PARMS_PAGE:
|
|
||||||
/* Don't handle these yet. */
|
|
||||||
break;
|
|
||||||
case CDIO_MMC_CAPABILITIES_PAGE:
|
|
||||||
scsi_mmc_get_drive_cap_buf(p, p_read_cap, p_write_cap, p_misc_cap);
|
|
||||||
break;
|
|
||||||
default: ;
|
|
||||||
}
|
|
||||||
p += (p[1] + 2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cdio_info("error in aspi USCSICMD MODE_SELECT");
|
|
||||||
*p_read_cap = CDIO_DRIVE_CAP_UNKNOWN;
|
|
||||||
*p_write_cap = CDIO_DRIVE_CAP_UNKNOWN;
|
|
||||||
*p_misc_cap = CDIO_DRIVE_CAP_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Get format of track.
|
Get format of track.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Win32 aspi specific */
|
/* Win32 aspi specific */
|
||||||
/*
|
/*
|
||||||
$Id: aspi32.h,v 1.12 2004/07/28 03:17:56 rocky Exp $
|
$Id: aspi32.h,v 1.13 2004/08/27 04:12:29 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -170,18 +170,6 @@ SRB_HAInquiry;
|
|||||||
*/
|
*/
|
||||||
discmode_t get_discmode_aspi (_img_private_t *p_env);
|
discmode_t get_discmode_aspi (_img_private_t *p_env);
|
||||||
|
|
||||||
/*!
|
|
||||||
Return the the kind of drive capabilities of device.
|
|
||||||
|
|
||||||
Note: string is malloc'd so caller should free() then returned
|
|
||||||
string when done with it.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void get_drive_cap_aspi (const _img_private_t *env,
|
|
||||||
cdio_drive_read_cap_t *p_read_cap,
|
|
||||||
cdio_drive_write_cap_t *p_write_cap,
|
|
||||||
cdio_drive_misc_cap_t *p_misc_cap);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return the the kind of drive capabilities of device.
|
Return the the kind of drive capabilities of device.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: win32.c,v 1.44 2004/08/10 12:09:20 rocky Exp $
|
$Id: win32.c,v 1.45 2004/08/27 04:12:29 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: win32.c,v 1.44 2004/08/10 12:09:20 rocky Exp $";
|
static const char _rcsid[] = "$Id: win32.c,v 1.45 2004/08/27 04:12:29 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -112,35 +112,6 @@ is_cdrom_win32(const char drive_letter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Return the the kind of drive capabilities of device.
|
|
||||||
|
|
||||||
Note: string is malloc'd so caller should free() then returned
|
|
||||||
string when done with it.
|
|
||||||
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
_cdio_get_drive_cap (const void *env,
|
|
||||||
cdio_drive_read_cap_t *p_read_cap,
|
|
||||||
cdio_drive_write_cap_t *p_write_cap,
|
|
||||||
cdio_drive_misc_cap_t *p_misc_cap)
|
|
||||||
{
|
|
||||||
const _img_private_t *_obj = env;
|
|
||||||
|
|
||||||
*p_read_cap = 0;
|
|
||||||
*p_write_cap = 0;
|
|
||||||
*p_misc_cap = 0;
|
|
||||||
|
|
||||||
if (_obj->hASPI) {
|
|
||||||
/* A safe guess */
|
|
||||||
|
|
||||||
get_drive_cap_aspi (env, p_read_cap, p_write_cap, p_misc_cap);
|
|
||||||
} else {
|
|
||||||
get_drive_cap_win32ioctl (env, p_read_cap, p_write_cap, p_misc_cap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Run a SCSI MMC command.
|
Run a SCSI MMC command.
|
||||||
|
|
||||||
@@ -717,7 +688,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
|
|||||||
.get_default_device = cdio_get_default_device_win32,
|
.get_default_device = cdio_get_default_device_win32,
|
||||||
.get_devices = cdio_get_devices_win32,
|
.get_devices = cdio_get_devices_win32,
|
||||||
.get_discmode = get_discmode_win32,
|
.get_discmode = get_discmode_win32,
|
||||||
.get_drive_cap = _cdio_get_drive_cap,
|
.get_drive_cap = scsi_mmc_get_drive_cap_generic,
|
||||||
.get_first_track_num= get_first_track_num_generic,
|
.get_first_track_num= get_first_track_num_generic,
|
||||||
.get_mcn = _cdio_get_mcn,
|
.get_mcn = _cdio_get_mcn,
|
||||||
.get_num_tracks = get_num_tracks_generic,
|
.get_num_tracks = get_num_tracks_generic,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: win32_ioctl.c,v 1.35 2004/08/10 03:03:27 rocky Exp $
|
$Id: win32_ioctl.c,v 1.36 2004/08/27 04:12:29 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.35 2004/08/10 03:03:27 rocky Exp $";
|
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.36 2004/08/27 04:12:29 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -554,72 +554,4 @@ get_track_format_win32ioctl(const _img_private_t *env, track_t i_track)
|
|||||||
return TRACK_FORMAT_AUDIO;
|
return TRACK_FORMAT_AUDIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Return the the kind of drive capabilities of device.
|
|
||||||
|
|
||||||
Note: string is malloc'd so caller should free() then returned
|
|
||||||
string when done with it.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
get_drive_cap_win32ioctl (const _img_private_t *p_env,
|
|
||||||
cdio_drive_read_cap_t *p_read_cap,
|
|
||||||
cdio_drive_write_cap_t *p_write_cap,
|
|
||||||
cdio_drive_misc_cap_t *p_misc_cap)
|
|
||||||
{
|
|
||||||
SCSI_PASS_THROUGH_WITH_BUFFERS sptwb;
|
|
||||||
ULONG returned = 0;
|
|
||||||
ULONG length;
|
|
||||||
|
|
||||||
/* If device supports SCSI-3, then we can get the CD drive
|
|
||||||
capabilities, i.e. ability to read/write to CD-ROM/R/RW
|
|
||||||
or/and read/write to DVD-ROM/R/RW. */
|
|
||||||
|
|
||||||
memset(&sptwb,0, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));
|
|
||||||
|
|
||||||
sptwb.Spt.Length = sizeof(SCSI_PASS_THROUGH);
|
|
||||||
sptwb.Spt.PathId = 0;
|
|
||||||
sptwb.Spt.TargetId = 1;
|
|
||||||
sptwb.Spt.Lun = 0;
|
|
||||||
sptwb.Spt.CdbLength = 6; /* CDB6GENERIC_LENGTH; */
|
|
||||||
sptwb.Spt.SenseInfoLength = 24;
|
|
||||||
sptwb.Spt.DataIn = SCSI_IOCTL_DATA_IN;
|
|
||||||
sptwb.Spt.DataTransferLength = 192;
|
|
||||||
sptwb.Spt.TimeOutValue = 2;
|
|
||||||
sptwb.Spt.DataBufferOffset =
|
|
||||||
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,DataBuf);
|
|
||||||
sptwb.Spt.SenseInfoOffset =
|
|
||||||
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,SenseBuf);
|
|
||||||
|
|
||||||
CDIO_MMC_SET_COMMAND(sptwb.Spt.Cdb, CDIO_MMC_GPCMD_MODE_SENSE);
|
|
||||||
/*sptwb.Spt.Cdb[1] = 0x08; /+ doesn't return block descriptors */
|
|
||||||
sptwb.Spt.Cdb[1] = 0x0;
|
|
||||||
sptwb.Spt.Cdb[2] = CDIO_MMC_CAPABILITIES_PAGE;
|
|
||||||
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;
|
|
||||||
|
|
||||||
if ( DeviceIoControl(p_env->h_device_handle,
|
|
||||||
IOCTL_SCSI_PASS_THROUGH,
|
|
||||||
&sptwb,
|
|
||||||
sizeof(SCSI_PASS_THROUGH),
|
|
||||||
&sptwb,
|
|
||||||
length,
|
|
||||||
&returned,
|
|
||||||
FALSE) ) {
|
|
||||||
unsigned int n=sptwb.DataBuf[3]+4;
|
|
||||||
/* Reader? */
|
|
||||||
scsi_mmc_get_drive_cap_buf(&(sptwb.DataBuf[n]), p_read_cap,
|
|
||||||
p_write_cap, p_misc_cap);
|
|
||||||
} else {
|
|
||||||
*p_read_cap = CDIO_DRIVE_CAP_UNKNOWN;
|
|
||||||
*p_write_cap = CDIO_DRIVE_CAP_UNKNOWN;
|
|
||||||
*p_misc_cap = CDIO_DRIVE_CAP_UNKNOWN;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /*HAVE_WIN32_CDROM*/
|
#endif /*HAVE_WIN32_CDROM*/
|
||||||
|
|||||||
Reference in New Issue
Block a user