lib/drivermmc.{c,h}: Add mmc_have_interface() to see if we've got SCSI

or ATAPI or whatever.

cdda_interface: Use mmc_have_inteface() we don't have anything for
this except in GNU/Linux. May reduce the unnecessary data_bigendianp()
calls which cause lots of disc reading.

Turn #defines for MMC Profiles into enumeration.
Add enumeration for "core" interface types

#include <cdio/scsi_mmc.h> -> #include <cdio/mmc.h>
This commit is contained in:
rocky
2005-02-07 03:36:01 +00:00
parent 3344d5642f
commit 2860cea4cb
17 changed files with 600 additions and 555 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: freebsd_cam.c,v 1.6 2005/02/06 13:05:42 rocky Exp $
$Id: freebsd_cam.c,v 1.7 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,12 +26,12 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.6 2005/02/06 13:05:42 rocky Exp $";
static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.7 2005/02/07 03:36:02 rocky Exp $";
#ifdef HAVE_FREEBSD_CDROM
#include "freebsd.h"
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
/* Default value in seconds we will wait for a command to
complete. */

View File

@@ -1,5 +1,5 @@
/*
$Id: aspi32.c,v 1.6 2005/02/06 17:36:17 rocky Exp $
$Id: aspi32.c,v 1.7 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,12 +27,12 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: aspi32.c,v 1.6 2005/02/06 17:36:17 rocky Exp $";
static const char _rcsid[] = "$Id: aspi32.c,v 1.7 2005/02/07 03:36:02 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
#include <cdio/util.h>
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdio_assert.h"
#include <string.h>

View File

@@ -1,5 +1,5 @@
/*
$Id: win32.c,v 1.16 2005/02/06 17:36:17 rocky Exp $
$Id: win32.c,v 1.17 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,12 +26,12 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32.c,v 1.16 2005/02/06 17:36:17 rocky Exp $";
static const char _rcsid[] = "$Id: win32.c,v 1.17 2005/02/07 03:36:02 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
#include <cdio/util.h>
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdio_assert.h"
#include "cdio_private.h" /* protoype for cdio_is_device_win32 */

View File

@@ -1,5 +1,5 @@
/*
$Id: win32_ioctl.c,v 1.12 2005/02/06 17:36:17 rocky Exp $
$Id: win32_ioctl.c,v 1.13 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.12 2005/02/06 17:36:17 rocky Exp $";
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.13 2005/02/07 03:36:02 rocky Exp $";
#ifdef HAVE_WIN32_CDROM
@@ -61,7 +61,7 @@ static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.12 2005/02/06 17:36:17 rock
#include <cdio/cdio.h>
#include <cdio/sector.h>
#include "cdio_assert.h"
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdtext_private.h"
#include "cdio/logging.h"

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_aix.c,v 1.10 2005/02/06 11:13:37 rocky Exp $
$Id: _cdio_aix.c,v 1.11 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -29,7 +29,7 @@
#include <cdio/logging.h>
#include <cdio/sector.h>
#include <cdio/util.h>
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdio_assert.h"
#include "cdio_private.h"
@@ -37,7 +37,7 @@
#ifdef HAVE_AIX_CDROM
static const char _rcsid[] = "$Id: _cdio_aix.c,v 1.10 2005/02/06 11:13:37 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_aix.c,v 1.11 2005/02/07 03:36:02 rocky Exp $";
#ifdef HAVE_GLOB_H
#include <glob.h>

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_linux.c,v 1.22 2005/02/06 15:09:10 rocky Exp $
$Id: _cdio_linux.c,v 1.23 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,14 +27,14 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.22 2005/02/06 15:09:10 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.23 2005/02/07 03:36:02 rocky Exp $";
#include <string.h>
#include <cdio/sector.h>
#include <cdio/util.h>
#include <cdio/types.h>
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include <cdio/cdtext.h>
#include "cdtext_private.h"
#include "cdio_assert.h"

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_sunos.c,v 1.20 2005/02/06 11:32:22 rocky Exp $
$Id: _cdio_sunos.c,v 1.21 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -30,7 +30,7 @@
#include <cdio/logging.h>
#include <cdio/sector.h>
#include <cdio/util.h>
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdio_assert.h"
#include "cdio_private.h"
@@ -38,7 +38,7 @@
#ifdef HAVE_SOLARIS_CDROM
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.20 2005/02/06 11:32:22 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.21 2005/02/07 03:36:02 rocky Exp $";
#ifdef HAVE_GLOB_H
#include <glob.h>

View File

@@ -148,6 +148,7 @@ cdtext_is_keyword
cdtext_set
discmode2str
mmc_get_hwinfo
mmc_have_interface
mmc_run_cmd
track_format2str
CDIO_SECTOR_SYNC_HEADER

View File

@@ -1,6 +1,6 @@
/* Common Multimedia Command (MMC) routines.
$Id: mmc.c,v 1.2 2005/02/06 11:13:37 rocky Exp $
$Id: mmc.c,v 1.3 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -25,7 +25,7 @@
#include <cdio/cdio.h>
#include <cdio/logging.h>
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdio_private.h"
#ifdef HAVE_STRING_H
@@ -767,6 +767,48 @@ mmc_eject_media( const CdIo_t *p_cdio )
}
/*!
* See if CD-ROM has feature with value value
* @return true if we have the feature and false if not.
*/
bool
mmc_have_interface( const CdIo_t *p_cdio, mmc_feature_interface_t interface )
{
int i_status; /* Result of MMC command */
uint8_t buf[500] = { 0, }; /* Place to hold returned data */
scsi_mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = CDIO_MMC_GET_CONF_NAMED_FEATURE;
cdb.field[3] = CDIO_MMC_FEATURE_CORE;
i_status = mmc_run_cmd(p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, sizeof(buf),
&buf);
if (i_status == 0) {
uint8_t *p;
uint32_t i_data;
uint8_t *p_max = buf + 65530;
i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf);
/* set to first sense feature code, and then walk through the masks */
p = buf + 8;
while( (p < &(buf[i_data])) && (p < p_max) ) {
uint16_t i_feature;
uint8_t i_feature_additional = p[3];
i_feature = CDIO_MMC_GET_LEN16(p);
if (CDIO_MMC_FEATURE_CORE == i_feature) {
uint8_t *q = p+4;
uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q);
if (interface == i_interface_standard) return true;
}
p += i_feature_additional + 4;
}
}
return false;
}
/*! Read sectors using SCSI-MMC GPCMD_READ_CD.
Can read only up to 25 blocks.
*/

View File

@@ -1,6 +1,6 @@
/* private MMC helper routines.
$Id: mmc_private.h,v 1.2 2005/02/06 11:13:37 rocky Exp $
$Id: mmc_private.h,v 1.3 2005/02/07 03:36:02 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -19,7 +19,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cdio/scsi_mmc.h>
#include <cdio/mmc.h>
#include "cdtext_private.h"
/*! Convert milliseconds to seconds taking the ceiling value, i.e.