mmc.h

Go to the documentation of this file.
00001 /*
00002     $Id: mmc.h,v 1.24 2006/02/16 20:09:27 rocky Exp $
00003 
00004     Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00028 #ifndef __CDIO_MMC_H__
00029 #define __CDIO_MMC_H__
00030 
00031 #include <cdio/cdio.h>
00032 #include <cdio/types.h>
00033 #include <cdio/dvd.h>
00034 #include <cdio/audio.h>
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif /* __cplusplus */
00039 
00042   extern uint32_t mmc_timeout_ms; 
00043 
00045 #define MMC_TIMEOUT_DEFAULT 6000
00046 
00049   extern uint32_t mmc_read_timeout_ms;
00050 
00052 #define MMC_READ_TIMEOUT_DEFAULT 3*60*1000
00053 
00054 
00065   typedef enum {
00066   CDIO_MMC_GPCMD_INQUIRY                = 0x12, 
00068   CDIO_MMC_GPCMD_MODE_SELECT_6          = 0x15, 
00070   CDIO_MMC_GPCMD_MODE_SENSE_6           = 0x1a, 
00075   CDIO_MMC_GPCMD_START_STOP             = 0x1b, 
00077   CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL   = 0x1e, 
00082   CDIO_MMC_GPCMD_READ_10                = 0x28, 
00084   CDIO_MMC_GPCMD_READ_SUBCHANNEL        = 0x42, 
00086   CDIO_MMC_GPCMD_READ_TOC               = 0x43, 
00088   CDIO_MMC_GPCMD_READ_HEADER            = 0x44,
00089   CDIO_MMC_GPCMD_PLAY_AUDIO_10          = 0x45, 
00092   CDIO_MMC_GPCMD_GET_CONFIGURATION      = 0x46, 
00094   CDIO_MMC_GPCMD_PLAY_AUDIO_MSF         = 0x47, 
00097   CDIO_MMC_GPCMD_PLAY_AUDIO_TI          = 0x48,
00098   CDIO_MMC_GPCMD_PLAY_TRACK_REL_10      = 0x49, 
00105   CDIO_MMC_GPCMD_GET_EVENT_STATUS       = 0x4a, 
00107   CDIO_MMC_GPCMD_PAUSE_RESUME           = 0x4b, 
00111   CDIO_MMC_GPCMD_READ_DISC_INFO         = 0x51, 
00113   CDIO_MMC_GPCMD_MODE_SELECT_10         = 0x55, 
00115   CDIO_MMC_GPCMD_MODE_SENSE_10          = 0x5a, 
00123   CDIO_MMC_GPCMD_PLAY_AUDIO_12          = 0xa5, 
00126   CDIO_MMC_GPCMD_LOAD_UNLOAD            = 0xa6, 
00128   CDIO_MMC_GPCMD_READ_12                = 0xa8, 
00130   CDIO_MMC_GPCMD_PLAY_TRACK_REL_12      = 0xa9, 
00136   CDIO_MMC_GPCMD_READ_DVD_STRUCTURE     = 0xad, 
00138   CDIO_MMC_GPCMD_READ_MSF               = 0xb9, 
00141   CDIO_MMC_GPCMD_SET_SPEED              = 0xbb, 
00151   CDIO_MMC_GPCMD_READ_CD                = 0xbe, 
00156   CDIO_MMC_GPCMD_CD_PLAYBACK_STATUS  = 0xc4 ,
00157   CDIO_MMC_GPCMD_PLAYBACK_CONTROL    = 0xc9 ,
00158   CDIO_MMC_GPCMD_READ_CDDA           = 0xd8 ,
00159   CDIO_MMC_GPCMD_READ_CDXA           = 0xdb ,
00160   CDIO_MMC_GPCMD_READ_ALL_SUBCODES   = 0xdf 
00161   } cdio_mmc_gpcmd_t;
00162 
00163 
00165   typedef enum {
00166     CDIO_MMC_READ_SUB_ST_INVALID   = 0x00, 
00167     CDIO_MMC_READ_SUB_ST_PLAY      = 0x11, 
00169     CDIO_MMC_READ_SUB_ST_PAUSED    = 0x12, 
00170     CDIO_MMC_READ_SUB_ST_COMPLETED = 0x13, 
00172     CDIO_MMC_READ_SUB_ST_ERROR     = 0x14, 
00174     CDIO_MMC_READ_SUB_ST_NO_STATUS = 0x15, 
00176   } cdio_mmc_read_sub_state_t;
00177 
00179 #define CDIO_MMC_READ_TYPE_ANY   0  
00180 #define CDIO_MMC_READ_TYPE_CDDA  1  
00181 #define CDIO_MMC_READ_TYPE_MODE1 2  
00182 #define CDIO_MMC_READ_TYPE_MODE2 3  
00183 #define CDIO_MMC_READ_TYPE_M2F1  4  
00184 #define CDIO_MMC_READ_TYPE_M2F2  5  
00187 #define CDIO_MMC_READTOC_FMT_TOC      0
00188 #define CDIO_MMC_READTOC_FMT_SESSION  1  
00189 #define CDIO_MMC_READTOC_FMT_FULTOC   2  
00190 #define CDIO_MMC_READTOC_FMT_PMA      3  
00191 #define CDIO_MMC_READTOC_FMT_ATIP     4  
00192 #define CDIO_MMC_READTOC_FMT_CDTEXT   5  
00195 #define CDIO_MMC_R_W_ERROR_PAGE         0x01
00196 #define CDIO_MMC_WRITE_PARMS_PAGE       0x05
00197 #define CDIO_MMC_CDR_PARMS_PAGE         0x0d
00198 #define CDIO_MMC_AUDIO_CTL_PAGE         0x0e
00199 #define CDIO_MMC_POWER_PAGE             0x1a
00200 #define CDIO_MMC_FAULT_FAIL_PAGE        0x1c
00201 #define CDIO_MMC_TO_PROTECT_PAGE        0x1d
00202 #define CDIO_MMC_CAPABILITIES_PAGE      0x2a
00203 #define CDIO_MMC_ALL_PAGES              0x3f
00204 
00205 PRAGMA_BEGIN_PACKED
00206   struct mmc_audio_volume_entry_s 
00207   {
00208     uint8_t  selection; /* Only the lower 4 bits are used. */
00209     uint8_t  volume;
00210   } GNUC_PACKED;
00211 
00212   typedef struct mmc_audio_volume_entry_s mmc_audio_volume_entry_t;
00213   
00215   struct mmc_audio_volume_s
00216   {
00217     mmc_audio_volume_entry_t port[4];
00218   } GNUC_PACKED;
00219 
00220   typedef struct mmc_audio_volume_s mmc_audio_volume_t;
00221   
00222 PRAGMA_END_PACKED
00223   
00224 
00226 typedef enum {
00227   CDIO_MMC_GET_CONF_ALL_FEATURES     = 0,  
00229   CDIO_MMC_GET_CONF_CURRENT_FEATURES = 1,  
00232   CDIO_MMC_GET_CONF_NAMED_FEATURE    = 2   
00234 } cdio_mmc_get_conf_t;
00235   
00236 
00239 typedef enum {
00240   CDIO_MMC_FEATURE_PROFILE_LIST     = 0x000, 
00241   CDIO_MMC_FEATURE_CORE             = 0x001, 
00242   CDIO_MMC_FEATURE_MORPHING         = 0x002, 
00244   CDIO_MMC_FEATURE_REMOVABLE_MEDIUM = 0x003, 
00245   CDIO_MMC_FEATURE_WRITE_PROTECT    = 0x004, 
00246   CDIO_MMC_FEATURE_RANDOM_READABLE  = 0x010, 
00247   CDIO_MMC_FEATURE_MULTI_READ       = 0x01D, 
00248   CDIO_MMC_FEATURE_CD_READ          = 0x01E, 
00249   CDIO_MMC_FEATURE_DVD_READ         = 0x01F, 
00250   CDIO_MMC_FEATURE_RANDOM_WRITABLE  = 0x020, 
00251   CDIO_MMC_FEATURE_INCR_WRITE       = 0x021, 
00253   CDIO_MMC_FEATURE_SECTOR_ERASE     = 0x022, 
00254   CDIO_MMC_FEATURE_FORMATABLE       = 0x023, 
00255   CDIO_MMC_FEATURE_DEFECT_MGMT      = 0x024, 
00259   CDIO_MMC_FEATURE_WRITE_ONCE       = 0x025, 
00261   CDIO_MMC_FEATURE_RESTRICT_OVERW   = 0x026, 
00263   CDIO_MMC_FEATURE_CD_RW_CAV        = 0x027, 
00264   CDIO_MMC_FEATURE_MRW              = 0x028, 
00265   CDIO_MMC_FEATURE_ENHANCED_DEFECT  = 0x029, 
00266   CDIO_MMC_FEATURE_DVD_PRW          = 0x02A, 
00267   CDIO_MMC_FEATURE_DVD_PR           = 0x02B, 
00268   CDIO_MMC_FEATURE_RIGID_RES_OVERW  = 0x02C, 
00269   CDIO_MMC_FEATURE_CD_TAO           = 0x02D, 
00270   CDIO_MMC_FEATURE_CD_SAO           = 0x02E, 
00272   CDIO_MMC_FEATURE_DVD_R_RW_WRITE   = 0x02F, 
00273   CDIO_MMC_FEATURE_CD_RW_MEDIA_WRITE= 0x037, 
00274   CDIO_MMC_FEATURE_DVD_PR_2_LAYER   = 0x03B, 
00275   CDIO_MMC_FEATURE_POWER_MGMT       = 0x100, 
00277   CDIO_MMC_FEATURE_CDDA_EXT_PLAY    = 0x103, 
00280   CDIO_MMC_FEATURE_MCODE_UPGRADE    = 0x104, /* Ability for the device to 
00281                                                 accept  new microcode via
00282                                                 the interface */
00283   CDIO_MMC_FEATURE_TIME_OUT         = 0x105, 
00286   CDIO_MMC_FEATURE_DVD_CSS          = 0x106, 
00289   CDIO_MMC_FEATURE_RT_STREAMING     = 0x107, 
00292   CDIO_MMC_FEATURE_LU_SN            = 0x108, 
00294   CDIO_MMC_FEATURE_FIRMWARE_DATE    = 0x1FF, 
00296 } cdio_mmc_feature_t;
00297                                 
00299 typedef enum {
00300   CDIO_MMC_FEATURE_PROF_NON_REMOVABLE = 0x0001, 
00302   CDIO_MMC_FEATURE_PROF_REMOVABLE     = 0x0002, 
00304   CDIO_MMC_FEATURE_PROF_MO_ERASABLE   = 0x0003, 
00307   CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE = 0x0004, 
00309   CDIO_MMC_FEATURE_PROF_AS_MO         = 0x0005, 
00311   CDIO_MMC_FEATURE_PROF_CD_ROM        = 0x0008, 
00313   CDIO_MMC_FEATURE_PROF_CD_R          = 0x0009, 
00315   CDIO_MMC_FEATURE_PROF_CD_RW         = 0x000A, 
00317   CDIO_MMC_FEATURE_PROF_DVD_ROM       = 0x0010, 
00318   CDIO_MMC_FEATURE_PROF_DVD_R_SEQ     = 0x0011, 
00320   CDIO_MMC_FEATURE_PROF_DVD_RAM       = 0x0012, 
00321   CDIO_MMC_FEATURE_PROF_DVD_RW_RO     = 0x0013, 
00323   CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ    = 0x0014, 
00325   CDIO_MMC_FEATURE_PROF_DVD_PRW       = 0x001A, 
00326   CDIO_MMC_FEATURE_PROF_DVD_PR        = 0x001B, 
00327   CDIO_MMC_FEATURE_PROF_DDCD_ROM      = 0x0020, 
00328   CDIO_MMC_FEATURE_PROF_DDCD_R        = 0x0021, 
00329   CDIO_MMC_FEATURE_PROF_DDCD_RW       = 0x0022, 
00330   CDIO_MMC_FEATURE_PROF_DVD_PR2       = 0x002B, 
00332   CDIO_MMC_FEATURE_PROF_NON_CONFORM   = 0xFFFF, 
00334 } cdio_mmc_feature_profile_t;
00335   
00336 typedef enum {
00337   CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED = 0,
00338   CDIO_MMC_FEATURE_INTERFACE_SCSI        = 1,
00339   CDIO_MMC_FEATURE_INTERFACE_ATAPI       = 2,
00340   CDIO_MMC_FEATURE_INTERFACE_IEEE_1394   = 3,
00341   CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A  = 4,
00342   CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH    = 5
00343 } cdio_mmc_feature_interface_t;
00344   
00345 
00349 #define MAX_CDB_LEN 12
00350 
00354 typedef struct mmc_cdb_s {
00355   uint8_t field[MAX_CDB_LEN];
00356 } mmc_cdb_t;
00357   
00361   typedef struct mmc_feature_list_header_s {
00362     unsigned char length_msb;
00363     unsigned char length_1sb;
00364     unsigned char length_2sb;
00365     unsigned char length_lsb;
00366     unsigned char reserved1;
00367     unsigned char reserved2;
00368     unsigned char profile_msb;
00369     unsigned char profile_lsb;
00370   } cdio_mmc_feature_list_header_t;
00371 
00375   typedef enum mmc_direction_s {
00376     SCSI_MMC_DATA_READ,
00377     SCSI_MMC_DATA_WRITE
00378   } cdio_mmc_direction_t;
00379   
00380   typedef struct mmc_subchannel_s
00381   {
00382     uint8_t       reserved;
00383     uint8_t       audio_status;
00384     uint16_t      data_length; 
00385     uint8_t       format;
00386     uint8_t       address:      4;
00387     uint8_t       control:      4;
00388     uint8_t       track;
00389     uint8_t       index;
00390     uint8_t       abs_addr[4];
00391     uint8_t       rel_addr[4];
00392   } cdio_mmc_subchannel_t;
00393   
00394 #define CDIO_MMC_SET_COMMAND(cdb, command) \
00395   cdb[0] = command
00396   
00397 #define CDIO_MMC_SET_READ_TYPE(cdb, sector_type) \
00398   cdb[1] = (sector_type << 2)
00399   
00400 #define CDIO_MMC_GET_LEN16(p) \
00401   (p[0]<<8) + p[1]
00402   
00403 #define CDIO_MMC_GET_LEN32(p) \
00404   (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
00405   
00406 #define CDIO_MMC_SET_LEN16(cdb, pos, len)  \
00407   cdb[pos  ] = (len >>  8) & 0xff; \
00408   cdb[pos+1] = (len      ) & 0xff
00409 
00410 #define CDIO_MMC_SET_READ_LBA(cdb, lba) \
00411   cdb[2] = (lba >> 24) & 0xff; \
00412   cdb[3] = (lba >> 16) & 0xff; \
00413   cdb[4] = (lba >>  8) & 0xff; \
00414   cdb[5] = (lba      ) & 0xff
00415 
00416 #define CDIO_MMC_SET_START_TRACK(cdb, command) \
00417   cdb[6] = command
00418 
00419 #define CDIO_MMC_SET_READ_LENGTH24(cdb, len) \
00420   cdb[6] = (len >> 16) & 0xff; \
00421   cdb[7] = (len >>  8) & 0xff; \
00422   cdb[8] = (len      ) & 0xff
00423 
00424 #define CDIO_MMC_SET_READ_LENGTH16(cdb, len) \
00425   CDIO_MMC_SET_LEN16(cdb, 7, len)
00426 
00427 #define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
00428   cdb[8] = (len      ) & 0xff
00429 
00430 #define CDIO_MMC_MCSB_ALL_HEADERS 0xf
00431 
00432 #define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
00433   cdb[9] = val << 3;
00434 
00441 driver_return_code_t
00442 mmc_audio_read_subchannel (CdIo_t *p_cdio, 
00443                            /*out*/ cdio_subchannel_t *p_subchannel);
00444   
00449   const char *mmc_audio_state2str( uint8_t i_audio_state );
00450   
00456   driver_return_code_t mmc_eject_media( const CdIo_t *p_cdio );
00457   
00461   const char *mmc_feature2str( int i_feature );
00462   
00466   const char *mmc_feature_profile2str( int i_feature_profile );
00467   
00473   uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
00474   
00479   int mmc_get_blocksize ( CdIo_t *p_cdio );
00480   
00481 #if 0
00482 
00486   driver_return_code_t mmc_close_tray( const char *psz_device );
00487 #endif
00488   
00494   lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
00495   
00505   discmode_t mmc_get_discmode( const CdIo_t *p_cdio );
00506   
00507   
00512   void mmc_get_drive_cap ( CdIo_t *p_cdio,
00513                            /*out*/ cdio_drive_read_cap_t  *p_read_cap,
00514                            /*out*/ cdio_drive_write_cap_t *p_write_cap,
00515                            /*out*/ cdio_drive_misc_cap_t  *p_misc_cap);
00516   
00517   typedef enum {
00518     CDIO_MMC_LEVEL_WEIRD,
00519     CDIO_MMC_LEVEL_1,
00520     CDIO_MMC_LEVEL_2,
00521     CDIO_MMC_LEVEL_3,
00522     CDIO_MMC_LEVEL_NONE
00523   } cdio_mmc_level_t;
00524   
00528   cdio_mmc_level_t mmc_get_drive_mmc_cap(CdIo_t *p_cdio);
00529   
00530 
00536   discmode_t mmc_get_dvd_struct_physical ( const CdIo_t *p_cdio, 
00537                                            cdio_dvd_struct_t *s);
00538   
00545   bool mmc_get_hwinfo ( const CdIo_t *p_cdio, 
00546                         /* out*/ cdio_hwinfo_t *p_hw_info );
00547   
00548   
00555   int mmc_get_media_changed(const CdIo_t *p_cdio);
00556   
00567   char * mmc_get_mcn ( const CdIo_t *p_cdio );
00568   
00573   driver_return_code_t mmc_audio_get_volume (CdIo_t *p_cdio,  /*out*/
00574                                              mmc_audio_volume_t *p_volume);
00575   
00582   bool_3way_t mmc_have_interface( CdIo_t *p_cdio, 
00583                                   cdio_mmc_feature_interface_t e_interface );
00584   
00589   int mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size, 
00590                       int page);
00591   
00592   
00597   int  mmc_mode_sense_10( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size, 
00598                           int page);
00599   
00604   int  mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size, 
00605                          int page);
00606   
00707   driver_return_code_t
00708   mmc_read_cd ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, 
00709                 int expected_sector_type, bool b_digital_audio_play,
00710                 bool b_sync, uint8_t header_codes, bool b_user_data, 
00711                 bool b_edc_ecc, uint8_t c2_error_information, 
00712                 uint8_t subchannel_selection, uint16_t i_blocksize, 
00713                 uint32_t i_blocks );
00714   
00733   driver_return_code_t mmc_read_data_sectors ( CdIo_t *p_cdio, void *p_buf, 
00734                                                lsn_t i_lsn, 
00735                                                uint16_t i_blocksize,
00736                                                uint32_t i_blocks );
00737   
00740   driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf, 
00741                                           lsn_t i_lsn,  int read_sector_type, 
00742                                           uint32_t i_blocks);
00743   
00759   int mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
00760                    const mmc_cdb_t *p_cdb,
00761                    cdio_mmc_direction_t e_direction, unsigned int i_buf, 
00762                    /*in/out*/ void *p_buf );
00766   driver_return_code_t mmc_set_blocksize ( const CdIo_t *p_cdio, 
00767                                            uint16_t i_blocksize);
00768   
00772   driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio, int i_speed );
00773   
00785   driver_return_code_t
00786   mmc_start_stop_media(const CdIo_t *p_cdio, bool b_eject, bool b_immediate,
00787                        uint8_t power_condition);
00788 
00789 #ifdef __cplusplus
00790 }
00791 #endif /* __cplusplus */
00792 
00798 extern cdio_mmc_feature_t           debug_cdio_mmc_feature;
00799 extern cdio_mmc_feature_interface_t debug_cdio_mmc_feature_interface;
00800 extern cdio_mmc_feature_profile_t   debug_cdio_mmc_feature_profile;
00801 extern cdio_mmc_get_conf_t          debug_cdio_mmc_get_conf;
00802 extern cdio_mmc_gpcmd_t             debug_cdio_mmc_gpcmd;
00803 extern cdio_mmc_read_sub_state_t    debug_cdio_mmc_read_sub_state;
00804   
00805 #endif /* __MMC_H__ */
00806 
00807 /* 
00808  * Local variables:
00809  *  c-file-style: "gnu"
00810  *  tab-width: 8
00811  *  indent-tabs-mode: nil
00812  * End:
00813  */

Generated on Fri Sep 14 20:54:16 2007 for libcdio by  doxygen 1.5.1