Add routine to report MMC capabilities of a drive. Add that to the

cd-drive program.
This commit is contained in:
rocky
2005-04-30 09:42:37 +00:00
parent 5a515d9140
commit 929770f419
5 changed files with 82 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.22 2005/04/30 02:04:29 rocky Exp $ # $Id: Makefile.am,v 1.23 2005/04/30 09:42:37 rocky Exp $
# #
# Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
# #
@@ -24,7 +24,8 @@ if !DISABLE_CPP
SUBDIRS = C++ SUBDIRS = C++
endif endif
noinst_PROGRAMS = audio cdtext device drives iso1 iso2 iso3 isofuzzy \ noinst_PROGRAMS = audio cdtext device drives iso1 iso2 iso3 isofuzzy \
mmc1 mmc2 paranoia paranoia2 tracks sample3 sample4 mmc1 mmc2 paranoia paranoia2 tracks \
sample3 sample4
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)

View File

@@ -1,5 +1,5 @@
/* /*
$Id: mmc.h,v 1.19 2005/03/21 09:19:06 rocky Exp $ $Id: mmc.h,v 1.20 2005/04/30 09:42:37 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -498,6 +498,20 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
/*out*/ cdio_drive_write_cap_t *p_write_cap, /*out*/ cdio_drive_write_cap_t *p_write_cap,
/*out*/ cdio_drive_misc_cap_t *p_misc_cap); /*out*/ cdio_drive_misc_cap_t *p_misc_cap);
typedef enum {
CDIO_MMC_LEVEL_WEIRD,
CDIO_MMC_LEVEL_1,
CDIO_MMC_LEVEL_2,
CDIO_MMC_LEVEL_3,
CDIO_MMC_LEVEL_NONE
} cdio_mmc_level_t;
/*!
Get the MMC level supported by the device.
*/
cdio_mmc_level_t mmc_get_drive_mmc_cap(CdIo_t *p_cdio);
/*! /*!
Get the DVD type associated with cd object. Get the DVD type associated with cd object.
@@ -546,7 +560,7 @@ mmc_audio_read_subchannel (CdIo_t *p_cdio,
/*! /*!
Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...) Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...)
Is it possible for an interface to have serveral? If not this Is it possible for an interface to have serveral? If not this
routine could probably return the sincle mmc_feature_interface_t. routine could probably return the single mmc_feature_interface_t.
@return true if we have the interface and false if not. @return true if we have the interface and false if not.
*/ */
bool_3way_t mmc_have_interface( CdIo_t *p_cdio, bool_3way_t mmc_have_interface( CdIo_t *p_cdio,

View File

@@ -168,6 +168,7 @@ mmc_audio_state2str
mmc_eject_media mmc_eject_media
mmc_get_blocksize mmc_get_blocksize
mmc_get_discmode mmc_get_discmode
mmc_get_drive_mmc_cap
mmc_get_dvd_struct_physical mmc_get_dvd_struct_physical
mmc_get_cmd_len mmc_get_cmd_len
mmc_get_media_changed mmc_get_media_changed

View File

@@ -1,6 +1,6 @@
/* Common Multimedia Command (MMC) routines. /* Common Multimedia Command (MMC) routines.
$Id: mmc.c,v 1.25 2005/03/23 11:15:25 rocky Exp $ $Id: mmc.c,v 1.26 2005/04/30 09:42:37 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -731,6 +731,36 @@ mmc_get_drive_cap (CdIo_t *p_cdio,
return; return;
} }
/*!
Get the MMC level supported by the device.
*/
cdio_mmc_level_t
mmc_get_drive_mmc_cap(CdIo_t *p_cdio)
{
uint8_t buf[256] = { 0, };
uint8_t len;
int rc = mmc_mode_sense(p_cdio, buf, sizeof(buf),
CDIO_MMC_CAPABILITIES_PAGE);
if (DRIVER_OP_SUCCESS != rc) {
return CDIO_MMC_LEVEL_NONE;
}
len = buf[1];
if (16 > len) {
return CDIO_MMC_LEVEL_WEIRD;
} else if (28 <= len) {
return CDIO_MMC_LEVEL_3;
} else if (24 <= len) {
return CDIO_MMC_LEVEL_2;
printf("MMC 2");
} else if (20 <= len) {
return CDIO_MMC_LEVEL_1;
} else {
return CDIO_MMC_LEVEL_WEIRD;
}
}
/*! /*!
Get the DVD type associated with cd object. Get the DVD type associated with cd object.
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-drive.c,v 1.19 2005/04/11 01:37:38 rocky Exp $ $Id: cd-drive.c,v 1.20 2005/04/30 09:42:37 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -146,6 +146,34 @@ _log_handler (cdio_log_level_t level, const char message[])
gl_default_cdio_log_handler (level, message); gl_default_cdio_log_handler (level, message);
} }
/*! Prints out SCSI-MMC drive features */
static void
print_mmc_drive_level(CdIo_t *p_cdio)
{
cdio_mmc_level_t mmc_level = mmc_get_drive_mmc_cap(p_cdio);
printf( "CD-ROM drive supports " );
switch(mmc_level) {
case CDIO_MMC_LEVEL_WEIRD:
printf("some nonstandard or degenerate set of MMC\n");
break;
case CDIO_MMC_LEVEL_1:
printf("MMC 1\n");
break;
case CDIO_MMC_LEVEL_2:
printf("MMC 2\n");
break;
case CDIO_MMC_LEVEL_3:
printf("MMC 3\n");
break;
case CDIO_MMC_LEVEL_NONE:
printf("no MMC\n");
break;
}
printf("\n");
}
/* Initialize global variables. */ /* Initialize global variables. */
static void static void
init(void) init(void)
@@ -228,6 +256,8 @@ main(int argc, const char *argv[])
cdio_hwinfo_t hwinfo; cdio_hwinfo_t hwinfo;
CdIo_t *p_cdio = cdio_open(*ppsz_cd, driver_id); CdIo_t *p_cdio = cdio_open(*ppsz_cd, driver_id);
print_mmc_drive_level(p_cdio);
printf("%28s: %s\n", "Drive", *ppsz_cd); printf("%28s: %s\n", "Drive", *ppsz_cd);
if (p_cdio) { if (p_cdio) {