• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asus-wl-520gu-7.0.1.45/src/linux/linux/drivers/ide/

Lines Matching defs:drive

64  *                        showed up if the drive returned data in 512 byte
86 * some drive not ready errors.
115 * 3.07a Feb 11, 1996 -- check drive->id for NULL before dereferencing, to fix
116 * problem with "hde=cdrom" with no drive present. -ml
153 * -- Add some probes of drive capability during setup.
163 * to fix the drive door locking problems.
169 * 4.05 Nov 20, 1997 -- Modified to print more drive info on init
227 * drive in transfer size limit.
272 * - Fixed a problem with WPI CDS-32X drive - it
326 static void cdrom_saw_media_change (ide_drive_t *drive)
328 struct cdrom_info *info = drive->driver_data;
330 CDROM_STATE_FLAGS (drive)->media_changed = 1;
331 CDROM_STATE_FLAGS (drive)->toc_valid = 0;
335 static int cdrom_log_sense(ide_drive_t *drive, struct packet_command *pc,
362 cdrom_saw_media_change(drive);
372 void cdrom_analyze_sense_data(ide_drive_t *drive,
377 if (!cdrom_log_sense(drive, failed_command, sense))
395 printk ("ATAPI device %s:\n", drive->name);
475 * In the case of NOT_READY, if SKSV is set the drive can
509 drive->name,
515 static void cdrom_queue_request_sense(ide_drive_t *drive,
520 struct cdrom_info *info = drive->driver_data;
539 (void) ide_do_drive_cmd(drive, rq, ide_preempt);
543 static void cdrom_end_request (int uptodate, ide_drive_t *drive)
545 struct request *rq = HWGROUP(drive)->rq;
549 cdrom_analyze_sense_data(drive,
557 ide_end_request (uptodate, HWGROUP(drive));
563 static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
566 struct request *rq = HWGROUP(drive)->rq;
582 printk("%s: missing rq in cdrom_decode_status\n", drive->name);
589 from the drive (probably while trying
594 cdrom_end_request (1, drive);
595 *startstop = ide_error (drive, "request sense failure", stat);
605 cdrom_saw_media_change (drive);
608 cdrom_saw_media_change (drive);
609 /*printk("%s: media changed\n",drive->name);*/
613 ide_dump_status(drive, "packet command error", stat);
631 cdrom_end_request (1, drive);
634 cdrom_queue_request_sense(drive, wait, pc->sense, pc);
640 cdrom_saw_media_change (drive);
643 printk ("%s: tray open\n", drive->name);
644 cdrom_end_request (0, drive);
647 cdrom_saw_media_change (drive);
653 cdrom_end_request (0, drive);
658 ide_dump_status (drive, "command error", stat);
659 cdrom_end_request (0, drive);
663 *startstop = ide_error (drive, "cdrom_decode_status", stat);
667 cdrom_end_request (0, drive);
673 cdrom_queue_request_sense(drive, NULL, NULL, NULL);
681 static int cdrom_timer_expiry(ide_drive_t *drive)
683 struct request *rq = HWGROUP(drive)->rq;
708 which actually transfers the command to the drive. If this is a
710 called when the interrupt from the drive arrives. Otherwise, HANDLER
711 will be called immediately after the drive is prepared for the transfer. */
713 static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
718 struct cdrom_info *info = drive->driver_data;
721 if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY))
726 info->dma = !HWIF(drive)->dmaproc(ide_dma_read, drive);
728 info->dma = !HWIF(drive)->dmaproc(ide_dma_write, drive);
742 OUT_BYTE (drive->ctl, IDE_CONTROL_REG);
745 (void) (HWIF(drive)->dmaproc(ide_dma_begin, drive));
747 if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
748 ide_set_handler (drive, handler, WAIT_CMD, cdrom_timer_expiry);
753 return (*handler) (drive);
766 static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
775 if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
781 if (cdrom_decode_status (&startstop, drive, DRQ_STAT, &stat_dum))
785 if (ide_wait_stat (&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY))
790 ide_set_handler (drive, handler, timeout, cdrom_timer_expiry);
793 atapi_output_bytes (drive, cmd_buf, cmd_len);
802 * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
808 static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
811 struct cdrom_info *info = drive->driver_data;
831 atapi_input_bytes (drive, dest, SECTOR_SIZE);
841 atapi_input_bytes (drive, dum, sizeof (dum));
852 int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
858 /* Whoops... The drive is expecting to receive data from us! */
861 drive->name);
863 /* Throw some data at the drive so it doesn't hang
867 atapi_output_bytes (drive, &dum, sizeof (dum));
879 drive->name, ireason);
882 cdrom_end_request (0, drive);
889 static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
893 struct cdrom_info *info = drive->driver_data;
897 struct request *rq = HWGROUP(drive)->rq;
902 if ((dma_error = HWIF(drive)->dmaproc(ide_dma_end, drive)))
903 HWIF(drive)->dmaproc(ide_dma_off, drive);
906 if (cdrom_decode_status (&startstop, drive, 0, &stat))
913 ide_end_request(1, HWGROUP(drive));
917 return ide_error (drive, "dma error", stat);
930 drive->name, rq->current_nr_sectors);
931 cdrom_end_request (0, drive);
933 cdrom_end_request (1, drive);
937 /* Check that the drive is expecting to do the same thing we are. */
938 if (cdrom_read_check_ireason (drive, len, ireason))
941 /* Assume that the drive will always provide data in multiples
946 drive->name, len);
947 if (CDROM_CONFIG_FLAGS (drive)->limit_nframes)
948 printk (" This drive is not supported by this version of the driver\n");
951 CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
953 cdrom_end_request (0, drive);
957 /* The number of sectors we need to read from the drive. */
968 atapi_input_bytes (drive, dum, sizeof (dum));
975 /* Now loop while we still have data to read from the drive. */
982 cdrom_end_request (1, drive);
987 cdrom_buffer_sectors(drive, rq->sector, sectors_to_transfer);
999 atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE);
1012 ide_set_handler(drive, &cdrom_read_intr, WAIT_CMD, NULL);
1020 static int cdrom_read_from_buffer (ide_drive_t *drive)
1022 struct cdrom_info *info = drive->driver_data;
1023 struct request *rq = HWGROUP(drive)->rq;
1034 cdrom_end_request (1, drive);
1049 cdrom_end_request (1, drive);
1055 cdrom_end_request (1, drive);
1064 drive->name, rq->sector);
1065 cdrom_end_request (0, drive);
1073 * Routine to send a read packet command to the drive.
1076 * when the drive is ready to accept the command.
1078 static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive)
1081 struct request *rq = HWGROUP(drive)->rq;
1103 drive->name, rq->current_nr_sectors);
1104 cdrom_end_request (0, drive);
1119 nframes = MIN (nframes, (CDROM_CONFIG_FLAGS (drive)->limit_nframes) ?
1130 /* Send the command to the drive and return. */
1131 return cdrom_transfer_packet_command(drive, &pc, &cdrom_read_intr);
1139 static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
1141 struct cdrom_info *info = drive->driver_data;
1146 if (cdrom_decode_status (&startstop, drive, 0, &stat))
1148 CDROM_CONFIG_FLAGS(drive)->seeking = 1;
1156 drive->dsc_overlap = 0;
1162 static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
1165 struct request *rq = HWGROUP(drive)->rq;
1179 return cdrom_transfer_packet_command(drive, &pc, &cdrom_seek_intr);
1182 static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
1184 struct cdrom_info *info = drive->driver_data;
1189 return cdrom_start_packet_command (drive, 0, cdrom_start_seek_continuation);
1215 static void cdrom_attempt_remerge(ide_drive_t *drive, struct request *rq)
1225 if (entry == &drive->queue.queue_head)
1259 static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
1261 struct cdrom_info *info = drive->driver_data;
1262 struct request *rq = HWGROUP(drive)->rq;
1278 if (cdrom_read_from_buffer(drive))
1281 cdrom_attempt_remerge(drive, rq);
1287 if (drive->using_dma && (rq->sector % SECTORS_PER_FRAME == 0) &&
1294 /* Start sending the read request to the drive. */
1295 return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation);
1303 static int cdrom_lockdoor(ide_drive_t *drive, int lockflag,
1307 static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
1310 struct request *rq = HWGROUP(drive)->rq;
1315 if (cdrom_decode_status (&startstop, drive, 0, &stat))
1337 cdrom_end_request (1, drive);
1344 drive->name, pc->buflen);
1347 cdrom_end_request (1, drive);
1356 /* The drive wants to be written to. */
1359 atapi_output_bytes (drive, pc->buffer, thislen);
1361 /* If we haven't moved enough data to satisfy the drive,
1365 atapi_output_bytes (drive, &dum, sizeof (dum));
1378 atapi_input_bytes (drive, pc->buffer, thislen);
1380 /* If we haven't moved enough data to satisfy the drive,
1384 atapi_input_bytes (drive, &dum, sizeof (dum));
1392 printk ("%s: cdrom_pc_intr: The drive "
1394 drive->name, ireason);
1399 ide_set_handler (drive, &cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry);
1404 static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive)
1406 struct request *rq = HWGROUP(drive)->rq;
1412 /* Send the command to the drive and return. */
1413 return cdrom_transfer_packet_command(drive, pc, &cdrom_pc_intr);
1417 static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
1420 struct request *rq = HWGROUP(drive)->rq;
1422 struct cdrom_info *info = drive->driver_data;
1429 /* Start sending the command to the drive. */
1430 return cdrom_start_packet_command (drive, len, cdrom_do_pc_continuation);
1448 int cdrom_queue_packet_command(ide_drive_t *drive, struct packet_command *pc)
1462 ide_do_drive_cmd (drive, &req, ide_wait);
1470 cdrom_saw_media_change (drive);
1473 /* The drive is in the process of loading
1475 the drive time to complete the load. */
1494 static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason)
1497 * the drive wants to receive data from us, 2 means that
1498 * the drive is expecting data from us.
1503 /* Whoops... The drive wants to send data. */
1505 drive->name);
1507 /* Throw some data at the drive so it doesn't hang
1511 atapi_output_bytes(drive, &dum, sizeof(dum));
1517 drive->name, ireason);
1520 cdrom_end_request(0, drive);
1524 static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
1527 struct cdrom_info *info = drive->driver_data;
1531 struct request *rq = HWGROUP(drive)->rq;
1536 if ((dma_error = HWIF(drive)->dmaproc(ide_dma_end, drive))) {
1538 HWIF(drive)->dmaproc(ide_dma_off, drive);
1542 if (cdrom_decode_status(&startstop, drive, 0, &stat)) {
1552 return ide_error(drive, "dma error", stat);
1554 rq = HWGROUP(drive)->rq;
1557 ide_end_request(1, HWGROUP(drive));
1574 drive->name, rq->current_nr_sectors);
1577 cdrom_end_request(uptodate, drive);
1581 /* Check that the drive is expecting to do the same thing we are. */
1583 if (cdrom_write_check_ireason(drive, len, ireason))
1605 atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE);
1618 cdrom_end_request (1, drive);
1622 ide_set_handler(drive, &cdrom_write_intr, 5 * WAIT_CMD, NULL);
1626 static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive)
1629 struct request *rq = HWGROUP(drive)->rq;
1646 return cdrom_transfer_packet_command(drive, &pc, cdrom_write_intr);
1649 static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
1651 struct cdrom_info *info = drive->driver_data;
1657 cdrom_end_request(0, drive);
1667 cdrom_attempt_remerge(drive, rq);
1673 info->dma = drive->using_dma ? 1 : 0;
1676 /* Start sending the read request to the drive. */
1677 return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont);
1684 ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, unsigned long block)
1687 struct cdrom_info *info = drive->driver_data;
1692 if (CDROM_CONFIG_FLAGS(drive)->seeking) {
1698 ide_stall_queue(drive, IDECD_SEEK_TIMER);
1701 printk ("%s: DSC timeout\n", drive->name);
1703 CDROM_CONFIG_FLAGS(drive)->seeking = 0;
1705 if (IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap)
1706 action = cdrom_start_seek (drive, block);
1709 action = cdrom_start_read(drive, block);
1711 action = cdrom_start_write(drive, rq);
1719 return cdrom_do_packet_command(drive);
1723 cdrom_end_request(1, drive);
1724 return ide_do_reset(drive);
1729 cdrom_end_request(0, drive);
1790 static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
1793 struct cdrom_info *info = drive->driver_data;
1808 return cdrom_queue_packet_command(drive, &pc);
1814 cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense)
1823 /* If the drive cannot lock the door, just pretend. */
1824 if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) {
1831 stat = cdrom_queue_packet_command (drive, &pc);
1834 /* If we got an illegal field error, the drive
1840 drive->name);
1841 CDROM_CONFIG_FLAGS (drive)->no_doorlock = 1;
1850 CDROM_STATE_FLAGS (drive)->door_locked = lockflag;
1858 static int cdrom_eject(ide_drive_t *drive, int ejectflag,
1863 if (CDROM_CONFIG_FLAGS(drive)->no_eject && !ejectflag)
1867 if (CDROM_STATE_FLAGS(drive)->door_locked && ejectflag)
1875 return cdrom_queue_packet_command (drive, &pc);
1878 static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1896 stat = cdrom_queue_packet_command(drive, &pc);
1903 static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
1924 return cdrom_queue_packet_command (drive, &pc);
1929 static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
1933 struct cdrom_info *info = drive->driver_data;
1946 printk ("%s: No cdrom TOC buffer!\n", drive->name);
1953 (void) cdrom_check_status(drive, sense);
1955 if (CDROM_STATE_FLAGS(drive)->toc_valid)
1959 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
1964 if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd) {
1977 stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0,
1994 stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0,
2004 if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd) {
2021 if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd) {
2029 if (CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd) {
2030 if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd)
2043 stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,
2054 if (CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd)
2065 minor = (drive->select.b.unit) << PARTN_BITS;
2066 dev = MKDEV(HWIF(drive)->major, minor);
2069 stat = cdrom_read_capacity(drive, &toc->capacity, sense);
2073 HWIF(drive)->gd->sizes[drive->select.b.unit << PARTN_BITS] = (toc->capacity * SECTORS_PER_FRAME) >> (BLOCK_SIZE_BITS - 9);
2074 drive->part[0].nr_sects = toc->capacity * SECTORS_PER_FRAME;
2077 CDROM_STATE_FLAGS (drive)->toc_valid = 1;
2083 static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
2099 return cdrom_queue_packet_command(drive, &pc);
2104 static int cdrom_select_speed(ide_drive_t *drive, int speed,
2121 if (CDROM_CONFIG_FLAGS(drive)->cd_r ||
2122 CDROM_CONFIG_FLAGS(drive)->cd_rw ||
2123 CDROM_CONFIG_FLAGS(drive)->dvd_r) {
2130 return cdrom_queue_packet_command(drive, &pc);
2133 static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end)
2145 return cdrom_queue_packet_command(drive, &pc);
2148 static int cdrom_get_toc_entry(ide_drive_t *drive, int track,
2151 struct cdrom_info *info = drive->driver_data;
2158 if (!CDROM_STATE_FLAGS(drive)->toc_valid)
2180 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2197 return cgc->stat = cdrom_queue_packet_command(drive, &pc);
2251 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2252 struct cdrom_info *info = drive->driver_data;
2265 stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc);
2269 stat = cdrom_get_toc_entry(drive, ti->cdti_trk1, &last_toc);
2281 return cdrom_play_audio(drive, lba_start, lba_end);
2289 stat = cdrom_read_toc(drive, NULL);
2303 stat = cdrom_get_toc_entry (drive, tocentry->cdte_track, &toce);
2327 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2334 ret = ide_do_drive_cmd(drive, &req, ide_wait);
2340 if (CDROM_STATE_FLAGS(drive)->door_locked)
2341 (void) cdrom_lockdoor(drive, 1, &sense);
2350 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2354 int stat = cdrom_lockdoor(drive, 0, &sense);
2358 return cdrom_eject(drive, !position, &sense);
2364 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2365 return cdrom_lockdoor(drive, lock, NULL);
2371 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2375 if ((stat = cdrom_select_speed (drive, speed, &sense)) < 0)
2378 cdi->speed = CDROM_STATE_FLAGS (drive)->current_speed;
2385 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2389 int stat = cdrom_check_status(drive, &sense);
2420 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2421 struct cdrom_info *info = drive->driver_data;
2425 if (!CDROM_STATE_FLAGS(drive)->toc_valid || info->toc == NULL)
2426 if ((ret = cdrom_read_toc(drive, &sense)))
2442 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2445 if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL)))
2466 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2470 (void) cdrom_check_status(drive, NULL);
2471 retval = CDROM_STATE_FLAGS (drive)->media_changed;
2472 CDROM_STATE_FLAGS (drive)->media_changed = 0;
2524 static int ide_cdrom_register (ide_drive_t *drive, int nslots)
2526 struct cdrom_info *info = drive->driver_data;
2528 int minor = (drive->select.b.unit) << PARTN_BITS;
2530 devinfo->dev = MKDEV (HWIF(drive)->major, minor);
2533 devinfo->speed = CDROM_STATE_FLAGS (drive)->current_speed;
2535 devinfo->handle = (void *) drive;
2536 strcpy(devinfo->name, drive->name);
2539 if (!CDROM_CONFIG_FLAGS (drive)->cd_r)
2541 if (!CDROM_CONFIG_FLAGS (drive)->cd_rw)
2543 if (!CDROM_CONFIG_FLAGS (drive)->dvd)
2545 if (!CDROM_CONFIG_FLAGS (drive)->dvd_r)
2547 if (!CDROM_CONFIG_FLAGS (drive)->dvd_ram)
2549 if (!CDROM_CONFIG_FLAGS (drive)->is_changer)
2551 if (!CDROM_CONFIG_FLAGS (drive)->audio_play)
2553 if (!CDROM_CONFIG_FLAGS (drive)->close_tray)
2556 devinfo->de = devfs_register(drive->de, "cd", DEVFS_FL_DEFAULT,
2557 HWIF(drive)->major, minor,
2565 int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap)
2567 struct cdrom_info *info = drive->driver_data;
2576 if (drive->id) {
2577 if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") ||
2578 !strcmp(drive->id->model, "WPI CDS-32X")))
2584 * drive from cdi->handle. Since this device hasn't been
2588 cdi->handle = (ide_drive_t *) drive;
2600 int ide_cdrom_probe_capabilities (ide_drive_t *drive)
2602 struct cdrom_info *info = drive->driver_data;
2607 if (CDROM_CONFIG_FLAGS (drive)->nec260) {
2608 CDROM_CONFIG_FLAGS (drive)->no_eject = 0;
2609 CDROM_CONFIG_FLAGS (drive)->audio_play = 1;
2613 if (ide_cdrom_get_capabilities(drive, &cap))
2617 CDROM_CONFIG_FLAGS (drive)->no_doorlock = 1;
2619 CDROM_CONFIG_FLAGS (drive)->no_eject = 0;
2621 CDROM_CONFIG_FLAGS (drive)->cd_r = 1;
2623 CDROM_CONFIG_FLAGS (drive)->cd_rw = 1;
2625 CDROM_CONFIG_FLAGS (drive)->test_write = 1;
2627 CDROM_CONFIG_FLAGS (drive)->dvd = 1;
2629 CDROM_CONFIG_FLAGS (drive)->dvd_ram = 1;
2631 CDROM_CONFIG_FLAGS (drive)->dvd_r = 1;
2633 CDROM_CONFIG_FLAGS (drive)->audio_play = 1;
2635 CDROM_CONFIG_FLAGS (drive)->close_tray = 0;
2640 if (strcmp (drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
2641 strcmp (drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
2642 strcmp (drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
2643 strcmp (drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
2644 CDROM_CONFIG_FLAGS (drive)->audio_play = 1;
2648 CDROM_CONFIG_FLAGS (drive)->is_changer = 1;
2657 CDROM_CONFIG_FLAGS (drive)->is_changer = 1;
2658 CDROM_CONFIG_FLAGS (drive)->supp_disc_present = 1;
2663 if (drive->id && !drive->id->model[0] && !strncmp(drive->id->fw_rev, "241N", 4)) {
2664 CDROM_STATE_FLAGS (drive)->current_speed =
2666 CDROM_CONFIG_FLAGS (drive)->max_speed =
2669 CDROM_STATE_FLAGS (drive)->current_speed =
2671 CDROM_CONFIG_FLAGS (drive)->max_speed =
2675 /* don't print speed if the drive reported 0.
2677 printk("%s: ATAPI", drive->name);
2678 if (CDROM_CONFIG_FLAGS(drive)->max_speed)
2679 printk(" %dX", CDROM_CONFIG_FLAGS(drive)->max_speed);
2680 printk(" %s", CDROM_CONFIG_FLAGS(drive)->dvd ? "DVD-ROM" : "CD-ROM");
2682 if (CDROM_CONFIG_FLAGS (drive)->dvd_r|CDROM_CONFIG_FLAGS (drive)->dvd_ram)
2684 (CDROM_CONFIG_FLAGS (drive)->dvd_r)? "-R" : "",
2685 (CDROM_CONFIG_FLAGS (drive)->dvd_ram)? "-RAM" : "");
2687 if (CDROM_CONFIG_FLAGS (drive)->cd_r|CDROM_CONFIG_FLAGS (drive)->cd_rw)
2689 (CDROM_CONFIG_FLAGS (drive)->cd_r)? "-R" : "",
2690 (CDROM_CONFIG_FLAGS (drive)->cd_rw)? "/RW" : "");
2692 if (CDROM_CONFIG_FLAGS (drive)->is_changer)
2695 printk (" drive");
2700 if (drive->using_dma)
2701 (void) HWIF(drive)->dmaproc(ide_dma_verbose, drive);
2708 static void ide_cdrom_add_settings(ide_drive_t *drive)
2710 int major = HWIF(drive)->major;
2711 int minor = drive->select.b.unit << PARTN_BITS;
2713 ide_add_setting(drive, "breada_readahead", SETTING_RW, BLKRAGET, BLKRASET, TYPE_INT, 0, 255, 1, 2, &read_ahead[major], NULL);
2714 ide_add_setting(drive, "file_readahead", SETTING_RW, BLKFRAGET, BLKFRASET, TYPE_INTA, 0, INT_MAX, 1, 1024, &max_readahead[major][minor], NULL);
2715 ide_add_setting(drive, "max_kb_per_request", SETTING_RW, BLKSECTGET, BLKSECTSET, TYPE_INTA, 1, 255, 1, 2, &max_sectors[major][minor], NULL);
2716 ide_add_setting(drive, "dsc_overlap", SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
2720 int ide_cdrom_setup (ide_drive_t *drive)
2722 struct cdrom_info *info = drive->driver_data;
2724 int minor = drive->select.b.unit << PARTN_BITS;
2730 set_device_ro(MKDEV(HWIF(drive)->major, minor), 1);
2731 set_blocksize(MKDEV(HWIF(drive)->major, minor), CD_FRAMESIZE);
2733 drive->special.all = 0;
2734 drive->ready_stat = 0;
2736 CDROM_STATE_FLAGS (drive)->media_changed = 1;
2737 CDROM_STATE_FLAGS (drive)->toc_valid = 0;
2738 CDROM_STATE_FLAGS (drive)->door_locked = 0;
2741 CDROM_CONFIG_FLAGS (drive)->no_doorlock = 1;
2743 CDROM_CONFIG_FLAGS (drive)->no_doorlock = 0;
2746 if (drive->id != NULL)
2747 CDROM_CONFIG_FLAGS (drive)->drq_interrupt =
2748 ((drive->id->config & 0x0060) == 0x20);
2750 CDROM_CONFIG_FLAGS (drive)->drq_interrupt = 0;
2752 CDROM_CONFIG_FLAGS (drive)->is_changer = 0;
2753 CDROM_CONFIG_FLAGS (drive)->cd_r = 0;
2754 CDROM_CONFIG_FLAGS (drive)->cd_rw = 0;
2755 CDROM_CONFIG_FLAGS (drive)->test_write = 0;
2756 CDROM_CONFIG_FLAGS (drive)->dvd = 0;
2757 CDROM_CONFIG_FLAGS (drive)->dvd_r = 0;
2758 CDROM_CONFIG_FLAGS (drive)->dvd_ram = 0;
2759 CDROM_CONFIG_FLAGS (drive)->no_eject = 1;
2760 CDROM_CONFIG_FLAGS (drive)->supp_disc_present = 0;
2761 CDROM_CONFIG_FLAGS (drive)->audio_play = 0;
2762 CDROM_CONFIG_FLAGS (drive)->close_tray = 1;
2765 CDROM_CONFIG_FLAGS (drive)->limit_nframes = 0;
2766 if (drive->id != NULL) {
2768 if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430"))
2769 CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
2770 else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432"))
2771 CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
2773 else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231"))
2782 CDROM_CONFIG_FLAGS (drive)->nec260 = 0;
2783 CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 0;
2784 CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 0;
2785 CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 0;
2786 CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 0;
2788 if (drive->id != NULL) {
2789 if (strcmp (drive->id->model, "V003S0DS") == 0 &&
2790 drive->id->fw_rev[4] == '1' &&
2791 drive->id->fw_rev[6] <= '2') {
2793 Some versions of this drive like to talk BCD. */
2794 CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 1;
2795 CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 1;
2796 CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
2797 CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1;
2800 else if (strcmp (drive->id->model, "V006E0DS") == 0 &&
2801 drive->id->fw_rev[4] == '1' &&
2802 drive->id->fw_rev[6] <= '2') {
2804 CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 1;
2807 else if (strcmp (drive->id->model,
2809 strncmp (drive->id->fw_rev, "1.01", 4) == 0) {
2811 This drive was released before the 1.2 version
2813 CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 1;
2814 CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
2815 CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1;
2816 CDROM_CONFIG_FLAGS (drive)->nec260 = 1;
2819 else if (strcmp (drive->id->model, "WEARNES CDD-120") == 0 &&
2820 strncmp (drive->id->fw_rev, "A1.1", 4) == 0) {
2822 CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
2823 CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1;
2828 else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) ||
2829 (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) ||
2830 (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) {
2847 nslots = ide_cdrom_probe_capabilities (drive);
2849 if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
2850 set_device_ro(MKDEV(HWIF(drive)->major, minor), 0);
2852 if (ide_cdrom_register (drive, nslots)) {
2853 printk ("%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
2857 ide_cdrom_add_settings(drive);
2863 int ide_cdrom_ioctl (ide_drive_t *drive,
2871 int ide_cdrom_open (struct inode *ip, struct file *fp, ide_drive_t *drive)
2873 struct cdrom_info *info = drive->driver_data;
2880 drive->usage--;
2888 ide_drive_t *drive)
2895 int ide_cdrom_check_media_change (ide_drive_t *drive)
2897 return cdrom_media_changed(MKDEV (HWIF (drive)->major,
2898 (drive->select.b.unit) << PARTN_BITS));
2902 void ide_cdrom_revalidate (ide_drive_t *drive)
2904 struct cdrom_info *info = drive->driver_data;
2906 int minor = drive->select.b.unit << PARTN_BITS;
2909 cdrom_read_toc(drive, &sense);
2911 if (!CDROM_STATE_FLAGS(drive)->toc_valid)
2917 drive->part[0].nr_sects = toc->capacity * SECTORS_PER_FRAME;
2918 HWIF(drive)->gd->sizes[minor] = toc->capacity * BLOCKS_PER_FRAME;
2924 blk_size[HWIF(drive)->major] = HWIF(drive)->gd->sizes;
2925 set_blocksize(MKDEV(HWIF(drive)->major, minor), CD_FRAMESIZE);
2929 unsigned long ide_cdrom_capacity (ide_drive_t *drive)
2933 if (cdrom_read_capacity(drive, &capacity, NULL))
2940 int ide_cdrom_cleanup(ide_drive_t *drive)
2942 struct cdrom_info *info = drive->driver_data;
2945 if (ide_unregister_subdriver (drive))
2953 if (devinfo->handle == drive && unregister_cdrom (devinfo))
2954 printk ("%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
2956 drive->driver_data = NULL;
2960 int ide_cdrom_reinit (ide_drive_t *drive);
3002 int ide_cdrom_reinit (ide_drive_t *drive)
3010 printk ("%s: Can't allocate a cdrom structure\n", drive->name);
3013 if (ide_register_subdriver (drive, &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) {
3014 printk ("%s: Failed to register the driver with ide.c\n", drive->name);
3019 drive->driver_data = info;
3020 DRIVER(drive)->busy++;
3021 if (ide_cdrom_setup (drive)) {
3022 DRIVER(drive)->busy--;
3023 if (ide_cdrom_cleanup (drive))
3024 printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
3027 DRIVER(drive)->busy--;
3037 ide_drive_t *drive;
3040 while ((drive = ide_scan_devices (ide_cdrom, ide_cdrom_driver.name, &ide_cdrom_driver, failed)) != NULL)
3041 if (ide_cdrom_cleanup (drive)) {
3042 printk ("%s: cleanup_module() called while still busy\n", drive->name);
3050 ide_drive_t *drive;
3055 while ((drive = ide_scan_devices (ide_cdrom, ide_cdrom_driver.name, NULL, failed++)) != NULL) {
3058 if (strstr(ignore, drive->name)) {
3059 printk("ide-cd: ignoring drive %s\n", drive->name);
3063 if (drive->scsi) {
3064 printk("ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
3069 printk ("%s: Can't allocate a cdrom structure\n", drive->name);
3072 if (ide_register_subdriver (drive, &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) {
3073 printk ("%s: Failed to register the driver with ide.c\n", drive->name);
3078 drive->driver_data = info;
3079 DRIVER(drive)->busy++;
3080 if (ide_cdrom_setup (drive)) {
3081 DRIVER(drive)->busy--;
3082 if (ide_cdrom_cleanup (drive))
3083 printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
3086 DRIVER(drive)->busy--;