--- /tmp/work/old/src/sys/dev/scsipi/cd.c	2010-12-19 14:25:14.000000000 +0200
+++ src/sys/dev/scsipi/cd.c	2010-12-19 14:25:14.000000000 +0200
@@ -3181,7 +3181,7 @@
 	const uint32_t buffer_size = 4 * 1024;	/* worst case TOC estimate */
 	uint8_t *buffer;
 	uint8_t track_sessionnr, last_tracknr, sessionnr, adr, tno, point;
-	uint8_t tmin, tsec, tframe, pmin, psec, pframe;
+	uint8_t control, tmin, tsec, tframe, pmin, psec, pframe;
 	int size, req_size;
 	int error, flags;
 
@@ -3225,6 +3225,7 @@
 
 	/* read in complete raw toc */
 	req_size = _2btol(toc_hdr->length);
+	req_size = 2*((req_size + 1) / 2);	/* for ATAPI */
 	_lto2b(req_size, gtoc_cmd.data_len);
 
 	error = scsipi_command(periph,
@@ -3255,6 +3256,7 @@
 		tno       = rawtoc->tno;
 		sessionnr = rawtoc->sessionnr;
 		adr       = rawtoc->adrcontrol >> 4;
+		control   = rawtoc->adrcontrol & 0xf;
 		point     = rawtoc->point;
 		tmin      = rawtoc->min;
 		tsec      = rawtoc->sec;
@@ -3292,6 +3294,14 @@
 			}
 		}
 
+		if ((control & (3<<2)) == 4)		/* 01xxb */
+			flags |= MMC_TRACKINFO_DATA;
+		if ((control & (1<<2)) == 0) {		/* x0xxb */
+			flags |= MMC_TRACKINFO_AUDIO;
+			if (control & 1)		/* xxx1b */
+				flags |= MMC_TRACKINFO_PRE_EMPH;
+		}
+
 		rawtoc++;
 		size -= sizeof(struct scsipi_toc_rawtoc);
 	}
@@ -3351,7 +3361,7 @@
 	uint32_t lba, lead_out;
 	const uint32_t buffer_size = 4 * 1024;	/* worst case TOC estimate */
 	uint8_t *buffer;
-	uint8_t last_tracknr;
+	uint8_t control, last_tracknr;
 	int size, req_size;
 	int error, flags;
 
@@ -3417,12 +3427,15 @@
 	track_start  = 0;
 	track_size   = 0;
 	lead_out     = 0;
+	flags        = 0;
 
 	size = req_size - sizeof(struct scsipi_toc_header) + 1;
 	while (size > 0) {
 		/* remember, DVD-ROM: tracknr == sessionnr */
 		lba     = _4btol(toc->msf_lba);
 		tracknr = toc->tracknr;
+		control = toc->adrcontrol & 0xf;
+
 		if (trackinfo->tracknr == tracknr) {
 			track_start = lba;
 		}
@@ -3433,6 +3446,17 @@
 		if (tracknr == 0xAA) {
 			lead_out = lba;
 		}
+
+		if ((control & (3<<2)) == 4)		/* 01xxb */
+			flags |= MMC_TRACKINFO_DATA;
+		if ((control & (1<<2)) == 0) {		/* x0xxb */
+			flags |= MMC_TRACKINFO_AUDIO;
+			if (control & (1<<3))		/* 10xxb */
+				flags |= MMC_TRACKINFO_AUDIO_4CHAN;
+			if (control & 1)		/* xxx1b */
+				flags |= MMC_TRACKINFO_PRE_EMPH;
+		}
+
 		toc++;
 		size -= sizeof(struct scsipi_toc_formatted);
 	}
@@ -3446,7 +3470,7 @@
 	trackinfo->track_mode = 0;	/* unknown */
 	trackinfo->data_mode  = 8;	/* 2048 bytes mode1   */
 
-	trackinfo->flags         = 0;
+	trackinfo->flags         = flags;
 	trackinfo->track_start   = track_start;
 	trackinfo->next_writable = 0;
 	trackinfo->free_blocks   = 0;
--- /tmp/work/old/src/sys/dev/scsipi/scsipi_cd.h	2010-12-19 14:26:22.000000000 +0200
+++ src/sys/dev/scsipi/scsipi_cd.h	2010-12-19 14:26:22.000000000 +0200
@@ -115,7 +115,7 @@
 /* read TOC form 0 result entries */
 struct scsipi_toc_formatted {
 	uint8_t  unused1;
-	uint8_t  adrcontol;
+	uint8_t  adrcontrol;
 	uint8_t  tracknr;
 	uint8_t  unused2;
 	uint8_t	 msf_lba[4];		/* union msf_lba from cdio.h */
