blob: 1de33719ad8ef32c7042e2e59fd3c310973f7896 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sr.h by David Giller
3 * CD-ROM disk driver header file
4 *
5 * adapted from:
6 * sd.h Copyright (C) 1992 Drew Eckhardt
7 * SCSI disk driver header file by
8 * Drew Eckhardt
9 *
10 * <drew@colorado.edu>
11 *
12 * Modified by Eric Youngdale eric@andante.org to
13 * add scatter-gather, multiple outstanding request, and other
14 * enhancements.
15 */
16
17#ifndef _SR_H
18#define _SR_H
19
20#include <linux/genhd.h>
21#include <linux/kref.h>
22
James Bottomley210ba1d2008-01-05 10:39:51 -060023#define MAX_RETRIES 3
24#define SR_TIMEOUT (30 * HZ)
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026struct 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
33typedef struct scsi_cd {
34 struct scsi_driver *driver;
35 unsigned capacity; /* size in blocks */
36 struct scsi_device *device;
37 unsigned int vendor; /* vendor code, see sr_vendor.c */
38 unsigned long ms_offset; /* for reading multisession-CD's */
Christoph Hellwigfd2eb902014-07-18 16:59:19 +020039 unsigned writeable : 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 unsigned use:1; /* is this device still supportable */
41 unsigned xa_flag:1; /* CD has XA sectors ? */
42 unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
43 unsigned readcd_cdda:1; /* reading audio data using READ_CD */
Tejun Heo93aae172010-12-16 17:52:17 +010044 unsigned media_present:1; /* media is present */
Kay Sievers79b96772011-06-30 15:03:48 +020045
46 /* GET_EVENT spurious event handling, blk layer guarantees exclusion */
47 int tur_mismatch; /* nr of get_event TUR mismatches */
48 bool tur_changed:1; /* changed according to TUR */
49 bool get_event_changed:1; /* changed according to GET_EVENT */
50 bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 struct cdrom_device_info cdi;
53 /* We hold gendisk and scsi_device references on probe and use
54 * the refs on this kref to decide when to release them */
55 struct kref kref;
56 struct gendisk *disk;
57} Scsi_CD;
58
Hannes Reinecke96eefad2014-06-25 16:39:54 +020059#define sr_printk(prefix, cd, fmt, a...) \
Hannes Reinecke22e0d992014-10-24 14:26:44 +020060 sdev_prefix_printk(prefix, (cd)->device, (cd)->cdi.name, fmt, ##a)
Hannes Reinecke96eefad2014-06-25 16:39:54 +020061
Linus Torvalds1da177e2005-04-16 15:20:36 -070062int sr_do_ioctl(Scsi_CD *, struct packet_command *);
63
64int sr_lock_door(struct cdrom_device_info *, int);
65int sr_tray_move(struct cdrom_device_info *, int);
66int sr_drive_status(struct cdrom_device_info *, int);
67int sr_disk_status(struct cdrom_device_info *);
68int sr_get_last_session(struct cdrom_device_info *, struct cdrom_multisession *);
69int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
70int sr_reset(struct cdrom_device_info *);
71int sr_select_speed(struct cdrom_device_info *cdi, int speed);
72int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74int sr_is_xa(Scsi_CD *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76/* sr_vendor.c */
77void sr_vendor_init(Scsi_CD *);
78int sr_cd_check(struct cdrom_device_info *);
79int sr_set_blocklength(Scsi_CD *, int blocklength);
80
81#endif