Add routine for reading data independent of or mode1 and mode2 format.

Should help with ISO 9660 reading. Add generic MMC READ_CD routine.

Warning - even more breakage in some situations. (But there's promise
of an overall brighter future.)
This commit is contained in:
rocky
2005-02-17 04:57:21 +00:00
parent 9dead00107
commit 78a3f49868
18 changed files with 487 additions and 154 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: mmc.h,v 1.9 2005/02/12 15:27:22 rocky Exp $
$Id: mmc.h,v 1.10 2005/02/17 04:57:21 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -358,10 +358,10 @@ typedef enum scsi_mmc_direction {
#define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
cdb[8] = (len ) & 0xff
#define CDIO_MMC_MCSB_ALL_HEADERS 0x78
#define CDIO_MMC_MCSB_ALL_HEADERS 0xf
#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
cdb[9] = val;
cdb[9] = val << 3;
/*!
* Eject using MMC commands.
@@ -490,12 +490,137 @@ int mmc_mode_sense_10( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
/*! Issue a MMC READ_CD command.
/*! Packet driver to read mode2 sectors.
Can read only up to 25 blocks.
@param p_cdio object to read from
@param p_buf Place to store data. The caller should ensure that
p_buf can hold at least i_blocksize * i_blocks bytes.
@param i_lsn sector to read
@param 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
@param 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.
b_sync_header return the sync header (which will probably have
the same value as CDIO_SECTOR_SYNC_HEADER of size
CDIO_CD_SYNC_SIZE).
@param header_codes Header Codes refer to the sector header and
the sub-header that is present in mode 2 formed sectors:
0 No header information is returned.
1 The 4-byte sector header of data sectors is be returned,
2 The 8-byte sector sub-header of mode 2 formed sectors is
returned.
3 Both sector header and sub-header (12 bytes) is returned.
The Header preceeds the rest of the bytes (e.g. user-data bytes)
that might get returned.
@param b_user_data Return user data if true.
For CD-DA, the User Data is CDIO_CD_FRAMESIZE_RAW bytes.
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.
@param b_edc_ecc, Return EDC/ECC error detection/correction bits.
The presence and size of EDC redundancy or ECC parity is defined
according to sector type:
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.
@param 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.
@param subchannel_selection subchannel-selection bits
0 No Sub-channel data shall be returned. (0 bytes)
1 RAW P-W Sub-channel data shall be returned. (96 byte)
2 Formatted Q sub-channel data shall be transferred (16 bytes)
3 Reserved
4 Corrected and de-interleaved R-W sub-channel (96 bytes)
5-7 Reserved
@param i_blocksize size of the a block expected to be returned
@param i_blocks number of blocks expected to be returned.
*/
int mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf, lba_t lba,
int sector_type, unsigned int i_blocks);
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 );
/*! Read just the user data part of some sort of data sector (via
mmc_read_cd).
@param p_cdio object to read from
@param 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.
@param i_lsn sector to read
*/
driver_return_code_t mmc_read_data_sector ( CdIo_t *p_cdio, void *p_buf,
lsn_t i_lsn,
uint16_t i_blocksize );
/*! issue a MMC read mode2 sectors. - depricated.
*/
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);
/*!
Run an MMC command.
@@ -520,7 +645,7 @@ int mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
Set the block size for subsequest read requests, via MMC.
*/
driver_return_code_t mmc_set_blocksize ( const CdIo_t *p_cdio,
unsigned int i_bsize);
uint16_t i_blocksize);
/*!
Set the drive speed.