Blame view
drivers/scsi/sr_ioctl.c
14.7 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 |
#include <linux/kernel.h> |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 7 |
#include <linux/mm.h> #include <linux/fs.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/blkdev.h> |
acf3368ff scsi: Fix up file... |
8 |
#include <linux/module.h> |
1da177e4c Linux-2.6.12-rc2 |
9 10 11 |
#include <linux/blkpg.h> #include <linux/cdrom.h> #include <linux/delay.h> |
5a0e3ad6a include cleanup: ... |
12 |
#include <linux/slab.h> |
1da177e4c Linux-2.6.12-rc2 |
13 |
#include <asm/io.h> |
7c0f6ba68 Replace <asm/uacc... |
14 |
#include <linux/uaccess.h> |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 18 19 20 21 |
#include <scsi/scsi.h> #include <scsi/scsi_dbg.h> #include <scsi/scsi_device.h> #include <scsi/scsi_eh.h> #include <scsi/scsi_host.h> #include <scsi/scsi_ioctl.h> |
820732b50 [SCSI] convert sr... |
22 |
#include <scsi/scsi_cmnd.h> |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 26 27 28 29 30 31 32 33 34 |
#include "sr.h" #if 0 #define DEBUG #endif /* The sr_is_xa() seems to trigger firmware bugs with some drives :-( * It is off by default and can be turned on with this module parameter */ static int xa_test = 0; module_param(xa_test, int, S_IRUGO | S_IWUSR); |
a09c63112 [SCSI] sr: split ... |
35 36 37 |
/* primitive to determine whether we need to have GFP_DMA set based on * the status of the unchecked_isa_dma flag in the host structure */ #define SR_GFP_DMA(cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0) |
a09c63112 [SCSI] sr: split ... |
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
static int sr_read_tochdr(struct cdrom_device_info *cdi, struct cdrom_tochdr *tochdr) { struct scsi_cd *cd = cdi->handle; struct packet_command cgc; int result; unsigned char *buffer; buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd)); if (!buffer) return -ENOMEM; memset(&cgc, 0, sizeof(struct packet_command)); cgc.timeout = IOCTL_TIMEOUT; cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; cgc.cmd[8] = 12; /* LSB of length */ cgc.buffer = buffer; cgc.buflen = 12; cgc.quiet = 1; cgc.data_direction = DMA_FROM_DEVICE; result = sr_do_ioctl(cd, &cgc); tochdr->cdth_trk0 = buffer[2]; tochdr->cdth_trk1 = buffer[3]; kfree(buffer); return result; } static int sr_read_tocentry(struct cdrom_device_info *cdi, struct cdrom_tocentry *tocentry) { struct scsi_cd *cd = cdi->handle; struct packet_command cgc; int result; unsigned char *buffer; buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd)); if (!buffer) return -ENOMEM; memset(&cgc, 0, sizeof(struct packet_command)); cgc.timeout = IOCTL_TIMEOUT; cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0; cgc.cmd[6] = tocentry->cdte_track; cgc.cmd[8] = 12; /* LSB of length */ cgc.buffer = buffer; cgc.buflen = 12; cgc.data_direction = DMA_FROM_DEVICE; result = sr_do_ioctl(cd, &cgc); tocentry->cdte_ctrl = buffer[5] & 0xf; tocentry->cdte_adr = buffer[5] >> 4; tocentry->cdte_datamode = (tocentry->cdte_ctrl & 0x04) ? 1 : 0; if (tocentry->cdte_format == CDROM_MSF) { tocentry->cdte_addr.msf.minute = buffer[9]; tocentry->cdte_addr.msf.second = buffer[10]; tocentry->cdte_addr.msf.frame = buffer[11]; } else tocentry->cdte_addr.lba = (((((buffer[8] << 8) + buffer[9]) << 8) + buffer[10]) << 8) + buffer[11]; kfree(buffer); return result; } |
1da177e4c Linux-2.6.12-rc2 |
106 107 108 109 110 111 112 113 114 115 116 117 118 |
#define IOCTL_RETRIES 3 /* ATAPI drives don't have a SCMD_PLAYAUDIO_TI command. When these drives are emulating a SCSI device via the idescsi module, they need to have CDROMPLAYTRKIND commands translated into CDROMPLAYMSF commands for them */ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti) { struct cdrom_tocentry trk0_te, trk1_te; struct cdrom_tochdr tochdr; struct packet_command cgc; int ntracks, ret; |
a09c63112 [SCSI] sr: split ... |
119 120 |
ret = sr_read_tochdr(cdi, &tochdr); if (ret) |
1da177e4c Linux-2.6.12-rc2 |
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
return ret; ntracks = tochdr.cdth_trk1 - tochdr.cdth_trk0 + 1; if (ti->cdti_trk1 == ntracks) ti->cdti_trk1 = CDROM_LEADOUT; else if (ti->cdti_trk1 != CDROM_LEADOUT) ti->cdti_trk1 ++; trk0_te.cdte_track = ti->cdti_trk0; trk0_te.cdte_format = CDROM_MSF; trk1_te.cdte_track = ti->cdti_trk1; trk1_te.cdte_format = CDROM_MSF; |
a09c63112 [SCSI] sr: split ... |
135 136 |
ret = sr_read_tocentry(cdi, &trk0_te); if (ret) |
1da177e4c Linux-2.6.12-rc2 |
137 |
return ret; |
a09c63112 [SCSI] sr: split ... |
138 139 |
ret = sr_read_tocentry(cdi, &trk1_te); if (ret) |
1da177e4c Linux-2.6.12-rc2 |
140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
return ret; memset(&cgc, 0, sizeof(struct packet_command)); cgc.cmd[0] = GPCMD_PLAY_AUDIO_MSF; cgc.cmd[3] = trk0_te.cdte_addr.msf.minute; cgc.cmd[4] = trk0_te.cdte_addr.msf.second; cgc.cmd[5] = trk0_te.cdte_addr.msf.frame; cgc.cmd[6] = trk1_te.cdte_addr.msf.minute; cgc.cmd[7] = trk1_te.cdte_addr.msf.second; cgc.cmd[8] = trk1_te.cdte_addr.msf.frame; cgc.data_direction = DMA_NONE; cgc.timeout = IOCTL_TIMEOUT; return sr_do_ioctl(cdi->handle, &cgc); } |
a09c63112 [SCSI] sr: split ... |
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
static int sr_play_trkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti) { struct scsi_cd *cd = cdi->handle; struct packet_command cgc; int result; memset(&cgc, 0, sizeof(struct packet_command)); cgc.timeout = IOCTL_TIMEOUT; cgc.cmd[0] = GPCMD_PLAYAUDIO_TI; cgc.cmd[4] = ti->cdti_trk0; cgc.cmd[5] = ti->cdti_ind0; cgc.cmd[7] = ti->cdti_trk1; cgc.cmd[8] = ti->cdti_ind1; cgc.data_direction = DMA_NONE; result = sr_do_ioctl(cd, &cgc); if (result == -EDRIVE_CANT_DO_THIS) result = sr_fake_playtrkind(cdi, ti); return result; } |
1da177e4c Linux-2.6.12-rc2 |
177 178 179 180 181 182 |
/* We do our own retries because we want to know what the specific error code is. Normally the UNIT_ATTENTION code will automatically clear after one error */ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) { |
1da177e4c Linux-2.6.12-rc2 |
183 |
struct scsi_device *SDev; |
e7d0748dd block: Switch str... |
184 |
struct scsi_sense_hdr local_sshdr, *sshdr = &local_sshdr; |
1da177e4c Linux-2.6.12-rc2 |
185 186 187 |
int result, err = 0, retries = 0; SDev = cd->device; |
820732b50 [SCSI] convert sr... |
188 |
|
e7d0748dd block: Switch str... |
189 190 |
if (cgc->sshdr) sshdr = cgc->sshdr; |
f7068114d sr: pass down cor... |
191 |
|
1da177e4c Linux-2.6.12-rc2 |
192 193 194 |
retry: if (!scsi_block_when_processing_errors(SDev)) { err = -ENODEV; |
820732b50 [SCSI] convert sr... |
195 |
goto out; |
1da177e4c Linux-2.6.12-rc2 |
196 |
} |
820732b50 [SCSI] convert sr... |
197 |
result = scsi_execute(SDev, cgc->cmd, cgc->data_direction, |
e7d0748dd block: Switch str... |
198 |
cgc->buffer, cgc->buflen, NULL, sshdr, |
76aaf87b4 scsi: merge __scs... |
199 |
cgc->timeout, IOCTL_RETRIES, 0, 0, NULL); |
1da177e4c Linux-2.6.12-rc2 |
200 201 202 |
/* Minimal error checking. Ignore cases we know about, and report the rest. */ if (driver_byte(result) != 0) { |
e7d0748dd block: Switch str... |
203 |
switch (sshdr->sense_key) { |
1da177e4c Linux-2.6.12-rc2 |
204 205 206 |
case UNIT_ATTENTION: SDev->changed = 1; if (!cgc->quiet) |
96eefad2d scsi: Implement s... |
207 208 209 |
sr_printk(KERN_INFO, cd, "disc change detected. "); |
1da177e4c Linux-2.6.12-rc2 |
210 211 212 213 214 |
if (retries++ < 10) goto retry; err = -ENOMEDIUM; break; case NOT_READY: /* This happens if there is no disc in drive */ |
e7d0748dd block: Switch str... |
215 216 |
if (sshdr->asc == 0x04 && sshdr->ascq == 0x01) { |
1da177e4c Linux-2.6.12-rc2 |
217 218 |
/* sense: Logical unit is in process of becoming ready */ if (!cgc->quiet) |
96eefad2d scsi: Implement s... |
219 220 221 |
sr_printk(KERN_INFO, cd, "CDROM not ready yet. "); |
1da177e4c Linux-2.6.12-rc2 |
222 223 224 225 226 227 228 229 230 231 232 |
if (retries++ < 10) { /* sleep 2 sec and try again */ ssleep(2); goto retry; } else { /* 20 secs are enough? */ err = -ENOMEDIUM; break; } } if (!cgc->quiet) |
96eefad2d scsi: Implement s... |
233 234 235 236 |
sr_printk(KERN_INFO, cd, "CDROM not ready. Make sure there " "is a disc in the drive. "); |
1da177e4c Linux-2.6.12-rc2 |
237 238 239 240 |
err = -ENOMEDIUM; break; case ILLEGAL_REQUEST: err = -EIO; |
e7d0748dd block: Switch str... |
241 242 |
if (sshdr->asc == 0x20 && sshdr->ascq == 0x00) |
1da177e4c Linux-2.6.12-rc2 |
243 244 |
/* sense: Invalid command operation code */ err = -EDRIVE_CANT_DO_THIS; |
1da177e4c Linux-2.6.12-rc2 |
245 246 |
break; default: |
1da177e4c Linux-2.6.12-rc2 |
247 248 249 |
err = -EIO; } } |
1da177e4c Linux-2.6.12-rc2 |
250 |
/* Wake up a process waiting for device */ |
1da177e4c Linux-2.6.12-rc2 |
251 252 253 254 255 256 257 |
out: cgc->stat = err; return err; } /* ---------------------------------------------------------------------- */ /* interface to cdrom.c */ |
1da177e4c Linux-2.6.12-rc2 |
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
int sr_tray_move(struct cdrom_device_info *cdi, int pos) { Scsi_CD *cd = cdi->handle; struct packet_command cgc; memset(&cgc, 0, sizeof(struct packet_command)); cgc.cmd[0] = GPCMD_START_STOP_UNIT; cgc.cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ; cgc.data_direction = DMA_NONE; cgc.timeout = IOCTL_TIMEOUT; return sr_do_ioctl(cd, &cgc); } int sr_lock_door(struct cdrom_device_info *cdi, int lock) { Scsi_CD *cd = cdi->handle; return scsi_set_medium_removal(cd->device, lock ? SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW); } int sr_drive_status(struct cdrom_device_info *cdi, int slot) { |
210ba1d17 [SCSI] sr: update... |
281 282 283 |
struct scsi_cd *cd = cdi->handle; struct scsi_sense_hdr sshdr; struct media_event_desc med; |
1da177e4c Linux-2.6.12-rc2 |
284 285 286 287 |
if (CDSL_CURRENT != slot) { /* we have no changer support */ return -EINVAL; } |
9f8a2c23c scsi: replace sr_... |
288 |
if (!scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr)) |
1da177e4c Linux-2.6.12-rc2 |
289 |
return CDS_DISC_OK; |
96bcc722c [SCSI] sr: report... |
290 291 292 293 |
/* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */ if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY && sshdr.asc == 0x04 && sshdr.ascq == 0x01) return CDS_DRIVE_NOT_READY; |
210ba1d17 [SCSI] sr: update... |
294 295 296 297 298 299 300 301 302 303 |
if (!cdrom_get_media_event(cdi, &med)) { if (med.media_present) return CDS_DISC_OK; else if (med.door_open) return CDS_TRAY_OPEN; else return CDS_NO_DISC; } /* |
b84791789 [SCSI] sr: fix sr... |
304 305 306 307 308 309 310 311 312 |
* SK/ASC/ASCQ of 2/4/2 means "initialization required" * Using CD_TRAY_OPEN results in an START_STOP_UNIT to close * the tray, which resolves the initialization requirement. */ if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY && sshdr.asc == 0x04 && sshdr.ascq == 0x02) return CDS_TRAY_OPEN; /* |
210ba1d17 [SCSI] sr: update... |
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
* 0x04 is format in progress .. but there must be a disc present! */ if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04) return CDS_DISC_OK; /* * If not using Mt Fuji extended media tray reports, * just return TRAY_OPEN since ATAPI doesn't provide * any other way to detect this... */ if (scsi_sense_valid(&sshdr) && /* 0x3a is medium not present */ sshdr.asc == 0x3a) return CDS_NO_DISC; else return CDS_TRAY_OPEN; return CDS_DRIVE_NOT_READY; |
1da177e4c Linux-2.6.12-rc2 |
331 332 333 334 335 336 337 338 339 340 |
} int sr_disk_status(struct cdrom_device_info *cdi) { Scsi_CD *cd = cdi->handle; struct cdrom_tochdr toc_h; struct cdrom_tocentry toc_e; int i, rc, have_datatracks = 0; /* look for data tracks */ |
a09c63112 [SCSI] sr: split ... |
341 342 |
rc = sr_read_tochdr(cdi, &toc_h); if (rc) |
1da177e4c Linux-2.6.12-rc2 |
343 344 345 346 347 |
return (rc == -ENOMEDIUM) ? CDS_NO_DISC : CDS_NO_INFO; for (i = toc_h.cdth_trk0; i <= toc_h.cdth_trk1; i++) { toc_e.cdte_track = i; toc_e.cdte_format = CDROM_LBA; |
a09c63112 [SCSI] sr: split ... |
348 |
if (sr_read_tocentry(cdi, &toc_e)) |
1da177e4c Linux-2.6.12-rc2 |
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
return CDS_NO_INFO; if (toc_e.cdte_ctrl & CDROM_DATA_TRACK) { have_datatracks = 1; break; } } if (!have_datatracks) return CDS_AUDIO; if (cd->xa_flag) return CDS_XA_2_1; else return CDS_DATA_1; } int sr_get_last_session(struct cdrom_device_info *cdi, struct cdrom_multisession *ms_info) { Scsi_CD *cd = cdi->handle; ms_info->addr.lba = cd->ms_offset; ms_info->xa_flag = cd->xa_flag || cd->ms_offset > 0; return 0; } |
1da177e4c Linux-2.6.12-rc2 |
374 375 376 377 378 379 |
int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) { Scsi_CD *cd = cdi->handle; struct packet_command cgc; char *buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd)); int result; |
3a73e8c77 [SCSI] drivers/sc... |
380 381 |
if (!buffer) return -ENOMEM; |
1da177e4c Linux-2.6.12-rc2 |
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
memset(&cgc, 0, sizeof(struct packet_command)); cgc.cmd[0] = GPCMD_READ_SUBCHANNEL; cgc.cmd[2] = 0x40; /* I do want the subchannel info */ cgc.cmd[3] = 0x02; /* Give me medium catalog number info */ cgc.cmd[8] = 24; cgc.buffer = buffer; cgc.buflen = 24; cgc.data_direction = DMA_FROM_DEVICE; cgc.timeout = IOCTL_TIMEOUT; result = sr_do_ioctl(cd, &cgc); memcpy(mcn->medium_catalog_number, buffer + 9, 13); mcn->medium_catalog_number[13] = 0; kfree(buffer); return result; } int sr_reset(struct cdrom_device_info *cdi) { return 0; } int sr_select_speed(struct cdrom_device_info *cdi, int speed) { Scsi_CD *cd = cdi->handle; struct packet_command cgc; if (speed == 0) speed = 0xffff; /* set to max */ else speed *= 177; /* Nx to kbyte/s */ memset(&cgc, 0, sizeof(struct packet_command)); cgc.cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */ cgc.cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */ cgc.cmd[3] = speed & 0xff; /* LSB */ cgc.data_direction = DMA_NONE; cgc.timeout = IOCTL_TIMEOUT; if (sr_do_ioctl(cd, &cgc)) return -EIO; return 0; } /* ----------------------------------------------------------------------- */ /* this is called by the generic cdrom driver. arg is a _kernel_ pointer, */ /* because the generic cdrom driver does the user access stuff for us. */ /* only cdromreadtochdr and cdromreadtocentry are left - for use with the */ /* sr_disk_status interface for the generic cdrom driver. */ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) { |
1da177e4c Linux-2.6.12-rc2 |
435 436 |
switch (cmd) { case CDROMREADTOCHDR: |
a09c63112 [SCSI] sr: split ... |
437 |
return sr_read_tochdr(cdi, arg); |
1da177e4c Linux-2.6.12-rc2 |
438 |
case CDROMREADTOCENTRY: |
a09c63112 [SCSI] sr: split ... |
439 440 441 |
return sr_read_tocentry(cdi, arg); case CDROMPLAYTRKIND: return sr_play_trkind(cdi, arg); |
1da177e4c Linux-2.6.12-rc2 |
442 |
default: |
a09c63112 [SCSI] sr: split ... |
443 |
return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
444 |
} |
1da177e4c Linux-2.6.12-rc2 |
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
} /* ----------------------------------------------------------------------- * a function to read all sorts of funny cdrom sectors using the READ_CD * scsi-3 mmc command * * lba: linear block address * format: 0 = data (anything) * 1 = audio * 2 = data (mode 1) * 3 = data (mode 2) * 4 = data (mode 2 form1) * 5 = data (mode 2 form2) * blksize: 2048 | 2336 | 2340 | 2352 */ static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int blksize) { struct packet_command cgc; #ifdef DEBUG |
96eefad2d scsi: Implement s... |
466 467 468 |
sr_printk(KERN_INFO, cd, "sr_read_cd lba=%d format=%d blksize=%d ", lba, format, blksize); |
1da177e4c Linux-2.6.12-rc2 |
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
#endif memset(&cgc, 0, sizeof(struct packet_command)); cgc.cmd[0] = GPCMD_READ_CD; /* READ_CD */ cgc.cmd[1] = ((format & 7) << 2); cgc.cmd[2] = (unsigned char) (lba >> 24) & 0xff; cgc.cmd[3] = (unsigned char) (lba >> 16) & 0xff; cgc.cmd[4] = (unsigned char) (lba >> 8) & 0xff; cgc.cmd[5] = (unsigned char) lba & 0xff; cgc.cmd[8] = 1; switch (blksize) { case 2336: cgc.cmd[9] = 0x58; break; case 2340: cgc.cmd[9] = 0x78; break; case 2352: cgc.cmd[9] = 0xf8; break; default: cgc.cmd[9] = 0x10; break; } cgc.buffer = dest; cgc.buflen = blksize; cgc.data_direction = DMA_FROM_DEVICE; cgc.timeout = IOCTL_TIMEOUT; return sr_do_ioctl(cd, &cgc); } /* * read sectors with blocksizes other than 2048 */ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest) { struct packet_command cgc; int rc; /* we try the READ CD command first... */ if (cd->readcd_known) { rc = sr_read_cd(cd, dest, lba, 0, blksize); if (-EDRIVE_CANT_DO_THIS != rc) return rc; cd->readcd_known = 0; |
96eefad2d scsi: Implement s... |
515 516 517 |
sr_printk(KERN_INFO, cd, "CDROM does'nt support READ CD (0xbe) command "); |
1da177e4c Linux-2.6.12-rc2 |
518 519 520 521 522 523 524 525 |
/* fall & retry the other way */ } /* ... if this fails, we switch the blocksize using MODE SELECT */ if (blksize != cd->device->sector_size) { if (0 != (rc = sr_set_blocklength(cd, blksize))) return rc; } #ifdef DEBUG |
96eefad2d scsi: Implement s... |
526 527 528 |
sr_printk(KERN_INFO, cd, "sr_read_sector lba=%d blksize=%d ", lba, blksize); |
1da177e4c Linux-2.6.12-rc2 |
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
#endif memset(&cgc, 0, sizeof(struct packet_command)); cgc.cmd[0] = GPCMD_READ_10; cgc.cmd[2] = (unsigned char) (lba >> 24) & 0xff; cgc.cmd[3] = (unsigned char) (lba >> 16) & 0xff; cgc.cmd[4] = (unsigned char) (lba >> 8) & 0xff; cgc.cmd[5] = (unsigned char) lba & 0xff; cgc.cmd[8] = 1; cgc.buffer = dest; cgc.buflen = blksize; cgc.data_direction = DMA_FROM_DEVICE; cgc.timeout = IOCTL_TIMEOUT; rc = sr_do_ioctl(cd, &cgc); return rc; } /* * read a sector in raw mode to check the sector format * ret: 1 == mode2 (XA), 0 == mode1, <0 == error */ int sr_is_xa(Scsi_CD *cd) { unsigned char *raw_sector; int is_xa; if (!xa_test) return 0; |
5cbded585 [PATCH] getting r... |
559 |
raw_sector = kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd)); |
1da177e4c Linux-2.6.12-rc2 |
560 561 562 563 564 565 566 567 568 569 570 |
if (!raw_sector) return -ENOMEM; if (0 == sr_read_sector(cd, cd->ms_offset + 16, CD_FRAMESIZE_RAW1, raw_sector)) { is_xa = (raw_sector[3] == 0x02) ? 1 : 0; } else { /* read a raw sector failed for some reason. */ is_xa = -1; } kfree(raw_sector); #ifdef DEBUG |
96eefad2d scsi: Implement s... |
571 572 |
sr_printk(KERN_INFO, cd, "sr_is_xa: %d ", is_xa); |
1da177e4c Linux-2.6.12-rc2 |
573 574 575 |
#endif return is_xa; } |