mmc.c: fix up read_audio_subchannel_mmc

audio.h: more direct field names
mmc.h: add mmc_subchannel_t;  scsi_mmc -> mmc
cdio-linux.c: remove deprecated from_bcd8
This commit is contained in:
rocky
2005-03-01 10:53:15 +00:00
parent cd328dac84
commit 881d4fcf8f
9 changed files with 128 additions and 83 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: audio.h,v 1.1 2005/03/01 00:41:34 rocky Exp $ $Id: audio.h,v 1.2 2005/03/01 10:53:15 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -36,14 +36,14 @@ extern "C" {
/*! This struct is used by the cdio_audio_read_subchannel */ /*! This struct is used by the cdio_audio_read_subchannel */
typedef struct cdio_subchannel_s typedef struct cdio_subchannel_s
{ {
uint8_t cdsc_format; uint8_t format;
uint8_t cdsc_audiostatus; uint8_t audio_status;
uint8_t cdsc_adr: 4; uint8_t address: 4;
uint8_t cdsc_ctrl: 4; uint8_t control: 4;
uint8_t cdsc_trk; uint8_t track;
uint8_t cdsc_ind; uint8_t index;
union cdio_cdrom_addr cdsc_absaddr; union cdio_cdrom_addr abs_addr;
union cdio_cdrom_addr cdsc_reladdr; union cdio_cdrom_addr rel_addr;
} cdio_subchannel_t; } cdio_subchannel_t;
/*! This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */ /*! This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: mmc.h,v 1.14 2005/03/01 09:33:52 rocky Exp $ $Id: mmc.h,v 1.15 2005/03/01 10:53:15 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -315,14 +315,14 @@ typedef enum {
/*! \brief A Command Descriptor Block (CDB) used in sending MMC /*! \brief A Command Descriptor Block (CDB) used in sending MMC
commands. commands.
*/ */
typedef struct scsi_mmc_cdb { typedef struct mmc_cdb_s {
uint8_t field[MAX_CDB_LEN]; uint8_t field[MAX_CDB_LEN];
} scsi_mmc_cdb_t; } mmc_cdb_t;
/*! \brief Format of header block in data returned from an MMC /*! \brief Format of header block in data returned from an MMC
GET_CONFIGURATION command. GET_CONFIGURATION command.
*/ */
typedef struct scsi_mmc_feature_list_header { typedef struct mmc_feature_list_header_s {
unsigned char length_msb; unsigned char length_msb;
unsigned char length_1sb; unsigned char length_1sb;
unsigned char length_2sb; unsigned char length_2sb;
@@ -331,15 +331,29 @@ typedef struct scsi_mmc_feature_list_header {
unsigned char reserved2; unsigned char reserved2;
unsigned char profile_msb; unsigned char profile_msb;
unsigned char profile_lsb; unsigned char profile_lsb;
} scs_mmc_feature_list_header_t; } mmc_feature_list_header_t;
/*! An enumeration indicating whether an MMC command is sending /*! An enumeration indicating whether an MMC command is sending
data or getting data. data or getting data.
*/ */
typedef enum scsi_mmc_direction { typedef enum mmc_direction_s {
SCSI_MMC_DATA_READ, SCSI_MMC_DATA_READ,
SCSI_MMC_DATA_WRITE SCSI_MMC_DATA_WRITE
} scsi_mmc_direction_t; } mmc_direction_t;
typedef struct mmc_subchannel_s
{
uint8_t reserved;
uint8_t audio_status;
uint16_t data_length; /* Really 7.2.2 */
uint8_t format;
uint8_t address: 4;
uint8_t control: 4;
uint8_t track;
uint8_t index;
uint8_t abs_addr[4];
uint8_t rel_addr[4];
} mmc_subchannel_t;
#define CDIO_MMC_SET_COMMAND(cdb, command) \ #define CDIO_MMC_SET_COMMAND(cdb, command) \
cdb[0] = command cdb[0] = command
@@ -413,7 +427,7 @@ const char *mmc_feature_profile2str( int i_feature_profile );
Buffer (CDB) for a given MMC command. The length will be Buffer (CDB) for a given MMC command. The length will be
either 6, 10, or 12. either 6, 10, or 12.
*/ */
uint8_t mmc_get_cmd_len(uint8_t scsi_cmd); uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
/*! /*!
Get the block size used in read requests, via MMC. Get the block size used in read requests, via MMC.
@@ -668,8 +682,8 @@ driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf,
@return 0 if command completed successfully. @return 0 if command completed successfully.
*/ */
int mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms, int mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
const scsi_mmc_cdb_t *p_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, unsigned int i_buf, mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf ); /*in/out*/ void *p_buf );
/*! /*!
Set the block size for subsequest read requests, via MMC. Set the block size for subsequest read requests, via MMC.
@@ -687,6 +701,8 @@ driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio, int i_speed );
#endif /* __cplusplus */ #endif /* __cplusplus */
/** For backward compatibility. */ /** For backward compatibility. */
#define scsi_mmc_cdb_t mmc_cdb_t
#define scsi_mmc_direction_t mmc_direction_t
#define scsi_mmc_get_cmd_len mmc_get_cmd_len #define scsi_mmc_get_cmd_len mmc_get_cmd_len
#define scsi_mmc_run_cmd mmc_run_cmd #define scsi_mmc_run_cmd mmc_run_cmd
#define scsi_mmc_eject_media mmc_eject_media #define scsi_mmc_eject_media mmc_eject_media
@@ -701,7 +717,7 @@ driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio, int i_speed );
#define scsi_mmc_get_blocksize mmc_get_blocksize #define scsi_mmc_get_blocksize mmc_get_blocksize
#define scsi_mmc_set_speed mmc_set_speed #define scsi_mmc_set_speed mmc_set_speed
#endif /* __SCSI_MMC_H__ */ #endif /* __MMC_H__ */
/* /*
* Local variables: * Local variables:

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_bsdi.c,v 1.14 2005/02/17 12:05:10 rocky Exp $ $Id: _cdio_bsdi.c,v 1.15 2005/03/01 10:53:15 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, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.14 2005/02/17 12:05:10 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.15 2005/03/01 10:53:15 rocky Exp $";
#include <cdio/logging.h> #include <cdio/logging.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -81,7 +81,7 @@ typedef struct {
/* Define the Cdrom Generic Command structure */ /* Define the Cdrom Generic Command structure */
typedef struct cgc typedef struct cgc
{ {
scsi_mmc_cdb_t cdb; mmc_cdb_t cdb;
u_char *buf; u_char *buf;
int buflen; int buflen;
int rw; int rw;
@@ -95,7 +95,7 @@ typedef struct cgc
*/ */
static driver_return_code_t static driver_return_code_t
run_mmc_cmd_bsdi(void *p_user_data, unsigned int i_timeout_ms, run_mmc_cmd_bsdi(void *p_user_data, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
{ {

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_linux.c,v 1.32 2005/03/01 09:33:52 rocky Exp $ $Id: _cdio_linux.c,v 1.33 2005/03/01 10:53:15 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, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004, 2005 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.32 2005/03/01 09:33:52 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.33 2005/03/01 10:53:15 rocky Exp $";
#include <string.h> #include <string.h>
@@ -103,7 +103,7 @@ static bool read_toc_linux (void *p_user_data);
static driver_return_code_t run_mmc_cmd_linux( void *p_user_data, static driver_return_code_t run_mmc_cmd_linux( void *p_user_data,
unsigned int i_timeout, unsigned int i_timeout,
unsigned int i_cdb, unsigned int i_cdb,
const scsi_mmc_cdb_t *p_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, unsigned int i_buf,
/*in/out*/ void *p_buf ); /*in/out*/ void *p_buf );
@@ -676,7 +676,7 @@ static driver_return_code_t
_read_mode2_sectors_mmc (_img_private_t *p_env, void *p_buf, lba_t lba, _read_mode2_sectors_mmc (_img_private_t *p_env, void *p_buf, lba_t lba,
uint32_t i_blocks, bool b_read_10) uint32_t i_blocks, bool b_read_10)
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
CDIO_MMC_SET_READ_LBA(cdb.field, lba); CDIO_MMC_SET_READ_LBA(cdb.field, lba);
@@ -1013,7 +1013,7 @@ read_toc_linux (void *p_user_data)
static driver_return_code_t static driver_return_code_t
run_mmc_cmd_linux( void *p_user_data, run_mmc_cmd_linux( void *p_user_data,
unsigned int i_timeout_ms, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
{ {
@@ -1272,7 +1272,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
.audio_pause = audio_pause_linux, .audio_pause = audio_pause_linux,
.audio_play_msf = audio_play_msf_linux, .audio_play_msf = audio_play_msf_linux,
.audio_play_track_index= audio_play_track_index_linux, .audio_play_track_index= audio_play_track_index_linux,
.audio_read_subchannel = audio_read_subchannel_linux, .audio_read_subchannel = audio_read_subchannel_mmc,
.audio_resume = audio_resume_linux, .audio_resume = audio_resume_linux,
.audio_set_volume = audio_set_volume_linux, .audio_set_volume = audio_set_volume_linux,
.eject_media = eject_media_linux, .eject_media = eject_media_linux,

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_osx.c,v 1.19 2005/02/25 09:17:41 rocky Exp $ $Id: _cdio_osx.c,v 1.20 2005/03/01 10:53:15 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
from vcdimager code: from vcdimager code:
@@ -34,7 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.19 2005/02/25 09:17:41 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.20 2005/03/01 10:53:15 rocky Exp $";
#include <cdio/logging.h> #include <cdio/logging.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -349,7 +349,7 @@ init_osx(_img_private_t *p_env) {
static int static int
run_mmc_cmd_osx( void *p_user_data, run_mmc_cmd_osx( void *p_user_data,
unsigned int i_timeout_ms, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
{ {
@@ -482,7 +482,7 @@ run_mmc_cmd_osx( void *p_user_data,
static int static int
run_mmc_cmd_osx( const void *p_user_data, run_mmc_cmd_osx( const void *p_user_data,
unsigned int i_timeout_ms, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
{ {

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_sunos.c,v 1.27 2005/03/01 09:33:52 rocky Exp $ $Id: _cdio_sunos.c,v 1.28 2005/03/01 10:53:15 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, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -38,7 +38,7 @@
#ifdef HAVE_SOLARIS_CDROM #ifdef HAVE_SOLARIS_CDROM
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.27 2005/03/01 09:33:52 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.28 2005/03/01 10:53:15 rocky Exp $";
#ifdef HAVE_GLOB_H #ifdef HAVE_GLOB_H
#include <glob.h> #include <glob.h>
@@ -230,7 +230,7 @@ init_solaris (_img_private_t *p_env)
*/ */
static driver_return_code_t static driver_return_code_t
run_mmc_cmd_solaris( void *p_user_data, unsigned int i_timeout_ms, run_mmc_cmd_solaris( void *p_user_data, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
{ {

View File

@@ -1,6 +1,6 @@
/* Common Multimedia Command (MMC) routines. /* Common Multimedia Command (MMC) routines.
$Id: mmc.c,v 1.17 2005/03/01 09:33:52 rocky Exp $ $Id: mmc.c,v 1.18 2005/03/01 10:53:15 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -65,7 +65,7 @@ audio_read_subchannel_mmc ( void *p_user_data, cdio_subchannel_t *p_subchannel)
{ {
generic_img_private_t *p_env = p_user_data; generic_img_private_t *p_env = p_user_data;
if (!p_env) return DRIVER_OP_UNINIT; if (!p_env) return DRIVER_OP_UNINIT;
return mmc_get_blocksize(p_env->cdio); return mmc_audio_read_subchannel(p_env->cdio, p_subchannel);
} }
/*! /*!
@@ -200,7 +200,7 @@ mmc_get_dvd_struct_physical_private ( void *p_env,
mmc_run_cmd_fn_t run_mmc_cmd, mmc_run_cmd_fn_t run_mmc_cmd,
cdio_dvd_struct_t *s) cdio_dvd_struct_t *s)
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
unsigned char buf[4 + 4 * 20], *base; unsigned char buf[4 + 4 * 20], *base;
int i_status; int i_status;
uint8_t layer_num = s->physical.layer_num; uint8_t layer_num = s->physical.layer_num;
@@ -262,7 +262,7 @@ mmc_get_mcn_private ( void *p_env,
const mmc_run_cmd_fn_t run_mmc_cmd const mmc_run_cmd_fn_t run_mmc_cmd
) )
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
char buf[28] = { 0, }; char buf[28] = { 0, };
int i_status; int i_status;
@@ -270,10 +270,11 @@ mmc_get_mcn_private ( void *p_env,
return NULL; return NULL;
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = 0x0; cdb.field[1] = 0x0;
cdb.field[2] = 0x40; cdb.field[2] = 0x40;
cdb.field[3] = CDIO_SUBCHANNEL_MEDIA_CATALOG; cdb.field[3] = CDIO_SUBCHANNEL_MEDIA_CATALOG;
CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(buf));
i_status = run_mmc_cmd(p_env, DEFAULT_TIMEOUT_MS, i_status = run_mmc_cmd(p_env, DEFAULT_TIMEOUT_MS,
mmc_get_cmd_len(cdb.field[0]), mmc_get_cmd_len(cdb.field[0]),
@@ -309,7 +310,7 @@ mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int int
mmc_mode_sense_6( CdIo_t *p_cdio, void *p_buf, int i_size, int page) mmc_mode_sense_6( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
if ( ! p_cdio ) return DRIVER_OP_UNINIT; if ( ! p_cdio ) return DRIVER_OP_UNINIT;
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED; if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
@@ -335,7 +336,7 @@ mmc_mode_sense_6( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
int int
mmc_mode_sense_10( CdIo_t *p_cdio, void *p_buf, int i_size, int page) mmc_mode_sense_10( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
if ( ! p_cdio ) return DRIVER_OP_UNINIT; if ( ! p_cdio ) return DRIVER_OP_UNINIT;
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED; if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
@@ -343,9 +344,9 @@ mmc_mode_sense_10( CdIo_t *p_cdio, void *p_buf, int i_size, int page)
memset (p_buf, 0, i_size); memset (p_buf, 0, i_size);
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_10); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_10);
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_size);
cdb.field[2] = 0x3F & page; cdb.field[2] = 0x3F & page;
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_size);
return p_cdio->op.run_mmc_cmd (p_cdio->env, return p_cdio->op.run_mmc_cmd (p_cdio->env,
DEFAULT_TIMEOUT_MS, DEFAULT_TIMEOUT_MS,
@@ -368,7 +369,7 @@ mmc_init_cdtext_private ( void *p_user_data,
{ {
generic_img_private_t *p_env = p_user_data; generic_img_private_t *p_env = p_user_data;
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
unsigned char wdata[5000] = { 0, }; unsigned char wdata[5000] = { 0, };
int i_status, i_errno; int i_status, i_errno;
@@ -378,13 +379,13 @@ mmc_init_cdtext_private ( void *p_user_data,
/* Operation code */ /* Operation code */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_TOC); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_TOC);
/* Setup to read header, to get length of data */
CDIO_MMC_SET_READ_LENGTH8(cdb.field, 4);
cdb.field[1] = CDIO_CDROM_MSF; cdb.field[1] = CDIO_CDROM_MSF;
/* Format */ /* Format */
cdb.field[2] = CDIO_MMC_READTOC_FMT_CDTEXT; cdb.field[2] = CDIO_MMC_READTOC_FMT_CDTEXT;
/* Setup to read header, to get length of data */
CDIO_MMC_SET_READ_LENGTH16(cdb.field, 4);
errno = 0; errno = 0;
/* Set read timeout 3 minues. */ /* Set read timeout 3 minues. */
@@ -430,7 +431,7 @@ mmc_set_blocksize_private ( void *p_env,
const mmc_run_cmd_fn_t run_mmc_cmd, const mmc_run_cmd_fn_t run_mmc_cmd,
uint16_t i_blocksize) uint16_t i_blocksize)
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
struct struct
{ {
@@ -489,7 +490,7 @@ mmc_get_cmd_len(uint8_t scsi_cmd)
lsn_t lsn_t
mmc_get_disc_last_lsn ( const CdIo_t *p_cdio ) mmc_get_disc_last_lsn ( const CdIo_t *p_cdio )
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
uint8_t buf[12] = { 0, }; uint8_t buf[12] = { 0, };
lsn_t retval = 0; lsn_t retval = 0;
@@ -532,18 +533,41 @@ mmc_get_disc_last_lsn ( const CdIo_t *p_cdio )
driver_return_code_t driver_return_code_t
mmc_audio_read_subchannel (CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel) mmc_audio_read_subchannel (CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel)
{ {
scsi_mmc_cdb_t cdb; mmc_cdb_t cdb;
driver_return_code_t i_rc;
mmc_subchannel_t mmc_subchannel;
if (!p_cdio) return DRIVER_OP_UNINIT; if (!p_cdio) return DRIVER_OP_UNINIT;
memset(&cdb, 0, sizeof(scsi_mmc_cdb_t)); memset(&mmc_subchannel, 0, sizeof(mmc_subchannel));
mmc_subchannel.format = CDIO_CDROM_MSF;
memset(&cdb, 0, sizeof(mmc_cdb_t));
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(mmc_subchannel_t));
cdb.field[1] = CDIO_CDROM_MSF; cdb.field[1] = CDIO_CDROM_MSF;
cdb.field[2] = 0x40; /* subq */ cdb.field[2] = 0x40; /* subq */
cdb.field[6] = 0x40; /* track number (only in isrc mode, ignored) */ cdb.field[3] = CDIO_SUBCHANNEL_CURRENT_POSITION;
cdb.field[8] = 20; cdb.field[6] = 0; /* track number (only in isrc mode, ignored) */
return mmc_run_cmd(p_cdio, 2000, &cdb, SCSI_MMC_DATA_READ,
sizeof(cdio_subchannel_t), p_subchannel); i_rc = mmc_run_cmd(p_cdio, DEFAULT_TIMEOUT_MS, &cdb, SCSI_MMC_DATA_READ,
sizeof(mmc_subchannel_t), &mmc_subchannel);
if (DRIVER_OP_SUCCESS == i_rc) {
p_subchannel->format = mmc_subchannel.format;
p_subchannel->audio_status = mmc_subchannel.audio_status;
p_subchannel->address = mmc_subchannel.address;
p_subchannel->control = mmc_subchannel.control;
p_subchannel->track = mmc_subchannel.track;
p_subchannel->index = mmc_subchannel.index;
p_subchannel->abs_addr.msf.m = mmc_subchannel.abs_addr[1];
p_subchannel->abs_addr.msf.s = mmc_subchannel.abs_addr[2];
p_subchannel->abs_addr.msf.f = mmc_subchannel.abs_addr[3];
p_subchannel->rel_addr.msf.m = mmc_subchannel.rel_addr[1];
p_subchannel->rel_addr.msf.s = mmc_subchannel.rel_addr[2];
p_subchannel->rel_addr.msf.f = mmc_subchannel.rel_addr[3];
}
return i_rc;
} }
/*! /*!
@@ -560,13 +584,16 @@ mmc_get_discmode( const CdIo_t *p_cdio )
{ {
uint8_t buf[14] = { 0, }; uint8_t buf[14] = { 0, };
scsi_mmc_cdb_t cdb; mmc_cdb_t cdb;
memset(&cdb, 0, sizeof(mmc_cdb_t));
memset(&cdb, 0, sizeof(scsi_mmc_cdb_t));
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_TOC); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_TOC);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = CDIO_CDROM_MSF; /* The MMC-5 spec may require this. */ cdb.field[1] = CDIO_CDROM_MSF; /* The MMC-5 spec may require this. */
cdb.field[2] = CDIO_MMC_READTOC_FMT_FULTOC; cdb.field[2] = CDIO_MMC_READTOC_FMT_FULTOC;
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
mmc_run_cmd(p_cdio, 2000, &cdb, SCSI_MMC_DATA_READ, sizeof(buf), buf); mmc_run_cmd(p_cdio, 2000, &cdb, SCSI_MMC_DATA_READ, sizeof(buf), buf);
if (buf[7] == 0xA0) { if (buf[7] == 0xA0) {
if (buf[13] == 0x00) { if (buf[13] == 0x00) {
@@ -678,7 +705,7 @@ mmc_get_hwinfo ( const CdIo_t *p_cdio,
{ {
int i_status; /* Result of SCSI MMC command */ int i_status; /* Result of SCSI MMC command */
char buf[36] = { 0, }; /* Place to hold returned data */ char buf[36] = { 0, }; /* Place to hold returned data */
scsi_mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Block */ mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Block */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY);
cdb.field[4] = sizeof(buf); cdb.field[4] = sizeof(buf);
@@ -715,7 +742,7 @@ mmc_get_hwinfo ( const CdIo_t *p_cdio,
*/ */
int mmc_get_media_changed(const CdIo_t *p_cdio) int mmc_get_media_changed(const CdIo_t *p_cdio)
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
uint8_t buf[8] = { 0, }; uint8_t buf[8] = { 0, };
int i_status; int i_status;
@@ -723,12 +750,13 @@ int mmc_get_media_changed(const CdIo_t *p_cdio)
if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED; if ( ! p_cdio->op.run_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_EVENT_STATUS); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_EVENT_STATUS);
cdb.field[1] = 1; /* We poll for info */
cdb.field[4] = 1 << 4; /* We want Media events */
/* Setup to read header, to get length of data */ /* Setup to read header, to get length of data */
CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(buf)); CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(buf));
cdb.field[1] = 1; /* We poll for info */
cdb.field[4] = 1 << 4; /* We want Media events */
i_status = p_cdio->op.run_mmc_cmd(p_cdio->env, DEFAULT_TIMEOUT_MS, i_status = p_cdio->op.run_mmc_cmd(p_cdio->env, DEFAULT_TIMEOUT_MS,
mmc_get_cmd_len(cdb.field[0]), mmc_get_cmd_len(cdb.field[0]),
&cdb, SCSI_MMC_DATA_READ, &cdb, SCSI_MMC_DATA_READ,
@@ -761,7 +789,7 @@ mmc_get_mcn ( const CdIo_t *p_cdio )
*/ */
driver_return_code_t driver_return_code_t
mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms, mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
const scsi_mmc_cdb_t *p_cdb, const mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, unsigned int i_buf, scsi_mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf ) /*in/out*/ void *p_buf )
{ {
@@ -822,7 +850,7 @@ driver_return_code_t
mmc_eject_media( const CdIo_t *p_cdio ) mmc_eject_media( const CdIo_t *p_cdio )
{ {
int i_status = 0; int i_status = 0;
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
uint8_t buf[1]; uint8_t buf[1];
mmc_run_cmd_fn_t run_mmc_cmd; mmc_run_cmd_fn_t run_mmc_cmd;
@@ -1014,12 +1042,13 @@ mmc_have_interface( CdIo_t *p_cdio, mmc_feature_interface_t e_interface )
{ {
int i_status; /* Result of MMC command */ int i_status; /* Result of MMC command */
uint8_t buf[500] = { 0, }; /* Place to hold returned data */ uint8_t buf[500] = { 0, }; /* Place to hold returned data */
scsi_mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */ 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 nope;
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf)); CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = CDIO_MMC_GET_CONF_NAMED_FEATURE; cdb.field[1] = CDIO_MMC_GET_CONF_NAMED_FEATURE;
cdb.field[3] = CDIO_MMC_FEATURE_CORE; cdb.field[3] = CDIO_MMC_FEATURE_CORE;
@@ -1066,7 +1095,7 @@ mmc_read_cd ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
uint8_t subchannel_selection, uint16_t i_blocksize, uint8_t subchannel_selection, uint16_t i_blocksize,
uint32_t i_blocks ) uint32_t i_blocks )
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
mmc_run_cmd_fn_t run_mmc_cmd; mmc_run_cmd_fn_t run_mmc_cmd;
uint8_t i_read_type = 0; uint8_t i_read_type = 0;
@@ -1151,7 +1180,7 @@ driver_return_code_t
mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
int sector_type, uint32_t i_blocks ) int sector_type, uint32_t i_blocks )
{ {
scsi_mmc_cdb_t cdb = {{0, }}; mmc_cdb_t cdb = {{0, }};
mmc_run_cmd_fn_t run_mmc_cmd; mmc_run_cmd_fn_t run_mmc_cmd;
@@ -1195,7 +1224,7 @@ mmc_set_speed( const CdIo_t *p_cdio, int i_speed )
{ {
uint8_t buf[14] = { 0, }; uint8_t buf[14] = { 0, };
scsi_mmc_cdb_t cdb; mmc_cdb_t cdb;
/* If the requested speed is less than 1x 176 kb/s this command /* If the requested speed is less than 1x 176 kb/s this command
will return an error - it's part of the ATAPI specs. Therefore, will return an error - it's part of the ATAPI specs. Therefore,
@@ -1203,7 +1232,7 @@ mmc_set_speed( const CdIo_t *p_cdio, int i_speed )
if ( i_speed < 1 ) return -1; if ( i_speed < 1 ) return -1;
memset(&cdb, 0, sizeof(scsi_mmc_cdb_t)); memset(&cdb, 0, sizeof(mmc_cdb_t));
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_SET_SPEED); CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_SET_SPEED);
CDIO_MMC_SET_LEN16(cdb.field, 2, i_speed); CDIO_MMC_SET_LEN16(cdb.field, 2, i_speed);
/* Some drives like the Creative 24x CDRW require one to set a /* Some drives like the Creative 24x CDRW require one to set a

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-info.c,v 1.122 2005/03/01 07:54:09 rocky Exp $ $Id: cd-info.c,v 1.123 2005/03/01 10:53:15 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -1150,7 +1150,7 @@ main(int argc, const char *argv[])
driver_return_code_t rc; driver_return_code_t rc;
memset(&subchannel, 0, sizeof(subchannel)); memset(&subchannel, 0, sizeof(subchannel));
subchannel.cdsc_format = CDIO_CDROM_MSF; subchannel.format = CDIO_CDROM_MSF;
rc = cdio_audio_read_subchannel(p_cdio, &subchannel); rc = cdio_audio_read_subchannel(p_cdio, &subchannel);
@@ -1158,7 +1158,7 @@ main(int argc, const char *argv[])
report( stdout, "audio status: "); fflush(stdout); report( stdout, "audio status: "); fflush(stdout);
switch (subchannel.cdsc_audiostatus) { switch (subchannel.audio_status) {
case CDIO_MMC_READ_SUB_ST_INVALID: case CDIO_MMC_READ_SUB_ST_INVALID:
report( stdout, "invalid\n" ); break; report( stdout, "invalid\n" ); break;
case CDIO_MMC_READ_SUB_ST_PLAY: case CDIO_MMC_READ_SUB_ST_PLAY:
@@ -1175,14 +1175,14 @@ main(int argc, const char *argv[])
default: default:
report( stdout, "Oops: unknown\n" ); report( stdout, "Oops: unknown\n" );
} }
if (subchannel.cdsc_audiostatus == CDIO_MMC_READ_SUB_ST_PLAY || if (subchannel.audio_status == CDIO_MMC_READ_SUB_ST_PLAY ||
subchannel.cdsc_audiostatus == CDIO_MMC_READ_SUB_ST_PAUSED) { subchannel.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED) {
report( stdout, " at: %02d:%02d abs / %02d:%02d track %d\n", report( stdout, " at: %02d:%02d abs / %02d:%02d track %d\n",
subchannel.cdsc_absaddr.msf.m, subchannel.abs_addr.msf.m,
subchannel.cdsc_absaddr.msf.s, subchannel.abs_addr.msf.s,
subchannel.cdsc_reladdr.msf.m, subchannel.rel_addr.msf.m,
subchannel.cdsc_reladdr.msf.s, subchannel.rel_addr.msf.s,
subchannel.cdsc_trk ); subchannel.track );
} }
} else { } else {
report( stdout, "FAILED\n" ); report( stdout, "FAILED\n" );

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdinfo-linux.c,v 1.2 2003/09/25 10:28:22 rocky Exp $ $Id: cdinfo-linux.c,v 1.3 2005/03/01 10:53:15 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
@@ -541,7 +541,7 @@ cddb_dec_digit_sum(int n)
static inline unsigned int static inline unsigned int
msf_seconds(msf_t *msf) msf_seconds(msf_t *msf)
{ {
return from_bcd8(msf->m)*60 + from_bcd8(msf->s); return cdio_from_bcd8(msf->m)*60 + cdio_from_bcd8(msf->s);
} }
/* /*