Start populating mmc/mmc_hl_cmds.c. Create mmc directory in preparation
for making it a library.
mmc.h: CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL ->
CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
mmc.c: Move mm_eject_media and mmc_set_drive_speed to mmc/mmc_hl_cmds.c
mmc_ll_cmds.c: add mmc_prevent_allow_medium_removal,
move mmc_mode_sense to mmc/mmc_hl_cmds.c
This commit is contained in:
@@ -172,7 +172,8 @@ extern "C" {
|
|||||||
settings. (6 bytes). */
|
settings. (6 bytes). */
|
||||||
CDIO_MMC_GPCMD_START_STOP_UNIT = 0x1b, /**< Enable/disable Disc
|
CDIO_MMC_GPCMD_START_STOP_UNIT = 0x1b, /**< Enable/disable Disc
|
||||||
operations. (6 bytes). */
|
operations. (6 bytes). */
|
||||||
CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL = 0x1e, /**< Enable/disable Disc
|
CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
|
||||||
|
= 0x1e, /**< Enable/disable Disc
|
||||||
removal. (6 bytes). */
|
removal. (6 bytes). */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,17 +614,6 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
|
|||||||
*/
|
*/
|
||||||
const char *mmc_audio_state2str( uint8_t i_audio_state );
|
const char *mmc_audio_state2str( uint8_t i_audio_state );
|
||||||
|
|
||||||
/**
|
|
||||||
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_unit.
|
|
||||||
|
|
||||||
@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
|
|
||||||
*/
|
|
||||||
driver_return_code_t mmc_eject_media( const CdIo_t *p_cdio );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a string containing the name of the given feature
|
Return a string containing the name of the given feature
|
||||||
*/
|
*/
|
||||||
@@ -927,6 +917,8 @@ extern cdio_mmc_mode_page_t debug_cdio_mmc_mode_page;
|
|||||||
|
|
||||||
#ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
|
#ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
|
||||||
#define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
|
#define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
|
||||||
|
#define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL \
|
||||||
|
CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
|
||||||
#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
|
#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
|
||||||
|
|
||||||
#endif /* __MMC_H__ */
|
#endif /* __MMC_H__ */
|
||||||
|
|||||||
@@ -39,6 +39,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/**
|
||||||
|
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_unit.
|
||||||
|
|
||||||
|
@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
|
||||||
|
*/
|
||||||
|
driver_return_code_t mmc_eject_media( const CdIo_t *p_cdio );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return results of media status
|
Return results of media status
|
||||||
|
|
||||||
@@ -114,6 +125,22 @@ extern "C" {
|
|||||||
driver_return_code_t mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf,
|
driver_return_code_t mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf,
|
||||||
unsigned int i_size, int page);
|
unsigned int i_size, int page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Request preventing/allowing medium removal on a drive via
|
||||||
|
SCSI-MMC PREVENT/ALLOW MEDIUM REMOVAL.
|
||||||
|
|
||||||
|
@param p_cdio the CD object to be acted upon.
|
||||||
|
@param b_prevent true of drive locked and false if unlocked
|
||||||
|
@param b_persisent make b_prevent state persistent
|
||||||
|
|
||||||
|
@return DRIVER_OP_SUCCESS (0) if we got the status.
|
||||||
|
return codes are the same as driver_return_code_t
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
mmc_prevent_allow_medium_removal(const CdIo_t *p_cdio,
|
||||||
|
bool b_persistent, bool b_prevent,
|
||||||
|
unsigned int i_timeout_ms);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Issue a MMC READ_CD command.
|
Issue a MMC READ_CD command.
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ static const char _rcsid[] = "$Id: gnu_linux.c,v 1.33 2008/06/25 07:46:21 rocky
|
|||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
#include <cdio/types.h>
|
#include <cdio/types.h>
|
||||||
#include <cdio/mmc.h>
|
#include <cdio/mmc.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
#include <cdio/audio.h>
|
#include <cdio/audio.h>
|
||||||
#include <cdio/cdtext.h>
|
#include <cdio/cdtext.h>
|
||||||
#include "cdtext_private.h"
|
#include "cdtext_private.h"
|
||||||
|
|||||||
@@ -1059,36 +1059,6 @@ mmc_close_tray( 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.
|
|
||||||
|
|
||||||
@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
|
|
||||||
*/
|
|
||||||
driver_return_code_t
|
|
||||||
mmc_eject_media( const CdIo_t *p_cdio )
|
|
||||||
{
|
|
||||||
int i_status = 0;
|
|
||||||
mmc_cdb_t cdb = {{0, }};
|
|
||||||
uint8_t buf[1];
|
|
||||||
|
|
||||||
if ( ! p_cdio ) return DRIVER_OP_UNINIT;
|
|
||||||
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
|
||||||
|
|
||||||
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL);
|
|
||||||
|
|
||||||
i_status = p_cdio->op.run_mmc_cmd (p_cdio->env, mmc_timeout_ms,
|
|
||||||
mmc_get_cmd_len(cdb.field[0]), &cdb,
|
|
||||||
SCSI_MMC_DATA_WRITE, 0, &buf);
|
|
||||||
if (0 != i_status) return i_status;
|
|
||||||
|
|
||||||
return mmc_start_stop_unit(p_cdio, true, false, 0, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a string containing the name of the given feature
|
Return a string containing the name of the given feature
|
||||||
*/
|
*/
|
||||||
@@ -1370,30 +1340,6 @@ 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local variables:
|
* Local variables:
|
||||||
|
|||||||
@@ -20,3 +20,72 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
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.
|
||||||
|
|
||||||
|
@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
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
mmc_eject_media( const CdIo_t *p_cdio )
|
||||||
|
{
|
||||||
|
int i_status = 0;
|
||||||
|
i_status = mmc_prevent_allow_medium_removal(p_cdio, false, false, 0);
|
||||||
|
if (0 != i_status) return i_status;
|
||||||
|
|
||||||
|
return mmc_start_stop_unit(p_cdio, true, false, 0, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run a SCSI-MMC MMC MODE SENSE command (6- or 10-byte version)
|
||||||
|
and put the results in p_buf
|
||||||
|
@param p_cdio the CD object to be acted upon.
|
||||||
|
@param p_buf pointer to location to store mode sense information
|
||||||
|
@param i_size number of bytes allocated to p_buf
|
||||||
|
@param page which "page" of the mode sense command we are interested in
|
||||||
|
@return DRIVER_OP_SUCCESS if we ran the command ok.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
mmc_mode_sense(CdIo_t *p_cdio, /*out*/ void *p_buf, unsigned int i_size,
|
||||||
|
int page)
|
||||||
|
{
|
||||||
|
/* We used to make a choice as to which routine we'd use based
|
||||||
|
cdio_have_atapi(). But since that calls this in its determination,
|
||||||
|
we had an infinite recursion. So we can't use cdio_have_atapi()
|
||||||
|
(until we put in better capability checks.)
|
||||||
|
*/
|
||||||
|
if ( DRIVER_OP_SUCCESS == mmc_mode_sense_6(p_cdio, p_buf, i_size, page) )
|
||||||
|
return DRIVER_OP_SUCCESS;
|
||||||
|
return mmc_mode_sense_10(p_cdio, p_buf, i_size, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,35 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
Request preventing/allowing medium removal on a drive via
|
||||||
|
SCSI-MMC PREVENT/ALLOW MEDIUM REMOVAL.
|
||||||
|
|
||||||
|
@param p_cdio the CD object to be acted upon.
|
||||||
|
@param b_prevent true of drive locked and false if unlocked
|
||||||
|
@param b_persisent make b_prevent state persistent
|
||||||
|
|
||||||
|
@return DRIVER_OP_SUCCESS (0) if we got the status.
|
||||||
|
return codes are the same as driver_return_code_t
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
mmc_prevent_allow_medium_removal(const CdIo_t *p_cdio,
|
||||||
|
bool b_persistent, bool b_prevent,
|
||||||
|
unsigned int i_timeout_ms)
|
||||||
|
{
|
||||||
|
uint8_t buf[8] = { 0, };
|
||||||
|
void *p_buf = &buf;
|
||||||
|
const unsigned int i_size = 0;
|
||||||
|
driver_return_code_t i_status;
|
||||||
|
|
||||||
|
MMC_CMD_SETUP(CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL);
|
||||||
|
if (0 == i_timeout_ms) i_timeout_ms = mmc_timeout_ms;
|
||||||
|
if (b_prevent) cdb.field[4] |= 1;
|
||||||
|
if (b_persistent) cdb.field[4] |= 2;
|
||||||
|
|
||||||
|
return MMC_RUN_CMD(SCSI_MMC_DATA_WRITE, i_timeout_ms);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return results of media status
|
Return results of media status
|
||||||
@param p_cdio the CD object to be acted upon.
|
@param p_cdio the CD object to be acted upon.
|
||||||
@@ -57,7 +86,6 @@ mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2])
|
|||||||
}
|
}
|
||||||
return i_status;
|
return i_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Run a SCSI-MMC MODE SELECT (10-byte) command
|
Run a SCSI-MMC MODE SELECT (10-byte) command
|
||||||
and put the results in p_buf.
|
and put the results in p_buf.
|
||||||
@@ -87,29 +115,6 @@ mmc_mode_select_10(CdIo_t *p_cdio, /*out*/ void *p_buf, unsigned int i_size,
|
|||||||
return MMC_RUN_CMD(SCSI_MMC_DATA_WRITE, i_timeout_ms);
|
return MMC_RUN_CMD(SCSI_MMC_DATA_WRITE, i_timeout_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Run a SCSI-MMC MMC MODE SENSE command (6- or 10-byte version)
|
|
||||||
and put the results in p_buf
|
|
||||||
@param p_cdio the CD object to be acted upon.
|
|
||||||
@param p_buf pointer to location to store mode sense information
|
|
||||||
@param i_size number of bytes allocated to p_buf
|
|
||||||
@param page which "page" of the mode sense command we are interested in
|
|
||||||
@return DRIVER_OP_SUCCESS if we ran the command ok.
|
|
||||||
*/
|
|
||||||
driver_return_code_t
|
|
||||||
mmc_mode_sense(CdIo_t *p_cdio, /*out*/ void *p_buf, unsigned int i_size,
|
|
||||||
int page)
|
|
||||||
{
|
|
||||||
/* We used to make a choice as to which routine we'd use based
|
|
||||||
cdio_have_atapi(). But since that calls this in its determination,
|
|
||||||
we had an infinite recursion. So we can't use cdio_have_atapi()
|
|
||||||
(until we put in better capability checks.)
|
|
||||||
*/
|
|
||||||
if ( DRIVER_OP_SUCCESS == mmc_mode_sense_6(p_cdio, p_buf, i_size, page) )
|
|
||||||
return DRIVER_OP_SUCCESS;
|
|
||||||
return mmc_mode_sense_10(p_cdio, p_buf, i_size, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Run a SCSI-MMC MODE SENSE command (10-byte version)
|
Run a SCSI-MMC MODE SENSE command (10-byte version)
|
||||||
and put the results in p_buf
|
and put the results in p_buf
|
||||||
|
|||||||
Reference in New Issue
Block a user