Small cleanups

This commit is contained in:
R. Bernstein
2010-02-06 23:27:46 -05:00
parent f93e673fd5
commit 51f6eb6912
4 changed files with 182 additions and 166 deletions

View File

@@ -906,30 +906,6 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
driver_return_code_t mmc_set_drive_speed( const CdIo_t *p_cdio, driver_return_code_t mmc_set_drive_speed( const CdIo_t *p_cdio,
int i_drive_speed ); 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 );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@@ -194,6 +194,31 @@ extern "C" {
uint8_t subchannel_selection, uint16_t i_blocksize, uint8_t subchannel_selection, uint16_t i_blocksize,
uint32_t i_blocks ); uint32_t i_blocks );
/**
Set the drive speed in K bytes per second using SCSI-MMC SET SPEED.
.
@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 UNIT command. Load or Unload media using a MMC START STOP UNIT command.

View File

@@ -630,9 +630,8 @@ mmc_get_cmd_len(uint8_t scsi_cmd)
@return true if the disc is detected as erasable (rewritable), false @return true if the disc is detected as erasable (rewritable), false
otherwise. otherwise.
*/ */
bool bool mmc_get_disc_erasable(const CdIo_t *p_cdio,
mmc_get_disc_erasable( const CdIo_t *p_cdio, driver_return_code_t *opt_i_status) {
driver_return_code_t *opt_i_status ) {
mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
uint8_t buf[42] = { 0, }; uint8_t buf[42] = { 0, };
driver_return_code_t i_status; driver_return_code_t i_status;
@@ -640,7 +639,7 @@ bool
CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_DISC_INFO); CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_DISC_INFO);
CDIO_MMC_SET_READ_LENGTH8 (cdb.field, sizeof(buf)); CDIO_MMC_SET_READ_LENGTH8 (cdb.field, sizeof(buf));
i_status = mmc_run_cmd (p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, i_status = mmc_run_cmd(p_cdio, 0, &cdb, SCSI_MMC_DATA_READ,
sizeof(buf), &buf); sizeof(buf), &buf);
if (opt_i_status != NULL) *opt_i_status = i_status; if (opt_i_status != NULL) *opt_i_status = i_status;
return (DRIVER_OP_SUCCESS == i_status) ? return (DRIVER_OP_SUCCESS == i_status) ?
@@ -967,7 +966,7 @@ int mmc_get_tray_status(const CdIo_t *p_cdio)
bytes available, <0 in case of internal error. bytes available, <0 in case of internal error.
*/ */
int int
mmc_last_cmd_sense( const CdIo_t *p_cdio, mmc_request_sense_t **pp_sense) mmc_last_cmd_sense(const CdIo_t *p_cdio, mmc_request_sense_t **pp_sense)
{ {
generic_img_private_t *gen; generic_img_private_t *gen;
@@ -1371,7 +1370,7 @@ mmc_set_blocksize ( const CdIo_t *p_cdio, uint16_t i_blocksize)
} }
/*! /**
Set the drive speed in CD-ROM speed units. Set the drive speed in CD-ROM speed units.
@param p_cdio CD structure set by cdio_open(). @param p_cdio CD structure set by cdio_open().
@@ -1395,38 +1394,6 @@ mmc_set_drive_speed( const CdIo_t *p_cdio, int i_drive_speed )
} }
/*!
Set the drive speed in K bytes per second.
@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.
*/
int
mmc_set_speed( const CdIo_t *p_cdio, int i_Kbs_speed )
{
uint8_t buf[14] = { 0, };
mmc_cdb_t cdb;
/* If the requested speed is less than 1x 176 kb/s this command
will return an error - it's part of the ATAPI specs. Therefore,
test and stop early. */
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_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
the maximum allowable speed.
*/
CDIO_MMC_SET_LEN16(cdb.field, 4, 0xffff);
return mmc_run_cmd(p_cdio, 2000, &cdb, SCSI_MMC_DATA_WRITE,
sizeof(buf), buf);
}
/* /*
* Local variables: * Local variables:

View File

@@ -317,7 +317,56 @@ mmc_read_cd(const CdIo_t *p_cdio, void *p_buf1, lsn_t i_lsn,
} }
/** /**
Load or Unload media using a MMC START STOP command. Set the drive speed in K bytes per second using SCSI-MMC SET SPEED.
.
@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
*/
int
mmc_set_speed(const CdIo_t *p_cdio, int i_Kbs_speed)
{
uint8_t buf[14] = { 0, };
void * p_buf = &buf;
const unsigned int i_size = sizeof(buf);
MMC_CMD_SETUP(CDIO_MMC_GPCMD_SET_SPEED);
/* If the requested speed is less than 1x 176 kb/s this command
will return an error - it's part of the ATAPI specs. Therefore,
test and stop early. */
if ( i_Kbs_speed < 176 ) return -1;
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
the maximum allowable speed.
*/
CDIO_MMC_SET_LEN16(cdb.field, 4, 0xffff);
return MMC_RUN_CMD(SCSI_MMC_DATA_WRITE);
}
/**
Load or Unload media using a MMC START/STOP UNIT command.
@param p_cdio the CD object to be acted upon. @param p_cdio the CD object to be acted upon.
@param b_eject eject if true and close tray if false @param b_eject eject if true and close tray if false
@@ -350,4 +399,3 @@ mmc_start_stop_unit(const CdIo_t *p_cdio, bool b_eject, bool b_immediate,
return MMC_RUN_CMD(SCSI_MMC_DATA_WRITE); return MMC_RUN_CMD(SCSI_MMC_DATA_WRITE);
} }