[PATCH] Changing of dvd speed via CDROM_SELECT_SPEED ioctl() call again :)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, Jens Axboe!

This patch implements changing of DVD speed via CDROM_SELECT_SPEED 
ioctl() call. 
Now it checks for the type of media in drive. If drive is dvdrom or
media type is DVD, it change speed via SET_STREAMING command or it
changes speed of CDs via SET_SPEED command. 
What you think about this?

Signed-off-by: Ilja Samartsev <[email protected]>

===========================
--- linux/drivers/ide/ide-cd.c	2005-08-21 21:18:05.000000000 +0600
+++ my_linux/drivers/ide/ide-cd.c	2005-08-28 14:10:51.000000000 +0600
@@ -2390,10 +2390,77 @@ static int cdrom_select_speed(ide_drive_
 			      struct request_sense *sense)
 {
 	struct request req;
+
+	if (CDROM_CONFIG_FLAGS(drive)->dvd) {
+		struct request_sense tmp_sense;
+		unsigned char buf[8];
+
+		/* Detecting type of media */
+		cdrom_prepare_request(drive, &req);
+	
+		req.sense = &tmp_sense;
+		req.data = buf;
+		req.data_len = sizeof(buf);
+
+		req.cmd[0] = GPCMD_GET_CONFIGURATION;
+		req.cmd[8] = sizeof(buf); /* Allocation Length */
+
+		cdrom_queue_packet_command(drive, &req);
+
+		if (((buf[6] << 8) | buf[7]) & 0x30) { /* Media is dvd */
+			struct request_sense cap_sense;
+			unsigned char pd[28];
+			unsigned long cap, spf;
+
+			cdrom_prepare_request(drive, &req);
+
+			req.sense = sense;
+			req.data = pd;
+			req.data_len = sizeof(pd);
+
+			memset(pd, 0, sizeof(pd));
+
+			req.cmd[0] = GPCMD_SET_STREAMING;
+			req.cmd[10] = sizeof(pd); /* parameter list length */
+
+			if (speed <= 0) {
+				pd[0] = 4;	/* restore drive defaults */
+			} else {
+				speed *= 1385;	/* Nx to kbytes/s (FIXME: maybe not right value) */
+
+				if (!cdrom_read_capacity(drive, &cap, &spf, &cap_sense) && cap) {
+					/* good End LBA detected */
+					cap++;
+					pd[8] = (cap >> 24) & 0xff;
+					pd[9] = (cap >> 16) & 0xff;
+					pd[10] = (cap >> 8) & 0xff;
+					pd[11] = cap & 0xff; 
+				} else {
+					/* no good End LBA detected, using max */
+					pd[8] = 0xff;
+					pd[9] = 0xff;
+					pd[10] = 0xff;
+					pd[11] = 0xff; 
+				}
+
+				/* read and write size */
+				pd[12] = pd[20] = (speed >> 24) & 0xff;
+				pd[13] = pd[21] = (speed >> 16) & 0xff;
+				pd[14] = pd[22] = (speed >> 8) & 0xff;
+				pd[15] = pd[23] = speed & 0xff;
+
+				/* read and write time */
+				pd[18] = pd[26] = 1000 >> 8;
+				pd[19] = pd[27] = 1000 & 0xff;
+			}
+			return cdrom_queue_packet_command(drive, &req);
+		}
+	}
+
 	cdrom_prepare_request(drive, &req);
 
 	req.sense = sense;
-	if (speed == 0)
+	if (speed <= 0)
 		speed = 0xffff; /* set to max */
 	else
 		speed *= 177;   /* Nx to kbytes/s */
========== EOF ============

-- 
Samartsev Ilja
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux