Reading audio CD

Alexander Motin mav at FreeBSD.org
Wed Dec 21 05:53:29 UTC 2011


Hi.

Comparing cd and acd drivers I've found that acd driver handles reading 
of full 2352 bytes audio sectors via READ CD command, while cd driver 
doesn't. In particular that causes error messages about wrong access 
mode during boot/taste if audio CD inserted. Experimenting with it I've 
made a small patch for the cd driver (attached) to allow reading 2352 
bytes sectors. As positive result those errors gone now. But looking for 
some real consumer of this I've found that at least both cdparanoia and 
libcdio are working with device directly with SCSI commands not using 
kernel drivers.

So the question is: are there applications that reading audio cd via 
/dev/cdX device as previously they could do via /dev/acdX? Is this 
functionality used/needed?

-- 
Alexander Motin
-------------- next part --------------
Index: scsi/scsi_all.h
===================================================================
--- scsi/scsi_all.h	(revision 228743)
+++ scsi/scsi_all.h	(working copy)
@@ -932,6 +932,7 @@
 #define	WRITE_12		0xAA
 #define	WRITE_VERIFY_12		0xAE
 #define	READ_ELEMENT_STATUS	0xB8
+#define	READ_CD			0xBE
 
 /* Maintenance In Service Action Codes */
 #define	REPORT_IDENTIFYING_INFRMATION		0x05
Index: scsi/scsi_cd.c
===================================================================
--- scsi/scsi_cd.c	(revision 228743)
+++ scsi/scsi_cd.c	(working copy)
@@ -1483,6 +1483,11 @@
 					/* dxfer_len */ bp->bio_bcount,
 					/* sense_len */ SSD_FULL_SIZE,
 					/* timeout */ 30000);
+			/* Use READ CD command for audio tracks. */
+			if (softc->params.blksize == 2352) {
+				start_ccb->csio.cdb_io.cdb_bytes[0] = READ_CD;
+				start_ccb->csio.cdb_io.cdb_bytes[9] = 0xf8;
+			}
 			start_ccb->ccb_h.ccb_state = CD_CCB_BUFFER_IO;
 
 			
@@ -2880,6 +2885,13 @@
 
 	softc->flags |= CD_FLAG_VALID_TOC;
 
+	/* If the first track is audio, correct sector size. */
+	if ((softc->toc.entries[0].control & 4) == 0) {
+		softc->disk->d_sectorsize = softc->params.blksize = 2352;
+		softc->disk->d_mediasize =
+		    (off_t)softc->params.blksize * softc->params.disksize;
+	}
+
 bailout:
 
 	/*


More information about the freebsd-scsi mailing list