Commit ad3c73f5 authored by Christophe Massiot's avatar Christophe Massiot

* modules/access/dvb: Fixed link-level CAM API.

parent 415518de
......@@ -1132,7 +1132,7 @@ static void CAPMTDelete( access_t * p_access, int i_session_id,
uint8_t *p_capmt;
int i_capmt_size;
p_access->p_sys->i_selected_programs++;
p_access->p_sys->i_selected_programs--;
msg_Dbg( p_access, "deleting CAPMT for SID %d on session %d",
p_pmt->i_program_number, i_session_id );
......@@ -1554,13 +1554,45 @@ int E_(en50221_Init)( access_t * p_access )
{
access_sys_t *p_sys = p_access->p_sys;
if( p_sys->i_ca_type != CA_CI ) /* Link level init is done in Poll() */
if( p_sys->i_ca_type & CA_CI_LINK )
{
int i_slot;
for ( i_slot = 0; i_slot < p_sys->i_nb_slots; i_slot++ )
{
if ( ioctl( p_sys->i_ca_handle, CA_RESET, 1 << i_slot) != 0 )
{
msg_Err( p_access, "en50221_Init: couldn't reset slot %d",
i_slot );
}
}
p_sys->i_ca_timeout = 100000;
/* Wait a bit otherwise it doesn't initialize properly... */
msleep( 1000000 );
return VLC_SUCCESS;
}
else
{
struct ca_slot_info info;
/* We don't reset the CAM in that case because it's done by the
* ASIC. */
if ( ioctl( p_sys->i_ca_handle, CA_GET_SLOT_INFO, &info ) < 0 )
{
msg_Err( p_access, "en50221_Init: couldn't get slot info" );
close( p_sys->i_ca_handle );
p_sys->i_ca_handle = 0;
return VLC_EGENERIC;
}
if( info.flags == 0 )
{
msg_Err( p_access, "en50221_Init: no CAM inserted" );
close( p_sys->i_ca_handle );
p_sys->i_ca_handle = 0;
return VLC_EGENERIC;
}
/* Allocate a dummy sessions */
p_sys->p_sessions[ 0 ].i_resource_id = RI_CONDITIONAL_ACCESS_SUPPORT;
......@@ -1575,9 +1607,10 @@ int E_(en50221_Init)( access_t * p_access )
APDUSend( p_access, 1, AOT_APPLICATION_INFO_ENQ, NULL, 0 );
if ( ioctl( p_sys->i_ca_handle, CA_GET_MSG, &ca_msg ) < 0 )
{
msg_Err( p_access, "CAM: failed getting message" );
msg_Err( p_access, "en50221_Init: failed getting message" );
return VLC_EGENERIC;
}
#if HLCI_WAIT_CAM_READY
while( ca_msg.msg[8] == 0xff && ca_msg.msg[9] == 0xff )
{
......@@ -1592,10 +1625,10 @@ int E_(en50221_Init)( access_t * p_access )
memset( &ca_msg.msg[3], 0, 253 );
if ( ioctl( p_sys->i_ca_handle, CA_GET_MSG, &ca_msg ) < 0 )
{
msg_Err( p_access, "CAM: failed getting message" );
msg_Err( p_access, "en50221_Init: failed getting message" );
return VLC_EGENERIC;
}
msg_Dbg( p_access, "CAM: Got length: %d, tag: 0x%x", ca_msg.length, APDUGetTag( ca_msg.msg, ca_msg.length ) );
msg_Dbg( p_access, "en50221_Init: Got length: %d, tag: 0x%x", ca_msg.length, APDUGetTag( ca_msg.msg, ca_msg.length ) );
}
#else
if( ca_msg.msg[8] == 0xff && ca_msg.msg[9] == 0xff )
......@@ -1607,7 +1640,6 @@ int E_(en50221_Init)( access_t * p_access )
msg_Dbg( p_access, "found CAM %s using id 0x%x", &ca_msg.msg[12],
(ca_msg.msg[8]<<8)|ca_msg.msg[9] );
return VLC_SUCCESS;
}
}
......
......@@ -74,8 +74,6 @@ struct frontend_t
#define FRONTEND_LOCK_TIMEOUT 10000000 /* 10 s */
#define RESET_CAM_SLOTS 1 /* Do we want to reset cam upon opening */
/* Local prototypes */
static int FrontendInfo( access_t * );
static int FrontendSetQPSK( access_t * );
......@@ -1210,9 +1208,8 @@ int E_(CAMOpen)( access_t *p_access )
{
access_sys_t *p_sys = p_access->p_sys;
char ca[128];
int i_adapter, i_device, i_slot;
int i_adapter, i_device;
ca_caps_t caps;
struct ca_slot_info info;
i_adapter = var_GetInteger( p_access, "dvb-adapter" );
i_device = var_GetInteger( p_access, "dvb-device" );
......@@ -1273,24 +1270,10 @@ int E_(CAMOpen)( access_t *p_access )
}
p_sys->i_ca_type = caps.slot_type;
if( caps.slot_type != CA_CI_LINK &&
caps.slot_type != CA_CI )
if ( !(caps.slot_type & CA_CI_LINK) &&
!(caps.slot_type & CA_CI) )
{
msg_Err( p_access, "CAMInit: incompatible CAM module" );
close( p_sys->i_ca_handle );
p_sys->i_ca_handle = 0;
return VLC_EGENERIC;
}
if( ioctl( p_sys->i_ca_handle, CA_GET_SLOT_INFO, &info ) < 0 )
{
msg_Err( p_access, "CAMInit: Couldn't get slot info" );
close( p_sys->i_ca_handle );
p_sys->i_ca_handle = 0;
return VLC_EGENERIC;
}
if( info.flags == 0 )
{
msg_Err( p_access, "CAMInit: No CAM inserted" );
msg_Err( p_access, "CAMInit: incompatible CAM interface" );
close( p_sys->i_ca_handle );
p_sys->i_ca_handle = 0;
return VLC_EGENERIC;
......@@ -1298,19 +1281,6 @@ int E_(CAMOpen)( access_t *p_access )
p_sys->i_nb_slots = caps.slot_num;
memset( p_sys->pb_active_slot, 0, sizeof(vlc_bool_t) * MAX_CI_SLOTS );
#if(RESET_CAM_SLOTS)
for ( i_slot = 0; i_slot < p_sys->i_nb_slots; i_slot++ )
{
if ( ioctl( p_sys->i_ca_handle, CA_RESET, 1 << i_slot) != 0 )
{
msg_Err( p_access, "CAMInit: couldn't reset slot %d", i_slot );
}
}
#endif
p_sys->i_ca_timeout = 100000;
/* Wait a bit otherwise it doesn't initialize properly... */
msleep( 1000000 );
return E_(en50221_Init)( p_access );
}
......
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