Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] ?: How can I properly tune my DVB-S card with the NAPI
Have a look at this example. It works for me. Although I couldn't find
Vox on Hotbird, but I have some Problems with that dish. I also added
it to the public CVS (in test/test_switch.c)
Marcus
/*
* test_switch.c - Test program for new API
*
* Copyright (C) 2001 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@convergence.de>
for convergence integrated media GmbH
*
* 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.
*
* 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, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <ost/dmx.h>
#include <ost/frontend.h>
#include <ost/sec.h>
#include <ost/video.h>
int fd_frontend;
int fd_sec;
int fd_demuxa;
int fd_demuxv;
int fd_demuxtt;
struct secCommand scmd;
struct secCmdSequence scmds;
struct dmxPesFilterParams pesFilterParamsV;
struct dmxPesFilterParams pesFilterParamsA;
struct dmxPesFilterParams pesFilterParamsTT;
struct qpskParameters qpsk;
int front_type;
set_front(void)
{
feStatus stat = 0;
int i, freq;
uint32_t soff;
scmds.miniCommand = SEC_MINI_NONE;
scmds.numCommands = 1;
scmds.commands = &scmd;
soff = qpsk.SymbolRate/16000;
if (ioctl(fd_sec, SEC_SEND_SEQUENCE, &scmds) < 0)
perror("setfront sec");
usleep(100000);
freq = qpsk.iFrequency;
stat = tune_it(&qpsk);
for (i=2; i<10; i++) {
if (stat & FE_HAS_SIGNAL) {
//cerr << "got signal" << endl;
break;
}
if (i&1)
qpsk.iFrequency = freq+soff*(i/2);
else
qpsk.iFrequency = freq-soff*(i/2);
stat = tune_it(&qpsk);
}
}
set_diseqc_nb(int nr)
{
scmd.type=0;
scmd.u.diseqc.addr = 0x10;
scmd.u.diseqc.cmd = 0x38;
scmd.u.diseqc.numParams = 1;
scmd.u.diseqc.params[0] = 0xF0 | ((nr * 4) & 0x0F) |
(scmds.continuousTone == SEC_TONE_ON ? 1 : 0) |
(scmds.voltage==SEC_VOLTAGE_18 ? 2 : 0);
}
set_ttpid(ushort ttpid)
{
if (ttpid==0 || ttpid==0xffff || ttpid==0x1fff) {
ioctl(fd_demuxtt, DMX_STOP, 0);
return;
}
pesFilterParamsTT.pid = ttpid;
pesFilterParamsTT.input = DMX_IN_FRONTEND;
pesFilterParamsTT.output = DMX_OUT_DECODER;
pesFilterParamsTT.pesType = DMX_PES_TELETEXT;
pesFilterParamsTT.flags = DMX_IMMEDIATE_START;
if (ioctl(fd_demuxtt, DMX_SET_PES_FILTER,
&pesFilterParamsTT) < 0) {
printf("PID=%04x\n", ttpid);
perror("set_ttpid");
}
}
set_vpid(ushort vpid)
{
if (vpid==0 || vpid==0xffff || vpid==0x1fff) {
ioctl(fd_demuxv, DMX_STOP, 0);
return;
}
pesFilterParamsV.pid = vpid;
pesFilterParamsV.input = DMX_IN_FRONTEND;
pesFilterParamsV.output = DMX_OUT_DECODER;
pesFilterParamsV.pesType = DMX_PES_VIDEO;
pesFilterParamsV.flags = DMX_IMMEDIATE_START;
if (ioctl(fd_demuxv, DMX_SET_PES_FILTER,
&pesFilterParamsV) < 0)
perror("set_vpid");
}
set_apid(ushort apid)
{
if (apid==0 || apid==0xffff || apid==0x1fff) {
ioctl(fd_demuxa, DMX_STOP, apid);
return;
}
pesFilterParamsA.pid = apid;
pesFilterParamsA.input = DMX_IN_FRONTEND;
pesFilterParamsA.output = DMX_OUT_DECODER;
pesFilterParamsA.pesType = DMX_PES_AUDIO;
pesFilterParamsA.flags = DMX_IMMEDIATE_START;
if (ioctl(fd_demuxa, DMX_SET_PES_FILTER,
&pesFilterParamsA) < 0)
perror("set_apid");
}
tune_it(struct qpskParameters *qpsk)
{
feStatus stat = 0;
int res;
struct qpskEvent event;
int count = 0;
if (ioctl(fd_frontend, QPSK_TUNE, qpsk) <0)
perror("setfront front");
if ( (res = ioctl(fd_frontend, QPSK_GET_EVENT, &event))
== -EBUFFEROVERFLOW)
res = ioctl(fd_frontend, QPSK_GET_EVENT, &event);
if (res < 0)
perror("qpsk ge event");
while( !(stat & FE_HAS_SIGNAL) && count < 10){
if (ioctl(fd_frontend, FE_READ_STATUS, &stat) < 0)
perror("set_tp stat");
count++;
}
return stat;
}
set_tp(uint *freq, int ttk, int pol, uint srate, int dis)
{
if (*freq < 11800000) {
qpsk.iFrequency = (*freq - 9750000);
scmds.continuousTone = SEC_TONE_OFF;
} else {
qpsk.iFrequency = (*freq - 10600000);
scmds.continuousTone = SEC_TONE_ON;
}
if (pol) scmds.voltage = SEC_VOLTAGE_18;
else scmds.voltage = SEC_VOLTAGE_13;
set_diseqc_nb(dis);
qpsk.SymbolRate = srate;
qpsk.FEC_inner = 0;
}
get_front(void)
{
set_vpid(0);
set_apid(0);
set_ttpid(0);
scmds.voltage = SEC_VOLTAGE_13;
scmds.miniCommand = SEC_MINI_NONE;
scmds.continuousTone = SEC_TONE_OFF;
scmds.numCommands=1;
scmds.commands=&scmd;
qpsk.iFrequency=(12666000-10600000);
qpsk.SymbolRate=22000000;
qpsk.FEC_inner=0;
}
main()
{
int freq;
fd_demuxtt = open("/dev/ost/demux", O_RDWR|O_NONBLOCK);
fd_frontend = open("/dev/ost/qpskfe", O_RDWR);
fd_sec = open("/dev/ost/sec", O_RDWR);
fd_demuxa = open("/dev/ost/demux", O_RDWR|O_NONBLOCK);
fd_demuxv = open("/dev/ost/demux", O_RDWR|O_NONBLOCK);
// JSTV on Hotbird (diseqc = 1)
get_front();
set_vpid(0x7d0);
set_apid(0x7d2);
set_ttpid(0);
freq = 12597000;
set_tp(&freq, 1, 0, 27500000, 1);
set_front();
}
---
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index