blob: 339c624e04d8604e89d3a107c6bc2a7eb7b5d5d6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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/genhd.h>
22#include <linux/kref.h>
Merlijn Wajer51a85882020-02-18 15:39:17 +010023#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
James Bottomley210ba1d2008-01-05 10:39:51 -060025#define MAX_RETRIES 3
26#define SR_TIMEOUT (30 * HZ)
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028struct scsi_device;
29
30/* The CDROM is fairly slow, so we need a little extra time */
31/* In fact, it is very slow if it has to spin up first */
32#define IOCTL_TIMEOUT 30*HZ
33
34
35typedef struct scsi_cd {
36 struct scsi_driver *driver;
37 unsigned capacity; /* size in blocks */
38 struct scsi_device *device;
39 unsigned int vendor; /* vendor code, see sr_vendor.c */
40 unsigned long ms_offset; /* for reading multisession-CD's */
Christoph Hellwigfd2eb902014-07-18 16:59:19 +020041 unsigned writeable : 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 unsigned use:1; /* is this device still supportable */
43 unsigned xa_flag:1; /* CD has XA sectors ? */
44 unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
45 unsigned readcd_cdda:1; /* reading audio data using READ_CD */
Tejun Heo93aae172010-12-16 17:52:17 +010046 unsigned media_present:1; /* media is present */
Kay Sievers79b96772011-06-30 15:03:48 +020047
48 /* GET_EVENT spurious event handling, blk layer guarantees exclusion */
49 int tur_mismatch; /* nr of get_event TUR mismatches */
50 bool tur_changed:1; /* changed according to TUR */
51 bool get_event_changed:1; /* changed according to GET_EVENT */
52 bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 struct cdrom_device_info cdi;
Merlijn Wajer51a85882020-02-18 15:39:17 +010055 struct mutex lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 /* We hold gendisk and scsi_device references on probe and use
57 * the refs on this kref to decide when to release them */
58 struct kref kref;
59 struct gendisk *disk;
60} Scsi_CD;
61
Hannes Reinecke96eefad22014-06-25 16:39:54 +020062#define sr_printk(prefix, cd, fmt, a...) \
Hannes Reinecke22e0d992014-10-24 14:26:44 +020063 sdev_prefix_printk(prefix, (cd)->device, (cd)->cdi.name, fmt, ##a)
Hannes Reinecke96eefad22014-06-25 16:39:54 +020064
Linus Torvalds1da177e2005-04-16 15:20:36 -070065int sr_do_ioctl(Scsi_CD *, struct packet_command *);
66
67int sr_lock_door(struct cdrom_device_info *, int);
68int sr_tray_move(struct cdrom_device_info *, int);
69int sr_drive_status(struct cdrom_device_info *, int);
70int sr_disk_status(struct cdrom_device_info *);
71int sr_get_last_session(struct cdrom_device_info *, struct cdrom_multisession *);
72int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
73int sr_reset(struct cdrom_device_info *);
74int sr_select_speed(struct cdrom_device_info *cdi, int speed);
75int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77int sr_is_xa(Scsi_CD *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79/* sr_vendor.c */
80void sr_vendor_init(Scsi_CD *);
81int sr_cd_check(struct cdrom_device_info *);
82int sr_set_blocklength(Scsi_CD *, int blocklength);
83
84#endif