1 #include <linux/kernel.h>
4 #include <linux/errno.h>
5 #include <linux/string.h>
7 #include <linux/module.h>
9 #include <linux/cdrom.h>
11 #include <linux/slab.h>
13 #include <asm/uaccess.h>
15 #include <scsi/scsi.h>
31 static int xa_test = 0;
37 #define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0)
102 tocentry->
cdte_addr.
lba = (((((buffer[8] << 8) + buffer[9]) << 8)
103 + buffer[10]) << 8) + buffer[11];
109 #define IOCTL_RETRIES 3
122 ret = sr_read_tochdr(cdi, &tochdr);
138 ret = sr_read_tocentry(cdi, &trk0_te);
141 ret = sr_read_tocentry(cdi, &trk1_te);
177 result = sr_fake_playtrkind(cdi, ti);
209 memset(sense, 0,
sizeof(*sense));
228 if (sshdr.
asc == 0x04 &&
229 sshdr.
ascq == 0x01) {
244 printk(
KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->
cdi.name);
252 if (sshdr.
asc == 0x20 &&
287 cgc.
cmd[4] = (pos == 0) ? 0x03 : 0x02 ;
316 && sshdr.
asc == 0x04 && sshdr.
ascq == 0x01)
320 if (med.media_present)
322 else if (med.door_open)
334 && sshdr.
asc == 0x04 && sshdr.
ascq == 0x02)
348 if (scsi_sense_valid(&sshdr) &&
363 int i,
rc, have_datatracks = 0;
366 rc = sr_read_tochdr(cdi, &toc_h);
373 if (sr_read_tocentry(cdi, &toc_e))
380 if (!have_datatracks)
445 cgc.
cmd[2] = (speed >> 8) & 0xff;
446 cgc.
cmd[3] = speed & 0xff;
465 return sr_read_tochdr(cdi, arg);
467 return sr_read_tocentry(cdi, arg);
469 return sr_play_trkind(cdi, arg);
494 printk(
"%s: sr_read_cd lba=%d format=%d blksize=%d\n",
495 cd->
cdi.name, lba, format, blksize);
500 cgc.cmd[1] = ((format & 7) << 2);
501 cgc.cmd[2] = (
unsigned char) (lba >> 24) & 0xff;
502 cgc.cmd[3] = (
unsigned char) (lba >> 16) & 0xff;
503 cgc.cmd[4] = (
unsigned char) (lba >> 8) & 0xff;
504 cgc.cmd[5] = (
unsigned char) lba & 0xff;
521 cgc.buflen = blksize;
531 static int sr_read_sector(
Scsi_CD *cd,
int lba,
int blksize,
unsigned char *dest)
538 rc = sr_read_cd(cd, dest, lba, 0, blksize);
542 printk(
"CDROM does'nt support READ CD (0xbe) command\n");
546 if (blksize != cd->
device->sector_size) {
551 printk(
"%s: sr_read_sector lba=%d blksize=%d\n", cd->
cdi.name, lba, blksize);
556 cgc.cmd[2] = (
unsigned char) (lba >> 24) & 0xff;
557 cgc.cmd[3] = (
unsigned char) (lba >> 16) & 0xff;
558 cgc.cmd[4] = (
unsigned char) (lba >> 8) & 0xff;
559 cgc.cmd[5] = (
unsigned char) lba & 0xff;
562 cgc.buflen = blksize;
577 unsigned char *raw_sector;
586 if (0 == sr_read_sector(cd, cd->
ms_offset + 16,
588 is_xa = (raw_sector[3] == 0x02) ? 1 : 0;
595 printk(
"%s: sr_is_xa: %d\n", cd->
cdi.name, is_xa);