#include <cdio/cdio.h>
#include <cdio/types.h>
#include <cdio/dvd.h>
#include <cdio/audio.h>
Go to the source code of this file.
#define CDIO_MMC_GET_LEN16 | ( | p | ) | (p[0]<<8) + p[1] |
#define CDIO_MMC_GET_LEN32 | ( | p | ) | (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3]; |
#define CDIO_MMC_GETPOS_LEN16 | ( | p, | |||
pos | ) | (p[pos]<<8) + p[pos+1] |
#define CDIO_MMC_MCSB_ALL_HEADERS 0xf |
#define CDIO_MMC_SET_COMMAND | ( | cdb, | |||
command | ) | cdb[0] = command |
#define CDIO_MMC_SET_LEN16 | ( | cdb, | |||
pos, | |||||
len | ) |
Value:
cdb[pos ] = (len >> 8) & 0xff; \ cdb[pos+1] = (len ) & 0xff
#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS | ( | cdb, | |||
val | ) | cdb[9] = val << 3; |
#define CDIO_MMC_SET_READ_LBA | ( | cdb, | |||
lba | ) |
Value:
cdb[2] = (lba >> 24) & 0xff; \ cdb[3] = (lba >> 16) & 0xff; \ cdb[4] = (lba >> 8) & 0xff; \ cdb[5] = (lba ) & 0xff
#define CDIO_MMC_SET_READ_LENGTH16 | ( | cdb, | |||
len | ) | CDIO_MMC_SET_LEN16(cdb, 7, len) |
#define CDIO_MMC_SET_READ_LENGTH24 | ( | cdb, | |||
len | ) |
Value:
cdb[6] = (len >> 16) & 0xff; \ cdb[7] = (len >> 8) & 0xff; \ cdb[8] = (len ) & 0xff
#define CDIO_MMC_SET_READ_LENGTH8 | ( | cdb, | |||
len | ) | cdb[8] = (len ) & 0xff |
#define CDIO_MMC_SET_READ_TYPE | ( | cdb, | |||
sector_type | ) | cdb[1] = (sector_type << 2) |
#define CDIO_MMC_SET_START_TRACK | ( | cdb, | |||
command | ) | cdb[6] = command |
#define MAX_CDB_LEN 12 |
The largest Command Descriptor Block (CDB) size. The possible sizes are 6, 10, and 12 bytes.
#define MMC_READ_TIMEOUT_DEFAULT 3*60*1000 |
The default read timeout is 3 minutes.
#define MMC_TIMEOUT_DEFAULT 6000 |
The default timeout (non-read) is 6 seconds.
typedef enum mmc_direction_s cdio_mmc_direction_t |
An enumeration indicating whether an MMC command is sending data or getting data.
typedef struct mmc_feature_list_header_s cdio_mmc_feature_list_header_t |
Format of header block in data returned from an MMC GET_CONFIGURATION command.
typedef struct mmc_subchannel_s cdio_mmc_subchannel_t |
typedef struct mmc_audio_volume_entry_s mmc_audio_volume_entry_t |
typedef struct mmc_audio_volume_s mmc_audio_volume_t |
Profile profile codes used in GET_CONFIGURATION - PROFILE LIST.
enum cdio_mmc_feature_t |
FEATURE codes used in GET CONFIGURATION.
enum cdio_mmc_get_conf_t |
Return type codes for GET_CONFIGURATION.
enum cdio_mmc_gpcmd_t |
The opcode-portion (generic packet commands) of an MMC command.
In general, those opcodes that end in 6 take a 6-byte command descriptor, those that end in 10 take a 10-byte descriptor and those that in in 12 take a 12-byte descriptor.
(Not that you need to know that, but it seems to be a big deal in the MMC specification.)
enum cdio_mmc_level_t |
enum cdio_mmc_mode_page_t |
Level values that can go into READ_CD
Read Subchannel states
enum cdio_mmc_readtoc_t |
enum mmc_direction_s |
driver_return_code_t mmc_audio_get_volume | ( | CdIo_t * | p_cdio, | |
mmc_audio_volume_t * | p_volume | |||
) |
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.
driver_return_code_t mmc_audio_read_subchannel | ( | CdIo_t * | p_cdio, | |
cdio_subchannel_t * | p_subchannel | |||
) |
Read Audio Subchannel information
p_cdio | the CD object to be acted upon. | |
p_subchannel | place for returned subchannel information |
const char* mmc_audio_state2str | ( | uint8_t | i_audio_state | ) |
Return a string containing the name of the audio state as returned from the Q_SUBCHANNEL.
driver_return_code_t mmc_close_tray | ( | CdIo_t * | p_cdio | ) |
Close tray using a MMC START STOP command.
driver_return_code_t mmc_eject_media | ( | const 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,
const char* mmc_feature2str | ( | int | i_feature | ) |
Return a string containing the name of the given feature
const char* mmc_feature_profile2str | ( | int | i_feature_profile | ) |
Return a string containing the name of the given feature
int mmc_get_blocksize | ( | CdIo_t * | p_cdio | ) |
Get the block size used in read requests, via MMC.
uint8_t mmc_get_cmd_len | ( | uint8_t | mmc_cmd | ) |
Return the length in bytes of the Command Descriptor Buffer (CDB) for a given MMC command. The length will be either 6, 10, or 12.
Get the lsn of the end of the CD
discmode_t mmc_get_discmode | ( | const CdIo_t * | p_cdio | ) |
Return the discmode as reported by the MMC Read (FULL) TOC command.
Information was obtained from Section 5.1.13 (Read TOC/PMA/ATIP) pages 56-62 from the MMC draft specification, revision 10a at http://www.t10.org/ftp/t10/drafts/mmc/mmc-r10a.pdf See especially tables 72, 73 and 75.
void mmc_get_drive_cap | ( | CdIo_t * | p_cdio, | |
cdio_drive_read_cap_t * | p_read_cap, | |||
cdio_drive_write_cap_t * | p_write_cap, | |||
cdio_drive_misc_cap_t * | p_misc_cap | |||
) |
Get drive capabilities for a device.
cdio_mmc_level_t mmc_get_drive_mmc_cap | ( | CdIo_t * | p_cdio | ) |
Get the MMC level supported by the device.
discmode_t mmc_get_dvd_struct_physical | ( | const CdIo_t * | p_cdio, | |
cdio_dvd_struct_t * | s | |||
) |
Get the DVD type associated with cd object.
int mmc_get_event_status | ( | const CdIo_t * | p_cdio, | |
uint8_t | out_buf[2] | |||
) |
Return results of media status
p_cdio | the CD object to be acted upon. | |
out_buf | media status code from operation |
bool mmc_get_hwinfo | ( | const CdIo_t * | p_cdio, | |
cdio_hwinfo_t * | p_hw_info | |||
) |
Get the CD-ROM hardware info via an MMC INQUIRY command.
char* mmc_get_mcn | ( | const CdIo_t * | p_cdio | ) |
Get the media catalog number (MCN) from the CD via MMC.
int mmc_get_media_changed | ( | const CdIo_t * | p_cdio | ) |
Find out if media has changed since the last call.
p_cdio | the CD object to be acted upon. |
int mmc_get_tray_status | ( | const CdIo_t * | p_cdio | ) |
Find out if media tray is open or closed.
p_cdio | the CD object to be acted upon. |
bool_3way_t mmc_have_interface | ( | CdIo_t * | p_cdio, | |
cdio_mmc_feature_interface_t | e_interface | |||
) |
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.
int mmc_mode_sense | ( | CdIo_t * | p_cdio, | |
void * | p_buf, | |||
int | i_size, | |||
int | page | |||
) |
Run a MODE_SENSE command (6- or 10-byte version) and put the results in p_buf
int mmc_mode_sense_10 | ( | CdIo_t * | p_cdio, | |
void * | p_buf, | |||
int | i_size, | |||
int | page | |||
) |
Run a MODE_SENSE command (10-byte version) and put the results in p_buf
int mmc_mode_sense_6 | ( | CdIo_t * | p_cdio, | |
void * | p_buf, | |||
int | i_size, | |||
int | page | |||
) |
Run a MODE_SENSE command (6-byte version) and put the results in p_buf
driver_return_code_t mmc_read_cd | ( | const CdIo_t * | p_cdio, | |
void * | p_buf, | |||
lsn_t | i_lsn, | |||
int | expected_sector_type, | |||
bool | b_digital_audio_play, | |||
bool | b_sync, | |||
uint8_t | header_codes, | |||
bool | b_user_data, | |||
bool | b_edc_ecc, | |||
uint8_t | c2_error_information, | |||
uint8_t | subchannel_selection, | |||
uint16_t | i_blocksize, | |||
uint32_t | i_blocks | |||
) |
Issue a MMC READ_CD command.
p_cdio | object to read from | |
p_buf | Place to store data. The caller should ensure that p_buf can hold at least i_blocksize * i_blocks bytes. | |
i_lsn | sector to read | |
expected_sector_type | restricts reading to a specific CD sector type. Only 3 bits with values 1-5 are used: 0 all sector types 1 CD-DA sectors only 2 Mode 1 sectors only 3 Mode 2 formless sectors only. Note in contrast to all other values an MMC CD-ROM is not required to support this mode. 4 Mode 2 Form 1 sectors only 5 Mode 2 Form 2 sectors only | |
b_digital_audio_play | Control error concealment when the data being read is CD-DA. If the data being read is not CD-DA, this parameter is ignored. If the data being read is CD-DA and DAP is false zero, then the user data returned should not be modified by flaw obscuring mechanisms such as audio data mute and interpolate. If the data being read is CD-DA and DAP is true, then the user data returned should be modified by flaw obscuring mechanisms such as audio data mute and interpolate. |
header_codes | Header Codes refer to the sector header and the sub-header that is present in mode 2 formed sectors: |
b_user_data | Return user data if true. |
For Mode 1, The User Data is ISO_BLOCKSIZE bytes beginning at offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
For Mode 2 formless, The User Data is M2RAW_SECTOR_SIZE bytes beginning at offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
For data Mode 2, form 1, User Data is ISO_BLOCKSIZE bytes beginning at offset CDIO_CD_XA_SYNC_HEADER.
For data Mode 2, form 2, User Data is 2 324 bytes beginning at offset CDIO_CD_XA_SYNC_HEADER.
b_sync | ||
b_edc_ecc | true if we return EDC/ECC error detection/correction bits. |
CD-DA sectors have neither EDC redundancy nor ECC parity.
Data Mode 1 sectors have 288 bytes of EDC redundancy, Pad, and ECC parity beginning at offset 2064.
Data Mode 2 formless sectors have neither EDC redundancy nor ECC parity
Data Mode 2 form 1 sectors have 280 bytes of EDC redundancy and ECC parity beginning at offset 2072
Data Mode 2 form 2 sectors optionally have 4 bytes of EDC redundancy beginning at offset 2348.
c2_error_information | If true associate a bit with each sector for C2 error The resulting bit field is ordered exactly as the main channel bytes. Each 8-bit boundary defines a byte of flag bits. | |
subchannel_selection | subchannel-selection bits |
i_blocksize | size of the a block expected to be returned | |
i_blocks | number of blocks expected to be returned. |
driver_return_code_t mmc_read_data_sectors | ( | CdIo_t * | p_cdio, | |
void * | p_buf, | |||
lsn_t | i_lsn, | |||
uint16_t | i_blocksize, | |||
uint32_t | i_blocks | |||
) |
Read just the user data part of some sort of data sector (via mmc_read_cd).
p_cdio | object to read from | |
p_buf | place to read data into. The caller should make sure this location can store at least CDIO_CD_FRAMESIZE, M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending on the kind of sector getting read. If you don't know whether you have a Mode 1/2, Form 1/ Form 2/Formless sector best to reserve space for the maximum, M2RAW_SECTOR_SIZE. | |
i_lsn | sector to read | |
i_blocksize | size of each block | |
i_blocks | number of blocks to read |
driver_return_code_t mmc_read_sectors | ( | const CdIo_t * | p_cdio, | |
void * | p_buf, | |||
lsn_t | i_lsn, | |||
int | read_sector_type, | |||
uint32_t | i_blocks | |||
) |
Read sectors using SCSI-MMC GPCMD_READ_CD. Can read only up to 25 blocks.
int mmc_run_cmd | ( | const CdIo_t * | p_cdio, | |
unsigned int | i_timeout_ms, | |||
const mmc_cdb_t * | p_cdb, | |||
cdio_mmc_direction_t | e_direction, | |||
unsigned int | i_buf, | |||
void * | p_buf | |||
) |
Run a Multimedia command (MMC).
p_cdio | CD structure set by cdio_open(). | |
i_timeout_ms | time in milliseconds we will wait for the command to complete. | |
p_cdb | CDB bytes. All values that are needed should be set on input. We'll figure out what the right CDB length should be. | |
e_direction | direction the transfer is to go. | |
i_buf | Size of buffer | |
p_buf | Buffer for data, both sending and receiving. |
int mmc_run_cmd_len | ( | const CdIo_t * | p_cdio, | |
unsigned int | i_timeout_ms, | |||
const mmc_cdb_t * | p_cdb, | |||
unsigned int | i_cdb, | |||
cdio_mmc_direction_t | e_direction, | |||
unsigned int | i_buf, | |||
void * | p_buf | |||
) |
Run a Multimedia command (MMC) specifying the CDB length. The motivation here is for example ot use in is an undocumented debug command for LG drives (namely E7), whose length is being miscalculated by mmc_get_cmd_len(); it doesn't follow the usual code number to length conventions. Patch supplied by SukkoPera.
p_cdio | CD structure set by cdio_open(). | |
i_timeout_ms | time in milliseconds we will wait for the command to complete. | |
p_cdb | CDB bytes. All values that are needed should be set on input. | |
i_cdb | number of CDB bytes. | |
e_direction | direction the transfer is to go. | |
i_buf | Size of buffer | |
p_buf | Buffer for data, both sending and receiving. |
driver_return_code_t mmc_set_blocksize | ( | const CdIo_t * | p_cdio, | |
uint16_t | i_blocksize | |||
) |
Set the block size for subsequest read requests, via MMC.
driver_return_code_t mmc_set_drive_speed | ( | const CdIo_t * | p_cdio, | |
int | i_drive_speed | |||
) |
Set the drive speed in CD-ROM speed units.
p_cdio | CD structure set by cdio_open(). | |
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. |
driver_return_code_t mmc_set_speed | ( | const CdIo_t * | p_cdio, | |
int | i_Kbs_speed | |||
) |
Set the drive speed in K bytes per second.
p_cdio | CD structure set by cdio_open(). | |
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. |
driver_return_code_t mmc_start_stop_media | ( | const CdIo_t * | p_cdio, | |
bool | b_eject, | |||
bool | b_immediate, | |||
uint8_t | power_condition | |||
) |
Load or Unload media using a MMC START STOP command.
p_cdio | the CD object to be acted upon. | |
b_eject | eject if true and close tray if false | |
b_immediate | wait or don't wait for operation to complete | |
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. |
The below variables are trickery to force the above enum symbol values to be recorded in debug symbol tables. They are used to allow one to refer to the enumeration value names in the typedefs above in a debugger and debugger expressions
struct mmc_audio_volume_s GNUC_PACKED |
This struct is used by cdio_audio_get_volume and cdio_audio_set_volume
uint32_t mmc_read_timeout_ms |
Set this to the maximum value in milliseconds that we will wait on an MMC read command.
uint32_t mmc_timeout_ms |
Set this to the maximum value in milliseconds that we will wait on an MMC command.