From owner-freebsd-bugs Sun Apr 7 5:40:17 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 637F237B419 for ; Sun, 7 Apr 2002 05:40:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g37Ce2b65107; Sun, 7 Apr 2002 05:40:02 -0700 (PDT) (envelope-from gnats) Received: from mailgate.rz.uni-karlsruhe.de (mailgate.rz.uni-karlsruhe.de [129.13.64.97]) by hub.freebsd.org (Postfix) with ESMTP id 9754137B41B for ; Sun, 7 Apr 2002 05:36:47 -0700 (PDT) Received: from nce2.hadiko.de (hadince2.hadiko.uni-karlsruhe.de [172.20.32.2]) by mailgate.rz.uni-karlsruhe.de with esmtp (Exim 3.33 #1) id 16uBuY-0000e6-00; Sun, 07 Apr 2002 14:36:46 +0200 Received: from i609a.hadiko.de (hadii609a.hadiko.uni-karlsruhe.de [172.20.49.159]) by nce2.hadiko.de (8.11.3/8.11.3) with ESMTP id g37Cajx24888 for ; Sun, 7 Apr 2002 14:36:45 +0200 (MET DST) Received: from i609a.hadiko.de (localhost [127.0.0.1]) by i609a.hadiko.de (8.12.2/8.12.2) with ESMTP id g37CajI3000965 for ; Sun, 7 Apr 2002 14:36:45 +0200 (CEST) (envelope-from p@i609a.hadiko.de) Received: (from p@localhost) by i609a.hadiko.de (8.12.2/8.12.2/Submit) id g37CaiN0000964; Sun, 7 Apr 2002 14:36:44 +0200 (CEST) Message-Id: <200204071236.g37CaiN0000964@i609a.hadiko.de> Date: Sun, 7 Apr 2002 14:36:44 +0200 (CEST) From: Philipp Mergenthaler Reply-To: Philipp Mergenthaler To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/36845: Add ioctls CDRIOCREADSPEED/WRITESPEED to the scsi cd driver Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36845 >Category: kern >Synopsis: Add ioctls CDRIOCREADSPEED/WRITESPEED to the scsi cd driver >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Apr 07 05:40:02 PDT 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 #528: Sun Apr 7 11:36:14 CEST 2002 p@i609a.hadiko.de:/usr/src/sys/i386/compile/I609 i386 >Description: This patch adds the ioctls CDRIOCREADSPEED and CDRIOCWRITESPEED to the scsi driver, which allow to set the drive's speed. >How-To-Repeat: To test this, you may want to use the patch to cdcontrol from PR kern/35512. To test whether your drive offers this capability, use camcontrol cmd cd0 -v -c 'bb 0 v:i2 0:i2 0 0 0 0 0 0' 2000 where the last number (here: 2000) is the speed in kB/s. (But apparently there are drives which have a vendor specific command for this and for which this patch may not work.) >Fix: Index: sys/cam/scsi/scsi_cd.c =================================================================== RCS file: /ncvs/src/sys/cam/scsi/scsi_cd.c,v retrieving revision 1.58 diff -u -r1.58 scsi_cd.c --- sys/cam/scsi/scsi_cd.c 22 Feb 2002 09:18:43 -0000 1.58 +++ sys/cam/scsi/scsi_cd.c 6 Apr 2002 19:18:23 -0000 @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -231,6 +232,8 @@ static int cdpause(struct cam_periph *periph, u_int32_t go); static int cdstopunit(struct cam_periph *periph, u_int32_t eject); static int cdstartunit(struct cam_periph *periph); +static int cdsetspeed(struct cam_periph *periph, + u_int16_t rdspeed, u_int16_t wrspeed); static int cdreportkey(struct cam_periph *periph, struct dvd_authinfo *authinfo); static int cdsendkey(struct cam_periph *periph, @@ -2427,6 +2430,12 @@ /* return (cd_reset(periph)); */ error = ENOTTY; break; + case CDRIOCREADSPEED: + error = cdsetspeed(periph, *(u_int16_t *)addr, -1); + break; + case CDRIOCWRITESPEED: + error = cdsetspeed(periph, -1, *(u_int16_t *)addr); + break; case DVDIOCSENDKEY: case DVDIOCREPORTKEY: { struct dvd_authinfo *authinfo; @@ -3066,6 +3075,48 @@ /* immediate */ FALSE, /* sense_len */ SSD_FULL_SIZE, /* timeout */ 50000); + + error = cdrunccb(ccb, cderror, /*cam_flags*/CAM_RETRY_SELTO, + /*sense_flags*/SF_RETRY_UA); + + xpt_release_ccb(ccb); + + return(error); +} + +static int +cdsetspeed(struct cam_periph *periph, u_int16_t rdspeed, u_int16_t wrspeed) +{ + struct scsi_set_speed *scsi_cmd; + struct ccb_scsiio *csio; + union ccb *ccb; + int error; + + error = 0; + + ccb = cdgetccb(periph, /* priority */ 1); + + csio = &ccb->csio; + + cam_fill_csio(csio, + /* retries */ 1, + /* cbfcnp */ cddone, + /* flags */ CAM_DIR_NONE, + /* tag_action */ MSG_SIMPLE_Q_TAG, + /* data_ptr */ NULL, + /* dxfer_len */ 0, + /* sense_len */ SSD_FULL_SIZE, + sizeof(struct scsi_set_speed), + /* timeout */ 50000); + + scsi_cmd = (struct scsi_set_speed *)&csio->cdb_io.cdb_bytes; + bzero (scsi_cmd, sizeof(*scsi_cmd)); + + scsi_cmd->op_code = SET_CD_SPEED; + scsi_cmd->readspeed[0]=rdspeed >> 8 & 0xff; + scsi_cmd->readspeed[1]=rdspeed & 0xff; + scsi_cmd->writespeed[0]=wrspeed >> 8 & 0xff; + scsi_cmd->writespeed[1]=wrspeed & 0xff; error = cdrunccb(ccb, cderror, /*cam_flags*/CAM_RETRY_SELTO, /*sense_flags*/SF_RETRY_UA); Index: sys/cam/scsi/scsi_cd.h =================================================================== RCS file: /ncvs/src/sys/cam/scsi/scsi_cd.h,v retrieving revision 1.5 diff -u -r1.5 scsi_cd.h --- sys/cam/scsi/scsi_cd.h 10 Feb 2002 21:36:13 -0000 1.5 +++ sys/cam/scsi/scsi_cd.h 7 Apr 2002 09:26:29 -0000 @@ -169,6 +169,16 @@ u_int8_t control; }; +struct scsi_set_speed +{ + u_int8_t op_code; + u_int8_t byte2; + u_int8_t readspeed[2]; + u_int8_t writespeed[2]; + u_int8_t unused[5]; + u_int8_t control; +}; + struct scsi_report_key { u_int8_t opcode; @@ -251,6 +261,7 @@ #define PLAY_12 0xa5 /* cdrom pause in 'play audio' mode */ #define PLAY_TRACK_REL_BIG 0xa9 /* cdrom play track/index mode */ #define READ_DVD_STRUCTURE 0xad /* read dvd structure */ +#define SET_CD_SPEED 0xbb /* set c/dvd speed */ struct scsi_report_key_data_header { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message