1 /*****************************************************************************
2 * dvd_ioctl.c: DVD ioctl replacement function
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: dvd_ioctl.c,v 1.16 2001/05/31 03:12:49 sam Exp $
7 * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
8 * Samuel Hocevar <sam@zoy.org>
9 * Jon Lech Johansen <jon-vl@nanocrew.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <string.h> /* memcpy(), memset() */
32 #include <sys/types.h>
36 # include <winioctl.h>
38 # include <netinet/in.h>
39 # include <sys/ioctl.h>
42 #ifdef DVD_STRUCT_IN_SYS_CDIO_H
43 # include <sys/cdio.h>
45 #ifdef DVD_STRUCT_IN_SYS_DVDIO_H
46 # include <sys/dvdio.h>
48 #ifdef DVD_STRUCT_IN_LINUX_CDROM_H
49 # include <linux/cdrom.h>
61 # include "DVDioctl/DVDioctl.h"
65 #include "dvd_ioctl.h"
67 /*****************************************************************************
68 * Local prototypes, BeOS specific
69 *****************************************************************************/
70 #if defined( SYS_BEOS )
71 static void BeInitRDC ( raw_device_command *, int );
74 /*****************************************************************************
75 * ioctl_ReadCopyright: check whether the disc is encrypted or not
76 *****************************************************************************/
77 int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
81 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
84 dvd.type = DVD_STRUCT_COPYRIGHT;
85 dvd.copyright.layer_num = i_layer;
87 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
89 *pi_copyright = dvd.copyright.cpst;
91 #elif defined( HAVE_BSD_DVD_STRUCT )
92 struct dvd_struct dvd;
94 dvd.format = DVD_STRUCT_COPYRIGHT;
95 dvd.layer_num = i_layer;
97 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
99 *pi_copyright = dvd.cpst;
101 #elif defined( SYS_BEOS )
102 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 );
104 rdc.command[ 6 ] = i_layer;
105 rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT;
107 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
109 *pi_copyright = p_buffer[ 4 ];
111 #elif defined( SYS_DARWIN1_3 )
112 intf_ErrMsg( "css error: DVD ioctls not fully functional yet" );
113 intf_ErrMsg( "css error: assuming disc is encrypted" );
119 #elif defined( WIN32 )
120 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
124 SCSI_PASS_THROUGH_DIRECT sptd;
126 memset( &sptd, 0, sizeof( sptd ) );
127 memset( &p_buffer, 0, sizeof( p_buffer ) );
129 /* When using IOCTL_DVD_READ_STRUCTURE and
130 DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
131 is always 6. So we send a raw scsi command instead. */
133 sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT );
135 sptd.DataIn = SCSI_IOCTL_DATA_IN;
136 sptd.DataTransferLength = 8;
137 sptd.TimeOutValue = 2;
138 sptd.DataBuffer = p_buffer;
139 sptd.Cdb[ 0 ] = GPCMD_READ_DVD_STRUCTURE;
140 sptd.Cdb[ 6 ] = i_layer;
141 sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
142 sptd.Cdb[ 8 ] = (8 >> 8) & 0xff;
143 sptd.Cdb[ 9 ] = 8 & 0xff;
145 i_ret = DeviceIoControl( (HANDLE) i_fd,
146 IOCTL_SCSI_PASS_THROUGH_DIRECT,
147 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
148 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
149 &tmp, NULL ) ? 0 : -1;
151 *pi_copyright = p_buffer[4];
155 /* TODO: add WNASPI support for Win9x */
156 intf_ErrMsg( "css error: DVD ioctls not functional yet" );
157 intf_ErrMsg( "css error: assuming disc is unencrypted" );
163 /* DVD ioctls unavailable - do as if the ioctl failed */
170 /*****************************************************************************
171 * ioctl_ReadKey: get the disc key
172 *****************************************************************************/
173 int ioctl_ReadKey( int i_fd, int *pi_agid, u8 *p_key )
177 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
180 dvd.type = DVD_STRUCT_DISCKEY;
181 dvd.disckey.agid = *pi_agid;
182 memset( dvd.disckey.value, 0, 2048 );
184 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
191 memcpy( p_key, dvd.disckey.value, 2048 );
193 #elif defined( HAVE_BSD_DVD_STRUCT )
194 struct dvd_struct dvd;
196 dvd.format = DVD_STRUCT_DISCKEY;
198 memset( dvd.data, 0, 2048 );
200 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
207 memcpy( p_key, dvd.data, 2048 );
209 #elif defined( SYS_BEOS )
210 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
212 rdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
213 rdc.command[ 10 ] = *pi_agid << 6;
215 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
222 memcpy( p_key, p_buffer + 4, 2048 );
224 #elif defined( SYS_DARWIN1_3 )
225 intf_ErrMsg( "css error: DVD ioctls not fully functional yet" );
226 intf_ErrMsg( "css error: sending an empty key" );
230 memset( p_key, 0x00, 2048 );
232 #elif defined( WIN32 )
233 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
236 u8 buffer[DVD_DISK_KEY_LENGTH];
237 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
239 memset( &buffer, 0, sizeof( buffer ) );
241 key->KeyLength = DVD_DISK_KEY_LENGTH;
242 key->SessionId = *pi_agid;
243 key->KeyType = DvdDiskKey;
246 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
247 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
254 memcpy( p_key, key->KeyData, 2048 );
262 /* DVD ioctls unavailable - do as if the ioctl failed */
269 /*****************************************************************************
270 * ioctl_ReportAgid: get AGID from the drive
271 *****************************************************************************/
272 int ioctl_ReportAgid( int i_fd, int *pi_agid )
276 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
277 dvd_authinfo auth_info;
279 auth_info.type = DVD_LU_SEND_AGID;
280 auth_info.lsa.agid = *pi_agid;
282 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
284 *pi_agid = auth_info.lsa.agid;
286 #elif defined( HAVE_BSD_DVD_STRUCT )
287 struct dvd_authinfo auth_info;
289 auth_info.format = DVD_REPORT_AGID;
290 auth_info.agid = *pi_agid;
292 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
294 *pi_agid = auth_info.agid;
296 #elif defined( SYS_BEOS )
297 INIT_RDC( GPCMD_REPORT_KEY, 8 );
299 rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
301 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
303 *pi_agid = p_buffer[ 7 ] >> 6;
305 #elif defined( SYS_DARWIN1_3 )
308 dvdioctl.i_keyformat = kCSSAGID;
309 dvdioctl.i_agid = *pi_agid;
312 i_ret = ioctl( i_fd, IODVD_REPORT_KEY, &dvdioctl );
314 *pi_agid = p_buffer[ 7 ] >> 6;
316 #elif defined( WIN32 )
317 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
322 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
323 &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1;
333 /* DVD ioctls unavailable - do as if the ioctl failed */
340 /*****************************************************************************
341 * ioctl_ReportChallenge: get challenge from the drive
342 *****************************************************************************/
343 int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
347 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
348 dvd_authinfo auth_info;
350 auth_info.type = DVD_LU_SEND_CHALLENGE;
351 auth_info.lsc.agid = *pi_agid;
353 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
355 memcpy( p_challenge, auth_info.lsc.chal, sizeof(dvd_challenge) );
357 #elif defined( HAVE_BSD_DVD_STRUCT )
358 struct dvd_authinfo auth_info;
360 auth_info.format = DVD_REPORT_CHALLENGE;
361 auth_info.agid = *pi_agid;
363 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
365 memcpy( p_challenge, auth_info.keychal, 10 );
367 #elif defined( SYS_BEOS )
368 INIT_RDC( GPCMD_REPORT_KEY, 16 );
370 rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
372 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
374 memcpy( p_challenge, p_buffer + 4, 12 );
376 #elif defined( SYS_DARWIN1_3 )
379 dvdioctl.i_keyformat = kChallengeKey;
380 dvdioctl.i_agid = *pi_agid;
383 i_ret = ioctl( i_fd, IODVD_REPORT_KEY, &dvdioctl );
385 memcpy( p_challenge, p_buffer + 4, 12 );
387 #elif defined( WIN32 )
388 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
391 u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
392 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
394 memset( &buffer, 0, sizeof( buffer ) );
396 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
397 key->SessionId = *pi_agid;
398 key->KeyType = DvdChallengeKey;
401 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
402 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
409 memcpy( p_challenge, key->KeyData, 10 );
417 /* DVD ioctls unavailable - do as if the ioctl failed */
424 /*****************************************************************************
425 * ioctl_ReportASF: get ASF from the drive
426 *****************************************************************************/
427 int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
431 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
432 dvd_authinfo auth_info;
434 auth_info.type = DVD_LU_SEND_ASF;
435 auth_info.lsasf.agid = *pi_agid;
436 auth_info.lsasf.asf = *pi_asf;
438 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
440 *pi_asf = auth_info.lsasf.asf;
442 #elif defined( HAVE_BSD_DVD_STRUCT )
443 struct dvd_authinfo auth_info;
445 auth_info.format = DVD_REPORT_ASF;
446 auth_info.agid = *pi_agid;
447 auth_info.asf = *pi_asf;
449 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
451 *pi_asf = auth_info.asf;
453 #elif defined( SYS_BEOS )
454 INIT_RDC( GPCMD_REPORT_KEY, 8 );
456 rdc.command[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
458 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
460 *pi_asf = p_buffer[ 7 ] & 1;
462 #elif defined( SYS_DARWIN1_3 )
465 dvdioctl.i_keyformat = kASF;
466 dvdioctl.i_agid = *pi_agid;
469 i_ret = ioctl( i_fd, IODVD_REPORT_KEY, &dvdioctl );
471 *pi_asf = p_buffer[ 7 ] & 1;
473 #elif defined( WIN32 )
474 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
477 u8 buffer[DVD_ASF_LENGTH];
478 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
480 memset( &buffer, 0, sizeof( buffer ) );
482 key->KeyLength = DVD_ASF_LENGTH;
483 key->SessionId = *pi_agid;
484 key->KeyType = DvdAsf;
487 ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
489 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
490 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
497 *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
505 /* DVD ioctls unavailable - do as if the ioctl failed */
512 /*****************************************************************************
513 * ioctl_ReportKey1: get the first key from the drive
514 *****************************************************************************/
515 int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
519 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
520 dvd_authinfo auth_info;
522 auth_info.type = DVD_LU_SEND_KEY1;
523 auth_info.lsk.agid = *pi_agid;
525 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
527 memcpy( p_key, auth_info.lsk.key, sizeof(dvd_key) );
529 #elif defined( HAVE_BSD_DVD_STRUCT )
530 struct dvd_authinfo auth_info;
532 auth_info.format = DVD_REPORT_KEY1;
533 auth_info.agid = *pi_agid;
535 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
537 memcpy( p_key, auth_info.keychal, 8 );
539 #elif defined( SYS_BEOS )
540 INIT_RDC( GPCMD_REPORT_KEY, 12 );
542 rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
544 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
546 memcpy( p_key, p_buffer + 4, 8 );
548 #elif defined( SYS_DARWIN1_3 )
551 dvdioctl.i_keyformat = kKey1;
552 dvdioctl.i_agid = *pi_agid;
554 i_ret = ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
556 memcpy( p_key, p_buffer + 4, 8 );
558 #elif defined( WIN32 )
559 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
562 u8 buffer[DVD_BUS_KEY_LENGTH];
563 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
565 memset( &buffer, 0, sizeof( buffer ) );
567 key->KeyLength = DVD_BUS_KEY_LENGTH;
568 key->SessionId = *pi_agid;
569 key->KeyType = DvdBusKey1;
572 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
573 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
575 memcpy( p_key, key->KeyData, 8 );
583 /* DVD ioctls unavailable - do as if the ioctl failed */
590 /*****************************************************************************
591 * ioctl_InvalidateAgid: invalidate the current AGID
592 *****************************************************************************/
593 int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
597 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
598 dvd_authinfo auth_info;
600 auth_info.type = DVD_INVALIDATE_AGID;
601 auth_info.lsa.agid = *pi_agid;
603 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
605 *pi_agid = auth_info.lsa.agid;
607 #elif defined( HAVE_BSD_DVD_STRUCT )
608 struct dvd_authinfo auth_info;
610 auth_info.format = DVD_INVALIDATE_AGID;
611 auth_info.agid = *pi_agid;
613 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
615 *pi_agid = auth_info.agid;
617 #elif defined( SYS_BEOS )
618 INIT_RDC( GPCMD_REPORT_KEY, 0 );
620 rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
622 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
624 #elif defined( SYS_DARWIN1_3 )
627 dvdioctl.i_keyformat = kInvalidateAGID;
628 dvdioctl.i_agid = *pi_agid;
630 i_ret = ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
632 #elif defined( WIN32 )
633 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
637 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
638 pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1;
646 /* DVD ioctls unavailable - do as if the ioctl failed */
653 /*****************************************************************************
654 * ioctl_SendChallenge: send challenge to the drive
655 *****************************************************************************/
656 int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
658 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
659 dvd_authinfo auth_info;
661 auth_info.type = DVD_HOST_SEND_CHALLENGE;
662 auth_info.hsc.agid = *pi_agid;
664 memcpy( auth_info.hsc.chal, p_challenge, sizeof(dvd_challenge) );
666 return ioctl( i_fd, DVD_AUTH, &auth_info );
668 #elif defined( HAVE_BSD_DVD_STRUCT )
669 struct dvd_authinfo auth_info;
671 auth_info.format = DVD_SEND_CHALLENGE;
672 auth_info.agid = *pi_agid;
674 memcpy( auth_info.keychal, p_challenge, 12 );
676 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
678 #elif defined( SYS_BEOS )
679 INIT_RDC( GPCMD_SEND_KEY, 16 );
681 rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
684 memcpy( p_buffer + 4, p_challenge, 12 );
686 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
688 #elif defined( SYS_DARWIN1_3 )
691 dvdioctl.i_keyformat = kChallengeKey;
692 dvdioctl.i_agid = *pi_agid;
695 memcpy( p_buffer + 4, p_challenge, 12 );
697 return ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
699 #elif defined( WIN32 )
700 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
703 u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
704 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
706 memset( &buffer, 0, sizeof( buffer ) );
708 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
709 key->SessionId = *pi_agid;
710 key->KeyType = DvdChallengeKey;
713 memcpy( key->KeyData, p_challenge, 10 );
715 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
716 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
724 /* DVD ioctls unavailable - do as if the ioctl failed */
730 /*****************************************************************************
731 * ioctl_SendKey2: send the second key to the drive
732 *****************************************************************************/
733 int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
735 #if defined( DVD_STRUCT_IN_LINUX_CDROM_H )
736 dvd_authinfo auth_info;
738 auth_info.type = DVD_HOST_SEND_KEY2;
739 auth_info.hsk.agid = *pi_agid;
741 memcpy( auth_info.hsk.key, p_key, sizeof(dvd_key) );
743 return ioctl( i_fd, DVD_AUTH, &auth_info );
745 #elif defined( HAVE_BSD_DVD_STRUCT )
746 struct dvd_authinfo auth_info;
748 auth_info.format = DVD_SEND_KEY2;
749 auth_info.agid = *pi_agid;
751 memcpy( auth_info.keychal, p_key, 8 );
753 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
755 #elif defined( SYS_BEOS )
756 INIT_RDC( GPCMD_SEND_KEY, 12 );
758 rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
761 memcpy( p_buffer + 4, p_key, 8 );
763 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
765 #elif defined( WIN32 )
766 if( GetVersion() < 0x80000000 ) /* NT/Win2000/Whistler */
769 u8 buffer[DVD_BUS_KEY_LENGTH];
770 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
772 memset( &buffer, 0, sizeof( buffer ) );
774 key->KeyLength = DVD_BUS_KEY_LENGTH;
775 key->SessionId = *pi_agid;
776 key->KeyType = DvdBusKey2;
779 memcpy( key->KeyData, p_key, 8 );
781 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
782 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
789 #elif defined( SYS_DARWIN1_3 )
792 dvdioctl.i_keyformat = kKey2;
793 dvdioctl.i_agid = *pi_agid;
796 memcpy( p_buffer + 4, p_key, 8 );
798 return ioctl( i_fd, IODVD_SEND_KEY, &dvdioctl );
801 /* DVD ioctls unavailable - do as if the ioctl failed */
807 /* Local prototypes */
809 #if defined( SYS_BEOS )
810 /*****************************************************************************
811 * BeInitRDC: initialize a RDC structure for the BeOS kernel
812 *****************************************************************************
813 * This function initializes a BeOS raw device command structure for future
814 * use, either a read command or a write command.
815 *****************************************************************************/
816 static void BeInitRDC( raw_device_command *p_rdc, int i_type )
818 memset( p_rdc->data, 0, p_rdc->data_length );
823 /* leave the flags to 0 */
826 case GPCMD_READ_DVD_STRUCTURE:
827 case GPCMD_REPORT_KEY:
828 p_rdc->flags = B_RAW_DEVICE_DATA_IN;
832 p_rdc->command[ 0 ] = i_type;
834 p_rdc->command[ 8 ] = (p_rdc->data_length >> 8) & 0xff;
835 p_rdc->command[ 9 ] = p_rdc->data_length & 0xff;
836 p_rdc->command_length = 12;
838 p_rdc->sense_data = NULL;
839 p_rdc->sense_data_length = 0;
841 p_rdc->timeout = 1000000;