newbie q: dvbsec_set() - frontend setup howto

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

I newbie in DVB API such as in DVB technology.
Now I try to make simple userspace application to set up one tv channel and 
store MPEG video stream from budget DVB card.
libdvbapi and libdvbsec libraries used (I guess it's enough for my task, so I 
try to avoid a lots of ioctl's), so the task is to setup frontend using 
parameters passed to my utility as parameters.
So now I stopped when try to set up frontend from my application.
I guess it's easy task and I just miss something,
That's why I ask here to help - may be someone experienced can view to my 
source code (easydvb-fe.c attached) and tell me what I miss (or what's 
wrong).

Output:

# ./easydvb -f 10723 -s 27500 -P 163
DEBUG: Freq=10723
DVB Device: DST DVB-S
Current: Freq: 1997000kHz       SymbolRate: 27500000    Pol.: 2 FEC: 9  signal 
unlocked
Set up frontend: Freq=10723000kHz, S/R=27500000
Set DVB Frontend (0)
Failed to set up frontend
Set up:  Freq: 1997000kHz       SymbolRate: 27500000    Pol.: 2 FEC: 9  
Signal: no unlocked
Set DVB Frontend (1)
Failed to set up frontend
Set up:  Freq: 1997000kHz       SymbolRate: 27500000    Pol.: 2 FEC: 9  
Signal: no unlocked
Set DVB Frontend (2)
Failed to set up frontend
Set up:  Freq: 1997000kHz       SymbolRate: 27500000    Pol.: 2 FEC: 9  
Signal: no unlocked
Set DVB Frontend (3)
Failed to set up frontend
Set up:  Freq: 1997000kHz       SymbolRate: 27500000    Pol.: 2 FEC: 9  
Signal: no unlocked
Set DVB Frontend (4)
Failed to set up frontend
Set up:  Freq: 1997000kHz       SymbolRate: 27500000    Pol.: 2 FEC: 9  
Signal: no unlocked

root@voodsat:/usr/src/dvb-apps/util/easydvb# scan -c
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
WARNING: filter timeout pid 0x0011
WARNING: filter timeout pid 0x0000
dumping lists (0 services)
Done.


-- 
Best regards, Nick Fedchik
/********************************************************************
* Description: easydvb - trivial application to receive video
* from Twinhan 1025 DVB adapter
* Author: Nick Fedchik
* Created at: Thu Oct 26 19:43:07 EEST 2006
* Computer: voodsat 
* System: Linux 2.6.18-dvb on i686
*    
* Copyright (c) 2006 Nick Fedchik  All rights reserved.
*
********************************************************************/


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#include <signal.h>
#include <assert.h>
#include <glob.h>
#include <ctype.h>


#include <libdvbapi/dvbfe.h>
#include <libdvbapi/dvbdemux.h>
#include <libdvbsec/dvbsec_api.h>

#include <linux/dvb/frontend.h>

#define MPEG_FILE "easydvb.mpeg"


struct dvbfe_handle {
    int fd;
    enum dvbfe_type type;
    char *name;
};


int main(int argc, char *argv[])
{
    struct dvbfe_handle *h_fe;
    struct dvbfe_parameters params;
    struct dvbfe_info dvb_info;
    struct dvbsec_config sec_config;

    // start the DVB stuff
    int adapter_id = 0;
    int frontend_id = 0;
    int demux_id = 0;
    int dvr_id = 0;
    int locked = 0;

    int written;
    int i;
    int res;
    int opt;

/* Parameteres parsing code begin */
/* 
* f - frequency (unsigned integer)
* s - symbol rate in KB
* P - PID (for video PES)
*/

// Pass params for 1+1 TV Channel
// 1PLUS1:10723:h:1:27500:769:770:3

    while ((opt = getopt(argc, argv, "h?f:s:P:p:")) != -1) {
	switch (opt) {
	case '?':
	case 'h':
	default:
	    printf("Usage: %s <param1> \n", argv[0]);
	case 'f':
	    params.frequency = strtoul(optarg, NULL, 0);
	    printf("DEBUG: Freq=%d\n", params.frequency);
	    params.frequency *= 1000;
	    break;
	case 's':		// symbol rate
	    params.u.dvbs.symbol_rate = strtoul(optarg, NULL, 0);
	    params.u.dvbs.symbol_rate *= 1000;
	    break;
	case 'P':		// PID
	    pid = strtoul(optarg, NULL, 0);	//Raw...
	    break;
	case 'p':
	    pol = strcmp("h", optarg);	//Raw...
	    break;
	}
    };

/* Parameteres parsing code end */


/* DVB Frontend area */
    // open the frontend
    h_fe = dvbfe_open(adapter_id, frontend_id, 0 /*1:readonly, 0:rw */ );

    if (NULL == h_fe) {
	fprintf(stderr, "Failed to open frontend\n");
	exit(1);
    }
/* Param 2 - Mask:  DVBFE_INFO_LOCKSTATUS | DVBFE_INFO_FEPARAMS */
    locked = dvbfe_get_info(h_fe, DVBFE_INFO_LOCKSTATUS | DVBFE_INFO_FEPARAMS,
			    &dvb_info, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0);
    if (locked) {
	printf("DVB Device: %s\n", dvb_info.name);	// DST DVB-S
	printf("Current: Freq: %ukHz\t", dvb_info.feparams.frequency);
	printf("SymbolRate: %d\t", dvb_info.feparams.u.dvbs.symbol_rate);
	printf("Pol.: %d\t", dvb_info.feparams.inversion);
	printf("FEC: %d\t", dvb_info.feparams.u.dvbs.fec_inner);
	printf("%s %slocked\n", dvb_info.signal ? "" : "signal",
	       dvb_info.lock ? "" : "un");
    } else {
	fprintf(stderr, "Failed to get frontend info\n");
	dvbfe_close(h_fe);
	exit(1);
    }

// TODO - Set our specific values - to our transponder
    params.inversion = DVBFE_INVERSION_AUTO;
    params.u.dvbs.fec_inner = DVBFE_FEC_AUTO;
    printf("Set up frontend: Freq=%ukHz, S/R=%d\n", params.frequency,
	   params.u.dvbs.symbol_rate);
    // five tries
    for (i = 0; i < 5; i++) {
	/* sat_no, pol, hiband */
	printf("Set DVB Frontend (%d)\n", i);
	sec_config.config_type = DVBSEC_CONFIG_STANDARD;
	res = dvbsec_set(h_fe, &sec_config, DISEQC_POLARIZATION_H,	/* enum dvbsec_diseqc_polarization polarization, */
			 DISEQC_SWITCH_A,	/* enum dvbsec_diseqc_switch sat_pos, DISEQC_SWITCH_A */
			 DISEQC_SWITCH_UNCHANGED,	/* enum dvbsec_diseqc_switch switch_option, */
			 &params, 2 /*timeout */ );

	if (0 > res)
	    fprintf(stderr, "Failed to set up frontend\n");
	locked =
	    dvbfe_get_info(h_fe, DVBFE_INFO_FEPARAMS, &dvb_info,
			   DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0);
	if (locked) {
	    printf("Set up:  Freq: %dkHz\t", dvb_info.feparams.frequency);
	    printf("SymbolRate: %d\t", dvb_info.feparams.u.dvbs.symbol_rate);
	    printf("Pol.: %d\t", dvb_info.feparams.inversion);
	    printf("FEC: %d\t", dvb_info.feparams.u.dvbs.fec_inner);
	    printf("Signal: %s %slocked\n", dvb_info.signal ? "yes" : "no",
		   dvb_info.lock ? "" : "un");
	}
    }
/* DVB Frontend area end */

    // Close fronend
    dvbfe_close(h_fe);

    return 0;
}
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux