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 <jpsaman@wxs.nl>
9 * Christopher Ross <chris@tebibyte.org>
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_InfoFrontend : return information about given frontend
86 *****************************************************************************/
87 int ioctl_InfoFrontend(input_thread_t * p_input, struct dvb_frontend_info *info,
88 unsigned int u_adapter, unsigned int u_device)
92 char frontend[] = FRONTEND;
95 i_len = sizeof(FRONTEND);
96 if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
98 msg_Err(p_input, "snprintf() truncated string for FRONTEND" );
99 frontend[sizeof(FRONTEND)] = '\0';
102 msg_Dbg(p_input, "Opening device %s", frontend);
103 if((front = open(frontend,O_RDWR)) < 0)
106 msg_Err(p_input, "ioctl_InfoFrontEnd: opening device failed (%s)", strerror(errno));
108 msg_Err(p_input, "ioctl_InfoFrontEnd: opening device failed");
113 /* Determine type of frontend */
114 if ((ret=ioctl(front, FE_GET_INFO, info)) < 0)
118 msg_Err(p_input, "ioctl FE_GET_INFO failed (%d) %s", ret, strerror(errno));
120 msg_Err(p_input, "ioctl FE_GET_INFO failed (%d)", ret);
124 /* Print out frontend capabilities. */
125 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",
129 info->frequency_stepsize,
130 info->frequency_tolerance,
131 info->symbol_rate_min,
132 info->symbol_rate_max,
133 info->symbol_rate_tolerance,
134 info->notifier_delay );
135 msg_Dbg(p_input, "Frontend Info capability list:");
136 if (info->caps&FE_IS_STUPID)
137 msg_Dbg(p_input, "no capabilities - frontend is stupid!");
138 if (info->caps&FE_CAN_INVERSION_AUTO)
139 msg_Dbg(p_input, "inversion auto");
140 if (info->caps&FE_CAN_FEC_1_2)
141 msg_Dbg(p_input, "forward error correction 1/2");
142 if (info->caps&FE_CAN_FEC_2_3)
143 msg_Dbg(p_input, "forward error correction 2/3");
144 if (info->caps&FE_CAN_FEC_3_4)
145 msg_Dbg(p_input, "forward error correction 3/4");
146 if (info->caps&FE_CAN_FEC_4_5)
147 msg_Dbg(p_input, "forward error correction 4/5");
148 if (info->caps&FE_CAN_FEC_5_6)
149 msg_Dbg(p_input, "forward error correction 5/6");
150 if (info->caps&FE_CAN_FEC_6_7)
151 msg_Dbg(p_input, "forward error correction 6/7");
152 if (info->caps&FE_CAN_FEC_7_8)
153 msg_Dbg(p_input, "forward error correction 7/8");
154 if (info->caps&FE_CAN_FEC_8_9)
155 msg_Dbg(p_input, "forward error correction 8/9");
156 if (info->caps&FE_CAN_FEC_AUTO)
157 msg_Dbg(p_input, "forward error correction auto");
158 if (info->caps&FE_CAN_QPSK)
159 msg_Dbg(p_input, "card can do QPSK");
160 if (info->caps&FE_CAN_QAM_16)
161 msg_Dbg(p_input, "card can do QAM 16");
162 if (info->caps&FE_CAN_QAM_32)
163 msg_Dbg(p_input, "card can do QAM 32");
164 if (info->caps&FE_CAN_QAM_64)
165 msg_Dbg(p_input, "card can do QAM 64");
166 if (info->caps&FE_CAN_QAM_128)
167 msg_Dbg(p_input, "card can do QAM 128");
168 if (info->caps&FE_CAN_QAM_256)
169 msg_Dbg(p_input, "card can do QAM 256");
170 if (info->caps&FE_CAN_QAM_AUTO)
171 msg_Dbg(p_input, "card can do QAM auto");
172 if (info->caps&FE_CAN_TRANSMISSION_MODE_AUTO)
173 msg_Dbg(p_input, "transmission mode auto");
174 if (info->caps&FE_CAN_BANDWIDTH_AUTO)
175 msg_Dbg(p_input, "bandwidth mode auto");
176 if (info->caps&FE_CAN_GUARD_INTERVAL_AUTO)
177 msg_Dbg(p_input, "guard interval mode auto");
178 if (info->caps&FE_CAN_HIERARCHY_AUTO)
179 msg_Dbg(p_input, "hierarchy mode auto");
180 if (info->caps&FE_CAN_MUTE_TS)
181 msg_Dbg(p_input, "card can mute TS");
182 if (info->caps&FE_CAN_CLEAN_SETUP)
183 msg_Dbg(p_input, "clean setup");
184 msg_Dbg(p_input,"End of capability list");
191 int ioctl_DiseqcSendMsg (input_thread_t *p_input, int fd, fe_sec_voltage_t v, struct diseqc_cmd_t **cmd,
192 fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
196 if ((err = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF))<0)
199 msg_Err(p_input, "ioclt FE_SET_TONE failed, tone=%s (%d) %s", SEC_TONE_ON ? "on" : "off", err, strerror(errno));
201 msg_Err(p_input, "ioclt FE_SET_TONE failed, tone=%s (%d)", SEC_TONE_ON ? "on" : "off", err);
205 if ((err = ioctl(fd, FE_SET_VOLTAGE, v))<0)
208 msg_Err(p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d) %s", v, err, strerror(errno));
210 msg_Err(p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d)", v, err);
218 msg_Dbg(p_input, "DiseqcSendMsg(): %02x %02x %02x %02x %02x %02x",
219 (*cmd)->cmd.msg[0], (*cmd)->cmd.msg[1],
220 (*cmd)->cmd.msg[2], (*cmd)->cmd.msg[3],
221 (*cmd)->cmd.msg[4], (*cmd)->cmd.msg[5]);
223 if ((err = ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &(*cmd)->cmd))<0)
226 msg_Err(p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d) %s", err, strerror(errno));
228 msg_Err(p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d)", err);
233 msleep((*cmd)->wait);
239 if ((err = ioctl(fd, FE_DISEQC_SEND_BURST, b))<0)
242 msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d) %s",b, err, strerror(errno));
244 msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d)",b, err);
250 if ((err = ioctl(fd, FE_SET_TONE, t))<0)
253 msg_Err(p_input, "ioctl FE_SET_TONE failed, tone=%d (%d) %s", t, err, strerror(errno));
255 msg_Err(p_input, "ioctl FE_SET_TONE failed, tone=%d (%d)", t, err);
263 int ioctl_SetupSwitch (input_thread_t *p_input, int frontend_fd, int switch_pos,
264 int voltage_18, int hiband)
267 struct diseqc_cmd_t *cmd[2] = { NULL, NULL };
268 int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
270 msg_Dbg(p_input, "ioctl_SetupSwitch: switch pos %i, %sV, %sband",
271 switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo");
272 msg_Dbg(p_input, "ioctl_SetupSwitch: index %i", i);
274 if ((i < 0) || (i >= (int)(sizeof(switch_cmds)/sizeof(struct diseqc_cmd_t))))
277 cmd[0] = &switch_cmds[i];
279 if ((ret = ioctl_DiseqcSendMsg (p_input, frontend_fd,
280 (i % 2) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13,
282 (i/2) % 2 ? SEC_TONE_ON : SEC_TONE_OFF,
283 (i/4) % 2 ? SEC_MINI_B : SEC_MINI_A))<0)
285 msg_Err(p_input, "ioctl_DiseqcSendMsg() failed (%d)", ret);
292 /*****************************************************************************
293 * ioctl_SetQPSKFrontend : controls the FE device
294 *****************************************************************************/
295 int ioctl_SetQPSKFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation,
296 unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
297 unsigned int u_adapter, unsigned int u_device )
302 char frontend[] = FRONTEND;
305 i_len = sizeof(FRONTEND);
306 if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
308 msg_Err(p_input, "DVB-S: FrontEnd snprintf() truncated string for FRONTEND" );
309 frontend[sizeof(FRONTEND)] = '\0';
312 /* Open the frontend device */
313 msg_Dbg(p_input, "DVB-S: Opening frontend %s", frontend);
314 if(( front = open(frontend,O_RDWR)) < 0)
317 msg_Err(p_input, "DVB-S: failed to open frontend (%s)", strerror(errno));
319 msg_Err(p_input, "DVB-S: failed to open frontend");
324 /* Set the frequency of the transponder, taking into account the
325 local frequencies of the LNB */
326 hiband = (fep.frequency >= u_lnb_slof);
328 if ((ret=ioctl_SetupSwitch (p_input, front, 0, b_polarisation, hiband))<0)
330 msg_Err(p_input, "DVB-S: Setup frontend switch failed (%d)", ret);
335 fep.frequency -= u_lnb_lof2;
337 fep.frequency -= u_lnb_lof1;
339 /* Now send it all to the frontend device */
340 if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
344 msg_Err(p_input, "DVB-S: setting frontend failed (%d) %s", ret, strerror(errno));
346 msg_Err(p_input, "DVB-S: setting frontend failed (%d)", ret);
351 ret = ioctl_CheckFrontend(p_input, front);
353 /* Fixme: Return this instead of closing it.
354 Close front end device */
359 int ioctl_SetOFDMFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
360 unsigned int u_adapter, unsigned int u_device )
364 char frontend[] = FRONTEND;
367 i_len = sizeof(FRONTEND);
368 if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
370 msg_Err(p_input, "DVB-T FrontEnd snprintf() truncated string for FRONTEND" );
371 frontend[sizeof(FRONTEND)] = '\0';
374 /* Open the frontend device */
375 msg_Dbg(p_input, "DVB-T: Opening frontend %s", frontend);
376 if(( front = open(frontend,O_RDWR)) < 0)
379 msg_Err(p_input, "DVB-T: failed to open frontend (%s)", strerror(errno));
381 msg_Err(p_input, "DVB-T: failed to open frontend");
386 /* Now send it all to the frontend device */
387 if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
391 msg_Err(p_input, "DVB-T: setting frontend failed (%d) %s", ret, strerror(errno));
393 msg_Err(p_input, "DVB-T: setting frontend failed (%d)", ret);
398 ret = ioctl_CheckFrontend(p_input, front);
400 /* Fixme: Return this instead of closing it.
401 Close front end device */
406 int ioctl_SetQAMFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
407 unsigned int u_adapter, unsigned int u_device )
411 char frontend[] = FRONTEND;
414 i_len = sizeof(FRONTEND);
415 if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
417 msg_Err(p_input, "DVB-C: FrontEnd snprintf() truncated string for FRONTEND" );
418 frontend[sizeof(FRONTEND)] = '\0';
421 /* Open the frontend device */
422 msg_Dbg(p_input, "DVB-C: Opening frontend %s", frontend);
423 if(( front = open(frontend,O_RDWR)) < 0)
426 msg_Err(p_input, "DVB-C: failed to open frontend (%s)", strerror(errno));
428 msg_Err(p_input, "DVB-C: failed to open frontend");
433 /* Now send it all to the frontend device */
434 if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
438 msg_Err(p_input, "DVB-C: setting frontend failed (%d) %s", ret, strerror(errno));
440 msg_Err(p_input, "DVB-C: setting frontend failed (%d)", ret);
445 /* Check Status of frontend */
446 ret = ioctl_CheckFrontend(p_input, front);
448 /* Fixme: Return this instead of closing it.
449 Close front end device */
454 /******************************************************************
455 * Check completion of the frontend control sequence
456 ******************************************************************/
457 static int ioctl_CheckFrontend(input_thread_t * p_input, int front)
461 struct pollfd pfd[1];
462 struct dvb_frontend_event event;
463 /* poll for frontend event to check if tuning worked */
465 pfd[0].events = POLLIN;
471 if ((ret=ioctl(front, FE_READ_STATUS, &status))<0)
474 msg_Err(p_input, "reading frontend status failed (%d) %s", ret, strerror(errno));
476 msg_Err(p_input, "reading frontend status failed (%d)", ret);
480 if (status & FE_HAS_SIGNAL) /* found something above the noise level */
481 msg_Dbg(p_input, "check frontend ... has signal");
483 if (status & FE_HAS_CARRIER) /* found a DVB signal */
484 msg_Dbg(p_input, "check frontend ... has carrier");
486 if (status & FE_HAS_VITERBI) /* FEC is stable */
487 msg_Dbg(p_input, "check frontend ... has stable fec");
489 if (status & FE_HAS_SYNC) /* found sync bytes */
490 msg_Dbg(p_input, "check frontend ... has sync");
492 if (status & FE_HAS_LOCK) /* everything's working... */
494 msg_Dbg(p_input, "check frontend ... has lock");
495 msg_Dbg(p_input, "check frontend ... tuning status == 0x%02x!!! ..."
496 "tuning succeeded", status);
500 if (status & FE_TIMEDOUT) /* no lock within the last ~2 seconds */
502 msg_Dbg(p_input, "check frontend ... tuning status == 0x%02x!!! ..."
503 "tuning failed", status);
504 msg_Err(p_input, "check frontend ... timed out");
508 if (status & FE_REINIT)
510 /* frontend was reinitialized, */
511 /* application is recommned to reset */
512 /* DiSEqC, tone and parameters */
513 msg_Dbg(p_input, "DVB-S: tuning status == 0x%02x!!! ..."
514 "tuning failed", status);
515 msg_Err(p_input, "check frontend ... resend frontend parameters");
522 if (poll(pfd,1,3000))
524 if (pfd[0].revents & POLLIN)
526 if ( (ret=ioctl(front, FE_GET_EVENT, &event)) < 0)
529 msg_Err(p_input, "check frontend ... error occured (%d) %s", ret, strerror(errno));
531 msg_Err(p_input, "check frontend ... error occured (%d)", ret);
538 case FE_HAS_SIGNAL: /* found something above the noise level */
539 msg_Dbg(p_input, "check frontend ... has signal");
541 case FE_HAS_CARRIER: /* found a DVB signal */
542 msg_Dbg(p_input, "check frontend ... has carrier");
544 case FE_HAS_VITERBI: /* FEC is stable */
545 msg_Dbg(p_input, "check frontend ... has stable fec");
547 case FE_HAS_SYNC: /* found sync bytes */
548 msg_Dbg(p_input, "check frontend ... has sync");
550 case FE_HAS_LOCK: /* everything's working... */
551 msg_Dbg(p_input, "check frontend ... has lock");
553 case FE_TIMEDOUT: /* no lock within the last ~2 seconds */
554 msg_Err(p_input, "check frontend ... timed out");
556 case FE_REINIT: /* frontend was reinitialized, */
557 /* application is recommned to reset */
558 /* DiSEqC, tone and parameters */
559 msg_Err(p_input, "check frontend ... resend frontend parameters");
565 /* should come here */
566 msg_Err(p_input, "check frontend ... no event occured");
573 msg_Err(p_input, "check frontend ... timeout when polling for event (%s)", strerror(errno));
575 msg_Err(p_input, "check frontend ... timeout when polling for event ");
584 /*****************************************************************************
585 * ioctl_SetDMXFilter : controls the demux to add a filter
586 *****************************************************************************/
587 int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_type,
588 unsigned int u_adapter, unsigned int u_device )
590 struct dmx_pes_filter_params s_filter_params;
595 /* We first open the device */
597 if (snprintf( dmx, sizeof(DMX), DMX, u_adapter, u_device) >= i_len)
599 msg_Err(p_input, "snprintf() truncated string for DMX" );
600 dmx[sizeof(DMX)] = '\0';
603 msg_Dbg(p_input, "Opening demux device %s", dmx);
604 if (( (*pi_fd) = open(dmx, O_RDWR|O_NONBLOCK)) < 0)
607 msg_Err(p_input, "ioctl_SetDMXFilter: opening device failed (%s)", strerror(errno));
609 msg_Err(p_input, "ioctl_SetDMXFilter: opening device failed");
614 /* We fill the DEMUX structure : */
615 s_filter_params.pid = i_pid;
616 s_filter_params.input = DMX_IN_FRONTEND;
617 s_filter_params.output = DMX_OUT_TS_TAP;
621 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO0 for PMT %d", i_pid);
622 s_filter_params.pes_type = DMX_PES_VIDEO0;
625 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO0 for PMT %d", i_pid);
626 s_filter_params.pes_type = DMX_PES_AUDIO0;
629 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_TELETEXT0 for PMT %d", i_pid);
630 s_filter_params.pes_type = DMX_PES_TELETEXT0;
633 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE0 for PMT %d", i_pid);
634 s_filter_params.pes_type = DMX_PES_SUBTITLE0;
637 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_PCR0 for PMT %d", i_pid);
638 s_filter_params.pes_type = DMX_PES_PCR0;
642 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO1 for PMT %d", i_pid);
643 s_filter_params.pes_type = DMX_PES_VIDEO1;
646 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO1 for PMT %d", i_pid);
647 s_filter_params.pes_type = DMX_PES_AUDIO1;
650 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_TELETEXT1 for PMT %d", i_pid);
651 s_filter_params.pes_type = DMX_PES_TELETEXT1;
654 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE1 for PMT %d", i_pid);
655 s_filter_params.pes_type = DMX_PES_SUBTITLE1;
658 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_PCR1 for PMT %d", i_pid);
659 s_filter_params.pes_type = DMX_PES_PCR1;
663 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO2 for PMT %d", i_pid);
664 s_filter_params.pes_type = DMX_PES_VIDEO2;
667 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO2 for PMT %d", i_pid);
668 s_filter_params.pes_type = DMX_PES_AUDIO2;
671 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_TELETEXT2 for PMT %d", i_pid);
672 s_filter_params.pes_type = DMX_PES_TELETEXT2;
675 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE2 for PMT %d", i_pid);
676 s_filter_params.pes_type = DMX_PES_SUBTITLE2;
679 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_PCR2 for PMT %d", i_pid);
680 s_filter_params.pes_type = DMX_PES_PCR2;
684 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO3 for PMT %d", i_pid);
685 s_filter_params.pes_type = DMX_PES_VIDEO3;
688 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_AUDIO3 for PMT %d", i_pid);
689 s_filter_params.pes_type = DMX_PES_AUDIO3;
692 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_TELETEXT3 for PMT %d", i_pid);
693 s_filter_params.pes_type = DMX_PES_TELETEXT3;
696 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE3 for PMT %d", i_pid);
697 s_filter_params.pes_type = DMX_PES_SUBTITLE3;
700 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_PCR3 for PMT %d", i_pid);
701 s_filter_params.pes_type = DMX_PES_PCR3;
703 /* Usually used by Nova cards */
705 msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_OTHER for PMT %d", i_pid);
706 s_filter_params.pes_type = DMX_PES_OTHER;
708 /* What to do with i? */
710 msg_Err(p_input, "trying to set PMT id to=%d for unknown type %d", i_pid, i_type );
713 s_filter_params.flags = DMX_IMMEDIATE_START;
715 /* We then give the order to the device : */
716 if ((result = ioctl(*pi_fd, DMX_SET_PES_FILTER, &s_filter_params)) < 0)
719 msg_Err(p_input, "ioctl_SetDMXFilter: ioctl failed with %d (%s)",result, strerror(errno));
721 msg_Err(p_input, "ioctl_SetDMXFilter: ioctl failed with %d",result);
728 /*****************************************************************************
729 * ioctl_UnsetDMXFilter : removes a filter
730 *****************************************************************************/
731 int ioctl_UnsetDMXFilter(input_thread_t * p_input, int pi_fd)
735 if ((ret=ioctl( pi_fd, DMX_STOP))<0)
738 msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d) %s", pi_fd, ret, strerror(errno));
740 msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d)", pi_fd, ret);
744 msg_Dbg( p_input, "ioctl_UnsetDMXFilter closing demux %d", pi_fd);
749 /*****************************************************************************
750 * dvb_DecodeBandwidth : decodes arguments for DVB S/C/T card
751 *****************************************************************************/
752 fe_bandwidth_t dvb_DecodeBandwidth(input_thread_t * p_input, int bandwidth)
754 fe_bandwidth_t fe_bandwidth = 0;
759 fe_bandwidth = BANDWIDTH_AUTO;
762 fe_bandwidth = BANDWIDTH_6_MHZ;
765 fe_bandwidth = BANDWIDTH_7_MHZ;
768 fe_bandwidth = BANDWIDTH_8_MHZ;
771 msg_Dbg( p_input, "terrestrial dvb has bandwidth not set, using auto");
772 fe_bandwidth = BANDWIDTH_AUTO;
779 fe_code_rate_t dvb_DecodeFEC(input_thread_t * p_input, int fec)
781 fe_code_rate_t fe_fec = FEC_NONE;
815 msg_Err( p_input, "argument has invalid FEC (%d)", fec);
821 fe_modulation_t dvb_DecodeModulation(input_thread_t * p_input, int modulation)
823 fe_modulation_t fe_modulation = 0;
828 fe_modulation = QPSK;
831 fe_modulation = QAM_AUTO;
834 fe_modulation = QAM_16;
837 fe_modulation = QAM_32;
840 fe_modulation = QAM_64;
843 fe_modulation = QAM_128;
846 fe_modulation = QAM_256;
849 msg_Dbg( p_input, "terrestrial/cable dvb has constellation/modulation not set, using auto");
850 fe_modulation = QAM_AUTO;
853 return fe_modulation;
856 fe_transmit_mode_t dvb_DecodeTransmission(input_thread_t * p_input, int transmission)
858 fe_transmit_mode_t fe_transmission = 0;
860 switch( transmission )
863 fe_transmission = TRANSMISSION_MODE_AUTO;
866 fe_transmission = TRANSMISSION_MODE_2K;
869 fe_transmission = TRANSMISSION_MODE_8K;
872 msg_Dbg( p_input, "terrestrial dvb has transmission mode not set, using auto");
873 fe_transmission = TRANSMISSION_MODE_AUTO;
876 return fe_transmission;
879 fe_guard_interval_t dvb_DecodeGuardInterval(input_thread_t * p_input, int guard)
881 fe_guard_interval_t fe_guard = 0;
886 fe_guard = GUARD_INTERVAL_AUTO;
889 fe_guard = GUARD_INTERVAL_1_4;
892 fe_guard = GUARD_INTERVAL_1_8;
895 fe_guard = GUARD_INTERVAL_1_16;
898 fe_guard = GUARD_INTERVAL_1_32;
901 msg_Dbg( p_input, "terrestrial dvb has guard interval not set, using auto");
902 fe_guard = GUARD_INTERVAL_AUTO;
908 fe_hierarchy_t dvb_DecodeHierarchy(input_thread_t * p_input, int hierarchy)
910 fe_hierarchy_t fe_hierarchy = 0;
915 fe_hierarchy = HIERARCHY_NONE;
918 fe_hierarchy = HIERARCHY_AUTO;
921 fe_hierarchy = HIERARCHY_1;
924 fe_hierarchy = HIERARCHY_2;
927 fe_hierarchy = HIERARCHY_4;
930 msg_Dbg( p_input, "terrestrial dvb has hierarchy not set, using auto");
931 fe_hierarchy = HIERARCHY_AUTO;
937 fe_spectral_inversion_t dvb_DecodeInversion(input_thread_t * p_input, int inversion)
939 fe_spectral_inversion_t fe_inversion=0;
944 fe_inversion = INVERSION_OFF;
947 fe_inversion = INVERSION_ON;
950 fe_inversion = INVERSION_AUTO;
953 msg_Dbg( p_input, "dvb has inversion/polarisation not set, using auto");
954 fe_inversion = INVERSION_AUTO;