1 /*****************************************************************************
2 * dvb.c : functions to control a DVB card under Linux with v4l2
3 *****************************************************************************
4 * Copyright (C) 1998-2003 VideoLAN
6 * Authors: Damien Lucas <nitrox@via.ecp.fr>
7 * Johan Bilien <jobi@via.ecp.fr>
8 * Jean-Paul Saman <saman@natlab.research.philips.com>
9 * Christopher Ross <ross@natlab.research.philips.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
27 #include <vlc/input.h>
29 #include <sys/ioctl.h>
36 #ifdef HAVE_INTTYPES_H
37 # include <inttypes.h> /* int16_t .. */
39 #include <sys/types.h>
44 #include <sys/types.h>
48 /* DVB Card Drivers */
49 #include <linux/dvb/dmx.h>
50 #include <linux/dvb/frontend.h>
52 #include <linux/errno.h>
58 struct dvb_diseqc_master_cmd cmd;
62 struct diseqc_cmd_t switch_cmds[] =
64 { { { 0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00 }, 4 }, 0 },
65 { { { 0xe0, 0x10, 0x38, 0xf2, 0x00, 0x00 }, 4 }, 0 },
66 { { { 0xe0, 0x10, 0x38, 0xf1, 0x00, 0x00 }, 4 }, 0 },
67 { { { 0xe0, 0x10, 0x38, 0xf3, 0x00, 0x00 }, 4 }, 0 },
68 { { { 0xe0, 0x10, 0x38, 0xf4, 0x00, 0x00 }, 4 }, 0 },
69 { { { 0xe0, 0x10, 0x38, 0xf6, 0x00, 0x00 }, 4 }, 0 },
70 { { { 0xe0, 0x10, 0x38, 0xf5, 0x00, 0x00 }, 4 }, 0 },
71 { { { 0xe0, 0x10, 0x38, 0xf7, 0x00, 0x00 }, 4 }, 0 },
72 { { { 0xe0, 0x10, 0x38, 0xf8, 0x00, 0x00 }, 4 }, 0 },
73 { { { 0xe0, 0x10, 0x38, 0xfa, 0x00, 0x00 }, 4 }, 0 },
74 { { { 0xe0, 0x10, 0x38, 0xf9, 0x00, 0x00 }, 4 }, 0 },
75 { { { 0xe0, 0x10, 0x38, 0xfb, 0x00, 0x00 }, 4 }, 0 },
76 { { { 0xe0, 0x10, 0x38, 0xfc, 0x00, 0x00 }, 4 }, 0 },
77 { { { 0xe0, 0x10, 0x38, 0xfe, 0x00, 0x00 }, 4 }, 0 },
78 { { { 0xe0, 0x10, 0x38, 0xfd, 0x00, 0x00 }, 4 }, 0 },
79 { { { 0xe0, 0x10, 0x38, 0xff, 0x00, 0x00 }, 4 }, 0 }
82 static int ioctl_CheckFrontend(input_thread_t * p_input, int front);
84 /*****************************************************************************
85 * ioctl_FrontendControl : commands the SEC device
86 *****************************************************************************/
87 int ioctl_FrontendControl(input_thread_t * p_input, int freq, int pol, int lnb_slof,
88 int diseqc, unsigned int u_adapter, unsigned int u_device)
90 struct dvb_diseqc_master_cmd cmd;
91 fe_sec_tone_mode_t tone;
92 fe_sec_voltage_t voltage;
94 char front[] = FRONTEND;
97 i_len = sizeof(FRONTEND);
98 if (snprintf(front, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
100 msg_Err(p_input, "snprintf() truncated string for FRONTEND" );
101 front[sizeof(FRONTEND)] = '\0';
104 msg_Dbg(p_input, "Opening frontend %s",front);
105 if((frontend = open(front,O_RDWR)) < 0)
108 msg_Err(p_input, "ioctl_FrontEndControl: Opening frontend failed (%s)",strerror(errno));
110 msg_Err(p_input, "ioctl_FrontEndControl: Opening frontend failed");
115 /* Set the frequency of the transponder, taking into account the
116 local frequencies of the LNB */
117 tone = (freq<lnb_slof) ? SEC_TONE_OFF : SEC_TONE_ON;
119 /* Set the polarisation of the transponder by setting the correct
120 voltage on the universal LNB */
121 voltage = (pol) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13;
123 /* In case we have a DiSEqC, set it to the correct address */
124 cmd.msg[0] = 0x0; /* framing */
125 cmd.msg[1] = 0x10; /* address */
126 cmd.msg[2] = 0x38; /* command */
127 /* command parameters start at index 3 */
128 cmd.msg[3] = 0xF0 | ((diseqc * 4) & 0x0F);
131 /* Reset everything before sending. */
133 # define CHECK_IOCTL(X) if(X<0) \
135 msg_Err( p_input, "InfoFrontend: ioctl failed (%s)", strerror(errno)); \
140 # define CHECK_IOCTL(X) if(X<0) \
142 msg_Err( p_input, "InfoFrontend: ioctl failed"); \
148 CHECK_IOCTL(ioctl(frontend, FE_SET_TONE, SEC_TONE_OFF));
149 CHECK_IOCTL(ioctl(frontend, FE_SET_VOLTAGE, voltage));
152 /* Send the data to the SEC device to prepare the LNB for tuning */
153 CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd));
155 CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_BURST, &cmd));
157 CHECK_IOCTL(ioctl(frontend, FE_SET_TONE, tone));
164 /*****************************************************************************
165 * ioctl_InfoFrontend : return information about given frontend
166 *****************************************************************************/
167 int ioctl_InfoFrontend(input_thread_t * p_input, struct dvb_frontend_info *info,
168 unsigned int u_adapter, unsigned int u_device)
172 char frontend[] = FRONTEND;
175 i_len = sizeof(FRONTEND);
176 if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
178 msg_Err(p_input, "snprintf() truncated string for FRONTEND" );
179 frontend[sizeof(FRONTEND)] = '\0';
182 msg_Dbg(p_input, "Opening device %s", frontend);
183 if((front = open(frontend,O_RDWR)) < 0)
186 msg_Err(p_input, "ioctl_InfoFrontEnd: opening device failed (%s)", strerror(errno));
188 msg_Err(p_input, "ioctl_InfoFrontEnd: opening device failed");
193 /* Determine type of frontend */
194 if ((ret=ioctl(front, FE_GET_INFO, info)) < 0)
198 msg_Err(p_input, "ioctl FE_GET_INFO failed (%d) %s", ret, strerror(errno));
200 msg_Err(p_input, "ioctl FE_GET_INFO failed (%d)", ret);
204 /* Print out frontend capabilities. */
205 msg_Dbg(p_input, "Frontend Info:\tname = %s\n\t\tfrequency_min = %d\n\t\tfrequency_max = %d\n\t\tfrequency_stepsize = %d\n\t\tfrequency_tolerance = %d\n\t\tsymbol_rate_min = %d\n\t\tsymbol_rate_max = %d\n\t\tsymbol_rate_tolerance (ppm) = %d\n\t\tnotifier_delay (ms)= %d\n",
209 info->frequency_stepsize,
210 info->frequency_tolerance,
211 info->symbol_rate_min,
212 info->symbol_rate_max,
213 info->symbol_rate_tolerance,
214 info->notifier_delay );
215 msg_Dbg(p_input, "Frontend Info capability list:");
216 if (info->caps&FE_IS_STUPID)
217 msg_Dbg(p_input, "no capabilities - frontend is stupid!");
218 if (info->caps&FE_CAN_INVERSION_AUTO)
219 msg_Dbg(p_input, "inversion auto");
220 if (info->caps&FE_CAN_FEC_1_2)
221 msg_Dbg(p_input, "forward error correction 1/2");
222 if (info->caps&FE_CAN_FEC_2_3)
223 msg_Dbg(p_input, "forward error correction 2/3");
224 if (info->caps&FE_CAN_FEC_3_4)
225 msg_Dbg(p_input, "forward error correction 3/4");
226 if (info->caps&FE_CAN_FEC_4_5)
227 msg_Dbg(p_input, "forward error correction 4/5");
228 if (info->caps&FE_CAN_FEC_5_6)
229 msg_Dbg(p_input, "forward error correction 5/6");
230 if (info->caps&FE_CAN_FEC_6_7)
231 msg_Dbg(p_input, "forward error correction 6/7");
232 if (info->caps&FE_CAN_FEC_7_8)
233 msg_Dbg(p_input, "forward error correction 7/8");
234 if (info->caps&FE_CAN_FEC_8_9)
235 msg_Dbg(p_input, "forward error correction 8/9");
236 if (info->caps&FE_CAN_FEC_AUTO)
237 msg_Dbg(p_input, "forward error correction auto");
238 if (info->caps&FE_CAN_QPSK)
239 msg_Dbg(p_input, "card can do QPSK");
240 if (info->caps&FE_CAN_QAM_16)
241 msg_Dbg(p_input, "card can do QAM 16");
242 if (info->caps&FE_CAN_QAM_32)
243 msg_Dbg(p_input, "card can do QAM 32");
244 if (info->caps&FE_CAN_QAM_64)
245 msg_Dbg(p_input, "card can do QAM 64");
246 if (info->caps&FE_CAN_QAM_128)
247 msg_Dbg(p_input, "card can do QAM 128");
248 if (info->caps&FE_CAN_QAM_256)
249 msg_Dbg(p_input, "card can do QAM 256");
250 if (info->caps&FE_CAN_QAM_AUTO)
251 msg_Dbg(p_input, "card can do QAM auto");
252 if (info->caps&FE_CAN_TRANSMISSION_MODE_AUTO)
253 msg_Dbg(p_input, "transmission mode auto");
254 if (info->caps&FE_CAN_BANDWIDTH_AUTO)
255 msg_Dbg(p_input, "bandwidth mode auto");
256 if (info->caps&FE_CAN_GUARD_INTERVAL_AUTO)
257 msg_Dbg(p_input, "guard interval mode auto");
258 if (info->caps&FE_CAN_HIERARCHY_AUTO)
259 msg_Dbg(p_input, "hierarchy mode auto");
260 if (info->caps&FE_CAN_MUTE_TS)
261 msg_Dbg(p_input, "card can mute TS");
262 if (info->caps&FE_CAN_CLEAN_SETUP)
263 msg_Dbg(p_input, "clean setup");
264 msg_Dbg(p_input,"End of capability list");
270 int ioctl_DiseqcSendMsg (input_thread_t *p_input, int fd, fe_sec_voltage_t v, struct diseqc_cmd_t **cmd,
271 fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
275 if ((err = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF))<0)
278 msg_Err(p_input, "ioclt FE_SET_TONE failed, tone=%s (%d) %s", SEC_TONE_ON ? "on" : "off", err, strerror(errno));
280 msg_Err(p_input, "ioclt FE_SET_TONE failed, tone=%s (%d)", SEC_TONE_ON ? "on" : "off", err);
284 if ((err = ioctl(fd, FE_SET_VOLTAGE, v))<0)
287 msg_Err(p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d) %s", v, err, strerror(errno));
289 msg_Err(p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d)", v, err);
297 msg_Dbg(p_input, "DiseqcSendMsg(): %02x %02x %02x %02x %02x %02x",
298 (*cmd)->cmd.msg[0], (*cmd)->cmd.msg[1],
299 (*cmd)->cmd.msg[2], (*cmd)->cmd.msg[3],
300 (*cmd)->cmd.msg[4], (*cmd)->cmd.msg[5]);
302 if ((err = ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &(*cmd)->cmd))<0)
305 msg_Err(p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d) %s", err, strerror(errno));
307 msg_Err(p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d)", err);
312 msleep((*cmd)->wait);
318 if ((err = ioctl(fd, FE_DISEQC_SEND_BURST, b))<0)
321 msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d) %s",b, err, strerror(errno));
323 msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d)",b, err);
329 if ((err = ioctl(fd, FE_SET_TONE, t))<0)
332 msg_Err(p_input, "ioctl FE_SET_TONE failed, tone=%d (%d) %s", t, err, strerror(errno));
334 msg_Err(p_input, "ioctl FE_SET_TONE failed, tone=%d (%d)", t, err);
341 int ioctl_SetupSwitch (input_thread_t *p_input, int frontend_fd, int switch_pos,
342 int voltage_18, int hiband)
345 struct diseqc_cmd_t *cmd[2] = { NULL, NULL };
346 int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
348 msg_Dbg(p_input, "ioctl_SetupSwitch: switch pos %i, %sV, %sband",
349 switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo");
350 msg_Dbg(p_input, "ioctl_SetupSwitch: index %i", i);
352 if ((i < 0) || (i >= (int)(sizeof(switch_cmds)/sizeof(struct diseqc_cmd_t))))
355 cmd[0] = &switch_cmds[i];
357 if ((ret = ioctl_DiseqcSendMsg (p_input, frontend_fd,
358 (i % 2) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13,
360 (i/2) % 2 ? SEC_TONE_ON : SEC_TONE_OFF,
361 (i/4) % 2 ? SEC_MINI_B : SEC_MINI_A))<0)
363 msg_Err(p_input, "ioctl_DiseqcSendMsg() failed (%d)", ret);
370 #define SWITCHFREQ 11700000
371 #define LOF_HI 10600000
372 #define LOF_LO 9750000
374 /*****************************************************************************
375 * ioctl_SetFrontend : controls the FE device
376 *****************************************************************************/
377 int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
378 int b_polarisation, unsigned int u_adapter, unsigned int u_device )
384 char frontend[] = FRONTEND;
387 i_len = sizeof(FRONTEND);
388 if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
390 msg_Err(p_input, "ioctl_SetFrontEnd snprintf() truncated string for FRONTEND" );
391 frontend[sizeof(FRONTEND)] = '\0';
394 /* Open the frontend device */
395 msg_Dbg(p_input, "Opening frontend %s", frontend);
396 if((front = open(frontend,O_RDWR)) < 0)
399 msg_Err(p_input, "failed to open frontend (%s)", strerror(errno));
401 msg_Err(p_input, "failed to open frontend");
406 /* Set the frequency of the transponder, taking into account the
407 local frequencies of the LNB */
408 hiband = (fep.frequency >= SWITCHFREQ);
409 if ((ret=ioctl_SetupSwitch (p_input, front, 0, b_polarisation, hiband))<0)
411 msg_Err(p_input, "ioctl_SetupSwitch failed (%d)", ret);
416 fep.frequency -= LOF_HI;
418 fep.frequency -= LOF_LO;
420 /* Now send it all to the frontend device */
421 if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
425 msg_Err(p_input, "ioctl_SetFrontend: ioctl FE_SET_FRONTEND failed (%d) %s", ret, strerror(errno));
427 msg_Err(p_input, "ioctl_SetFrontend: ioctl FE_SET_FRONTEND failed (%d)", ret);
435 if ((ret=ioctl(front, FE_READ_STATUS, &s))<0)
438 msg_Err(p_input, "ioctl FE_READ_STATUS failed (%d) %s", ret, strerror(errno));
440 msg_Err(p_input, "ioctl FE_READ_STATUS failed (%d)", ret);
446 msg_Dbg(p_input, "ioctl_SetFrontend: tuning status == 0x%02x!!! ..."
447 "tuning succeeded", s);
452 msg_Dbg(p_input, "ioctl_SetFrontend: tuning status == 0x%02x!!! ..."
459 /* Close front end device */
464 /******************************************************************
465 * Check completion of the frontend control sequence
466 ******************************************************************/
467 static int ioctl_CheckFrontend(input_thread_t * p_input, int front)
470 struct pollfd pfd[1];
471 struct dvb_frontend_event event;
472 /* poll for frontend event to check if tuning worked */
474 pfd[0].events = POLLIN;
476 if (poll(pfd,1,3000))
478 if (pfd[0].revents & POLLIN)
480 if ( (ret=ioctl(front, FE_GET_EVENT, &event)) < 0)
483 msg_Err(p_input, "ioctl_CheckFrontend: ioctl FE_GET_EVENT failed (%d) %s", ret, strerror(errno));
485 msg_Err(p_input, "ioctl_CheckFrontend: ioctl FE_GET_EVENT failed (%d)", ret);
492 case FE_HAS_SIGNAL: /* found something above the noise level */
493 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_HAS_SIGNAL");
495 case FE_HAS_CARRIER: /* found a DVB signal */
496 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_HAS_CARRIER");
498 case FE_HAS_VITERBI: /* FEC is stable */
499 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_HAS_VITERBI");
501 case FE_HAS_SYNC: /* found sync bytes */
502 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_HAS_SYNC");
504 case FE_HAS_LOCK: /* everything's working... */
505 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_HAS_LOCK");
507 case FE_TIMEDOUT: /* no lock within the last ~2 seconds */
508 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_TIMEDOUT");
510 case FE_REINIT: /* frontend was reinitialized, */
511 /* application is recommned to reset */
512 /* DiSEqC, tone and parameters */
513 msg_Dbg(p_input, "ioctl_CheckFrontend: FE_REINIT");
519 /* should come here */
520 msg_Err(p_input, "ioctl_CheckFrontend: event() failed");
527 msg_Err(p_input, "ioctl_CheckFrontend: poll() failed (%s)", strerror(errno));
529 msg_Err(p_input, "ioctl_CheckFrontend: poll() failed");
537 /*****************************************************************************
538 * ioctl_SetDMXFilter : controls the demux to add a filter
539 *****************************************************************************/
540 int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_type,
541 unsigned int u_adapter, unsigned int u_device )
543 struct dmx_pes_filter_params s_filter_params;
548 /* We first open the device */
550 if (snprintf( dmx, sizeof(DMX), DMX, u_adapter, u_device) >= i_len)
552 msg_Err(p_input, "snprintf() truncated string for DMX" );
553 dmx[sizeof(DMX)] = '\0';
556 msg_Dbg(p_input, "Opening demux device %s", dmx);
557 if ((*pi_fd = open(dmx, O_RDWR|O_NONBLOCK)) < 0)
560 msg_Err(p_input, "ioctl_SetDMXFilter: opening device failed (%s)", strerror(errno));
562 msg_Err(p_input, "ioctl_SetDMXFilter: opening device failed");
567 /* We fill the DEMUX structure : */
568 s_filter_params.pid = i_pid;
569 s_filter_params.input = DMX_IN_FRONTEND;
570 s_filter_params.output = DMX_OUT_TS_TAP;
574 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO for PMT %d", i_pid);
575 s_filter_params.pes_type = DMX_PES_VIDEO;
578 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO for PMT %d", i_pid);
579 s_filter_params.pes_type = DMX_PES_AUDIO;
582 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_OTHER for PMT %d", i_pid);
583 s_filter_params.pes_type = DMX_PES_OTHER;
586 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO1 for PMT %d", i_pid);
587 s_filter_params.pes_type = DMX_PES_VIDEO1;
590 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO1 for PMT %d", i_pid);
591 s_filter_params.pes_type = DMX_PES_AUDIO1;
595 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO2 for PMT %d", i_pid);
596 s_filter_params.pes_type = DMX_PES_VIDEO2;
599 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO2 for PMT %d", i_pid);
600 s_filter_params.pes_type = DMX_PES_AUDIO2;
604 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO3 for PMT %d", i_pid);
605 s_filter_params.pes_type = DMX_PES_VIDEO3;
608 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO3 for PMT %d", i_pid);
609 s_filter_params.pes_type = DMX_PES_AUDIO3;
612 msg_Err(p_input, "trying to set PMT id to=%d for unknown type %d", i_pid, i_type );
615 s_filter_params.flags = DMX_IMMEDIATE_START;
617 /* We then give the order to the device : */
618 if ((result = ioctl(*pi_fd, DMX_SET_PES_FILTER, &s_filter_params)) < 0)
621 msg_Err(p_input, "ioctl_SetDMXFilter: ioctl failed with %d (%s)",result, strerror(errno));
623 msg_Err(p_input, "ioctl_SetDMXFilter: ioctl failed with %d",result);
630 /*****************************************************************************
631 * ioctl_UnsetDMXFilter : removes a filter
632 *****************************************************************************/
633 int ioctl_UnsetDMXFilter(input_thread_t * p_input, int demux)
637 if ((ret=ioctl(demux, DMX_STOP))<0)
640 msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d) %s", demux, ret, strerror(errno));
642 msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d)", demux, ret);
650 /*****************************************************************************
651 * dvb_DecodeBandwidth : decodes arguments for DVB S/C/T card
652 *****************************************************************************/
653 fe_bandwidth_t dvb_DecodeBandwidth(input_thread_t * p_input, int bandwidth)
655 fe_bandwidth_t fe_bandwidth = 0;
660 fe_bandwidth = BANDWIDTH_AUTO;
663 fe_bandwidth = BANDWIDTH_6_MHZ;
666 fe_bandwidth = BANDWIDTH_7_MHZ;
669 fe_bandwidth = BANDWIDTH_8_MHZ;
672 msg_Dbg( p_input, "terrestrial dvb has bandwidth not set, using auto");
673 fe_bandwidth = BANDWIDTH_AUTO;
680 fe_code_rate_t dvb_DecodeFEC(input_thread_t * p_input, int fec)
682 fe_code_rate_t fe_fec = FEC_NONE;
716 msg_Err( p_input, "argument has invalid FEC (%d)", fec);
722 fe_modulation_t dvb_DecodeModulation(input_thread_t * p_input, int modulation)
724 fe_modulation_t fe_modulation = 0;
729 fe_modulation = QPSK;
732 fe_modulation = QAM_AUTO;
735 fe_modulation = QAM_16;
738 fe_modulation = QAM_32;
741 fe_modulation = QAM_64;
744 fe_modulation = QAM_128;
747 fe_modulation = QAM_256;
750 msg_Dbg( p_input, "terrestrial/cable dvb has constellation/modulation not set, using auto");
751 fe_modulation = QAM_AUTO;
754 return fe_modulation;
757 fe_transmit_mode_t dvb_DecodeTransmission(input_thread_t * p_input, int transmission)
759 fe_transmit_mode_t fe_transmission = 0;
761 switch( transmission )
764 fe_transmission = TRANSMISSION_MODE_AUTO;
767 fe_transmission = TRANSMISSION_MODE_2K;
770 fe_transmission = TRANSMISSION_MODE_8K;
773 msg_Dbg( p_input, "terrestrial dvb has transmission mode not set, using auto");
774 fe_transmission = TRANSMISSION_MODE_AUTO;
777 return fe_transmission;
780 fe_guard_interval_t dvb_DecodeGuardInterval(input_thread_t * p_input, int guard)
782 fe_guard_interval_t fe_guard = 0;
787 fe_guard = GUARD_INTERVAL_AUTO;
790 fe_guard = GUARD_INTERVAL_1_4;
793 fe_guard = GUARD_INTERVAL_1_8;
796 fe_guard = GUARD_INTERVAL_1_16;
799 fe_guard = GUARD_INTERVAL_1_32;
802 msg_Dbg( p_input, "terrestrial dvb has guard interval not set, using auto");
803 fe_guard = GUARD_INTERVAL_AUTO;
809 fe_hierarchy_t dvb_DecodeHierarchy(input_thread_t * p_input, int hierarchy)
811 fe_hierarchy_t fe_hierarchy = 0;
816 fe_hierarchy = HIERARCHY_NONE;
819 fe_hierarchy = HIERARCHY_AUTO;
822 fe_hierarchy = HIERARCHY_1;
825 fe_hierarchy = HIERARCHY_2;
828 fe_hierarchy = HIERARCHY_4;
831 msg_Dbg( p_input, "terrestrial dvb has hierarchy not set, using auto");
832 fe_hierarchy = HIERARCHY_AUTO;
838 fe_spectral_inversion_t dvb_DecodeInversion(input_thread_t * p_input, int inversion)
840 fe_spectral_inversion_t fe_inversion=0;
845 fe_inversion = INVERSION_OFF;
848 fe_inversion = INVERSION_ON;
851 fe_inversion = INVERSION_AUTO;
854 msg_Dbg( p_input, "dvb has inversion/polarisation not set, using auto");
855 fe_inversion = INVERSION_AUTO;