diff --git a/example/mmc2.c b/example/mmc2.c index e98cd0fd..6c3e9fa7 100644 --- a/example/mmc2.c +++ b/example/mmc2.c @@ -188,7 +188,7 @@ main(int argc, const char *argv[]) } } - if (mmc_have_interface(p_cdio, CDIO_MMC_FEATURE_INTERFACE_ATAPI)) + if (mmc_get_interface(p_cdio) == CDIO_MMC_FEATURE_INTERFACE_ATAPI) printf("CD-ROM is an ATAPI interface.\n"); else printf("CD-ROM is not an ATAPI interface.\n"); diff --git a/include/cdio++/mmc.hpp b/include/cdio++/mmc.hpp index e94169b4..1d5a90e2 100644 --- a/include/cdio++/mmc.hpp +++ b/include/cdio++/mmc.hpp @@ -153,14 +153,19 @@ void mmcAudioGetVolume (mmc_audio_volume_t *p_volume) } /** - Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...) - Is it possible for an interface to have serveral? If not this - routine could probably return the single mmc_feature_interface_t. - @return true if we have the interface and false if not. -*/ -bool_3way_t mmcHaveInterface( cdio_mmc_feature_interface_t e_interface ) + Return interface of device. + As per MMC6, Table 94, Note 7, in the case of a two-interface + scheme (USB-ATAPI bridge) the drive may not be aware, so only + ATAPI is returned. + Also it seems there is no way for the drive to return more than + one interface at all. + On MMC1 devices, where it is not specified, we will return + interface as CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED. + @return interface of the device. + */ +cdio_mmc_feature_interface_t mmcGetInterface() { - return mmc_have_interface( p_cdio, e_interface ); + return mmc_get_interface( p_cdio ); } /** diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h index ee5421cb..a7676c59 100644 --- a/include/cdio/mmc.h +++ b/include/cdio/mmc.h @@ -409,7 +409,11 @@ typedef enum { CDIO_MMC_FEATURE_INTERFACE_ATAPI = 2, CDIO_MMC_FEATURE_INTERFACE_IEEE_1394 = 3, CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A = 4, - CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH = 5 + CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH = 5, + CDIO_MMC_FEATURE_INTERFACE_IEEE_1394B = 6, + CDIO_MMC_FEATURE_INTERFACE_SATA = 7, + CDIO_MMC_FEATURE_INTERFACE_USB = 8, + CDIO_MMC_FEATURE_INTERFACE_VENDOR_UNIQ = 0xFFFF } cdio_mmc_feature_interface_t; @@ -660,15 +664,18 @@ driver_return_code_t mmc_audio_get_volume (CdIo_t *p_cdio, /*out*/ char * mmc_get_mcn(const CdIo_t *p_cdio); /** - Report if CD-ROM has a particular kind of interface (ATAPI, SCSCI, ...) - Is it possible for an interface to have several? If not this - routine could probably return the single mmc_feature_interface_t. + Return interface of device. + As per MMC6, Table 94, Note 7, in the case of a two-interface + scheme (USB-ATAPI bridge) the drive may not be aware, so only + ATAPI is returned. + Also it seems there is no way for the drive to return more than + one interface at all. + On MMC1 devices, where it is not specified, we will return + interface as CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED. @param p_cdio the CD object to be acted upon. - @param e_interface - @return true if we have the interface and false if not. + @return interface of the device. */ - bool_3way_t mmc_have_interface(CdIo_t *p_cdio, - cdio_mmc_feature_interface_t e_interface ); + cdio_mmc_feature_interface_t mmc_get_interface(CdIo_t *p_cdio); /** diff --git a/lib/driver/device.c b/lib/driver/device.c index 8df6db09..1c47fdad 100644 --- a/lib/driver/device.c +++ b/lib/driver/device.c @@ -833,11 +833,14 @@ cdio_get_media_changed(CdIo_t *p_cdio) bool_3way_t cdio_have_atapi(CdIo_t *p_cdio) { - bool_3way_t i_status; + cdio_mmc_feature_interface_t i_interface; if (!p_cdio) return nope; - i_status = mmc_have_interface(p_cdio, CDIO_MMC_FEATURE_INTERFACE_ATAPI); - if (dunno != i_status) return i_status; + i_interface = mmc_get_interface(p_cdio); + if (i_interface == CDIO_MMC_FEATURE_INTERFACE_ATAPI) + return yep; + if (i_interface != CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED) + return nope; { /* cdparanoia seems to think that if we have a mode sense command diff --git a/lib/driver/mmc/mmc.c b/lib/driver/mmc/mmc.c index 236c8347..07055410 100644 --- a/lib/driver/mmc/mmc.c +++ b/lib/driver/mmc/mmc.c @@ -971,17 +971,18 @@ mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms, } /** - See if CD-ROM has feature with value value - @return true if we have the feature and false if not. + Returns device's interface + @return interface of the device. */ -bool_3way_t -mmc_have_interface( CdIo_t *p_cdio, cdio_mmc_feature_interface_t e_interface ) +cdio_mmc_feature_interface_t +mmc_get_interface( CdIo_t *p_cdio ) { int i_status; /* Result of MMC command */ uint8_t buf[500] = { 0, }; /* Place to hold returned data */ mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */ - if (!p_cdio || !p_cdio->op.run_mmc_cmd) return nope; + if (!p_cdio || !p_cdio->op.run_mmc_cmd) + return CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED; CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION); CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf)); @@ -1007,13 +1008,13 @@ mmc_have_interface( CdIo_t *p_cdio, cdio_mmc_feature_interface_t e_interface ) if (CDIO_MMC_FEATURE_CORE == i_feature) { uint8_t *q = p+4; uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q); - if (e_interface == i_interface_standard) return yep; + return i_interface_standard; } p += i_feature_additional + 4; } - return nope; - } else - return dunno; + return CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED; + } else // If we can't get the interface, it is unspecified + return CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED; } /**