Commit e9ea66ae authored by Sam Hocevar's avatar Sam Hocevar

  * Solaris DVD decryption support by H}kan Hjort <d95hjort@dtek.chalmers.se>.
parent 641341e8
...@@ -106,6 +106,10 @@ E: jimmy@via.ecp.fr ...@@ -106,6 +106,10 @@ E: jimmy@via.ecp.fr
C: jimmy C: jimmy
D: IDCT and YUV transformations D: IDCT and YUV transformations
N: H}kan Hjort
E: d95hjort@dtek.chalmers.se
D: Solaris port of the DVD ioctls
N: Samuel Hocevar N: Samuel Hocevar
E: sam@zoy.org E: sam@zoy.org
C: sam C: sam
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
HEAD HEAD
* Nothing yet. * Solaris DVD decryption support by H}kan Hjort <d95hjort@dtek.chalmers.se>.
0.2.82 0.2.82
Tue, 7 Aug 2001 12:39:16 +0200 Tue, 7 Aug 2001 12:39:16 +0200
......
This diff is collapsed.
...@@ -256,6 +256,14 @@ AC_CHECK_HEADERS(sys/ioctl.h,[ ...@@ -256,6 +256,14 @@ AC_CHECK_HEADERS(sys/ioctl.h,[
LINUX_DVD_STRUCT=1 LINUX_DVD_STRUCT=1
]) ])
dnl dnl
dnl Solaris: sys/scsi/generic/commands.h sys/scsi/impl/uscsi.h
dnl
AC_CHECK_HEADER(/usr/include/sys/scsi/scsi_types.h,[
AC_CHECK_HEADER(sys/scsi/impl/uscsi.h,[
AC_DEFINE(SOLARIS_USCSI, 1, Have userspace SCSI headers.)
])
])
dnl
dnl Final tests to check what was detected dnl Final tests to check what was detected
dnl dnl
if test x$LINUX_DVD_STRUCT = x1; then if test x$LINUX_DVD_STRUCT = x1; then
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ioctl.c: DVD ioctl replacement function * ioctl.c: DVD ioctl replacement function
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ioctl.c,v 1.7 2001/08/07 02:48:24 sam Exp $ * $Id: ioctl.c,v 1.8 2001/08/08 02:48:44 sam Exp $
* *
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com> * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -55,6 +55,12 @@ ...@@ -55,6 +55,12 @@
# include <malloc.h> # include <malloc.h>
# include <scsi.h> # include <scsi.h>
#endif #endif
#ifdef SOLARIS_USCSI
# include <unistd.h>
# include <stropts.h>
# include </usr/include/sys/scsi/scsi_types.h>
# include <sys/scsi/impl/uscsi.h>
#endif
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"
...@@ -72,6 +78,13 @@ ...@@ -72,6 +78,13 @@
static void BeInitRDC ( raw_device_command *, int ); static void BeInitRDC ( raw_device_command *, int );
#endif #endif
/*****************************************************************************
* Local prototypes, Solaris specific
*****************************************************************************/
#if defined( SOLARIS_USCSI )
static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type );
#endif
/***************************************************************************** /*****************************************************************************
* Local prototypes, win32 (aspi) specific * Local prototypes, win32 (aspi) specific
*****************************************************************************/ *****************************************************************************/
...@@ -117,6 +130,21 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) ...@@ -117,6 +130,21 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
*pi_copyright = p_buffer[ 4 ]; *pi_copyright = p_buffer[ 4 ];
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 );
rs_cdb.cdb_opaque[ 6 ] = i_layer;
rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT;
i_ret = ioctl(i_fd, USCSICMD, &sc);
if( i_ret < 0 || sc.uscsi_status ) {
i_ret = -1;
}
*pi_copyright = p_buffer[ 4 ];
// s->copyright.rmi = p_buffer[ 5 ];
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
*pi_copyright = 1; *pi_copyright = 1;
...@@ -240,6 +268,22 @@ int ioctl_ReadKey( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -240,6 +268,22 @@ int ioctl_ReadKey( int i_fd, int *pi_agid, u8 *p_key )
memcpy( p_key, p_buffer + 4, 2048 ); memcpy( p_key, p_buffer + 4, 2048 );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
return i_ret;
}
memcpy( p_key, p_buffer + 4, 2048 );
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
i_ret = 0; i_ret = 0;
...@@ -330,6 +374,20 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid ) ...@@ -330,6 +374,20 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
*pi_agid = p_buffer[ 7 ] >> 6; *pi_agid = p_buffer[ 7 ] >> 6;
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
*pi_agid = p_buffer[ 7 ] >> 6;
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
INIT_DVDIOCTL( 8 ); INIT_DVDIOCTL( 8 );
...@@ -407,6 +465,20 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -407,6 +465,20 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
memcpy( p_challenge, p_buffer + 4, 12 ); memcpy( p_challenge, p_buffer + 4, 12 );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 16 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
memcpy( p_challenge, p_buffer + 4, 12 );
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
INIT_DVDIOCTL( 16 ); INIT_DVDIOCTL( 16 );
...@@ -499,6 +571,20 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf ) ...@@ -499,6 +571,20 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
*pi_asf = p_buffer[ 7 ] & 1; *pi_asf = p_buffer[ 7 ] & 1;
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
*pi_asf = p_buffer[ 7 ] & 1;
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
INIT_DVDIOCTL( 8 ); INIT_DVDIOCTL( 8 );
...@@ -591,6 +677,20 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -591,6 +677,20 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
memcpy( p_key, p_buffer + 4, 8 ); memcpy( p_key, p_buffer + 4, 8 );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 12 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
memcpy( p_key, p_buffer + 4, 8 );;
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
INIT_DVDIOCTL( 12 ); INIT_DVDIOCTL( 12 );
...@@ -673,6 +773,18 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid ) ...@@ -673,6 +773,18 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 0 );
rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
INIT_DVDIOCTL( 0 ); INIT_DVDIOCTL( 0 );
...@@ -749,6 +861,21 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) ...@@ -749,6 +861,21 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_SEND_KEY, 16 );
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 );
if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
{
return -1;
}
return 0;
#elif defined( SYS_DARWIN ) #elif defined( SYS_DARWIN )
INIT_DVDIOCTL( 16 ); INIT_DVDIOCTL( 16 );
...@@ -833,6 +960,21 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) ...@@ -833,6 +960,21 @@ int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_SEND_KEY, 12 );
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
p_buffer[ 1 ] = 0xa;
memcpy( p_buffer + 4, p_key, 8 );
if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
{
return -1;
}
return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */ if( WIN2K ) /* NT/Win2000/Whistler */
{ {
...@@ -920,6 +1062,43 @@ static void BeInitRDC( raw_device_command *p_rdc, int i_type ) ...@@ -920,6 +1062,43 @@ static void BeInitRDC( raw_device_command *p_rdc, int i_type )
} }
#endif #endif
#if defined( SOLARIS_USCSI )
/*****************************************************************************
* SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel
*****************************************************************************
* This function initializes a Solaris userspace scsi command structure for
* future use, either a read command or a write command.
*****************************************************************************/
static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type )
{
union scsi_cdb *rs_cdb;
memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) );
memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen );
switch( i_type )
{
case GPCMD_SEND_KEY:
p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_WRITE;
break;
case GPCMD_READ_DVD_STRUCTURE:
case GPCMD_REPORT_KEY:
p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ;
break;
}
rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb;
rs_cdb->scc_cmd = i_type;
rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff;
rs_cdb->cdb_opaque[ 9 ] = p_sc->uscsi_buflen & 0xff;
p_sc->uscsi_cdblen = 12;
USCSI_TIMEOUT( p_sc, 15 );
}
#endif
#if defined( WIN32 ) #if defined( WIN32 )
/***************************************************************************** /*****************************************************************************
* WinInitSSC: initialize a ssc structure for the win32 aspi layer * WinInitSSC: initialize a ssc structure for the win32 aspi layer
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ioctl.h: DVD ioctl replacement function * ioctl.h: DVD ioctl replacement function
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ioctl.h,v 1.5 2001/07/07 21:10:58 gbazin Exp $ * $Id: ioctl.h,v 1.6 2001/08/08 02:48:44 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -45,6 +45,23 @@ int ioctl_SendKey2 ( int, int *, u8 * ); ...@@ -45,6 +45,23 @@ int ioctl_SendKey2 ( int, int *, u8 * );
BeInitRDC( &rdc, (TYPE) ); BeInitRDC( &rdc, (TYPE) );
#endif #endif
/*****************************************************************************
* Common macro, Solaris specific
*****************************************************************************/
#if defined( SOLARIS_USCSI )
#define USCSI_TIMEOUT( SC, TO ) ( (SC)->uscsi_timeout = (TO) )
#define USCSI_RESID( SC ) ( (SC)->uscsi_resid )
#define INIT_USCSI( TYPE, SIZE ) \
struct uscsi_cmd sc; \
union scsi_cdb rs_cdb; \
u8 p_buffer[ (SIZE) ]; \
memset( &sc, 0, sizeof( struct uscsi_cmd ) ); \
sc.uscsi_cdb = (caddr_t)&rs_cdb; \
sc.uscsi_bufaddr = p_buffer; \
sc.uscsi_buflen = (SIZE); \
SolarisInitUSCSI( &sc, (TYPE) );
#endif
/***************************************************************************** /*****************************************************************************
* Common macro, Darwin specific * Common macro, Darwin specific
*****************************************************************************/ *****************************************************************************/
...@@ -75,15 +92,18 @@ int ioctl_SendKey2 ( int, int *, u8 * ); ...@@ -75,15 +92,18 @@ int ioctl_SendKey2 ( int, int *, u8 * );
* Various DVD I/O tables * Various DVD I/O tables
*****************************************************************************/ *****************************************************************************/
#if defined( SYS_BEOS ) || defined( WIN32 ) #if defined( SYS_BEOS ) || defined( WIN32 ) || defined ( SOLARIS_USCSI )
/* The generic packet command opcodes for CD/DVD Logical Units, /* The generic packet command opcodes for CD/DVD Logical Units,
* From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
# define GPCMD_READ_DVD_STRUCTURE 0xad # define GPCMD_READ_DVD_STRUCTURE 0xad
# define GPCMD_REPORT_KEY 0xa4 # define GPCMD_REPORT_KEY 0xa4
# define GPCMD_SEND_KEY 0xa3 # define GPCMD_SEND_KEY 0xa3
/* DVD struct types */ /* DVD struct types */
# define DVD_STRUCT_PHYSICAL 0x00
# define DVD_STRUCT_COPYRIGHT 0x01 # define DVD_STRUCT_COPYRIGHT 0x01
# define DVD_STRUCT_DISCKEY 0x02 # define DVD_STRUCT_DISCKEY 0x02
# define DVD_STRUCT_BCA 0x03
# define DVD_STRUCT_MANUFACT 0x04
/* Key formats */ /* Key formats */
# define DVD_REPORT_AGID 0x00 # define DVD_REPORT_AGID 0x00
# define DVD_REPORT_CHALLENGE 0x01 # define DVD_REPORT_CHALLENGE 0x01
......
...@@ -190,6 +190,9 @@ ...@@ -190,6 +190,9 @@
/* Define if <dvd.h> defines DVD_STRUCT. */ /* Define if <dvd.h> defines DVD_STRUCT. */
#undef DVD_STRUCT_IN_DVD_H #undef DVD_STRUCT_IN_DVD_H
/* Have userspace SCSI headers. */
#undef SOLARIS_USCSI
/* Define if Linux-like dvd_struct is defined. */ /* Define if Linux-like dvd_struct is defined. */
#undef HAVE_LINUX_DVD_STRUCT #undef HAVE_LINUX_DVD_STRUCT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment