public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Changing of dvd speed via CDROM_SELECT_SPEED ioctl() call again :)
@ 2005-08-30  6:56 Samartsev Ilja
  0 siblings, 0 replies; only message in thread
From: Samartsev Ilja @ 2005-08-30  6:56 UTC (permalink / raw)
  To: linux-kernel

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 <samartsev@gmail.com>

===========================
--- 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-08-30  6:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-30  6:56 [PATCH] Changing of dvd speed via CDROM_SELECT_SPEED ioctl() call again :) Samartsev Ilja

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox