FreeBSD/Linux Kernel Cross Reference
sys/sys/cdio.h
1 /* $NetBSD: cdio.h,v 1.26.6.1 2008/02/01 14:42:54 riz Exp $ */
2
3 #ifndef _SYS_CDIO_H_
4 #define _SYS_CDIO_H_
5
6 /* Shared between kernel & process */
7
8 union msf_lba {
9 struct {
10 u_char unused;
11 u_char minute;
12 u_char second;
13 u_char frame;
14 } msf;
15 uint32_t lba;
16 u_char addr[4];
17 };
18
19 struct cd_toc_entry {
20 u_char nothing1;
21 #if BYTE_ORDER == LITTLE_ENDIAN
22 u_char control:4;
23 u_char addr_type:4;
24 #endif
25 #if BYTE_ORDER == BIG_ENDIAN
26 u_char addr_type:4;
27 u_char control:4;
28 #endif
29 u_char track;
30 u_char nothing2;
31 union msf_lba addr;
32 };
33
34 struct cd_sub_channel_header {
35 u_char nothing1;
36 u_char audio_status;
37 #define CD_AS_AUDIO_INVALID 0x00
38 #define CD_AS_PLAY_IN_PROGRESS 0x11
39 #define CD_AS_PLAY_PAUSED 0x12
40 #define CD_AS_PLAY_COMPLETED 0x13
41 #define CD_AS_PLAY_ERROR 0x14
42 #define CD_AS_NO_STATUS 0x15
43 u_char data_len[2];
44 };
45
46 struct cd_sub_channel_q_data {
47 u_char data_format;
48 #if BYTE_ORDER == LITTLE_ENDIAN
49 u_char control:4;
50 u_char addr_type:4;
51 #endif
52 #if BYTE_ORDER == BIG_ENDIAN
53 u_char addr_type:4;
54 u_char control:4;
55 #endif
56 u_char track_number;
57 u_char index_number;
58 u_char absaddr[4];
59 u_char reladdr[4];
60 #if BYTE_ORDER == LITTLE_ENDIAN
61 u_char :7;
62 u_char mc_valid:1;
63 #endif
64 #if BYTE_ORDER == BIG_ENDIAN
65 u_char mc_valid:1;
66 u_char :7;
67 #endif
68 u_char mc_number[15];
69 #if BYTE_ORDER == LITTLE_ENDIAN
70 u_char :7;
71 u_char ti_valid:1;
72 #endif
73 #if BYTE_ORDER == BIG_ENDIAN
74 u_char ti_valid:1;
75 u_char :7;
76 #endif
77 u_char ti_number[15];
78 };
79
80 struct cd_sub_channel_position_data {
81 u_char data_format;
82 #if BYTE_ORDER == LITTLE_ENDIAN
83 u_char control:4;
84 u_char addr_type:4;
85 #endif
86 #if BYTE_ORDER == BIG_ENDIAN
87 u_char addr_type:4;
88 u_char control:4;
89 #endif
90 u_char track_number;
91 u_char index_number;
92 union msf_lba absaddr;
93 union msf_lba reladdr;
94 };
95
96 struct cd_sub_channel_media_catalog {
97 u_char data_format;
98 u_char nothing1;
99 u_char nothing2;
100 u_char nothing3;
101 #if BYTE_ORDER == LITTLE_ENDIAN
102 u_char :7;
103 u_char mc_valid:1;
104 #endif
105 #if BYTE_ORDER == BIG_ENDIAN
106 u_char mc_valid:1;
107 u_char :7;
108 #endif
109 u_char mc_number[15];
110 };
111
112 struct cd_sub_channel_track_info {
113 u_char data_format;
114 u_char nothing1;
115 u_char track_number;
116 u_char nothing2;
117 #if BYTE_ORDER == LITTLE_ENDIAN
118 u_char :7;
119 u_char ti_valid:1;
120 #endif
121 #if BYTE_ORDER == BIG_ENDIAN
122 u_char ti_valid:1;
123 u_char :7;
124 #endif
125 u_char ti_number[15];
126 };
127
128 struct cd_sub_channel_info {
129 struct cd_sub_channel_header header;
130 union {
131 struct cd_sub_channel_q_data q_data;
132 struct cd_sub_channel_position_data position;
133 struct cd_sub_channel_media_catalog media_catalog;
134 struct cd_sub_channel_track_info track_info;
135 } what;
136 };
137
138 /*
139 * Ioctls for the CD drive
140 */
141 struct ioc_play_track {
142 u_char start_track;
143 u_char start_index;
144 u_char end_track;
145 u_char end_index;
146 };
147
148 #define CDIOCPLAYTRACKS _IOW('c', 1, struct ioc_play_track)
149 struct ioc_play_blocks {
150 int blk;
151 int len;
152 };
153 #define CDIOCPLAYBLOCKS _IOW('c', 2, struct ioc_play_blocks)
154
155 struct ioc_read_subchannel {
156 u_char address_format;
157 #define CD_LBA_FORMAT 1
158 #define CD_MSF_FORMAT 2
159 u_char data_format;
160 #define CD_SUBQ_DATA 0
161 #define CD_CURRENT_POSITION 1
162 #define CD_MEDIA_CATALOG 2
163 #define CD_TRACK_INFO 3
164 u_char track;
165 int data_len;
166 struct cd_sub_channel_info *data;
167 };
168 #define CDIOCREADSUBCHANNEL _IOWR('c', 3, struct ioc_read_subchannel )
169
170 struct ioc_toc_header {
171 u_short len;
172 u_char starting_track;
173 u_char ending_track;
174 };
175
176 #define CDIOREADTOCHEADER _IOR('c', 4, struct ioc_toc_header)
177
178 struct ioc_read_toc_entry {
179 u_char address_format;
180 u_char starting_track;
181 u_short data_len;
182 struct cd_toc_entry *data;
183 };
184 #define CDIOREADTOCENTRIES _IOWR('c', 5, struct ioc_read_toc_entry)
185 #define CDIOREADTOCENTRYS CDIOREADTOCENTRIES
186
187 /* read LBA start of a given session; 0=last, others not yet supported */
188 #define CDIOREADMSADDR _IOWR('c', 6, int)
189
190 struct ioc_patch {
191 u_char patch[4]; /* one for each channel */
192 };
193 #define CDIOCSETPATCH _IOW('c', 9, struct ioc_patch)
194
195 struct ioc_vol {
196 u_char vol[4]; /* one for each channel */
197 };
198 #define CDIOCGETVOL _IOR('c', 10, struct ioc_vol)
199 #define CDIOCSETVOL _IOW('c', 11, struct ioc_vol)
200 #define CDIOCSETMONO _IO('c', 12)
201 #define CDIOCSETSTEREO _IO('c', 13)
202 #define CDIOCSETMUTE _IO('c', 14)
203 #define CDIOCSETLEFT _IO('c', 15)
204 #define CDIOCSETRIGHT _IO('c', 16)
205 #define CDIOCSETDEBUG _IO('c', 17)
206 #define CDIOCCLRDEBUG _IO('c', 18)
207 #define CDIOCPAUSE _IO('c', 19)
208 #define CDIOCRESUME _IO('c', 20)
209 #define CDIOCRESET _IO('c', 21)
210 #define CDIOCSTART _IO('c', 22)
211 #define CDIOCSTOP _IO('c', 23)
212 #define CDIOCEJECT _IO('c', 24)
213 #define CDIOCALLOW _IO('c', 25)
214 #define CDIOCPREVENT _IO('c', 26)
215 #define CDIOCCLOSE _IO('c', 27)
216
217 struct ioc_play_msf {
218 u_char start_m;
219 u_char start_s;
220 u_char start_f;
221 u_char end_m;
222 u_char end_s;
223 u_char end_f;
224 };
225 #define CDIOCPLAYMSF _IOW('c', 25, struct ioc_play_msf)
226
227 struct ioc_load_unload {
228 u_char options;
229 #define CD_LU_ABORT 0x1 /* NOTE: These are the same as the ATAPI */
230 #define CD_LU_UNLOAD 0x2 /* op values for the LOAD_UNLOAD command */
231 #define CD_LU_LOAD 0x3
232 u_char slot;
233 };
234 #define CDIOCLOADUNLOAD _IOW('c', 26, struct ioc_load_unload)
235
236
237 #if defined(_KERNEL) || defined(_EXPOSE_MMC)
238 /* not exposed to userland yet until its completely mature */
239 /*
240 * MMC device abstraction interface.
241 *
242 * It gathers information from GET_CONFIGURATION, READ_DISCINFO,
243 * READ_TRACKINFO, READ_TOC2, READ_CD_CAPACITY and GET_CONFIGURATION
244 * SCSI/ATAPI calls regardless if its a legacy CD-ROM/DVD-ROM device or a MMC
245 * standard recordable device.
246 */
247 struct mmc_discinfo {
248 uint16_t mmc_profile;
249 uint16_t mmc_class;
250
251 uint8_t disc_state;
252 uint8_t last_session_state;
253 uint8_t bg_format_state;
254 uint8_t link_block_penalty; /* in sectors */
255
256 uint64_t mmc_cur; /* current MMC_CAPs */
257 uint64_t mmc_cap; /* possible MMC_CAPs */
258
259 uint32_t disc_flags; /* misc flags */
260
261 uint32_t disc_id;
262 uint64_t disc_barcode;
263 uint8_t application_code; /* 8 bit really */
264
265 uint8_t unused1[3]; /* padding */
266
267 uint32_t last_possible_lba; /* last leadout start adr. */
268 uint32_t sector_size;
269
270 uint16_t num_sessions;
271 uint16_t num_tracks; /* derived */
272
273 uint16_t first_track;
274 uint16_t first_track_last_session;
275 uint16_t last_track_last_session;
276
277 uint16_t unused2; /* padding/misc info resv. */
278
279 uint16_t reserved1[4]; /* MMC-5 track resources */
280 uint32_t reserved2[3]; /* MMC-5 POW resources */
281
282 uint32_t reserved3[8]; /* MMC-5+ */
283 };
284 #define MMCGETDISCINFO _IOR('c', 28, struct mmc_discinfo)
285
286 #define MMC_CLASS_UNKN 0
287 #define MMC_CLASS_DISC 1
288 #define MMC_CLASS_CD 2
289 #define MMC_CLASS_DVD 3
290 #define MMC_CLASS_MO 4
291 #define MMC_CLASS_BD 5
292 #define MMC_CLASS_FILE 0xffff /* emulation mode */
293
294 #define MMC_DFLAGS_BARCODEVALID (1 << 0) /* barcode is present and valid */
295 #define MMC_DFLAGS_DISCIDVALID (1 << 1) /* discid is present and valid */
296 #define MMC_DFLAGS_APPCODEVALID (1 << 2) /* application code valid */
297 #define MMC_DFLAGS_UNRESTRICTED (1 << 3) /* restricted, then set app. code */
298
299 #define MMC_DFLAGS_FLAGBITS \
300 "\1\1BARCODEVALID\2DISCIDVALID\3APPCODEVALID\4UNRESTRICTED"
301
302 #define MMC_CAP_SEQUENTIAL (1 << 0) /* sequential writable only */
303 #define MMC_CAP_RECORDABLE (1 << 1) /* record-able; i.e. not static */
304 #define MMC_CAP_ERASABLE (1 << 2) /* drive can erase sectors */
305 #define MMC_CAP_BLANKABLE (1 << 3) /* media can be blanked */
306 #define MMC_CAP_FORMATTABLE (1 << 4) /* media can be formatted */
307 #define MMC_CAP_REWRITABLE (1 << 5) /* media can be rewritten */
308 #define MMC_CAP_MRW (1 << 6) /* Mount Rainier formatted */
309 #define MMC_CAP_PACKET (1 << 7) /* using packet recording */
310 #define MMC_CAP_STRICTOVERWRITE (1 << 8) /* only writes a packet at a time */
311 #define MMC_CAP_PSEUDOOVERWRITE (1 << 9) /* overwrite through replacement */
312 #define MMC_CAP_ZEROLINKBLK (1 << 10) /* zero link block length capable */
313 #define MMC_CAP_HW_DEFECTFREE (1 << 11) /* hardware defect management */
314
315 #define MMC_CAP_FLAGBITS \
316 "\1\1SEQUENTIAL\2RECORDABLE\3ERASABLE\4BLANKABLE\5FORMATTABLE" \
317 "\6REWRITABLE\7MRW\10PACKET\11STRICTOVERWRITE\12PSEUDOOVERWRITE" \
318 "\13ZEROLINKBLK\14HW_DEFECTFREE"
319
320 #define MMC_STATE_EMPTY 0
321 #define MMC_STATE_INCOMPLETE 1
322 #define MMC_STATE_FULL 2
323 #define MMC_STATE_CLOSED 3
324
325 #define MMC_BGFSTATE_UNFORM 0
326 #define MMC_BGFSTATE_STOPPED 1
327 #define MMC_BGFSTATE_RUNNING 2
328 #define MMC_BGFSTATE_COMPLETED 3
329
330
331 struct mmc_trackinfo {
332 uint16_t tracknr; /* IN/OUT */
333 uint16_t sessionnr;
334
335 uint8_t track_mode;
336 uint8_t data_mode;
337
338 uint16_t flags;
339
340 uint32_t track_start;
341 uint32_t next_writable;
342 uint32_t free_blocks;
343 uint32_t packet_size;
344 uint32_t track_size;
345 uint32_t last_recorded;
346 };
347 #define MMCGETTRACKINFO _IOWR('c', 29, struct mmc_trackinfo)
348
349 #define MMC_TRACKINFO_COPY (1 << 0)
350 #define MMC_TRACKINFO_DAMAGED (1 << 1)
351 #define MMC_TRACKINFO_FIXED_PACKET (1 << 2)
352 #define MMC_TRACKINFO_INCREMENTAL (1 << 3)
353 #define MMC_TRACKINFO_BLANK (1 << 4)
354 #define MMC_TRACKINFO_RESERVED (1 << 5)
355 #define MMC_TRACKINFO_NWA_VALID (1 << 6)
356 #define MMC_TRACKINFO_LRA_VALID (1 << 7)
357
358 #define MMC_TRACKINFO_FLAGBITS \
359 "\8\1COPY\2DAMAGED\3FIXEDPACKET\4INCREMENTAL\5BLANK" \
360 "\6RESERVED\7NWA_VALID\10LRA_VALID"
361
362 #endif /* _KERNEL || _EXPOSE_MMC */
363
364 #endif /* !_SYS_CDIO_H_ */
Cache object: 9bd74bfadb6c5aeeca376b40208db2fa
|