Start to split off specific mmc commands from the lower-level internals.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2006, 2008, 2009 Rocky Bernstein <rocky@gnu.org>
|
Copyright (C) 2006, 2008, 2009, 2010 Rocky Bernstein <rocky@gnu.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/mmc.h>
|
#include <cdio/mmc.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_mode_sense (const char *psz_drive, const char *six_or_ten,
|
print_mode_sense (const char *psz_drive, const char *six_or_ten,
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio.hpp,v 1.13 2008/03/25 15:59:10 karl Exp $
|
|
||||||
|
|
||||||
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
@@ -30,6 +28,7 @@
|
|||||||
#include <cdio/audio.h>
|
#include <cdio/audio.h>
|
||||||
#include <cdio/dvd.h>
|
#include <cdio/dvd.h>
|
||||||
#include <cdio/mmc.h>
|
#include <cdio/mmc.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
|
|
||||||
// Make pre- and post-increment operators for enums in libcdio where it
|
// Make pre- and post-increment operators for enums in libcdio where it
|
||||||
// makes sense.
|
// makes sense.
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ libcdioinclude_HEADERS = \
|
|||||||
iso9660.h \
|
iso9660.h \
|
||||||
logging.h \
|
logging.h \
|
||||||
mmc.h \
|
mmc.h \
|
||||||
|
mmc_cmds.h \
|
||||||
paranoia.h \
|
paranoia.h \
|
||||||
posix.h \
|
posix.h \
|
||||||
read.h \
|
read.h \
|
||||||
|
|||||||
@@ -732,16 +732,6 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
|
|||||||
discmode_t mmc_get_dvd_struct_physical ( const CdIo_t *p_cdio,
|
discmode_t mmc_get_dvd_struct_physical ( const CdIo_t *p_cdio,
|
||||||
cdio_dvd_struct_t *s);
|
cdio_dvd_struct_t *s);
|
||||||
|
|
||||||
/**
|
|
||||||
Return results of media status
|
|
||||||
@param p_cdio the CD object to be acted upon.
|
|
||||||
@param out_buf media status code from operation
|
|
||||||
@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_get_event_status(const CdIo_t *p_cdio,
|
|
||||||
uint8_t out_buf[2]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Find out if media tray is open or closed.
|
Find out if media tray is open or closed.
|
||||||
@param p_cdio the CD object to be acted upon.
|
@param p_cdio the CD object to be acted upon.
|
||||||
@@ -794,151 +784,6 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
|
|||||||
bool_3way_t mmc_have_interface( CdIo_t *p_cdio,
|
bool_3way_t mmc_have_interface( CdIo_t *p_cdio,
|
||||||
cdio_mmc_feature_interface_t e_interface );
|
cdio_mmc_feature_interface_t e_interface );
|
||||||
|
|
||||||
/**
|
|
||||||
Run a 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.
|
|
||||||
*/
|
|
||||||
int mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
|
|
||||||
int page);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Run a MODE_SENSE command (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.
|
|
||||||
*/
|
|
||||||
int 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)
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
int mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
|
|
||||||
int page);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Issue a MMC READ_CD command.
|
|
||||||
|
|
||||||
@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_sync
|
|
||||||
|
|
||||||
@param b_edc_ecc true if we 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.
|
|
||||||
*/
|
|
||||||
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
|
Read just the user data part of some sort of data sector (via
|
||||||
mmc_read_cd).
|
mmc_read_cd).
|
||||||
|
|||||||
209
include/cdio/mmc_cmds.h
Normal file
209
include/cdio/mmc_cmds.h
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 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
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\file mmc_cmds.h
|
||||||
|
|
||||||
|
\brief Wrappers for specific Multimedia Command (MMC) commands e.g., READ
|
||||||
|
DISC, START/STOP UNIT.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CDIO_MMC_CMDS_H__
|
||||||
|
#define __CDIO_MMC_CMDS_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return results of media status
|
||||||
|
@param p_cdio the CD object to be acted upon.
|
||||||
|
@param out_buf media status code from operation
|
||||||
|
@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_get_event_status(const CdIo_t *p_cdio,
|
||||||
|
uint8_t out_buf[2]);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run a 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.
|
||||||
|
*/
|
||||||
|
int mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
|
||||||
|
int page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run a MODE_SENSE command (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.
|
||||||
|
*/
|
||||||
|
int 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)
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
int mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
|
||||||
|
int page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Issue a MMC READ_CD command.
|
||||||
|
|
||||||
|
@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_sync
|
||||||
|
|
||||||
|
@param b_edc_ecc true if we 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.
|
||||||
|
*/
|
||||||
|
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 );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* __MMC_H__ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* c-file-style: "gnu"
|
||||||
|
* tab-width: 8
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
@@ -80,6 +80,7 @@ libcdio_sources = \
|
|||||||
image/nrg.h \
|
image/nrg.h \
|
||||||
logging.c \
|
logging.c \
|
||||||
mmc.c \
|
mmc.c \
|
||||||
|
mmc_cmds.c \
|
||||||
mmc_private.h \
|
mmc_private.h \
|
||||||
MSWindows/aspi32.c \
|
MSWindows/aspi32.c \
|
||||||
MSWindows/aspi32.h \
|
MSWindows/aspi32.h \
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <cdio/cd_types.h>
|
#include <cdio/cd_types.h>
|
||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
323
lib/driver/mmc.c
323
lib/driver/mmc.c
@@ -23,6 +23,7 @@
|
|||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include <cdio/mmc.h>
|
#include <cdio/mmc.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
|
||||||
@@ -401,91 +402,6 @@ mmc_get_mcn_private ( void *p_env,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Run a 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.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, 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 MODE_SENSE command (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.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mmc_mode_sense_6( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
|
|
||||||
{
|
|
||||||
mmc_cdb_t cdb = {{0, }};
|
|
||||||
|
|
||||||
if ( ! p_cdio ) return DRIVER_OP_UNINIT;
|
|
||||||
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
|
||||||
|
|
||||||
memset (p_buf, 0, i_size);
|
|
||||||
|
|
||||||
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_6);
|
|
||||||
|
|
||||||
cdb.field[2] = CDIO_MMC_ALL_PAGES & page;
|
|
||||||
cdb.field[4] = i_size;
|
|
||||||
|
|
||||||
return p_cdio->op.run_mmc_cmd (p_cdio->env,
|
|
||||||
mmc_timeout_ms,
|
|
||||||
mmc_get_cmd_len(cdb.field[0]), &cdb,
|
|
||||||
SCSI_MMC_DATA_READ, i_size, p_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Run a MODE_SENSE command (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.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mmc_mode_sense_10( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
|
|
||||||
{
|
|
||||||
mmc_cdb_t cdb = {{0, }};
|
|
||||||
|
|
||||||
if ( ! p_cdio ) return DRIVER_OP_UNINIT;
|
|
||||||
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
|
||||||
|
|
||||||
memset (p_buf, 0, i_size);
|
|
||||||
|
|
||||||
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_10);
|
|
||||||
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_size);
|
|
||||||
|
|
||||||
cdb.field[2] = CDIO_MMC_ALL_PAGES & page;
|
|
||||||
|
|
||||||
return p_cdio->op.run_mmc_cmd (p_cdio->env,
|
|
||||||
mmc_timeout_ms,
|
|
||||||
mmc_get_cmd_len(cdb.field[0]), &cdb,
|
|
||||||
SCSI_MMC_DATA_READ, i_size, p_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read cdtext information for a CdIo_t object .
|
Read cdtext information for a CdIo_t object .
|
||||||
|
|
||||||
@@ -980,41 +896,6 @@ mmc_get_hwinfo ( const CdIo_t *p_cdio,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Return results of media status
|
|
||||||
@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_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2])
|
|
||||||
{
|
|
||||||
mmc_cdb_t cdb = {{0, }};
|
|
||||||
uint8_t buf[8] = { 0, };
|
|
||||||
int i_status;
|
|
||||||
|
|
||||||
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_GET_EVENT_STATUS);
|
|
||||||
|
|
||||||
/* Setup to read header, to get length of data */
|
|
||||||
CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(buf));
|
|
||||||
|
|
||||||
cdb.field[1] = 1; /* We poll for info */
|
|
||||||
cdb.field[4] = 1 << 4; /* We want Media events */
|
|
||||||
|
|
||||||
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_READ,
|
|
||||||
sizeof(buf), buf);
|
|
||||||
if(i_status == DRIVER_OP_SUCCESS) {
|
|
||||||
out_buf[0] = buf[4];
|
|
||||||
out_buf[1] = buf[5];
|
|
||||||
}
|
|
||||||
return i_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Find out if media has changed since the last call.
|
Find out if media has changed since the last call.
|
||||||
@param p_cdio the CD object to be acted upon.
|
@param p_cdio the CD object to be acted upon.
|
||||||
@@ -1163,45 +1044,6 @@ mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
|
|||||||
p_cdb, e_direction, i_buf, p_buf);
|
p_cdb, e_direction, i_buf, p_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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_START_STOP);
|
|
||||||
|
|
||||||
if (b_immediate) cdb.field[1] |= 1;
|
|
||||||
|
|
||||||
if (power_condition)
|
|
||||||
cdb.field[4] = power_condition << 4;
|
|
||||||
else {
|
|
||||||
if (b_eject)
|
|
||||||
cdb.field[4] = 2; /* eject */
|
|
||||||
else
|
|
||||||
cdb.field[4] = 3; /* close tray for tray-type */
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Close tray using a MMC START STOP command.
|
Close tray using a MMC START STOP command.
|
||||||
@param p_cdio the CD object to be acted upon.
|
@param p_cdio the CD object to be acted upon.
|
||||||
@@ -1464,169 +1306,6 @@ mmc_have_interface( CdIo_t *p_cdio, cdio_mmc_feature_interface_t e_interface )
|
|||||||
return dunno;
|
return dunno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Maximum blocks to retrieve. Would be nice to customize this based on
|
|
||||||
drive capabilities.
|
|
||||||
*/
|
|
||||||
#define MAX_CD_READ_BLOCKS 16
|
|
||||||
#define CD_READ_TIMEOUT_MS mmc_timeout_ms * (MAX_CD_READ_BLOCKS/2)
|
|
||||||
|
|
||||||
/**
|
|
||||||
Issue a MMC READ_CD command.
|
|
||||||
|
|
||||||
@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_sync
|
|
||||||
|
|
||||||
@param b_edc_ecc true if we 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.
|
|
||||||
*/
|
|
||||||
driver_return_code_t
|
|
||||||
mmc_read_cd ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
|
|
||||||
int read_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 )
|
|
||||||
{
|
|
||||||
mmc_cdb_t cdb = {{0, }};
|
|
||||||
|
|
||||||
mmc_run_cmd_fn_t run_mmc_cmd;
|
|
||||||
uint8_t cdb9 = 0;
|
|
||||||
|
|
||||||
if (!p_cdio) return DRIVER_OP_UNINIT;
|
|
||||||
if (!p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
|
||||||
|
|
||||||
run_mmc_cmd = p_cdio->op.run_mmc_cmd;
|
|
||||||
|
|
||||||
CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_CD);
|
|
||||||
CDIO_MMC_SET_READ_TYPE(cdb.field, read_sector_type);
|
|
||||||
if (b_digital_audio_play) cdb.field[1] |= 0x2;
|
|
||||||
|
|
||||||
if (b_sync) cdb9 |= 128;
|
|
||||||
if (b_user_data) cdb9 |= 16;
|
|
||||||
if (b_edc_ecc) cdb9 |= 8;
|
|
||||||
cdb9 |= (header_codes & 3) << 5;
|
|
||||||
cdb9 |= (c2_error_information & 3) << 1;
|
|
||||||
cdb.field[9] = cdb9;
|
|
||||||
cdb.field[10] = (subchannel_selection & 7);
|
|
||||||
|
|
||||||
{
|
|
||||||
unsigned int j = 0;
|
|
||||||
int i_ret = DRIVER_OP_SUCCESS;
|
|
||||||
const uint8_t i_cdb = mmc_get_cmd_len(cdb.field[0]);
|
|
||||||
|
|
||||||
while (i_blocks > 0) {
|
|
||||||
const unsigned i_blocks2 = (i_blocks > MAX_CD_READ_BLOCKS)
|
|
||||||
? MAX_CD_READ_BLOCKS : i_blocks;
|
|
||||||
void *p_buf2 = ((char *)p_buf ) + (j * i_blocksize);
|
|
||||||
|
|
||||||
CDIO_MMC_SET_READ_LBA (cdb.field, (i_lsn+j));
|
|
||||||
CDIO_MMC_SET_READ_LENGTH24(cdb.field, i_blocks2);
|
|
||||||
|
|
||||||
i_ret = run_mmc_cmd (p_cdio->env, CD_READ_TIMEOUT_MS,
|
|
||||||
i_cdb, &cdb,
|
|
||||||
SCSI_MMC_DATA_READ,
|
|
||||||
i_blocksize * i_blocks2,
|
|
||||||
p_buf2);
|
|
||||||
|
|
||||||
if (i_ret) return i_ret;
|
|
||||||
|
|
||||||
i_blocks -= i_blocks2;
|
|
||||||
j += i_blocks2;
|
|
||||||
}
|
|
||||||
return i_ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read sectors using SCSI-MMC GPCMD_READ_CD.
|
Read sectors using SCSI-MMC GPCMD_READ_CD.
|
||||||
*/
|
*/
|
||||||
|
|||||||
352
lib/driver/mmc_cmds.c
Normal file
352
lib/driver/mmc_cmds.c
Normal file
@@ -0,0 +1,352 @@
|
|||||||
|
/*
|
||||||
|
Wrappers for specific Multimedia Command (MMC) commands e.g., READ
|
||||||
|
DISC, START/STOP UNIT.
|
||||||
|
|
||||||
|
Copyright (C) 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
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
|
#include "cdio_private.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return results of media status
|
||||||
|
@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_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2])
|
||||||
|
{
|
||||||
|
mmc_cdb_t cdb = {{0, }};
|
||||||
|
uint8_t buf[8] = { 0, };
|
||||||
|
int i_status;
|
||||||
|
|
||||||
|
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_GET_EVENT_STATUS);
|
||||||
|
|
||||||
|
/* Setup to read header, to get length of data */
|
||||||
|
CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(buf));
|
||||||
|
|
||||||
|
cdb.field[1] = 1; /* We poll for info */
|
||||||
|
cdb.field[4] = 1 << 4; /* We want Media events */
|
||||||
|
|
||||||
|
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_READ,
|
||||||
|
sizeof(buf), buf);
|
||||||
|
if(i_status == DRIVER_OP_SUCCESS) {
|
||||||
|
out_buf[0] = buf[4];
|
||||||
|
out_buf[1] = buf[5];
|
||||||
|
}
|
||||||
|
return i_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run a 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.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, 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 MODE_SENSE command (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.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
mmc_mode_sense_10( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
|
||||||
|
{
|
||||||
|
mmc_cdb_t cdb = {{0, }};
|
||||||
|
|
||||||
|
if ( ! p_cdio ) return DRIVER_OP_UNINIT;
|
||||||
|
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
||||||
|
|
||||||
|
memset (p_buf, 0, i_size);
|
||||||
|
|
||||||
|
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_10);
|
||||||
|
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_size);
|
||||||
|
|
||||||
|
cdb.field[2] = CDIO_MMC_ALL_PAGES & page;
|
||||||
|
|
||||||
|
return p_cdio->op.run_mmc_cmd (p_cdio->env,
|
||||||
|
mmc_timeout_ms,
|
||||||
|
mmc_get_cmd_len(cdb.field[0]), &cdb,
|
||||||
|
SCSI_MMC_DATA_READ, i_size, p_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run a MODE_SENSE command (6-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.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
mmc_mode_sense_6( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
|
||||||
|
{
|
||||||
|
mmc_cdb_t cdb = {{0, }};
|
||||||
|
|
||||||
|
if ( ! p_cdio ) return DRIVER_OP_UNINIT;
|
||||||
|
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
||||||
|
|
||||||
|
memset (p_buf, 0, i_size);
|
||||||
|
|
||||||
|
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_6);
|
||||||
|
|
||||||
|
cdb.field[2] = CDIO_MMC_ALL_PAGES & page;
|
||||||
|
cdb.field[4] = i_size;
|
||||||
|
|
||||||
|
return p_cdio->op.run_mmc_cmd (p_cdio->env,
|
||||||
|
mmc_timeout_ms,
|
||||||
|
mmc_get_cmd_len(cdb.field[0]), &cdb,
|
||||||
|
SCSI_MMC_DATA_READ, i_size, p_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Maximum blocks to retrieve. Would be nice to customize this based on
|
||||||
|
drive capabilities.
|
||||||
|
*/
|
||||||
|
#define MAX_CD_READ_BLOCKS 16
|
||||||
|
#define CD_READ_TIMEOUT_MS mmc_timeout_ms * (MAX_CD_READ_BLOCKS/2)
|
||||||
|
|
||||||
|
/**
|
||||||
|
Issue a MMC READ_CD command.
|
||||||
|
|
||||||
|
@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_sync
|
||||||
|
|
||||||
|
@param b_edc_ecc true if we 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.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
mmc_read_cd ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
|
||||||
|
int read_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 )
|
||||||
|
{
|
||||||
|
mmc_cdb_t cdb = {{0, }};
|
||||||
|
|
||||||
|
mmc_run_cmd_fn_t run_mmc_cmd;
|
||||||
|
uint8_t cdb9 = 0;
|
||||||
|
|
||||||
|
if (!p_cdio) return DRIVER_OP_UNINIT;
|
||||||
|
if (!p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
||||||
|
|
||||||
|
run_mmc_cmd = p_cdio->op.run_mmc_cmd;
|
||||||
|
|
||||||
|
CDIO_MMC_SET_COMMAND (cdb.field, CDIO_MMC_GPCMD_READ_CD);
|
||||||
|
CDIO_MMC_SET_READ_TYPE(cdb.field, read_sector_type);
|
||||||
|
if (b_digital_audio_play) cdb.field[1] |= 0x2;
|
||||||
|
|
||||||
|
if (b_sync) cdb9 |= 128;
|
||||||
|
if (b_user_data) cdb9 |= 16;
|
||||||
|
if (b_edc_ecc) cdb9 |= 8;
|
||||||
|
cdb9 |= (header_codes & 3) << 5;
|
||||||
|
cdb9 |= (c2_error_information & 3) << 1;
|
||||||
|
cdb.field[9] = cdb9;
|
||||||
|
cdb.field[10] = (subchannel_selection & 7);
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned int j = 0;
|
||||||
|
int i_ret = DRIVER_OP_SUCCESS;
|
||||||
|
const uint8_t i_cdb = mmc_get_cmd_len(cdb.field[0]);
|
||||||
|
|
||||||
|
while (i_blocks > 0) {
|
||||||
|
const unsigned i_blocks2 = (i_blocks > MAX_CD_READ_BLOCKS)
|
||||||
|
? MAX_CD_READ_BLOCKS : i_blocks;
|
||||||
|
void *p_buf2 = ((char *)p_buf ) + (j * i_blocksize);
|
||||||
|
|
||||||
|
CDIO_MMC_SET_READ_LBA (cdb.field, (i_lsn+j));
|
||||||
|
CDIO_MMC_SET_READ_LENGTH24(cdb.field, i_blocks2);
|
||||||
|
|
||||||
|
i_ret = run_mmc_cmd (p_cdio->env, CD_READ_TIMEOUT_MS,
|
||||||
|
i_cdb, &cdb,
|
||||||
|
SCSI_MMC_DATA_READ,
|
||||||
|
i_blocksize * i_blocks2,
|
||||||
|
p_buf2);
|
||||||
|
|
||||||
|
if (i_ret) return i_ret;
|
||||||
|
|
||||||
|
i_blocks -= i_blocks2;
|
||||||
|
j += i_blocks2;
|
||||||
|
}
|
||||||
|
return i_ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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_START_STOP);
|
||||||
|
|
||||||
|
if (b_immediate) cdb.field[1] |= 1;
|
||||||
|
|
||||||
|
if (power_condition)
|
||||||
|
cdb.field[4] = power_condition << 4;
|
||||||
|
else {
|
||||||
|
if (b_eject)
|
||||||
|
cdb.field[4] = 2; /* eject */
|
||||||
|
else
|
||||||
|
cdb.field[4] = 3; /* close tray for tray-type */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 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);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: mmc-tool.c,v 1.12 2008/06/19 15:44:24 flameeyes Exp $
|
Copyright (C) 2006, 2008, 2010 Rocky Bernstein <rocky@gnu.org>
|
||||||
|
|
||||||
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -34,6 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/mmc.h>
|
#include <cdio/mmc.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include <cdio/mmc.h>
|
#include <cdio/mmc.h>
|
||||||
|
#include <cdio/mmc_cmds.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -173,7 +174,6 @@ tmmc_load_eject(CdIo_t *p_cdio, int *sense_avail,
|
|||||||
unsigned char sense_reply[18], int flag)
|
unsigned char sense_reply[18], int flag)
|
||||||
{
|
{
|
||||||
int i_status;
|
int i_status;
|
||||||
mmc_cdb_t cdb = {{0, }};
|
|
||||||
bool b_eject = !!(flag & 4);
|
bool b_eject = !!(flag & 4);
|
||||||
bool b_immediate = !!(flag & 2);
|
bool b_immediate = !!(flag & 2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user