[vlc-devel] DVB-S2 patch

Jean-Paul Saman jpsaman at gmail.com
Thu Oct 15 09:36:33 CEST 2009


On Mon, Oct 12, 2009 at 10:47 AM, Lou Otway <lotway at nildram.co.uk> wrote:

> Hi,
>
> I've used the attached code to tune DVB-S2 adapters, under Linux, with the
> v4l drivers.
>
> The patch is against VLC 0.9.8a.
>

Could you update it against git master branch?

The patch looks ok. I cannot test it, because I do not own an DVB-S2 card or
satellite dish. So if someone of the team has one, please test.

gtz
Jean-Paul Saman


>
> Thanks,
>
> Lou
>
>
>
> diff -urN --exclude 'Make*' vlc-0.9.8a.orig/modules/access/dvb/access.c
> vlc-0.9.8a/modules/access/dvb/access.c
> --- vlc-0.9.8a.orig/modules/access/dvb/access.c 2008-10-15
> 20:31:20.000000000 +0100
> +++ vlc-0.9.8a/modules/access/dvb/access.c      2009-02-25
> 14:16:50.000000000 +0000
> @@ -86,6 +86,9 @@
>  #define DEVICE_TEXT N_("Device number to use on adapter")
>  #define DEVICE_LONGTEXT ""
>
> +#define DELIVERY_TEXT N_("Delivery System")
> +#define DELIVERY_LONGTEXT ""
> +
>  #define FREQ_TEXT N_("Transponder/multiplex frequency")
>  #define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
>
> @@ -109,6 +112,9 @@
>  #define HIGH_VOLTAGE_LONGTEXT N_("Enable high voltage if your cables are "
> \
>     "particularly long. This is not supported by all frontends.")
>
> +#define MODULATION_2G_TEXT N_("2nd Gen Modulation")
> +#define MODULATION_2G_LONGTEXT N_("DVB-S2, C2 and T2 support")
> +
>  #define TONE_TEXT N_("22 kHz tone")
>  #define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto].")
>
> @@ -196,6 +202,8 @@
>                  false );
>     add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
>                  true );
> +    add_integer( "dvb-delivery", 0, NULL, DELIVERY_TEXT,
> DELIVERY_LONGTEXT,
> +                 true );
>     add_integer( "dvb-frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT,
>                  false );
>     add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT,
> INVERSION_LONGTEXT,
> @@ -208,6 +216,9 @@
>                  true );
>     add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT,
>                  true );
> +    // TODO: Added 2G modulation
> +    add_bool( "dvb-2g-modulation", 0, NULL, MODULATION_2G_TEXT,
> +               MODULATION_2G_LONGTEXT, true );
>     add_bool( "dvb-high-voltage", 0, NULL, HIGH_VOLTAGE_TEXT,
>               HIGH_VOLTAGE_LONGTEXT, true );
>     add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT,
> @@ -661,12 +672,15 @@
>     /* */
>     var_Create( p_access, "dvb-adapter", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT
> );
> +    var_Create( p_access, "dvb-delivery", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-frequency", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-inversion", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-budget-mode", VLC_VAR_BOOL |
> VLC_VAR_DOINHERIT );
>
>     /* */
> +    //TODO: Added 2nd gen mod
> +    var_Create( p_access, "dvb-2g-modulation", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-satno", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT
> );
>     var_Create( p_access, "dvb-voltage", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT );
>     var_Create( p_access, "dvb-high-voltage", VLC_VAR_BOOL |
> VLC_VAR_DOINHERIT );
> @@ -745,8 +759,9 @@
>         else GET_OPTION_INT("inversion")
>         else GET_OPTION_BOOL("probe")
>         else GET_OPTION_BOOL("budget-mode")
> -
> +               else GET_OPTION_INT("dvb-delivery")
>         else GET_OPTION_INT("voltage")
> +        else GET_OPTION_BOOL("dvb-2g-modulation")
>         else GET_OPTION_BOOL("high-voltage")
>         else GET_OPTION_INT("tone")
>         else GET_OPTION_INT("satno")
> diff -urN --exclude 'Make*' vlc-0.9.8a.orig/modules/access/dvb/linux_dvb.c
> vlc-0.9.8a/modules/access/dvb/linux_dvb.c
> --- vlc-0.9.8a.orig/modules/access/dvb/linux_dvb.c      2008-10-15
> 20:31:20.000000000 +0100
> +++ vlc-0.9.8a/modules/access/dvb/linux_dvb.c   2009-02-25
> 14:18:12.000000000 +0000
> @@ -82,6 +82,7 @@
>  #define FRONTEND_LOCK_TIMEOUT 10000000 /* 10 s */
>
>  /* Local prototypes */
> +static fe_modulation_t DecodeModulationPSK( access_t *p_access );
>  static int FrontendInfo( access_t * );
>  static int FrontendSetQPSK( access_t * );
>  static int FrontendSetQAM( access_t * );
> @@ -133,6 +134,7 @@
>             return VLC_EGENERIC;
>         }
>
> +        msg_Dbg( p_access, "Frontend open - about to check type" );
>         switch( p_frontend->info.type )
>         {
>         case FE_OFDM:
> @@ -142,7 +144,16 @@
>             psz_real = "DVB-C";
>             break;
>         case FE_QPSK:
> -            psz_real = "DVB-S";
> +                msg_Dbg( p_access, "Checking for DVB-S or DVB-S2" );
> +                if (p_frontend->info.caps & FE_CAN_2G_MODULATION)
> +               {
> +                       // If can do 2G Mod, we have a DVB-S2 card
> +                       psz_real = "DVB-S2";
> +               }
> +               else
> +               {
> +                       psz_real = "DVB-S";
> +               }
>             break;
>         case FE_ATSC:
>             psz_real = "ATSC";
> @@ -240,7 +251,7 @@
>     case FE_QPSK:
>         if( FrontendSetQPSK( p_access ) < 0 )
>         {
> -            msg_Err( p_access, "DVB-S: tuning failed" );
> +            msg_Err( p_access, "DVB-S/DVB-S2: tuning failed" );
>             return VLC_EGENERIC;
>         }
>         break;
> @@ -541,7 +552,14 @@
>     switch( p_frontend->info.type )
>     {
>         case FE_QPSK:
> -            msg_Dbg( p_access, "  type = QPSK (DVB-S)" );
> +               if (p_frontend->info.caps & FE_CAN_2G_MODULATION)
> +               {
> +                       msg_Dbg( p_access, "  type = DVB-S2" );
> +               }
> +               else
> +               {
> +                       msg_Dbg( p_access, "  type = DVB-S" );
> +               }
>             break;
>         case FE_QAM:
>             msg_Dbg( p_access, "  type = QAM (DVB-C)" );
> @@ -631,6 +649,8 @@
>         msg_Dbg(p_access, "  card can mute TS");
>     if( p_frontend->info.caps & FE_CAN_RECOVER)
>         msg_Dbg(p_access, "  card can recover from a cable unplug");
> +    if( p_frontend->info.caps & FE_CAN_2G_MODULATION)
> +        msg_Dbg(p_access, "  card can do 2nd gen modulation");
>     if( p_frontend->info.caps & FE_CAN_8VSB)
>         msg_Dbg(p_access, "  card can do 8vsb");
>     if( p_frontend->info.caps & FE_CAN_16VSB)
> @@ -664,6 +684,9 @@
>     return fe_inversion;
>  }
>
>
> +/*****************************************************************************
> + * DecodeFEC: Returns FEC value
> +
> *****************************************************************************/
>  static fe_code_rate_t DecodeFEC( access_t *p_access, int i_val )
>  {
>     fe_code_rate_t      fe_fec = FEC_NONE;
> @@ -682,6 +705,11 @@
>         case 7: fe_fec = FEC_7_8; break;
>         case 8: fe_fec = FEC_8_9; break;
>         case 9: fe_fec = FEC_AUTO; break;
> +
> +        // Added new values
> +        case 10: fe_fec = FEC_3_5; break;
> +        case 11: fe_fec = FEC_9_10; break;
> +
>         default:
>             /* cannot happen */
>             fe_fec = FEC_NONE;
> @@ -691,6 +719,9 @@
>     return fe_fec;
>  }
>
>
> +/*****************************************************************************
> + * DecodeModulationQAM: Returns QAM modulation
> +
> *****************************************************************************/
>  static fe_modulation_t DecodeModulationQAM( access_t *p_access )
>  {
>     switch( var_GetInteger( p_access, "dvb-modulation" ) )
> @@ -706,6 +737,10 @@
>             return QAM_AUTO;
>     }
>  }
> +
>
> +/*****************************************************************************
> + * DecodeModulationOFDM : Returns OFDM modulation
> +
> *****************************************************************************/
>  static fe_modulation_t DecodeModulationOFDM( access_t *p_access )
>  {
>     switch( var_GetInteger( p_access, "dvb-modulation" ) )
> @@ -722,6 +757,9 @@
>             return QAM_AUTO;
>     }
>  }
>
> +/*****************************************************************************
> + * DecodeModulationATSC : Returns ATSC modulation
> +
> *****************************************************************************/
>  static fe_modulation_t DecodeModulationATSC( access_t *p_access )
>  {
>     switch( var_GetInteger( p_access, "dvb-modulation" ) )
> @@ -735,7 +773,37 @@
>  }
>
>
>  /*****************************************************************************
> - * FrontendSetQPSK : controls the FE device
> + * DecodeDeliverySystem : Returns delivery system
> +
> *****************************************************************************/
> +static fe_delivery_system_t DecodeDeliverySystem( access_t *p_access )
> +{
> +       return var_GetInteger( p_access, "dvb-delivery" );
> +}
> +
>
> +/*****************************************************************************
> + * DecodeModulationPSK : Returns DVB-S modulation
> +
> *****************************************************************************/
> +static fe_modulation_t DecodeModulationPSK( access_t *p_access )
> +{
> +       int mod;
> +
> +       mod = var_GetInteger( p_access, "dvb-modulation" );
> +
> +       switch(mod)
> +    {
> +        case QPSK:     return QPSK;
> +        case PSK_8:            return PSK_8;
> +        case APSK_16:          return APSK_16;
> +        case APSK_32:  return APSK_32;
> +        default:
> +            msg_Dbg( p_access, "DVB modulation not set, got %d, using
> QPSK",mod);
> +            return QPSK;
> +    }
> +}
> +
> +
>
> +/*****************************************************************************
> + * DecodeVoltage : controls the FE device
>
>  *****************************************************************************/
>  static fe_sec_voltage_t DecodeVoltage( access_t *p_access )
>  {
> @@ -890,18 +958,27 @@
>     return 0;
>  }
>
>
> +/*****************************************************************************
> + * FrontendSetQPSK : controls the FE device
> +
> *****************************************************************************/
>  static int FrontendSetQPSK( access_t *p_access )
>  {
>     access_sys_t *p_sys = p_access->p_sys;
>     struct dvb_frontend_parameters fep;
> +    fe_modulation_t modulation;
>     int i_ret;
>     vlc_value_t val;
>     int i_frequency, i_lnb_slof = 0, i_lnb_lof1, i_lnb_lof2 = 0;
> +    fe_delivery_system_t delSys;
>
>     /* Prepare the fep structure */
>     var_Get( p_access, "dvb-frequency", &val );
>     i_frequency = val.i_int;
>
> +    modulation = DecodeModulationPSK(p_access);
> +    // TODO: is this a valid way of determining between DVB-S and DVB-S2?
> +    delSys = DecodeDeliverySystem(p_access);
> +
>     var_Get( p_access, "dvb-lnb-lof1", &val );
>     if ( val.i_int == 0 )
>     {
> @@ -983,21 +1060,36 @@
>         return VLC_EGENERIC;
>     }
>
> -    /* Empty the event queue */
> -    for( ; ; )
> -    {
> -        struct dvb_frontend_event event;
> -        if ( ioctl( p_sys->i_frontend_handle, FE_GET_EVENT, &event ) < 0
> -              && errno == EWOULDBLOCK )
> -            break;
> -    }
> +       struct dvb_frontend_event ev;
> +       struct dtv_property p_tune[] = {
> +               { .cmd = DTV_DELIVERY_SYSTEM,   .u.data = delSys },
> +               { .cmd = DTV_FREQUENCY,                 .u.data =
> fep.frequency },
> +               { .cmd = DTV_MODULATION,                .u.data =
> modulation },
> +               { .cmd = DTV_SYMBOL_RATE,               .u.data =
> fep.u.qpsk.symbol_rate },
> +               { .cmd = DTV_INNER_FEC,                 .u.data =
> fep.u.qpsk.fec_inner },
> +               { .cmd = DTV_INVERSION,                 .u.data =
> fep.inversion },
> +               { .cmd = DTV_ROLLOFF,                   .u.data =
> ROLLOFF_AUTO },
> +               { .cmd = DTV_TUNE },
> +       };
> +       struct dtv_properties cmdseq_tune = {
> +               .num = 8,               //Important - this must match the
> count of .cmd's above
> +               .props = p_tune
> +       };
> +
> +       /* discard stale QPSK events */
> +       while (1) {
> +               if (ioctl(p_sys->i_frontend_handle, FE_GET_EVENT, &ev) ==
> -1)
> +                       break;
> +       }
> +
> +       msg_Dbg(p_access,"About to tune: mod=%d delivery=%d,
> freq=%d",modulation,delSys,fep.frequency);
>
>     /* Now send it all to the frontend device */
> -    if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep ))
> < 0 )
> -    {
> -        msg_Err( p_access, "DVB-S: setting frontend failed (%d) %m", i_ret
> );
> -        return VLC_EGENERIC;
> -    }
> +       if ((ioctl(p_sys->i_frontend_handle, FE_SET_PROPERTY,
> &cmdseq_tune)) == -1)
> +       {
> +               msg_Err(p_access,"FE_SET_PROPERTY TUNE failed");
> +               return VLC_EGENERIC;
> +       }
>
>     return VLC_SUCCESS;
>  }
> @@ -1493,7 +1585,7 @@
>         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" );
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20091015/d1b15531/attachment.html>


More information about the vlc-devel mailing list