1
2
3
4
5
6
7
8
9
10
11#ifndef _LINUX_CDROM_H
12#define _LINUX_CDROM_H
13
14#include <linux/types.h>
15#include <asm/byteorder.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46#define EDRIVE_CANT_DO_THIS EOPNOTSUPP
47
48
49
50
51
52
53#define CDROMPAUSE 0x5301
54#define CDROMRESUME 0x5302
55#define CDROMPLAYMSF 0x5303
56#define CDROMPLAYTRKIND 0x5304
57
58#define CDROMREADTOCHDR 0x5305
59
60#define CDROMREADTOCENTRY 0x5306
61
62#define CDROMSTOP 0x5307
63#define CDROMSTART 0x5308
64#define CDROMEJECT 0x5309
65#define CDROMVOLCTRL 0x530a
66
67#define CDROMSUBCHNL 0x530b
68
69#define CDROMREADMODE2 0x530c
70
71#define CDROMREADMODE1 0x530d
72
73#define CDROMREADAUDIO 0x530e
74#define CDROMEJECT_SW 0x530f
75#define CDROMMULTISESSION 0x5310
76
77
78#define CDROM_GET_MCN 0x5311
79
80#define CDROM_GET_UPC CDROM_GET_MCN
81
82#define CDROMRESET 0x5312
83#define CDROMVOLREAD 0x5313
84
85#define CDROMREADRAW 0x5314
86
87
88
89
90#define CDROMREADCOOKED 0x5315
91#define CDROMSEEK 0x5316
92
93
94
95
96
97#define CDROMPLAYBLK 0x5317
98
99
100
101
102#define CDROMREADALL 0x5318
103
104
105
106
107
108
109
110
111#define CDROMGETSPINDOWN 0x531d
112#define CDROMSETSPINDOWN 0x531e
113
114
115
116
117
118
119#define CDROMCLOSETRAY 0x5319
120#define CDROM_SET_OPTIONS 0x5320
121#define CDROM_CLEAR_OPTIONS 0x5321
122#define CDROM_SELECT_SPEED 0x5322
123#define CDROM_SELECT_DISC 0x5323
124#define CDROM_MEDIA_CHANGED 0x5325
125#define CDROM_DRIVE_STATUS 0x5326
126#define CDROM_DISC_STATUS 0x5327
127#define CDROM_CHANGER_NSLOTS 0x5328
128#define CDROM_LOCKDOOR 0x5329
129#define CDROM_DEBUG 0x5330
130#define CDROM_GET_CAPABILITY 0x5331
131
132
133
134
135
136
137#define CDROMAUDIOBUFSIZ 0x5382
138
139
140
141#define DVD_READ_STRUCT 0x5390
142#define DVD_WRITE_STRUCT 0x5391
143#define DVD_AUTH 0x5392
144
145#define CDROM_SEND_PACKET 0x5393
146#define CDROM_NEXT_WRITABLE 0x5394
147#define CDROM_LAST_WRITTEN 0x5395
148
149
150
151
152
153
154struct cdrom_msf0
155{
156 __u8 minute;
157 __u8 second;
158 __u8 frame;
159};
160
161
162union cdrom_addr
163{
164 struct cdrom_msf0 msf;
165 int lba;
166};
167
168
169struct cdrom_msf
170{
171 __u8 cdmsf_min0;
172 __u8 cdmsf_sec0;
173 __u8 cdmsf_frame0;
174 __u8 cdmsf_min1;
175 __u8 cdmsf_sec1;
176 __u8 cdmsf_frame1;
177};
178
179
180struct cdrom_ti
181{
182 __u8 cdti_trk0;
183 __u8 cdti_ind0;
184 __u8 cdti_trk1;
185 __u8 cdti_ind1;
186};
187
188
189struct cdrom_tochdr
190{
191 __u8 cdth_trk0;
192 __u8 cdth_trk1;
193};
194
195
196struct cdrom_volctrl
197{
198 __u8 channel0;
199 __u8 channel1;
200 __u8 channel2;
201 __u8 channel3;
202};
203
204
205struct cdrom_subchnl
206{
207 __u8 cdsc_format;
208 __u8 cdsc_audiostatus;
209 __u8 cdsc_adr: 4;
210 __u8 cdsc_ctrl: 4;
211 __u8 cdsc_trk;
212 __u8 cdsc_ind;
213 union cdrom_addr cdsc_absaddr;
214 union cdrom_addr cdsc_reladdr;
215};
216
217
218
219struct cdrom_tocentry
220{
221 __u8 cdte_track;
222 __u8 cdte_adr :4;
223 __u8 cdte_ctrl :4;
224 __u8 cdte_format;
225 union cdrom_addr cdte_addr;
226 __u8 cdte_datamode;
227};
228
229
230struct cdrom_read
231{
232 int cdread_lba;
233 char *cdread_bufaddr;
234 int cdread_buflen;
235};
236
237
238struct cdrom_read_audio
239{
240 union cdrom_addr addr;
241 __u8 addr_format;
242 int nframes;
243 __u8 __user *buf;
244};
245
246
247struct cdrom_multisession
248{
249 union cdrom_addr addr;
250
251
252 __u8 xa_flag;
253 __u8 addr_format;
254};
255
256
257
258
259
260
261struct cdrom_mcn
262{
263 __u8 medium_catalog_number[14];
264};
265
266
267struct cdrom_blk
268{
269 unsigned from;
270 unsigned short len;
271};
272
273#define CDROM_PACKET_SIZE 12
274
275#define CGC_DATA_UNKNOWN 0
276#define CGC_DATA_WRITE 1
277#define CGC_DATA_READ 2
278#define CGC_DATA_NONE 3
279
280
281struct cdrom_generic_command
282{
283 unsigned char cmd[CDROM_PACKET_SIZE];
284 unsigned char __user *buffer;
285 unsigned int buflen;
286 int stat;
287 struct request_sense __user *sense;
288 unsigned char data_direction;
289 int quiet;
290 int timeout;
291 void __user *reserved[1];
292};
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329#define CD_MINS 74
330#define CD_SECS 60
331#define CD_FRAMES 75
332#define CD_SYNC_SIZE 12
333#define CD_MSF_OFFSET 150
334#define CD_CHUNK_SIZE 24
335#define CD_NUM_OF_CHUNKS 98
336#define CD_FRAMESIZE_SUB 96
337#define CD_HEAD_SIZE 4
338#define CD_SUBHEAD_SIZE 8
339#define CD_EDC_SIZE 4
340#define CD_ZERO_SIZE 8
341#define CD_ECC_SIZE 276
342#define CD_FRAMESIZE 2048
343#define CD_FRAMESIZE_RAW 2352
344#define CD_FRAMESIZE_RAWER 2646
345
346#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE)
347#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE)
348
349#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE)
350#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE)
351#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD)
352
353
354#define CDROM_LBA 0x01
355#define CDROM_MSF 0x02
356
357
358#define CDROM_DATA_TRACK 0x04
359
360
361#define CDROM_LEADOUT 0xAA
362
363
364#define CDROM_AUDIO_INVALID 0x00
365#define CDROM_AUDIO_PLAY 0x11
366#define CDROM_AUDIO_PAUSED 0x12
367#define CDROM_AUDIO_COMPLETED 0x13
368#define CDROM_AUDIO_ERROR 0x14
369#define CDROM_AUDIO_NO_STATUS 0x15
370
371
372#define CDC_CLOSE_TRAY 0x1
373#define CDC_OPEN_TRAY 0x2
374#define CDC_LOCK 0x4
375#define CDC_SELECT_SPEED 0x8
376#define CDC_SELECT_DISC 0x10
377#define CDC_MULTI_SESSION 0x20
378#define CDC_MCN 0x40
379#define CDC_MEDIA_CHANGED 0x80
380#define CDC_PLAY_AUDIO 0x100
381#define CDC_RESET 0x200
382#define CDC_DRIVE_STATUS 0x800
383#define CDC_GENERIC_PACKET 0x1000
384#define CDC_CD_R 0x2000
385#define CDC_CD_RW 0x4000
386#define CDC_DVD 0x8000
387#define CDC_DVD_R 0x10000
388#define CDC_DVD_RAM 0x20000
389#define CDC_MO_DRIVE 0x40000
390#define CDC_MRW 0x80000
391#define CDC_MRW_W 0x100000
392#define CDC_RAM 0x200000
393
394
395#define CDS_NO_INFO 0
396#define CDS_NO_DISC 1
397#define CDS_TRAY_OPEN 2
398#define CDS_DRIVE_NOT_READY 3
399#define CDS_DISC_OK 4
400
401
402
403#define CDS_AUDIO 100
404#define CDS_DATA_1 101
405#define CDS_DATA_2 102
406#define CDS_XA_2_1 103
407#define CDS_XA_2_2 104
408#define CDS_MIXED 105
409
410
411#define CDO_AUTO_CLOSE 0x1
412#define CDO_AUTO_EJECT 0x2
413#define CDO_USE_FFLAGS 0x4
414#define CDO_LOCK 0x8
415#define CDO_CHECK_TYPE 0x10
416
417
418#define CDSL_NONE (INT_MAX-1)
419#define CDSL_CURRENT INT_MAX
420
421
422
423
424
425
426#define CD_PART_MAX 64
427#define CD_PART_MASK (CD_PART_MAX - 1)
428
429
430
431
432
433
434
435#define GPCMD_BLANK 0xa1
436#define GPCMD_CLOSE_TRACK 0x5b
437#define GPCMD_FLUSH_CACHE 0x35
438#define GPCMD_FORMAT_UNIT 0x04
439#define GPCMD_GET_CONFIGURATION 0x46
440#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
441#define GPCMD_GET_PERFORMANCE 0xac
442#define GPCMD_INQUIRY 0x12
443#define GPCMD_LOAD_UNLOAD 0xa6
444#define GPCMD_MECHANISM_STATUS 0xbd
445#define GPCMD_MODE_SELECT_10 0x55
446#define GPCMD_MODE_SENSE_10 0x5a
447#define GPCMD_PAUSE_RESUME 0x4b
448#define GPCMD_PLAY_AUDIO_10 0x45
449#define GPCMD_PLAY_AUDIO_MSF 0x47
450#define GPCMD_PLAY_AUDIO_TI 0x48
451#define GPCMD_PLAY_CD 0xbc
452#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
453#define GPCMD_READ_10 0x28
454#define GPCMD_READ_12 0xa8
455#define GPCMD_READ_BUFFER 0x3c
456#define GPCMD_READ_BUFFER_CAPACITY 0x5c
457#define GPCMD_READ_CDVD_CAPACITY 0x25
458#define GPCMD_READ_CD 0xbe
459#define GPCMD_READ_CD_MSF 0xb9
460#define GPCMD_READ_DISC_INFO 0x51
461#define GPCMD_READ_DVD_STRUCTURE 0xad
462#define GPCMD_READ_FORMAT_CAPACITIES 0x23
463#define GPCMD_READ_HEADER 0x44
464#define GPCMD_READ_TRACK_RZONE_INFO 0x52
465#define GPCMD_READ_SUBCHANNEL 0x42
466#define GPCMD_READ_TOC_PMA_ATIP 0x43
467#define GPCMD_REPAIR_RZONE_TRACK 0x58
468#define GPCMD_REPORT_KEY 0xa4
469#define GPCMD_REQUEST_SENSE 0x03
470#define GPCMD_RESERVE_RZONE_TRACK 0x53
471#define GPCMD_SEND_CUE_SHEET 0x5d
472#define GPCMD_SCAN 0xba
473#define GPCMD_SEEK 0x2b
474#define GPCMD_SEND_DVD_STRUCTURE 0xbf
475#define GPCMD_SEND_EVENT 0xa2
476#define GPCMD_SEND_KEY 0xa3
477#define GPCMD_SEND_OPC 0x54
478#define GPCMD_SET_READ_AHEAD 0xa7
479#define GPCMD_SET_STREAMING 0xb6
480#define GPCMD_START_STOP_UNIT 0x1b
481#define GPCMD_STOP_PLAY_SCAN 0x4e
482#define GPCMD_TEST_UNIT_READY 0x00
483#define GPCMD_VERIFY_10 0x2f
484#define GPCMD_WRITE_10 0x2a
485#define GPCMD_WRITE_12 0xaa
486#define GPCMD_WRITE_AND_VERIFY_10 0x2e
487#define GPCMD_WRITE_BUFFER 0x3b
488
489
490
491
492#define GPCMD_SET_SPEED 0xbb
493
494
495#define GPCMD_PLAYAUDIO_TI 0x48
496
497
498
499
500#define GPCMD_GET_MEDIA_STATUS 0xda
501
502
503#define GPMODE_VENDOR_PAGE 0x00
504#define GPMODE_R_W_ERROR_PAGE 0x01
505#define GPMODE_WRITE_PARMS_PAGE 0x05
506#define GPMODE_WCACHING_PAGE 0x08
507#define GPMODE_AUDIO_CTL_PAGE 0x0e
508#define GPMODE_POWER_PAGE 0x1a
509#define GPMODE_FAULT_FAIL_PAGE 0x1c
510#define GPMODE_TO_PROTECT_PAGE 0x1d
511#define GPMODE_CAPABILITIES_PAGE 0x2a
512#define GPMODE_ALL_PAGES 0x3f
513
514
515#define GPMODE_CDROM_PAGE 0x0d
516
517
518
519
520#define DVD_STRUCT_PHYSICAL 0x00
521#define DVD_STRUCT_COPYRIGHT 0x01
522#define DVD_STRUCT_DISCKEY 0x02
523#define DVD_STRUCT_BCA 0x03
524#define DVD_STRUCT_MANUFACT 0x04
525
526struct dvd_layer {
527 __u8 book_version : 4;
528 __u8 book_type : 4;
529 __u8 min_rate : 4;
530 __u8 disc_size : 4;
531 __u8 layer_type : 4;
532 __u8 track_path : 1;
533 __u8 nlayers : 2;
534 __u8 track_density : 4;
535 __u8 linear_density : 4;
536 __u8 bca : 1;
537 __u32 start_sector;
538 __u32 end_sector;
539 __u32 end_sector_l0;
540};
541
542#define DVD_LAYERS 4
543
544struct dvd_physical {
545 __u8 type;
546 __u8 layer_num;
547 struct dvd_layer layer[DVD_LAYERS];
548};
549
550struct dvd_copyright {
551 __u8 type;
552
553 __u8 layer_num;
554 __u8 cpst;
555 __u8 rmi;
556};
557
558struct dvd_disckey {
559 __u8 type;
560
561 unsigned agid : 2;
562 __u8 value[2048];
563};
564
565struct dvd_bca {
566 __u8 type;
567
568 int len;
569 __u8 value[188];
570};
571
572struct dvd_manufact {
573 __u8 type;
574
575 __u8 layer_num;
576 int len;
577 __u8 value[2048];
578};
579
580typedef union {
581 __u8 type;
582
583 struct dvd_physical physical;
584 struct dvd_copyright copyright;
585 struct dvd_disckey disckey;
586 struct dvd_bca bca;
587 struct dvd_manufact manufact;
588} dvd_struct;
589
590
591
592
593
594
595#define DVD_LU_SEND_AGID 0
596#define DVD_HOST_SEND_CHALLENGE 1
597#define DVD_LU_SEND_KEY1 2
598#define DVD_LU_SEND_CHALLENGE 3
599#define DVD_HOST_SEND_KEY2 4
600
601
602#define DVD_AUTH_ESTABLISHED 5
603#define DVD_AUTH_FAILURE 6
604
605
606#define DVD_LU_SEND_TITLE_KEY 7
607#define DVD_LU_SEND_ASF 8
608#define DVD_INVALIDATE_AGID 9
609#define DVD_LU_SEND_RPC_STATE 10
610#define DVD_HOST_SEND_RPC_STATE 11
611
612
613typedef __u8 dvd_key[5];
614typedef __u8 dvd_challenge[10];
615
616struct dvd_lu_send_agid {
617 __u8 type;
618 unsigned agid : 2;
619};
620
621struct dvd_host_send_challenge {
622 __u8 type;
623 unsigned agid : 2;
624
625 dvd_challenge chal;
626};
627
628struct dvd_send_key {
629 __u8 type;
630 unsigned agid : 2;
631
632 dvd_key key;
633};
634
635struct dvd_lu_send_challenge {
636 __u8 type;
637 unsigned agid : 2;
638
639 dvd_challenge chal;
640};
641
642#define DVD_CPM_NO_COPYRIGHT 0
643#define DVD_CPM_COPYRIGHTED 1
644
645#define DVD_CP_SEC_NONE 0
646#define DVD_CP_SEC_EXIST 1
647
648#define DVD_CGMS_UNRESTRICTED 0
649#define DVD_CGMS_SINGLE 2
650#define DVD_CGMS_RESTRICTED 3
651
652struct dvd_lu_send_title_key {
653 __u8 type;
654 unsigned agid : 2;
655
656 dvd_key title_key;
657 int lba;
658 unsigned cpm : 1;
659 unsigned cp_sec : 1;
660 unsigned cgms : 2;
661};
662
663struct dvd_lu_send_asf {
664 __u8 type;
665 unsigned agid : 2;
666
667 unsigned asf : 1;
668};
669
670struct dvd_host_send_rpcstate {
671 __u8 type;
672 __u8 pdrc;
673};
674
675struct dvd_lu_send_rpcstate {
676 __u8 type : 2;
677 __u8 vra : 3;
678 __u8 ucca : 3;
679 __u8 region_mask;
680 __u8 rpc_scheme;
681};
682
683typedef union {
684 __u8 type;
685
686 struct dvd_lu_send_agid lsa;
687 struct dvd_host_send_challenge hsc;
688 struct dvd_send_key lsk;
689 struct dvd_lu_send_challenge lsc;
690 struct dvd_send_key hsk;
691 struct dvd_lu_send_title_key lstk;
692 struct dvd_lu_send_asf lsasf;
693 struct dvd_host_send_rpcstate hrpcs;
694 struct dvd_lu_send_rpcstate lrpcs;
695} dvd_authinfo;
696
697struct request_sense {
698#if defined(__BIG_ENDIAN_BITFIELD)
699 __u8 valid : 1;
700 __u8 error_code : 7;
701#elif defined(__LITTLE_ENDIAN_BITFIELD)
702 __u8 error_code : 7;
703 __u8 valid : 1;
704#endif
705 __u8 segment_number;
706#if defined(__BIG_ENDIAN_BITFIELD)
707 __u8 reserved1 : 2;
708 __u8 ili : 1;
709 __u8 reserved2 : 1;
710 __u8 sense_key : 4;
711#elif defined(__LITTLE_ENDIAN_BITFIELD)
712 __u8 sense_key : 4;
713 __u8 reserved2 : 1;
714 __u8 ili : 1;
715 __u8 reserved1 : 2;
716#endif
717 __u8 information[4];
718 __u8 add_sense_len;
719 __u8 command_info[4];
720 __u8 asc;
721 __u8 ascq;
722 __u8 fruc;
723 __u8 sks[3];
724 __u8 asb[46];
725};
726
727
728
729
730#define CDF_RWRT 0x0020
731#define CDF_HWDM 0x0024
732#define CDF_MRW 0x0028
733
734
735
736
737#define CDM_MRW_NOTMRW 0
738#define CDM_MRW_BGFORMAT_INACTIVE 1
739#define CDM_MRW_BGFORMAT_ACTIVE 2
740#define CDM_MRW_BGFORMAT_COMPLETE 3
741
742
743
744
745#define MRW_LBA_DMA 0
746#define MRW_LBA_GAA 1
747
748
749
750
751
752#define MRW_MODE_PC_PRE1 0x2c
753#define MRW_MODE_PC 0x03
754
755struct mrw_feature_desc {
756 __be16 feature_code;
757#if defined(__BIG_ENDIAN_BITFIELD)
758 __u8 reserved1 : 2;
759 __u8 feature_version : 4;
760 __u8 persistent : 1;
761 __u8 curr : 1;
762#elif defined(__LITTLE_ENDIAN_BITFIELD)
763 __u8 curr : 1;
764 __u8 persistent : 1;
765 __u8 feature_version : 4;
766 __u8 reserved1 : 2;
767#endif
768 __u8 add_len;
769#if defined(__BIG_ENDIAN_BITFIELD)
770 __u8 reserved2 : 7;
771 __u8 write : 1;
772#elif defined(__LITTLE_ENDIAN_BITFIELD)
773 __u8 write : 1;
774 __u8 reserved2 : 7;
775#endif
776 __u8 reserved3;
777 __u8 reserved4;
778 __u8 reserved5;
779};
780
781
782struct rwrt_feature_desc {
783 __be16 feature_code;
784#if defined(__BIG_ENDIAN_BITFIELD)
785 __u8 reserved1 : 2;
786 __u8 feature_version : 4;
787 __u8 persistent : 1;
788 __u8 curr : 1;
789#elif defined(__LITTLE_ENDIAN_BITFIELD)
790 __u8 curr : 1;
791 __u8 persistent : 1;
792 __u8 feature_version : 4;
793 __u8 reserved1 : 2;
794#endif
795 __u8 add_len;
796 __u32 last_lba;
797 __u32 block_size;
798 __u16 blocking;
799#if defined(__BIG_ENDIAN_BITFIELD)
800 __u8 reserved2 : 7;
801 __u8 page_present : 1;
802#elif defined(__LITTLE_ENDIAN_BITFIELD)
803 __u8 page_present : 1;
804 __u8 reserved2 : 7;
805#endif
806 __u8 reserved3;
807};
808
809typedef struct {
810 __be16 disc_information_length;
811#if defined(__BIG_ENDIAN_BITFIELD)
812 __u8 reserved1 : 3;
813 __u8 erasable : 1;
814 __u8 border_status : 2;
815 __u8 disc_status : 2;
816#elif defined(__LITTLE_ENDIAN_BITFIELD)
817 __u8 disc_status : 2;
818 __u8 border_status : 2;
819 __u8 erasable : 1;
820 __u8 reserved1 : 3;
821#else
822#error "Please fix <asm/byteorder.h>"
823#endif
824 __u8 n_first_track;
825 __u8 n_sessions_lsb;
826 __u8 first_track_lsb;
827 __u8 last_track_lsb;
828#if defined(__BIG_ENDIAN_BITFIELD)
829 __u8 did_v : 1;
830 __u8 dbc_v : 1;
831 __u8 uru : 1;
832 __u8 reserved2 : 2;
833 __u8 dbit : 1;
834 __u8 mrw_status : 2;
835#elif defined(__LITTLE_ENDIAN_BITFIELD)
836 __u8 mrw_status : 2;
837 __u8 dbit : 1;
838 __u8 reserved2 : 2;
839 __u8 uru : 1;
840 __u8 dbc_v : 1;
841 __u8 did_v : 1;
842#endif
843 __u8 disc_type;
844 __u8 n_sessions_msb;
845 __u8 first_track_msb;
846 __u8 last_track_msb;
847 __u32 disc_id;
848 __u32 lead_in;
849 __u32 lead_out;
850 __u8 disc_bar_code[8];
851 __u8 reserved3;
852 __u8 n_opc;
853} disc_information;
854
855typedef struct {
856 __be16 track_information_length;
857 __u8 track_lsb;
858 __u8 session_lsb;
859 __u8 reserved1;
860#if defined(__BIG_ENDIAN_BITFIELD)
861 __u8 reserved2 : 2;
862 __u8 damage : 1;
863 __u8 copy : 1;
864 __u8 track_mode : 4;
865 __u8 rt : 1;
866 __u8 blank : 1;
867 __u8 packet : 1;
868 __u8 fp : 1;
869 __u8 data_mode : 4;
870 __u8 reserved3 : 6;
871 __u8 lra_v : 1;
872 __u8 nwa_v : 1;
873#elif defined(__LITTLE_ENDIAN_BITFIELD)
874 __u8 track_mode : 4;
875 __u8 copy : 1;
876 __u8 damage : 1;
877 __u8 reserved2 : 2;
878 __u8 data_mode : 4;
879 __u8 fp : 1;
880 __u8 packet : 1;
881 __u8 blank : 1;
882 __u8 rt : 1;
883 __u8 nwa_v : 1;
884 __u8 lra_v : 1;
885 __u8 reserved3 : 6;
886#endif
887 __be32 track_start;
888 __be32 next_writable;
889 __be32 free_blocks;
890 __be32 fixed_packet_size;
891 __be32 track_size;
892 __be32 last_rec_address;
893} track_information;
894
895struct feature_header {
896 __u32 data_len;
897 __u8 reserved1;
898 __u8 reserved2;
899 __u16 curr_profile;
900};
901
902struct mode_page_header {
903 __be16 mode_data_length;
904 __u8 medium_type;
905 __u8 reserved1;
906 __u8 reserved2;
907 __u8 reserved3;
908 __be16 desc_length;
909};
910
911#ifdef __KERNEL__
912#include <linux/fs.h>
913#include <linux/device.h>
914#include <linux/list.h>
915
916struct packet_command
917{
918 unsigned char cmd[CDROM_PACKET_SIZE];
919 unsigned char *buffer;
920 unsigned int buflen;
921 int stat;
922 struct request_sense *sense;
923 unsigned char data_direction;
924 int quiet;
925 int timeout;
926 void *reserved[1];
927};
928
929
930
931
932#define CDDA_OLD 0
933#define CDDA_BPC_SINGLE 1
934#define CDDA_BPC_FULL 2
935
936
937struct cdrom_device_info {
938 struct cdrom_device_ops *ops;
939 struct list_head list;
940 struct gendisk *disk;
941 void *handle;
942
943 int mask;
944 int speed;
945 int capacity;
946
947 unsigned int options : 30;
948 unsigned mc_flags : 2;
949 unsigned int vfs_events;
950 unsigned int ioctl_events;
951 int use_count;
952 char name[20];
953
954 __u8 sanyo_slot : 2;
955 __u8 reserved : 6;
956 int cdda_method;
957 __u8 last_sense;
958 __u8 media_written;
959 unsigned short mmc3_profile;
960 int for_data;
961 int (*exit)(struct cdrom_device_info *);
962 int mrw_mode_page;
963};
964
965struct cdrom_device_ops {
966
967 int (*open) (struct cdrom_device_info *, int);
968 void (*release) (struct cdrom_device_info *);
969 int (*drive_status) (struct cdrom_device_info *, int);
970 unsigned int (*check_events) (struct cdrom_device_info *cdi,
971 unsigned int clearing, int slot);
972 int (*media_changed) (struct cdrom_device_info *, int);
973 int (*tray_move) (struct cdrom_device_info *, int);
974 int (*lock_door) (struct cdrom_device_info *, int);
975 int (*select_speed) (struct cdrom_device_info *, int);
976 int (*select_disc) (struct cdrom_device_info *, int);
977 int (*get_last_session) (struct cdrom_device_info *,
978 struct cdrom_multisession *);
979 int (*get_mcn) (struct cdrom_device_info *,
980 struct cdrom_mcn *);
981
982 int (*reset) (struct cdrom_device_info *);
983
984 int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
985
986
987 const int capability;
988 int n_minors;
989
990 int (*generic_packet) (struct cdrom_device_info *,
991 struct packet_command *);
992};
993
994
995extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
996 fmode_t mode);
997extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
998extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
999 fmode_t mode, unsigned int cmd, unsigned long arg);
1000extern unsigned int cdrom_check_events(struct cdrom_device_info *cdi,
1001 unsigned int clearing);
1002extern int cdrom_media_changed(struct cdrom_device_info *);
1003
1004extern int register_cdrom(struct cdrom_device_info *cdi);
1005extern void unregister_cdrom(struct cdrom_device_info *cdi);
1006
1007typedef struct {
1008 int data;
1009 int audio;
1010 int cdi;
1011 int xa;
1012 long error;
1013} tracktype;
1014
1015extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written);
1016extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
1017extern int cdrom_mode_select(struct cdrom_device_info *cdi,
1018 struct packet_command *cgc);
1019extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
1020 struct packet_command *cgc,
1021 int page_code, int page_control);
1022extern void init_cdrom_command(struct packet_command *cgc,
1023 void *buffer, int len, int type);
1024
1025
1026#define CDROM_MAX_SLOTS 256
1027
1028struct cdrom_mechstat_header {
1029#if defined(__BIG_ENDIAN_BITFIELD)
1030 __u8 fault : 1;
1031 __u8 changer_state : 2;
1032 __u8 curslot : 5;
1033 __u8 mech_state : 3;
1034 __u8 door_open : 1;
1035 __u8 reserved1 : 4;
1036#elif defined(__LITTLE_ENDIAN_BITFIELD)
1037 __u8 curslot : 5;
1038 __u8 changer_state : 2;
1039 __u8 fault : 1;
1040 __u8 reserved1 : 4;
1041 __u8 door_open : 1;
1042 __u8 mech_state : 3;
1043#endif
1044 __u8 curlba[3];
1045 __u8 nslots;
1046 __u16 slot_tablelen;
1047};
1048
1049struct cdrom_slot {
1050#if defined(__BIG_ENDIAN_BITFIELD)
1051 __u8 disc_present : 1;
1052 __u8 reserved1 : 6;
1053 __u8 change : 1;
1054#elif defined(__LITTLE_ENDIAN_BITFIELD)
1055 __u8 change : 1;
1056 __u8 reserved1 : 6;
1057 __u8 disc_present : 1;
1058#endif
1059 __u8 reserved2[3];
1060};
1061
1062struct cdrom_changer_info {
1063 struct cdrom_mechstat_header hdr;
1064 struct cdrom_slot slots[CDROM_MAX_SLOTS];
1065};
1066
1067typedef enum {
1068 mechtype_caddy = 0,
1069 mechtype_tray = 1,
1070 mechtype_popup = 2,
1071 mechtype_individual_changer = 4,
1072 mechtype_cartridge_changer = 5
1073} mechtype_t;
1074
1075typedef struct {
1076#if defined(__BIG_ENDIAN_BITFIELD)
1077 __u8 ps : 1;
1078 __u8 reserved1 : 1;
1079 __u8 page_code : 6;
1080 __u8 page_length;
1081 __u8 reserved2 : 1;
1082 __u8 bufe : 1;
1083 __u8 ls_v : 1;
1084 __u8 test_write : 1;
1085 __u8 write_type : 4;
1086 __u8 multi_session : 2;
1087 __u8 fp : 1;
1088 __u8 copy : 1;
1089 __u8 track_mode : 4;
1090 __u8 reserved3 : 4;
1091 __u8 data_block_type : 4;
1092#elif defined(__LITTLE_ENDIAN_BITFIELD)
1093 __u8 page_code : 6;
1094 __u8 reserved1 : 1;
1095 __u8 ps : 1;
1096 __u8 page_length;
1097 __u8 write_type : 4;
1098 __u8 test_write : 1;
1099 __u8 ls_v : 1;
1100 __u8 bufe : 1;
1101 __u8 reserved2 : 1;
1102 __u8 track_mode : 4;
1103 __u8 copy : 1;
1104 __u8 fp : 1;
1105 __u8 multi_session : 2;
1106 __u8 data_block_type : 4;
1107 __u8 reserved3 : 4;
1108#endif
1109 __u8 link_size;
1110 __u8 reserved4;
1111#if defined(__BIG_ENDIAN_BITFIELD)
1112 __u8 reserved5 : 2;
1113 __u8 app_code : 6;
1114#elif defined(__LITTLE_ENDIAN_BITFIELD)
1115 __u8 app_code : 6;
1116 __u8 reserved5 : 2;
1117#endif
1118 __u8 session_format;
1119 __u8 reserved6;
1120 __be32 packet_size;
1121 __u16 audio_pause;
1122 __u8 mcn[16];
1123 __u8 isrc[16];
1124 __u8 subhdr0;
1125 __u8 subhdr1;
1126 __u8 subhdr2;
1127 __u8 subhdr3;
1128} __attribute__((packed)) write_param_page;
1129
1130struct modesel_head
1131{
1132 __u8 reserved1;
1133 __u8 medium;
1134 __u8 reserved2;
1135 __u8 block_desc_length;
1136 __u8 density;
1137 __u8 number_of_blocks_hi;
1138 __u8 number_of_blocks_med;
1139 __u8 number_of_blocks_lo;
1140 __u8 reserved3;
1141 __u8 block_length_hi;
1142 __u8 block_length_med;
1143 __u8 block_length_lo;
1144};
1145
1146typedef struct {
1147 __u16 report_key_length;
1148 __u8 reserved1;
1149 __u8 reserved2;
1150#if defined(__BIG_ENDIAN_BITFIELD)
1151 __u8 type_code : 2;
1152 __u8 vra : 3;
1153 __u8 ucca : 3;
1154#elif defined(__LITTLE_ENDIAN_BITFIELD)
1155 __u8 ucca : 3;
1156 __u8 vra : 3;
1157 __u8 type_code : 2;
1158#endif
1159 __u8 region_mask;
1160 __u8 rpc_scheme;
1161 __u8 reserved3;
1162} rpc_state_t;
1163
1164struct event_header {
1165 __be16 data_len;
1166#if defined(__BIG_ENDIAN_BITFIELD)
1167 __u8 nea : 1;
1168 __u8 reserved1 : 4;
1169 __u8 notification_class : 3;
1170#elif defined(__LITTLE_ENDIAN_BITFIELD)
1171 __u8 notification_class : 3;
1172 __u8 reserved1 : 4;
1173 __u8 nea : 1;
1174#endif
1175 __u8 supp_event_class;
1176};
1177
1178struct media_event_desc {
1179#if defined(__BIG_ENDIAN_BITFIELD)
1180 __u8 reserved1 : 4;
1181 __u8 media_event_code : 4;
1182 __u8 reserved2 : 6;
1183 __u8 media_present : 1;
1184 __u8 door_open : 1;
1185#elif defined(__LITTLE_ENDIAN_BITFIELD)
1186 __u8 media_event_code : 4;
1187 __u8 reserved1 : 4;
1188 __u8 door_open : 1;
1189 __u8 media_present : 1;
1190 __u8 reserved2 : 6;
1191#endif
1192 __u8 start_slot;
1193 __u8 end_slot;
1194};
1195
1196extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med);
1197
1198static inline void lba_to_msf(int lba, u8 *m, u8 *s, u8 *f)
1199{
1200 lba += CD_MSF_OFFSET;
1201 lba &= 0xffffff;
1202 *m = lba / (CD_SECS * CD_FRAMES);
1203 lba %= (CD_SECS * CD_FRAMES);
1204 *s = lba / CD_FRAMES;
1205 *f = lba % CD_FRAMES;
1206}
1207
1208static inline int msf_to_lba(u8 m, u8 s, u8 f)
1209{
1210 return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
1211}
1212#endif
1213
1214#endif
1215