X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fdvb%2Flinux_dvb.c;h=7c12e89ccaec32bcc47413109cf57898b44e7da1;hb=8f8ff669731a51d36dc2a3a78cc0e520b568b434;hp=4d17387d70d28422570c0d416f362d9979e95cc8;hpb=2095481ecdd376e5b4a3b605a650b02631ecf4e5;p=vlc diff --git a/modules/access/dvb/linux_dvb.c b/modules/access/dvb/linux_dvb.c index 4d17387d70..7c12e89cca 100644 --- a/modules/access/dvb/linux_dvb.c +++ b/modules/access/dvb/linux_dvb.c @@ -1,7 +1,7 @@ /***************************************************************************** * linux_dvb.c : functions to control a DVB card under Linux with v4l2 ***************************************************************************** - * Copyright (C) 1998-2010 the VideoLAN team + * Copyright (C) 1998-2010 VLC authors and VideoLAN * * Authors: Damien Lucas * Johan Bilien @@ -10,18 +10,18 @@ * Christophe Massiot * David Kaplan * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ @@ -38,27 +38,11 @@ #include #include #include -#include /* DVB Card Drivers */ #include #include #include -#include - -/* Include dvbpsi headers */ -# include -# include -# include -# include -# include -# include -# include -# include - -#ifdef ENABLE_HTTPD -# include -#endif #include "dvb.h" #include "scan.h" @@ -66,7 +50,6 @@ #define DMX "/dev/dvb/adapter%d/demux%d" #define FRONTEND "/dev/dvb/adapter%d/frontend%d" #define DVR "/dev/dvb/adapter%d/dvr%d" -#define CA "/dev/dvb/adapter%d/ca%d" /* * Frontends @@ -424,7 +407,7 @@ static int ScanParametersDvbC( access_t *p_access, scan_parameter_t *p_scan ) ? p_frontend->info.frequency_stepsize : 166667; p_scan->frequency.i_count = (p_scan->frequency.i_max-p_scan->frequency.i_min)/p_scan->frequency.i_step; - /* if user supplies modulation or frontend can do auto, dont scan them */ + /* if user supplies modulation or frontend can do auto, don't scan them */ if( var_GetInteger( p_access, "dvb-modulation" ) || p_frontend->info.caps & FE_CAN_QAM_AUTO ) { @@ -488,152 +471,6 @@ int FrontendGetScanParameter( access_t *p_access, scan_parameter_t *p_scan ) return VLC_EGENERIC; } -#ifdef ENABLE_HTTPD -/***************************************************************************** - * FrontendStatus : Read frontend status - *****************************************************************************/ -void FrontendStatus( access_t *p_access ) -{ - access_sys_t *p_sys = p_access->p_sys; - frontend_t *p_frontend = p_sys->p_frontend; - char *p = p_sys->psz_frontend_info = malloc( 10000 ); - fe_status_t i_status; - - /* Determine type of frontend */ - if( ioctl( p_sys->i_frontend_handle, FE_GET_INFO, &p_frontend->info ) < 0 ) - { - char buf[1000]; - strerror_r( errno, buf, sizeof( buf ) ); - p += sprintf( p, "ioctl FE_GET_INFO failed %s\n", buf ); - goto out; - } - - /* Print out frontend capabilities. */ - p += sprintf( p, "\n", - p_frontend->info.name ); - switch( p_frontend->info.type ) - { - case FE_QPSK: - p += sprintf( p, "\n" ); - break; - case FE_QAM: - p += sprintf( p, "\n" ); - break; - case FE_OFDM: - p += sprintf( p, "\n" ); - break; -#if 0 /* DVB_API_VERSION == 3 */ - case FE_MEMORY: - p += sprintf( p, "\n" ); - break; - case FE_NET: - p += sprintf( p, "\n" ); - break; -#endif - default: - p += sprintf( p, "\n", - p_frontend->info.type ); - goto out; - } -#define CHECK_INFO( x ) \ - p += sprintf( p, \ - "\n", \ - p_frontend->info.x ); - - CHECK_INFO( frequency_min ); - CHECK_INFO( frequency_max ); - CHECK_INFO( frequency_stepsize ); - CHECK_INFO( frequency_tolerance ); - CHECK_INFO( symbol_rate_min ); - CHECK_INFO( symbol_rate_max ); - CHECK_INFO( symbol_rate_tolerance ); - CHECK_INFO( notifier_delay ); -#undef CHECK_INFO - - p += sprintf( p, "
name%s
typeQPSK (DVB-S)
typeQAM (DVB-C)
typeOFDM (DVB-T)
typeMEMORY
typeNETWORK
typeUNKNOWN (%d)
" STRINGIFY(x) "%u

Frontend capability list:\n" ); - -#define CHECK_CAPS( x ) \ - if ( p_frontend->info.caps & (FE_##x) ) \ - p += sprintf( p, "\n" ); - - CHECK_CAPS( IS_STUPID ); - CHECK_CAPS( CAN_INVERSION_AUTO ); - CHECK_CAPS( CAN_FEC_1_2 ); - CHECK_CAPS( CAN_FEC_2_3 ); - CHECK_CAPS( CAN_FEC_3_4 ); - CHECK_CAPS( CAN_FEC_4_5 ); - CHECK_CAPS( CAN_FEC_5_6 ); - CHECK_CAPS( CAN_FEC_6_7 ); - CHECK_CAPS( CAN_FEC_7_8 ); - CHECK_CAPS( CAN_FEC_8_9 ); - CHECK_CAPS( CAN_FEC_AUTO ); - CHECK_CAPS( CAN_QPSK ); - CHECK_CAPS( CAN_QAM_16 ); - CHECK_CAPS( CAN_QAM_32 ); - CHECK_CAPS( CAN_QAM_64 ); - CHECK_CAPS( CAN_QAM_128 ); - CHECK_CAPS( CAN_QAM_256 ); - CHECK_CAPS( CAN_QAM_AUTO ); - CHECK_CAPS( CAN_TRANSMISSION_MODE_AUTO ); - CHECK_CAPS( CAN_BANDWIDTH_AUTO ); - CHECK_CAPS( CAN_GUARD_INTERVAL_AUTO ); - CHECK_CAPS( CAN_HIERARCHY_AUTO ); - CHECK_CAPS( CAN_MUTE_TS ); - CHECK_CAPS( CAN_RECOVER ); -#if 0 /* Disabled because of older distributions */ - CHECK_CAPS( CAN_CLEAN_SETUP ); -#endif -#undef CHECK_CAPS - - p += sprintf( p, "
" STRINGIFY(x) "

Current frontend status:\n" ); - - if( ioctl( p_sys->i_frontend_handle, FE_READ_STATUS, &i_status ) < 0 ) - { - char buf[1000]; - strerror_r( errno, buf, sizeof( buf ) ); - p += sprintf( p, "
ioctl FE_READ_STATUS failed %s\n", buf ); - goto out; - } - -#define CHECK_STATUS( x ) \ - if ( i_status & (FE_##x) ) \ - p += sprintf( p, "" STRINGIFY(x) "\n" ); - - CHECK_STATUS( HAS_SIGNAL ); - CHECK_STATUS( HAS_CARRIER ); - CHECK_STATUS( HAS_VITERBI ); - CHECK_STATUS( HAS_SYNC ); - CHECK_STATUS( HAS_LOCK ); - CHECK_STATUS( REINIT ); - if( i_status == 0 ) - p += sprintf( p, "Tuning failed\n" ); -#undef CHECK_STATUS - - if ( i_status & FE_HAS_LOCK ) - { - int32_t i_value; - p += sprintf( p, "

Signal status:\n" ); - if( ioctl( p_sys->i_frontend_handle, FE_READ_BER, &i_value ) >= 0 ) - p += sprintf( p, "\n", - i_value ); - if( ioctl( p_sys->i_frontend_handle, FE_READ_SIGNAL_STRENGTH, - &i_value ) >= 0 ) - p += sprintf( p, "\n", - i_value ); - if( ioctl( p_sys->i_frontend_handle, FE_READ_SNR, &i_value ) >= 0 ) - p += sprintf( p, "\n", - i_value ); - } - p += sprintf( p, "
Bit error rate%d
Signal strength%d
SNR%d
" ); - -out: - vlc_mutex_lock( &p_sys->httpd_mutex ); - p_sys->b_request_frontend_info = false; - vlc_cond_signal( &p_sys->httpd_cond ); - vlc_mutex_unlock( &p_sys->httpd_mutex ); -} -#endif - /***************************************************************************** * FrontendInfo : Return information about given frontend *****************************************************************************/ @@ -1111,11 +948,11 @@ static int FrontendSetQAM( access_t *p_access ) static fe_bandwidth_t DecodeBandwidth( access_t *p_access ) { fe_bandwidth_t fe_bandwidth = 0; - int i_bandwith = var_GetInteger( p_access, "dvb-bandwidth" ); + int i_bandwidth = var_GetInteger( p_access, "dvb-bandwidth" ); - msg_Dbg( p_access, "using bandwidth=%d", i_bandwith ); + msg_Dbg( p_access, "using bandwidth=%d", i_bandwidth ); - switch( i_bandwith ) + switch( i_bandwidth ) { case 0: fe_bandwidth = BANDWIDTH_AUTO; break; case 6: fe_bandwidth = BANDWIDTH_6_MHZ; break; @@ -1467,421 +1304,3 @@ void DVRClose( access_t * p_access ) close( p_sys->i_handle ); } - - -/* - * CAM device - */ - -/***************************************************************************** - * CAMOpen : - *****************************************************************************/ -int CAMOpen( access_t *p_access ) -{ - cam_t *p_cam = &p_access->p_sys->cam; - char ca[128]; - int i_adapter, i_device; - ca_caps_t caps; - - p_cam->obj = VLC_OBJECT(p_access); - - i_adapter = var_GetInteger( p_access, "dvb-adapter" ); - i_device = var_GetInteger( p_access, "dvb-device" ); - - if( snprintf( ca, sizeof(ca), CA, i_adapter, i_device ) >= (int)sizeof(ca) ) - { - msg_Err( p_access, "snprintf() truncated string for CA" ); - ca[sizeof(ca) - 1] = '\0'; - } - memset( &caps, 0, sizeof( ca_caps_t )); - - msg_Dbg( p_access, "Opening device %s", ca ); - p_cam->fd = vlc_open(ca, O_RDWR | O_NONBLOCK); - if( p_cam->fd == -1 ) - { - msg_Warn( p_access, "CAMInit: opening CAM device failed (%m)" ); - return VLC_EGENERIC; - } - - if ( ioctl( p_cam->fd, CA_GET_CAP, &caps ) < 0 ) - { - msg_Err( p_access, "CAMInit: ioctl() error getting CAM capabilities" ); - goto error; - } - - /* Output CA capabilities */ - msg_Dbg( p_access, "CAMInit: CA interface with %d %s", caps.slot_num, - caps.slot_num == 1 ? "slot" : "slots" ); - if ( caps.slot_type & CA_CI ) - msg_Dbg( p_access, "CAMInit: CI high level interface type" ); - if ( caps.slot_type & CA_CI_LINK ) - msg_Dbg( p_access, "CAMInit: CI link layer level interface type" ); - if ( caps.slot_type & CA_CI_PHYS ) - msg_Dbg( p_access, "CAMInit: CI physical layer level interface type (not supported) " ); - if ( caps.slot_type & CA_DESCR ) - msg_Dbg( p_access, "CAMInit: built-in descrambler detected" ); - if ( caps.slot_type & CA_SC ) - msg_Dbg( p_access, "CAMInit: simple smart card interface" ); - - msg_Dbg( p_access, "CAMInit: %d available %s", caps.descr_num, - caps.descr_num == 1 ? "descrambler (key)" : "descramblers (keys)" ); - if ( caps.descr_type & CA_ECD ) - msg_Dbg( p_access, "CAMInit: ECD scrambling system supported" ); - if ( caps.descr_type & CA_NDS ) - msg_Dbg( p_access, "CAMInit: NDS scrambling system supported" ); - if ( caps.descr_type & CA_DSS ) - msg_Dbg( p_access, "CAMInit: DSS scrambling system supported" ); - - if ( caps.slot_num == 0 ) - { - msg_Err( p_access, "CAMInit: CAM module with no slots" ); - goto error; - } - - if( caps.slot_type & CA_CI_LINK ) - { - p_cam->i_ca_type = CA_CI_LINK; - } - else if( caps.slot_type & CA_CI ) - { - p_cam->i_ca_type = CA_CI; - } - else - { - p_cam->i_ca_type = -1; - msg_Err( p_access, "CAMInit: incompatible CAM interface" ); - goto error; - } - - p_cam->i_nb_slots = caps.slot_num; - memset( p_cam->pb_active_slot, 0, sizeof(bool) * MAX_CI_SLOTS ); - memset( p_cam->pb_slot_mmi_expected, 0, sizeof(bool) * MAX_CI_SLOTS ); - memset( p_cam->pb_slot_mmi_undisplayed, 0, - sizeof(bool) * MAX_CI_SLOTS ); - - return en50221_Init( p_cam ); -error: - close( p_cam->fd ); - p_cam->fd = -1; - return VLC_EGENERIC; -} - -/***************************************************************************** - * CAMPoll : - *****************************************************************************/ -int CAMPoll( access_t * p_access ) -{ - cam_t *p_cam = &p_access->p_sys->cam; - - if ( p_cam->fd == -1 ) - return VLC_EGENERIC; - - switch( p_cam->i_ca_type ) - { - case CA_CI_LINK: - if ( mdate() > p_cam->i_next_event ) - { - int ret = en50221_Poll( p_cam ); - p_cam->i_next_event = mdate() + p_cam->i_timeout; - return ret; - } - case CA_CI: - return VLC_SUCCESS; - } - msg_Err( p_access, "CAMPoll: This should not happen" ); - return VLC_EGENERIC;; -} - -#ifdef ENABLE_HTTPD -/***************************************************************************** - * CAMStatus : - *****************************************************************************/ -void CAMStatus( access_t * p_access ) -{ - access_sys_t *p_sys = p_access->p_sys; - cam_t *p_cam = &p_sys->cam; - char *p; - ca_caps_t caps; - int i; - - if ( p_sys->psz_request != NULL && *p_sys->psz_request ) - { - /* Check if we have an undisplayed MMI message : in that case we ignore - * the user input to avoid confusing the CAM. */ - for ( unsigned i_slot = 0; i_slot < p_cam->i_nb_slots; i_slot++ ) - { - if ( p_cam->pb_slot_mmi_undisplayed[i_slot] == true ) - { - p_sys->psz_request = NULL; - msg_Dbg( p_access, - "ignoring user request because of a new MMI object" ); - break; - } - } - } - - if ( p_sys->psz_request != NULL && *p_sys->psz_request ) - { - /* We have a mission to accomplish. */ - en50221_mmi_object_t mmi_object; - char *psz_request = p_sys->psz_request; - char psz_value[255]; - int i_slot; - bool b_ok = false; - - p_sys->psz_request = NULL; - - if ( HTTPExtractValue( psz_request, "slot", psz_value, - sizeof(psz_value) ) == NULL ) - { - p_sys->psz_mmi_info = strdup( "invalid request parameter\n" ); - goto out; - } - i_slot = atoi(psz_value); - - if ( HTTPExtractValue( psz_request, "open", psz_value, - sizeof(psz_value) ) != NULL ) - { - en50221_OpenMMI( p_cam, i_slot ); - return; - } - - if ( HTTPExtractValue( psz_request, "close", psz_value, - sizeof(psz_value) ) != NULL ) - { - en50221_CloseMMI( p_cam, i_slot ); - return; - } - - if ( HTTPExtractValue( psz_request, "cancel", psz_value, - sizeof(psz_value) ) == NULL ) - { - b_ok = true; - } - - if ( HTTPExtractValue( psz_request, "type", psz_value, - sizeof(psz_value) ) == NULL ) - { - p_sys->psz_mmi_info = strdup( "invalid request parameter\n" ); - goto out; - } - - if ( !strcmp( psz_value, "enq" ) ) - { - mmi_object.i_object_type = EN50221_MMI_ANSW; - mmi_object.u.answ.b_ok = b_ok; - if ( b_ok == false ) - { - mmi_object.u.answ.psz_answ = strdup(""); - } - else - { - if ( HTTPExtractValue( psz_request, "answ", psz_value, - sizeof(psz_value) ) == NULL ) - { - p_sys->psz_mmi_info = strdup( "invalid request parameter\n" ); - goto out; - } - - mmi_object.u.answ.psz_answ = strdup(psz_value); - } - } - else - { - mmi_object.i_object_type = EN50221_MMI_MENU_ANSW; - if ( b_ok == false ) - { - mmi_object.u.menu_answ.i_choice = 0; - } - else - { - if ( HTTPExtractValue( psz_request, "choice", psz_value, - sizeof(psz_value) ) == NULL ) - mmi_object.u.menu_answ.i_choice = 0; - else - mmi_object.u.menu_answ.i_choice = atoi(psz_value); - } - } - - en50221_SendMMIObject( p_cam, i_slot, &mmi_object ); - return; - } - - /* Check that we have all necessary MMI information. */ - for( unsigned i_slot = 0; i_slot < p_cam->i_nb_slots; i_slot++ ) - { - if ( p_cam->pb_slot_mmi_expected[i_slot] == true ) - return; - } - - p = p_sys->psz_mmi_info = malloc( 10000 ); - - if ( ioctl( p_cam->fd, CA_GET_CAP, &caps ) != 0 ) - { - char buf[1000]; - strerror_r( errno, buf, sizeof( buf ) ); - p += sprintf( p, "ioctl CA_GET_CAP failed (%s)\n", buf ); - goto out; - } - - /* Output CA capabilities */ - p += sprintf( p, "CA interface with %d %s, type:\n", caps.slot_num, - caps.slot_num == 1 ? "slot" : "slots" ); -#define CHECK_CAPS( x, s ) \ - if ( caps.slot_type & (CA_##x) ) \ - p += sprintf( p, "\n" ); - - CHECK_CAPS( CI, "CI high level interface" ); - CHECK_CAPS( CI_LINK, "CI link layer level interface" ); - CHECK_CAPS( CI_PHYS, "CI physical layer level interface (not supported)" ); - CHECK_CAPS( DESCR, "built-in descrambler" ); - CHECK_CAPS( SC, "simple smartcard interface" ); -#undef CHECK_CAPS - - p += sprintf( p, "
" s "
%d available %s\n", caps.descr_num, - caps.descr_num == 1 ? "descrambler (key)" : "descramblers (keys)" ); -#define CHECK_DESC( x ) \ - if ( caps.descr_type & (CA_##x) ) \ - p += sprintf( p, "\n" ); - - CHECK_DESC( ECD ); - CHECK_DESC( NDS ); - CHECK_DESC( DSS ); -#undef CHECK_DESC - - p += sprintf( p, "
" STRINGIFY(x) "
" ); - - for( unsigned i_slot = 0; i_slot < p_cam->i_nb_slots; i_slot++ ) - { - ca_slot_info_t sinfo; - - p_cam->pb_slot_mmi_undisplayed[i_slot] = false; - p += sprintf( p, "

CA slot #%d: ", i_slot ); - - sinfo.num = i_slot; - if ( ioctl( p_cam->fd, CA_GET_SLOT_INFO, &sinfo ) != 0 ) - { - char buf[1000]; - strerror_r( errno, buf, sizeof( buf ) ); - p += sprintf( p, "ioctl CA_GET_SLOT_INFO failed (%s)
\n", buf ); - continue; - } - -#define CHECK_TYPE( x, s ) \ - if ( sinfo.type & (CA_##x) ) \ - p += sprintf( p, "%s", s ); - - CHECK_TYPE( CI, "high level, " ); - CHECK_TYPE( CI_LINK, "link layer level, " ); - CHECK_TYPE( CI_PHYS, "physical layer level, " ); -#undef CHECK_TYPE - - if ( sinfo.flags & CA_CI_MODULE_READY ) - { - en50221_mmi_object_t *p_object = en50221_GetMMIObject( p_cam, - i_slot ); - - p += sprintf( p, "module present and ready

\n" ); - p += sprintf( p, "

\n" ); - p += sprintf( p, "\n", - i_slot ); - - if ( p_object == NULL ) - { - p += sprintf( p, "\n" ); - } - else - { - switch ( p_object->i_object_type ) - { - case EN50221_MMI_ENQ: - p += sprintf( p, "\n" ); - p += sprintf( p, "\n", - p_object->u.enq.psz_text ); - if ( p_object->u.enq.b_blind == false ) - p += sprintf( p, "\n" ); - else - p += sprintf( p, "\n" ); - break; - - case EN50221_MMI_MENU: - p += sprintf( p, "\n" ); - p += sprintf( p, "
%s
\n", - p_object->u.menu.psz_title ); - p += sprintf( p, "\n", - p_object->u.menu.psz_bottom ); - break; - - case EN50221_MMI_LIST: - p += sprintf( p, "\n" ); - p += sprintf( p, "\n" ); - p += sprintf( p, "
%s
%s
\n", - p_object->u.menu.psz_subtitle ); - for ( i = 0; i < p_object->u.menu.i_choices; i++ ) - p += sprintf( p, "%s
\n", i + 1, p_object->u.menu.ppsz_choices[i] ); - p += sprintf( p, "
%s
\n", - p_object->u.menu.psz_title ); - p += sprintf( p, "\n", - p_object->u.menu.psz_bottom ); - break; - - default: - p += sprintf( p, "
%s
%s
\n", - p_object->u.menu.psz_subtitle ); - for ( i = 0; i < p_object->u.menu.i_choices; i++ ) - p += sprintf( p, "%s
\n", - p_object->u.menu.ppsz_choices[i] ); - p += sprintf( p, "
%s
\n" ); - } - - p += sprintf( p, "
Unknown MMI object type

\n" ); - p += sprintf( p, "\n" ); - p += sprintf( p, "\n" ); - } - p += sprintf( p, "

\n" ); - } - else if ( sinfo.flags & CA_CI_MODULE_PRESENT ) - p += sprintf( p, "module present, not ready
\n" ); - else - p += sprintf( p, "module not present
\n" ); - } - -out: - vlc_mutex_lock( &p_sys->httpd_mutex ); - p_sys->b_request_mmi_info = false; - vlc_cond_signal( &p_sys->httpd_cond ); - vlc_mutex_unlock( &p_sys->httpd_mutex ); -} -#endif - -/***************************************************************************** - * CAMSet : - *****************************************************************************/ -int CAMSet( access_t * p_access, dvbpsi_pmt_t *p_pmt ) -{ - cam_t *p_cam = &p_access->p_sys->cam; - - if( p_cam->fd == -1 ) - { - dvbpsi_DeletePMT( p_pmt ); - return VLC_EGENERIC; - } - - en50221_SetCAPMT( p_cam, p_pmt ); - - return VLC_SUCCESS; -} - -/***************************************************************************** - * CAMClose : - *****************************************************************************/ -void CAMClose( access_t * p_access ) -{ - cam_t *p_cam = &p_access->p_sys->cam; - - if ( p_cam->fd == -1 ) - return; - - en50221_End( p_cam ); - close( p_cam->fd ); -}