Commit 635d08ed authored by Christophe Massiot's avatar Christophe Massiot

* en50221.c: Use asynchronous I/O for CAM operations.

parent a26123f8
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
* Local declarations * Local declarations
*****************************************************************************/ *****************************************************************************/
#define FRONTEND_LOCK_TIMEOUT 30000000 /* 30 s */ #define FRONTEND_LOCK_TIMEOUT 30000000 /* 30 s */
#define CA_POLL_PERIOD 100000 /* 100 ms */
#define MAX_READ_ONCE 50 #define MAX_READ_ONCE 50
#define DVR_BUFFER_SIZE 40*188*1024 /* bytes */ #define DVR_BUFFER_SIZE 40*188*1024 /* bytes */
...@@ -61,7 +62,6 @@ static fe_status_t i_last_status; ...@@ -61,7 +62,6 @@ static fe_status_t i_last_status;
static mtime_t i_frontend_timeout; static mtime_t i_frontend_timeout;
static mtime_t i_ca_next_event = 0; static mtime_t i_ca_next_event = 0;
static block_t *p_freelist = NULL; static block_t *p_freelist = NULL;
mtime_t i_ca_timeout = 0;
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -105,7 +105,7 @@ void dvb_Open( void ) ...@@ -105,7 +105,7 @@ void dvb_Open( void )
} }
en50221_Init(); en50221_Init();
i_ca_next_event = mdate() + i_ca_timeout; i_ca_next_event = mdate() + CA_POLL_PERIOD;
} }
/***************************************************************************** /*****************************************************************************
...@@ -121,7 +121,7 @@ void dvb_Reset( void ) ...@@ -121,7 +121,7 @@ void dvb_Reset( void )
*****************************************************************************/ *****************************************************************************/
block_t *dvb_Read( void ) block_t *dvb_Read( void )
{ {
struct pollfd ufds[3]; struct pollfd ufds[4];
int i_ret, i_nb_fd = 2; int i_ret, i_nb_fd = 2;
mtime_t i_wallclock; mtime_t i_wallclock;
block_t *p_blocks = NULL; block_t *p_blocks = NULL;
...@@ -133,9 +133,15 @@ block_t *dvb_Read( void ) ...@@ -133,9 +133,15 @@ block_t *dvb_Read( void )
ufds[1].events = POLLERR | POLLPRI; ufds[1].events = POLLERR | POLLPRI;
if ( i_comm_fd != -1 ) if ( i_comm_fd != -1 )
{ {
ufds[2].fd = i_comm_fd; ufds[i_nb_fd].fd = i_comm_fd;
ufds[2].events = POLLIN; ufds[i_nb_fd].events = POLLIN;
i_nb_fd = 3; i_nb_fd++;
}
if ( i_ca_handle && i_ca_type == CA_CI_LINK )
{
ufds[i_nb_fd].fd = i_ca_handle;
ufds[i_nb_fd].events = POLLIN;
i_nb_fd++;
} }
i_ret = poll( ufds, i_nb_fd, 100 ); i_ret = poll( ufds, i_nb_fd, 100 );
...@@ -151,12 +157,18 @@ block_t *dvb_Read( void ) ...@@ -151,12 +157,18 @@ block_t *dvb_Read( void )
p_blocks = DVRRead(); p_blocks = DVRRead();
i_wallclock = mdate(); i_wallclock = mdate();
if ( i_ca_handle && i_ca_type == CA_CI_LINK if ( i_ca_handle && i_ca_type == CA_CI_LINK )
&& i_wallclock > i_ca_next_event ) {
if ( ufds[i_nb_fd - 1].revents )
{
en50221_Read();
i_ca_next_event = i_wallclock + CA_POLL_PERIOD;
}
else if ( i_wallclock > i_ca_next_event )
{ {
en50221_Poll(); en50221_Poll();
i_wallclock = mdate(); i_ca_next_event = i_wallclock + CA_POLL_PERIOD;
i_ca_next_event = i_wallclock + i_ca_timeout; }
} }
if ( ufds[1].revents ) if ( ufds[1].revents )
...@@ -165,8 +177,6 @@ block_t *dvb_Read( void ) ...@@ -165,8 +177,6 @@ block_t *dvb_Read( void )
if ( i_frontend_timeout && i_wallclock > i_frontend_timeout ) if ( i_frontend_timeout && i_wallclock > i_frontend_timeout )
{ {
msg_Warn( NULL, "no lock, tuning again" ); msg_Warn( NULL, "no lock, tuning again" );
/* Do not reset the frontend because the previous parameters were
* correct, and some transponders take a long time to lock. */
FrontendSet(false); FrontendSet(false);
} }
...@@ -716,7 +726,6 @@ static void FrontendSet( bool b_init ) ...@@ -716,7 +726,6 @@ static void FrontendSet( bool b_init )
} }
if ( b_init ) if ( b_init )
{
FrontendInfo( info ); FrontendInfo( info );
/* Clear frontend commands */ /* Clear frontend commands */
...@@ -725,7 +734,6 @@ static void FrontendSet( bool b_init ) ...@@ -725,7 +734,6 @@ static void FrontendSet( bool b_init )
msg_Err( NULL, "Unable to clear frontend" ); msg_Err( NULL, "Unable to clear frontend" );
exit(1); exit(1);
} }
}
switch ( info.type ) switch ( info.type )
{ {
......
...@@ -125,7 +125,6 @@ extern int b_output_udp; ...@@ -125,7 +125,6 @@ extern int b_output_udp;
extern int b_enable_epg; extern int b_enable_epg;
extern int b_unique_tsid; extern int b_unique_tsid;
extern volatile int b_hup_received; extern volatile int b_hup_received;
extern mtime_t i_ca_timeout;
extern int i_comm_fd; extern int i_comm_fd;
extern uint16_t i_src_port; extern uint16_t i_src_port;
extern in_addr_t i_src_addr; extern in_addr_t i_src_addr;
......
This diff is collapsed.
...@@ -79,6 +79,7 @@ extern int i_ca_type; ...@@ -79,6 +79,7 @@ extern int i_ca_type;
*****************************************************************************/ *****************************************************************************/
void en50221_Init( void ); void en50221_Init( void );
void en50221_Reset( void ); void en50221_Reset( void );
void en50221_Read( void );
void en50221_Poll( void ); void en50221_Poll( void );
void en50221_AddPMT( dvbpsi_pmt_t *p_pmt ); void en50221_AddPMT( dvbpsi_pmt_t *p_pmt );
void en50221_UpdatePMT( dvbpsi_pmt_t *p_pmt ); void en50221_UpdatePMT( dvbpsi_pmt_t *p_pmt );
......
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