lib/driver/mmc.c - DRY code. Warning - might have introduced breakage here

*mmc*: mmc_start_stop_media -> mmc_start_stop_unit,
 CDIO_MMC_GPCMD_START_STOP -> CDIO_MMC_GPCMD_START_STOP_UNIT
cdio++/mmc.hpp: Regularize Doxygen comment format.
This commit is contained in:
R. Bernstein
2010-02-06 22:53:03 -05:00
parent 1687e2633f
commit f93e673fd5
7 changed files with 167 additions and 152 deletions

View File

@@ -1,7 +1,5 @@
/*
$Id: mmc.hpp,v 1.3 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2005, 2006, 2008, 2010 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,12 +15,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file mmc.hpp
/**
* \file mmc.hpp
* \brief methods relating to MMC (Multimedia Commands). This file
* should not be #included directly.
*/
/*!
/**
Read Audio Subchannel information
@param p_cdio the CD object to be acted upon.
@@ -37,10 +36,10 @@ mmcAudioReadSubchannel (/*out*/ cdio_subchannel_t *p_subchannel)
possible_throw_device_exception(drc);
}
/*!
/**
Eject using MMC commands. If CD-ROM is "locked" we'll unlock it.
Command is not "immediate" -- we'll wait for the command to complete.
For a more general (and lower-level) routine, @see mmc_start_stop_media.
For a more general (and lower-level) routine, @see mmc_start_stop_unit.
A DriverOpException is raised on error.
*/
@@ -50,7 +49,7 @@ void mmcEjectMedia()
possible_throw_device_exception(drc);
}
/*!
/**
Get the lsn of the end of the CD
@return the lsn. On error return CDIO_INVALID_LSN.
@@ -60,7 +59,7 @@ lsn_t mmcGetDiscLastLsn()
return mmc_get_disc_last_lsn( p_cdio );
}
/*!
/**
Return the discmode as reported by the MMC Read (FULL) TOC
command.
@@ -74,7 +73,7 @@ discmode_t mmcGetDiscmode()
return mmc_get_discmode( p_cdio );
}
/*!
/**
Get drive capabilities for a device.
@return the drive capabilities.
*/
@@ -85,7 +84,7 @@ void mmcGetDriveCap ( /*out*/ cdio_drive_read_cap_t *p_read_cap,
mmc_get_drive_cap ( p_cdio, p_read_cap, p_write_cap, p_misc_cap);
}
/*!
/**
Get the MMC level supported by the device.
*/
cdio_mmc_level_t mmcGetDriveMmcCap()
@@ -93,7 +92,7 @@ cdio_mmc_level_t mmcGetDriveMmcCap()
return mmc_get_drive_mmc_cap(p_cdio);
}
/*!
/**
Get the DVD type associated with cd object.
@return the DVD discmode.
@@ -103,7 +102,7 @@ discmode_t mmcGetDvdStructPhysical (cdio_dvd_struct_t *s)
return mmc_get_dvd_struct_physical (p_cdio, s);
}
/*!
/**
Get the CD-ROM hardware info via an MMC INQUIRY command.
@return true if we were able to get hardware info, false if we had
@@ -114,7 +113,7 @@ bool mmcGetHwinfo ( /* out*/ cdio_hwinfo_t *p_hw_info )
return mmc_get_hwinfo ( p_cdio, p_hw_info );
}
/*!
/**
Find out if media has changed since the last call.
@param p_cdio the CD object to be acted upon.
@return 1 if media has changed since last call, 0 if not. Error
@@ -125,7 +124,7 @@ int mmcGetMediaChanged()
return mmc_get_media_changed(p_cdio);
}
/*!
/**
Get the media catalog number (MCN) from the CD via MMC.
@return the media catalog number r NULL if there is none or we
@@ -140,7 +139,8 @@ char * mmcGetMcn ()
return mmc_get_mcn ( p_cdio );
}
/** Get the output port volumes and port selections used on AUDIO PLAY
/**
Get the output port volumes and port selections used on AUDIO PLAY
commands via a MMC MODE SENSE command using the CD Audio Control
Page.
@@ -152,7 +152,7 @@ void mmcAudioGetVolume (mmc_audio_volume_t *p_volume)
possible_throw_device_exception(drc);
}
/*!
/**
Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...)
Is it possible for an interface to have serveral? If not this
routine could probably return the single mmc_feature_interface_t.
@@ -163,34 +163,38 @@ bool_3way_t mmcHaveInterface( cdio_mmc_feature_interface_t e_interface )
return mmc_have_interface( p_cdio, e_interface );
}
/*! Run a MODE_SENSE command (6- or 10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
/**
Run a MODE_SENSE command (6- or 10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense( /*out*/ void *p_buf, int i_size, int page)
{
return mmc_mode_sense( p_cdio, /*out*/ p_buf, i_size, page);
}
/*! Run a MODE_SENSE command (10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
/**
Run a MODE_SENSE command (10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense10( /*out*/ void *p_buf, int i_size, int page)
{
return mmc_mode_sense_10( p_cdio, /*out*/ p_buf, i_size, page);
}
/*! Run a MODE_SENSE command (6-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
/**
Run a MODE_SENSE command (6-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense6( /*out*/ void *p_buf, int i_size, int page)
{
return mmc_mode_sense_6( p_cdio, /*out*/ p_buf, i_size, page);
}
/*! Issue a MMC READ_CD command.
/**
Issue a MMC READ_CD command.
@param p_cdio object to read from
@@ -306,7 +310,9 @@ mmcReadCd ( void *p_buf, lsn_t i_lsn, int expected_sector_type,
possible_throw_device_exception(drc);
}
/*! Read just the user data part of some sort of data sector (via
/**
Read just the user data part of some sort of data sector (via
mmc_read_cd).
@param p_cdio object to read from
@@ -333,7 +339,8 @@ void mmcReadDataSectors ( void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
}
/*! Read MMC read mode2 sectors
/**
Read MMC read mode2 sectors
A DriverOpException is raised on error.
*/
@@ -345,7 +352,7 @@ void mmcReadSectors ( void *p_buf, lsn_t i_lsn, int read_sector_type,
possible_throw_device_exception(drc);
}
/*!
/**
Run an MMC command.
@param p_cdio CD structure set by cdio_open().
@@ -367,7 +374,7 @@ int mmcRunCmd( unsigned int i_timeout_ms, const mmc_cdb_t *p_cdb,
return mmc_run_cmd( p_cdio, i_timeout_ms, p_cdb, e_direction, i_buf, p_buf );
}
/*!
/**
Set the block size for subsequent read requests, via MMC.
@param i_blocksize size to set for subsequent requests
@@ -381,7 +388,7 @@ void mmcSetBlocksize ( uint16_t i_blocksize)
}
/*!
/**
Set the drive speed via MMC.
@param i_speed speed to set drive to.
@@ -394,7 +401,7 @@ void mmcSetSpeed( int i_speed )
possible_throw_device_exception(drc);
}
/*!
/**
Load or Unload media using a MMC START STOP command.
@param p_cdio the CD object to be acted upon.
@@ -411,7 +418,7 @@ void mmcStartStopMedia(bool b_eject, bool b_immediate,
uint8_t power_condition)
{
driver_return_code_t drc =
mmc_start_stop_media(p_cdio, b_eject, b_immediate, power_condition);
mmc_start_stop_unit(p_cdio, b_eject, b_immediate, power_condition);
possible_throw_device_exception(drc);
}

View File

@@ -171,7 +171,7 @@ extern "C" {
before MODE SELECT to get
mode support or save current
settings. (6 bytes). */
CDIO_MMC_GPCMD_START_STOP = 0x1b, /**< Enable/disable Disc
CDIO_MMC_GPCMD_START_STOP_UNIT = 0x1b, /**< Enable/disable Disc
operations. (6 bytes). */
CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL = 0x1e, /**< Enable/disable Disc
removal. (6 bytes). */
@@ -617,7 +617,7 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
/**
Eject using MMC commands. If CD-ROM is "locked" we'll unlock it.
Command is not "immediate" -- we'll wait for the command to complete.
For a more general (and lower-level) routine, @see mmc_start_stop_media.
For a more general (and lower-level) routine, @see mmc_start_stop_unit.
@param p_cdio the CD object to be acted upon.
@return DRIVER_OP_SUCCESS (0) if we got the status.
@@ -674,7 +674,7 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
/**
Close tray using a MMC START STOP command.
Close tray using a MMC START STOP UNIT command.
@param p_cdio the CD object to be acted upon.
@return DRIVER_OP_SUCCESS (0) if we got the status.
return codes are the same as driver_return_code_t
@@ -930,21 +930,6 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
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.
@param p_cdio the CD object to be acted upon.
@param b_eject eject if true and close tray if false
@param b_immediate wait or don't wait for operation to complete
@param power_condition Set CD-ROM to idle/standby/sleep. If nonzero,
eject/load is ignored, so set to 0 if you want to eject or load.
@see mmc_eject_media or mmc_close_tray
*/
driver_return_code_t
mmc_start_stop_media(const CdIo_t *p_cdio, bool b_eject, bool b_immediate,
uint8_t power_condition);
#ifdef __cplusplus
}
#endif /* __cplusplus */
@@ -965,6 +950,10 @@ extern cdio_mmc_read_cd_type_t debug_cdio_mmc_read_cd_type;
extern cdio_mmc_readtoc_t debug_cdio_mmc_readtoc;
extern cdio_mmc_mode_page_t debug_cdio_mmc_mode_page;
#ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
#define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
#endif /* __MMC_H__ */
/*

View File

@@ -59,8 +59,8 @@ extern "C" {
@param page which "page" of the mode sense command we are interested in
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
driver_return_code_t mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf,
int i_size, int page);
/**
Run a MODE_SENSE command (10-byte version)
@@ -71,8 +71,8 @@ extern "C" {
@param page which "page" of the mode sense command we are interested in
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmc_mode_sense_10( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
driver_return_code_t mmc_mode_sense_10( CdIo_t *p_cdio, /*out*/ void *p_buf,
int i_size, int page);
/**
Run a MODE_SENSE command (6-byte version)
@@ -83,8 +83,8 @@ extern "C" {
@param page which "page" of the mode sense command we are interested in
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
driver_return_code_t mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf,
int i_size, int page);
/**
Issue a MMC READ_CD command.
@@ -194,6 +194,25 @@ extern "C" {
uint8_t subchannel_selection, uint16_t i_blocksize,
uint32_t i_blocks );
/**
Load or Unload media using a MMC START STOP UNIT command.
@param p_cdio the CD object to be acted upon.
@param b_eject eject if true and close tray if false
@param b_immediate wait or don't wait for operation to complete
@param power_condition Set CD-ROM to idle/standby/sleep. If nonzero,
eject/load is ignored, so set to 0 if you want to eject or load.
@see mmc_eject_media or mmc_close_tray
*/
driver_return_code_t
mmc_start_stop_unit(const CdIo_t *p_cdio, bool b_eject, bool b_immediate,
uint8_t power_condition);
#ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
#define mmc_start_stop_media mmc_start_stop_unit
#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
#ifdef __cplusplus
}
#endif /* __cplusplus */