Clarify the difference betweeen speed as it is defined in the MMC spec

and drive unit speeds. Add a new mmc routine for the latter.
This commit is contained in:
rocky
2006-04-04 02:06:12 +00:00
parent 380b9322ee
commit edc8056ec9
8 changed files with 105 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*-
$Id: device.h,v 1.34 2006/03/28 03:26:16 rocky Exp $
$Id: device.h,v 1.35 2006/04/04 02:06:12 rocky Exp $
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -921,8 +921,20 @@ extern "C" {
/*!
Set the drive speed.
@param p_cdio CD structure set by cdio_open().
@param i_drive_speed speed in CD-ROM speed units. Note this
not Kbs as would be used in the MMC spec or
in mmc_set_speed(). To convert CD-ROM speed units
to Kbs, multiply the number by 176 (for raw data)
and by 150 (for filesystem data). On many CD-ROM
drives, specifying a value too large will result
in using the fastest speed.
@see mmc_set_speed and mmc_set_drive_speed
*/
driver_return_code_t cdio_set_speed ( const CdIo_t *p_cdio, int i_speed );
driver_return_code_t cdio_set_speed ( const CdIo_t *p_cdio,
int i_drive_speed );
/*!
Get the value associatied with key.

View File

@@ -1,5 +1,5 @@
/*
$Id: mmc.h,v 1.25 2006/04/03 18:51:46 rocky Exp $
$Id: mmc.h,v 1.26 2006/04/04 02:06:13 rocky Exp $
Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -778,9 +778,48 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
uint16_t i_blocksize);
/*!
Set the drive speed.
Set the drive speed in CD-ROM speed units.
@param p_cdio CD structure set by cdio_open().
@param i_drive_speed speed in CD-ROM speed units. Note this
not Kbs as would be used in the MMC spec or
in mmc_set_speed(). To convert CD-ROM speed units
to Kbs, multiply the number by 176 (for raw data)
and by 150 (for filesystem data). On many CD-ROM
drives, specifying a value too large will result
in using the fastest speed.
@return the drive speed if greater than 0. -1 if we had an error. is -2
returned if this is not implemented for the current driver.
@see cdio_set_speed and mmc_set_speed
*/
driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio, int i_speed );
driver_return_code_t mmc_set_drive_speed( const CdIo_t *p_cdio,
int i_drive_speed );
/*!
Set the drive speed in K bytes per second.
@param p_cdio CD structure set by cdio_open().
@param i_Kbs_speed speed in K bytes per second. Note this is
not in standard CD-ROM speed units, e.g.
1x, 4x, 16x as it is in cdio_set_speed.
To convert CD-ROM speed units to Kbs,
multiply the number by 176 (for raw data)
and by 150 (for filesystem data).
Also note that ATAPI specs say that a value
less than 176 will result in an error.
On many CD-ROM drives,
specifying a value too large will result in using
the fastest speed.
@return the drive speed if greater than 0. -1 if we had an error. is -2
returned if this is not implemented for the current driver.
@see cdio_set_speed and mmc_set_drive_speed
*/
driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio,
int i_Kbs_speed );
/*!
Load or Unload media using a MMC START STOP command.

View File

@@ -1,5 +1,5 @@
/*
$Id: win32.c,v 1.34 2006/03/28 13:16:09 rocky Exp $
$Id: win32.c,v 1.35 2006/04/04 02:06:13 rocky Exp $
Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein
<rockyb@users.sourceforge.net>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32.c,v 1.34 2006/03/28 13:16:09 rocky Exp $";
static const char _rcsid[] = "$Id: win32.c,v 1.35 2006/04/04 02:06:13 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
@@ -953,7 +953,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
_funcs.run_mmc_cmd = run_mmc_cmd_win32;
_funcs.set_arg = set_arg_win32;
_funcs.set_blocksize = set_blocksize_mmc;
_funcs.set_speed = set_speed_mmc;
_funcs.set_speed = set_drive_speed_mmc;
_data = calloc(1, sizeof (_img_private_t));
_data->access_mode = str_to_access_mode_win32(psz_access_mode);

View File

@@ -1,5 +1,5 @@
/*
$Id: device.c,v 1.38 2006/03/28 03:26:16 rocky Exp $
$Id: device.c,v 1.39 2006/04/04 02:06:13 rocky Exp $
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -996,7 +996,16 @@ cdio_set_blocksize ( const CdIo_t *p_cdio, int i_blocksize )
/*!
Set the drive speed.
@see cdio_set_speed
@param p_cdio CD structure set by cdio_open().
@param i_drive_speed speed in CD-ROM speed units. Note this
not Kbs as would be used in the MMC spec or
in mmc_set_speed(). To convert CD-ROM speed units
to Kbs, multiply the number by 176 (for raw data)
and by 150 (for filesystem data). On many CD-ROM
drives, specifying a value too large will result
in using the fastest speed.
@see mmc_set_speed and mmc_set_drive_speed
*/
driver_return_code_t
cdio_set_speed (const CdIo_t *p_cdio, int i_speed)

View File

@@ -1,5 +1,5 @@
/*
$Id: gnu_linux.c,v 1.21 2006/04/03 19:31:18 rocky Exp $
$Id: gnu_linux.c,v 1.22 2006/04/04 02:06:13 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.21 2006/04/03 19:31:18 rocky Exp $";
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.22 2006/04/04 02:06:13 rocky Exp $";
#include <string.h>
@@ -1216,12 +1216,12 @@ static char checklist2[][40] = {
/* Set CD-ROM drive speed */
static driver_return_code_t
set_speed_linux (void *p_user_data, int i_speed)
set_speed_linux (void *p_user_data, int i_drive_speed)
{
const _img_private_t *p_env = p_user_data;
if (!p_env) return DRIVER_OP_UNINIT;
return ioctl(p_env->gen.fd, CDROM_SELECT_SPEED, i_speed);
return ioctl(p_env->gen.fd, CDROM_SELECT_SPEED, i_drive_speed);
}
#endif /* HAVE_LINUX_CDROM */

View File

@@ -153,6 +153,7 @@ cdio_read_sector
cdio_read_sectors
cdio_set_arg
cdio_set_blocksize
cdio_set_drive_speed
cdio_set_speed
cdio_stdio_destroy
cdio_stdio_new

View File

@@ -1,6 +1,6 @@
/* Common Multimedia Command (MMC) routines.
$Id: mmc.c,v 1.31 2006/04/03 19:31:18 rocky Exp $
$Id: mmc.c,v 1.32 2006/04/04 02:06:13 rocky Exp $
Copyright (C) 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -1338,6 +1338,30 @@ mmc_set_blocksize ( const CdIo_t *p_cdio, uint16_t i_blocksize)
}
/*!
Set the drive speed in CD-ROM speed units.
@param p_cdio CD structure set by cdio_open().
@param i_drive_speed speed in CD-ROM speed units. Note this
not Kbytes/sec as would be used in the MMC spec or
in mmc_set_speed(). To convert CD-ROM speed units
to Kbs, multiply the number by 176 (for raw data)
and by 150 (for filesystem data). On many CD-ROM
drives, specifying a value too large will result
in using the fastest speed.
@return the drive speed if greater than 0. -1 if we had an error. is -2
returned if this is not implemented for the current driver.
@see cdio_set_speed and mmc_set_speed
*/
driver_return_code_t
mmc_set_drive_speed( const CdIo_t *p_cdio, int i_drive_speed )
{
return mmc_set_speed(p_cdio, i_drive_speed * 176);
}
/*!
Set the drive speed.
@@ -1345,7 +1369,7 @@ mmc_set_blocksize ( const CdIo_t *p_cdio, uint16_t i_blocksize)
returned if this is not implemented for the current driver.
*/
int
mmc_set_speed( const CdIo_t *p_cdio, int i_speed )
mmc_set_speed( const CdIo_t *p_cdio, int i_Kbs_speed )
{
uint8_t buf[14] = { 0, };
@@ -1355,11 +1379,11 @@ mmc_set_speed( const CdIo_t *p_cdio, int i_speed )
will return an error - it's part of the ATAPI specs. Therefore,
test and stop early. */
if ( i_speed < 1 ) return -1;
if ( i_Kbs_speed < 176 ) return -1;
memset(&cdb, 0, sizeof(mmc_cdb_t));
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_SET_SPEED);
CDIO_MMC_SET_LEN16(cdb.field, 2, i_speed);
CDIO_MMC_SET_LEN16(cdb.field, 2, i_Kbs_speed);
/* Some drives like the Creative 24x CDRW require one to set a
nonzero write speed or else one gets an error back. Some
specifications have setting the value 0xfffff indicate setting to

View File

@@ -1,5 +1,5 @@
/*
$Id: mmc-tool.c,v 1.1 2006/04/04 00:20:48 rocky Exp $
$Id: mmc-tool.c,v 1.2 2006/04/04 02:06:13 rocky Exp $
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com>
@@ -87,7 +87,7 @@ parse_options (int argc, char *argv[])
" current setting.\n"
" -e, --eject eject drive\n"
" -m, --mcn get media catalog number (AKA UPC)\n"
" -s, --speed=INT Set drive speed to SPEED Kb/s\n"
" -s, --speed=INT Set drive speed to SPEED K bytes/sec\n"
" Note: 1x = 4234KB/s \n"
" -V, --version display version and copyright information\n"
" and exit\n"