diff --git a/include/cdio/device.h b/include/cdio/device.h index b1b20d69..d4a0f66f 100644 --- a/include/cdio/device.h +++ b/include/cdio/device.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: device.h,v 1.15 2005/02/28 02:00:20 rocky Exp $ + $Id: device.h,v 1.16 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -30,6 +30,86 @@ extern "C" { #endif /* __cplusplus */ + /*! The type of an drive capability bit mask. See below for values*/ + typedef uint32_t cdio_drive_read_cap_t; + typedef uint32_t cdio_drive_write_cap_t; + typedef uint32_t cdio_drive_misc_cap_t; + + /*! + \brief Drive types returned by cdio_get_drive_cap() + + NOTE: Setting a bit here means the presence of a capability. + */ + +#define CDIO_DRIVE_CAP_ERROR 0x40000 /**< Error */ +#define CDIO_DRIVE_CAP_UNKNOWN 0x80000 /**< Dunno. It can be on if we + have only partial information + or are not completely certain + */ + +#define CDIO_DRIVE_CAP_MISC_CLOSE_TRAY 0x00001 /**< caddy systems can't + close... */ +#define CDIO_DRIVE_CAP_MISC_EJECT 0x00002 /**< but can eject. */ +#define CDIO_DRIVE_CAP_MISC_LOCK 0x00004 /**< disable manual eject */ +#define CDIO_DRIVE_CAP_MISC_SELECT_SPEED 0x00008 /**< programmable speed */ +#define CDIO_DRIVE_CAP_MISC_SELECT_DISC 0x00010 /**< select disc from + juke-box */ +#define CDIO_DRIVE_CAP_MISC_MULTI_SESSION 0x00020 /**< read sessions>1 */ +#define CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED 0x00080 /**< media changed */ +#define CDIO_DRIVE_CAP_MISC_RESET 0x00100 /**< hard reset device */ +#define CDIO_DRIVE_CAP_MISC_FILE 0x20000 /**< drive is really a file, + i.e a CD file image */ + + /*! Reading masks.. */ +#define CDIO_DRIVE_CAP_READ_AUDIO 0x00001 /**< drive can play CD audio */ +#define CDIO_DRIVE_CAP_READ_CD_DA 0x00002 /**< drive can read CD-DA */ +#define CDIO_DRIVE_CAP_READ_CD_G 0x00004 /**< drive can read CD+G */ +#define CDIO_DRIVE_CAP_READ_CD_R 0x00008 /**< drive can read CD-R */ +#define CDIO_DRIVE_CAP_READ_CD_RW 0x00010 /**< drive can read CD-RW */ +#define CDIO_DRIVE_CAP_READ_DVD_R 0x00020 /**< drive can read DVD-R */ +#define CDIO_DRIVE_CAP_READ_DVD_PR 0x00040 /**< drive can read DVD+R */ +#define CDIO_DRIVE_CAP_READ_DVD_RAM 0x00080 /**< drive can read DVD-RAM */ +#define CDIO_DRIVE_CAP_READ_DVD_ROM 0x00100 /**< drive can read DVD-ROM */ +#define CDIO_DRIVE_CAP_READ_DVD_RW 0x00200 /**< drive can read DVD-RW */ +#define CDIO_DRIVE_CAP_READ_DVD_RPW 0x00400 /**< drive can read DVD+RW */ +#define CDIO_DRIVE_CAP_READ_C2_ERRS 0x00800 /**< has C2 error correction */ +#define CDIO_DRIVE_CAP_READ_MODE2_FORM1 0x01000 /**< can read mode 2 form 1 */ +#define CDIO_DRIVE_CAP_READ_MODE2_FORM2 0x02000 /**< can read mode 2 form 2 */ +#define CDIO_DRIVE_CAP_READ_MCN 0x04000 /**< can read MCN */ +#define CDIO_DRIVE_CAP_READ_ISRC 0x08000 /**< can read ISRC */ + + /*! Writing masks.. */ +#define CDIO_DRIVE_CAP_WRITE_CD_R 0x00001 /**< drive can write CD-R */ +#define CDIO_DRIVE_CAP_WRITE_CD_RW 0x00002 /**< drive can write CD-R */ +#define CDIO_DRIVE_CAP_WRITE_DVD_R 0x00004 /**< drive can write DVD-R */ +#define CDIO_DRIVE_CAP_WRITE_DVD_PR 0x00008 /**< drive can write DVD+R */ +#define CDIO_DRIVE_CAP_WRITE_DVD_RAM 0x00010 /**< drive can write DVD-RAM */ +#define CDIO_DRIVE_CAP_WRITE_DVD_RW 0x00020 /**< drive can write DVD-RW */ +#define CDIO_DRIVE_CAP_WRITE_DVD_RPW 0x00040 /**< drive can write DVD+RW */ +#define CDIO_DRIVE_CAP_WRITE_MT_RAINIER 0x00080 /**< Mount Rainier */ +#define CDIO_DRIVE_CAP_WRITE_BURN_PROOF 0x00100 /**< burn proof */ + +/**< Masks derived from above... */ +#define CDIO_DRIVE_CAP_WRITE_CD ( \ + CDIO_DRIVE_CAP_WRITE_CD_R \ + | CDIO_DRIVE_CAP_WRITE_CD_RW \ + ) +/**< Has some sort of CD writer ability */ + +/**< Masks derived from above... */ +#define CDIO_DRIVE_CAP_WRITE_DVD ( \ + | CDIO_DRIVE_CAP_WRITE_DVD_R \ + | CDIO_DRIVE_CAP_WRITE_DVD_PR \ + | CDIO_DRIVE_CAP_WRITE_DVD_RAM \ + | CDIO_DRIVE_CAP_WRITE_DVD_RW \ + | CDIO_DRIVE_CAP_WRITE_DVD_RPW \ + ) +/**< Has some sort of DVD writer ability */ + +#define CDIO_DRIVE_CAP_WRITE \ + (CDIO_DRIVE_CAP_WRITE_CD | CDIO_DRIVE_CAP_WRITE_DVD) +/**< Has some sort of DVD or CD writing ability */ + /*! Size of fields returned by an INQUIRY command */ #define CDIO_MMC_HW_VENDOR_LEN 8 /**< length of vendor field */ #define CDIO_MMC_HW_MODEL_LEN 16 /**< length of model field */ diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h index b35088c1..15384982 100644 --- a/include/cdio/mmc.h +++ b/include/cdio/mmc.h @@ -1,5 +1,5 @@ /* - $Id: mmc.h,v 1.13 2005/03/01 00:41:34 rocky Exp $ + $Id: mmc.h,v 1.14 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -381,6 +382,15 @@ typedef enum scsi_mmc_direction { #define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \ cdb[9] = val << 3; +/*! + Read Audio Subchannel information + + @param p_cdio the CD object to be acted upon. + +*/ +driver_return_code_t +mmc_audio_read_subchannel (CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel); + /*! * Eject using MMC commands. @@ -445,7 +455,7 @@ void mmc_get_drive_cap ( CdIo_t *p_cdio, @return the DVD discmode. */ discmode_t mmc_get_dvd_struct_physical ( const CdIo_t *p_cdio, - cdio_dvd_struct_t *s); + cdio_dvd_struct_t *s); /*! Get the CD-ROM hardware info via an MMC INQUIRY command. diff --git a/include/cdio/types.h b/include/cdio/types.h index 6f46c76f..a819f868 100644 --- a/include/cdio/types.h +++ b/include/cdio/types.h @@ -1,8 +1,8 @@ /* - $Id: types.h,v 1.27 2005/03/01 00:41:34 rocky Exp $ + $Id: types.h,v 1.28 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel - Copyright (C) 2002, 2003, 2004 Rocky Bernstein + Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein 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 @@ -279,86 +279,6 @@ extern "C" { typedef int cdio_fs_anal_t; - /*! The type of an drive capability bit mask. See below for values*/ - typedef uint32_t cdio_drive_read_cap_t; - typedef uint32_t cdio_drive_write_cap_t; - typedef uint32_t cdio_drive_misc_cap_t; - - /*! - \brief Drive types returned by cdio_get_drive_cap() - - NOTE: Setting a bit here means the presence of a capability. - */ - -#define CDIO_DRIVE_CAP_ERROR 0x40000 /**< Error */ -#define CDIO_DRIVE_CAP_UNKNOWN 0x80000 /**< Dunno. It can be on if we - have only partial information - or are not completely certain - */ - -#define CDIO_DRIVE_CAP_MISC_CLOSE_TRAY 0x00001 /**< caddy systems can't - close... */ -#define CDIO_DRIVE_CAP_MISC_EJECT 0x00002 /**< but can eject. */ -#define CDIO_DRIVE_CAP_MISC_LOCK 0x00004 /**< disable manual eject */ -#define CDIO_DRIVE_CAP_MISC_SELECT_SPEED 0x00008 /**< programmable speed */ -#define CDIO_DRIVE_CAP_MISC_SELECT_DISC 0x00010 /**< select disc from - juke-box */ -#define CDIO_DRIVE_CAP_MISC_MULTI_SESSION 0x00020 /**< read sessions>1 */ -#define CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED 0x00080 /**< media changed */ -#define CDIO_DRIVE_CAP_MISC_RESET 0x00100 /**< hard reset device */ -#define CDIO_DRIVE_CAP_MISC_FILE 0x20000 /**< drive is really a file, - i.e a CD file image */ - - /*! Reading masks.. */ -#define CDIO_DRIVE_CAP_READ_AUDIO 0x00001 /**< drive can play CD audio */ -#define CDIO_DRIVE_CAP_READ_CD_DA 0x00002 /**< drive can read CD-DA */ -#define CDIO_DRIVE_CAP_READ_CD_G 0x00004 /**< drive can read CD+G */ -#define CDIO_DRIVE_CAP_READ_CD_R 0x00008 /**< drive can read CD-R */ -#define CDIO_DRIVE_CAP_READ_CD_RW 0x00010 /**< drive can read CD-RW */ -#define CDIO_DRIVE_CAP_READ_DVD_R 0x00020 /**< drive can read DVD-R */ -#define CDIO_DRIVE_CAP_READ_DVD_PR 0x00040 /**< drive can read DVD+R */ -#define CDIO_DRIVE_CAP_READ_DVD_RAM 0x00080 /**< drive can read DVD-RAM */ -#define CDIO_DRIVE_CAP_READ_DVD_ROM 0x00100 /**< drive can read DVD-ROM */ -#define CDIO_DRIVE_CAP_READ_DVD_RW 0x00200 /**< drive can read DVD-RW */ -#define CDIO_DRIVE_CAP_READ_DVD_RPW 0x00400 /**< drive can read DVD+RW */ -#define CDIO_DRIVE_CAP_READ_C2_ERRS 0x00800 /**< has C2 error correction */ -#define CDIO_DRIVE_CAP_READ_MODE2_FORM1 0x01000 /**< can read mode 2 form 1 */ -#define CDIO_DRIVE_CAP_READ_MODE2_FORM2 0x02000 /**< can read mode 2 form 2 */ -#define CDIO_DRIVE_CAP_READ_MCN 0x04000 /**< can read MCN */ -#define CDIO_DRIVE_CAP_READ_ISRC 0x08000 /**< can read ISRC */ - - /*! Writing masks.. */ -#define CDIO_DRIVE_CAP_WRITE_CD_R 0x00001 /**< drive can write CD-R */ -#define CDIO_DRIVE_CAP_WRITE_CD_RW 0x00002 /**< drive can write CD-R */ -#define CDIO_DRIVE_CAP_WRITE_DVD_R 0x00004 /**< drive can write DVD-R */ -#define CDIO_DRIVE_CAP_WRITE_DVD_PR 0x00008 /**< drive can write DVD+R */ -#define CDIO_DRIVE_CAP_WRITE_DVD_RAM 0x00010 /**< drive can write DVD-RAM */ -#define CDIO_DRIVE_CAP_WRITE_DVD_RW 0x00020 /**< drive can write DVD-RW */ -#define CDIO_DRIVE_CAP_WRITE_DVD_RPW 0x00040 /**< drive can write DVD+RW */ -#define CDIO_DRIVE_CAP_WRITE_MT_RAINIER 0x00080 /**< Mount Rainier */ -#define CDIO_DRIVE_CAP_WRITE_BURN_PROOF 0x00100 /**< burn proof */ - -/**< Masks derived from above... */ -#define CDIO_DRIVE_CAP_WRITE_CD ( \ - CDIO_DRIVE_CAP_WRITE_CD_R \ - | CDIO_DRIVE_CAP_WRITE_CD_RW \ - ) -/**< Has some sort of CD writer ability */ - -/**< Masks derived from above... */ -#define CDIO_DRIVE_CAP_WRITE_DVD ( \ - | CDIO_DRIVE_CAP_WRITE_DVD_R \ - | CDIO_DRIVE_CAP_WRITE_DVD_PR \ - | CDIO_DRIVE_CAP_WRITE_DVD_RAM \ - | CDIO_DRIVE_CAP_WRITE_DVD_RW \ - | CDIO_DRIVE_CAP_WRITE_DVD_RPW \ - ) -/**< Has some sort of DVD writer ability */ - -#define CDIO_DRIVE_CAP_WRITE \ - (CDIO_DRIVE_CAP_WRITE_CD | CDIO_DRIVE_CAP_WRITE_DVD) -/**< Has some sort of DVD or CD writing ability */ - /*! track flags Q Sub-channel Control Field (4.2.3.3) diff --git a/lib/driver/MSWindows/win32.c b/lib/driver/MSWindows/win32.c index 1b494489..cb773e21 100644 --- a/lib/driver/MSWindows/win32.c +++ b/lib/driver/MSWindows/win32.c @@ -1,5 +1,5 @@ /* - $Id: win32.c,v 1.21 2005/03/01 01:22:38 rocky Exp $ + $Id: win32.c,v 1.22 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: win32.c,v 1.21 2005/03/01 01:22:38 rocky Exp $"; +static const char _rcsid[] = "$Id: win32.c,v 1.22 2005/03/01 09:33:52 rocky Exp $"; #include #include @@ -748,6 +748,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode) memset( &_funcs, 0, sizeof(_funcs) ); + _funcs.audio_read_subchannel = audio_read_subchannel_mmc; _funcs.eject_media = _cdio_eject_media; _funcs.free = free_win32; _funcs.get_arg = _get_arg_win32; diff --git a/lib/driver/_cdio_linux.c b/lib/driver/_cdio_linux.c index 023da186..a1dd92ea 100644 --- a/lib/driver/_cdio_linux.c +++ b/lib/driver/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.31 2005/03/01 08:14:09 rocky Exp $ + $Id: _cdio_linux.c,v 1.32 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.31 2005/03/01 08:14:09 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.32 2005/03/01 09:33:52 rocky Exp $"; #include @@ -236,7 +236,7 @@ audio_play_track_index_linux (void *p_user_data, } /*! - Resume playing an audio CD. + Read Audio Subchannel information @param p_cdio the CD object to be acted upon. diff --git a/lib/driver/_cdio_sunos.c b/lib/driver/_cdio_sunos.c index 2d72ea69..a2ba05d5 100644 --- a/lib/driver/_cdio_sunos.c +++ b/lib/driver/_cdio_sunos.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_sunos.c,v 1.26 2005/03/01 08:14:09 rocky Exp $ + $Id: _cdio_sunos.c,v 1.27 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein @@ -38,7 +38,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.26 2005/03/01 08:14:09 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.27 2005/03/01 09:33:52 rocky Exp $"; #ifdef HAVE_GLOB_H #include @@ -160,7 +160,7 @@ audio_play_track_index_solaris (void *p_user_data, } /*! - Resume playing an audio CD. + Read Audio Subchannel information @param p_cdio the CD object to be acted upon. diff --git a/lib/driver/libcdio.sym b/lib/driver/libcdio.sym index ff3e17be..c7f99fca 100644 --- a/lib/driver/libcdio.sym +++ b/lib/driver/libcdio.sym @@ -157,6 +157,7 @@ cdtext_init cdtext_is_keyword cdtext_set discmode2str +mmc_audio_read_subchannel mmc_eject_media mmc_get_blocksize mmc_get_discmode diff --git a/lib/driver/mmc.c b/lib/driver/mmc.c index 3baa44ba..1eea848d 100644 --- a/lib/driver/mmc.c +++ b/lib/driver/mmc.c @@ -1,6 +1,6 @@ /* Common Multimedia Command (MMC) routines. - $Id: mmc.c,v 1.16 2005/02/28 02:56:26 rocky Exp $ + $Id: mmc.c,v 1.17 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein @@ -54,6 +54,20 @@ corresponding publically-accessible routine. *************************************************************************/ +/*! + Read Audio Subchannel information + + @param p_user_data the CD object to be acted upon. + +*/ +driver_return_code_t +audio_read_subchannel_mmc ( void *p_user_data, cdio_subchannel_t *p_subchannel) +{ + generic_img_private_t *p_env = p_user_data; + if (!p_env) return DRIVER_OP_UNINIT; + return mmc_get_blocksize(p_env->cdio); +} + /*! Get the block size for subsequest read requests, via MMC. @return the blocksize if > 0; error if <= 0 @@ -161,6 +175,7 @@ mmc_get_drive_cap_buf(const uint8_t *p, if (p[5] & 0x01) *p_read_cap |= CDIO_DRIVE_CAP_READ_CD_DA; if (p[5] & 0x10) *p_read_cap |= CDIO_DRIVE_CAP_READ_C2_ERRS; if (p[5] & 0x20) *p_read_cap |= CDIO_DRIVE_CAP_READ_ISRC; + if (p[5] & 0x40) *p_read_cap |= CDIO_DRIVE_CAP_READ_MCN; /* Writer */ if (p[3] & 0x01) *p_write_cap |= CDIO_DRIVE_CAP_WRITE_CD_R; @@ -508,6 +523,29 @@ mmc_get_disc_last_lsn ( const CdIo_t *p_cdio ) return retval; } +/*! + Read Audio Subchannel information + + @param p_cdio the CD object to be acted upon. + +*/ +driver_return_code_t +mmc_audio_read_subchannel (CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel) +{ + scsi_mmc_cdb_t cdb; + + if (!p_cdio) return DRIVER_OP_UNINIT; + + memset(&cdb, 0, sizeof(scsi_mmc_cdb_t)); + CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL); + cdb.field[1] = CDIO_CDROM_MSF; + cdb.field[2] = 0x40; /* subq */ + cdb.field[6] = 0x40; /* track number (only in isrc mode, ignored) */ + cdb.field[8] = 20; + return mmc_run_cmd(p_cdio, 2000, &cdb, SCSI_MMC_DATA_READ, + sizeof(cdio_subchannel_t), p_subchannel); +} + /*! Return the discmode as reported by the SCSI-MMC Read (FULL) TOC command. diff --git a/lib/driver/mmc_private.h b/lib/driver/mmc_private.h index b9642c2e..5e82c85d 100644 --- a/lib/driver/mmc_private.h +++ b/lib/driver/mmc_private.h @@ -1,6 +1,6 @@ /* private MMC helper routines. - $Id: mmc_private.h,v 1.6 2005/02/17 07:03:37 rocky Exp $ + $Id: mmc_private.h,v 1.7 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein @@ -37,6 +37,16 @@ msecs2secs(unsigned int msecs) MMC CdIo Operations which a driver may use. These are not directly user-accessible. ************************************************************/ +/*! + Read Audio Subchannel information + + @param p_user_data the CD object to be acted upon. + +*/ +driver_return_code_t +audio_read_subchannel_mmc ( void *p_user_data, + cdio_subchannel_t *p_subchannel); + /*! Get the block size for subsequest read requests, via a SCSI MMC MODE_SENSE 6 command. diff --git a/src/util.c b/src/util.c index ed900cc5..bcc1991a 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.45 2005/02/26 23:25:33 rocky Exp $ + $Id: util.c,v 1.46 2005/03/01 09:33:52 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -406,6 +406,8 @@ print_drive_capabilities(cdio_drive_read_cap_t i_read_cap, i_read_cap & CDIO_DRIVE_CAP_READ_C2_ERRS ? "Yes" : "No" ); report( stdout, _(" Can read IRSC : %s\n"), i_read_cap & CDIO_DRIVE_CAP_READ_ISRC ? "Yes" : "No" ); + report( stdout, _(" Can read MCN : %s\n"), + i_read_cap & CDIO_DRIVE_CAP_READ_MCN ? "Yes" : "No" ); report( stdout, _(" Can play audio : %s\n"), i_read_cap & CDIO_DRIVE_CAP_READ_AUDIO ? "Yes" : "No" ); report( stdout, _(" Can read CD-DA : %s\n"),