ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / modules / cdda-cdrom-extensions.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
3 /* fm-cdrom-extension.c - CDROM handliong constants copied from <linux/cdrom.h>.
4
5    Copyright (C) 2000 Eazel, Inc.
6
7    The Gnome Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11
12    The Gnome Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16
17    You should have received a copy of the GNU Library General Public
18    License along with the Gnome Library; see the file COPYING.LIB.  If not,
19    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.
21
22    Authors: Gene Z. Ragan <gzr@eazel.com>
23 */
24
25 #ifndef CDDA_CDROM_EXTENSIONS_H
26 #define CDDA_CDROM_EXTENSIONS_H
27
28 /*******************************************************
29  * The CD-ROM IOCTL commands  -- these should be supported by 
30  * all the various cdrom drivers.  For the CD-ROM ioctls, we 
31  * will commandeer byte 0x53, or 'S'.
32  *******************************************************/
33 #define CDROMPAUSE              0x5301 /* Pause Audio Operation */ 
34 #define CDROMRESUME             0x5302 /* Resume paused Audio Operation */
35 #define CDROMPLAYMSF            0x5303 /* Play Audio MSF (struct cdrom_msf) */
36 #define CDROMPLAYTRKIND         0x5304 /* Play Audio Track/index 
37                                            (struct cdrom_ti) */
38 #define CDROMREADTOCHDR         0x5305 /* Read TOC header 
39                                            (struct cdrom_tochdr) */
40 #define CDROMREADTOCENTRY       0x5306 /* Read TOC entry 
41                                            (struct cdrom_tocentry) */
42 #define CDROMSTOP               0x5307 /* Stop the cdrom drive */
43 #define CDROMSTART              0x5308 /* Start the cdrom drive */
44 #define CDROMEJECT              0x5309 /* Ejects the cdrom media */
45 #define CDROMVOLCTRL            0x530a /* Control output volume 
46                                            (struct cdrom_volctrl) */
47 #define CDROMSUBCHNL            0x530b /* Read subchannel data 
48                                            (struct cdrom_subchnl) */
49 #define CDROMREADMODE2          0x530c /* Read CDROM mode 2 data (2336 Bytes) 
50                                            (struct cdrom_read) */
51 #define CDROMREADMODE1          0x530d /* Read CDROM mode 1 data (2048 Bytes)
52                                            (struct cdrom_read) */
53 #define CDROMREADAUDIO          0x530e /* (struct cdrom_read_audio) */
54 #define CDROMEJECT_SW           0x530f /* enable(1)/disable(0) auto-ejecting */
55 #define CDROMMULTISESSION       0x5310 /* Obtain the start-of-last-session 
56                                            address of multi session disks 
57                                            (struct cdrom_multisession) */
58 #define CDROM_GET_MCN           0x5311 /* Obtain the "Universal Product Code" 
59                                            if available (struct cdrom_mcn) */
60 #define CDROM_GET_UPC           CDROM_GET_MCN  /* This one is depricated, 
61                                           but here anyway for compatability */
62 #define CDROMRESET              0x5312 /* hard-reset the drive */
63 #define CDROMVOLREAD            0x5313 /* Get the drive's volume setting 
64                                           (struct cdrom_volctrl) */
65 #define CDROMREADRAW            0x5314  /* read data in raw mode (2352 Bytes)
66                                            (struct cdrom_read) */
67 /* 
68  * These ioctls are used only used in aztcd.c and optcd.c
69  */
70 #define CDROMREADCOOKED         0x5315  /* read data in cooked mode */
71 #define CDROMSEEK               0x5316  /* seek msf address */
72   
73 /*
74  * This ioctl is only used by the scsi-cd driver.  
75    It is for playing audio in logical block addressing mode.
76  */
77 #define CDROMPLAYBLK            0x5317  /* (struct cdrom_blk) */
78
79 /* 
80  * These ioctls are only used in optcd.c
81  */
82 #define CDROMREADALL            0x5318  /* read all 2646 bytes */
83
84 /* 
85  * These ioctls are (now) only in ide-cd.c for controlling 
86  * drive spindown time.  They should be implemented in the
87  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
88  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
89  *  -Erik
90  */
91 #define CDROMGETSPINDOWN        0x531d
92 #define CDROMSETSPINDOWN        0x531e
93
94 /* 
95  * These ioctls are implemented through the uniform CD-ROM driver
96  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
97  * drivers are eventually ported to the uniform CD-ROM driver interface.
98  */
99 #define CDROMCLOSETRAY          0x5319  /* pendant of CDROMEJECT */
100 #define CDROM_SET_OPTIONS       0x5320  /* Set behavior options */
101 #define CDROM_CLEAR_OPTIONS     0x5321  /* Clear behavior options */
102 #define CDROM_SELECT_SPEED      0x5322  /* Set the CD-ROM speed */
103 #define CDROM_SELECT_DISC       0x5323  /* Select disc (for juke-boxes) */
104 #define CDROM_MEDIA_CHANGED     0x5325  /* Check is media changed  */
105 #define CDROM_DRIVE_STATUS      0x5326  /* Get tray position, etc. */
106 #define CDROM_DISC_STATUS       0x5327  /* Get disc type, etc. */
107 #define CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
108 #define CDROM_LOCKDOOR          0x5329  /* lock or unlock door */
109 #define CDROM_DEBUG             0x5330  /* Turn debug messages on/off */
110 #define CDROM_GET_CAPABILITY    0x5331  /* get capabilities */
111
112 /* This ioctl is only used by sbpcd at the moment */
113 #define CDROMAUDIOBUFSIZ        0x5382  /* set the audio buffer size */
114
115 /* DVD-ROM Specific ioctls */
116 #define DVD_READ_STRUCT         0x5390  /* Read structure */
117 #define DVD_WRITE_STRUCT        0x5391  /* Write structure */
118 #define DVD_AUTH                0x5392  /* Authentication */
119
120 #define CDROM_SEND_PACKET       0x5393  /* send a packet to the drive */
121 #define CDROM_NEXT_WRITABLE     0x5394  /* get next writable block */
122 #define CDROM_LAST_WRITTEN      0x5395  /* get last block written on disc */
123
124 /* Some generally useful CD-ROM information -- mostly based on the above */
125 #define CD_MINS              74 /* max. minutes per CD, not really a limit */
126 #define CD_SECS              60 /* seconds per minute */
127 #define CD_FRAMES            75 /* frames per second */
128 #define CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
129 #define CD_MSF_OFFSET       150 /* MSF numbering offset of first frame */
130 #define CD_CHUNK_SIZE        24 /* lowest-level "data bytes piece" */
131 #define CD_NUM_OF_CHUNKS     98 /* chunks per frame */
132 #define CD_FRAMESIZE_SUB     96 /* subchannel data "frame" size */
133 #define CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
134 #define CD_SUBHEAD_SIZE       8 /* subheader bytes per raw XA data frame */
135 #define CD_EDC_SIZE           4 /* bytes EDC per most raw data frame types */
136 #define CD_ZERO_SIZE          8 /* bytes zero per yellow book mode 1 frame */
137 #define CD_ECC_SIZE         276 /* bytes ECC per most raw data frame types */
138 #define CD_FRAMESIZE       2048 /* bytes per frame, "cooked" mode */
139 #define CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
140 #define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 
141 /* most drives don't deliver everything: */
142 #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
143 #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
144
145 #define CD_XA_HEAD        (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
146 #define CD_XA_TAIL        (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
147 #define CD_XA_SYNC_HEAD   (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
148
149 /* CD-ROM address types (cdrom_tocentry.cdte_format) */
150 #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
151 #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
152
153 /* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
154 #define CDROM_DATA_TRACK        0x04
155
156 /* The leadout track is always 0xAA, regardless of # of tracks on disc */
157 #define CDROM_LEADOUT           0xAA
158
159 /* audio states (from SCSI-2, but seen with other drives, too) */
160 #define CDROM_AUDIO_INVALID     0x00    /* audio status not supported */
161 #define CDROM_AUDIO_PLAY        0x11    /* audio play operation in progress */
162 #define CDROM_AUDIO_PAUSED      0x12    /* audio play operation paused */
163 #define CDROM_AUDIO_COMPLETED   0x13    /* audio play successfully completed */
164 #define CDROM_AUDIO_ERROR       0x14    /* audio play stopped due to error */
165 #define CDROM_AUDIO_NO_STATUS   0x15    /* no current audio status to return */
166
167 /* capability flags used with the uniform CD-ROM driver */ 
168 #define CDC_CLOSE_TRAY          0x1     /* caddy systems _can't_ close */
169 #define CDC_OPEN_TRAY           0x2     /* but _can_ eject.  */
170 #define CDC_LOCK                0x4     /* disable manual eject */
171 #define CDC_SELECT_SPEED        0x8     /* programmable speed */
172 #define CDC_SELECT_DISC         0x10    /* select disc from juke-box */
173 #define CDC_MULTI_SESSION       0x20    /* read sessions>1 */
174 #define CDC_MCN                 0x40    /* Medium Catalog Number */
175 #define CDC_MEDIA_CHANGED       0x80    /* media changed */
176 #define CDC_PLAY_AUDIO          0x100   /* audio functions */
177 #define CDC_RESET               0x200   /* hard reset device */
178 #define CDC_IOCTLS              0x400   /* driver has non-standard ioctls */
179 #define CDC_DRIVE_STATUS        0x800   /* driver implements drive status */
180 #define CDC_GENERIC_PACKET      0x1000  /* driver implements generic packets */
181 #define CDC_CD_R                0x2000  /* drive is a CD-R */
182 #define CDC_CD_RW               0x4000  /* drive is a CD-RW */
183 #define CDC_DVD                 0x8000  /* drive is a DVD */
184 #define CDC_DVD_R               0x10000 /* drive can write DVD-R */
185 #define CDC_DVD_RAM             0x20000 /* drive can write DVD-RAM */
186
187 /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
188 #define CDS_NO_INFO             0       /* if not implemented */
189 #define CDS_NO_DISC             1
190 #define CDS_TRAY_OPEN           2
191 #define CDS_DRIVE_NOT_READY     3
192 #define CDS_DISC_OK             4
193
194 /* return values for the CDROM_DISC_STATUS ioctl */
195 /* can also return CDS_NO_[INFO|DISC], from above */
196 #define CDS_AUDIO               100
197 #define CDS_DATA_1              101
198 #define CDS_DATA_2              102
199 #define CDS_XA_2_1              103
200 #define CDS_XA_2_2              104
201 #define CDS_MIXED               105
202
203 /* User-configurable behavior options for the uniform CD-ROM driver */
204 #define CDO_AUTO_CLOSE          0x1     /* close tray on first open() */
205 #define CDO_AUTO_EJECT          0x2     /* open tray on last release() */
206 #define CDO_USE_FFLAGS          0x4     /* use O_NONBLOCK information on open */
207 #define CDO_LOCK                0x8     /* lock tray on open files */
208 #define CDO_CHECK_TYPE          0x10    /* check type on open for data */
209
210 /* Special codes used when specifying changer slots. */
211 #define CDSL_NONE               ((int) (~0U>>1)-1)
212 #define CDSL_CURRENT            ((int) (~0U>>1))
213
214 /* For partition based multisession access. IDE can handle 64 partitions
215  * per drive - SCSI CD-ROM's use minors to differentiate between the
216  * various drives, so we can't do multisessions the same way there.
217  * Use the -o session=x option to mount on them.
218  */
219 #define CD_PART_MAX             64
220 #define CD_PART_MASK            (CD_PART_MAX - 1)
221
222 /*******************************************************
223  * CDROM IOCTL structures
224  *******************************************************/
225
226 /* Address in MSF format */
227 struct cdrom_msf0               
228 {
229         u_char  minute;
230         u_char  second;
231         u_char  frame;
232 };
233
234 /* Address in either MSF or logical format */
235 union cdrom_addr                
236 {
237         struct cdrom_msf0       msf;
238         int                     lba;
239 };
240
241 /* This struct is used by the CDROMSUBCHNL ioctl */
242 struct cdrom_subchnl 
243 {
244         u_char  cdsc_format;
245         u_char  cdsc_audiostatus;
246         u_char  cdsc_adr:       4;
247         u_char  cdsc_ctrl:      4;
248         u_char  cdsc_trk;
249         u_char  cdsc_ind;
250         union cdrom_addr cdsc_absaddr;
251         union cdrom_addr cdsc_reladdr;
252 };
253
254
255 /* This struct is used by the CDROMREADTOCENTRY ioctl */
256 struct cdrom_tocentry 
257 {
258         u_char  cdte_track;
259         u_char  cdte_adr        :4;
260         u_char  cdte_ctrl       :4;
261         u_char  cdte_format;
262         union cdrom_addr cdte_addr;
263         u_char  cdte_datamode;
264 };
265
266
267 /* This struct is used by the CDROMREADTOCHDR ioctl */
268 struct cdrom_tochdr     
269 {
270         u_char  cdth_trk0;      /* start track */
271         u_char  cdth_trk1;      /* end track */
272 };
273
274
275
276
277 #endif  /* CDDA_CDROM_EXTENSIONS_H */