Search
lxdream.org :: lxdream :: r1178:e55ec927d55d
lxdream 0.9.1
released Jun 29
Download Now
changeset1178:e55ec927d55d
parent1177:bd5893522efc
child1179:af1c5d7d5a5a
authorNathan Keynes <nkeynes@lxdream.org>
dateSat Sep 17 22:39:36 2011 +1000 (8 years ago)
Fix structure packing on v55 nero images (64-bit)
Add basic support for track mode 16 (CDDA + subchannel data, 2448 bytes)
src/drivers/cdrom/cd_nrg.c
src/drivers/cdrom/defs.h
src/drivers/cdrom/sector.c
1.1 --- a/src/drivers/cdrom/cd_nrg.c Sat Sep 17 22:35:45 2011 +1000
1.2 +++ b/src/drivers/cdrom/cd_nrg.c Sat Sep 17 22:39:36 2011 +1000
1.3 @@ -58,7 +58,7 @@
1.4 struct nrg_footer_v55 {
1.5 uint32_t id;
1.6 uint64_t offset;
1.7 - } v55;
1.8 + } __attribute__((packed)) v55;
1.9 };
1.10
1.11 struct nrg_chunk {
1.12 @@ -132,6 +132,7 @@
1.13 case 2: return SECTOR_MODE2_FORM1;
1.14 case 3: return SECTOR_SEMIRAW_MODE2;
1.15 case 7: return SECTOR_CDDA;
1.16 + case 16: return SECTOR_CDDA_SUBCHANNEL;
1.17 default: return -1;
1.18 }
1.19 }
1.20 @@ -172,14 +173,18 @@
1.21
1.22 fseek( f, -12, SEEK_END );
1.23 fread( &footer, sizeof(footer), 1, f );
1.24 + uint32_t start = 0;
1.25 if( GUINT32_FROM_BE(footer.v50.id) == NERO_V50_ID ) {
1.26 - fseek( f, GUINT32_FROM_BE(footer.v50.offset), SEEK_SET );
1.27 + start = GUINT32_FROM_BE(footer.v50.offset);
1.28 } else if( GUINT32_FROM_BE(footer.v55.id) == NERO_V55_ID ) {
1.29 - fseek( f, (uint32_t)GUINT64_FROM_BE(footer.v55.offset), SEEK_SET );
1.30 + start = (uint32_t)GUINT64_FROM_BE(footer.v55.offset);
1.31 } else {
1.32 /* Not a (recognized) Nero image (should never happen) */
1.33 RETURN_PARSE_ERROR("File is not an NRG image" );
1.34 }
1.35 + if( fseek( f, start, SEEK_SET) != 0 ) {
1.36 + RETURN_PARSE_ERROR("File is not a valid NRG image" );
1.37 + }
1.38
1.39 do {
1.40 fread( &chunk, sizeof(chunk), 1, f );
2.1 --- a/src/drivers/cdrom/defs.h Sat Sep 17 22:35:45 2011 +1000
2.2 +++ b/src/drivers/cdrom/defs.h Sat Sep 17 22:39:36 2011 +1000
2.3 @@ -74,6 +74,8 @@
2.4 SECTOR_RAW_XA,
2.5 /* 2352-byte raw data sector in a non-XA session */
2.6 SECTOR_RAW_NONXA,
2.7 + /* CDDA + subchannel data */
2.8 + SECTOR_CDDA_SUBCHANNEL
2.9 } sector_mode_t;
2.10
2.11
3.1 --- a/src/drivers/cdrom/sector.c Sat Sep 17 22:35:45 2011 +1000
3.2 +++ b/src/drivers/cdrom/sector.c Sat Sep 17 22:39:36 2011 +1000
3.3 @@ -43,13 +43,14 @@
3.4 CDROM_READ_MODE2|CDROM_READ_DATA, CDROM_READ_MODE2_FORM1|CDROM_READ_DATA,
3.5 CDROM_READ_MODE2_FORM1|CDROM_READ_DATA,
3.6 CDROM_READ_MODE2|CDROM_READ_DATA|CDROM_READ_SUBHEADER|CDROM_READ_ECC,
3.7 - CDROM_READ_RAW, CDROM_READ_RAW };
3.8 + CDROM_READ_RAW, CDROM_READ_RAW,
3.9 + CDROM_READ_CDDA|CDROM_READ_DATA};
3.10
3.11 /* Block size for each sector mode */
3.12 -const uint32_t cdrom_sector_size[] = { 0, 2352, 2048, 2336, 2048, 2324, 2336, 2352, 2352 };
3.13 +const uint32_t cdrom_sector_size[] = { 0, 2352, 2048, 2336, 2048, 2324, 2336, 2352, 2352, 2448 };
3.14
3.15 const char *cdrom_sector_mode_names[] = { "Unknown", "Audio", "Mode 1", "Mode 2", "Mode 2 Form 1", "Mode 2 Form 2",
3.16 - "Mode 2 semiraw", "XA Raw", "Non-XA Raw" };
3.17 + "Mode 2 semiraw", "XA Raw", "Non-XA Raw", "CDDA+Subchan" };
3.18
3.19
3.20 /********************* Public functions *************************/
3.21 @@ -152,7 +153,7 @@
3.22 switch( read_sector_type ) {
3.23 case CDROM_READ_ANY: break;
3.24 case CDROM_READ_CDDA:
3.25 - if( sector_mode != SECTOR_CDDA )
3.26 + if( sector_mode != SECTOR_CDDA && sector_mode != SECTOR_CDDA_SUBCHANNEL )
3.27 return CDROM_ERROR_BADREADMODE;
3.28 break;
3.29 case CDROM_READ_MODE1:
3.30 @@ -175,6 +176,7 @@
3.31 /* Check the fields requested are sane per MMC (non-contiguous regions prohibited) */
3.32 switch( sector_mode ) {
3.33 case SECTOR_CDDA:
3.34 + case SECTOR_CDDA_SUBCHANNEL:
3.35 return CDROM_ERROR_OK; /* Everything is OK */
3.36 case SECTOR_MODE2_FORM1:
3.37 case SECTOR_MODE2_FORM2:
3.38 @@ -301,7 +303,7 @@
3.39 cdrom_lba_t lba, cdrom_count_t block_count, cdrom_read_mode_t mode,
3.40 unsigned char *buf, size_t *length )
3.41 {
3.42 - unsigned char tmp[CDROM_MAX_SECTOR_SIZE];
3.43 + unsigned char tmp[2448];
3.44 int read_sector_type = CDROM_READ_TYPE(mode);
3.45 int read_sector_fields = CDROM_READ_FIELDS(mode);
3.46 int i;
3.47 @@ -319,6 +321,17 @@
3.48 device->read_blocks( device, lba, block_count, buf );
3.49 }
3.50 break;
3.51 + case SECTOR_CDDA_SUBCHANNEL:
3.52 + if( read_sector_type != CDROM_READ_ANY && read_sector_type != CDROM_READ_CDDA )
3.53 + return CDROM_ERROR_BADREADMODE;
3.54 + if( read_sector_fields != 0 ) {
3.55 + len = block_count * 2352;
3.56 + for( i=0; i<block_count; i++ ) {
3.57 + device->read_blocks( device, lba+i, 1, tmp );
3.58 + memcpy( &buf[2352*i], tmp, 2352 );
3.59 + }
3.60 + }
3.61 + break;
3.62 case SECTOR_RAW_XA:
3.63 case SECTOR_RAW_NONXA:
3.64 case SECTOR_SEMIRAW_MODE2:
.