^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * sr.h by David Giller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * CD-ROM disk driver header file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * adapted from:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * sd.h Copyright (C) 1992 Drew Eckhardt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * SCSI disk driver header file by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Drew Eckhardt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * <drew@colorado.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Modified by Eric Youngdale eric@andante.org to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * add scatter-gather, multiple outstanding request, and other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * enhancements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifndef _SR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define _SR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/genhd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define MAX_RETRIES 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define SR_TIMEOUT (30 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct scsi_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* The CDROM is fairly slow, so we need a little extra time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* In fact, it is very slow if it has to spin up first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define IOCTL_TIMEOUT 30*HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) typedef struct scsi_cd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct scsi_driver *driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) unsigned capacity; /* size in blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct scsi_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned int vendor; /* vendor code, see sr_vendor.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned long ms_offset; /* for reading multisession-CD's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned writeable : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) unsigned use:1; /* is this device still supportable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned xa_flag:1; /* CD has XA sectors ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned readcd_cdda:1; /* reading audio data using READ_CD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned media_present:1; /* media is present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* GET_EVENT spurious event handling, blk layer guarantees exclusion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int tur_mismatch; /* nr of get_event TUR mismatches */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) bool tur_changed:1; /* changed according to TUR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) bool get_event_changed:1; /* changed according to GET_EVENT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct cdrom_device_info cdi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* We hold gendisk and scsi_device references on probe and use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * the refs on this kref to decide when to release them */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct kref kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct gendisk *disk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) } Scsi_CD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define sr_printk(prefix, cd, fmt, a...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) sdev_prefix_printk(prefix, (cd)->device, (cd)->cdi.name, fmt, ##a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int sr_do_ioctl(Scsi_CD *, struct packet_command *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int sr_lock_door(struct cdrom_device_info *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int sr_tray_move(struct cdrom_device_info *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int sr_drive_status(struct cdrom_device_info *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int sr_disk_status(struct cdrom_device_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int sr_get_last_session(struct cdrom_device_info *, struct cdrom_multisession *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) int sr_reset(struct cdrom_device_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int sr_select_speed(struct cdrom_device_info *cdi, int speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int sr_is_xa(Scsi_CD *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* sr_vendor.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) void sr_vendor_init(Scsi_CD *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int sr_cd_check(struct cdrom_device_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int sr_set_blocklength(Scsi_CD *, int blocklength);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif