annotate stream/dvb_tune.c @ 36736:cb25e73ac822

Make sdp:// URLs also work via FFmpeg.
author reimar
date Fri, 14 Feb 2014 19:01:19 +0000
parents d9bbd1844876
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
1 /* dvbtune - tune.c
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
2
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
3 Copyright (C) Dave Chapman 2001,2002
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
4
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18561
diff changeset
5 Modified for use with MPlayer, for details see the changelog at
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18561
diff changeset
6 http://svn.mplayerhq.hu/mplayer/trunk/
15178
8dd7a656eaf8 Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents: 14382
diff changeset
7 $Id$
8dd7a656eaf8 Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents: 14382
diff changeset
8
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
9 This program is free software; you can redistribute it and/or
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
10 modify it under the terms of the GNU General Public License
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
11 as published by the Free Software Foundation; either version 2
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
12 of the License, or (at your option) any later version.
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
13
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
17 GNU General Public License for more details.
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
18
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
20 along with this program; if not, write to the Free Software
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
22 Or, point your browser to http://www.gnu.org/copyleft/gpl.html
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
23
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
24 */
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
25
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
26 #include <stdio.h>
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
27 #include <stdlib.h>
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
28 #include <ctype.h>
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
29 #include <sys/ioctl.h>
27431
bb738b9ea7c4 Use '#include <poll.h>' instead of '#include <sys/poll.h>'.
diego
parents: 27370
diff changeset
30 #include <poll.h>
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
31 #include <unistd.h>
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
32 #include <fcntl.h>
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
33 #include <time.h>
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
34 #include <errno.h>
30776
d9bbd1844876 Drop support for old-style DVB code.
diego
parents: 30646
diff changeset
35 #include <linux/dvb/dmx.h>
d9bbd1844876 Drop support for old-style DVB code.
diego
parents: 30646
diff changeset
36 #include <linux/dvb/frontend.h>
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
37 #include "config.h"
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
38 #include "dvbin.h"
30646
07a7bc5f94a8 Add header for exported DVB-related functions.
diego
parents: 30645
diff changeset
39 #include "dvb_tune.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15178
diff changeset
40 #include "mp_msg.h"
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
41
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
42
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
43
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
44 int dvb_get_tuner_type(int fe_fd)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
45 {
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
46 struct dvb_frontend_info fe_info;
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
47
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
48 int res;
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
49
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
50 res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
51 if(res < 0)
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
52 {
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
53 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
54 return 0;
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
55 }
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
56
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
57 switch(fe_info.type)
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
58 {
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
59 case FE_OFDM:
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
60 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-T\n");
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
61 return TUNER_TER;
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
62
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
63 case FE_QPSK:
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
64 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-S\n");
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
65 return TUNER_SAT;
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
66
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
67 case FE_QAM:
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
68 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-C\n");
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
69 return TUNER_CBL;
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
70
14382
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
71 #ifdef DVB_ATSC
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
72 case FE_ATSC:
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
73 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-ATSC\n");
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
74 return TUNER_ATSC;
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
75 #endif
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
76 default:
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
77 mp_msg(MSGT_DEMUX, MSGL_ERR, "UNKNOWN TUNER TYPE\n");
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
78 return 0;
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
79 }
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
80
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
81 }
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
82
24875
fe6dc73c7314 removed unused variables and parameters
nicodvb
parents: 24861
diff changeset
83 int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt)
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
84 {
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
85 int i;
27786
187ca29cd878 Conditionally declare a conditionally used variable, fixes the warning:
diego
parents: 27431
diff changeset
86 char frontend_dev[32], dvr_dev[32], demux_dev[32];
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
87
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
88 sprintf(frontend_dev, "/dev/dvb/adapter%d/frontend0", n);
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
89 sprintf(dvr_dev, "/dev/dvb/adapter%d/dvr0", n);
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
90 sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", n);
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
91 priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK);
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
92 if(priv->fe_fd < 0)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
93 {
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
94 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno);
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
95 return 0;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
96 }
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
97 priv->demux_fds_cnt = 0;
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
98 mp_msg(MSGT_DEMUX, MSGL_V, "DVB_OPEN_DEVICES(%d)\n", demux_cnt);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
99 for(i = 0; i < demux_cnt; i++)
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
100 {
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
101 priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK);
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
102 if(priv->demux_fds[i] < 0)
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
103 {
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
104 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
105 return 0;
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
106 }
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
107 else
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
108 {
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
109 mp_msg(MSGT_DEMUX, MSGL_V, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, demux_dev, priv->demux_fds[i], priv->demux_fds_cnt);
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
110 priv->demux_fds_cnt++;
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
111 }
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
112 }
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
113
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
114
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
115 priv->dvr_fd = open(dvr_dev, O_RDONLY| O_NONBLOCK);
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
116 if(priv->dvr_fd < 0)
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
117 {
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
118 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno);
12309
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
119 return 0;
5c375ea5fb0f new configuration structure, gcc warn silencing
nicodvb
parents: 12048
diff changeset
120 }
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
121
21777
3af036ae3c75 reindentation
nicodvb
parents: 19271
diff changeset
122 return 1;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
123 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
124
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
125
24875
fe6dc73c7314 removed unused variables and parameters
nicodvb
parents: 24861
diff changeset
126 int dvb_fix_demuxes(dvb_priv_t *priv, int cnt)
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
127 {
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
128 int i;
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
129 char demux_dev[32];
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
130
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
131 sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card);
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
132 mp_msg(MSGT_DEMUX, MSGL_V, "FIX %d -> %d\n", priv->demux_fds_cnt, cnt);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
133 if(priv->demux_fds_cnt >= cnt)
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
134 {
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
135 for(i = priv->demux_fds_cnt-1; i >= cnt; i--)
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
136 {
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
137 mp_msg(MSGT_DEMUX, MSGL_V, "FIX, CLOSE fd(%d): %d\n", i, priv->demux_fds[i]);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
138 close(priv->demux_fds[i]);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
139 }
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
140 priv->demux_fds_cnt = cnt;
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
141 }
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
142 else if(priv->demux_fds_cnt < cnt)
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
143 {
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
144 for(i = priv->demux_fds_cnt; i < cnt; i++)
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
145 {
26401
617754f47828 in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents: 25694
diff changeset
146 priv->demux_fds[i] = open(demux_dev, O_RDWR | O_NONBLOCK);
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
147 mp_msg(MSGT_DEMUX, MSGL_V, "FIX, OPEN fd(%d): %d\n", i, priv->demux_fds[i]);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
148 if(priv->demux_fds[i] < 0)
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
149 {
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
150 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DEMUX 0: %d\n", errno);
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
151 return 0;
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
152 }
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
153 else
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
154 priv->demux_fds_cnt++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27863
diff changeset
155 }
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
156 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27863
diff changeset
157
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
158 return 1;
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
159 }
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
160
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
161 int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
162 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
163 int i;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
164 struct dmx_pes_filter_params pesFilterParams;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
165
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
166 pesFilterParams.pid = pid;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
167 pesFilterParams.input = DMX_IN_FRONTEND;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
168 pesFilterParams.output = DMX_OUT_TS_TAP;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
169 pesFilterParams.pes_type = pestype;
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
170 pesFilterParams.flags = DMX_IMMEDIATE_START;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
171
12803
168238f8c715 added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents: 12309
diff changeset
172 errno = 0;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
173 if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0)
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
174 {
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
175 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno);
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
176 return 0;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
177 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
178
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
179 mp_msg(MSGT_DEMUX, MSGL_V, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
180 return 1;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
181 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
182
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
183
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
184 int dvb_demux_stop(int fd)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
185 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
186 int i;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
187 i = ioctl(fd, DMX_STOP);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
188
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
189 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STOPPING FD: %d, RESULT: %d\n", fd, i);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
190
29717
afc8b80eb027 cosmetics: Remove some pointless parentheses from return calls.
diego
parents: 29263
diff changeset
191 return i == 0;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
192 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
193
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
194
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
195 int dvb_demux_start(int fd)
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
196 {
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
197 int i;
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
198 i = ioctl(fd, DMX_START);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
199
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
200 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STARTING FD: %d, RESULT: %d\n", fd, i);
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
201
29717
afc8b80eb027 cosmetics: Remove some pointless parentheses from return calls.
diego
parents: 29263
diff changeset
202 return i == 0;
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
203 }
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
204
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
205
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
206 static void print_status(fe_status_t festatus)
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
207 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
208 mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
209 if (festatus & FE_HAS_SIGNAL) mp_msg(MSGT_DEMUX, MSGL_V," FE_HAS_SIGNAL");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
210 if (festatus & FE_TIMEDOUT) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TIMEDOUT");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
211 if (festatus & FE_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_LOCK");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
212 if (festatus & FE_HAS_CARRIER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_CARRIER");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
213 if (festatus & FE_HAS_VITERBI) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_VITERBI");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
214 if (festatus & FE_HAS_SYNC) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SYNC");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
215 mp_msg(MSGT_DEMUX, MSGL_V, "\n");
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
216 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
217
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
218
21816
fa8128898231 removed useless reporting code
nicodvb
parents: 21815
diff changeset
219 static int check_status(int fd_frontend, int tmout)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
220 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
221 int32_t strength;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
222 fe_status_t festatus;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
223 struct pollfd pfd[1];
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
224 int ok=0, locks=0;
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
225 time_t tm1, tm2;
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
226
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
227 pfd[0].fd = fd_frontend;
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
228 pfd[0].events = POLLPRI;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
229
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
230 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend status\n");
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
231 tm1 = tm2 = time((time_t*) NULL);
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
232 while(!ok)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
233 {
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
234 festatus = 0;
18561
15fbdb09330f configurable tuning timeout
nicodvb
parents: 17012
diff changeset
235 if(poll(pfd,1,tmout*1000) > 0)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
236 {
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
237 if (pfd[0].revents & POLLPRI)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
238 {
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
239 if(ioctl(fd_frontend, FE_READ_STATUS, &festatus) >= 0)
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
240 if(festatus & FE_HAS_LOCK)
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
241 locks++;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
242 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
243 }
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
244 usleep(10000);
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
245 tm2 = time((time_t*) NULL);
18561
15fbdb09330f configurable tuning timeout
nicodvb
parents: 17012
diff changeset
246 if((festatus & FE_TIMEDOUT) || (locks >= 2) || (tm2 - tm1 >= tmout))
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
247 ok = 1;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
248 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
249
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
250 if(festatus & FE_HAS_LOCK)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
251 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
252 strength=0;
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
253 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
254 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
255
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
256 strength=0;
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
257 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
258 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
259
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
260 strength=0;
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
261 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
262 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
263
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
264 strength=0;
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
265 if(ioctl(fd_frontend,FE_READ_UNCORRECTED_BLOCKS,&strength) >= 0)
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
266 mp_msg(MSGT_DEMUX, MSGL_V, "UNC: %d\n",strength);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 27863
diff changeset
267
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
268 print_status(festatus);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
269 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
270 else
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
271 {
18561
15fbdb09330f configurable tuning timeout
nicodvb
parents: 17012
diff changeset
272 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
273 return -1;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
274 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
275 return 0;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
276 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
277
30645
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
278
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
279 struct diseqc_cmd {
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
280 struct dvb_diseqc_master_cmd cmd;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
281 uint32_t wait;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
282 };
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
283
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
284 static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
285 fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
286 {
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
287 if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
288 return -1;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
289 if(ioctl(fd, FE_SET_VOLTAGE, v) == -1)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
290 return -1;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
291 usleep(15 * 1000);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
292 if(ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd) == -1)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
293 return -1;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
294 usleep(cmd->wait * 1000);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
295 usleep(15 * 1000);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
296 if(ioctl(fd, FE_DISEQC_SEND_BURST, b) == -1)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
297 return -1;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
298 usleep(15 * 1000);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
299 if(ioctl(fd, FE_SET_TONE, t) == -1)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
300 return -1;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
301
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
302 return 0;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
303 }
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
304
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
305 /* digital satellite equipment control,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
306 * specification is available from http://www.eutelsat.com/
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
307 */
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
308 static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
309 {
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
310 struct diseqc_cmd cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
311
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
312 /* param: high nibble: reset bits, low nibble set bits,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
313 * bits are: option, position, polarizaion, band
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
314 */
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
315 cmd.cmd.msg[3] =
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
316 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2));
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
317
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
318 return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
319 &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
320 (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
321 }
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
322
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
323 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
324 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate,
13155
fd40ef23053b added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents: 12803
diff changeset
325 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
18561
15fbdb09330f configurable tuning timeout
nicodvb
parents: 17012
diff changeset
326 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
327 {
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
328 int res, hi_lo, dfd;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
329 struct dvb_frontend_parameters feparams;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
330 struct dvb_frontend_info fe_info;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
331
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
332 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",
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
333 fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
334
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
335
21824
8353d81de100 init to 0 feparams before tuning
nicodvb
parents: 21816
diff changeset
336 memset(&feparams, 0, sizeof(feparams));
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
337 if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0))
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
338 {
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
339 mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n");
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
340 return -1;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
341 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
342
10560
11826d9f90c7 this patch fixes
arpi
parents: 9610
diff changeset
343 mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
344
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
345 switch(fe_info.type)
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
346 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
347 case FE_OFDM:
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
348 if (freq < 1000000) freq*=1000UL;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
349 feparams.frequency=freq;
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
350 feparams.inversion=specInv;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
351 feparams.u.ofdm.bandwidth=bandwidth;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
352 feparams.u.ofdm.code_rate_HP=HP_CodeRate;
13155
fd40ef23053b added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents: 12803
diff changeset
353 feparams.u.ofdm.code_rate_LP=LP_CodeRate;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
354 feparams.u.ofdm.constellation=modulation;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
355 feparams.u.ofdm.transmission_mode=TransmissionMode;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
356 feparams.u.ofdm.guard_interval=guardInterval;
13155
fd40ef23053b added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents: 12803
diff changeset
357 feparams.u.ofdm.hierarchy_information=hier;
14282
2188637c0e8f replaced deprecated FE_GET_EVENT with FE_READ_STATUS (only for DVB_HEAD); added a workaround for drivers that don't support FE_TIMEDOUT
nicodvb
parents: 13155
diff changeset
358 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
359 break;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
360 case FE_QPSK:
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
361 if (freq > 2200000)
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
362 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
363 // this must be an absolute frequency
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
364 if (freq < SLOF)
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
365 {
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
366 freq = feparams.frequency=(freq-LOF1);
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
367 hi_lo = 0;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
368 }
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
369 else
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
370 {
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
371 freq = feparams.frequency=(freq-LOF2);
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
372 hi_lo = 1;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
373 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
374 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
375 else
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
376 {
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
377 // this is an L-Band frequency
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
378 feparams.frequency=freq;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
379 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
380
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
381 feparams.inversion=specInv;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
382 feparams.u.qpsk.symbol_rate=srate;
12048
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
383 feparams.u.qpsk.fec_inner=HP_CodeRate;
09aae06de9c8 removed unused code, synced to szap tuning sequence and unified diseqc, tone and voltage in a (non/old)-diseqc compatible function
nicodvb
parents: 11872
diff changeset
384 dfd = fd_frontend;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
385
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
386 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);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
387
21825
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
388 if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0)
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
389 mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n");
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
390 else
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
391 {
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
392 mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n");
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
393 return -1;
abc080b3f63a reindented
nicodvb
parents: 21824
diff changeset
394 }
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
395 break;
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
396 case FE_QAM:
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
397 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
398 feparams.frequency=freq;
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
399 feparams.inversion=specInv;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
400 feparams.u.qam.symbol_rate = srate;
11872
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
401 feparams.u.qam.fec_inner = HP_CodeRate;
d158978a3d3c Compliance with the DVB power management specification (doesn't close
attila
parents: 11352
diff changeset
402 feparams.u.qam.modulation = modulation;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
403 break;
14382
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
404 #ifdef DVB_ATSC
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
405 case FE_ATSC:
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
406 mp_msg(MSGT_DEMUX, MSGL_V, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
407 feparams.frequency=freq;
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
408 feparams.u.vsb.modulation = modulation;
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
409 break;
42d792053cde added support for ATSC tuner and conf.file
nicodvb
parents: 14282
diff changeset
410 #endif
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
411 default:
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
412 mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n");
10603
alex
parents: 10560
diff changeset
413 return 0;
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
414 }
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
415 usleep(100000);
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
416
21815
8b2d611f3ade moved actual tuning code from check_status() to tune_it()
nicodvb
parents: 21777
diff changeset
417 if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
8b2d611f3ade moved actual tuning code from check_status() to tune_it()
nicodvb
parents: 21777
diff changeset
418 {
8b2d611f3ade moved actual tuning code from check_status() to tune_it()
nicodvb
parents: 21777
diff changeset
419 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n");
8b2d611f3ade moved actual tuning code from check_status() to tune_it()
nicodvb
parents: 21777
diff changeset
420 return -1;
8b2d611f3ade moved actual tuning code from check_status() to tune_it()
nicodvb
parents: 21777
diff changeset
421 }
8b2d611f3ade moved actual tuning code from check_status() to tune_it()
nicodvb
parents: 21777
diff changeset
422
29717
afc8b80eb027 cosmetics: Remove some pointless parentheses from return calls.
diego
parents: 29263
diff changeset
423 return check_status(fd_frontend, timeout);
9610
76c6d8f1ebf5 this is a combo patch that:
arpi
parents:
diff changeset
424 }
30645
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
425
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
426
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
427 int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
428 fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
429 fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate,
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
430 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
431 {
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
432 int ris;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
433
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
434 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", (long unsigned int) freq);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
435
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
436 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);
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
437
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
438 if(ris != 0)
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
439 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n");
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
440
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
441 return ris == 0;
7a5b8fc5df4a cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents: 29717
diff changeset
442 }