- Redo types of lsn and lba to allow negative values. Should model MMC3
specs. Add max/min values for lsn. - More complete MMC command set
This commit is contained in:
6
NEWS
6
NEWS
@@ -2,7 +2,9 @@
|
|||||||
- Add interface returning drive capabilityes (cdio_get_drive_cap).
|
- Add interface returning drive capabilityes (cdio_get_drive_cap).
|
||||||
- Minimal cdrdao image reading
|
- Minimal cdrdao image reading
|
||||||
- Some important (I think) bug fixes
|
- Some important (I think) bug fixes
|
||||||
|
- Redo types of lsn and lba to allow negative values. Should model MMC3
|
||||||
|
specs. Add max/min values for lsn.
|
||||||
|
- More complete MMC command set
|
||||||
|
|
||||||
0.68
|
0.68
|
||||||
- More honest about mode1 reading in backends. Remove some of the bogusness.
|
- More honest about mode1 reading in backends. Remove some of the bogusness.
|
||||||
@@ -111,4 +113,4 @@
|
|||||||
0.1
|
0.1
|
||||||
Routines split off from VCDImager.
|
Routines split off from VCDImager.
|
||||||
|
|
||||||
$Id: NEWS,v 1.39 2004/05/08 20:36:01 rocky Exp $
|
$Id: NEWS,v 1.40 2004/05/11 02:15:42 rocky Exp $
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: scsi_mmc.h,v 1.1 2004/05/10 03:28:52 rocky Exp $
|
$Id: scsi_mmc.h,v 1.2 2004/05/11 02:15:47 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -41,9 +41,12 @@
|
|||||||
#define CDIO_MMC_GPCMD_READ_10 0x28
|
#define CDIO_MMC_GPCMD_READ_10 0x28
|
||||||
#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42
|
#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42
|
||||||
#define CDIO_MMC_READ_TOC 0x43
|
#define CDIO_MMC_READ_TOC 0x43
|
||||||
|
#define CDIO_MMC_MODE_SELECT 0x55
|
||||||
|
#define CDIO_MMC_MODE_SELECT_6 0x15
|
||||||
#define CDIO_MMC_MODE_SENSE_10 0x5a
|
#define CDIO_MMC_MODE_SENSE_10 0x5a
|
||||||
#define CDIO_MMC_GPCMD_READ_12 0xa8
|
#define CDIO_MMC_GPCMD_READ_12 0xa8
|
||||||
#define CDIO_MMC_GPCMD_READ_CD 0xbe
|
#define CDIO_MMC_GPCMD_READ_CD 0xbe
|
||||||
|
#define CDIO_MMC_GPCMD_READ_MSF 0xb9
|
||||||
|
|
||||||
#define CDIO_MMC_SET_COMMAND(rec, command) \
|
#define CDIO_MMC_SET_COMMAND(rec, command) \
|
||||||
rec[0] = command
|
rec[0] = command
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: sector.h,v 1.11 2004/05/10 03:28:52 rocky Exp $
|
$Id: sector.h,v 1.12 2004/05/11 02:15:49 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -123,8 +123,11 @@
|
|||||||
#define M2SUB_SECTOR_SIZE 2332
|
#define M2SUB_SECTOR_SIZE 2332
|
||||||
#define M2RAW_SECTOR_SIZE 2336
|
#define M2RAW_SECTOR_SIZE 2336
|
||||||
|
|
||||||
#define CDIO_CD_MAX_TRACKS 99
|
#define CDIO_CD_MAX_TRACKS 99
|
||||||
#define CDIO_CD_MIN_TRACK_NO 1
|
#define CDIO_CD_MIN_TRACK_NO 1
|
||||||
|
#define CDIO_CD_MAX_LSN 450150
|
||||||
|
#define CDIO_CD_MIN_LSN -450150
|
||||||
|
|
||||||
|
|
||||||
#define CDIO_CD_FRAMES_PER_MIN \
|
#define CDIO_CD_FRAMES_PER_MIN \
|
||||||
(CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN)
|
(CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: types.h,v 1.15 2004/05/08 14:07:09 rocky Exp $
|
$Id: types.h,v 1.16 2004/05/11 02:15:57 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 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>
|
||||||
@@ -204,14 +204,19 @@ extern "C" {
|
|||||||
typedef uint8_t bitfield_t;
|
typedef uint8_t bitfield_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! The type of a Logical Block Address.
|
/*! The type of a Logical Block Address. We allow for an lba to be
|
||||||
|
negative to be consistent with an lba, although I'm not sure this
|
||||||
|
this is possible.
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef int32_t lba_t;
|
||||||
|
|
||||||
|
/*! The type of a Logical Sector Number. Note that an lba lsn be negative
|
||||||
|
and the MMC3 specs allow for a conversion of a negative lba
|
||||||
|
|
||||||
@see msf_t
|
@see msf_t
|
||||||
*/
|
*/
|
||||||
typedef uint32_t lba_t;
|
typedef int32_t lsn_t;
|
||||||
|
|
||||||
/*! The type of an Logical Sector Number. */
|
|
||||||
typedef uint32_t lsn_t;
|
|
||||||
|
|
||||||
/*! The type of an track number 0..99. */
|
/*! The type of an track number 0..99. */
|
||||||
typedef uint8_t track_t;
|
typedef uint8_t track_t;
|
||||||
@@ -222,14 +227,16 @@ extern "C" {
|
|||||||
#define CDIO_INVALID_TRACK 0xFF
|
#define CDIO_INVALID_TRACK 0xFF
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constant for invalid LBA
|
Constant for invalid LBA. It is 151 less than the most negative
|
||||||
|
LBA -45150. This provide slack for the 150-frame offset in
|
||||||
|
LBA to LSN 150 conversions
|
||||||
*/
|
*/
|
||||||
#define CDIO_INVALID_LBA 0xFFFFFFFF
|
#define CDIO_INVALID_LBA -45301
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constant for invalid LSN
|
Constant for invalid LSN
|
||||||
*/
|
*/
|
||||||
#define CDIO_INVALID_LSN 0xFFFFFFFF
|
#define CDIO_INVALID_LSN CDIO_INVALID_LBA
|
||||||
|
|
||||||
typedef int cdio_fs_anal_t;
|
typedef int cdio_fs_anal_t;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: bincue.c,v 1.16 2004/04/30 06:54:15 rocky Exp $
|
$Id: bincue.c,v 1.17 2004/05/11 02:15:58 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>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
(*.cue).
|
(*.cue).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: bincue.c,v 1.16 2004/04/30 06:54:15 rocky Exp $";
|
static const char _rcsid[] = "$Id: bincue.c,v 1.17 2004/05/11 02:15:58 rocky Exp $";
|
||||||
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
@@ -546,8 +546,8 @@ _read_mode1_sector_bincue (void *env, void *data, lsn_t lsn,
|
|||||||
Returns 0 if no error.
|
Returns 0 if no error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_read_mode1_sectors_bincue (void *env, void *data, uint32_t lsn,
|
_read_mode1_sectors_bincue (void *env, void *data, lsn_t lsn,
|
||||||
bool b_form2, unsigned int nblocks)
|
bool b_form2, unsigned int nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
@@ -613,8 +613,8 @@ _read_mode2_sector_bincue (void *env, void *data, lsn_t lsn,
|
|||||||
Returns 0 if no error.
|
Returns 0 if no error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_read_mode2_sectors_bincue (void *env, void *data, uint32_t lsn,
|
_read_mode2_sectors_bincue (void *env, void *data, lsn_t lsn,
|
||||||
bool b_form2, unsigned int nblocks)
|
bool b_form2, unsigned int nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdrdao.c,v 1.5 2004/05/08 22:02:28 rocky Exp $
|
$Id: cdrdao.c,v 1.6 2004/05/11 02:16:00 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
toc reading routine adapted from cuetools
|
toc reading routine adapted from cuetools
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
(*.cue).
|
(*.cue).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: cdrdao.c,v 1.5 2004/05/08 22:02:28 rocky Exp $";
|
static const char _rcsid[] = "$Id: cdrdao.c,v 1.6 2004/05/11 02:16:00 rocky Exp $";
|
||||||
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
@@ -888,8 +888,8 @@ _read_mode1_sector_cdrdao (void *env, void *data, lsn_t lsn,
|
|||||||
Returns 0 if no error.
|
Returns 0 if no error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_read_mode1_sectors_cdrdao (void *env, void *data, uint32_t lsn,
|
_read_mode1_sectors_cdrdao (void *env, void *data, lsn_t lsn,
|
||||||
bool b_form2, unsigned int nblocks)
|
bool b_form2, unsigned int nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
@@ -956,8 +956,8 @@ _read_mode2_sector_cdrdao (void *env, void *data, lsn_t lsn,
|
|||||||
Returns 0 if no error.
|
Returns 0 if no error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_read_mode2_sectors_cdrdao (void *env, void *data, uint32_t lsn,
|
_read_mode2_sectors_cdrdao (void *env, void *data, lsn_t lsn,
|
||||||
bool b_form2, unsigned int nblocks)
|
bool b_form2, unsigned int nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: nrg.c,v 1.12 2004/05/09 16:52:20 rocky Exp $
|
$Id: nrg.c,v 1.13 2004/05/11 02:16:01 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
#include "_cdio_stdio.h"
|
#include "_cdio_stdio.h"
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: nrg.c,v 1.12 2004/05/09 16:52:20 rocky Exp $";
|
static const char _rcsid[] = "$Id: nrg.c,v 1.13 2004/05/11 02:16:01 rocky Exp $";
|
||||||
|
|
||||||
/* structures used */
|
/* structures used */
|
||||||
|
|
||||||
@@ -898,8 +898,8 @@ _read_mode1_sector_nrg (void *env, void *data, lsn_t lsn,
|
|||||||
Returns 0 if no error.
|
Returns 0 if no error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_read_mode1_sectors_nrg (void *env, void *data, uint32_t lsn,
|
_read_mode1_sectors_nrg (void *env, void *data, lsn_t lsn,
|
||||||
bool b_form2, unsigned nblocks)
|
bool b_form2, unsigned nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
@@ -971,8 +971,8 @@ _read_mode2_sector_nrg (void *env, void *data, lsn_t lsn,
|
|||||||
Returns 0 if no error.
|
Returns 0 if no error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_read_mode2_sectors_nrg (void *env, void *data, uint32_t lsn,
|
_read_mode2_sectors_nrg (void *env, void *data, lsn_t lsn,
|
||||||
bool b_form2, unsigned nblocks)
|
bool b_form2, unsigned nblocks)
|
||||||
{
|
{
|
||||||
_img_private_t *_obj = env;
|
_img_private_t *_obj = env;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
45
lib/sector.c
45
lib/sector.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: sector.c,v 1.6 2004/05/09 16:53:01 rocky Exp $
|
$Id: sector.c,v 1.7 2004/05/11 02:15:58 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: sector.c,v 1.6 2004/05/09 16:53:01 rocky Exp $";
|
static const char _rcsid[] = "$Id: sector.c,v 1.7 2004/05/11 02:15:58 rocky Exp $";
|
||||||
|
|
||||||
lba_t
|
lba_t
|
||||||
cdio_lba_to_lsn (lba_t lba)
|
cdio_lba_to_lsn (lba_t lba)
|
||||||
@@ -42,14 +42,35 @@ cdio_lba_to_lsn (lba_t lba)
|
|||||||
return lba - CDIO_PREGAP_SECTORS;
|
return lba - CDIO_PREGAP_SECTORS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The below is adapted from cdparanoia code which claims it is
|
||||||
|
straight from the MMC3 spec.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
cdio_lba_to_msf (lba_t lba, msf_t *msf)
|
cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
|
||||||
{
|
{
|
||||||
|
int m, s, f;
|
||||||
|
|
||||||
cdio_assert (msf != 0);
|
cdio_assert (msf != 0);
|
||||||
|
|
||||||
msf->m = to_bcd8 (lba / (60 * 75));
|
if ( lsn >= -CDIO_PREGAP_SECTORS ){
|
||||||
msf->s = to_bcd8 ((lba / 75) % 60);
|
m = (lsn + CDIO_PREGAP_SECTORS) / CDIO_CD_FRAMES_PER_MIN;
|
||||||
msf->f = to_bcd8 (lba % 75);
|
lsn -= m * CDIO_CD_FRAMES_PER_MIN;
|
||||||
|
s = (lsn + CDIO_PREGAP_SECTORS) / CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
lsn -= s * CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
f = lsn + CDIO_PREGAP_SECTORS;
|
||||||
|
} else {
|
||||||
|
m = (lsn + CDIO_CD_MAX_LSN) / CDIO_CD_FRAMES_PER_MIN;
|
||||||
|
lsn -= m * (CDIO_CD_FRAMES_PER_MIN);
|
||||||
|
s = (lsn+CDIO_CD_MAX_LSN) / CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
lsn -= s * CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
f = lsn + CDIO_CD_MAX_LSN;
|
||||||
|
}
|
||||||
|
|
||||||
|
msf->m = to_bcd8 (m);
|
||||||
|
msf->s = to_bcd8 (s);
|
||||||
|
msf->f = to_bcd8 (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* warning, returns new allocated string */
|
/* warning, returns new allocated string */
|
||||||
@@ -74,13 +95,13 @@ cdio_lsn_to_lba (lsn_t lsn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
|
cdio_lba_to_msf (lba_t lba, msf_t *msf)
|
||||||
{
|
{
|
||||||
cdio_assert (msf != 0);
|
cdio_assert (msf != 0);
|
||||||
cdio_lba_to_msf(cdio_lsn_to_lba(lsn), msf);
|
cdio_lsn_to_msf(cdio_lba_to_lsn(lba), msf);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
lba_t
|
||||||
cdio_msf_to_lba (const msf_t *msf)
|
cdio_msf_to_lba (const msf_t *msf)
|
||||||
{
|
{
|
||||||
uint32_t lba = 0;
|
uint32_t lba = 0;
|
||||||
@@ -88,17 +109,17 @@ cdio_msf_to_lba (const msf_t *msf)
|
|||||||
cdio_assert (msf != 0);
|
cdio_assert (msf != 0);
|
||||||
|
|
||||||
lba = from_bcd8 (msf->m);
|
lba = from_bcd8 (msf->m);
|
||||||
lba *= 60;
|
lba *= CDIO_CD_SECS_PER_MIN;
|
||||||
|
|
||||||
lba += from_bcd8 (msf->s);
|
lba += from_bcd8 (msf->s);
|
||||||
lba *= 75;
|
lba *= CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
|
||||||
lba += from_bcd8 (msf->f);
|
lba += from_bcd8 (msf->f);
|
||||||
|
|
||||||
return lba;
|
return lba;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
lba_t
|
||||||
cdio_msf_to_lsn (const msf_t *msf)
|
cdio_msf_to_lsn (const msf_t *msf)
|
||||||
{
|
{
|
||||||
return cdio_lba_to_lsn(cdio_msf_to_lba (msf));
|
return cdio_lba_to_lsn(cdio_msf_to_lba (msf));
|
||||||
|
|||||||
Reference in New Issue
Block a user