Date: Sun, 3 Mar 2002 11:38:52 +0100 (CET) From: Philipp Mergenthaler <philipp.mergenthaler@stud.uni-karlsruhe.de> To: FreeBSD-gnats-submit@freebsd.org Subject: kern/35512: ATA/ATAPI CD driver: impossible to set cd speed to magic value for "maximum speed" Message-ID: <200203031038.g23AcqrI011528@i609a.hadiko.de>
next in thread | raw e-mail | index | archive | help
>Number: 35512 >Category: kern >Synopsis: ATA/ATAPI CD driver: impossible to set cd speed to magic value for "maximum speed" >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 03 02:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Philipp Mergenthaler >Release: FreeBSD 5.0-CURRENT i386 >Organization: University of Karlsruhe >Environment: System: FreeBSD i609a.hadiko.de 5.0-CURRENT FreeBSD 5.0-CURRENT #505: Sun Mar 3 00:34:35 CET 2002 p@i609a.hadiko.de:/usr/src/sys/i386/compile/I609 i386 >Description: When calling acd_set_speed(), the speed is multiplied with 177, i.e. converted from "multiples of single speed" to "data rate in kB/sec". However, since 177 isn't a divisor of 65535, it is impossible to set the speed to this value, which means "maximum speed". (At least with my drive - LITEON DVD-ROM LTD122/IK01 - it is necessary to specify exactly this value. A value like e.g. 65490 (=177*370) won't change the drive's current speed.) >How-To-Repeat: Below is a patch to cdcontrol which adds the command "speed" so you can test this easily. >Fix: I would suggest that the driver should set the drive's speed to the value given with ioctl(), i.e. that the speed conversion should be left to the userland. Index: atapi-cd.c =================================================================== RCS file: /ncvs/src/sys/dev/ata/atapi-cd.c,v retrieving revision 1.109 diff -u -r1.109 atapi-cd.c --- atapi-cd.c 15 Feb 2002 07:08:44 -0000 1.109 +++ atapi-cd.c 2 Mar 2002 23:48:36 -0000 @@ -978,11 +978,11 @@ break; case CDRIOCREADSPEED: - error = acd_set_speed(cdp, 177 * (*(int *)addr), -1); + error = acd_set_speed(cdp, *(int *)addr, -1); break; case CDRIOCWRITESPEED: - error = acd_set_speed(cdp, -1, 177 * (*(int *)addr)); + error = acd_set_speed(cdp, -1, *(int *)addr); break; case CDRIOCGETBLOCKSIZE: Here's the patch to cdcontrol. It passes the speed as entered by the user directly to the driver. I.e with the current driver the speed is in "multiples of single speed" and with the above patch it is in kB/s (or -1 for "maximum speed supported by the drive"). Index: cdcontrol.1 =================================================================== RCS file: /ncvs/src/usr.sbin/cdcontrol/cdcontrol.1,v retrieving revision 1.32 diff -u -r1.32 cdcontrol.1 --- cdcontrol.1 15 Jul 2001 08:01:46 -0000 1.32 +++ cdcontrol.1 2 Mar 2002 21:20:28 -0000 @@ -156,6 +156,11 @@ Set LBA ioctl mode. .It Cm quit Quit the program. +.It Cm speed Op Ar s +Set the highest speed that the drive should use (default is single speed). +This command is currently only supported on ATAPI drives. +Note that reading CD data will use the speed set by this command +but playing audio CDs might not. .El .Sh ENVIRONMENT The following environment variables affect the execution of Index: cdcontrol.c =================================================================== RCS file: /ncvs/src/usr.sbin/cdcontrol/cdcontrol.c,v retrieving revision 1.37 diff -u -r1.37 cdcontrol.c --- cdcontrol.c 18 Feb 2002 20:35:27 -0000 1.37 +++ cdcontrol.c 3 Mar 2002 01:42:27 -0000 @@ -24,6 +24,7 @@ #endif /* not lint */ #include <sys/cdio.h> +#include <sys/cdrio.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/param.h> @@ -73,6 +74,7 @@ #define CMD_CDID 15 #define CMD_NEXT 16 #define CMD_PREVIOUS 17 +#define CMD_SPEED 18 #define STATUS_AUDIO 0x1 #define STATUS_MEDIA 0x2 #define STATUS_VOLUME 0x4 @@ -105,6 +107,7 @@ { CMD_VOLUME, "volume", 1, "<l> <r> | left | right | mute | mono | stereo" }, { CMD_CDID, "cdid", 2, "" }, +{ CMD_SPEED, "speed", 2, "[speed]" }, { 0, NULL, 0, NULL } }; @@ -277,7 +280,7 @@ int run (int cmd, char *arg) { - int l, r, rc; + int l, r, rc, speed; switch (cmd) { @@ -425,6 +428,25 @@ return setvol (l, r); + case CMD_SPEED: + if (fd < 0 && ! open_cd ()) + return (0); + + rc=sscanf (arg, "%d", &speed); + switch (rc) { + case EOF: + speed = 1; + break; + case 1: + break; + default: + warnx("invalid command arguments"); + return (0); + } + rc = ioctl (fd, CDRIOCREADSPEED, &speed); + + return (rc); + default: case CMD_HELP: help (); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203031038.g23AcqrI011528>