annotate libmpdvdkit2/ioctl.c @ 7994:458992506962

disabling compilation of .so if its not needed, gcc 3.1 seems to have problems with it
author michael
date Thu, 31 Oct 2002 10:21:44 +0000
parents c9a4dfaa9868
children fd991102dd60
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7027
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
2 * ioctl.c: DVD ioctl replacement function
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
3 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
4 * Copyright (C) 1999-2001 VideoLAN
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
5 * $Id$
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
6 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
7 * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
8 * Samuel Hocevar <sam@zoy.org>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
9 * Jon Lech Johansen <jon-vl@nanocrew.net>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
10 * Håkan Hjort <d95hjort@dtek.chalmers.se>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
11 * Eugenio Jarosiewicz <ej0@cise.ufl.edu>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
12 * David Siebörger <drs-videolan@rucus.ru.ac.za>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
13 * Alex Strelnikov <lelik@os2.ru>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
14 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
15 * This program is free software; you can redistribute it and/or modify
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
16 * it under the terms of the GNU General Public License as published by
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
17 * the Free Software Foundation; either version 2 of the License, or
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
18 * (at your option) any later version.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
19 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
20 * This program is distributed in the hope that it will be useful,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
23 * GNU General Public License for more details.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
24 *
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
25 * You should have received a copy of the GNU General Public License
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
26 * along with this program; if not, write to the Free Software
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
28 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
29
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
30 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
31 * Preamble
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
32 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
33 #include "config.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
34
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
35 #include <stdio.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
36
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
37 #include <string.h> /* memcpy(), memset() */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
38 #include <sys/types.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
39
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
40 #if defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
41 # include <windows.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
42 # include <winioctl.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
43 #elif defined ( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
44 # define INCL_DOSFILEMGR
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
45 # define INCL_DOSDEVICES
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
46 # define INCL_DOSDEVIOCTL
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
47 # define INCL_DOSERRORS
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
48 # include <os2.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
49 # include <sys/ioctl.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
50 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
51 # include <netinet/in.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
52 # include <sys/ioctl.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
53 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
54
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
55 #ifdef DVD_STRUCT_IN_SYS_CDIO_H
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
56 # include <sys/cdio.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
57 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
58 #ifdef DVD_STRUCT_IN_SYS_DVDIO_H
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
59 # include <sys/dvdio.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
60 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
61 #ifdef DVD_STRUCT_IN_LINUX_CDROM_H
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
62 # include <linux/cdrom.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
63 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
64 #ifdef DVD_STRUCT_IN_DVD_H
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
65 # include <dvd.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
66 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
67 #ifdef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
68 # include "bsdi_dvd.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
69 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
70 #ifdef SYS_BEOS
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
71 # include <malloc.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
72 # include <scsi.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
73 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
74 #ifdef HPUX_SCTL_IO
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
75 # include <sys/scsi.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
76 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
77 #ifdef SOLARIS_USCSI
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
78 # include <unistd.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
79 # include <stropts.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
80 # include <sys/scsi/scsi_types.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
81 # include <sys/scsi/impl/uscsi.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
82 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
83 #ifdef DARWIN_DVD_IOCTL
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
84 # include <IOKit/storage/IODVDMediaBSDClient.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
85 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
86 #ifdef __QNXNTO__
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
87 # include <sys/mman.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
88 # include <sys/dcmd_cam.h>
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
89 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
90
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
91 #include "common.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
92
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
93 #include "ioctl.h"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
94
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
95 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
96 * Local prototypes, BeOS specific
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
97 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
98 #if defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
99 static void BeInitRDC ( raw_device_command *, int );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
100 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
101
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
102 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
103 * Local prototypes, HP-UX specific
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
104 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
105 #if defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
106 static void HPUXInitSCTL ( struct sctl_io *sctl_io, int i_type );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
107 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
108
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
109 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
110 * Local prototypes, Solaris specific
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
111 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
112 #if defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
113 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
114 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
115
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
116 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
117 * Local prototypes, win32 (aspi) specific
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
118 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
119 #if defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
120 static void WinInitSSC ( struct SRB_ExecSCSICmd *, int );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
121 static int WinSendSSC ( int, struct SRB_ExecSCSICmd * );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
122 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
123
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
124 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
125 * Local prototypes, QNX specific
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
126 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
127 #if defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
128 static void QNXInitCPT ( CAM_PASS_THRU *, int );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
129 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
130
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
131 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
132 * Local prototypes, OS2 specific
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
133 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
134 #if defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
135 static void OS2InitSDC( struct OS2_ExecSCSICmd *, int );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
136 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
137
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
138 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
139 * ioctl_ReadCopyright: check whether the disc is encrypted or not
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
140 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
141 int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
142 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
143 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
144
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
145 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
146 dvd_struct dvd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
147
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
148 memset( &dvd, 0, sizeof( dvd ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
149 dvd.type = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
150 dvd.copyright.layer_num = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
151
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
152 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
153
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
154 *pi_copyright = dvd.copyright.cpst;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
155
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
156 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
157 struct dvd_struct dvd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
158
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
159 memset( &dvd, 0, sizeof( dvd ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
160 dvd.format = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
161 dvd.layer_num = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
162
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
163 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
164
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
165 *pi_copyright = dvd.cpst;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
166
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
167 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
168 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
169
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
170 rdc.command[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
171 rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
172
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
173 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
174
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
175 *pi_copyright = p_buffer[ 4 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
176
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
177 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
178 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
179
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
180 sctl_io.cdb[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
181 sctl_io.cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
182
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
183 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
184
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
185 *pi_copyright = p_buffer[ 4 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
186
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
187 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
188 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
189
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
190 rs_cdb.cdb_opaque[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
191 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
192
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
193 i_ret = ioctl(i_fd, USCSICMD, &sc);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
194
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
195 if( i_ret < 0 || sc.uscsi_status ) {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
196 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
197 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
198
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
199 *pi_copyright = p_buffer[ 4 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
200 /* s->copyright.rmi = p_buffer[ 5 ]; */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
201
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
202 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
203 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDCopyrightInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
204 kDVDStructureFormatCopyrightInfo );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
205
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
206 dvd.layer = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
207
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
208 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
209
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
210 *pi_copyright = dvdbs.copyrightProtectionSystemType;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
211
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
212 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
213 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
214 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
215 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
216 u8 p_buffer[ 8 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
217 SCSI_PASS_THROUGH_DIRECT sptd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
218
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
219 memset( &sptd, 0, sizeof( sptd ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
220 memset( &p_buffer, 0, sizeof( p_buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
221
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
222 /* When using IOCTL_DVD_READ_STRUCTURE and
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
223 DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
224 is always 6. So we send a raw scsi command instead. */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
225
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
226 sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
227 sptd.CdbLength = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
228 sptd.DataIn = SCSI_IOCTL_DATA_IN;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
229 sptd.DataTransferLength = 8;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
230 sptd.TimeOutValue = 2;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
231 sptd.DataBuffer = p_buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
232 sptd.Cdb[ 0 ] = GPCMD_READ_DVD_STRUCTURE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
233 sptd.Cdb[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
234 sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
235 sptd.Cdb[ 8 ] = (8 >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
236 sptd.Cdb[ 9 ] = 8 & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
237
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
238 i_ret = DeviceIoControl( (HANDLE) i_fd,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
239 IOCTL_SCSI_PASS_THROUGH_DIRECT,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
240 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
241 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
242 &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
243
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
244 *pi_copyright = p_buffer[ 4 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
245 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
246 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
247 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
248 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
249
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
250 ssc.CDBByte[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
251 ssc.CDBByte[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
252
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
253 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
254
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
255 *pi_copyright = p_buffer[ 4 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
256 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
257
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
258 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
259
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
260 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
261
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
262 p_cpt->cam_cdb[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
263 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
264
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
265 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
266
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
267 *pi_copyright = p_buffer[4];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
268
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
269 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
270 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
271
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
272 sdc.command[ 6 ] = i_layer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
273 sdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
274
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
275 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
276 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
277 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
278
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
279 *pi_copyright = p_buffer[ 4 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
280
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
281 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
282 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
283
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
284 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
285 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
286 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
287
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
288 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
289 * ioctl_ReadDiscKey: get the disc key
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
290 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
291 int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
292 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
293 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
294
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
295 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
296 dvd_struct dvd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
297
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
298 memset( &dvd, 0, sizeof( dvd ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
299 dvd.type = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
300 dvd.disckey.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
301 memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
302
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
303 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
304
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
305 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
306 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
307 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
308 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
309
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
310 memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
311
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
312 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
313 struct dvd_struct dvd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
314
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
315 memset( &dvd, 0, sizeof( dvd ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
316 dvd.format = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
317 dvd.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
318 memset( dvd.data, 0, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
319
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
320 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
321
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
322 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
323 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
324 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
325 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
326
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
327 memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
328
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
329 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
330 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
331
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
332 rdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
333 rdc.command[ 10 ] = *pi_agid << 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
334
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
335 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
336
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
337 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
338 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
339 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
340 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
341
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
342 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
343
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
344 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
345 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
346
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
347 sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
348 sctl_io.cdb[ 10 ] = *pi_agid << 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
349
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
350 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
351
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
352 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
353 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
354 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
355 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
356
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
357 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
358
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
359 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
360 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
361
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
362 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
363 rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
364
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
365 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
366
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
367 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
368 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
369 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
370 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
371 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
372
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
373 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
374
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
375 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
376 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDDiscKeyInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
377 kDVDStructureFormatDiscKeyInfo );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
378
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
379 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
380
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
381 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
382
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
383 memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
384
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
385 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
386 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
387 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
388 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
389 u8 buffer[DVD_DISK_KEY_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
390 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
391
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
392 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
393
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
394 key->KeyLength = DVD_DISK_KEY_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
395 key->SessionId = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
396 key->KeyType = DvdDiskKey;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
397 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
398
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
399 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
400 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
401
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
402 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
403 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
404 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
405 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
406
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
407 memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
408 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
409 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
410 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
411 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
412
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
413 ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
414 ssc.CDBByte[ 10 ] = *pi_agid << 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
415
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
416 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
417
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
418 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
419 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
420 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
421 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
422
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
423 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
424 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
425
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
426 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
427
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
428 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
429
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
430 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
431 p_cpt->cam_cdb[ 10 ] = *pi_agid << 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
432
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
433 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
434
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
435 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
436
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
437 #elif defined ( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
438 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
439
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
440 sdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
441 sdc.command[ 10 ] = *pi_agid << 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
442
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
443 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
444 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
445 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
446
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
447 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
448 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
449 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
450 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
451
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
452 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
453
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
454 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
455 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
456
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
457 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
458 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
459 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
460
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
461 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
462 * ioctl_ReadTitleKey: get the title key
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
463 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
464 int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
465 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
466 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
467
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
468 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
469 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
470
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
471 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
472 auth_info.type = DVD_LU_SEND_TITLE_KEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
473 auth_info.lstk.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
474 auth_info.lstk.lba = i_pos;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
475
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
476 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
477
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
478 memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
479
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
480 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
481 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
482
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
483 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
484 auth_info.format = DVD_REPORT_TITLE_KEY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
485 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
486 auth_info.lba = i_pos;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
487
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
488 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
489
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
490 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
491
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
492 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
493 INIT_RDC( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
494
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
495 rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
496 rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
497 rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
498 rdc.command[ 5 ] = ( i_pos ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
499 rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
500
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
501 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
502
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
503 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
504
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
505 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
506 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
507
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
508 sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
509 sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
510 sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
511 sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
512 sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
513
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
514 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
515
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
516 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
517
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
518 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
519 INIT_USCSI( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
520
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
521 rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
522 rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
523 rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
524 rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
525 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
526
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
527 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
528
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
529 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
530 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
531 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
532 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
533
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
534 /* Do we want to return the cp_sec flag perhaps? */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
535 /* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
536 /* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
537 /* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
538
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
539 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
540
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
541 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
542 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDTitleKeyInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
543 kDVDKeyFormatTitleKey );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
544
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
545 dvd.address = i_pos;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
546 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
547 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
548
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
549 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
550
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
551 memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
552
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
553 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
554 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
555 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
556 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
557 u8 buffer[DVD_BUS_KEY_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
558 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
559
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
560 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
561
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
562 key->KeyLength = DVD_TITLE_KEY_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
563 key->SessionId = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
564 key->KeyType = DvdTitleKey;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
565 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
566 key->Parameters.TitleOffset.QuadPart = (LONGLONG) i_pos;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
567
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
568 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
569 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
570
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
571 memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
572 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
573 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
574 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
575 INIT_SSC( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
576
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
577 ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
578 ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
579 ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
580 ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
581 ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
582
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
583 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
584
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
585 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
586 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
587
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
588 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
589
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
590 INIT_CPT( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
591
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
592 p_cpt->cam_cdb[ 2 ] = ( i_pos >> 24 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
593 p_cpt->cam_cdb[ 3 ] = ( i_pos >> 16 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
594 p_cpt->cam_cdb[ 4 ] = ( i_pos >> 8 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
595 p_cpt->cam_cdb[ 5 ] = ( i_pos ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
596 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
597
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
598 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
599
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
600 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
601
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
602 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
603 INIT_SSC( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
604
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
605 sdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
606 sdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
607 sdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
608 sdc.command[ 5 ] = ( i_pos ) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
609 sdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
610
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
611 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
612 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
613 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
614
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
615 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
616
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
617 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
618 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
619
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
620 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
621
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
622 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
623 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
624
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
625
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
626 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
627 * ioctl_ReportAgid: get AGID from the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
628 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
629 int ioctl_ReportAgid( int i_fd, int *pi_agid )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
630 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
631 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
632
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
633 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
634 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
635
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
636 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
637 auth_info.type = DVD_LU_SEND_AGID;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
638 auth_info.lsa.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
639
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
640 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
641
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
642 *pi_agid = auth_info.lsa.agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
643
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
644 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
645 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
646
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
647 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
648 auth_info.format = DVD_REPORT_AGID;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
649 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
650
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
651 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
652
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
653 *pi_agid = auth_info.agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
654
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
655 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
656 INIT_RDC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
657
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
658 rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
659
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
660 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
661
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
662 *pi_agid = p_buffer[ 7 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
663
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
664 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
665 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
666
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
667 sctl_io.cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
668
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
669 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
670
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
671 *pi_agid = p_buffer[ 7 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
672
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
673 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
674 INIT_USCSI( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
675
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
676 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
677
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
678 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
679
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
680 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
681 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
682 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
683 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
684
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
685 *pi_agid = p_buffer[ 7 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
686
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
687 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
688 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationGrantIDInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
689 kDVDKeyFormatAGID_CSS );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
690
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
691 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
692 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
693
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
694 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
695
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
696 *pi_agid = dvdbs.grantID;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
697
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
698 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
699 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
700 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
701 ULONG id;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
702 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
703
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
704 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
705 &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
706
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
707 *pi_agid = id;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
708 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
709 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
710 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
711 INIT_SSC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
712
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
713 ssc.CDBByte[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
714
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
715 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
716
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
717 *pi_agid = p_buffer[ 7 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
718 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
719
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
720 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
721
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
722 INIT_CPT( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
723
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
724 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
725
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
726 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
727
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
728 *pi_agid = p_buffer[ 7 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
729
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
730 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
731 INIT_SSC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
732
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
733 sdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
734
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
735 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
736 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
737 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
738
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
739 *pi_agid = p_buffer[ 7 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
740
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
741 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
742 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
743
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
744 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
745 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
746 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
747
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
748 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
749 * ioctl_ReportChallenge: get challenge from the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
750 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
751 int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
752 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
753 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
754
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
755 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
756 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
757
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
758 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
759 auth_info.type = DVD_LU_SEND_CHALLENGE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
760 auth_info.lsc.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
761
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
762 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
763
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
764 memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
765
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
766 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
767 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
768
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
769 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
770 auth_info.format = DVD_REPORT_CHALLENGE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
771 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
772
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
773 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
774
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
775 memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
776
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
777 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
778 INIT_RDC( GPCMD_REPORT_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
779
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
780 rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
781
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
782 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
783
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
784 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
785
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
786 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
787 INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
788
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
789 sctl_io.cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
790
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
791 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
792
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
793 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
794
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
795 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
796 INIT_USCSI( GPCMD_REPORT_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
797
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
798 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
799
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
800 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
801
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
802 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
803 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
804 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
805 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
806
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
807 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
808
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
809 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
810 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDChallengeKeyInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
811 kDVDKeyFormatChallengeKey );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
812
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
813 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
814
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
815 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
816
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
817 memcpy( p_challenge, dvdbs.challengeKeyValue, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
818
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
819 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
820 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
821 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
822 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
823 u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
824 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
825
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
826 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
827
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
828 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
829 key->SessionId = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
830 key->KeyType = DvdChallengeKey;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
831 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
832
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
833 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
834 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
835
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
836 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
837 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
838 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
839 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
840
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
841 memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
842 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
843 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
844 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
845 INIT_SSC( GPCMD_REPORT_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
846
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
847 ssc.CDBByte[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
848
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
849 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
850
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
851 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
852 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
853
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
854 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
855
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
856 INIT_CPT( GPCMD_REPORT_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
857
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
858 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
859
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
860 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
861
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
862 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
863
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
864 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
865 INIT_SSC( GPCMD_REPORT_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
866
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
867 sdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
868
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
869 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
870 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
871 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
872
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
873 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
874
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
875 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
876 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
877
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
878 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
879 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
880 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
881
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
882 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
883 * ioctl_ReportASF: get ASF from the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
884 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
885 int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
886 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
887 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
888
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
889 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
890 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
891
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
892 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
893 auth_info.type = DVD_LU_SEND_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
894 auth_info.lsasf.asf = *pi_asf;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
895
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
896 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
897
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
898 *pi_asf = auth_info.lsasf.asf;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
899
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
900 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
901 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
902
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
903 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
904 auth_info.format = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
905 auth_info.asf = *pi_asf;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
906
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
907 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
908
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
909 *pi_asf = auth_info.asf;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
910
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
911 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
912 INIT_RDC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
913
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
914 rdc.command[ 10 ] = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
915
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
916 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
917
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
918 *pi_asf = p_buffer[ 7 ] & 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
919
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
920 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
921 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
922
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
923 sctl_io.cdb[ 10 ] = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
924
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
925 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
926
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
927 *pi_asf = p_buffer[ 7 ] & 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
928
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
929 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
930 INIT_USCSI( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
931
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
932 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
933
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
934 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
935
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
936 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
937 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
938 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
939 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
940
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
941 *pi_asf = p_buffer[ 7 ] & 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
942
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
943 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
944 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationSuccessFlagInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
945 kDVDKeyFormatASF );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
946
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
947 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
948
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
949 *pi_asf = dvdbs.successFlag;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
950
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
951 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
952 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
953 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
954 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
955 u8 buffer[DVD_ASF_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
956 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
957
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
958 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
959
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
960 key->KeyLength = DVD_ASF_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
961 key->KeyType = DvdAsf;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
962 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
963
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
964 ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
965
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
966 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
967 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
968
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
969 if( i_ret < 0 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
970 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
971 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
972 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
973
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
974 *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
975 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
976 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
977 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
978 INIT_SSC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
979
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
980 ssc.CDBByte[ 10 ] = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
981
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
982 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
983
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
984 *pi_asf = p_buffer[ 7 ] & 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
985 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
986
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
987 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
988
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
989 INIT_CPT( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
990
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
991 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
992
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
993 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
994
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
995 *pi_asf = p_buffer[ 7 ] & 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
996
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
997 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
998 INIT_SSC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
999
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1000 sdc.command[ 10 ] = DVD_REPORT_ASF;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1001
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1002 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1003 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1004 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1005
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1006 *pi_asf = p_buffer[ 7 ] & 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1007
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1008 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1009 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1010
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1011 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1012 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1013 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1014
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1015 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1016 * ioctl_ReportKey1: get the first key from the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1017 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1018 int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1019 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1020 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1021
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1022 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1023 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1024
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1025 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1026 auth_info.type = DVD_LU_SEND_KEY1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1027 auth_info.lsk.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1028
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1029 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1030
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1031 memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1032
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1033 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1034 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1035
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1036 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1037 auth_info.format = DVD_REPORT_KEY1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1038 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1039
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1040 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1041
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1042 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1043
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1044 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1045 INIT_RDC( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1046
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1047 rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1048
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1049 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1050
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1051 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1052
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1053 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1054 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1055
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1056 sctl_io.cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1057
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1058 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1059
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1060 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1061
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1062 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1063 INIT_USCSI( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1064
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1065 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1066
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1067 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1068
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1069 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1070 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1071 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1072 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1073
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1074 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1075
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1076 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1077 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDKey1Info,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1078 kDVDKeyFormatKey1 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1079
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1080 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1081
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1082 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1083
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1084 memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1085
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1086 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1087 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1088 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1089 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1090 u8 buffer[DVD_BUS_KEY_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1091 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1092
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1093 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1094
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1095 key->KeyLength = DVD_BUS_KEY_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1096 key->SessionId = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1097 key->KeyType = DvdBusKey1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1098 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1099
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1100 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1101 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1102
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1103 memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1104 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1105 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1106 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1107 INIT_SSC( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1108
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1109 ssc.CDBByte[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1110
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1111 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1112
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1113 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1114 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1115
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1116 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1117
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1118 INIT_CPT( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1119
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1120 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1121
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1122 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1123
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1124 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1125
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1126 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1127 INIT_SSC( GPCMD_REPORT_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1128
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1129 sdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1130
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1131 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1132 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1133 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1134
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1135 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1136
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1137 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1138 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1139
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1140 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1141 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1142 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1143
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1144 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1145 * ioctl_InvalidateAgid: invalidate the current AGID
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1146 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1147 int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1148 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1149 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1150
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1151 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1152 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1153
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1154 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1155 auth_info.type = DVD_INVALIDATE_AGID;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1156 auth_info.lsa.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1157
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1158 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1159
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1160 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1161 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1162
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1163 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1164 auth_info.format = DVD_INVALIDATE_AGID;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1165 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1166
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1167 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1168
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1169 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1170 INIT_RDC( GPCMD_REPORT_KEY, 0 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1171
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1172 rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1173
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1174 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1175
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1176 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1177 INIT_SCTL_IO( GPCMD_REPORT_KEY, 0 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1178
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1179 sctl_io.cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1180
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1181 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1182
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1183 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1184 INIT_USCSI( GPCMD_REPORT_KEY, 0 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1185
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1186 rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1187
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1188 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1189
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1190 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1191 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1192 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1193 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1194
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1195 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1196 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDAuthenticationGrantIDInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1197 kDVDKeyFormatAGID_Invalidate );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1198
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1199 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1200
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1201 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1202
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1203 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1204 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1205 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1206 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1207
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1208 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1209 pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1210 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1211 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1212 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1213 #if defined( __MINGW32__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1214 INIT_SSC( GPCMD_REPORT_KEY, 0 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1215 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1216 INIT_SSC( GPCMD_REPORT_KEY, 1 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1217
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1218 ssc.SRB_BufLen = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1219 ssc.CDBByte[ 8 ] = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1220 ssc.CDBByte[ 9 ] = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1221 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1222
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1223 ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1224
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1225 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1226 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1227
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1228 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1229
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1230 INIT_CPT( GPCMD_REPORT_KEY, 0 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1231
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1232 p_cpt->cam_cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1233
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1234 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1235
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1236 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1237 INIT_SSC( GPCMD_REPORT_KEY, 1 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1238
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1239 sdc.data_length = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1240 sdc.command[ 8 ] = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1241 sdc.command[ 9 ] = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1242
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1243 sdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1244
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1245 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1246 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1247 NULL, 0, &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1248 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1249 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1250
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1251 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1252 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1253 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1254
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1255 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1256 * ioctl_SendChallenge: send challenge to the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1257 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1258 int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1259 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1260 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1261
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1262 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1263 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1264
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1265 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1266 auth_info.type = DVD_HOST_SEND_CHALLENGE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1267 auth_info.hsc.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1268
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1269 memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1270
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1271 return ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1272
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1273 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1274 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1275
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1276 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1277 auth_info.format = DVD_SEND_CHALLENGE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1278 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1279
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1280 memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1281
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1282 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1283
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1284 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1285 INIT_RDC( GPCMD_SEND_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1286
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1287 rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1288
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1289 p_buffer[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1290 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1291
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1292 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1293
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1294 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1295 INIT_SCTL_IO( GPCMD_SEND_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1296
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1297 sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1298
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1299 p_buffer[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1300 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1301
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1302 return ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1303
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1304 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1305 INIT_USCSI( GPCMD_SEND_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1306
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1307 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1308
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1309 p_buffer[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1310 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1311
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1312 if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1313 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1314 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1315 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1316
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1317 return 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1318
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1319 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1320 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDChallengeKeyInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1321 kDVDKeyFormatChallengeKey );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1322
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1323 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1324 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1325
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1326 dvdbs.dataLength[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1327 memcpy( dvdbs.challengeKeyValue, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1328
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1329 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1330
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1331 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1332 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1333 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1334 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1335 u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1336 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1337
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1338 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1339
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1340 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1341 key->SessionId = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1342 key->KeyType = DvdChallengeKey;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1343 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1344
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1345 memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1346
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1347 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1348 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1349 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1350 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1351 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1352 INIT_SSC( GPCMD_SEND_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1353
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1354 ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1355
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1356 p_buffer[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1357 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1358
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1359 return WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1360 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1361
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1362 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1363
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1364 INIT_CPT( GPCMD_SEND_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1365
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1366 p_cpt->cam_cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1367
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1368 p_buffer[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1369 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1370
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1371 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1372
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1373 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1374 INIT_SSC( GPCMD_SEND_KEY, 16 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1375
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1376 sdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1377
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1378 p_buffer[ 1 ] = 0xe;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1379 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1380
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1381 return DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1382 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1383 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1384
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1385 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1386 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1387
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1388 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1389 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1390 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1391
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1392 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1393 * ioctl_SendKey2: send the second key to the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1394 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1395 int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1396 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1397 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1398
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1399 #if defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1400 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1401
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1402 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1403 auth_info.type = DVD_HOST_SEND_KEY2;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1404 auth_info.hsk.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1405
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1406 memcpy( auth_info.hsk.key, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1407
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1408 return ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1409
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1410 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1411 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1412
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1413 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1414 auth_info.format = DVD_SEND_KEY2;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1415 auth_info.agid = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1416
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1417 memcpy( auth_info.keychal, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1418
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1419 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1420
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1421 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1422 INIT_RDC( GPCMD_SEND_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1423
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1424 rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1425
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1426 p_buffer[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1427 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1428
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1429 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1430
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1431 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1432 INIT_SCTL_IO( GPCMD_SEND_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1433
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1434 sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1435
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1436 p_buffer[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1437 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1438
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1439 return ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1440
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1441 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1442 INIT_USCSI( GPCMD_SEND_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1443
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1444 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1445
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1446 p_buffer[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1447 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1448
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1449 if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1450 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1451 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1452 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1453
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1454 return 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1455
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1456 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1457 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDKey2Info,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1458 kDVDKeyFormatKey2 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1459
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1460 dvd.grantID = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1461 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1462
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1463 dvdbs.dataLength[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1464 memcpy( dvdbs.key2Value, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1465
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1466 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1467
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1468 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1469 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1470 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1471 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1472 u8 buffer[DVD_BUS_KEY_LENGTH];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1473 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1474
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1475 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1476
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1477 key->KeyLength = DVD_BUS_KEY_LENGTH;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1478 key->SessionId = *pi_agid;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1479 key->KeyType = DvdBusKey2;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1480 key->KeyFlags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1481
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1482 memcpy( key->KeyData, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1483
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1484 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1485 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1486 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1487 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1488 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1489 INIT_SSC( GPCMD_SEND_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1490
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1491 ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1492
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1493 p_buffer[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1494 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1495
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1496 return WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1497 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1498
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1499 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1500
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1501 INIT_CPT( GPCMD_SEND_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1502
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1503 p_cpt->cam_cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1504
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1505 p_buffer[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1506 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1507
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1508 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1509
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1510 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1511 INIT_SSC( GPCMD_SEND_KEY, 12 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1512
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1513 sdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1514
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1515 p_buffer[ 1 ] = 0xa;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1516 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1517
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1518 return DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1519 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1520 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1521
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1522 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1523 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1524
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1525 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1526 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1527 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1528
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1529 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1530 * ioctl_ReportRPC: get RPC status for the drive
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1531 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1532 int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1533 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1534 int i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1535
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1536 #if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_LU_SEND_RPC_STATE )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1537 dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1538
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1539 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1540 auth_info.type = DVD_LU_SEND_RPC_STATE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1541
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1542 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1543
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1544 *p_type = auth_info.lrpcs.type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1545 *p_mask = auth_info.lrpcs.region_mask;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1546 *p_scheme = auth_info.lrpcs.rpc_scheme;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1547
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1548 #elif defined( HAVE_LINUX_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1549 /* FIXME: OpenBSD doesn't know this */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1550 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1551
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1552 #elif defined( HAVE_BSD_DVD_STRUCT )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1553 struct dvd_authinfo auth_info;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1554
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1555 memset( &auth_info, 0, sizeof( auth_info ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1556 auth_info.format = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1557
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1558 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1559
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1560 *p_type = auth_info.reg_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1561 *p_mask = auth_info.region; // ??
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1562 *p_scheme = auth_info.rpc_scheme;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1563
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1564 #elif defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1565 INIT_RDC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1566
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1567 rdc.command[ 10 ] = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1568
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1569 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1570
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1571 *p_type = p_buffer[ 4 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1572 *p_mask = p_buffer[ 5 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1573 *p_scheme = p_buffer[ 6 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1574
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1575 #elif defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1576 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1577
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1578 sctl_io.cdb[ 10 ] = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1579
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1580 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1581
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1582 *p_type = p_buffer[ 4 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1583 *p_mask = p_buffer[ 5 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1584 *p_scheme = p_buffer[ 6 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1585
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1586 #elif defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1587 INIT_USCSI( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1588
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1589 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1590
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1591 i_ret = ioctl( i_fd, USCSICMD, &sc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1592
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1593 if( i_ret < 0 || sc.uscsi_status )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1594 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1595 i_ret = -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1596 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1597
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1598 *p_type = p_buffer[ 4 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1599 *p_mask = p_buffer[ 5 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1600 *p_scheme = p_buffer[ 6 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1601
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1602 #elif defined( DARWIN_DVD_IOCTL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1603 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDRegionPlaybackControlInfo,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1604 kDVDKeyFormatRegionState );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1605
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1606 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1607
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1608 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1609
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1610 *p_type = dvdbs.typeCode;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1611 *p_mask = dvdbs.driveRegion;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1612 *p_scheme = dvdbs.rpcScheme;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1613
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1614 #elif defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1615 if( WIN2K ) /* NT/Win2000/Whistler */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1616 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1617 DWORD tmp;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1618 u8 buffer[ DVD_REGION_LENGTH ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1619 PDVD_REGION region = (PDVD_REGION) &buffer;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1620
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1621 memset( &buffer, 0, sizeof( buffer ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1622
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1623 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_GET_REGION, NULL, 0,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1624 region, DVD_REGION_LENGTH, &tmp, NULL ) ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1625
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1626 /* Someone who has the headers should correct all this. */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1627 /* Use the IOCTL_SCSI_PASS_THROUGH_DIRECT so we get the real
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1628 * values of theses entities? */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1629 if(region->SystemRegion != 0) {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1630 *p_type = region->ResetCount > 1 ? 1 : 3 - region->ResetCount;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1631 *p_mask = 0xff ^ (1 << (region->SystemRegion - 1));
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1632 *p_scheme = 1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1633 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1634 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1635 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1636 *p_type = 0; /* ?? */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1637 *p_mask = 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1638 *p_scheme = 1; /* ?? */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1639 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1640 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1641 else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1642 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1643 INIT_SSC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1644
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1645 ssc.CDBByte[ 10 ] = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1646
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1647 i_ret = WinSendSSC( i_fd, &ssc );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1648
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1649 *p_type = p_buffer[ 4 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1650 *p_mask = p_buffer[ 5 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1651 *p_scheme = p_buffer[ 6 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1652 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1653
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1654 #elif defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1655
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1656 INIT_CPT( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1657
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1658 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1659
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1660 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1661
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1662 *p_type = p_buffer[ 4 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1663 *p_mask = p_buffer[ 5 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1664 *p_scheme = p_buffer[ 6 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1665
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1666 #elif defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1667 INIT_SSC( GPCMD_REPORT_KEY, 8 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1668
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1669 sdc.command[ 10 ] = DVD_REPORT_RPC;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1670
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1671 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1672 &sdc, sizeof(sdc), &ulParamLen,
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1673 p_buffer, sizeof(p_buffer), &ulDataLen);
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1674
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1675 *p_type = p_buffer[ 4 ] >> 6;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1676 *p_mask = p_buffer[ 5 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1677 *p_scheme = p_buffer[ 6 ];
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1678
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1679 #else
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1680 # error "DVD ioctls are unavailable on this system"
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1681
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1682 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1683 return i_ret;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1684 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1685
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1686 /* Local prototypes */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1687
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1688 #if defined( SYS_BEOS )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1689 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1690 * BeInitRDC: initialize a RDC structure for the BeOS kernel
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1691 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1692 * This function initializes a BeOS raw device command structure for future
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1693 * use, either a read command or a write command.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1694 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1695 static void BeInitRDC( raw_device_command *p_rdc, int i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1696 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1697 memset( p_rdc->data, 0, p_rdc->data_length );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1698
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1699 switch( i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1700 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1701 case GPCMD_SEND_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1702 /* leave the flags to 0 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1703 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1704
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1705 case GPCMD_READ_DVD_STRUCTURE: case GPCMD_REPORT_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1706 p_rdc->flags = B_RAW_DEVICE_DATA_IN; break; }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1707
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1708 p_rdc->command[ 0 ] = i_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1709
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1710 p_rdc->command[ 8 ] = (p_rdc->data_length >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1711 p_rdc->command[ 9 ] = p_rdc->data_length & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1712 p_rdc->command_length = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1713
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1714 p_rdc->sense_data = NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1715 p_rdc->sense_data_length = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1716
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1717 p_rdc->timeout = 1000000;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1718 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1719 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1720
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1721 #if defined( HPUX_SCTL_IO )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1722 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1723 * HPUXInitSCTL: initialize a sctl_io structure for the HP-UX kernel
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1724 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1725 * This function initializes a HP-UX command structure for future
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1726 * use, either a read command or a write command.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1727 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1728 static void HPUXInitSCTL( struct sctl_io *sctl_io, int i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1729 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1730 memset( sctl_io->data, 0, sctl_io->data_length );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1731
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1732 switch( i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1733 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1734 case GPCMD_SEND_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1735 /* leave the flags to 0 */
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1736 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1737
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1738 case GPCMD_READ_DVD_STRUCTURE:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1739 case GPCMD_REPORT_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1740 sctl_io->flags = SCTL_READ;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1741 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1742 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1743
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1744 sctl_io->cdb[ 0 ] = i_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1745
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1746 sctl_io->cdb[ 8 ] = (sctl_io->data_length >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1747 sctl_io->cdb[ 9 ] = sctl_io->data_length & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1748 sctl_io->cdb_length = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1749
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1750 sctl_io->max_msecs = 1000000;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1751 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1752 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1753
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1754 #if defined( SOLARIS_USCSI )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1755 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1756 * SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1757 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1758 * This function initializes a Solaris userspace scsi command structure for
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1759 * future use, either a read command or a write command.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1760 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1761 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1762 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1763 union scsi_cdb *rs_cdb;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1764 memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1765 memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1766
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1767 switch( i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1768 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1769 case GPCMD_SEND_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1770 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_WRITE;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1771 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1772
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1773 case GPCMD_READ_DVD_STRUCTURE:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1774 case GPCMD_REPORT_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1775 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1776 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1777 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1778
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1779 rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1780
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1781 rs_cdb->scc_cmd = i_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1782
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1783 rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1784 rs_cdb->cdb_opaque[ 9 ] = p_sc->uscsi_buflen & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1785 p_sc->uscsi_cdblen = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1786
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1787 USCSI_TIMEOUT( p_sc, 15 );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1788 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1789 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1790
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1791 #if defined( WIN32 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1792 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1793 * WinInitSSC: initialize a ssc structure for the win32 aspi layer
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1794 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1795 * This function initializes a ssc raw device command structure for future
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1796 * use, either a read command or a write command.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1797 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1798 static void WinInitSSC( struct SRB_ExecSCSICmd *p_ssc, int i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1799 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1800 memset( p_ssc->SRB_BufPointer, 0, p_ssc->SRB_BufLen );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1801
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1802 switch( i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1803 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1804 case GPCMD_SEND_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1805 p_ssc->SRB_Flags = SRB_DIR_OUT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1806 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1807
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1808 case GPCMD_READ_DVD_STRUCTURE:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1809 case GPCMD_REPORT_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1810 p_ssc->SRB_Flags = SRB_DIR_IN;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1811 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1812 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1813
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1814 p_ssc->SRB_Cmd = SC_EXEC_SCSI_CMD;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1815 p_ssc->SRB_Flags |= SRB_EVENT_NOTIFY;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1816
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1817 p_ssc->CDBByte[ 0 ] = i_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1818
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1819 p_ssc->CDBByte[ 8 ] = (u8)(p_ssc->SRB_BufLen >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1820 p_ssc->CDBByte[ 9 ] = (u8) p_ssc->SRB_BufLen & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1821 p_ssc->SRB_CDBLen = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1822
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1823 p_ssc->SRB_SenseLen = SENSE_LEN;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1824 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1825
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1826 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1827 * WinSendSSC: send a ssc structure to the aspi layer
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1828 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1829 static int WinSendSSC( int i_fd, struct SRB_ExecSCSICmd *p_ssc )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1830 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1831 HANDLE hEvent = NULL;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1832 struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1833
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1834 hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1835 if( hEvent == NULL )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1836 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1837 return -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1838 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1839
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1840 p_ssc->SRB_PostProc = hEvent;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1841 p_ssc->SRB_HaId = LOBYTE( fd->i_sid );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1842 p_ssc->SRB_Target = HIBYTE( fd->i_sid );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1843
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1844 ResetEvent( hEvent );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1845 if( fd->lpSendCommand( (void*) p_ssc ) == SS_PENDING )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1846 WaitForSingleObject( hEvent, INFINITE );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1847
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1848 CloseHandle( hEvent );
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1849
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1850 return p_ssc->SRB_Status == SS_COMP ? 0 : -1;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1851 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1852 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1853
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1854 #if defined( __QNXNTO__ )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1855 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1856 * QNXInitCPT: initialize a ssc structure for the win32 aspi layer
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1857 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1858 * This function initializes a ssc raw device command structure for future
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1859 * use, either a read command or a write command.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1860 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1861 static void QNXInitCPT( CAM_PASS_THRU * p_cpt, int i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1862 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1863 switch( i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1864 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1865 case GPCMD_SEND_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1866 p_cpt->cam_flags = CAM_DIR_OUT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1867 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1868
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1869 case GPCMD_READ_DVD_STRUCTURE:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1870 case GPCMD_REPORT_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1871 p_cpt->cam_flags = CAM_DIR_IN;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1872 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1873 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1874
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1875 p_cpt->cam_cdb[0] = i_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1876
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1877 p_cpt->cam_cdb[ 8 ] = (p_cpt->cam_dxfer_len >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1878 p_cpt->cam_cdb[ 9 ] = p_cpt->cam_dxfer_len & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1879 p_cpt->cam_cdb_len = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1880
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1881 p_cpt->cam_timeout = CAM_TIME_DEFAULT;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1882 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1883 #endif
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1884
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1885 #if defined( SYS_OS2 )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1886 /*****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1887 * OS2InitSDC: initialize a SDC structure for the Execute SCSI-command
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1888 *****************************************************************************
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1889 * This function initializes a OS2 'execute SCSI command' structure for
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1890 * future use, either a read command or a write command.
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1891 *****************************************************************************/
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1892 static void OS2InitSDC( struct OS2_ExecSCSICmd *p_sdc, int i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1893 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1894 switch( i_type )
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1895 {
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1896 case GPCMD_SEND_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1897 p_sdc->flags = 0;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1898 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1899
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1900 case GPCMD_READ_DVD_STRUCTURE:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1901 case GPCMD_REPORT_KEY:
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1902 p_sdc->flags = EX_DIRECTION_IN;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1903 break;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1904 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1905
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1906 p_sdc->command[ 0 ] = i_type;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1907 p_sdc->command[ 8 ] = (p_sdc->data_length >> 8) & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1908 p_sdc->command[ 9 ] = p_sdc->data_length & 0xff;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1909 p_sdc->id_code = 0x31304443; // 'CD01'
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1910 p_sdc->cmd_length = 12;
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1911 }
c9a4dfaa9868 importing libdvdcss 1.2.2 files
arpi
parents:
diff changeset
1912 #endif