Mercurial > mplayer.hg
annotate libmpdemux/dvb_tune.c @ 12265:c9e1fe032d10
1000000000000l to bunkus
author | rfelker |
---|---|
date | Fri, 23 Apr 2004 22:30:18 +0000 (2004-04-23) |
parents | 09aae06de9c8 |
children | 5c375ea5fb0f |
rev | line source |
---|---|
9610 | 1 /* dvbtune - tune.c |
2 | |
3 Copyright (C) Dave Chapman 2001,2002 | |
4 | |
5 This program is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU General Public License | |
7 as published by the Free Software Foundation; either version 2 | |
8 of the License, or (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 Or, point your browser to http://www.gnu.org/copyleft/gpl.html | |
19 | |
20 */ | |
21 | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <ctype.h> | |
25 #include <sys/ioctl.h> | |
26 #include <sys/poll.h> | |
27 #include <unistd.h> | |
28 #include <fcntl.h> | |
29 #include <error.h> | |
10560 | 30 #include <errno.h> |
9610 | 31 #include "config.h" |
32 | |
33 #ifdef HAVE_DVB_HEAD | |
34 #include <linux/dvb/dmx.h> | |
35 #include <linux/dvb/frontend.h> | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
36 char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"}; |
10560 | 37 char* dvb_dvrdev[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"}; |
38 char* dvb_demuxdev[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"}; | |
39 static char* dvb_secdev[4]={"","","",""}; //UNUSED, ONLY FOR UNIFORMITY | |
9610 | 40 #else |
41 #include <ost/dmx.h> | |
42 #include <ost/sec.h> | |
43 #include <ost/frontend.h> | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
44 char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"}; |
10560 | 45 char* dvb_dvrdev[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"}; |
46 static char* dvb_secdev[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"}; | |
47 char* dvb_demuxdev[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"}; | |
9610 | 48 #endif |
49 | |
50 #include "dvbin.h" | |
51 #include "../mp_msg.h" | |
52 | |
53 | |
54 | |
10560 | 55 int dvb_get_tuner_type(dvb_priv_t *priv) |
9610 | 56 { |
10560 | 57 #ifdef HAVE_DVB_HEAD |
58 struct dvb_frontend_info fe_info; | |
59 #else | |
60 FrontendInfo fe_info; | |
61 #endif | |
62 | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
63 int res, fe_fd; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
64 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
65 fe_fd = priv->fe_fd; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
66 |
10560 | 67 res = ioctl(fe_fd, FE_GET_INFO, &fe_info); |
68 if(res < 0) | |
69 { | |
70 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd); | |
71 return 0; | |
72 } | |
73 | |
74 switch(fe_info.type) | |
75 { | |
76 case FE_OFDM: | |
77 mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-T\n"); | |
78 return TUNER_TER; | |
79 | |
80 case FE_QPSK: | |
81 mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-S\n"); | |
82 return TUNER_SAT; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
83 |
10560 | 84 case FE_QAM: |
85 mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-C\n"); | |
86 return TUNER_CBL; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
87 |
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 |
95 | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
96 int dvb_open_fe(dvb_priv_t *priv) |
10560 | 97 { |
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
|
98 priv->fe_fd = open(dvb_frontenddev[priv->card], O_RDWR | O_NONBLOCK); |
10560 | 99 if(priv->fe_fd < 0) |
9610 | 100 { |
11352 | 101 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN OPENING FRONTEND DEVICE %s: ERRNO %d\n", dvb_frontenddev[priv->card], errno); |
10560 | 102 return 0; |
9610 | 103 } |
104 #ifdef HAVE_DVB_HEAD | |
10560 | 105 priv->sec_fd=0; |
9610 | 106 #else |
10560 | 107 priv->sec_fd = open(dvb_secdev[priv->card], O_RDWR); |
108 if(priv->sec_fd < 0) | |
109 { | |
11352 | 110 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN OPENING SEC DEVICE %s: ERRNO %d\n", dvb_secdev[priv->card], errno); |
10560 | 111 close(priv->fe_fd); |
112 return 0; | |
113 } | |
9610 | 114 #endif |
10560 | 115 |
116 return 1; | |
9610 | 117 } |
118 | |
119 | |
120 | |
10560 | 121 int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype) |
9610 | 122 { |
123 int i; | |
124 struct dmx_pes_filter_params pesFilterParams; | |
125 | |
126 pesFilterParams.pid = pid; | |
127 pesFilterParams.input = DMX_IN_FRONTEND; | |
128 pesFilterParams.output = DMX_OUT_TS_TAP; | |
129 #ifdef HAVE_DVB_HEAD | |
130 pesFilterParams.pes_type = pestype; | |
131 #else | |
132 pesFilterParams.pesType = pestype; | |
133 #endif | |
134 | |
10560 | 135 pesFilterParams.flags = DMX_IMMEDIATE_START; |
9610 | 136 |
137 if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) | |
138 { | |
10560 | 139 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno); |
140 return 0; | |
9610 | 141 } |
142 | |
10560 | 143 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 | 144 return 1; |
145 } | |
146 | |
147 | |
10560 | 148 int dvb_demux_stop(int fd) |
9610 | 149 { |
150 int i; | |
151 i = ioctl(fd, DMX_STOP); | |
152 | |
153 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STOPPING FD: %d, RESULT: %d\n", fd, i); | |
154 | |
155 return (i==0); | |
156 } | |
157 | |
158 | |
10560 | 159 int dvb_demux_start(int fd) |
160 { | |
161 int i; | |
162 i = ioctl(fd, DMX_START); | |
9610 | 163 |
10560 | 164 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STARTING FD: %d, RESULT: %d\n", fd, i); |
165 | |
166 return (i==0); | |
167 } | |
168 | |
169 | |
9610 | 170 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, |
171 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, | |
172 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth); | |
173 | |
174 | |
175 dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, | |
176 fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, | |
177 fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate) | |
178 { | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
179 int ris; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
180 |
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
|
181 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", (long unsigned int) freq); |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
182 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
183 ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth); |
9610 | 184 |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
185 if(ris != 0) |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
186 mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n"); |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
187 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
188 return (ris == 0); |
9610 | 189 } |
190 | |
191 | |
192 #ifndef HAVE_DVB_HEAD | |
193 static int SecGetStatus (int fd, struct secStatus *state) | |
194 { | |
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
|
195 if(ioctl(fd, SEC_GET_STATUS, state) < 0) |
9610 | 196 { |
197 mp_msg(MSGT_DEMUX, MSGL_ERR, ("SEC GET STATUS: ")); | |
198 return -1; | |
199 } | |
200 | |
201 switch (state->busMode) | |
202 { | |
203 case SEC_BUS_IDLE: | |
204 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: IDLE (%d)\n",state->busMode); | |
205 break; | |
206 case SEC_BUS_BUSY: | |
207 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: BUSY (%d)\n",state->busMode); | |
208 break; | |
209 case SEC_BUS_OFF: | |
210 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: OFF (%d)\n",state->busMode); | |
211 break; | |
212 case SEC_BUS_OVERLOAD: | |
213 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: OVERLOAD (%d)\n",state->busMode); | |
214 break; | |
215 default: | |
216 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: unknown (%d)\n",state->busMode); | |
217 break; | |
218 } | |
219 | |
220 switch (state->selVolt) | |
221 { | |
222 case SEC_VOLTAGE_OFF: | |
223 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: OFF (%d)\n",state->selVolt); | |
224 break; | |
225 case SEC_VOLTAGE_LT: | |
226 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: LT (%d)\n",state->selVolt); | |
227 break; | |
228 case SEC_VOLTAGE_13: | |
229 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 13 (%d)\n",state->selVolt); | |
230 break; | |
231 case SEC_VOLTAGE_13_5: | |
232 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 13.5 (%d)\n",state->selVolt); | |
233 break; | |
234 case SEC_VOLTAGE_18: | |
235 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 18 (%d)\n",state->selVolt); | |
236 break; | |
237 case SEC_VOLTAGE_18_5: | |
238 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 18.5 (%d)\n",state->selVolt); | |
239 break; | |
240 default: | |
241 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: unknown (%d)\n",state->selVolt); | |
242 break; | |
243 } | |
244 | |
245 mp_msg(MSGT_DEMUX, MSGL_V, "SEC CONT TONE: %s\n", (state->contTone == SEC_TONE_ON ? "ON" : "OFF")); | |
246 return 0; | |
247 } | |
248 | |
249 #endif | |
250 | |
251 static void print_status(fe_status_t festatus) | |
252 { | |
253 mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:"); | |
254 if (festatus & FE_HAS_SIGNAL) mp_msg(MSGT_DEMUX, MSGL_V," FE_HAS_SIGNAL"); | |
255 #ifdef HAVE_DVB_HEAD | |
256 if (festatus & FE_TIMEDOUT) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TIMEDOUT"); | |
257 #else | |
258 if (festatus & FE_HAS_POWER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_POWER"); | |
259 if (festatus & FE_SPECTRUM_INV) mp_msg(MSGT_DEMUX, MSGL_V, " FE_SPECTRUM_INV"); | |
260 if (festatus & FE_TUNER_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TUNER_HAS_LOCK"); | |
261 #endif | |
262 if (festatus & FE_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_LOCK"); | |
263 if (festatus & FE_HAS_CARRIER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_CARRIER"); | |
264 if (festatus & FE_HAS_VITERBI) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_VITERBI"); | |
265 if (festatus & FE_HAS_SYNC) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SYNC"); | |
266 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); | |
267 } | |
268 | |
269 | |
270 #ifdef HAVE_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
|
271 static int check_status(int fd_frontend,struct dvb_frontend_parameters* feparams, int tuner_type, uint32_t base) |
9610 | 272 { |
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
|
273 int res; |
9610 | 274 int32_t strength; |
275 fe_status_t festatus; | |
276 struct dvb_frontend_event event; | |
277 struct pollfd pfd[1]; | |
278 | |
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
|
279 while(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
|
280 { |
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
|
281 if (ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) //EMPTY THE EVENT QUEUE |
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
|
282 break; |
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
|
283 } |
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
|
284 |
9610 | 285 if (ioctl(fd_frontend,FE_SET_FRONTEND,feparams) < 0) |
286 { | |
287 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n"); | |
288 return -1; | |
289 } | |
290 | |
291 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
|
292 pfd[0].events = POLLPRI; |
9610 | 293 |
294 event.status=0; | |
295 while (((event.status & FE_TIMEDOUT)==0) && ((event.status & FE_HAS_LOCK)==0)) | |
296 { | |
297 mp_msg(MSGT_DEMUX, MSGL_V, "polling....\n"); | |
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
|
298 if(poll(pfd,1,10000) > 0) |
9610 | 299 { |
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
|
300 if (pfd[0].revents & POLLPRI) |
9610 | 301 { |
302 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); | |
303 if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) | |
304 { | |
305 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_EVENT"); | |
306 return -1; | |
307 } | |
308 } | |
309 print_status(event.status); | |
310 } | |
311 } | |
312 | |
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
|
313 if(event.status & FE_HAS_LOCK) |
9610 | 314 { |
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
|
315 switch(tuner_type) |
9610 | 316 { |
317 case FE_OFDM: | |
318 mp_msg(MSGT_DEMUX, MSGL_V, "Event: Frequency: %d\n",event.parameters.frequency); | |
319 break; | |
320 case FE_QPSK: | |
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
|
321 mp_msg(MSGT_DEMUX, MSGL_V, "Event: Frequency: %d\n",(unsigned int)((event.parameters.frequency)+base)); |
9610 | 322 mp_msg(MSGT_DEMUX, MSGL_V, " SymbolRate: %d\n",event.parameters.u.qpsk.symbol_rate); |
323 mp_msg(MSGT_DEMUX, MSGL_V, " FEC_inner: %d\n",event.parameters.u.qpsk.fec_inner); | |
324 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); | |
325 break; | |
326 case FE_QAM: | |
327 mp_msg(MSGT_DEMUX, MSGL_V, "Event: Frequency: %d\n",event.parameters.frequency); | |
328 mp_msg(MSGT_DEMUX, MSGL_V, " SymbolRate: %d\n",event.parameters.u.qpsk.symbol_rate); | |
329 mp_msg(MSGT_DEMUX, MSGL_V, " FEC_inner: %d\n",event.parameters.u.qpsk.fec_inner); | |
330 break; | |
331 default: | |
332 break; | |
333 } | |
334 | |
335 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
|
336 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) |
9610 | 337 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); |
338 | |
339 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
|
340 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) |
9610 | 341 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); |
342 | |
343 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
|
344 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) |
9610 | 345 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); |
346 | |
347 festatus=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
|
348 if(ioctl(fd_frontend,FE_READ_STATUS,&festatus) >= 0) |
9610 | 349 print_status(festatus); |
350 } | |
351 else | |
352 { | |
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
|
353 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency\n"); |
9610 | 354 return -1; |
355 } | |
356 return 0; | |
357 } | |
358 | |
359 #else | |
360 | |
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
|
361 static int check_status(int fd_frontend,FrontendParameters* feparams,int tuner_type,uint32_t base) |
9610 | 362 { |
363 int i,res; | |
364 int32_t strength; | |
365 fe_status_t festatus; | |
366 FrontendEvent event; | |
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
|
367 |
9610 | 368 struct pollfd pfd[1]; |
369 | |
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
|
370 while(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
|
371 { |
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
|
372 if(ioctl(fd_frontend, FE_GET_EVENT, &event) == -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
|
373 break; |
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
|
374 } |
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
|
375 |
9610 | 376 i = 0; res = -1; |
377 while ((i < 3) && (res < 0)) | |
378 { | |
379 if (ioctl(fd_frontend,FE_SET_FRONTEND,feparams) < 0) | |
380 { | |
381 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n"); | |
382 return -1; | |
383 } | |
384 | |
385 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
|
386 pfd[0].events = POLLIN | POLLPRI; |
9610 | 387 |
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
|
388 if(poll(pfd,1,10000) > 0) |
9610 | 389 { |
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
|
390 if (pfd[0].revents & POLLPRI) |
9610 | 391 { |
392 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); | |
393 if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) | |
394 { | |
395 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_EVENT"); | |
396 return -1; | |
397 } | |
398 mp_msg(MSGT_DEMUX, MSGL_V, "Received "); | |
399 switch(event.type) | |
400 { | |
401 case FE_UNEXPECTED_EV: | |
402 mp_msg(MSGT_DEMUX, MSGL_V, "unexpected event\n"); | |
403 res = -1; | |
404 break; | |
405 | |
406 case FE_FAILURE_EV: | |
407 mp_msg(MSGT_DEMUX, MSGL_V, "failure event\n"); | |
408 res = -1; | |
409 break; | |
410 | |
411 case FE_COMPLETION_EV: | |
412 mp_msg(MSGT_DEMUX, MSGL_V, "completion event\n"); | |
413 res = 0; | |
414 break; | |
415 } | |
416 } | |
417 i++; | |
418 } | |
419 } | |
420 | |
421 if (res > 0) | |
422 switch (event.type) | |
423 { | |
424 case FE_UNEXPECTED_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_UNEXPECTED_EV\n"); | |
425 break; | |
426 case FE_COMPLETION_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_COMPLETION_EV\n"); | |
427 break; | |
428 case FE_FAILURE_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_FAILURE_EV\n"); | |
429 break; | |
430 } | |
431 | |
432 if (event.type == FE_COMPLETION_EV) | |
433 { | |
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
|
434 switch(tuner_type) |
9610 | 435 { |
436 case FE_OFDM: | |
437 mp_msg(MSGT_DEMUX, MSGL_V, "Event: Frequency: %d\n",event.u.completionEvent.Frequency); | |
438 break; | |
439 | |
440 case FE_QPSK: | |
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
|
441 mp_msg(MSGT_DEMUX, MSGL_V, "Event: Frequency: %d\n",(unsigned int)((event.u.completionEvent.Frequency)+base)); |
9610 | 442 mp_msg(MSGT_DEMUX, MSGL_V, " SymbolRate: %d\n",event.u.completionEvent.u.qpsk.SymbolRate); |
443 mp_msg(MSGT_DEMUX, MSGL_V, " FEC_inner: %d\n",event.u.completionEvent.u.qpsk.FEC_inner); | |
444 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); | |
445 break; | |
446 | |
447 case FE_QAM: | |
448 mp_msg(MSGT_DEMUX, MSGL_V, "Event: Frequency: %d\n",event.u.completionEvent.Frequency); | |
449 mp_msg(MSGT_DEMUX, MSGL_V, " SymbolRate: %d\n",event.u.completionEvent.u.qpsk.SymbolRate); | |
450 mp_msg(MSGT_DEMUX, MSGL_V, " FEC_inner: %d\n",event.u.completionEvent.u.qpsk.FEC_inner); | |
451 break; | |
452 | |
453 default: | |
454 break; | |
455 } | |
456 | |
457 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
|
458 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) |
9610 | 459 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); |
460 | |
461 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
|
462 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) |
9610 | 463 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); |
464 | |
465 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
|
466 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) |
9610 | 467 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); |
468 | |
469 festatus=0; | |
470 mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:"); | |
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
|
471 |
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
|
472 if(ioctl(fd_frontend,FE_READ_STATUS,&festatus) >= 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
|
473 print_status(festatus); |
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
|
474 else |
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
|
475 mp_msg(MSGT_DEMUX, MSGL_ERR, " ERROR, UNABLE TO READ_STATUS"); |
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
|
476 |
9610 | 477 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); |
478 } | |
479 else | |
480 { | |
481 mp_msg(MSGT_DEMUX, MSGL_V, "Not able to lock to the signal on the given frequency\n"); | |
482 return -1; | |
483 } | |
484 return 0; | |
485 } | |
486 #endif | |
487 | |
488 #ifdef HAVE_DVB_HEAD | |
489 | |
10560 | 490 static struct diseqc_cmd { |
9610 | 491 struct dvb_diseqc_master_cmd cmd; |
492 uint32_t wait; | |
493 }; | |
494 | |
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 static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd, |
9610 | 496 fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b) |
497 { | |
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
|
498 if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -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
|
499 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
|
500 if(ioctl(fd, FE_SET_VOLTAGE, v) == -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
|
501 return -1; |
9610 | 502 usleep(15 * 1000); |
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
|
503 if(ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd) == -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
|
504 return -1; |
9610 | 505 usleep(cmd->wait * 1000); |
506 usleep(15 * 1000); | |
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 if(ioctl(fd, FE_DISEQC_SEND_BURST, b) == -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
|
508 return -1; |
9610 | 509 usleep(15 * 1000); |
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
|
510 if(ioctl(fd, FE_SET_TONE, t) == -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
|
511 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
|
512 |
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
|
513 return 0; |
9610 | 514 } |
515 | |
516 /* digital satellite equipment control, | |
517 * specification is available from http://www.eutelsat.com/ | |
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 static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo) |
9610 | 520 { |
521 struct diseqc_cmd cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 }; | |
522 | |
523 /* param: high nibble: reset bits, low nibble set bits, | |
524 * bits are: option, position, polarizaion, band | |
525 */ | |
526 cmd.cmd.msg[3] = | |
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
|
527 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2)); |
9610 | 528 |
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
|
529 return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18, |
9610 | 530 &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF, |
531 (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A); | |
532 } | |
533 | |
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
|
534 #else |
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 |
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 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
|
537 { |
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 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
|
539 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
|
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 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
|
542 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
|
543 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
|
544 |
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 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
|
546 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
|
547 scmds.commands = &scmd; |
9610 | 548 |
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
|
549 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
|
550 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
|
551 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
|
552 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
|
553 (((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
|
554 (hi_lo ? 1 : 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
|
555 (polv ? 0 : 2); |
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 |
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
|
557 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
|
558 { |
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
|
559 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
|
560 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
|
561 } |
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
|
562 |
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
|
563 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
|
564 } |
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
|
565 #endif |
9610 | 566 |
567 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, | |
568 fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate, | |
569 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth) | |
570 { | |
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
|
571 int res, hi_lo, dfd; |
9610 | 572 #ifdef HAVE_DVB_HEAD |
573 struct dvb_frontend_parameters feparams; | |
574 struct dvb_frontend_info fe_info; | |
575 #else | |
576 FrontendParameters feparams; | |
577 FrontendInfo fe_info; | |
578 struct secStatus sec_state; | |
579 #endif | |
580 | |
581 | |
10560 | 582 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", |
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
|
583 fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc); |
9610 | 584 |
585 | |
586 if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)) | |
587 { | |
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
|
588 mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n"); |
9610 | 589 return -1; |
590 } | |
591 | |
592 | |
593 #ifdef HAVE_DVB_HEAD | |
10560 | 594 mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name); |
9610 | 595 #endif |
596 | |
597 switch(fe_info.type) | |
598 { | |
599 case FE_OFDM: | |
600 #ifdef HAVE_DVB_HEAD | |
601 if (freq < 1000000) freq*=1000UL; | |
602 feparams.frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
603 feparams.inversion=specInv; |
9610 | 604 feparams.u.ofdm.bandwidth=bandwidth; |
605 feparams.u.ofdm.code_rate_HP=HP_CodeRate; | |
606 feparams.u.ofdm.code_rate_LP=LP_CODERATE_DEFAULT; | |
607 feparams.u.ofdm.constellation=modulation; | |
608 feparams.u.ofdm.transmission_mode=TransmissionMode; | |
609 feparams.u.ofdm.guard_interval=guardInterval; | |
610 feparams.u.ofdm.hierarchy_information=HIERARCHY_DEFAULT; | |
611 #else | |
612 if (freq < 1000000) freq*=1000UL; | |
613 feparams.Frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
614 feparams.Inversion=specInv; |
9610 | 615 feparams.u.ofdm.bandWidth=bandwidth; |
616 feparams.u.ofdm.HP_CodeRate=HP_CodeRate; | |
617 feparams.u.ofdm.LP_CodeRate=LP_CODERATE_DEFAULT; | |
618 feparams.u.ofdm.Constellation=modulation; | |
619 feparams.u.ofdm.TransmissionMode=TransmissionMode; | |
620 feparams.u.ofdm.guardInterval=guardInterval; | |
621 feparams.u.ofdm.HierarchyInformation=HIERARCHY_DEFAULT; | |
622 #endif | |
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
|
623 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T (%s) to %d Hz, bandwidth: %d\n",DVB_T_LOCATION,freq, bandwidth); |
9610 | 624 break; |
625 case FE_QPSK: | |
626 if (freq > 2200000) | |
627 { | |
628 // this must be an absolute frequency | |
629 if (freq < SLOF) | |
630 { | |
631 #ifdef HAVE_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
|
632 freq = feparams.frequency=(freq-LOF1); |
9610 | 633 #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
|
634 freq = feparams.Frequency=(freq-LOF1); |
9610 | 635 #endif |
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
|
636 hi_lo = 0; |
9610 | 637 } |
638 else | |
639 { | |
640 #ifdef HAVE_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
|
641 freq = feparams.frequency=(freq-LOF2); |
9610 | 642 #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
|
643 freq = feparams.Frequency=(freq-LOF2); |
9610 | 644 #endif |
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
|
645 hi_lo = 1; |
9610 | 646 } |
647 } | |
648 else | |
649 { | |
650 // this is an L-Band frequency | |
651 #ifdef HAVE_DVB_HEAD | |
652 feparams.frequency=freq; | |
653 #else | |
654 feparams.Frequency=freq; | |
655 #endif | |
656 } | |
657 | |
658 #ifdef HAVE_DVB_HEAD | |
659 feparams.inversion=specInv; | |
660 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
|
661 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
|
662 dfd = fd_frontend; |
9610 | 663 #else |
664 feparams.Inversion=specInv; | |
665 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
|
666 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
|
667 dfd = fd_sec; |
9610 | 668 #endif |
669 | |
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
|
670 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 | 671 |
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
|
672 if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0) |
9610 | 673 mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n"); |
674 else | |
675 { | |
10560 | 676 mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n"); |
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
|
677 return -1; |
9610 | 678 } |
679 break; | |
680 case FE_QAM: | |
681 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate); | |
682 #ifdef HAVE_DVB_HEAD | |
683 feparams.frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
684 feparams.inversion=specInv; |
9610 | 685 feparams.u.qam.symbol_rate = srate; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
686 feparams.u.qam.fec_inner = HP_CodeRate; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
687 feparams.u.qam.modulation = modulation; |
9610 | 688 #else |
689 feparams.Frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
690 feparams.Inversion=specInv; |
9610 | 691 feparams.u.qam.SymbolRate = srate; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
692 feparams.u.qam.FEC_inner = HP_CodeRate; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
693 feparams.u.qam.QAM = modulation; |
9610 | 694 #endif |
695 break; | |
696 default: | |
697 mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n"); | |
10603 | 698 return 0; |
9610 | 699 } |
700 usleep(100000); | |
701 | |
702 #ifndef HAVE_DVB_HEAD | |
703 if (fd_sec) SecGetStatus(fd_sec, &sec_state); | |
704 #endif | |
705 | |
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
|
706 return(check_status(fd_frontend,&feparams,fe_info.type, (hi_lo ? LOF2 : LOF1))); |
9610 | 707 } |