Try to make get_dvd_physical a common routine. (Haven't tested yet.)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: scsi_mmc.h,v 1.16 2004/07/26 02:54:37 rocky Exp $
|
$Id: scsi_mmc.h,v 1.17 2004/07/26 03:58:25 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/types.h>
|
#include <cdio/types.h>
|
||||||
|
#include <cdio/dvd.h>
|
||||||
|
|
||||||
/*! The generic packet command opcodes for CD/DVD Logical Units. */
|
/*! The generic packet command opcodes for CD/DVD Logical Units. */
|
||||||
|
|
||||||
@@ -208,5 +209,10 @@ int scsi_mmc_read_sectors ( const CdIo *cdio, void *p_buf, lba_t lba,
|
|||||||
|
|
||||||
int scsi_mmc_set_bsize ( const CdIo *cdio, unsigned int bsize);
|
int scsi_mmc_set_bsize ( const CdIo *cdio, unsigned int bsize);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the DVD type associated with cd object.
|
||||||
|
*/
|
||||||
|
discmode_t scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio,
|
||||||
|
cdio_dvd_struct_t *s);
|
||||||
|
|
||||||
#endif /* __SCSI_MMC_H__ */
|
#endif /* __SCSI_MMC_H__ */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: aspi32.c,v 1.37 2004/07/25 22:33:54 rocky Exp $
|
$Id: aspi32.c,v 1.38 2004/07/26 03:58:25 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -27,13 +27,12 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: aspi32.c,v 1.37 2004/07/25 22:33:54 rocky Exp $";
|
static const char _rcsid[] = "$Id: aspi32.c,v 1.38 2004/07/26 03:58:25 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
#include <cdio/scsi_mmc.h>
|
#include <cdio/scsi_mmc.h>
|
||||||
#include <cdio/dvd.h>
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -178,60 +177,6 @@ have_aspi( HMODULE *hASPI,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
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_aspi(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.
|
Get disc type associated with cd object.
|
||||||
*/
|
*/
|
||||||
@@ -246,7 +191,9 @@ get_discmode_aspi (_img_private_t *p_env)
|
|||||||
|
|
||||||
dvd.physical.type = CDIO_DVD_STRUCT_PHYSICAL;
|
dvd.physical.type = CDIO_DVD_STRUCT_PHYSICAL;
|
||||||
dvd.physical.layer_num = 0;
|
dvd.physical.layer_num = 0;
|
||||||
if (0 == get_dvd_struct_physical (p_env, &dvd)) {
|
if (0 == get_dvd_struct_physical_mmc (p_env,
|
||||||
|
&scsi_mmc_run_cmd_aspi,
|
||||||
|
&dvd)) {
|
||||||
switch(dvd.physical.layer[0].book_type) {
|
switch(dvd.physical.layer[0].book_type) {
|
||||||
case CDIO_DVD_BOOK_DVD_ROM: return CDIO_DISC_MODE_DVD_ROM;
|
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_RAM: return CDIO_DISC_MODE_DVD_RAM;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: win32_ioctl.c,v 1.23 2004/07/25 22:33:54 rocky Exp $
|
$Id: win32_ioctl.c,v 1.24 2004/07/26 03:58:25 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,11 +26,10 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.23 2004/07/25 22:33:54 rocky Exp $";
|
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.24 2004/07/26 03:58:25 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
#include <cdio/dvd.h>
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
|
|
||||||
#ifdef HAVE_WIN32_CDROM
|
#ifdef HAVE_WIN32_CDROM
|
||||||
@@ -191,59 +190,6 @@ scsi_mmc_run_cmd_win32ioctl( const void *p_user_data, int i_timeout,
|
|||||||
return 0;
|
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.
|
Get disc type associated with cd object.
|
||||||
*/
|
*/
|
||||||
@@ -258,7 +204,9 @@ get_discmode_win32ioctl (_img_private_t *p_env)
|
|||||||
|
|
||||||
dvd.physical.type = CDIO_DVD_STRUCT_PHYSICAL;
|
dvd.physical.type = CDIO_DVD_STRUCT_PHYSICAL;
|
||||||
dvd.physical.layer_num = 0;
|
dvd.physical.layer_num = 0;
|
||||||
if (0 == get_dvd_struct_physical (p_env, &dvd)) {
|
if (0 == get_dvd_struct_physical_mmc (p_env,
|
||||||
|
&scsi_mmc_run_cmd_win32ioctl,
|
||||||
|
&dvd)) {
|
||||||
switch(dvd.physical.layer[0].book_type) {
|
switch(dvd.physical.layer[0].book_type) {
|
||||||
case CDIO_DVD_BOOK_DVD_ROM: return CDIO_DISC_MODE_DVD_ROM;
|
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_RAM: return CDIO_DISC_MODE_DVD_RAM;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_linux.c,v 1.81 2004/07/26 02:54:37 rocky Exp $
|
$Id: _cdio_linux.c,v 1.82 2004/07/26 03:58:25 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.81 2004/07/26 02:54:37 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.82 2004/07/26 03:58:25 rocky Exp $";
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.81 2004/07/26 02:54:37 rock
|
|||||||
#include <cdio/types.h>
|
#include <cdio/types.h>
|
||||||
#include <cdio/scsi_mmc.h>
|
#include <cdio/scsi_mmc.h>
|
||||||
#include <cdio/cdtext.h>
|
#include <cdio/cdtext.h>
|
||||||
#include <cdio/dvd.h>
|
|
||||||
#include "cdtext_private.h"
|
#include "cdtext_private.h"
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Common SCSI Multimedia Command (MMC) routines.
|
/* Common SCSI Multimedia Command (MMC) routines.
|
||||||
|
|
||||||
$Id: scsi_mmc.c,v 1.9 2004/07/26 03:39:55 rocky Exp $
|
$Id: scsi_mmc.c,v 1.10 2004/07/26 03:58:25 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -31,6 +31,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ERRNO_H
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
On input a MODE_SENSE command was issued and we have the results
|
On input a MODE_SENSE command was issued and we have the results
|
||||||
in p. We interpret this and return a bit mask set according to the
|
in p. We interpret this and return a bit mask set according to the
|
||||||
@@ -227,3 +231,75 @@ scsi_mmc_set_bsize ( const CdIo *cdio, unsigned int bsize)
|
|||||||
if ( ! cdio ) return -2;
|
if ( ! cdio ) return -2;
|
||||||
return set_bsize_mmc (cdio->env, (&cdio->op.run_scsi_mmc_cmd), bsize);
|
return set_bsize_mmc (cdio->env, (&cdio->op.run_scsi_mmc_cmd), bsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the DVD type associated with cd object.
|
||||||
|
*/
|
||||||
|
discmode_t
|
||||||
|
get_dvd_struct_physical_mmc ( void *p_env,
|
||||||
|
const scsi_mmc_run_cmd_fn_t *run_scsi_mmc_cmd,
|
||||||
|
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 ( ! p_env || ! run_scsi_mmc_cmd )
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
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 = (*run_scsi_mmc_cmd)(p_env, DEFAULT_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 the DVD type associated with cd object.
|
||||||
|
*/
|
||||||
|
discmode_t
|
||||||
|
scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio, cdio_dvd_struct_t *s)
|
||||||
|
{
|
||||||
|
if ( ! p_cdio ) return -2;
|
||||||
|
return get_dvd_struct_physical_mmc (p_cdio->env,
|
||||||
|
(&p_cdio->op.run_scsi_mmc_cmd),
|
||||||
|
s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* private MMC helper routines.
|
/* private MMC helper routines.
|
||||||
|
|
||||||
$Id: scsi_mmc_private.h,v 1.2 2004/07/26 03:39:55 rocky Exp $
|
$Id: scsi_mmc_private.h,v 1.3 2004/07/26 03:58:25 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -30,4 +30,14 @@ int (*scsi_mmc_run_cmd_fn_t) ( const void *p_user_data, int i_timeout,
|
|||||||
|
|
||||||
int set_bsize_mmc ( const void *p_env,
|
int set_bsize_mmc ( const void *p_env,
|
||||||
const scsi_mmc_run_cmd_fn_t *run_scsi_mmc_cmd,
|
const scsi_mmc_run_cmd_fn_t *run_scsi_mmc_cmd,
|
||||||
unsigned int bsize);
|
unsigned int bsize );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the DVD type associated with cd object.
|
||||||
|
*/
|
||||||
|
discmode_t
|
||||||
|
get_dvd_struct_physical_mmc ( void *p_env,
|
||||||
|
const scsi_mmc_run_cmd_fn_t *run_scsi_mmc_cmd,
|
||||||
|
cdio_dvd_struct_t *s );
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user