]> git.sesse.net Git - vlc/blob - plugins/dvd/dvd_ioctl.h
b142d50586d6f933bd98e70bc30c638228f385dc
[vlc] / plugins / dvd / dvd_ioctl.h
1 /*****************************************************************************
2  * dvd_ioctl.h: DVD ioctl replacement function
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: dvd_ioctl.h,v 1.9 2001/05/31 03:12:49 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 int ioctl_ReadCopyright     ( int, int, int * );
25 int ioctl_ReadKey           ( int, int *, u8 * );
26
27 int ioctl_ReportAgid        ( int, int * );
28 int ioctl_ReportChallenge   ( int, int *, u8 * );
29 int ioctl_ReportKey1        ( int, int *, u8 * );
30 int ioctl_ReportASF         ( int, int *, int * );
31 int ioctl_InvalidateAgid    ( int, int * );
32 int ioctl_SendChallenge     ( int, int *, u8 * );
33 int ioctl_SendKey2          ( int, int *, u8 * );
34
35 /*****************************************************************************
36  * Common macro, BeOS specific
37  *****************************************************************************/
38 #if defined( SYS_BEOS )
39 #define INIT_RDC( TYPE, SIZE ) \
40     raw_device_command rdc; \
41     u8 p_buffer[ (SIZE) ]; \
42     memset( &rdc, 0, sizeof( raw_device_command ) ); \
43     rdc.data = (char *)p_buffer; \
44     rdc.data_length = (SIZE); \
45     BeInitRDC( &rdc, (TYPE) );
46 #endif
47
48 /*****************************************************************************
49  * Common macro, Darwin specific
50  *****************************************************************************/
51 #if defined( SYS_DARWIN1_3 )
52 #define INIT_DVDIOCTL( SIZE ) \
53     dvdioctl_data_t dvdioctl; \
54     u8 p_buffer[ (SIZE) ]; \
55     dvdioctl.p_buffer = p_buffer; \
56     dvdioctl.i_size = (SIZE); \
57     dvdioctl.i_keyclass = kCSS_CSS2_CPRM; \
58     memset( p_buffer, 0, (SIZE) );
59 #endif
60
61 /*****************************************************************************
62  * Various DVD I/O tables
63  *****************************************************************************/
64
65 #if defined( SYS_BEOS ) || defined( WIN32 )
66
67 /* The generic packet command opcodes for CD/DVD Logical Units,
68  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
69 #define GPCMD_READ_DVD_STRUCTURE 0xad
70 #define GPCMD_REPORT_KEY         0xa4
71 #define GPCMD_SEND_KEY           0xa3
72
73 /* DVD struct types */
74 #define DVD_STRUCT_COPYRIGHT     0x01
75 #define DVD_STRUCT_DISCKEY       0x02
76 #endif
77
78 #if defined( WIN32 )
79
80 #define IOCTL_DVD_START_SESSION         CTL_CODE(FILE_DEVICE_DVD, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
81 #define IOCTL_DVD_READ_KEY              CTL_CODE(FILE_DEVICE_DVD, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
82 #define IOCTL_DVD_SEND_KEY              CTL_CODE(FILE_DEVICE_DVD, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
83 #define IOCTL_DVD_END_SESSION           CTL_CODE(FILE_DEVICE_DVD, 0x0403, METHOD_BUFFERED, FILE_READ_ACCESS)
84
85 #define IOCTL_SCSI_PASS_THROUGH_DIRECT  CTL_CODE(FILE_DEVICE_CONTROLLER, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
86
87 #define DVD_CHALLENGE_KEY_LENGTH    (12 + sizeof(DVD_COPY_PROTECT_KEY))
88 #define DVD_BUS_KEY_LENGTH          (8 + sizeof(DVD_COPY_PROTECT_KEY))
89 #define DVD_DISK_KEY_LENGTH         (2048 + sizeof(DVD_COPY_PROTECT_KEY))
90 #define DVD_ASF_LENGTH              (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
91
92 typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
93
94 typedef enum
95 {
96     DvdChallengeKey = 0x01,
97     DvdBusKey1,
98     DvdBusKey2,
99     DvdTitleKey,
100     DvdAsf,
101     DvdSetRpcKey = 0x6,
102     DvdGetRpcKey = 0x8,
103     DvdDiskKey = 0x80,
104     DvdInvalidateAGID = 0x3f
105 } DVD_KEY_TYPE;
106
107 typedef struct _DVD_COPY_PROTECT_KEY
108 {
109     ULONG KeyLength;
110     DVD_SESSION_ID SessionId;
111     DVD_KEY_TYPE KeyType;
112     ULONG KeyFlags;
113     union
114     {
115         struct
116         {
117             ULONG FileHandle;
118             ULONG Reserved;   // used for NT alignment
119         };
120         LARGE_INTEGER TitleOffset;
121     } Parameters;
122     UCHAR KeyData[0];
123 } DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY;
124
125 typedef struct _DVD_ASF
126 {
127     UCHAR Reserved0[3];
128     UCHAR SuccessFlag:1;
129     UCHAR Reserved1:7;
130 } DVD_ASF, * PDVD_ASF;
131
132 typedef struct _SCSI_PASS_THROUGH_DIRECT
133 {
134     USHORT Length;
135     UCHAR ScsiStatus;
136     UCHAR PathId;
137     UCHAR TargetId;
138     UCHAR Lun;
139     UCHAR CdbLength;
140     UCHAR SenseInfoLength;
141     UCHAR DataIn;
142     ULONG DataTransferLength;
143     ULONG TimeOutValue;
144     PVOID DataBuffer;
145     ULONG SenseInfoOffset;
146     UCHAR Cdb[16];
147 } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
148
149 #define SCSI_IOCTL_DATA_OUT         0
150 #define SCSI_IOCTL_DATA_IN          1
151
152 /* Key formats */
153 #define DVD_REPORT_AGID          0x00
154 #define DVD_REPORT_CHALLENGE     0x01
155 #define DVD_SEND_CHALLENGE       0x01
156 #define DVD_REPORT_KEY1          0x02
157 #define DVD_SEND_KEY2            0x03
158 #define DVD_REPORT_ASF           0x05
159 #define DVD_INVALIDATE_AGID      0x3f
160
161 #endif
162