Mercurial > mplayer.hg
annotate stream/dvb_tune.c @ 30646:07a7bc5f94a8
Add header for exported DVB-related functions.
author | diego |
---|---|
date | Sun, 21 Feb 2010 21:00:08 +0000 |
parents | 7a5b8fc5df4a |
children | d9bbd1844876 |
rev | line source |
---|---|
9610 | 1 /* dvbtune - tune.c |
2 | |
3 Copyright (C) Dave Chapman 2001,2002 | |
4 | |
18783 | 5 Modified for use with MPlayer, for details see the changelog at |
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 | 9 This program is free software; you can redistribute it and/or |
10 modify it under the terms of the GNU General Public License | |
11 as published by the Free Software Foundation; either version 2 | |
12 of the License, or (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with this program; if not, write to the Free Software | |
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 Or, point your browser to http://www.gnu.org/copyleft/gpl.html | |
23 | |
24 */ | |
25 | |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <ctype.h> | |
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 | 31 #include <unistd.h> |
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 | 34 #include <errno.h> |
9610 | 35 #include "config.h" |
36 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
37 #ifdef CONFIG_DVB_HEAD |
9610 | 38 #include <linux/dvb/dmx.h> |
39 #include <linux/dvb/frontend.h> | |
40 #else | |
41 #include <ost/dmx.h> | |
42 #include <ost/sec.h> | |
43 #include <ost/frontend.h> | |
44 #endif | |
45 | |
46 #include "dvbin.h" | |
30646 | 47 #include "dvb_tune.h" |
17012 | 48 #include "mp_msg.h" |
9610 | 49 |
50 | |
51 | |
12309 | 52 int dvb_get_tuner_type(int fe_fd) |
9610 | 53 { |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
54 #ifdef CONFIG_DVB_HEAD |
10560 | 55 struct dvb_frontend_info fe_info; |
56 #else | |
57 FrontendInfo fe_info; | |
58 #endif | |
59 | |
12309 | 60 int res; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
61 |
10560 | 62 res = ioctl(fe_fd, FE_GET_INFO, &fe_info); |
63 if(res < 0) | |
64 { | |
65 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd); | |
66 return 0; | |
67 } | |
68 | |
69 switch(fe_info.type) | |
70 { | |
71 case FE_OFDM: | |
12309 | 72 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-T\n"); |
10560 | 73 return TUNER_TER; |
74 | |
75 case FE_QPSK: | |
12309 | 76 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-S\n"); |
10560 | 77 return TUNER_SAT; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
78 |
10560 | 79 case FE_QAM: |
12309 | 80 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-C\n"); |
10560 | 81 return TUNER_CBL; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
82 |
14382 | 83 #ifdef DVB_ATSC |
84 case FE_ATSC: | |
85 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-ATSC\n"); | |
86 return TUNER_ATSC; | |
87 #endif | |
10560 | 88 default: |
89 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
|
90 return 0; |
10560 | 91 } |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
92 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
93 } |
10560 | 94 |
24875 | 95 int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt) |
10560 | 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 int i; |
27786
187ca29cd878
Conditionally declare a conditionally used variable, fixes the warning:
diego
parents:
27431
diff
changeset
|
98 char frontend_dev[32], dvr_dev[32], demux_dev[32]; |
187ca29cd878
Conditionally declare a conditionally used variable, fixes the warning:
diego
parents:
27431
diff
changeset
|
99 #ifndef CONFIG_DVB_HEAD |
187ca29cd878
Conditionally declare a conditionally used variable, fixes the warning:
diego
parents:
27431
diff
changeset
|
100 char sec_dev[32]; |
187ca29cd878
Conditionally declare a conditionally used variable, fixes the warning:
diego
parents:
27431
diff
changeset
|
101 #endif |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
102 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
103 #ifdef CONFIG_DVB_HEAD |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 #else |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
108 sprintf(frontend_dev, "/dev/ost/frontend%d", n); |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
109 sprintf(dvr_dev, "/dev/ost/dvr%d", n); |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
110 sprintf(demux_dev, "/dev/ost/demux%d", n); |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
111 sprintf(sec_dev, "/dev/ost/sec%d", n); |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
112 #endif |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
113 priv->fe_fd = open(frontend_dev, O_RDWR | O_NONBLOCK); |
10560 | 114 if(priv->fe_fd < 0) |
9610 | 115 { |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
116 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", frontend_dev, errno); |
10560 | 117 return 0; |
9610 | 118 } |
27863
f3384addfb0b
set to -1 fds that were closed; handle the sec_fd only if CONFIG_DVB_HEAD isn't defined; patch by Reimar
nicodvb
parents:
27859
diff
changeset
|
119 #ifndef CONFIG_DVB_HEAD |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
120 priv->sec_fd = open(sec_dev, O_RDWR); |
21777 | 121 if(priv->sec_fd < 0) |
122 { | |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
123 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING SEC DEVICE %s: ERRNO %d\n", sec_dev, errno); |
10560 | 124 close(priv->fe_fd); |
21777 | 125 return 0; |
126 } | |
9610 | 127 #endif |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
128 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
|
129 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
|
130 for(i = 0; i < demux_cnt; i++) |
12309 | 131 { |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
132 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
|
133 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
|
134 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
135 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
|
136 return 0; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
137 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
138 else |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
139 { |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
140 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
|
141 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
|
142 } |
12309 | 143 } |
144 | |
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->dvr_fd = open(dvr_dev, O_RDONLY| O_NONBLOCK); |
12309 | 147 if(priv->dvr_fd < 0) |
148 { | |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
149 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DVR DEVICE %s: %d\n", dvr_dev, errno); |
12309 | 150 return 0; |
151 } | |
10560 | 152 |
21777 | 153 return 1; |
9610 | 154 } |
155 | |
156 | |
24875 | 157 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
|
158 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
159 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
|
160 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
|
161 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
162 #ifdef CONFIG_DVB_HEAD |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
163 sprintf(demux_dev, "/dev/dvb/adapter%d/demux0", priv->card); |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
164 #else |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
165 sprintf(demux_dev, "/dev/ost/demux%d", priv->card); |
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
166 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
167 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
168 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
|
169 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
|
170 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
171 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
|
172 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
173 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
|
174 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
|
175 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
176 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
|
177 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
178 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
|
179 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
180 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
|
181 { |
26401
617754f47828
in preparation for multi-frontend patch replaced file-static device names with sprintf() calls in 2 functions
nicodvb
parents:
25694
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
186 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
|
187 return 0; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
188 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
189 else |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
190 priv->demux_fds_cnt++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
191 } |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
192 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
193 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
194 return 1; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
195 } |
9610 | 196 |
10560 | 197 int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype) |
9610 | 198 { |
199 int i; | |
200 struct dmx_pes_filter_params pesFilterParams; | |
201 | |
202 pesFilterParams.pid = pid; | |
203 pesFilterParams.input = DMX_IN_FRONTEND; | |
204 pesFilterParams.output = DMX_OUT_TS_TAP; | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
205 #ifdef CONFIG_DVB_HEAD |
9610 | 206 pesFilterParams.pes_type = pestype; |
207 #else | |
208 pesFilterParams.pesType = pestype; | |
209 #endif | |
210 | |
10560 | 211 pesFilterParams.flags = DMX_IMMEDIATE_START; |
9610 | 212 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
213 errno = 0; |
9610 | 214 if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) |
215 { | |
10560 | 216 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno); |
217 return 0; | |
9610 | 218 } |
219 | |
10560 | 220 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 | 221 return 1; |
222 } | |
223 | |
224 | |
10560 | 225 int dvb_demux_stop(int fd) |
9610 | 226 { |
227 int i; | |
228 i = ioctl(fd, DMX_STOP); | |
229 | |
230 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STOPPING FD: %d, RESULT: %d\n", fd, i); | |
231 | |
29717
afc8b80eb027
cosmetics: Remove some pointless parentheses from return calls.
diego
parents:
29263
diff
changeset
|
232 return i == 0; |
9610 | 233 } |
234 | |
235 | |
10560 | 236 int dvb_demux_start(int fd) |
237 { | |
238 int i; | |
239 i = ioctl(fd, DMX_START); | |
9610 | 240 |
10560 | 241 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STARTING FD: %d, RESULT: %d\n", fd, i); |
242 | |
29717
afc8b80eb027
cosmetics: Remove some pointless parentheses from return calls.
diego
parents:
29263
diff
changeset
|
243 return i == 0; |
10560 | 244 } |
245 | |
246 | |
9610 | 247 static void print_status(fe_status_t festatus) |
248 { | |
249 mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:"); | |
250 if (festatus & FE_HAS_SIGNAL) mp_msg(MSGT_DEMUX, MSGL_V," FE_HAS_SIGNAL"); | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
251 #ifdef CONFIG_DVB_HEAD |
9610 | 252 if (festatus & FE_TIMEDOUT) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TIMEDOUT"); |
253 #else | |
254 if (festatus & FE_HAS_POWER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_POWER"); | |
255 if (festatus & FE_SPECTRUM_INV) mp_msg(MSGT_DEMUX, MSGL_V, " FE_SPECTRUM_INV"); | |
256 if (festatus & FE_TUNER_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TUNER_HAS_LOCK"); | |
257 #endif | |
258 if (festatus & FE_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_LOCK"); | |
259 if (festatus & FE_HAS_CARRIER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_CARRIER"); | |
260 if (festatus & FE_HAS_VITERBI) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_VITERBI"); | |
261 if (festatus & FE_HAS_SYNC) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SYNC"); | |
262 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); | |
263 } | |
264 | |
265 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
266 #ifdef CONFIG_DVB_HEAD |
21816 | 267 static int check_status(int fd_frontend, int tmout) |
9610 | 268 { |
269 int32_t strength; | |
270 fe_status_t festatus; | |
271 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
|
272 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
|
273 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
|
274 |
9610 | 275 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
|
276 pfd[0].events = POLLPRI; |
9610 | 277 |
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
|
278 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
|
279 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
|
280 while(!ok) |
9610 | 281 { |
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
|
282 festatus = 0; |
18561 | 283 if(poll(pfd,1,tmout*1000) > 0) |
9610 | 284 { |
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
|
285 if (pfd[0].revents & POLLPRI) |
9610 | 286 { |
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
|
287 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
|
288 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
|
289 locks++; |
9610 | 290 } |
291 } | |
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
|
292 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
|
293 tm2 = time((time_t*) NULL); |
18561 | 294 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
|
295 ok = 1; |
9610 | 296 } |
297 | |
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
|
298 if(festatus & FE_HAS_LOCK) |
9610 | 299 { |
300 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
|
301 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) |
9610 | 302 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); |
303 | |
304 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
|
305 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) |
9610 | 306 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); |
307 | |
308 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
|
309 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) |
9610 | 310 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); |
311 | |
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
|
312 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
|
313 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
|
314 mp_msg(MSGT_DEMUX, MSGL_V, "UNC: %d\n",strength); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
315 |
9610 | 316 print_status(festatus); |
317 } | |
318 else | |
319 { | |
18561 | 320 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout); |
9610 | 321 return -1; |
322 } | |
323 return 0; | |
324 } | |
325 | |
30645
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
326 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
327 struct diseqc_cmd { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
328 struct dvb_diseqc_master_cmd cmd; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
329 uint32_t wait; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
330 }; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
331 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
332 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
|
333 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
|
334 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
335 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
|
336 return -1; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
337 if(ioctl(fd, FE_SET_VOLTAGE, v) == -1) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
338 return -1; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
339 usleep(15 * 1000); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
340 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
|
341 return -1; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
342 usleep(cmd->wait * 1000); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
343 usleep(15 * 1000); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
344 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
|
345 return -1; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
346 usleep(15 * 1000); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
347 if(ioctl(fd, FE_SET_TONE, t) == -1) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
348 return -1; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
349 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
350 return 0; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
351 } |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
352 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
353 /* digital satellite equipment control, |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
354 * specification is available from http://www.eutelsat.com/ |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
355 */ |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
356 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
|
357 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
358 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
|
359 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
360 /* 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
|
361 * bits are: option, position, polarizaion, band |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
362 */ |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
363 cmd.cmd.msg[3] = |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
364 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
|
365 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
366 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
|
367 &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
|
368 (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
|
369 } |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
370 |
9610 | 371 #else |
372 | |
30645
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
373 static int SecGetStatus (int fd, struct secStatus *state) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
374 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
375 if(ioctl(fd, SEC_GET_STATUS, state) < 0) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
376 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
377 mp_msg(MSGT_DEMUX, MSGL_ERR, ("SEC GET STATUS: ")); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
378 return -1; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
379 } |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
380 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
381 switch (state->busMode) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
382 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
383 case SEC_BUS_IDLE: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
384 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: IDLE (%d)\n",state->busMode); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
385 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
386 case SEC_BUS_BUSY: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
387 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: BUSY (%d)\n",state->busMode); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
388 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
389 case SEC_BUS_OFF: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
390 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: OFF (%d)\n",state->busMode); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
391 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
392 case SEC_BUS_OVERLOAD: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
393 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: OVERLOAD (%d)\n",state->busMode); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
394 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
395 default: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
396 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: unknown (%d)\n",state->busMode); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
397 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
398 } |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
399 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
400 switch (state->selVolt) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
401 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
402 case SEC_VOLTAGE_OFF: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
403 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: OFF (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
404 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
405 case SEC_VOLTAGE_LT: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
406 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: LT (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
407 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
408 case SEC_VOLTAGE_13: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
409 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 13 (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
410 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
411 case SEC_VOLTAGE_13_5: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
412 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 13.5 (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
413 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
414 case SEC_VOLTAGE_18: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
415 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 18 (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
416 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
417 case SEC_VOLTAGE_18_5: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
418 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 18.5 (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
419 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
420 default: |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
421 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: unknown (%d)\n",state->selVolt); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
422 break; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
423 } |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
424 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
425 mp_msg(MSGT_DEMUX, MSGL_V, "SEC CONT TONE: %s\n", (state->contTone == SEC_TONE_ON ? "ON" : "OFF")); |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
426 return 0; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
427 } |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
428 |
21816 | 429 static int check_status(int fd_frontend, int tmout) |
9610 | 430 { |
431 int i,res; | |
432 int32_t strength; | |
433 fe_status_t festatus; | |
434 FrontendEvent event; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
435 |
9610 | 436 struct pollfd pfd[1]; |
437 | |
438 i = 0; res = -1; | |
439 while ((i < 3) && (res < 0)) | |
440 { | |
441 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
|
442 pfd[0].events = POLLIN | POLLPRI; |
9610 | 443 |
18561 | 444 if(poll(pfd,1,tmout*1000) > 0) |
9610 | 445 { |
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
|
446 if (pfd[0].revents & POLLPRI) |
9610 | 447 { |
448 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); | |
449 if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) | |
450 { | |
451 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_EVENT"); | |
452 return -1; | |
453 } | |
454 mp_msg(MSGT_DEMUX, MSGL_V, "Received "); | |
455 switch(event.type) | |
456 { | |
457 case FE_UNEXPECTED_EV: | |
458 mp_msg(MSGT_DEMUX, MSGL_V, "unexpected event\n"); | |
459 res = -1; | |
460 break; | |
461 | |
462 case FE_FAILURE_EV: | |
463 mp_msg(MSGT_DEMUX, MSGL_V, "failure event\n"); | |
464 res = -1; | |
465 break; | |
466 | |
467 case FE_COMPLETION_EV: | |
468 mp_msg(MSGT_DEMUX, MSGL_V, "completion event\n"); | |
469 res = 0; | |
470 break; | |
471 } | |
472 } | |
473 i++; | |
474 } | |
475 } | |
476 | |
477 if (res > 0) | |
478 switch (event.type) | |
479 { | |
480 case FE_UNEXPECTED_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_UNEXPECTED_EV\n"); | |
481 break; | |
482 case FE_COMPLETION_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_COMPLETION_EV\n"); | |
483 break; | |
484 case FE_FAILURE_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_FAILURE_EV\n"); | |
485 break; | |
486 } | |
487 | |
488 if (event.type == FE_COMPLETION_EV) | |
489 { | |
490 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
|
491 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) |
9610 | 492 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); |
493 | |
494 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
|
495 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) |
9610 | 496 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); |
497 | |
498 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
|
499 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) |
9610 | 500 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); |
501 | |
502 festatus=0; | |
503 mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:"); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
504 |
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
|
505 if(ioctl(fd_frontend,FE_READ_STATUS,&festatus) >= 0) |
21777 | 506 print_status(festatus); |
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
|
507 else |
21777 | 508 mp_msg(MSGT_DEMUX, MSGL_ERR, " ERROR, UNABLE TO READ_STATUS"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
509 |
9610 | 510 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); |
511 } | |
512 else | |
513 { | |
514 mp_msg(MSGT_DEMUX, MSGL_V, "Not able to lock to the signal on the given frequency\n"); | |
515 return -1; | |
516 } | |
517 return 0; | |
518 } | |
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
|
519 |
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
|
520 static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo) |
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
|
521 { |
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
|
522 struct secCommand scmd; |
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
|
523 struct secCmdSequence scmds; |
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
|
524 |
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
|
525 scmds.continuousTone = (hi_lo ? SEC_TONE_ON : SEC_TONE_OFF); |
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
|
526 scmds.voltage = (polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); |
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
|
527 scmds.miniCommand = SEC_MINI_NONE; |
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
|
528 |
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
|
529 scmd.type = SEC_CMDTYPE_DISEQC; |
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
|
530 scmds.numCommands = 1; |
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
|
531 scmds.commands = &scmd; |
9610 | 532 |
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
|
533 scmd.u.diseqc.addr = 0x10; |
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
|
534 scmd.u.diseqc.cmd = 0x38; |
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
|
535 scmd.u.diseqc.numParams = 1; |
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
|
536 scmd.u.diseqc.params[0] = 0xf0 | |
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
|
537 (((sat_no) << 2) & 0x0F) | |
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
|
538 (hi_lo ? 1 : 0) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
539 (polv ? 0 : 2); |
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
|
540 |
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
|
541 if (ioctl(secfd,SEC_SEND_SEQUENCE,&scmds) < 0) |
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
|
542 { |
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
|
543 mp_msg(MSGT_DEMUX, MSGL_ERR, "Error sending DisEqC"); |
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
|
544 return -1; |
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
|
545 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27863
diff
changeset
|
546 |
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
|
547 return 0; |
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
|
548 } |
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
|
549 #endif |
9610 | 550 |
551 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, | |
552 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
|
553 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, |
18561 | 554 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) |
9610 | 555 { |
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
|
556 int res, hi_lo, dfd; |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
557 #ifdef CONFIG_DVB_HEAD |
9610 | 558 struct dvb_frontend_parameters feparams; |
559 struct dvb_frontend_info fe_info; | |
560 #else | |
561 FrontendParameters feparams; | |
562 FrontendInfo fe_info; | |
21815
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
563 FrontendEvent event; |
9610 | 564 struct secStatus sec_state; |
565 #endif | |
566 | |
567 | |
10560 | 568 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 | 569 fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc); |
9610 | 570 |
571 | |
21824 | 572 memset(&feparams, 0, sizeof(feparams)); |
9610 | 573 if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)) |
574 { | |
21825 | 575 mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n"); |
576 return -1; | |
9610 | 577 } |
578 | |
579 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
580 #ifdef CONFIG_DVB_HEAD |
10560 | 581 mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name); |
9610 | 582 #endif |
583 | |
584 switch(fe_info.type) | |
585 { | |
586 case FE_OFDM: | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
587 #ifdef CONFIG_DVB_HEAD |
9610 | 588 if (freq < 1000000) freq*=1000UL; |
589 feparams.frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
590 feparams.inversion=specInv; |
9610 | 591 feparams.u.ofdm.bandwidth=bandwidth; |
592 feparams.u.ofdm.code_rate_HP=HP_CodeRate; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
593 feparams.u.ofdm.code_rate_LP=LP_CodeRate; |
9610 | 594 feparams.u.ofdm.constellation=modulation; |
595 feparams.u.ofdm.transmission_mode=TransmissionMode; | |
596 feparams.u.ofdm.guard_interval=guardInterval; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
597 feparams.u.ofdm.hierarchy_information=hier; |
9610 | 598 #else |
599 if (freq < 1000000) freq*=1000UL; | |
600 feparams.Frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
601 feparams.Inversion=specInv; |
9610 | 602 feparams.u.ofdm.bandWidth=bandwidth; |
603 feparams.u.ofdm.HP_CodeRate=HP_CodeRate; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
604 feparams.u.ofdm.LP_CodeRate=LP_CodeRate; |
9610 | 605 feparams.u.ofdm.Constellation=modulation; |
606 feparams.u.ofdm.TransmissionMode=TransmissionMode; | |
607 feparams.u.ofdm.guardInterval=guardInterval; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
608 feparams.u.ofdm.HierarchyInformation=hier; |
9610 | 609 #endif |
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
|
610 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth); |
9610 | 611 break; |
612 case FE_QPSK: | |
613 if (freq > 2200000) | |
614 { | |
615 // this must be an absolute frequency | |
616 if (freq < SLOF) | |
21825 | 617 { |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
618 #ifdef CONFIG_DVB_HEAD |
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
|
619 freq = feparams.frequency=(freq-LOF1); |
9610 | 620 #else |
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
|
621 freq = feparams.Frequency=(freq-LOF1); |
9610 | 622 #endif |
21825 | 623 hi_lo = 0; |
9610 | 624 } |
21825 | 625 else |
626 { | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
627 #ifdef CONFIG_DVB_HEAD |
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
|
628 freq = feparams.frequency=(freq-LOF2); |
9610 | 629 #else |
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
|
630 freq = feparams.Frequency=(freq-LOF2); |
9610 | 631 #endif |
21825 | 632 hi_lo = 1; |
9610 | 633 } |
634 } | |
635 else | |
636 { | |
637 // this is an L-Band frequency | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
638 #ifdef CONFIG_DVB_HEAD |
9610 | 639 feparams.frequency=freq; |
640 #else | |
641 feparams.Frequency=freq; | |
642 #endif | |
643 } | |
644 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
645 #ifdef CONFIG_DVB_HEAD |
9610 | 646 feparams.inversion=specInv; |
647 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
|
648 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
|
649 dfd = fd_frontend; |
9610 | 650 #else |
651 feparams.Inversion=specInv; | |
652 feparams.u.qpsk.SymbolRate=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
|
653 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
|
654 dfd = fd_sec; |
9610 | 655 #endif |
656 | |
21825 | 657 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 | 658 |
21825 | 659 if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0) |
660 mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n"); | |
661 else | |
662 { | |
663 mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n"); | |
664 return -1; | |
665 } | |
9610 | 666 break; |
667 case FE_QAM: | |
668 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate); | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
669 #ifdef CONFIG_DVB_HEAD |
9610 | 670 feparams.frequency=freq; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
671 feparams.inversion=specInv; |
9610 | 672 feparams.u.qam.symbol_rate = srate; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
673 feparams.u.qam.fec_inner = HP_CodeRate; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
674 feparams.u.qam.modulation = modulation; |
9610 | 675 #else |
676 feparams.Frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
677 feparams.Inversion=specInv; |
9610 | 678 feparams.u.qam.SymbolRate = srate; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
679 feparams.u.qam.FEC_inner = HP_CodeRate; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
680 feparams.u.qam.QAM = modulation; |
9610 | 681 #endif |
682 break; | |
14382 | 683 #ifdef DVB_ATSC |
684 case FE_ATSC: | |
685 mp_msg(MSGT_DEMUX, MSGL_V, "tuning ATSC to %d, modulation=%d\n",freq,modulation); | |
686 feparams.frequency=freq; | |
687 feparams.u.vsb.modulation = modulation; | |
688 break; | |
689 #endif | |
9610 | 690 default: |
691 mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n"); | |
10603 | 692 return 0; |
9610 | 693 } |
694 usleep(100000); | |
695 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
26401
diff
changeset
|
696 #ifndef CONFIG_DVB_HEAD |
9610 | 697 if (fd_sec) SecGetStatus(fd_sec, &sec_state); |
21815
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
698 while(1) |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
699 { |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
700 if(ioctl(fd_frontend, FE_GET_EVENT, &event) == -1) |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
701 break; |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
702 } |
9610 | 703 #endif |
704 | |
21815
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
705 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
|
706 { |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
707 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
|
708 return -1; |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
709 } |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
710 |
29717
afc8b80eb027
cosmetics: Remove some pointless parentheses from return calls.
diego
parents:
29263
diff
changeset
|
711 return check_status(fd_frontend, timeout); |
9610 | 712 } |
30645
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
713 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
714 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
715 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
|
716 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
|
717 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
|
718 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
|
719 { |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
720 int ris; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
721 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
722 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
|
723 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
724 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
|
725 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
726 if(ris != 0) |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
727 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
|
728 |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
729 return ris == 0; |
7a5b8fc5df4a
cosmetics: Move functions around to avoid forward declarations and #ifdefs.
diego
parents:
29717
diff
changeset
|
730 } |