]> git.sesse.net Git - vlc/blobdiff - modules/access/dvb/linux_dvb.c
access: info.i_size -> control(ACCESS_GET_SIZE)
[vlc] / modules / access / dvb / linux_dvb.c
index e3f3cac250b41989b226cc904fbe9cfafc4ba186..7c12e89ccaec32bcc47413109cf57898b44e7da1 100644 (file)
@@ -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 <nitrox@via.ecp.fr>
  *          Johan Bilien <jobi@via.ecp.fr>
  *          Christophe Massiot <massiot@via.ecp.fr>
  *          David Kaplan <david@of1.org>
  *
- * 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.
  *****************************************************************************/
 
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <poll.h>
 
 /* DVB Card Drivers */
 #include <linux/dvb/version.h>
 #include <linux/dvb/dmx.h>
 #include <linux/dvb/frontend.h>
 
-/* Include dvbpsi headers */
-# include <dvbpsi/dvbpsi.h>
-# include <dvbpsi/descriptor.h>
-# include <dvbpsi/pat.h>
-# include <dvbpsi/pmt.h>
-# include <dvbpsi/dr.h>
-# include <dvbpsi/psi.h>
-# include <dvbpsi/demux.h>
-# include <dvbpsi/sdt.h>
-
 #include "dvb.h"
 #include "scan.h"
-#include "en50221.h"
 
 #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
@@ -420,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 )
     {
@@ -484,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, "<table border=1><tr><th>name</th><td>%s</td></tr>\n",
-                  p_frontend->info.name );
-    switch( p_frontend->info.type )
-    {
-        case FE_QPSK:
-            p += sprintf( p, "<tr><th>type</th><td>QPSK (DVB-S)</td></tr>\n" );
-            break;
-        case FE_QAM:
-            p += sprintf( p, "<tr><th>type</th><td>QAM (DVB-C)</td></tr>\n" );
-            break;
-        case FE_OFDM:
-            p += sprintf( p, "<tr><th>type</th><td>OFDM (DVB-T)</td></tr>\n" );
-            break;
-#if 0 /* DVB_API_VERSION == 3 */
-        case FE_MEMORY:
-            p += sprintf( p, "<tr><th>type</th><td>MEMORY</td></tr>\n" );
-            break;
-        case FE_NET:
-            p += sprintf( p, "<tr><th>type</th><td>NETWORK</td></tr>\n" );
-            break;
-#endif
-        default:
-            p += sprintf( p, "<tr><th>type</th><td>UNKNOWN (%d)</td></tr>\n",
-                          p_frontend->info.type );
-            goto out;
-    }
-#define CHECK_INFO( x )                                                     \
-    p += sprintf( p,                                                        \
-                  "<tr><th>" STRINGIFY(x) "</th><td>%u</td></tr>\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, "</table><p>Frontend capability list:\n<table border=1>" );
-
-#define CHECK_CAPS( x )                                                     \
-    if ( p_frontend->info.caps & (FE_##x) )                                 \
-        p += sprintf( p, "<tr><td>" STRINGIFY(x) "</td></tr>\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, "</table><p>Current frontend status:\n<table border=1>" );
-
-    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, "</table>ioctl FE_READ_STATUS failed %s\n", buf );
-        goto out;
-    }
-
-#define CHECK_STATUS( x )                                                   \
-    if ( i_status & (FE_##x) )                                              \
-        p += sprintf( p, "<tr><td>" STRINGIFY(x) "</td></tr>\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, "<tr><td>Tuning failed</td></tr>\n" );
-#undef CHECK_STATUS
-
-    if ( i_status & FE_HAS_LOCK )
-    {
-        int32_t i_value;
-        p += sprintf( p, "</table><p>Signal status:\n<table border=1>" );
-        if( ioctl( p_sys->i_frontend_handle, FE_READ_BER, &i_value ) >= 0 )
-            p += sprintf( p, "<tr><th>Bit error rate</th><td>%d</td></tr>\n",
-                          i_value );
-        if( ioctl( p_sys->i_frontend_handle, FE_READ_SIGNAL_STRENGTH,
-                   &i_value ) >= 0 )
-            p += sprintf( p, "<tr><th>Signal strength</th><td>%d</td></tr>\n",
-                          i_value );
-        if( ioctl( p_sys->i_frontend_handle, FE_READ_SNR, &i_value ) >= 0 )
-            p += sprintf( p, "<tr><th>SNR</th><td>%d</td></tr>\n",
-                          i_value );
-    }
-    p += sprintf( p, "</table>" );
-
-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
  *****************************************************************************/
@@ -1107,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;
@@ -1463,98 +1304,3 @@ void DVRClose( access_t * p_access )
 
     close( p_sys->i_handle );
 }
-
-
-/*
- * CAM device
- */
-
-/*****************************************************************************
- * CAMOpen :
- *****************************************************************************/
-int CAMOpen( access_t *p_access )
-{
-    int i_adapter = var_GetInteger( p_access, "dvb-adapter" );
-    int i_device = var_GetInteger( p_access, "dvb-device" );
-
-    char ca[128];
-    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';
-    }
-
-    msg_Dbg( p_access, "Opening device %s", ca );
-    int fd = vlc_open(ca, O_RDWR | O_NONBLOCK);
-    if( fd == -1 )
-    {
-        msg_Warn( p_access, "CAMInit: opening CAM device failed (%m)" );
-        return VLC_EGENERIC;
-    }
-
-    if( !(p_access->p_sys->p_cam = en50221_Init( VLC_OBJECT(p_access), fd )) )
-    {
-        close( fd );
-        return VLC_EGENERIC;
-    }
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * CAMPoll :
- *****************************************************************************/
-void CAMPoll( access_t * p_access )
-{
-    cam_t *p_cam = p_access->p_sys->p_cam;
-    if( p_cam != NULL )
-        en50221_Poll( p_cam );
-}
-
-#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->p_cam;
-
-    p_sys->psz_mmi_info = en50221_Status( p_cam, p_sys->psz_request );
-    p_sys->psz_request = NULL;
-    if( p_sys->psz_mmi_info != NULL )
-    {
-        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->p_cam;
-
-    if( p_cam == NULL )
-    {
-        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->p_cam;
-
-    if ( p_cam != NULL )
-         en50221_End( p_cam );
-}