diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index d9128a9ae3f8..d290e19845f8 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -2017,38 +2017,6 @@ static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) | |||
2017 | return 0; | 2017 | return 0; |
2018 | } | 2018 | } |
2019 | 2019 | ||
2020 | /* ATAPI cdrom drives are free to select the speed you request or any slower | ||
2021 | rate :-( Requesting too fast a speed will _not_ produce an error. */ | ||
2022 | static int cdrom_select_speed(ide_drive_t *drive, int speed, | ||
2023 | struct request_sense *sense) | ||
2024 | { | ||
2025 | struct cdrom_info *cd = drive->driver_data; | ||
2026 | struct cdrom_device_info *cdi = &cd->devinfo; | ||
2027 | struct request req; | ||
2028 | cdrom_prepare_request(drive, &req); | ||
2029 | |||
2030 | req.sense = sense; | ||
2031 | if (speed == 0) | ||
2032 | speed = 0xffff; /* set to max */ | ||
2033 | else | ||
2034 | speed *= 177; /* Nx to kbytes/s */ | ||
2035 | |||
2036 | req.cmd[0] = GPCMD_SET_SPEED; | ||
2037 | /* Read Drive speed in kbytes/second MSB */ | ||
2038 | req.cmd[2] = (speed >> 8) & 0xff; | ||
2039 | /* Read Drive speed in kbytes/second LSB */ | ||
2040 | req.cmd[3] = speed & 0xff; | ||
2041 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != | ||
2042 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { | ||
2043 | /* Write Drive speed in kbytes/second MSB */ | ||
2044 | req.cmd[4] = (speed >> 8) & 0xff; | ||
2045 | /* Write Drive speed in kbytes/second LSB */ | ||
2046 | req.cmd[5] = speed & 0xff; | ||
2047 | } | ||
2048 | |||
2049 | return cdrom_queue_packet_command(drive, &req); | ||
2050 | } | ||
2051 | |||
2052 | static int cdrom_get_toc_entry(ide_drive_t *drive, int track, | 2020 | static int cdrom_get_toc_entry(ide_drive_t *drive, int track, |
2053 | struct atapi_toc_entry **ent) | 2021 | struct atapi_toc_entry **ent) |
2054 | { | 2022 | { |
@@ -2272,23 +2240,47 @@ static void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf) | |||
2272 | cd->max_speed = (maxspeed + (176/2)) / 176; | 2240 | cd->max_speed = (maxspeed + (176/2)) / 176; |
2273 | } | 2241 | } |
2274 | 2242 | ||
2275 | static | 2243 | /* |
2276 | int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed) | 2244 | * ATAPI devices are free to select the speed you request or any slower |
2245 | * rate. :-( Requesting too fast a speed will _not_ produce an error. | ||
2246 | */ | ||
2247 | static int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) | ||
2277 | { | 2248 | { |
2278 | ide_drive_t *drive = cdi->handle; | 2249 | ide_drive_t *drive = cdi->handle; |
2279 | struct cdrom_info *cd = drive->driver_data; | 2250 | struct cdrom_info *cd = drive->driver_data; |
2251 | struct request rq; | ||
2280 | struct request_sense sense; | 2252 | struct request_sense sense; |
2281 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; | 2253 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
2282 | int stat; | 2254 | int stat; |
2283 | 2255 | ||
2284 | if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0) | 2256 | cdrom_prepare_request(drive, &rq); |
2285 | return stat; | 2257 | |
2258 | rq.sense = &sense; | ||
2259 | |||
2260 | if (speed == 0) | ||
2261 | speed = 0xffff; /* set to max */ | ||
2262 | else | ||
2263 | speed *= 177; /* Nx to kbytes/s */ | ||
2264 | |||
2265 | rq.cmd[0] = GPCMD_SET_SPEED; | ||
2266 | /* Read Drive speed in kbytes/second MSB/LSB */ | ||
2267 | rq.cmd[2] = (speed >> 8) & 0xff; | ||
2268 | rq.cmd[3] = speed & 0xff; | ||
2269 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != | ||
2270 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { | ||
2271 | /* Write Drive speed in kbytes/second MSB/LSB */ | ||
2272 | rq.cmd[4] = (speed >> 8) & 0xff; | ||
2273 | rq.cmd[5] = speed & 0xff; | ||
2274 | } | ||
2275 | |||
2276 | stat = cdrom_queue_packet_command(drive, &rq); | ||
2286 | 2277 | ||
2287 | if (!ide_cdrom_get_capabilities(drive, buf)) { | 2278 | if (!ide_cdrom_get_capabilities(drive, buf)) { |
2288 | ide_cdrom_update_speed(drive, buf); | 2279 | ide_cdrom_update_speed(drive, buf); |
2289 | cdi->speed = cd->current_speed; | 2280 | cdi->speed = cd->current_speed; |
2290 | } | 2281 | } |
2291 | return 0; | 2282 | |
2283 | return 0; | ||
2292 | } | 2284 | } |
2293 | 2285 | ||
2294 | /* | 2286 | /* |