3 Copyright (C) Dave Chapman 2001,2002
5 Modified for use with MPlayer, for details see the changelog at
6 http://svn.mplayerhq.hu/mplayer/trunk/
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 Or, point your browser to http://www.gnu.org/copyleft/gpl.html
29 #include <sys/ioctl.h>
38 #include <linux/dvb/dmx.h>
39 #include <linux/dvb/frontend.h>
40 char* dvb_frontenddev
[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"};
41 char* dvb_dvrdev
[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"};
42 char* dvb_demuxdev
[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"};
46 #include <ost/frontend.h>
47 char* dvb_frontenddev
[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"};
48 char* dvb_dvrdev
[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"};
49 static char* dvb_secdev
[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"};
50 char* dvb_demuxdev
[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"};
58 int dvb_get_tuner_type(int fe_fd
)
61 struct dvb_frontend_info fe_info
;
68 res
= ioctl(fe_fd
, FE_GET_INFO
, &fe_info
);
71 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "FE_GET_INFO error: %d, FD: %d\n\n", errno
, fe_fd
);
78 mp_msg(MSGT_DEMUX
, MSGL_V
, "TUNER TYPE SEEMS TO BE DVB-T\n");
82 mp_msg(MSGT_DEMUX
, MSGL_V
, "TUNER TYPE SEEMS TO BE DVB-S\n");
86 mp_msg(MSGT_DEMUX
, MSGL_V
, "TUNER TYPE SEEMS TO BE DVB-C\n");
91 mp_msg(MSGT_DEMUX
, MSGL_V
, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
95 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "UNKNOWN TUNER TYPE\n");
101 int dvb_set_ts_filt(int fd
, uint16_t pid
, dmx_pes_type_t pestype
);
103 int dvb_open_devices(dvb_priv_t
*priv
, int n
, int demux_cnt
)
107 priv
->fe_fd
= open(dvb_frontenddev
[n
], O_RDWR
| O_NONBLOCK
);
110 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", dvb_frontenddev
[n
], errno
);
116 priv
->sec_fd
= open(dvb_secdev
[n
], O_RDWR
);
119 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR OPENING SEC DEVICE %s: ERRNO %d\n", dvb_secdev
[n
], errno
);
124 priv
->demux_fds_cnt
= 0;
125 mp_msg(MSGT_DEMUX
, MSGL_V
, "DVB_OPEN_DEVICES(%d)\n", demux_cnt
);
126 for(i
= 0; i
< demux_cnt
; i
++)
128 priv
->demux_fds
[i
] = open(dvb_demuxdev
[n
], O_RDWR
| O_NONBLOCK
);
129 if(priv
->demux_fds
[i
] < 0)
131 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR OPENING DEMUX 0: %d\n", errno
);
136 mp_msg(MSGT_DEMUX
, MSGL_V
, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i
, dvb_demuxdev
[n
], priv
->demux_fds
[i
], priv
->demux_fds_cnt
);
137 priv
->demux_fds_cnt
++;
142 priv
->dvr_fd
= open(dvb_dvrdev
[n
], O_RDONLY
| O_NONBLOCK
);
145 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR OPENING DVR DEVICE %s: %d\n", dvb_dvrdev
[n
], errno
);
153 int dvb_fix_demuxes(dvb_priv_t
*priv
, int cnt
)
157 mp_msg(MSGT_DEMUX
, MSGL_V
, "FIX %d -> %d\n", priv
->demux_fds_cnt
, cnt
);
158 if(priv
->demux_fds_cnt
>= cnt
)
160 for(i
= priv
->demux_fds_cnt
-1; i
>= cnt
; i
--)
162 mp_msg(MSGT_DEMUX
, MSGL_V
, "FIX, CLOSE fd(%d): %d\n", i
, priv
->demux_fds
[i
]);
163 close(priv
->demux_fds
[i
]);
165 priv
->demux_fds_cnt
= cnt
;
167 else if(priv
->demux_fds_cnt
< cnt
)
169 for(i
= priv
->demux_fds_cnt
; i
< cnt
; i
++)
171 priv
->demux_fds
[i
] = open(dvb_demuxdev
[priv
->card
], O_RDWR
| O_NONBLOCK
);
172 mp_msg(MSGT_DEMUX
, MSGL_V
, "FIX, OPEN fd(%d): %d\n", i
, priv
->demux_fds
[i
]);
173 if(priv
->demux_fds
[i
] < 0)
175 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR OPENING DEMUX 0: %d\n", errno
);
179 priv
->demux_fds_cnt
++;
186 int dvb_set_ts_filt(int fd
, uint16_t pid
, dmx_pes_type_t pestype
)
189 struct dmx_pes_filter_params pesFilterParams
;
191 pesFilterParams
.pid
= pid
;
192 pesFilterParams
.input
= DMX_IN_FRONTEND
;
193 pesFilterParams
.output
= DMX_OUT_TS_TAP
;
195 pesFilterParams
.pes_type
= pestype
;
197 pesFilterParams
.pesType
= pestype
;
200 pesFilterParams
.flags
= DMX_IMMEDIATE_START
;
203 if ((i
= ioctl(fd
, DMX_SET_PES_FILTER
, &pesFilterParams
)) < 0)
205 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid
, fd
, errno
);
209 mp_msg(MSGT_DEMUX
, MSGL_V
, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid
, fd
, i
, errno
);
214 int dvb_demux_stop(int fd
)
217 i
= ioctl(fd
, DMX_STOP
);
219 mp_msg(MSGT_DEMUX
, MSGL_DBG2
, "STOPPING FD: %d, RESULT: %d\n", fd
, i
);
225 int dvb_demux_start(int fd
)
228 i
= ioctl(fd
, DMX_START
);
230 mp_msg(MSGT_DEMUX
, MSGL_DBG2
, "STARTING FD: %d, RESULT: %d\n", fd
, i
);
236 static int tune_it(int fd_frontend
, int fd_sec
, unsigned int freq
, unsigned int srate
, char pol
, int tone
,
237 fe_spectral_inversion_t specInv
, unsigned int diseqc
, fe_modulation_t modulation
, fe_code_rate_t HP_CodeRate
,
238 fe_transmit_mode_t TransmissionMode
, fe_guard_interval_t guardInterval
, fe_bandwidth_t bandwidth
,
239 fe_code_rate_t LP_CodeRate
, fe_hierarchy_t hier
, int tmout
);
242 int dvb_tune(dvb_priv_t
*priv
, int freq
, char pol
, int srate
, int diseqc
, int tone
,
243 fe_spectral_inversion_t specInv
, fe_modulation_t modulation
, fe_guard_interval_t guardInterval
,
244 fe_transmit_mode_t TransmissionMode
, fe_bandwidth_t bandWidth
, fe_code_rate_t HP_CodeRate
,
245 fe_code_rate_t LP_CodeRate
, fe_hierarchy_t hier
, int timeout
)
249 mp_msg(MSGT_DEMUX
, MSGL_INFO
, "dvb_tune Freq: %lu\n", (long unsigned int) freq
);
251 ris
= tune_it(priv
->fe_fd
, priv
->sec_fd
, freq
, srate
, pol
, tone
, specInv
, diseqc
, modulation
, HP_CodeRate
, TransmissionMode
, guardInterval
, bandWidth
, LP_CodeRate
, hier
, timeout
);
254 mp_msg(MSGT_DEMUX
, MSGL_INFO
, "dvb_tune, TUNING FAILED\n");
260 #ifndef HAVE_DVB_HEAD
261 static int SecGetStatus (int fd
, struct secStatus
*state
)
263 if(ioctl(fd
, SEC_GET_STATUS
, state
) < 0)
265 mp_msg(MSGT_DEMUX
, MSGL_ERR
, ("SEC GET STATUS: "));
269 switch (state
->busMode
)
272 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC BUS MODE: IDLE (%d)\n",state
->busMode
);
275 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC BUS MODE: BUSY (%d)\n",state
->busMode
);
278 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC BUS MODE: OFF (%d)\n",state
->busMode
);
280 case SEC_BUS_OVERLOAD
:
281 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC BUS MODE: OVERLOAD (%d)\n",state
->busMode
);
284 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC BUS MODE: unknown (%d)\n",state
->busMode
);
288 switch (state
->selVolt
)
290 case SEC_VOLTAGE_OFF
:
291 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: OFF (%d)\n",state
->selVolt
);
294 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: LT (%d)\n",state
->selVolt
);
297 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: 13 (%d)\n",state
->selVolt
);
299 case SEC_VOLTAGE_13_5
:
300 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: 13.5 (%d)\n",state
->selVolt
);
303 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: 18 (%d)\n",state
->selVolt
);
305 case SEC_VOLTAGE_18_5
:
306 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: 18.5 (%d)\n",state
->selVolt
);
309 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC VOLTAGE: unknown (%d)\n",state
->selVolt
);
313 mp_msg(MSGT_DEMUX
, MSGL_V
, "SEC CONT TONE: %s\n", (state
->contTone
== SEC_TONE_ON
? "ON" : "OFF"));
319 static void print_status(fe_status_t festatus
)
321 mp_msg(MSGT_DEMUX
, MSGL_V
, "FE_STATUS:");
322 if (festatus
& FE_HAS_SIGNAL
) mp_msg(MSGT_DEMUX
, MSGL_V
," FE_HAS_SIGNAL");
324 if (festatus
& FE_TIMEDOUT
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_TIMEDOUT");
326 if (festatus
& FE_HAS_POWER
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_HAS_POWER");
327 if (festatus
& FE_SPECTRUM_INV
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_SPECTRUM_INV");
328 if (festatus
& FE_TUNER_HAS_LOCK
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_TUNER_HAS_LOCK");
330 if (festatus
& FE_HAS_LOCK
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_HAS_LOCK");
331 if (festatus
& FE_HAS_CARRIER
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_HAS_CARRIER");
332 if (festatus
& FE_HAS_VITERBI
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_HAS_VITERBI");
333 if (festatus
& FE_HAS_SYNC
) mp_msg(MSGT_DEMUX
, MSGL_V
, " FE_HAS_SYNC");
334 mp_msg(MSGT_DEMUX
, MSGL_V
, "\n");
339 static int check_status(int fd_frontend
, int tmout
)
342 fe_status_t festatus
;
343 struct pollfd pfd
[1];
347 pfd
[0].fd
= fd_frontend
;
348 pfd
[0].events
= POLLPRI
;
350 mp_msg(MSGT_DEMUX
, MSGL_V
, "Getting frontend status\n");
351 tm1
= tm2
= time((time_t*) NULL
);
355 if(poll(pfd
,1,tmout
*1000) > 0)
357 if (pfd
[0].revents
& POLLPRI
)
359 if(ioctl(fd_frontend
, FE_READ_STATUS
, &festatus
) >= 0)
360 if(festatus
& FE_HAS_LOCK
)
365 tm2
= time((time_t*) NULL
);
366 if((festatus
& FE_TIMEDOUT
) || (locks
>= 2) || (tm2
- tm1
>= tmout
))
370 if(festatus
& FE_HAS_LOCK
)
373 if(ioctl(fd_frontend
,FE_READ_BER
,&strength
) >= 0)
374 mp_msg(MSGT_DEMUX
, MSGL_V
, "Bit error rate: %d\n",strength
);
377 if(ioctl(fd_frontend
,FE_READ_SIGNAL_STRENGTH
,&strength
) >= 0)
378 mp_msg(MSGT_DEMUX
, MSGL_V
, "Signal strength: %d\n",strength
);
381 if(ioctl(fd_frontend
,FE_READ_SNR
,&strength
) >= 0)
382 mp_msg(MSGT_DEMUX
, MSGL_V
, "SNR: %d\n",strength
);
385 if(ioctl(fd_frontend
,FE_READ_UNCORRECTED_BLOCKS
,&strength
) >= 0)
386 mp_msg(MSGT_DEMUX
, MSGL_V
, "UNC: %d\n",strength
);
388 print_status(festatus
);
392 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout
);
400 static int check_status(int fd_frontend
, int tmout
)
404 fe_status_t festatus
;
407 struct pollfd pfd
[1];
410 while ((i
< 3) && (res
< 0))
412 pfd
[0].fd
= fd_frontend
;
413 pfd
[0].events
= POLLIN
| POLLPRI
;
415 if(poll(pfd
,1,tmout
*1000) > 0)
417 if (pfd
[0].revents
& POLLPRI
)
419 mp_msg(MSGT_DEMUX
, MSGL_V
, "Getting frontend event\n");
420 if ( ioctl(fd_frontend
, FE_GET_EVENT
, &event
) < 0)
422 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "FE_GET_EVENT");
425 mp_msg(MSGT_DEMUX
, MSGL_V
, "Received ");
428 case FE_UNEXPECTED_EV
:
429 mp_msg(MSGT_DEMUX
, MSGL_V
, "unexpected event\n");
434 mp_msg(MSGT_DEMUX
, MSGL_V
, "failure event\n");
438 case FE_COMPLETION_EV
:
439 mp_msg(MSGT_DEMUX
, MSGL_V
, "completion event\n");
451 case FE_UNEXPECTED_EV
: mp_msg(MSGT_DEMUX
, MSGL_V
, "FE_UNEXPECTED_EV\n");
453 case FE_COMPLETION_EV
: mp_msg(MSGT_DEMUX
, MSGL_V
, "FE_COMPLETION_EV\n");
455 case FE_FAILURE_EV
: mp_msg(MSGT_DEMUX
, MSGL_V
, "FE_FAILURE_EV\n");
459 if (event
.type
== FE_COMPLETION_EV
)
462 if(ioctl(fd_frontend
,FE_READ_BER
,&strength
) >= 0)
463 mp_msg(MSGT_DEMUX
, MSGL_V
, "Bit error rate: %d\n",strength
);
466 if(ioctl(fd_frontend
,FE_READ_SIGNAL_STRENGTH
,&strength
) >= 0)
467 mp_msg(MSGT_DEMUX
, MSGL_V
, "Signal strength: %d\n",strength
);
470 if(ioctl(fd_frontend
,FE_READ_SNR
,&strength
) >= 0)
471 mp_msg(MSGT_DEMUX
, MSGL_V
, "SNR: %d\n",strength
);
474 mp_msg(MSGT_DEMUX
, MSGL_V
, "FE_STATUS:");
476 if(ioctl(fd_frontend
,FE_READ_STATUS
,&festatus
) >= 0)
477 print_status(festatus
);
479 mp_msg(MSGT_DEMUX
, MSGL_ERR
, " ERROR, UNABLE TO READ_STATUS");
481 mp_msg(MSGT_DEMUX
, MSGL_V
, "\n");
485 mp_msg(MSGT_DEMUX
, MSGL_V
, "Not able to lock to the signal on the given frequency\n");
495 struct dvb_diseqc_master_cmd cmd
;
499 static int diseqc_send_msg(int fd
, fe_sec_voltage_t v
, struct diseqc_cmd
*cmd
,
500 fe_sec_tone_mode_t t
, fe_sec_mini_cmd_t b
)
502 if(ioctl(fd
, FE_SET_TONE
, SEC_TONE_OFF
) == -1)
504 if(ioctl(fd
, FE_SET_VOLTAGE
, v
) == -1)
507 if(ioctl(fd
, FE_DISEQC_SEND_MASTER_CMD
, &cmd
->cmd
) == -1)
509 usleep(cmd
->wait
* 1000);
511 if(ioctl(fd
, FE_DISEQC_SEND_BURST
, b
) == -1)
514 if(ioctl(fd
, FE_SET_TONE
, t
) == -1)
520 /* digital satellite equipment control,
521 * specification is available from http://www.eutelsat.com/
523 static int do_diseqc(int secfd
, int sat_no
, int polv
, int hi_lo
)
525 struct diseqc_cmd cmd
= { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
527 /* param: high nibble: reset bits, low nibble set bits,
528 * bits are: option, position, polarizaion, band
531 0xf0 | (((sat_no
* 4) & 0x0f) | (hi_lo
? 1 : 0) | (polv
? 0 : 2));
533 return diseqc_send_msg(secfd
, polv
? SEC_VOLTAGE_13
: SEC_VOLTAGE_18
,
534 &cmd
, hi_lo
? SEC_TONE_ON
: SEC_TONE_OFF
,
535 (sat_no
/ 4) % 2 ? SEC_MINI_B
: SEC_MINI_A
);
540 static int do_diseqc(int secfd
, int sat_no
, int polv
, int hi_lo
)
542 struct secCommand scmd
;
543 struct secCmdSequence scmds
;
545 scmds
.continuousTone
= (hi_lo
? SEC_TONE_ON
: SEC_TONE_OFF
);
546 scmds
.voltage
= (polv
? SEC_VOLTAGE_13
: SEC_VOLTAGE_18
);
547 scmds
.miniCommand
= SEC_MINI_NONE
;
549 scmd
.type
= SEC_CMDTYPE_DISEQC
;
550 scmds
.numCommands
= 1;
551 scmds
.commands
= &scmd
;
553 scmd
.u
.diseqc
.addr
= 0x10;
554 scmd
.u
.diseqc
.cmd
= 0x38;
555 scmd
.u
.diseqc
.numParams
= 1;
556 scmd
.u
.diseqc
.params
[0] = 0xf0 |
557 (((sat_no
) << 2) & 0x0F) |
561 if (ioctl(secfd
,SEC_SEND_SEQUENCE
,&scmds
) < 0)
563 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "Error sending DisEqC");
571 static int tune_it(int fd_frontend
, int fd_sec
, unsigned int freq
, unsigned int srate
, char pol
, int tone
,
572 fe_spectral_inversion_t specInv
, unsigned int diseqc
, fe_modulation_t modulation
, fe_code_rate_t HP_CodeRate
,
573 fe_transmit_mode_t TransmissionMode
, fe_guard_interval_t guardInterval
, fe_bandwidth_t bandwidth
,
574 fe_code_rate_t LP_CodeRate
, fe_hierarchy_t hier
, int timeout
)
578 struct dvb_frontend_parameters feparams
;
579 struct dvb_frontend_info fe_info
;
581 FrontendParameters feparams
;
582 FrontendInfo fe_info
;
584 struct secStatus sec_state
;
588 mp_msg(MSGT_DEMUX
, MSGL_V
, "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
589 fd_frontend
, fd_sec
, (long unsigned int)freq
, (long unsigned int)srate
, pol
, tone
, diseqc
);
592 memset(&feparams
, 0, sizeof(feparams
));
593 if ( (res
= ioctl(fd_frontend
,FE_GET_INFO
, &fe_info
) < 0))
595 mp_msg(MSGT_DEMUX
, MSGL_FATAL
, "FE_GET_INFO FAILED\n");
601 mp_msg(MSGT_DEMUX
, MSGL_V
, "Using DVB card \"%s\"\n", fe_info
.name
);
608 if (freq
< 1000000) freq
*=1000UL;
609 feparams
.frequency
=freq
;
610 feparams
.inversion
=specInv
;
611 feparams
.u
.ofdm
.bandwidth
=bandwidth
;
612 feparams
.u
.ofdm
.code_rate_HP
=HP_CodeRate
;
613 feparams
.u
.ofdm
.code_rate_LP
=LP_CodeRate
;
614 feparams
.u
.ofdm
.constellation
=modulation
;
615 feparams
.u
.ofdm
.transmission_mode
=TransmissionMode
;
616 feparams
.u
.ofdm
.guard_interval
=guardInterval
;
617 feparams
.u
.ofdm
.hierarchy_information
=hier
;
619 if (freq
< 1000000) freq
*=1000UL;
620 feparams
.Frequency
=freq
;
621 feparams
.Inversion
=specInv
;
622 feparams
.u
.ofdm
.bandWidth
=bandwidth
;
623 feparams
.u
.ofdm
.HP_CodeRate
=HP_CodeRate
;
624 feparams
.u
.ofdm
.LP_CodeRate
=LP_CodeRate
;
625 feparams
.u
.ofdm
.Constellation
=modulation
;
626 feparams
.u
.ofdm
.TransmissionMode
=TransmissionMode
;
627 feparams
.u
.ofdm
.guardInterval
=guardInterval
;
628 feparams
.u
.ofdm
.HierarchyInformation
=hier
;
630 mp_msg(MSGT_DEMUX
, MSGL_V
, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq
, bandwidth
);
635 // this must be an absolute frequency
639 freq
= feparams
.frequency
=(freq
-LOF1
);
641 freq
= feparams
.Frequency
=(freq
-LOF1
);
648 freq
= feparams
.frequency
=(freq
-LOF2
);
650 freq
= feparams
.Frequency
=(freq
-LOF2
);
657 // this is an L-Band frequency
659 feparams
.frequency
=freq
;
661 feparams
.Frequency
=freq
;
666 feparams
.inversion
=specInv
;
667 feparams
.u
.qpsk
.symbol_rate
=srate
;
668 feparams
.u
.qpsk
.fec_inner
=HP_CodeRate
;
671 feparams
.Inversion
=specInv
;
672 feparams
.u
.qpsk
.SymbolRate
=srate
;
673 feparams
.u
.qpsk
.FEC_inner
=HP_CodeRate
;
677 mp_msg(MSGT_DEMUX
, MSGL_V
, "tuning DVB-S to Freq: %u, Pol: %c Srate: %d, 22kHz: %s, LNB: %d\n",freq
,pol
,srate
,hi_lo
? "on" : "off", diseqc
);
679 if(do_diseqc(dfd
, diseqc
, (pol
== 'V' ? 1 : 0), hi_lo
) == 0)
680 mp_msg(MSGT_DEMUX
, MSGL_V
, "DISEQC SETTING SUCCEDED\n");
683 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "DISEQC SETTING FAILED\n");
688 mp_msg(MSGT_DEMUX
, MSGL_V
, "tuning DVB-C to %d, srate=%d\n",freq
,srate
);
690 feparams
.frequency
=freq
;
691 feparams
.inversion
=specInv
;
692 feparams
.u
.qam
.symbol_rate
= srate
;
693 feparams
.u
.qam
.fec_inner
= HP_CodeRate
;
694 feparams
.u
.qam
.modulation
= modulation
;
696 feparams
.Frequency
=freq
;
697 feparams
.Inversion
=specInv
;
698 feparams
.u
.qam
.SymbolRate
= srate
;
699 feparams
.u
.qam
.FEC_inner
= HP_CodeRate
;
700 feparams
.u
.qam
.QAM
= modulation
;
705 mp_msg(MSGT_DEMUX
, MSGL_V
, "tuning ATSC to %d, modulation=%d\n",freq
,modulation
);
706 feparams
.frequency
=freq
;
707 feparams
.u
.vsb
.modulation
= modulation
;
711 mp_msg(MSGT_DEMUX
, MSGL_V
, "Unknown FE type. Aborting\n");
716 #ifndef HAVE_DVB_HEAD
717 if (fd_sec
) SecGetStatus(fd_sec
, &sec_state
);
720 if(ioctl(fd_frontend
, FE_GET_EVENT
, &event
) == -1)
725 if(ioctl(fd_frontend
,FE_SET_FRONTEND
,&feparams
) < 0)
727 mp_msg(MSGT_DEMUX
, MSGL_ERR
, "ERROR tuning channel\n");
731 return(check_status(fd_frontend
, timeout
));