All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samartsev Ilja <samartsev@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Changing of dvd speed via CDROM_SELECT_SPEED ioctl() call again :)
Date: Tue, 30 Aug 2005 12:56:33 +0600	[thread overview]
Message-ID: <20050830125633.466db563.samartsev@gmail.com> (raw)

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

                 reply	other threads:[~2005-08-30  6:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050830125633.466db563.samartsev@gmail.com \
    --to=samartsev@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.