diff --git a/example/mmc2.c b/example/mmc2.c index e2bb6612..68b81c4a 100644 --- a/example/mmc2.c +++ b/example/mmc2.c @@ -1,5 +1,5 @@ /* - $Id: mmc2.c,v 1.3 2005/02/07 03:36:02 rocky Exp $ + $Id: mmc2.c,v 1.4 2005/02/08 04:14:28 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein @@ -67,250 +67,115 @@ main(int argc, const char *argv[]) uint8_t i_feature_additional = p[3]; i_feature = CDIO_MMC_GET_LEN16(p); - switch( i_feature ) - { - uint8_t *q; - case CDIO_MMC_FEATURE_PROFILE_LIST: - printf("Profile List Feature\n"); - for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) { - int i_profile=CDIO_MMC_GET_LEN16(q); - switch (i_profile) { - case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE: - printf("\tRe-writable disk, capable of changing behavior"); - break; - case CDIO_MMC_FEATURE_PROF_REMOVABLE: - printf("\tdisk Re-writable; with removable media"); - break; - case CDIO_MMC_FEATURE_PROF_MO_ERASABLE: - printf("\tErasable Magneto-Optical disk with sector erase capability"); - break; - case CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE: - printf("\tWrite Once Magneto-Optical write once"); - break; - case CDIO_MMC_FEATURE_PROF_AS_MO: - printf("\tAdvance Storage Magneto-Optical"); - break; - case CDIO_MMC_FEATURE_PROF_CD_ROM: - printf("\tRead only Compact Disc capable"); - break; - case CDIO_MMC_FEATURE_PROF_CD_R: - printf("\tWrite once Compact Disc capable"); - break; - case CDIO_MMC_FEATURE_PROF_CD_RW: - printf("\tCD-RW Re-writable Compact Disc capable"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_ROM: - printf("\tRead only DVD"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_R_SEQ: - printf("\tRe-recordable DVD using Sequential recording"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_RAM: - printf("\tRe-writable DVD"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_RW_RO: - printf("\tRe-recordable DVD using Restricted Overwrite"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ: - printf("\tRe-recordable DVD using Sequential recording"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_PRW: - printf("\tDVD+RW - DVD ReWritable"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_PR: - printf("\tDVD+R - DVD Recordable"); - break; - case CDIO_MMC_FEATURE_PROF_DDCD_ROM: - printf("\tRead only DDCD"); - break; - case CDIO_MMC_FEATURE_PROF_DDCD_R: - printf("\tDDCD-R Write only DDCD"); - break; - case CDIO_MMC_FEATURE_PROF_DDCD_RW: - printf("\tRe-Write only DDCD"); - break; - case CDIO_MMC_FEATURE_PROF_NON_CONFORM: - printf("\tThe Logical Unit does not conform to any Profile."); - break; - default: - printf("\tUnknown Profile %x", i_profile); - break; - } - if (q[2] & 1) { - printf(" - on"); + { + uint8_t *q; + const char *feature_str = mmc_feature2str(i_feature); + printf("%s Feature\n", feature_str); + switch( i_feature ) + { + case CDIO_MMC_FEATURE_PROFILE_LIST: + for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) { + int i_profile=CDIO_MMC_GET_LEN16(q); + const char *feature_profile_str = + mmc_feature_profile2str(i_profile); + printf( "\t%s", feature_profile_str ); + if (q[2] & 1) { + printf(" - on"); + } + printf("\n"); } printf("\n"); - } - printf("\n"); - break; - case CDIO_MMC_FEATURE_CORE: - { - uint8_t *q = p+4; - uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q); - printf("Core Feature\n"); - switch(i_interface_standard) { - case 0: - printf("\tunspecified interface\n"); + break; + case CDIO_MMC_FEATURE_CORE: + { + uint8_t *q = p+4; + uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q); + switch(i_interface_standard) { + case 0: + printf("\tunspecified interface\n"); + break; + case 1: + printf("\tSCSI interface\n"); + break; + case 2: + printf("\tATAPI interface\n"); + break; + case 3: + printf("\tIEEE 1394 interface\n"); + break; + case 4: + printf("\tIEEE 1394A interface\n"); + break; + case 5: + printf("\tFibre Channel interface\n"); + } + printf("\n"); break; - case 1: - printf("\tSCSI interface\n"); + } + case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM: + switch(p[4] >> 5) { + case 0: + printf("\tCaddy/Slot type loading mechanism\n"); break; - case 2: - printf("\tATAPI interface\n"); + case 1: + printf("\tTray type loading mechanism\n"); break; - case 3: - printf("\tIEEE 1394 interface\n"); + case 2: + printf("\tPop-up type loading mechanism\n"); break; case 4: - printf("\tIEEE 1394A interface\n"); + printf("\tEmbedded changer with individually changeable discs\n"); break; case 5: - printf("\tFibre Channel interface\n"); + printf("\tEmbedded changer using a magazine mechanism\n"); + break; + default: + printf("\tUnknown changer mechanism\n"); + } + + printf("\tcan%s eject the medium or magazine via the normal " + "START/STOP command\n", + (p[4] & 8) ? "": "not"); + printf("\tcan%s be locked into the Logical Unit\n", + (p[4] & 1) ? "": "not"); + printf("\n"); + break; + case CDIO_MMC_FEATURE_CD_READ: + printf("CD Read Feature\n"); + printf("\tC2 Error pointers are %ssupported\n", + (p[4] & 2) ? "": "not "); + printf("\tCD-Text is %ssupported\n", + (p[4] & 1) ? "": "not "); + printf("\n"); + break; + case CDIO_MMC_FEATURE_CDDA_EXT_PLAY: + printf("\tSCAN command is %ssupported\n", + (p[4] & 4) ? "": "not "); + printf("\taudio channels can %sbe muted separately\n", + (p[4] & 2) ? "": "not "); + printf("\taudio channels can %shave separate volume levels\n", + (p[4] & 1) ? "": "not "); + { + uint8_t *q = p+6; + uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q); + printf("\t%d volume levels can be set\n", i_vol_levels); } printf("\n"); break; + case CDIO_MMC_FEATURE_LU_SN: { + uint8_t i_serial = *(p+3); + char serial[257] = { '\0', }; + memcpy(serial, p+4, i_serial); + printf("\t%s\n\n", serial); + break; } - case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM: - printf("Removable Medium Feature\n"); - switch(p[4] >> 5) { - case 0: - printf("\tCaddy/Slot type loading mechanism\n"); + default: + printf("\n"); break; - case 1: - printf("\tTray type loading mechanism\n"); - break; - case 2: - printf("\tPop-up type loading mechanism\n"); - break; - case 4: - printf("\tEmbedded changer with individually changeable discs\n"); - break; - case 5: - printf("\tEmbedded changer using a magazine mechanism\n"); - break; - default: - printf("\tUnknown changer mechanism\n"); } - - printf("\tcan%s eject the medium or magazine via the normal " - "START/STOP command\n", - (p[4] & 8) ? "": "not"); - printf("\tcan%s be locked into the Logical Unit\n", - (p[4] & 1) ? "": "not"); - printf("\n"); - break; - case CDIO_MMC_FEATURE_WRITE_PROTECT: - printf("Write Protect Feature\n"); - break; - case CDIO_MMC_FEATURE_RANDOM_READABLE: - printf("Random Readable Feature\n"); - break; - case CDIO_MMC_FEATURE_MULTI_READ: - printf("Multi-Read Feature\n"); - break; - case CDIO_MMC_FEATURE_CD_READ: - printf("CD Read Feature\n"); - printf("\tC2 Error pointers are %ssupported\n", - (p[4] & 2) ? "": "not "); - printf("\tCD-Text is %ssupported\n", - (p[4] & 1) ? "": "not "); - printf("\n"); - break; - case CDIO_MMC_FEATURE_DVD_READ: - printf("DVD Read Feature\n"); - break; - case CDIO_MMC_FEATURE_RANDOM_WRITABLE: - printf("Random Writable Feature\n"); - break; - case CDIO_MMC_FEATURE_INCR_WRITE: - printf("Incremental Streaming Writable Feature\n"); - break; - case CDIO_MMC_FEATURE_SECTOR_ERASE: - printf("Sector Erasable Feature\n"); - break; - case CDIO_MMC_FEATURE_FORMATABLE: - printf("Formattable Feature\n"); - break; - case CDIO_MMC_FEATURE_DEFECT_MGMT: - printf("Management Ability of the Logical Unit/media system " - "to provide an apparently defect-free space.\n"); - break; - case CDIO_MMC_FEATURE_WRITE_ONCE: - printf("Write Once Feature\n"); - break; - case CDIO_MMC_FEATURE_RESTRICT_OVERW: - printf("Restricted Overwrite Feature\n"); - break; - case CDIO_MMC_FEATURE_CD_RW_CAV: - printf("CD-RW CAV Write Feature\n"); - break; - case CDIO_MMC_FEATURE_MRW: - printf("MRW Feature\n"); - break; - case CDIO_MMC_FEATURE_DVD_PRW: - printf("DVD+RW Feature\n"); - break; - case CDIO_MMC_FEATURE_DVD_PR: - printf("DVD+R Feature\n"); - break; - case CDIO_MMC_FEATURE_CD_TAO: - printf("CD Track at Once Feature\n"); - break; - case CDIO_MMC_FEATURE_CD_SAO: - printf("CD Mastering (Session at Once) Feature\n"); - break; - case CDIO_MMC_FEATURE_POWER_MGMT: - printf("Initiator and device directed power management\n"); - break; - case CDIO_MMC_FEATURE_CDDA_EXT_PLAY: - printf("CD Audio External Play Feature\n"); - printf("\tSCAN command is %ssupported\n", - (p[4] & 4) ? "": "not "); - printf("\taudio channels can %sbe muted separately\n", - (p[4] & 2) ? "": "not "); - printf("\taudio channels can %shave separate volume levels\n", - (p[4] & 1) ? "": "not "); - { - uint8_t *q = p+6; - uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q); - printf("\t%d volume levels can be set\n", i_vol_levels); - } - printf("\n"); - break; - case CDIO_MMC_FEATURE_MCODE_UPGRADE: - printf("Ability for the device to accept new microcode via " - "the interface\n"); - break; - case CDIO_MMC_FEATURE_TIME_OUT: - printf("Ability to respond to all commands within a " - "specific time\n"); - break; - case CDIO_MMC_FEATURE_DVD_CSS: - printf("Ability to perform DVD CSS/CPPM authentication and" - " RPC\n"); - break; - case CDIO_MMC_FEATURE_RT_STREAMING: - printf("Ability to read and write using Initiator requested performance parameters\n"); - break; - case CDIO_MMC_FEATURE_LU_SN: { - uint8_t i_serial = *(p+3); - char serial[257] = { '\0', }; - - printf("The Logical Unit has a unique identifier:\n"); - memcpy(serial, p+4, i_serial); - printf("\t%s\n\n", serial); - - break; - } - default: - if ( 0 != (i_feature & 0xFF00) ) { - printf("Vendor-specific feature code %x\n", i_feature); - } else { - printf("Unknown feature code %x\n", i_feature); - } - } - p += i_feature_additional + 4; + p += i_feature_additional + 4; + } } } else { printf("Didn't get all feature codes\n"); diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h index a9d18bbd..06a06dca 100644 --- a/include/cdio/mmc.h +++ b/include/cdio/mmc.h @@ -1,5 +1,5 @@ /* - $Id: mmc.h,v 1.3 2005/02/07 17:09:31 rocky Exp $ + $Id: mmc.h,v 1.4 2005/02/08 04:14:28 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -238,8 +238,10 @@ typedef enum { identifier. */ CDIO_MMC_FEATURE_FIRMWARE_DATE = 0x1FF, /**< Firmware creation date report */ +} mmc_feature_t; -/*! Profile codes used in GET_CONFIGURATION - PROFILE LIST. */ +/*! Profile profile codes used in GET_CONFIGURATION - PROFILE LIST. */ +typedef enum { CDIO_MMC_FEATURE_PROF_NON_REMOVABLE = 0x0001, /**< Re-writable disk, capable of changing behavior */ CDIO_MMC_FEATURE_PROF_REMOVABLE = 0x0002, /**< disk Re-writable; with @@ -274,7 +276,7 @@ typedef enum { double layer */ CDIO_MMC_FEATURE_PROF_NON_CONFORM = 0xFFFF, /**< The Logical Unit does not conform to any Profile. */ -} mmc_feature_t; +} mmc_feature_profile_t; typedef enum { CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED = 0, @@ -368,6 +370,16 @@ typedef enum scsi_mmc_direction { */ int mmc_eject_media( const CdIo_t *p_cdio ); +/*! + Return a string containing the name of the given feature + */ +const char *mmc_feature2str( int i_feature ); + +/*! + Return a string containing the name of the given feature + */ +const char *mmc_feature_profile2str( int i_feature_profile ); + /*! Return the length in bytes of the Command Descriptor Buffer (CDB) for a given MMC command. The length will be diff --git a/lib/driver/libcdio.sym b/lib/driver/libcdio.sym index 1d735082..3d27063d 100644 --- a/lib/driver/libcdio.sym +++ b/lib/driver/libcdio.sym @@ -147,8 +147,21 @@ cdtext_init cdtext_is_keyword cdtext_set discmode2str +mmc_eject_media +mmc_get_blocksize +mmc_get_discmode +mmc_get_dvd_struct_physical +mmc_get_cmd_len +mmc_get_media_changed +mmc_get_mcn mmc_get_hwinfo +mmc_get_last_lsn +mmc_feature2str +mmc_feature_profile2str mmc_have_interface +mmc_read_sectors mmc_run_cmd +mmc_set_blocksize +mmc_set_speed track_format2str CDIO_SECTOR_SYNC_HEADER diff --git a/lib/driver/mmc.c b/lib/driver/mmc.c index b7995068..3f3dbcad 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.3 2005/02/07 03:36:02 rocky Exp $ + $Id: mmc.c,v 1.4 2005/02/08 04:14:28 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein @@ -36,6 +36,10 @@ #include #endif +#ifdef HAVE_STDIO_H +#include +#endif + #ifdef HAVE_ERRNO_H #include #endif @@ -767,6 +771,154 @@ mmc_eject_media( const CdIo_t *p_cdio ) } +/*! + Return a string containing the name of the given feature + */ +const char *mmc_feature2str( int i_feature ) +{ + switch(i_feature) { + case CDIO_MMC_FEATURE_PROFILE_LIST: + return "Profile List"; + case CDIO_MMC_FEATURE_CORE: + return "Core"; + case CDIO_MMC_FEATURE_MORPHING: + return "Morphing" ; + case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM: + return "Removable Medium"; + case CDIO_MMC_FEATURE_WRITE_PROTECT: + return "Write Protect"; + case CDIO_MMC_FEATURE_RANDOM_READABLE: + return "Random Readable"; + case CDIO_MMC_FEATURE_MULTI_READ: + return "Multi-Read"; + case CDIO_MMC_FEATURE_CD_READ: + return "CD Read"; + case CDIO_MMC_FEATURE_DVD_READ: + return "DVD Read"; + case CDIO_MMC_FEATURE_RANDOM_WRITABLE: + return "Random Writable"; + case CDIO_MMC_FEATURE_INCR_WRITE: + return "Incremental Streaming Writable"; + case CDIO_MMC_FEATURE_SECTOR_ERASE: + return "Sector Erasable"; + case CDIO_MMC_FEATURE_FORMATABLE: + return "Formattable"; + case CDIO_MMC_FEATURE_DEFECT_MGMT: + return "Management Ability of the Logical Unit/media system " + "to provide an apparently defect-free space."; + case CDIO_MMC_FEATURE_WRITE_ONCE: + return "Write Once"; + case CDIO_MMC_FEATURE_RESTRICT_OVERW: + return "Restricted Overwrite"; + case CDIO_MMC_FEATURE_CD_RW_CAV: + return "CD-RW CAV Write"; + case CDIO_MMC_FEATURE_MRW: + return "MRW"; + case CDIO_MMC_FEATURE_ENHANCED_DEFECT: + return "Enhanced Defect Reporting"; + case CDIO_MMC_FEATURE_DVD_PRW: + return "DVD+RW"; + case CDIO_MMC_FEATURE_DVD_PR: + return "DVD+R"; + case CDIO_MMC_FEATURE_CD_TAO: + return "CD Track at Once"; + case CDIO_MMC_FEATURE_CD_SAO: + return "CD Mastering (Session at Once)"; + case CDIO_MMC_FEATURE_DVD_R_RW_WRITE: + return "DVD-R/RW Write"; + case CDIO_MMC_FEATURE_CD_RW_MEDIA_WRITE: + return "CD-RW Media Write Support"; + case CDIO_MMC_FEATURE_DVD_PR_2_LAYER: + return "DVD+R Double Layer"; + case CDIO_MMC_FEATURE_POWER_MGMT: + return "Initiator- and Device-directed Power Management"; + case CDIO_MMC_FEATURE_CDDA_EXT_PLAY: + return "CD Audio External Play"; + case CDIO_MMC_FEATURE_MCODE_UPGRADE: + return "Ability for the device to accept new microcode via the interface"; + case CDIO_MMC_FEATURE_TIME_OUT: + return "Ability to respond to all commands within a specific time"; + case CDIO_MMC_FEATURE_DVD_CSS: + return "Ability to perform DVD CSS/CPPM authentication via RPC"; + case CDIO_MMC_FEATURE_RT_STREAMING: + return "Ability to read and write using Initiator requested performance" + " parameters"; + case CDIO_MMC_FEATURE_LU_SN: + return "The Logical Unit Unique Identifier"; + default: + { + static char buf[100]; + if ( 0 != (i_feature & 0xFF00) ) { + snprintf( buf, sizeof(buf), + "Vendor-specific code %x", i_feature ); + } else { + snprintf( buf, sizeof(buf), + "Unknown code %x", i_feature ); + } + return buf; + } + } +} + + +/*! + Return a string containing the name of the given feature profile. + */ +const char *mmc_feature_profile2str( int i_feature_profile ) +{ + switch(i_feature_profile) { + case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE: + return "Non-removable"; + case CDIO_MMC_FEATURE_PROF_REMOVABLE: + return "disk Re-writable; with removable media"; + case CDIO_MMC_FEATURE_PROF_MO_ERASABLE: + return "Erasable Magneto-Optical disk with sector erase capability"; + case CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE: + return "Write Once Magneto-Optical write once"; + case CDIO_MMC_FEATURE_PROF_AS_MO: + return "Advance Storage Magneto-Optical"; + case CDIO_MMC_FEATURE_PROF_CD_ROM: + return "Read only Compact Disc capable"; + case CDIO_MMC_FEATURE_PROF_CD_R: + return "Write once Compact Disc capable"; + case CDIO_MMC_FEATURE_PROF_CD_RW: + return "CD-RW Re-writable Compact Disc capable"; + case CDIO_MMC_FEATURE_PROF_DVD_ROM: + return "Read only DVD"; + case CDIO_MMC_FEATURE_PROF_DVD_R_SEQ: + return "Re-recordable DVD using Sequential recording"; + case CDIO_MMC_FEATURE_PROF_DVD_RAM: + return "Re-writable DVD"; + case CDIO_MMC_FEATURE_PROF_DVD_RW_RO: + return "Re-recordable DVD using Restricted Overwrite"; + case CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ: + return "Re-recordable DVD using Sequential recording"; + case CDIO_MMC_FEATURE_PROF_DVD_PRW: + return "DVD+RW - DVD ReWritable"; + case CDIO_MMC_FEATURE_RIGID_RES_OVERW: + return "Rigid Restricted Overwrite"; + case CDIO_MMC_FEATURE_PROF_DVD_PR: + return "DVD+R - DVD Recordable"; + case CDIO_MMC_FEATURE_PROF_DDCD_ROM: + return "Read only DDCD"; + case CDIO_MMC_FEATURE_PROF_DVD_PR2: + return "DVD+R Double Layer - DVD Recordable Double Layer"; + case CDIO_MMC_FEATURE_PROF_DDCD_R: + return "DDCD-R Write only DDCD"; + case CDIO_MMC_FEATURE_PROF_DDCD_RW: + return "Re-Write only DDCD"; + case CDIO_MMC_FEATURE_PROF_NON_CONFORM: + return "The Logical Unit does not conform to any Profile"; + default: + { + static char buf[100]; + snprintf(buf, sizeof(buf), "Unknown Profile %x", i_feature_profile); + return buf; + } + } +} + + /*! * See if CD-ROM has feature with value value * @return true if we have the feature and false if not. diff --git a/src/util.c b/src/util.c index 31d8a5e9..40050d14 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.34 2005/02/07 12:12:14 rocky Exp $ + $Id: util.c,v 1.35 2005/02/08 04:14:28 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -21,7 +21,7 @@ /* Miscellaneous things common to standalone programs. */ #include "util.h" -#include +#include cdio_log_handler_t gl_default_cdio_log_handler = NULL; char *source_name = NULL; @@ -202,321 +202,146 @@ print_mmc_drive_features(CdIo_t *p_cdio) uint8_t i_feature_additional = p[3]; i_feature = CDIO_MMC_GET_LEN16(p); - switch( i_feature ) - { - uint8_t *q; - case CDIO_MMC_FEATURE_PROFILE_LIST: - report( stdout, "Profile List Feature\n"); - for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) { - int i_profile=CDIO_MMC_GET_LEN16(q); - switch (i_profile) { - case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE: - report( stdout, - "\tRe-writable disk, capable of changing behavior"); - break; - case CDIO_MMC_FEATURE_PROF_REMOVABLE: - report( stdout, - "\tdisk Re-writable; with removable media"); - break; - case CDIO_MMC_FEATURE_PROF_MO_ERASABLE: - report( stdout, - "\tErasable Magneto-Optical disk with sector erase capability"); - break; - case CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE: - report( stdout, - "\tWrite Once Magneto-Optical write once"); - break; - case CDIO_MMC_FEATURE_PROF_AS_MO: - report( stdout, - "\tAdvance Storage Magneto-Optical"); - break; - case CDIO_MMC_FEATURE_PROF_CD_ROM: - report( stdout, - "\tRead only Compact Disc capable"); - break; - case CDIO_MMC_FEATURE_PROF_CD_R: - report( stdout, - "\tWrite once Compact Disc capable"); - break; - case CDIO_MMC_FEATURE_PROF_CD_RW: - report( stdout, - "\tCD-RW Re-writable Compact Disc capable"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_ROM: - report( stdout, - "\tRead only DVD"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_R_SEQ: - report( stdout, - "\tRe-recordable DVD using Sequential recording"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_RAM: - report( stdout, - "\tRe-writable DVD"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_RW_RO: - report( stdout, - "\tRe-recordable DVD using Restricted Overwrite"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ: - report( stdout, - "\tRe-recordable DVD using Sequential recording"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_PRW: - report( stdout, - "\tDVD+RW - DVD ReWritable"); - break; - case CDIO_MMC_FEATURE_RIGID_RES_OVERW: - report( stdout, - "\tRigid Restricted Overwrite"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_PR: - report( stdout, - "\tDVD+R - DVD Recordable"); - break; - case CDIO_MMC_FEATURE_PROF_DDCD_ROM: - report( stdout, - "\tRead only DDCD"); - break; - case CDIO_MMC_FEATURE_PROF_DVD_PR2: - report( stdout, - "\tDVD+R Double Layer - DVD Recordable Double Layer"); - break; - case CDIO_MMC_FEATURE_PROF_DDCD_R: - report( stdout, - "\tDDCD-R Write only DDCD"); - break; - case CDIO_MMC_FEATURE_PROF_DDCD_RW: - report( stdout, - "\tRe-Write only DDCD"); - break; - case CDIO_MMC_FEATURE_PROF_NON_CONFORM: - report( stdout, - "\tThe Logical Unit does not conform to any Profile."); - break; - default: - report( stdout, - "\tUnknown Profile %x", i_profile); - break; - } - if (q[2] & 1) { - report( stdout, " - on"); + { + uint8_t *q; + const char *feature_str = mmc_feature2str(i_feature); + report( stdout, "%s Feature\n", feature_str); + switch( i_feature ) + { + case CDIO_MMC_FEATURE_PROFILE_LIST: + for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) { + int i_profile=CDIO_MMC_GET_LEN16(q); + const char *feature_profile_str = + mmc_feature_profile2str(i_profile); + report( stdout, "\t%s", feature_profile_str ); + if (q[2] & 1) { + report( stdout, " - on"); + } + report( stdout, "\n"); } report( stdout, "\n"); - } - report( stdout, "\n"); - - break; - case CDIO_MMC_FEATURE_CORE: - { - uint8_t *q = p+4; - uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q); - report( stdout, "Core Feature\n"); - switch(i_interface_standard) { - case CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED: - report( stdout, "\tunspecified interface\n"); + + break; + case CDIO_MMC_FEATURE_CORE: + { + uint8_t *q = p+4; + uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q); + switch(i_interface_standard) { + case CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED: + report( stdout, "\tunspecified interface\n"); + break; + case CDIO_MMC_FEATURE_INTERFACE_SCSI: + report( stdout, "\tSCSI interface\n"); + break; + case CDIO_MMC_FEATURE_INTERFACE_ATAPI: + report( stdout, "\tATAPI interface\n"); + break; + case CDIO_MMC_FEATURE_INTERFACE_IEEE_1394: + report( stdout, "\tIEEE 1394 interface\n"); + break; + case CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A: + report( stdout, "\tIEEE 1394A interface\n"); + break; + case CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH: + report( stdout, "\tFibre Channel interface\n"); + } + report( stdout, "\n"); break; - case CDIO_MMC_FEATURE_INTERFACE_SCSI: - report( stdout, "\tSCSI interface\n"); + } + case CDIO_MMC_FEATURE_MORPHING: + report( stdout, + "\tOperational Change Request/Notification %ssupported\n", + (p[4] & 2) ? "": "not " ); + report( stdout, "\t%synchronous GET EVENT/STATUS NOTIFICATION " + "supported\n", + (p[4] & 1) ? "As": "S" ); + report( stdout, "\n"); + break; + ; + + case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM: + switch(p[4] >> 5) { + case 0: + report( stdout, + "\tCaddy/Slot type loading mechanism\n" ); break; - case CDIO_MMC_FEATURE_INTERFACE_ATAPI: - report( stdout, "\tATAPI interface\n"); + case 1: + report( stdout, + "\tTray type loading mechanism\n" ); break; - case CDIO_MMC_FEATURE_INTERFACE_IEEE_1394: - report( stdout, "\tIEEE 1394 interface\n"); + case 2: + report( stdout, "\tPop-up type loading mechanism\n"); break; - case CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A: - report( stdout, "\tIEEE 1394A interface\n"); + case 4: + report( stdout, + "\tEmbedded changer with individually changeable discs\n"); break; - case CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH: - report( stdout, "\tFibre Channel interface\n"); + case 5: + report( stdout, + "\tEmbedded changer using a magazine mechanism\n" ); + break; + default: + report( stdout, + "\tUnknown changer mechanism\n" ); + } + + report( stdout, + "\tcan%s eject the medium or magazine via the normal " + "START/STOP command\n", + (p[4] & 8) ? "": "not" ); + report( stdout, "\tcan%s be locked into the Logical Unit\n", + (p[4] & 1) ? "": "not" ); + report( stdout, "\n" ); + break; + case CDIO_MMC_FEATURE_CD_READ: + report( stdout, "\tC2 Error pointers are %ssupported\n", + (p[4] & 2) ? "": "not " ); + report( stdout, "\tCD-Text is %ssupported\n", + (p[4] & 1) ? "": "not " ); + report( stdout, "\n" ); + break; + case CDIO_MMC_FEATURE_ENHANCED_DEFECT: + report( stdout, "\t%s-DRM mode is supported\n", + (p[4] & 1) ? "DRT": "Persistent" ); + break; + case CDIO_MMC_FEATURE_CDDA_EXT_PLAY: + report( stdout, "\tSCAN command is %ssupported\n", + (p[4] & 4) ? "": "not "); + report( stdout, + "\taudio channels can %sbe muted separately\n", + (p[4] & 2) ? "": "not "); + report( stdout, + "\taudio channels can %shave separate volume levels\n", + (p[4] & 1) ? "": "not "); + { + uint8_t *q = p+6; + uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q); + report( stdout, "\t%d volume levels can be set\n", i_vol_levels ); } report( stdout, "\n"); break; - } - case CDIO_MMC_FEATURE_MORPHING: - report( stdout, "Morphing Feature\n" ); - report( stdout, - "\tOperational Change Request/Notification %ssupported\n", - (p[4] & 2) ? "": "not " ); - report( stdout, "\t%synchronous GET EVENT/STATUS NOTIFICATION " - "supported\n", - (p[4] & 1) ? "As": "S" ); - report( stdout, "\n"); - break; - ; - - case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM: - report( stdout, "Removable Medium Feature\n" ); - switch(p[4] >> 5) { - case 0: - report( stdout, - "\tCaddy/Slot type loading mechanism\n" ); - break; - case 1: - report( stdout, - "\tTray type loading mechanism\n" ); - break; - case 2: - report( stdout, "\tPop-up type loading mechanism\n"); - break; - case 4: - report( stdout, - "\tEmbedded changer with individually changeable discs\n"); - break; - case 5: - report( stdout, - "\tEmbedded changer using a magazine mechanism\n" ); - break; - default: - report( stdout, - "\tUnknown changer mechanism\n" ); - } - - report( stdout, - "\tcan%s eject the medium or magazine via the normal " - "START/STOP command\n", - (p[4] & 8) ? "": "not" ); - report( stdout, "\tcan%s be locked into the Logical Unit\n", - (p[4] & 1) ? "": "not" ); - report( stdout, "\n" ); - break; - case CDIO_MMC_FEATURE_WRITE_PROTECT: - report( stdout, "Write Protect Feature\n" ); - break; - case CDIO_MMC_FEATURE_RANDOM_READABLE: - report( stdout, "Random Readable Feature\n" ); - break; - case CDIO_MMC_FEATURE_MULTI_READ: - report( stdout, "Multi-Read Feature\n" ); - break; - case CDIO_MMC_FEATURE_CD_READ: - report( stdout, "CD Read Feature\n" ); - report( stdout, "\tC2 Error pointers are %ssupported\n", - (p[4] & 2) ? "": "not " ); - report( stdout, "\tCD-Text is %ssupported\n", - (p[4] & 1) ? "": "not " ); - report( stdout, "\n" ); - break; - case CDIO_MMC_FEATURE_DVD_READ: - report( stdout, "DVD Read Feature\n" ); - break; - case CDIO_MMC_FEATURE_RANDOM_WRITABLE: - report( stdout, "Random Writable Feature\n" ); - break; - case CDIO_MMC_FEATURE_INCR_WRITE: - report( stdout, "Incremental Streaming Writable Feature\n" ); - break; - case CDIO_MMC_FEATURE_SECTOR_ERASE: - report( stdout, "Sector Erasable Feature\n" ); - break; - case CDIO_MMC_FEATURE_FORMATABLE: - report( stdout, "Formattable Feature\n" ); - break; - case CDIO_MMC_FEATURE_DEFECT_MGMT: - report( stdout, - "Management Ability of the Logical Unit/media system " - "to provide an apparently defect-free space.\n" ); - break; - case CDIO_MMC_FEATURE_WRITE_ONCE: - report( stdout, "Write Once Feature\n" ); - break; - case CDIO_MMC_FEATURE_RESTRICT_OVERW: - report( stdout, "Restricted Overwrite Feature\n" ); - break; - case CDIO_MMC_FEATURE_CD_RW_CAV: - report( stdout, "CD-RW CAV Write Feature\n" ); - break; - case CDIO_MMC_FEATURE_MRW: - report( stdout, "MRW Feature\n" ); - break; - case CDIO_MMC_FEATURE_ENHANCED_DEFECT: - report( stdout, "Enhanced Defect Reporting\n" ); - report( stdout, "\t%s-DRM mode is supported\n", - (p[4] & 1) ? "DRT": "Persistent" ); - break; - case CDIO_MMC_FEATURE_DVD_PRW: - report( stdout, "DVD+RW Feature\n" ); - break; - case CDIO_MMC_FEATURE_DVD_PR: - report( stdout, "DVD+R Feature\n" ); - break; - case CDIO_MMC_FEATURE_CD_TAO: - report( stdout, "CD Track at Once Feature\n" ); - break; - case CDIO_MMC_FEATURE_CD_SAO: - report( stdout, "CD Mastering (Session at Once) Feature\n" ); - break; - case CDIO_MMC_FEATURE_DVD_R_RW_WRITE: - report( stdout, "DVD-R/RW Write Feature\n" ); - break; - case CDIO_MMC_FEATURE_CD_RW_MEDIA_WRITE: - report( stdout, "CD-RW Media Write Support\n" ); - break; - case CDIO_MMC_FEATURE_DVD_PR_2_LAYER: - report( stdout, "DVD+R Double Layer\n" ); - break; - case CDIO_MMC_FEATURE_POWER_MGMT: - report( stdout, - "Initiator and device directed power management\n" ); - break; - case CDIO_MMC_FEATURE_CDDA_EXT_PLAY: - report( stdout, "CD Audio External Play Feature\n" ); - report( stdout, "\tSCAN command is %ssupported\n", - (p[4] & 4) ? "": "not "); - report( stdout, - "\taudio channels can %sbe muted separately\n", - (p[4] & 2) ? "": "not "); - report( stdout, - "\taudio channels can %shave separate volume levels\n", - (p[4] & 1) ? "": "not "); - { - uint8_t *q = p+6; - uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q); - report( stdout, "\t%d volume levels can be set\n", i_vol_levels ); - } - report( stdout, "\n"); - break; - case CDIO_MMC_FEATURE_MCODE_UPGRADE: - report( stdout, "Ability for the device to accept new microcode via " - "the interface\n" ); - break; - case CDIO_MMC_FEATURE_TIME_OUT: - report( stdout, "Ability to respond to all commands within a " - "specific time\n" ); - break; - case CDIO_MMC_FEATURE_DVD_CSS: - report( stdout, "Ability to perform DVD CSS/CPPM authentication and" - " RPC\n" ); + case CDIO_MMC_FEATURE_DVD_CSS: #if 0 - report( stdout, "\tMedium does%s have Content Scrambling (CSS/CPPM)\n", - (p[2] & 1) ? "": "not " ); + report( stdout, "\tMedium does%s have Content Scrambling (CSS/CPPM)\n", + (p[2] & 1) ? "": "not " ); #endif - report( stdout, "\tCSS version %d\n", p[7] ); - report( stdout, "\t\n"); - break; - case CDIO_MMC_FEATURE_RT_STREAMING: - report( stdout, - "Ability to read and write using Initiator requested performance parameters\n"); - break; - case CDIO_MMC_FEATURE_LU_SN: { - uint8_t i_serial = *(p+3); - char serial[257] = { '\0', }; - - report( stdout, "The Logical Unit has a unique identifier:\n" ); - memcpy(serial, p+4, i_serial ); - report( stdout, "\t%s\n\n", serial ); - - break; - } - default: - if ( 0 != (i_feature & 0xFF00) ) { - report( stdout, "Vendor-specific feature code %x\n", i_feature ); - } else { - report( stdout, "Unknown feature code %x\n", i_feature ); + report( stdout, "\tCSS version %d\n", p[7] ); + report( stdout, "\t\n"); + break; + case CDIO_MMC_FEATURE_LU_SN: { + uint8_t i_serial = *(p+3); + char serial[257] = { '\0', }; + + memcpy(serial, p+4, i_serial ); + report( stdout, "\t%s\n\n", serial ); + + break; } - - } + default: + report( stdout, "\n"); + break; + } + } p += i_feature_additional + 4; } } else {