diff --git a/lib/MSWindows/aspi32.c b/lib/MSWindows/aspi32.c index b0266aee..70c88584 100644 --- a/lib/MSWindows/aspi32.c +++ b/lib/MSWindows/aspi32.c @@ -1,5 +1,5 @@ /* - $Id: aspi32.c,v 1.36 2004/07/25 21:43:30 rocky Exp $ + $Id: aspi32.c,v 1.37 2004/07/25 22:33:54 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: aspi32.c,v 1.36 2004/07/25 21:43:30 rocky Exp $"; +static const char _rcsid[] = "$Id: aspi32.c,v 1.37 2004/07/25 22:33:54 rocky Exp $"; #include #include @@ -269,7 +269,6 @@ get_discmode_aspi (_img_private_t *p_env) i_track ++) { track_format_t track_fmt=get_track_format_aspi(p_env, i_track); - /* FIXME Need to add getting DVD types. */ switch(track_fmt) { case TRACK_FORMAT_AUDIO: switch(discmode) { diff --git a/lib/MSWindows/win32.c b/lib/MSWindows/win32.c index 25023fa5..78b9f06e 100644 --- a/lib/MSWindows/win32.c +++ b/lib/MSWindows/win32.c @@ -1,5 +1,5 @@ /* - $Id: win32.c,v 1.28 2004/07/25 17:32:19 rocky Exp $ + $Id: win32.c,v 1.29 2004/07/25 22:33:54 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: win32.c,v 1.28 2004/07/25 17:32:19 rocky Exp $"; +static const char _rcsid[] = "$Id: win32.c,v 1.29 2004/07/25 22:33:54 rocky Exp $"; #include #include @@ -96,8 +96,8 @@ get_discmode_win32(void *p_user_data) { _img_private_t *p_env = p_user_data; - if ( WIN_NT ) { - return CDIO_DISC_MODE_ERROR; + if (p_env->hASPI) { + return get_discmode_win32ioctl (p_env); } else { return get_discmode_aspi (p_env); } @@ -408,15 +408,15 @@ _set_arg_win32 (void *user_data, const char key[], const char value[]) Return true if successful or false if an error. */ static bool -_cdio_read_toc (_img_private_t *env) +_cdio_read_toc (_img_private_t *p_env) { bool ret; - if( env->hASPI ) { - ret = read_toc_aspi( env ); + if( p_env->hASPI ) { + ret = read_toc_aspi( p_env ); } else { - ret = read_toc_win32ioctl( env ); + ret = read_toc_win32ioctl( p_env ); } - if (ret) env->gen.toc_init = true ; + if (ret) p_env->gen.toc_init = true ; return true; } diff --git a/lib/MSWindows/win32.h b/lib/MSWindows/win32.h index 4ba7d4b9..09ff0809 100644 --- a/lib/MSWindows/win32.h +++ b/lib/MSWindows/win32.h @@ -1,5 +1,5 @@ /* - $Id: win32.h,v 1.14 2004/07/23 14:40:43 rocky Exp $ + $Id: win32.h,v 1.15 2004/07/25 22:33:54 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -63,6 +63,11 @@ typedef struct { } _img_private_t; +/*! + Get disc type associated with cd object. +*/ +discmode_t get_discmode_win32ioctl (_img_private_t *p_env); + /*! Reads an audio device using the DeviceIoControl method into data starting from lsn. Returns 0 if no error. diff --git a/lib/MSWindows/win32_ioctl.c b/lib/MSWindows/win32_ioctl.c index 92eed84e..632e6abb 100644 --- a/lib/MSWindows/win32_ioctl.c +++ b/lib/MSWindows/win32_ioctl.c @@ -1,5 +1,5 @@ /* - $Id: win32_ioctl.c,v 1.22 2004/07/23 14:40:43 rocky Exp $ + $Id: win32_ioctl.c,v 1.23 2004/07/25 22:33:54 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -26,10 +26,11 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.22 2004/07/23 14:40:43 rocky Exp $"; +static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.23 2004/07/25 22:33:54 rocky Exp $"; #include #include +#include #include "cdio_assert.h" #ifdef HAVE_WIN32_CDROM @@ -42,6 +43,7 @@ static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.22 2004/07/23 14:40:43 rock #include #include /* offsetof() macro */ #include +#include #include #include #include "cdtext_private.h" @@ -189,6 +191,147 @@ scsi_mmc_run_cmd_win32ioctl( const void *p_user_data, int i_timeout, return 0; } +/*! + Get disc type associated with cd object. +*/ +static discmode_t +get_dvd_struct_physical (_img_private_t *p_env, cdio_dvd_struct_t *s) +{ + scsi_mmc_cdb_t cdb = {{0, }}; + unsigned char buf[20], *base; + int i_status; + uint8_t layer_num = s->physical.layer_num; + + cdio_dvd_layer_t *layer; + + if (layer_num >= CDIO_DVD_MAX_LAYERS) + return -EINVAL; + + CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_DVD_STRUCTURE); + cdb.field[6] = layer_num; + cdb.field[7] = CDIO_DVD_STRUCT_PHYSICAL; + cdb.field[9] = sizeof(buf) & 0xff; + + i_status = scsi_mmc_run_cmd_win32ioctl(p_env, OP_TIMEOUT_MS, + scsi_mmc_get_cmd_len(cdb.field[0]), + &cdb, SCSI_MMC_DATA_READ, + sizeof(buf), &buf); + if (0 != i_status) + return CDIO_DISC_MODE_ERROR; + + base = &buf[4]; + layer = &s->physical.layer[layer_num]; + + /* + * place the data... really ugly, but at least we won't have to + * worry about endianess in userspace. + */ + memset(layer, 0, sizeof(*layer)); + layer->book_version = base[0] & 0xf; + layer->book_type = base[0] >> 4; + layer->min_rate = base[1] & 0xf; + layer->disc_size = base[1] >> 4; + layer->layer_type = base[2] & 0xf; + layer->track_path = (base[2] >> 4) & 1; + layer->nlayers = (base[2] >> 5) & 3; + layer->track_density = base[3] & 0xf; + layer->linear_density = base[3] >> 4; + layer->start_sector = base[5] << 16 | base[6] << 8 | base[7]; + layer->end_sector = base[9] << 16 | base[10] << 8 | base[11]; + layer->end_sector_l0 = base[13] << 16 | base[14] << 8 | base[15]; + layer->bca = base[16] >> 7; + + return 0; +} + +/*! + Get disc type associated with cd object. +*/ +discmode_t +get_discmode_win32ioctl (_img_private_t *p_env) +{ + track_t i_track; + discmode_t discmode=CDIO_DISC_MODE_NO_INFO; + + /* See if this is a DVD. */ + cdio_dvd_struct_t dvd; /* DVD READ STRUCT for layer 0. */ + + dvd.physical.type = CDIO_DVD_STRUCT_PHYSICAL; + dvd.physical.layer_num = 0; + if (0 == get_dvd_struct_physical (p_env, &dvd)) { + switch(dvd.physical.layer[0].book_type) { + case CDIO_DVD_BOOK_DVD_ROM: return CDIO_DISC_MODE_DVD_ROM; + case CDIO_DVD_BOOK_DVD_RAM: return CDIO_DISC_MODE_DVD_RAM; + case CDIO_DVD_BOOK_DVD_R: return CDIO_DISC_MODE_DVD_R; + case CDIO_DVD_BOOK_DVD_RW: return CDIO_DISC_MODE_DVD_RW; + case CDIO_DVD_BOOK_DVD_PW: return CDIO_DISC_MODE_DVD_PR; + case CDIO_DVD_BOOK_DVD_PRW: return CDIO_DISC_MODE_DVD_PRW; + default: return CDIO_DISC_MODE_DVD_OTHER; + } + } + + if (!p_env->gen.toc_init) + read_toc_win32ioctl (p_env); + + if (!p_env->gen.toc_init) + return CDIO_DISC_MODE_NO_INFO; + + for (i_track = p_env->i_first_track; + i_track < p_env->i_first_track + p_env->i_tracks ; + i_track ++) { + track_format_t track_fmt=get_track_format_win32ioctl(p_env, i_track); + + switch(track_fmt) { + case TRACK_FORMAT_AUDIO: + switch(discmode) { + case CDIO_DISC_MODE_NO_INFO: + discmode = CDIO_DISC_MODE_CD_DA; + break; + case CDIO_DISC_MODE_CD_DA: + case CDIO_DISC_MODE_CD_MIXED: + case CDIO_DISC_MODE_ERROR: + /* No change*/ + break; + default: + discmode = CDIO_DISC_MODE_CD_MIXED; + } + break; + case TRACK_FORMAT_XA: + switch(discmode) { + case CDIO_DISC_MODE_NO_INFO: + discmode = CDIO_DISC_MODE_CD_XA; + break; + case CDIO_DISC_MODE_CD_XA: + case CDIO_DISC_MODE_CD_MIXED: + case CDIO_DISC_MODE_ERROR: + /* No change*/ + break; + default: + discmode = CDIO_DISC_MODE_CD_MIXED; + } + break; + case TRACK_FORMAT_DATA: + switch(discmode) { + case CDIO_DISC_MODE_NO_INFO: + discmode = CDIO_DISC_MODE_CD_DATA; + break; + case CDIO_DISC_MODE_CD_DATA: + case CDIO_DISC_MODE_CD_MIXED: + case CDIO_DISC_MODE_ERROR: + /* No change*/ + break; + default: + discmode = CDIO_DISC_MODE_CD_MIXED; + } + break; + case TRACK_FORMAT_ERROR: + default: + discmode = CDIO_DISC_MODE_ERROR; + } + } + return discmode; +} + /* Returns a string that can be used in a CreateFile call if c_drive letter is a character. If not NULL is returned.