lkml.org 
[lkml]   [2005]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Changing of dvd speed via CDROM_SELECT_SPEED ioctl() call again :)
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-08-30 08:59    [W:0.029 / U:8.964 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site