]> git.sesse.net Git - vlc/blob - modules/access/vcd/cdrom_internals.h
Removes trailing spaces. Removes tabs.
[vlc] / modules / access / vcd / cdrom_internals.h
1 /****************************************************************************
2  * cdrom_internals.h: cdrom tools private header
3  *****************************************************************************
4  * Copyright (C) 1998-2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Johan Bilien <jobi@via.ecp.fr>
8  *          Gildas Bazin <gbazin@netcourrier.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * The vcddev structure
27  *****************************************************************************/
28 struct vcddev_s
29 {
30     char   *psz_dev;                                      /* vcd device name */
31
32     /* Section used in vcd image mode */
33     int    i_vcdimage_handle;                   /* vcd image file descriptor */
34     int    i_tracks;                          /* number of tracks of the vcd */
35     int    *p_sectors;                           /* tracks layout on the vcd */
36
37     /* Section used in vcd device mode */
38
39 #ifdef WIN32
40     HANDLE h_device_handle;                         /* vcd device descriptor */
41     long  hASPI;
42     short i_sid;
43     long  (*lpSendCommand)( void* );
44
45 #else
46     int    i_device_handle;                         /* vcd device descriptor */
47 #endif
48
49 };
50
51
52 /*****************************************************************************
53  * Misc. Macros
54  *****************************************************************************/
55 /* LBA = msf.frame + 75 * ( msf.second + 60 * msf.minute ) */
56 #define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min))
57 /* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */
58 #define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min))
59
60 #ifndef O_BINARY
61 #   define O_BINARY 0
62 #endif
63
64 #define VCDDEV_T 1
65
66 /*****************************************************************************
67  * Platform specifics
68  *****************************************************************************/
69 #if defined( __APPLE__ )
70 #define darwin_freeTOC( p ) free( (void*)p )
71 #define CD_MIN_TRACK_NO 01
72 #define CD_MAX_TRACK_NO 99
73 #endif
74
75 #if defined( WIN32 )
76
77 /* Win32 DeviceIoControl specifics */
78 #ifndef MAXIMUM_NUMBER_TRACKS
79 #    define MAXIMUM_NUMBER_TRACKS 100
80 #endif
81 typedef struct _TRACK_DATA {
82     UCHAR Reserved;
83     UCHAR Control : 4;
84     UCHAR Adr : 4;
85     UCHAR TrackNumber;
86     UCHAR Reserved1;
87     UCHAR Address[4];
88 } TRACK_DATA, *PTRACK_DATA;
89 typedef struct _CDROM_TOC {
90     UCHAR Length[2];
91     UCHAR FirstTrack;
92     UCHAR LastTrack;
93     TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
94 } CDROM_TOC, *PCDROM_TOC;
95 typedef enum _TRACK_MODE_TYPE {
96     YellowMode2,
97     XAForm2,
98     CDDA
99 } TRACK_MODE_TYPE, *PTRACK_MODE_TYPE;
100 typedef struct __RAW_READ_INFO {
101     LARGE_INTEGER DiskOffset;
102     ULONG SectorCount;
103     TRACK_MODE_TYPE TrackMode;
104 } RAW_READ_INFO, *PRAW_READ_INFO;
105
106 #ifndef IOCTL_CDROM_BASE
107 #    define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
108 #endif
109 #ifndef IOCTL_CDROM_READ_TOC
110 #    define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, \
111                                           METHOD_BUFFERED, FILE_READ_ACCESS)
112 #endif
113 #ifndef IOCTL_CDROM_RAW_READ
114 #define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \
115                                       METHOD_OUT_DIRECT, FILE_READ_ACCESS)
116 #endif
117
118 /* Win32 aspi specific */
119 #define WIN_NT               ( GetVersion() < 0x80000000 )
120 #define ASPI_HAID           0
121 #define ASPI_TARGET         0
122 #define DTYPE_CDROM         0x05
123
124 #define SENSE_LEN           0x0E
125 #define SC_GET_DEV_TYPE     0x01
126 #define SC_EXEC_SCSI_CMD    0x02
127 #define SC_GET_DISK_INFO    0x06
128 #define SS_COMP             0x01
129 #define SS_PENDING          0x00
130 #define SS_NO_ADAPTERS      0xE8
131 #define SRB_DIR_IN          0x08
132 #define SRB_DIR_OUT         0x10
133 #define SRB_EVENT_NOTIFY    0x40
134
135 #define READ_CD 0xbe
136 #define SECTOR_TYPE_MODE2_FORM2 0x14
137 #define SECTOR_TYPE_CDDA 0x04
138 #define READ_CD_RAW_MODE2 0xF0
139 #define READ_CD_USERDATA 0x10
140
141 #define READ_TOC 0x43
142 #define READ_TOC_FORMAT_TOC 0x0
143
144 #pragma pack(1)
145
146 struct SRB_GetDiskInfo
147 {
148     unsigned char   SRB_Cmd;
149     unsigned char   SRB_Status;
150     unsigned char   SRB_HaId;
151     unsigned char   SRB_Flags;
152     unsigned long   SRB_Hdr_Rsvd;
153     unsigned char   SRB_Target;
154     unsigned char   SRB_Lun;
155     unsigned char   SRB_DriveFlags;
156     unsigned char   SRB_Int13HDriveInfo;
157     unsigned char   SRB_Heads;
158     unsigned char   SRB_Sectors;
159     unsigned char   SRB_Rsvd1[22];
160 };
161
162 struct SRB_GDEVBlock
163 {
164     unsigned char SRB_Cmd;
165     unsigned char SRB_Status;
166     unsigned char SRB_HaId;
167     unsigned char SRB_Flags;
168     unsigned long SRB_Hdr_Rsvd;
169     unsigned char SRB_Target;
170     unsigned char SRB_Lun;
171     unsigned char SRB_DeviceType;
172     unsigned char SRB_Rsvd1;
173 };
174
175 struct SRB_ExecSCSICmd
176 {
177     unsigned char   SRB_Cmd;
178     unsigned char   SRB_Status;
179     unsigned char   SRB_HaId;
180     unsigned char   SRB_Flags;
181     unsigned long   SRB_Hdr_Rsvd;
182     unsigned char   SRB_Target;
183     unsigned char   SRB_Lun;
184     unsigned short  SRB_Rsvd1;
185     unsigned long   SRB_BufLen;
186     unsigned char   *SRB_BufPointer;
187     unsigned char   SRB_SenseLen;
188     unsigned char   SRB_CDBLen;
189     unsigned char   SRB_HaStat;
190     unsigned char   SRB_TargStat;
191     unsigned long   *SRB_PostProc;
192     unsigned char   SRB_Rsvd2[20];
193     unsigned char   CDBByte[16];
194     unsigned char   SenseArea[SENSE_LEN+2];
195 };
196
197 #pragma pack()
198 #endif /* WIN32 */
199
200
201 /*****************************************************************************
202  * Local Prototypes
203  *****************************************************************************/
204 static int    OpenVCDImage( vlc_object_t *, const char *, struct vcddev_s * );
205 static void   CloseVCDImage( vlc_object_t *, struct vcddev_s * );
206
207 #if defined( __APPLE__ )
208 static CDTOC *darwin_getTOC( vlc_object_t *, const struct vcddev_s * );
209 static int    darwin_getNumberOfTracks( CDTOC *, int );
210
211 #elif defined( WIN32 )
212 static int    win32_vcd_open( vlc_object_t *, const char *, struct vcddev_s *);
213 #endif