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 $
7 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
24 int ioctl_ReadCopyright ( int, int, int * );
25 int ioctl_ReadKey ( int, int *, u8 * );
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 * );
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) );
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) );
61 /*****************************************************************************
62 * Various DVD I/O tables
63 *****************************************************************************/
65 #if defined( SYS_BEOS ) || defined( WIN32 )
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
73 /* DVD struct types */
74 #define DVD_STRUCT_COPYRIGHT 0x01
75 #define DVD_STRUCT_DISCKEY 0x02
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)
85 #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(FILE_DEVICE_CONTROLLER, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
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))
92 typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
96 DvdChallengeKey = 0x01,
104 DvdInvalidateAGID = 0x3f
107 typedef struct _DVD_COPY_PROTECT_KEY
110 DVD_SESSION_ID SessionId;
111 DVD_KEY_TYPE KeyType;
118 ULONG Reserved; // used for NT alignment
120 LARGE_INTEGER TitleOffset;
123 } DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY;
125 typedef struct _DVD_ASF
130 } DVD_ASF, * PDVD_ASF;
132 typedef struct _SCSI_PASS_THROUGH_DIRECT
140 UCHAR SenseInfoLength;
142 ULONG DataTransferLength;
145 ULONG SenseInfoOffset;
147 } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
149 #define SCSI_IOCTL_DATA_OUT 0
150 #define SCSI_IOCTL_DATA_IN 1
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