Search
lxdream.org :: lxdream/src/drivers/cd_linux.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/cd_linux.c
changeset 720:b5594d1ac80a
prev709:18c39a8e504c
next736:a02d1475ccfd
author nkeynes
date Sat Jul 05 11:57:36 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Get OS X cdrom driver to the 'sort of working' stage. Hide most of the IOKit
fun in a separate osx_iokit module.
file annotate diff log raw
1.1 --- a/src/drivers/cd_linux.c Wed Jun 25 10:40:45 2008 +0000
1.2 +++ b/src/drivers/cd_linux.c Sat Jul 05 11:57:36 2008 +0000
1.3 @@ -34,8 +34,6 @@
1.4 #define MAXTOCSIZE 4 + (MAXTOCENTRIES*11)
1.5 #define MAX_SECTORS_PER_CALL 1
1.6
1.7 -#define MSFTOLBA( m,s,f ) (f + (s*CD_FRAMES) + (m*CD_FRAMES*CD_SECS))
1.8 -
1.9 static uint32_t inline lbatomsf( uint32_t lba ) {
1.10 union cdrom_addr addr;
1.11 lba = lba + CD_MSF_OFFSET;
1.12 @@ -164,57 +162,9 @@
1.13 memset( buf, 0, sizeof(buf) );
1.14 gdrom_error_t status = linux_send_command( fd, cmd, buf, &buflen, CGC_DATA_READ );
1.15 if( status != 0 ) {
1.16 - return status;
1.17 + return status;
1.18 }
1.19 -
1.20 - int max_track = 0;
1.21 - int last_track = -1;
1.22 - int leadout = -1;
1.23 - int len = (buf[0] << 8) | buf[1];
1.24 - int session_type = -1;
1.25 - int i;
1.26 - for( i = 4; i<len; i+=11 ) {
1.27 - int session = buf[i];
1.28 - int adr = buf[i+1] >> 4;
1.29 - int point = buf[i+3];
1.30 - if( adr == 0x01 && point > 0 && point < 100 ) {
1.31 - /* Track info */
1.32 - int trackno = point-1;
1.33 - if( point > max_track ) {
1.34 - max_track = point;
1.35 - }
1.36 - disc->track[trackno].flags = (buf[i+1] & 0x0F) << 4;
1.37 - disc->track[trackno].session = session - 1;
1.38 - disc->track[trackno].lba = MSFTOLBA(buf[i+8],buf[i+9],buf[i+10]);
1.39 - if( disc->track[trackno].flags & TRACK_DATA ) {
1.40 - disc->track[trackno].mode = GDROM_MODE1;
1.41 - } else {
1.42 - disc->track[trackno].mode = GDROM_CDDA;
1.43 - }
1.44 - if( last_track != -1 ) {
1.45 - disc->track[last_track].sector_count = disc->track[trackno].lba -
1.46 - disc->track[last_track].lba;
1.47 - }
1.48 - last_track = trackno;
1.49 - } else switch( (adr << 8) | point ) {
1.50 - case 0x1A0: /* session info */
1.51 - if( buf[i+9] == 0x20 ) {
1.52 - session_type = IDE_DISC_CDROMXA;
1.53 - } else {
1.54 - session_type = IDE_DISC_CDROM;
1.55 - }
1.56 - disc->disc_type = session_type;
1.57 - break;
1.58 - case 0x1A2: /* leadout */
1.59 - leadout = MSFTOLBA(buf[i+8], buf[i+9], buf[i+10]);
1.60 - break;
1.61 - }
1.62 - }
1.63 - disc->track_count = max_track;
1.64 -
1.65 - if( leadout != -1 && last_track != -1 ) {
1.66 - disc->track[last_track].sector_count = leadout - disc->track[last_track].lba;
1.67 - }
1.68 + mmc_parse_toc2( disc, buf );
1.69 return 0;
1.70 }
1.71
1.72 @@ -252,34 +202,13 @@
1.73 int fd = fileno(image->file);
1.74 uint32_t real_sector = sector - CD_MSF_OFFSET;
1.75 uint32_t sector_size = MAX_SECTOR_SIZE;
1.76 - char cmd[12] = { 0xBE, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
1.77 -
1.78 - cmd[1] = (mode & 0x0E) << 1;
1.79 - cmd[2] = (real_sector >> 24) & 0xFF;
1.80 - cmd[3] = (real_sector >> 16) & 0xFF;
1.81 - cmd[4] = (real_sector >> 8) & 0xFF;
1.82 - cmd[5] = real_sector & 0xFF;
1.83 - cmd[6] = 0;
1.84 - cmd[7] = 0;
1.85 - cmd[8] = 1;
1.86 -
1.87 - if( READ_CD_RAW(mode) ) {
1.88 - cmd[9] = 0xF0;
1.89 - } else {
1.90 - if( READ_CD_HEADER(mode) ) {
1.91 - cmd[9] = 0xA0;
1.92 - }
1.93 - if( READ_CD_SUBHEAD(mode) ) {
1.94 - cmd[9] |= 0x40;
1.95 - }
1.96 - if( READ_CD_DATA(mode) ) {
1.97 - cmd[9] |= 0x10;
1.98 - }
1.99 - }
1.100 + char cmd[12];
1.101 +
1.102 + mmc_make_read_cd_cmd( cmd, real_sector, mode );
1.103
1.104 gdrom_error_t status = linux_send_command( fd, cmd, buf, &sector_size, CGC_DATA_READ );
1.105 if( status != 0 ) {
1.106 - return status;
1.107 + return status;
1.108 }
1.109 *length = 2048;
1.110 return 0;
.