Lines Matching refs:cdi
324 #define CDROM_CAN(type) (cdi->ops->capability & ~cdi->mask & (type))
338 static void signal_media_change(struct cdrom_device_info *cdi) in signal_media_change() argument
340 cdi->mc_flags = 0x3; /* set media changed bits, on both queues */ in signal_media_change()
341 cdi->last_media_change_ms = ktime_to_ms(ktime_get()); in signal_media_change()
344 int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi, in cdrom_dummy_generic_packet() argument
358 static int cdrom_flush_cache(struct cdrom_device_info *cdi) in cdrom_flush_cache() argument
367 return cdi->ops->generic_packet(cdi, &cgc); in cdrom_flush_cache()
371 static int cdrom_get_disc_info(struct cdrom_device_info *cdi, in cdrom_get_disc_info() argument
374 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_get_disc_info()
384 ret = cdo->generic_packet(cdi, &cgc); in cdrom_get_disc_info()
398 ret = cdo->generic_packet(cdi, &cgc); in cdrom_get_disc_info()
421 static int cdrom_mrw_probe_pc(struct cdrom_device_info *cdi) in cdrom_mrw_probe_pc() argument
431 if (!cdrom_mode_sense(cdi, &cgc, MRW_MODE_PC, 0)) { in cdrom_mrw_probe_pc()
432 cdi->mrw_mode_page = MRW_MODE_PC; in cdrom_mrw_probe_pc()
434 } else if (!cdrom_mode_sense(cdi, &cgc, MRW_MODE_PC_PRE1, 0)) { in cdrom_mrw_probe_pc()
435 cdi->mrw_mode_page = MRW_MODE_PC_PRE1; in cdrom_mrw_probe_pc()
442 static int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write) in cdrom_is_mrw() argument
458 if ((ret = cdi->ops->generic_packet(cdi, &cgc))) in cdrom_is_mrw()
466 if ((ret = cdrom_mrw_probe_pc(cdi))) { in cdrom_is_mrw()
474 static int cdrom_mrw_bgformat(struct cdrom_device_info *cdi, int cont) in cdrom_mrw_bgformat() argument
508 ret = cdi->ops->generic_packet(cdi, &cgc); in cdrom_mrw_bgformat()
515 static int cdrom_mrw_bgformat_susp(struct cdrom_device_info *cdi, int immed) in cdrom_mrw_bgformat_susp() argument
530 return cdi->ops->generic_packet(cdi, &cgc); in cdrom_mrw_bgformat_susp()
533 static int cdrom_mrw_exit(struct cdrom_device_info *cdi) in cdrom_mrw_exit() argument
538 ret = cdrom_get_disc_info(cdi, &di); in cdrom_mrw_exit()
545 ret = cdrom_mrw_bgformat_susp(cdi, 0); in cdrom_mrw_exit()
548 if (!ret && cdi->media_written) in cdrom_mrw_exit()
549 ret = cdrom_flush_cache(cdi); in cdrom_mrw_exit()
554 static int cdrom_mrw_set_lba_space(struct cdrom_device_info *cdi, int space) in cdrom_mrw_set_lba_space() argument
566 ret = cdrom_mode_sense(cdi, &cgc, cdi->mrw_mode_page, 0); in cdrom_mrw_set_lba_space()
577 ret = cdrom_mode_select(cdi, &cgc); in cdrom_mrw_set_lba_space()
582 cdi->name, mrw_address_space[space]); in cdrom_mrw_set_lba_space()
586 int register_cdrom(struct gendisk *disk, struct cdrom_device_info *cdi) in register_cdrom() argument
589 const struct cdrom_device_ops *cdo = cdi->ops; in register_cdrom()
601 cdi->disk = disk; in register_cdrom()
602 disk->cdi = cdi; in register_cdrom()
614 cdi->mc_flags = 0; in register_cdrom()
615 cdi->options = CDO_USE_FFLAGS; in register_cdrom()
616 cdi->last_media_change_ms = ktime_to_ms(ktime_get()); in register_cdrom()
619 cdi->options |= (int) CDO_AUTO_CLOSE; in register_cdrom()
621 cdi->options |= (int) CDO_AUTO_EJECT; in register_cdrom()
623 cdi->options |= (int) CDO_LOCK; in register_cdrom()
625 cdi->options |= (int) CDO_CHECK_TYPE; in register_cdrom()
628 cdi->exit = cdrom_mrw_exit; in register_cdrom()
630 if (cdi->ops->read_cdda_bpc) in register_cdrom()
631 cdi->cdda_method = CDDA_BPC_FULL; in register_cdrom()
633 cdi->cdda_method = CDDA_OLD; in register_cdrom()
637 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); in register_cdrom()
639 list_add(&cdi->list, &cdrom_list); in register_cdrom()
646 void unregister_cdrom(struct cdrom_device_info *cdi) in unregister_cdrom() argument
651 list_del(&cdi->list); in unregister_cdrom()
654 if (cdi->exit) in unregister_cdrom()
655 cdi->exit(cdi); in unregister_cdrom()
657 cd_dbg(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name); in unregister_cdrom()
661 int cdrom_get_media_event(struct cdrom_device_info *cdi, in cdrom_get_media_event() argument
675 if (cdi->ops->generic_packet(cdi, &cgc)) in cdrom_get_media_event()
689 static int cdrom_get_random_writable(struct cdrom_device_info *cdi, in cdrom_get_random_writable() argument
703 if ((ret = cdi->ops->generic_packet(cdi, &cgc))) in cdrom_get_random_writable()
710 static int cdrom_has_defect_mgt(struct cdrom_device_info *cdi) in cdrom_has_defect_mgt() argument
724 if ((ret = cdi->ops->generic_packet(cdi, &cgc))) in cdrom_has_defect_mgt()
735 static int cdrom_is_random_writable(struct cdrom_device_info *cdi, int *write) in cdrom_is_random_writable() argument
742 if ((ret = cdrom_get_random_writable(cdi, &rfd))) in cdrom_is_random_writable()
751 static int cdrom_media_erasable(struct cdrom_device_info *cdi) in cdrom_media_erasable() argument
756 ret = cdrom_get_disc_info(cdi, &di); in cdrom_media_erasable()
766 static int cdrom_dvdram_open_write(struct cdrom_device_info *cdi) in cdrom_dvdram_open_write() argument
768 int ret = cdrom_media_erasable(cdi); in cdrom_dvdram_open_write()
780 static int cdrom_mrw_open_write(struct cdrom_device_info *cdi) in cdrom_mrw_open_write() argument
788 if (cdrom_mrw_set_lba_space(cdi, MRW_LBA_DMA)) { in cdrom_mrw_open_write()
793 ret = cdrom_get_disc_info(cdi, &di); in cdrom_mrw_open_write()
813 ret = cdrom_mrw_bgformat(cdi, 1); in cdrom_mrw_open_write()
818 static int mo_open_write(struct cdrom_device_info *cdi) in mo_open_write() argument
832 ret = cdrom_mode_sense(cdi, &cgc, GPMODE_ALL_PAGES, 0); in mo_open_write()
834 ret = cdrom_mode_sense(cdi, &cgc, GPMODE_VENDOR_PAGE, 0); in mo_open_write()
837 ret = cdrom_mode_sense(cdi, &cgc, GPMODE_ALL_PAGES, 0); in mo_open_write()
847 static int cdrom_ram_open_write(struct cdrom_device_info *cdi) in cdrom_ram_open_write() argument
852 if ((ret = cdrom_has_defect_mgt(cdi))) in cdrom_ram_open_write()
855 if ((ret = cdrom_get_random_writable(cdi, &rfd))) in cdrom_ram_open_write()
864 static void cdrom_mmc3_profile(struct cdrom_device_info *cdi) in cdrom_mmc3_profile() argument
878 if (cdi->ops->generic_packet(cdi, &cgc)) in cdrom_mmc3_profile()
883 cdi->mmc3_profile = mmc3_profile; in cdrom_mmc3_profile()
886 static int cdrom_is_dvd_rw(struct cdrom_device_info *cdi) in cdrom_is_dvd_rw() argument
888 switch (cdi->mmc3_profile) { in cdrom_is_dvd_rw()
901 static int cdrom_open_write(struct cdrom_device_info *cdi) in cdrom_open_write() argument
907 if (!cdrom_is_mrw(cdi, &mrw_write)) in cdrom_open_write()
913 (void) cdrom_is_random_writable(cdi, &ram_write); in cdrom_open_write()
916 cdi->mask &= ~CDC_MRW; in cdrom_open_write()
918 cdi->mask |= CDC_MRW; in cdrom_open_write()
921 cdi->mask &= ~CDC_MRW_W; in cdrom_open_write()
923 cdi->mask |= CDC_MRW_W; in cdrom_open_write()
926 cdi->mask &= ~CDC_RAM; in cdrom_open_write()
928 cdi->mask |= CDC_RAM; in cdrom_open_write()
931 ret = cdrom_mrw_open_write(cdi); in cdrom_open_write()
933 ret = cdrom_dvdram_open_write(cdi); in cdrom_open_write()
936 ret = cdrom_ram_open_write(cdi); in cdrom_open_write()
938 ret = mo_open_write(cdi); in cdrom_open_write()
939 else if (!cdrom_is_dvd_rw(cdi)) in cdrom_open_write()
945 static void cdrom_dvd_rw_close_write(struct cdrom_device_info *cdi) in cdrom_dvd_rw_close_write() argument
949 if (cdi->mmc3_profile != 0x1a) { in cdrom_dvd_rw_close_write()
950 cd_dbg(CD_CLOSE, "%s: No DVD+RW\n", cdi->name); in cdrom_dvd_rw_close_write()
954 if (!cdi->media_written) { in cdrom_dvd_rw_close_write()
955 cd_dbg(CD_CLOSE, "%s: DVD+RW media clean\n", cdi->name); in cdrom_dvd_rw_close_write()
959 pr_info("%s: dirty DVD+RW media, \"finalizing\"\n", cdi->name); in cdrom_dvd_rw_close_write()
964 cdi->ops->generic_packet(cdi, &cgc); in cdrom_dvd_rw_close_write()
970 cdi->ops->generic_packet(cdi, &cgc); in cdrom_dvd_rw_close_write()
977 cdi->ops->generic_packet(cdi, &cgc); in cdrom_dvd_rw_close_write()
979 cdi->media_written = 0; in cdrom_dvd_rw_close_write()
983 static void cdrom_count_tracks(struct cdrom_device_info *cdi, tracktype *tracks) in cdrom_count_tracks() argument
990 tracks->cdi = 0; in cdrom_count_tracks()
1001 ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header); in cdrom_count_tracks()
1013 if (cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &entry)) { in cdrom_count_tracks()
1019 tracks->cdi++; in cdrom_count_tracks()
1032 tracks->cdi, tracks->xa); in cdrom_count_tracks()
1036 int open_for_data(struct cdrom_device_info *cdi) in open_for_data() argument
1039 const struct cdrom_device_ops *cdo = cdi->ops; in open_for_data()
1045 ret = cdo->drive_status(cdi, CDSL_CURRENT); in open_for_data()
1051 cdi->options & CDO_AUTO_CLOSE) { in open_for_data()
1053 ret=cdo->tray_move(cdi,0); in open_for_data()
1070 ret = cdo->drive_status(cdi, CDSL_CURRENT); in open_for_data()
1080 ret = cdo->drive_status(cdi, CDSL_CURRENT); in open_for_data()
1086 cdrom_count_tracks(cdi, &tracks); in open_for_data()
1095 if (cdi->options & CDO_CHECK_TYPE) { in open_for_data()
1112 ret = cdo->open(cdi, 0); /* open for data */ in open_for_data()
1121 if (CDROM_CAN(CDC_LOCK) && (cdi->options & CDO_LOCK)) { in open_for_data()
1122 cdo->lock_door(cdi, 1); in open_for_data()
1135 if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { in open_for_data()
1136 cdo->lock_door(cdi, 0); in open_for_data()
1150 int cdrom_open(struct cdrom_device_info *cdi, blk_mode_t mode) in cdrom_open() argument
1158 cdi->use_count++; in cdrom_open()
1159 if ((mode & BLK_OPEN_NDELAY) && (cdi->options & CDO_USE_FFLAGS)) { in cdrom_open()
1160 ret = cdi->ops->open(cdi, 1); in cdrom_open()
1162 ret = open_for_data(cdi); in cdrom_open()
1166 cdrom_mmc3_profile(cdi); in cdrom_open()
1169 if (cdrom_open_write(cdi)) in cdrom_open()
1174 cdi->media_written = 0; in cdrom_open()
1176 cdi->opened_for_data = true; in cdrom_open()
1183 cdi->name, cdi->use_count); in cdrom_open()
1186 if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { in cdrom_open()
1187 cdi->ops->lock_door(cdi, 0); in cdrom_open()
1190 cdi->ops->release(cdi); in cdrom_open()
1192 cdi->use_count--; in cdrom_open()
1200 static int check_for_audio_disc(struct cdrom_device_info *cdi, in check_for_audio_disc() argument
1206 if (!(cdi->options & CDO_CHECK_TYPE)) in check_for_audio_disc()
1209 ret = cdo->drive_status(cdi, CDSL_CURRENT); in check_for_audio_disc()
1215 cdi->options & CDO_AUTO_CLOSE) { in check_for_audio_disc()
1217 ret=cdo->tray_move(cdi,0); in check_for_audio_disc()
1232 ret = cdo->drive_status(cdi, CDSL_CURRENT); in check_for_audio_disc()
1244 cdrom_count_tracks(cdi, &tracks); in check_for_audio_disc()
1254 void cdrom_release(struct cdrom_device_info *cdi) in cdrom_release() argument
1256 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_release()
1260 if (cdi->use_count > 0) in cdrom_release()
1261 cdi->use_count--; in cdrom_release()
1263 if (cdi->use_count == 0) { in cdrom_release()
1265 cdi->name); in cdrom_release()
1266 cdrom_dvd_rw_close_write(cdi); in cdrom_release()
1268 if ((cdo->capability & CDC_LOCK) && !cdi->keeplocked) { in cdrom_release()
1270 cdo->lock_door(cdi, 0); in cdrom_release()
1274 cdo->release(cdi); in cdrom_release()
1276 if (cdi->use_count == 0 && cdi->opened_for_data) { in cdrom_release()
1277 if (cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY)) in cdrom_release()
1278 cdo->tray_move(cdi, 1); in cdrom_release()
1279 cdi->opened_for_data = false; in cdrom_release()
1284 static int cdrom_read_mech_status(struct cdrom_device_info *cdi, in cdrom_read_mech_status() argument
1288 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_read_mech_status()
1296 if (cdi->sanyo_slot) { in cdrom_read_mech_status()
1298 buf->hdr.curslot = cdi->sanyo_slot == 3 ? 0 : cdi->sanyo_slot; in cdrom_read_mech_status()
1307 cdi->capacity * sizeof(struct cdrom_slot); in cdrom_read_mech_status()
1313 return cdo->generic_packet(cdi, &cgc); in cdrom_read_mech_status()
1316 static int cdrom_slot_status(struct cdrom_device_info *cdi, int slot) in cdrom_slot_status() argument
1322 if (cdi->sanyo_slot) in cdrom_slot_status()
1329 if ((ret = cdrom_read_mech_status(cdi, info))) in cdrom_slot_status()
1345 int cdrom_number_of_slots(struct cdrom_device_info *cdi) in cdrom_number_of_slots() argument
1352 cdi->capacity = 0; in cdrom_number_of_slots()
1358 if (cdrom_read_mech_status(cdi, info) == 0) in cdrom_number_of_slots()
1368 static int cdrom_load_unload(struct cdrom_device_info *cdi, int slot) in cdrom_load_unload() argument
1373 if (cdi->sanyo_slot && slot < 0) in cdrom_load_unload()
1385 if (cdi->sanyo_slot && -1 < slot) { in cdrom_load_unload()
1389 cdi->sanyo_slot = slot ? slot : 3; in cdrom_load_unload()
1392 return cdi->ops->generic_packet(cdi, &cgc); in cdrom_load_unload()
1395 static int cdrom_select_disc(struct cdrom_device_info *cdi, int slot) in cdrom_select_disc() argument
1405 if (cdi->ops->check_events) in cdrom_select_disc()
1406 cdi->ops->check_events(cdi, 0, slot); in cdrom_select_disc()
1409 signal_media_change(cdi); in cdrom_select_disc()
1410 return cdrom_load_unload(cdi, -1); in cdrom_select_disc()
1417 if ((ret = cdrom_read_mech_status(cdi, info))) { in cdrom_select_disc()
1425 if (cdi->use_count > 1 || cdi->keeplocked) { in cdrom_select_disc()
1442 signal_media_change(cdi); in cdrom_select_disc()
1443 if ((ret = cdrom_load_unload(cdi, slot))) in cdrom_select_disc()
1463 static void cdrom_update_events(struct cdrom_device_info *cdi, in cdrom_update_events() argument
1468 events = cdi->ops->check_events(cdi, clearing, CDSL_CURRENT); in cdrom_update_events()
1469 cdi->vfs_events |= events; in cdrom_update_events()
1470 cdi->ioctl_events |= events; in cdrom_update_events()
1473 unsigned int cdrom_check_events(struct cdrom_device_info *cdi, in cdrom_check_events() argument
1478 cdrom_update_events(cdi, clearing); in cdrom_check_events()
1479 events = cdi->vfs_events; in cdrom_check_events()
1480 cdi->vfs_events = 0; in cdrom_check_events()
1492 int media_changed(struct cdrom_device_info *cdi, int queue) in media_changed() argument
1495 int ret = !!(cdi->mc_flags & mask); in media_changed()
1503 cdrom_update_events(cdi, DISK_EVENT_MEDIA_CHANGE); in media_changed()
1504 changed = cdi->ioctl_events & DISK_EVENT_MEDIA_CHANGE; in media_changed()
1505 cdi->ioctl_events = 0; in media_changed()
1508 signal_media_change(cdi); in media_changed()
1510 cdi->media_written = 0; in media_changed()
1513 cdi->mc_flags &= ~mask; /* clear bit */ in media_changed()
1615 static int dvd_do_auth(struct cdrom_device_info *cdi, dvd_authinfo *ai) in dvd_do_auth() argument
1620 const struct cdrom_device_ops *cdo = cdi->ops; in dvd_do_auth()
1633 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1644 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1655 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1672 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1686 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1699 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1711 if ((ret = cdo->generic_packet(cdi, &cgc))) { in dvd_do_auth()
1723 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1734 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1751 if ((ret = cdo->generic_packet(cdi, &cgc))) in dvd_do_auth()
1763 static int dvd_read_physical(struct cdrom_device_info *cdi, dvd_struct *s, in dvd_read_physical() argument
1768 const struct cdrom_device_ops *cdo = cdi->ops; in dvd_read_physical()
1785 ret = cdo->generic_packet(cdi, cgc); in dvd_read_physical()
1814 static int dvd_read_copyright(struct cdrom_device_info *cdi, dvd_struct *s, in dvd_read_copyright() argument
1819 const struct cdrom_device_ops *cdo = cdi->ops; in dvd_read_copyright()
1828 ret = cdo->generic_packet(cdi, cgc); in dvd_read_copyright()
1838 static int dvd_read_disckey(struct cdrom_device_info *cdi, dvd_struct *s, in dvd_read_disckey() argument
1843 const struct cdrom_device_ops *cdo = cdi->ops; in dvd_read_disckey()
1858 ret = cdo->generic_packet(cdi, cgc); in dvd_read_disckey()
1866 static int dvd_read_bca(struct cdrom_device_info *cdi, dvd_struct *s, in dvd_read_bca() argument
1871 const struct cdrom_device_ops *cdo = cdi->ops; in dvd_read_bca()
1882 ret = cdo->generic_packet(cdi, cgc); in dvd_read_bca()
1900 static int dvd_read_manufact(struct cdrom_device_info *cdi, dvd_struct *s, in dvd_read_manufact() argument
1905 const struct cdrom_device_ops *cdo = cdi->ops; in dvd_read_manufact()
1919 ret = cdo->generic_packet(cdi, cgc); in dvd_read_manufact()
1942 static int dvd_read_struct(struct cdrom_device_info *cdi, dvd_struct *s, in dvd_read_struct() argument
1947 return dvd_read_physical(cdi, s, cgc); in dvd_read_struct()
1950 return dvd_read_copyright(cdi, s, cgc); in dvd_read_struct()
1953 return dvd_read_disckey(cdi, s, cgc); in dvd_read_struct()
1956 return dvd_read_bca(cdi, s, cgc); in dvd_read_struct()
1959 return dvd_read_manufact(cdi, s, cgc); in dvd_read_struct()
1968 int cdrom_mode_sense(struct cdrom_device_info *cdi, in cdrom_mode_sense() argument
1972 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_mode_sense()
1981 return cdo->generic_packet(cdi, cgc); in cdrom_mode_sense()
1985 int cdrom_mode_select(struct cdrom_device_info *cdi, in cdrom_mode_select() argument
1988 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_mode_select()
1997 return cdo->generic_packet(cdi, cgc); in cdrom_mode_select()
2001 static int cdrom_read_subchannel(struct cdrom_device_info *cdi, in cdrom_read_subchannel() argument
2004 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_read_subchannel()
2016 if ((ret = cdo->generic_packet(cdi, &cgc))) in cdrom_read_subchannel()
2048 static int cdrom_read_cd(struct cdrom_device_info *cdi, in cdrom_read_cd() argument
2052 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_read_cd()
2064 return cdo->generic_packet(cdi, cgc); in cdrom_read_cd()
2068 static int cdrom_read_block(struct cdrom_device_info *cdi, in cdrom_read_block() argument
2072 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_read_block()
2097 return cdo->generic_packet(cdi, cgc); in cdrom_read_block()
2100 static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf, in cdrom_read_cdda_old() argument
2107 cdi->last_sense = 0; in cdrom_read_cdda_old()
2131 ret = cdrom_read_block(cdi, &cgc, lba, nr, 1, CD_FRAMESIZE_RAW); in cdrom_read_cdda_old()
2146 static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, in cdrom_read_cdda_bpc() argument
2149 int max_frames = (queue_max_sectors(cdi->disk->queue) << 9) / in cdrom_read_cdda_bpc()
2153 cdi->last_sense = 0; in cdrom_read_cdda_bpc()
2156 if (cdi->cdda_method == CDDA_BPC_SINGLE) in cdrom_read_cdda_bpc()
2161 ret = cdi->ops->read_cdda_bpc(cdi, ubuf, lba, nr, in cdrom_read_cdda_bpc()
2162 &cdi->last_sense); in cdrom_read_cdda_bpc()
2174 static int cdrom_read_cdda(struct cdrom_device_info *cdi, __u8 __user *ubuf, in cdrom_read_cdda() argument
2179 if (cdi->cdda_method == CDDA_OLD) in cdrom_read_cdda()
2180 return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); in cdrom_read_cdda()
2186 ret = cdrom_read_cdda_bpc(cdi, ubuf, lba, nframes); in cdrom_read_cdda()
2194 if (cdi->cdda_method == CDDA_BPC_FULL && nframes > 1) { in cdrom_read_cdda()
2196 cdi->cdda_method = CDDA_BPC_SINGLE; in cdrom_read_cdda()
2205 if (cdi->last_sense != 0x04 && cdi->last_sense != 0x0b) in cdrom_read_cdda()
2208 pr_info("dropping to old style cdda (sense=%x)\n", cdi->last_sense); in cdrom_read_cdda()
2209 cdi->cdda_method = CDDA_OLD; in cdrom_read_cdda()
2210 return cdrom_read_cdda_old(cdi, ubuf, lba, nframes); in cdrom_read_cdda()
2213 int cdrom_multisession(struct cdrom_device_info *cdi, in cdrom_multisession() argument
2219 if (!(cdi->ops->capability & CDC_MULTI_SESSION)) in cdrom_multisession()
2227 ret = cdi->ops->get_last_session(cdi, info); in cdrom_multisession()
2235 static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi, in cdrom_ioctl_multisession() argument
2245 ret = cdrom_multisession(cdi, &info); in cdrom_ioctl_multisession()
2255 static int cdrom_ioctl_eject(struct cdrom_device_info *cdi) in cdrom_ioctl_eject() argument
2261 if (cdi->use_count != 1 || cdi->keeplocked) in cdrom_ioctl_eject()
2264 int ret = cdi->ops->lock_door(cdi, 0); in cdrom_ioctl_eject()
2269 return cdi->ops->tray_move(cdi, 1); in cdrom_ioctl_eject()
2272 static int cdrom_ioctl_closetray(struct cdrom_device_info *cdi) in cdrom_ioctl_closetray() argument
2278 return cdi->ops->tray_move(cdi, 0); in cdrom_ioctl_closetray()
2281 static int cdrom_ioctl_eject_sw(struct cdrom_device_info *cdi, in cdrom_ioctl_eject_sw() argument
2288 if (cdi->keeplocked) in cdrom_ioctl_eject_sw()
2291 cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT); in cdrom_ioctl_eject_sw()
2293 cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT; in cdrom_ioctl_eject_sw()
2297 static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi, in cdrom_ioctl_media_changed() argument
2310 return media_changed(cdi, 1); in cdrom_ioctl_media_changed()
2312 if (arg >= cdi->capacity) in cdrom_ioctl_media_changed()
2316 arg = array_index_nospec(arg, cdi->capacity); in cdrom_ioctl_media_changed()
2322 ret = cdrom_read_mech_status(cdi, info); in cdrom_ioctl_media_changed()
2340 static int cdrom_ioctl_timed_media_change(struct cdrom_device_info *cdi, in cdrom_ioctl_timed_media_change() argument
2353 ret = cdrom_ioctl_media_changed(cdi, CDSL_CURRENT); in cdrom_ioctl_timed_media_change()
2361 if (cdi->last_media_change_ms > tmp_info.last_media_change) in cdrom_ioctl_timed_media_change()
2364 tmp_info.last_media_change = cdi->last_media_change_ms; in cdrom_ioctl_timed_media_change()
2372 static int cdrom_ioctl_set_options(struct cdrom_device_info *cdi, in cdrom_ioctl_set_options() argument
2390 return cdi->options; in cdrom_ioctl_set_options()
2396 cdi->options |= (int) arg; in cdrom_ioctl_set_options()
2397 return cdi->options; in cdrom_ioctl_set_options()
2400 static int cdrom_ioctl_clear_options(struct cdrom_device_info *cdi, in cdrom_ioctl_clear_options() argument
2405 cdi->options &= ~(int) arg; in cdrom_ioctl_clear_options()
2406 return cdi->options; in cdrom_ioctl_clear_options()
2409 static int cdrom_ioctl_select_speed(struct cdrom_device_info *cdi, in cdrom_ioctl_select_speed() argument
2416 return cdi->ops->select_speed(cdi, arg); in cdrom_ioctl_select_speed()
2419 static int cdrom_ioctl_select_disc(struct cdrom_device_info *cdi, in cdrom_ioctl_select_disc() argument
2428 if (arg >= cdi->capacity) in cdrom_ioctl_select_disc()
2433 return cdrom_select_disc(cdi, arg); in cdrom_ioctl_select_disc()
2436 static int cdrom_ioctl_reset(struct cdrom_device_info *cdi, in cdrom_ioctl_reset() argument
2446 return cdi->ops->reset(cdi); in cdrom_ioctl_reset()
2449 static int cdrom_ioctl_lock_door(struct cdrom_device_info *cdi, in cdrom_ioctl_lock_door() argument
2457 cdi->keeplocked = arg ? 1 : 0; in cdrom_ioctl_lock_door()
2463 if (cdi->use_count != 1 && !arg && !capable(CAP_SYS_ADMIN)) in cdrom_ioctl_lock_door()
2465 return cdi->ops->lock_door(cdi, arg); in cdrom_ioctl_lock_door()
2468 static int cdrom_ioctl_debug(struct cdrom_device_info *cdi, in cdrom_ioctl_debug() argument
2479 static int cdrom_ioctl_get_capability(struct cdrom_device_info *cdi) in cdrom_ioctl_get_capability() argument
2482 return (cdi->ops->capability & ~cdi->mask); in cdrom_ioctl_get_capability()
2491 static int cdrom_ioctl_get_mcn(struct cdrom_device_info *cdi, in cdrom_ioctl_get_mcn() argument
2499 if (!(cdi->ops->capability & CDC_MCN)) in cdrom_ioctl_get_mcn()
2501 ret = cdi->ops->get_mcn(cdi, &mcn); in cdrom_ioctl_get_mcn()
2511 static int cdrom_ioctl_drive_status(struct cdrom_device_info *cdi, in cdrom_ioctl_drive_status() argument
2516 if (!(cdi->ops->capability & CDC_DRIVE_STATUS)) in cdrom_ioctl_drive_status()
2520 return cdi->ops->drive_status(cdi, CDSL_CURRENT); in cdrom_ioctl_drive_status()
2521 if (arg >= cdi->capacity) in cdrom_ioctl_drive_status()
2523 return cdrom_slot_status(cdi, arg); in cdrom_ioctl_drive_status()
2543 static int cdrom_ioctl_disc_status(struct cdrom_device_info *cdi) in cdrom_ioctl_disc_status() argument
2549 cdrom_count_tracks(cdi, &tracks); in cdrom_ioctl_disc_status()
2555 if (!tracks.data && !tracks.cdi && !tracks.xa) in cdrom_ioctl_disc_status()
2561 if (tracks.cdi > 0) in cdrom_ioctl_disc_status()
2573 static int cdrom_ioctl_changer_nslots(struct cdrom_device_info *cdi) in cdrom_ioctl_changer_nslots() argument
2576 return cdi->capacity; in cdrom_ioctl_changer_nslots()
2579 static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi, in cdrom_ioctl_get_subchnl() argument
2596 ret = cdi->ops->audio_ioctl(cdi, CDROMSUBCHNL, &q); in cdrom_ioctl_get_subchnl()
2610 static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi, in cdrom_ioctl_read_tochdr() argument
2621 ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header); in cdrom_ioctl_read_tochdr()
2631 int cdrom_read_tocentry(struct cdrom_device_info *cdi, in cdrom_read_tocentry() argument
2642 ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, entry); in cdrom_read_tocentry()
2650 static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi, in cdrom_ioctl_read_tocentry() argument
2658 ret = cdrom_read_tocentry(cdi, &entry); in cdrom_ioctl_read_tocentry()
2664 static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi, in cdrom_ioctl_play_msf() argument
2675 return cdi->ops->audio_ioctl(cdi, CDROMPLAYMSF, &msf); in cdrom_ioctl_play_msf()
2678 static int cdrom_ioctl_play_trkind(struct cdrom_device_info *cdi, in cdrom_ioctl_play_trkind() argument
2691 ret = check_for_audio_disc(cdi, cdi->ops); in cdrom_ioctl_play_trkind()
2694 return cdi->ops->audio_ioctl(cdi, CDROMPLAYTRKIND, &ti); in cdrom_ioctl_play_trkind()
2696 static int cdrom_ioctl_volctrl(struct cdrom_device_info *cdi, in cdrom_ioctl_volctrl() argument
2707 return cdi->ops->audio_ioctl(cdi, CDROMVOLCTRL, &volume); in cdrom_ioctl_volctrl()
2710 static int cdrom_ioctl_volread(struct cdrom_device_info *cdi, in cdrom_ioctl_volread() argument
2721 ret = cdi->ops->audio_ioctl(cdi, CDROMVOLREAD, &volume); in cdrom_ioctl_volread()
2730 static int cdrom_ioctl_audioctl(struct cdrom_device_info *cdi, in cdrom_ioctl_audioctl() argument
2739 ret = check_for_audio_disc(cdi, cdi->ops); in cdrom_ioctl_audioctl()
2742 return cdi->ops->audio_ioctl(cdi, cmd, NULL); in cdrom_ioctl_audioctl()
2749 static int cdrom_switch_blocksize(struct cdrom_device_info *cdi, int size) in cdrom_switch_blocksize() argument
2751 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_switch_blocksize()
2771 return cdo->generic_packet(cdi, &cgc); in cdrom_switch_blocksize()
2774 static int cdrom_get_track_info(struct cdrom_device_info *cdi, in cdrom_get_track_info() argument
2777 const struct cdrom_device_ops *cdo = cdi->ops; in cdrom_get_track_info()
2789 ret = cdo->generic_packet(cdi, &cgc); in cdrom_get_track_info()
2800 ret = cdo->generic_packet(cdi, &cgc); in cdrom_get_track_info()
2810 int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written) in cdrom_get_last_written() argument
2821 ret = cdrom_get_disc_info(cdi, &di); in cdrom_get_last_written()
2828 ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); in cdrom_get_last_written()
2837 ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); in cdrom_get_last_written()
2867 if ((ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &toc))) in cdrom_get_last_written()
2876 static int cdrom_get_next_writable(struct cdrom_device_info *cdi, in cdrom_get_next_writable() argument
2887 ret = cdrom_get_disc_info(cdi, &di); in cdrom_get_next_writable()
2894 ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); in cdrom_get_next_writable()
2903 ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); in cdrom_get_next_writable()
2916 ret = cdrom_get_last_written(cdi, next_writable); in cdrom_get_next_writable()
2926 static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_read_data() argument
2962 ret = cdrom_read_block(cdi, cgc, lba, 1, format, blocksize); in mmc_ioctl_cdrom_read_data()
2971 ret = cdrom_switch_blocksize(cdi, blocksize); in mmc_ioctl_cdrom_read_data()
2976 ret = cdrom_read_cd(cdi, cgc, lba, blocksize, 1); in mmc_ioctl_cdrom_read_data()
2978 ret |= cdrom_switch_blocksize(cdi, CD_FRAMESIZE); in mmc_ioctl_cdrom_read_data()
2987 static noinline int mmc_ioctl_cdrom_read_audio(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_read_audio() argument
3032 return cdrom_read_cdda(cdi, ra.buf, lba, ra.nframes); in mmc_ioctl_cdrom_read_audio()
3035 static noinline int mmc_ioctl_cdrom_subchannel(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_subchannel() argument
3048 ret = cdrom_read_subchannel(cdi, &q, 0); in mmc_ioctl_cdrom_subchannel()
3060 static noinline int mmc_ioctl_cdrom_play_msf(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_play_msf() argument
3064 const struct cdrom_device_ops *cdo = cdi->ops; in mmc_ioctl_cdrom_play_msf()
3077 return cdo->generic_packet(cdi, cgc); in mmc_ioctl_cdrom_play_msf()
3080 static noinline int mmc_ioctl_cdrom_play_blk(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_play_blk() argument
3084 const struct cdrom_device_ops *cdo = cdi->ops; in mmc_ioctl_cdrom_play_blk()
3097 return cdo->generic_packet(cdi, cgc); in mmc_ioctl_cdrom_play_blk()
3100 static noinline int mmc_ioctl_cdrom_volume(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_volume() argument
3119 ret = cdrom_mode_sense(cdi, cgc, GPMODE_AUDIO_CTL_PAGE, 0); in mmc_ioctl_cdrom_volume()
3134 ret = cdrom_mode_sense(cdi, cgc, in mmc_ioctl_cdrom_volume()
3160 ret = cdrom_mode_sense(cdi, cgc, GPMODE_AUDIO_CTL_PAGE, 1); in mmc_ioctl_cdrom_volume()
3172 return cdrom_mode_select(cdi, cgc); in mmc_ioctl_cdrom_volume()
3175 static noinline int mmc_ioctl_cdrom_start_stop(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_start_stop() argument
3179 const struct cdrom_device_ops *cdo = cdi->ops; in mmc_ioctl_cdrom_start_stop()
3185 return cdo->generic_packet(cdi, cgc); in mmc_ioctl_cdrom_start_stop()
3188 static noinline int mmc_ioctl_cdrom_pause_resume(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_pause_resume() argument
3192 const struct cdrom_device_ops *cdo = cdi->ops; in mmc_ioctl_cdrom_pause_resume()
3197 return cdo->generic_packet(cdi, cgc); in mmc_ioctl_cdrom_pause_resume()
3200 static noinline int mmc_ioctl_dvd_read_struct(struct cdrom_device_info *cdi, in mmc_ioctl_dvd_read_struct() argument
3217 ret = dvd_read_struct(cdi, s, cgc); in mmc_ioctl_dvd_read_struct()
3228 static noinline int mmc_ioctl_dvd_auth(struct cdrom_device_info *cdi, in mmc_ioctl_dvd_auth() argument
3238 ret = dvd_do_auth(cdi, &ai); in mmc_ioctl_dvd_auth()
3246 static noinline int mmc_ioctl_cdrom_next_writable(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_next_writable() argument
3252 ret = cdrom_get_next_writable(cdi, &next); in mmc_ioctl_cdrom_next_writable()
3260 static noinline int mmc_ioctl_cdrom_last_written(struct cdrom_device_info *cdi, in mmc_ioctl_cdrom_last_written() argument
3266 ret = cdrom_get_last_written(cdi, &last); in mmc_ioctl_cdrom_last_written()
3275 static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, in mmc_ioctl() argument
3289 return mmc_ioctl_cdrom_read_data(cdi, userptr, &cgc, cmd); in mmc_ioctl()
3291 return mmc_ioctl_cdrom_read_audio(cdi, userptr); in mmc_ioctl()
3293 return mmc_ioctl_cdrom_subchannel(cdi, userptr); in mmc_ioctl()
3295 return mmc_ioctl_cdrom_play_msf(cdi, userptr, &cgc); in mmc_ioctl()
3297 return mmc_ioctl_cdrom_play_blk(cdi, userptr, &cgc); in mmc_ioctl()
3300 return mmc_ioctl_cdrom_volume(cdi, userptr, &cgc, cmd); in mmc_ioctl()
3303 return mmc_ioctl_cdrom_start_stop(cdi, &cgc, cmd); in mmc_ioctl()
3306 return mmc_ioctl_cdrom_pause_resume(cdi, &cgc, cmd); in mmc_ioctl()
3308 return mmc_ioctl_dvd_read_struct(cdi, userptr, &cgc); in mmc_ioctl()
3310 return mmc_ioctl_dvd_auth(cdi, userptr); in mmc_ioctl()
3312 return mmc_ioctl_cdrom_next_writable(cdi, userptr); in mmc_ioctl()
3314 return mmc_ioctl_cdrom_last_written(cdi, userptr); in mmc_ioctl()
3325 int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev, in cdrom_ioctl() argument
3333 return cdrom_ioctl_multisession(cdi, argp); in cdrom_ioctl()
3335 return cdrom_ioctl_eject(cdi); in cdrom_ioctl()
3337 return cdrom_ioctl_closetray(cdi); in cdrom_ioctl()
3339 return cdrom_ioctl_eject_sw(cdi, arg); in cdrom_ioctl()
3341 return cdrom_ioctl_media_changed(cdi, arg); in cdrom_ioctl()
3343 return cdrom_ioctl_timed_media_change(cdi, arg); in cdrom_ioctl()
3345 return cdrom_ioctl_set_options(cdi, arg); in cdrom_ioctl()
3347 return cdrom_ioctl_clear_options(cdi, arg); in cdrom_ioctl()
3349 return cdrom_ioctl_select_speed(cdi, arg); in cdrom_ioctl()
3351 return cdrom_ioctl_select_disc(cdi, arg); in cdrom_ioctl()
3353 return cdrom_ioctl_reset(cdi, bdev); in cdrom_ioctl()
3355 return cdrom_ioctl_lock_door(cdi, arg); in cdrom_ioctl()
3357 return cdrom_ioctl_debug(cdi, arg); in cdrom_ioctl()
3359 return cdrom_ioctl_get_capability(cdi); in cdrom_ioctl()
3361 return cdrom_ioctl_get_mcn(cdi, argp); in cdrom_ioctl()
3363 return cdrom_ioctl_drive_status(cdi, arg); in cdrom_ioctl()
3365 return cdrom_ioctl_disc_status(cdi); in cdrom_ioctl()
3367 return cdrom_ioctl_changer_nslots(cdi); in cdrom_ioctl()
3377 ret = mmc_ioctl(cdi, cmd, arg); in cdrom_ioctl()
3389 return cdrom_ioctl_get_subchnl(cdi, argp); in cdrom_ioctl()
3391 return cdrom_ioctl_read_tochdr(cdi, argp); in cdrom_ioctl()
3393 return cdrom_ioctl_read_tocentry(cdi, argp); in cdrom_ioctl()
3395 return cdrom_ioctl_play_msf(cdi, argp); in cdrom_ioctl()
3397 return cdrom_ioctl_play_trkind(cdi, argp); in cdrom_ioctl()
3399 return cdrom_ioctl_volctrl(cdi, argp); in cdrom_ioctl()
3401 return cdrom_ioctl_volread(cdi, argp); in cdrom_ioctl()
3406 return cdrom_ioctl_audioctl(cdi, cmd); in cdrom_ioctl()
3437 struct cdrom_device_info *cdi; in cdrom_print_info() local
3446 list_for_each_entry(cdi, &cdrom_list, list) { in cdrom_print_info()
3450 "\t%s", cdi->name); in cdrom_print_info()
3454 "\t%d", cdi->speed); in cdrom_print_info()
3458 "\t%d", cdi->capacity); in cdrom_print_info()
3565 struct cdrom_device_info *cdi; in cdrom_update_settings() local
3568 list_for_each_entry(cdi, &cdrom_list, list) { in cdrom_update_settings()
3570 cdi->options |= CDO_AUTO_CLOSE; in cdrom_update_settings()
3572 cdi->options &= ~CDO_AUTO_CLOSE; in cdrom_update_settings()
3574 cdi->options |= CDO_AUTO_EJECT; in cdrom_update_settings()
3576 cdi->options &= ~CDO_AUTO_EJECT; in cdrom_update_settings()
3578 cdi->options |= CDO_LOCK; in cdrom_update_settings()
3580 cdi->options &= ~CDO_LOCK; in cdrom_update_settings()
3582 cdi->options |= CDO_CHECK_TYPE; in cdrom_update_settings()
3584 cdi->options &= ~CDO_CHECK_TYPE; in cdrom_update_settings()