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