blob: fe0ea36e4124d1c1ba1cc438d9c8538918122664 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 1996-98 Erik Andersen
3 * Copyright (C) 1998-2000 Jens Axboe
4 */
5#ifndef _IDE_CD_H
6#define _IDE_CD_H
7
8#include <linux/cdrom.h>
9#include <asm/byteorder.h>
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011/*
12 * typical timeout for packet command
13 */
14#define ATAPI_WAIT_PC (60 * HZ)
15#define ATAPI_WAIT_WRITE_BUSY (10 * HZ)
16
17/************************************************************************/
18
19#define SECTOR_BITS 9
20#ifndef SECTOR_SIZE
21#define SECTOR_SIZE (1 << SECTOR_BITS)
22#endif
23#define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS)
24#define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Bartlomiej Zolnierkiewicz455d80a2008-02-01 23:09:21 +010026/* Capabilities Page size including 8 bytes of Mode Page Header */
27#define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20)
28#define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4
29
Bartlomiej Zolnierkiewicz2bc4cf22008-02-01 23:09:22 +010030enum {
31 /* Device sends an interrupt when ready for a packet command. */
32 IDE_CD_FLAG_DRQ_INTERRUPT = (1 << 0),
33 /* Drive cannot lock the door. */
34 IDE_CD_FLAG_NO_DOORLOCK = (1 << 1),
35 /* Drive cannot eject the disc. */
36 IDE_CD_FLAG_NO_EJECT = (1 << 2),
Bartlomiej Zolnierkiewicze59724c2008-02-01 23:09:22 +010037 /* Drive is a pre ATAPI 1.2 drive. */
38 IDE_CD_FLAG_PRE_ATAPI12 = (1 << 3),
Bartlomiej Zolnierkiewicz2bc4cf22008-02-01 23:09:22 +010039 /* TOC addresses are in BCD. */
40 IDE_CD_FLAG_TOCADDR_AS_BCD = (1 << 4),
41 /* TOC track numbers are in BCD. */
42 IDE_CD_FLAG_TOCTRACKS_AS_BCD = (1 << 5),
43 /*
44 * Drive does not provide data in multiples of SECTOR_SIZE
45 * when more than one interrupt is needed.
46 */
47 IDE_CD_FLAG_LIMIT_NFRAMES = (1 << 6),
48 /* Seeking in progress. */
49 IDE_CD_FLAG_SEEKING = (1 << 7),
50 /* Driver has noticed a media change. */
51 IDE_CD_FLAG_MEDIA_CHANGED = (1 << 8),
52 /* Saved TOC information is current. */
53 IDE_CD_FLAG_TOC_VALID = (1 << 9),
54 /* We think that the drive door is locked. */
55 IDE_CD_FLAG_DOOR_LOCKED = (1 << 10),
56 /* SET_CD_SPEED command is unsupported. */
57 IDE_CD_FLAG_NO_SPEED_SELECT = (1 << 11),
Bartlomiej Zolnierkiewicze59724c2008-02-01 23:09:22 +010058 IDE_CD_FLAG_VERTOS_300_SSD = (1 << 12),
59 IDE_CD_FLAG_VERTOS_600_ESD = (1 << 13),
60 IDE_CD_FLAG_SANYO_3CD = (1 << 14),
61 IDE_CD_FLAG_FULL_CAPS_PAGE = (1 << 15),
62 IDE_CD_FLAG_PLAY_AUDIO_OK = (1 << 16),
63 IDE_CD_FLAG_LE_SPEED_FIELDS = (1 << 17),
Linus Torvalds1da177e2005-04-16 15:20:36 -070064};
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066/* Structure of a MSF cdrom address. */
67struct atapi_msf {
68 byte reserved;
69 byte minute;
70 byte second;
71 byte frame;
72};
73
74/* Space to hold the disk TOC. */
75#define MAX_TRACKS 99
76struct atapi_toc_header {
77 unsigned short toc_length;
78 byte first_track;
79 byte last_track;
80};
81
82struct atapi_toc_entry {
83 byte reserved1;
84#if defined(__BIG_ENDIAN_BITFIELD)
85 __u8 adr : 4;
86 __u8 control : 4;
87#elif defined(__LITTLE_ENDIAN_BITFIELD)
88 __u8 control : 4;
89 __u8 adr : 4;
90#else
91#error "Please fix <asm/byteorder.h>"
92#endif
93 byte track;
94 byte reserved2;
95 union {
96 unsigned lba;
97 struct atapi_msf msf;
98 } addr;
99};
100
101struct atapi_toc {
102 int last_session_lba;
103 int xa_flag;
104 unsigned long capacity;
105 struct atapi_toc_header hdr;
106 struct atapi_toc_entry ent[MAX_TRACKS+1];
107 /* One extra for the leadout. */
108};
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/* Extra per-device info for cdrom drives. */
111struct cdrom_info {
112 ide_drive_t *drive;
113 ide_driver_t *driver;
114 struct gendisk *disk;
115 struct kref kref;
116
117 /* Buffer for table of contents. NULL if we haven't allocated
118 a TOC buffer for this device yet. */
119
120 struct atapi_toc *toc;
121
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 /* The result of the last successful request sense command
123 on this device. */
124 struct request_sense sense_data;
125
126 struct request request_sense_request;
127 int dma;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 unsigned long last_block;
129 unsigned long start_seek;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Bartlomiej Zolnierkiewicz2bc4cf22008-02-01 23:09:22 +0100131 unsigned int cd_flags;
132
133 u8 max_speed; /* Max speed of the drive. */
134 u8 current_speed; /* Current speed of the drive. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
136 /* Per-device info needed by cdrom.c generic driver. */
137 struct cdrom_device_info devinfo;
138
139 unsigned long write_timeout;
140};
141
Bartlomiej Zolnierkiewicz972560f2008-02-01 23:09:23 +0100142/* ide-cd_verbose.c */
143void ide_cd_log_error(const char *, struct request *, struct request_sense *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100145/* ide-cd.c functions used by ide-cd_ioctl.c */
FUJITA Tomonori5f828542008-07-15 21:21:42 +0200146int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *,
147 unsigned *, struct request_sense *, int, unsigned int);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100148int ide_cd_read_toc(ide_drive_t *, struct request_sense *);
149int ide_cdrom_get_capabilities(ide_drive_t *, u8 *);
150void ide_cdrom_update_speed(ide_drive_t *, u8 *);
Borislav Petkovf9afd182008-02-01 23:09:29 +0100151int cdrom_check_status(ide_drive_t *, struct request_sense *);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100152
153/* ide-cd_ioctl.c */
Borislav Petkovf9afd182008-02-01 23:09:29 +0100154int ide_cdrom_open_real(struct cdrom_device_info *, int);
155void ide_cdrom_release_real(struct cdrom_device_info *);
156int ide_cdrom_drive_status(struct cdrom_device_info *, int);
157int ide_cdrom_check_media_change_real(struct cdrom_device_info *, int);
158int ide_cdrom_tray_move(struct cdrom_device_info *, int);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100159int ide_cdrom_lock_door(struct cdrom_device_info *, int);
160int ide_cdrom_select_speed(struct cdrom_device_info *, int);
161int ide_cdrom_get_last_session(struct cdrom_device_info *,
162 struct cdrom_multisession *);
163int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
164int ide_cdrom_reset(struct cdrom_device_info *cdi);
165int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
Borislav Petkovf9afd182008-02-01 23:09:29 +0100166int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168#endif /* _IDE_CD_H */