1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * sr.h by David Giller 41da177e4SLinus Torvalds * CD-ROM disk driver header file 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * adapted from: 71da177e4SLinus Torvalds * sd.h Copyright (C) 1992 Drew Eckhardt 81da177e4SLinus Torvalds * SCSI disk driver header file by 91da177e4SLinus Torvalds * Drew Eckhardt 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * <drew@colorado.edu> 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * Modified by Eric Youngdale eric@andante.org to 141da177e4SLinus Torvalds * add scatter-gather, multiple outstanding request, and other 151da177e4SLinus Torvalds * enhancements. 161da177e4SLinus Torvalds */ 171da177e4SLinus Torvalds 181da177e4SLinus Torvalds #ifndef _SR_H 191da177e4SLinus Torvalds #define _SR_H 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds #include <linux/genhd.h> 221da177e4SLinus Torvalds #include <linux/kref.h> 231da177e4SLinus Torvalds 24210ba1d1SJames Bottomley #define MAX_RETRIES 3 25210ba1d1SJames Bottomley #define SR_TIMEOUT (30 * HZ) 26210ba1d1SJames Bottomley 271da177e4SLinus Torvalds struct scsi_device; 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds /* The CDROM is fairly slow, so we need a little extra time */ 301da177e4SLinus Torvalds /* In fact, it is very slow if it has to spin up first */ 311da177e4SLinus Torvalds #define IOCTL_TIMEOUT 30*HZ 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds 341da177e4SLinus Torvalds typedef struct scsi_cd { 351da177e4SLinus Torvalds struct scsi_driver *driver; 361da177e4SLinus Torvalds unsigned capacity; /* size in blocks */ 371da177e4SLinus Torvalds struct scsi_device *device; 381da177e4SLinus Torvalds unsigned int vendor; /* vendor code, see sr_vendor.c */ 391da177e4SLinus Torvalds unsigned long ms_offset; /* for reading multisession-CD's */ 40fd2eb903SChristoph Hellwig unsigned writeable : 1; 411da177e4SLinus Torvalds unsigned use:1; /* is this device still supportable */ 421da177e4SLinus Torvalds unsigned xa_flag:1; /* CD has XA sectors ? */ 431da177e4SLinus Torvalds unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */ 441da177e4SLinus Torvalds unsigned readcd_cdda:1; /* reading audio data using READ_CD */ 4593aae17aSTejun Heo unsigned media_present:1; /* media is present */ 4679b9677dSKay Sievers 4779b9677dSKay Sievers /* GET_EVENT spurious event handling, blk layer guarantees exclusion */ 4879b9677dSKay Sievers int tur_mismatch; /* nr of get_event TUR mismatches */ 4979b9677dSKay Sievers bool tur_changed:1; /* changed according to TUR */ 5079b9677dSKay Sievers bool get_event_changed:1; /* changed according to GET_EVENT */ 5179b9677dSKay Sievers bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */ 5279b9677dSKay Sievers 531da177e4SLinus Torvalds struct cdrom_device_info cdi; 541da177e4SLinus Torvalds /* We hold gendisk and scsi_device references on probe and use 551da177e4SLinus Torvalds * the refs on this kref to decide when to release them */ 561da177e4SLinus Torvalds struct kref kref; 571da177e4SLinus Torvalds struct gendisk *disk; 581da177e4SLinus Torvalds } Scsi_CD; 591da177e4SLinus Torvalds 6096eefad2SHannes Reinecke #define sr_printk(prefix, cd, fmt, a...) \ 6122e0d994SHannes Reinecke sdev_prefix_printk(prefix, (cd)->device, (cd)->cdi.name, fmt, ##a) 6296eefad2SHannes Reinecke 631da177e4SLinus Torvalds int sr_do_ioctl(Scsi_CD *, struct packet_command *); 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds int sr_lock_door(struct cdrom_device_info *, int); 661da177e4SLinus Torvalds int sr_tray_move(struct cdrom_device_info *, int); 671da177e4SLinus Torvalds int sr_drive_status(struct cdrom_device_info *, int); 681da177e4SLinus Torvalds int sr_disk_status(struct cdrom_device_info *); 691da177e4SLinus Torvalds int sr_get_last_session(struct cdrom_device_info *, struct cdrom_multisession *); 701da177e4SLinus Torvalds int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); 711da177e4SLinus Torvalds int sr_reset(struct cdrom_device_info *); 721da177e4SLinus Torvalds int sr_select_speed(struct cdrom_device_info *cdi, int speed); 731da177e4SLinus Torvalds int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds int sr_is_xa(Scsi_CD *); 761da177e4SLinus Torvalds 771da177e4SLinus Torvalds /* sr_vendor.c */ 781da177e4SLinus Torvalds void sr_vendor_init(Scsi_CD *); 791da177e4SLinus Torvalds int sr_cd_check(struct cdrom_device_info *); 801da177e4SLinus Torvalds int sr_set_blocklength(Scsi_CD *, int blocklength); 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds #endif 83