libcdio
2.1.0
|
Common definitions for MMC (Multimedia Commands). Applications include this for direct MMC access. More...
#include <cdio/cdio.h>
#include <cdio/types.h>
#include <cdio/dvd.h>
#include <cdio/audio.h>
#include <cdio/mmc_util.h>
Go to the source code of this file.
Data Structures | |
struct | cdio_mmc_request_sense |
struct | mmc_audio_volume_entry_s |
struct | mmc_audio_volume_s |
struct | mmc_cdb_s |
A Command Descriptor Block (CDB) used in sending MMC commands. More... | |
struct | mmc_feature_list_header_s |
Format of header block in data returned from an MMC GET_CONFIGURATION command. More... | |
struct | mmc_subchannel_s |
Typedefs | |
typedef struct cdio_mmc_request_sense | cdio_mmc_request_sense_t |
typedef struct mmc_audio_volume_entry_s | mmc_audio_volume_entry_t |
typedef struct mmc_audio_volume_s | mmc_audio_volume_t |
typedef struct mmc_cdb_s | mmc_cdb_t |
A Command Descriptor Block (CDB) used in sending MMC commands. More... | |
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. More... | |
typedef enum mmc_direction_s | cdio_mmc_direction_t |
typedef struct mmc_subchannel_s | cdio_mmc_subchannel_t |
Common definitions for MMC (Multimedia Commands). Applications include this for direct MMC access.
The documents we make use of are described in several specifications made by the SCSI committee T10 http://www.t10.org. In particular, SCSI Primary Commands (SPC), SCSI Block Commands (SBC), and Multi-Media Commands (MMC). These documents generally have a numeric level number appended. For example SPC-3 refers to ``SCSI Primary Commands - 3'.
In year 2010 the current versions were SPC-3, SBC-2, MMC-5.
#define __MMC_LITTLE_ENDIAN_BITFIELD |
#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_GPCMD_ALLOW_MEDIUM_REMOVAL CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL |
#define CDIO_MMC_GPCMD_READ_DISC_INFO CDIO_MMC_GPCMD_READ_DISC_INFORMATION |
#define CDIO_MMC_GPCMD_READ_DISC_STRUCTURE CDIO_MMC_GPMD_READ_DVD_STRUCTURE |
#define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT |
#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 | |||
) |
#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS | ( | cdb, | |
val | |||
) | cdb[9] = val << 3; |
#define CDIO_MMC_SET_READ_LBA | ( | cdb, | |
lba | |||
) |
#define CDIO_MMC_SET_READ_LENGTH16 | ( | cdb, | |
len | |||
) | CDIO_MMC_SET_LEN16(cdb, 7, len) |
#define CDIO_MMC_SET_READ_LENGTH24 | ( | cdb, | |
len | |||
) |
#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 SCSI_MMC_HAS_DIR_NONE 1 |
Indicate to applications that SCSI_MMC_DATA_NONE
is available. It has been added after version 0.82 and should be used with commands that neither read nor write payload bytes. (On Linux, at least, these work with SCSI_MMC_DATA_READ
and SCSI_MMC_DATA_WRITE
, too.)
typedef enum mmc_direction_s cdio_mmc_direction_t |
An enumeration indicating whether an MMC command is sending data, or getting data, or does none of both.
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 cdio_mmc_request_sense cdio_mmc_request_sense_t |
Structure of a SCSI/MMC sense reply.
This has been adapted from GNU/Linux request_sense of <linux/cdrom.h> include this for direct MMC access. See SCSI Primary Commands-2 (SPC-3) table 26 page 38.
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 |
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 cdio_mmc_sense_key_t |
Meanings of the values of mmc_request_sense.sense_key
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.
p_cdio | the CD object to be acted upon. |
p_volume | volume parameters retrieved |
DRIVER_OP_SUCCESS
if we ran the command ok. 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.
const char* mmc_cmd2str | ( | uint8_t | command | ) |
Get string name for MMC command
command | cdio_mmc_gpcmd_t command value |
int mmc_get_blocksize | ( | CdIo_t * | p_cdio | ) |
Get the block size used in read requests, via MMC (e.g. READ_10, READ_MSF, ...)
p_cdio | the CD object to be acted upon. |
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
p_cdio | the CD object to be acted upon. |
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.
cdio_mmc_level_t mmc_get_drive_mmc_cap | ( | CdIo_t * | p_cdio | ) |
Get the MMC level supported by the device.
p_cdio | the CD object to be acted upon. |
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.
p_cdio | the CD object to be acted upon. |
s | location to store DVD information. |
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.
p_cdio | the CD object to be acted upon. |
p_hw_info | place to store hardware information retrieved |
char* mmc_get_mcn | ( | const CdIo_t * | p_cdio | ) |
Get the media catalog number (MCN
) from the CD via MMC.
p_cdio | the CD object to be acted upon. |
Note: The caller must free the returned string with cdio_free() when done with it.
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. |
driver_return_code_t
. Get the international standard recording code (ISRC
) of the track via MMC.
p_cdio | the CD object to be acted upon. |
i_track | the track to get the ISRC info for |
Note: The caller must free the returned string with cdio_free() when done with it.
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. |
driver_return_code_t
. bool_3way_t mmc_have_interface | ( | CdIo_t * | p_cdio, |
cdio_mmc_feature_interface_t | e_interface | ||
) |
Report if CD-ROM has a particular kind of interface (ATAPI, SCSCI, ...) Is it possible for an interface to have several? If not this routine could probably return the single mmc_feature_interface_t
.
p_cdio | the CD object to be acted upon. |
e_interface |
int mmc_last_cmd_sense | ( | const CdIo_t * | p_cdio, |
cdio_mmc_request_sense_t ** | pp_sense | ||
) |
Obtain the SCSI sense reply of the most-recently-performed MMC command. These bytes give an indication of possible problems which occured in the drive while the command was performed. With some commands they tell about the current state of the drive (e.g. 00h TEST
UNIT
READY
).
p_cdio | CD structure set by cdio_open(). |
pp_sense | returns the sense bytes received from the drive. This is allocated memory or NULL if no sense bytes are available. Dispose non-NULL pointers by cdio_free() when no longer needed. See SPC-3 4.5.3 Fixed format sense data. SCSI error codes as of SPC-3 Annex D, MMC-5 Annex F: sense[2]&15 = Key , sense[12] = ASC , sense[13] = ASCQ |
uint8_t* mmc_read_cdtext | ( | const CdIo_t * | p_cdio | ) |
Read cdtext information for a cdtext_t object.
This is the raw SCSI/MMC reply as retrieved by mmc_read_toc_cdtext(). It consists of 4 header bytes and a variable number of text packs.
The first two bytes of the header, a Big-Endian number, specifies the number of following bytes. The count also includes the next two header bytes which should be 0.
See also information in mmc_read_toc_cdtext().
Here is some code to parse the text packs into a cdtext_t
object:
p_cdio | the CD object to be acted upon. |
NULL
on error or if CD-Text information does not exist.Note: the caller must free the returned memory.
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.
driver_return_code_t 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. |
driver_return_code_t 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.
cdio_mmc_feature_t debug_cdio_mmc_feature |
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
cdio_mmc_feature_interface_t debug_cdio_mmc_feature_interface |
cdio_mmc_feature_profile_t debug_cdio_mmc_feature_profile |
cdio_mmc_get_conf_t debug_cdio_mmc_get_conf |
cdio_mmc_gpcmd_t debug_cdio_mmc_gpcmd |
cdio_mmc_mode_page_t debug_cdio_mmc_mode_page |
cdio_mmc_read_cd_type_t debug_cdio_mmc_read_cd_type |
cdio_mmc_read_sub_state_t debug_cdio_mmc_read_sub_state |
cdio_mmc_readtoc_t debug_cdio_mmc_readtoc |
struct mmc_audio_volume_s GNUC_PACKED |