Mercurial > mplayer.hg
annotate stream/dvb_tune.c @ 24173:49aa1cef1867
Fix warning:
In file included from layer3.c:1171,
from sr1.c:391:
decod386.c:106: warning: redundant redeclaration of 'synth_1to1_MMX'
mpg123.h:120: warning: previous declaration of 'synth_1to1_MMX' was here
author | diego |
---|---|
date | Sat, 25 Aug 2007 17:05:02 +0000 |
parents | 4cdc4b2cd3da |
children | 1c09a39f755a |
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> | |
30 #include <sys/poll.h> | |
31 #include <unistd.h> | |
32 #include <fcntl.h> | |
33 #include <error.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
|
34 #include <time.h> |
10560 | 35 #include <errno.h> |
9610 | 36 #include "config.h" |
37 | |
38 #ifdef HAVE_DVB_HEAD | |
39 #include <linux/dvb/dmx.h> | |
40 #include <linux/dvb/frontend.h> | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
41 char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"}; |
10560 | 42 char* dvb_dvrdev[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"}; |
43 char* dvb_demuxdev[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"}; | |
44 static char* dvb_secdev[4]={"","","",""}; //UNUSED, ONLY FOR UNIFORMITY | |
9610 | 45 #else |
46 #include <ost/dmx.h> | |
47 #include <ost/sec.h> | |
48 #include <ost/frontend.h> | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
49 char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"}; |
10560 | 50 char* dvb_dvrdev[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"}; |
51 static char* dvb_secdev[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"}; | |
52 char* dvb_demuxdev[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"}; | |
9610 | 53 #endif |
54 | |
55 #include "dvbin.h" | |
17012 | 56 #include "mp_msg.h" |
9610 | 57 |
58 | |
59 | |
12309 | 60 int dvb_get_tuner_type(int fe_fd) |
9610 | 61 { |
10560 | 62 #ifdef HAVE_DVB_HEAD |
63 struct dvb_frontend_info fe_info; | |
64 #else | |
65 FrontendInfo fe_info; | |
66 #endif | |
67 | |
12309 | 68 int res; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
69 |
10560 | 70 res = ioctl(fe_fd, FE_GET_INFO, &fe_info); |
71 if(res < 0) | |
72 { | |
73 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd); | |
74 return 0; | |
75 } | |
76 | |
77 switch(fe_info.type) | |
78 { | |
79 case FE_OFDM: | |
12309 | 80 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-T\n"); |
10560 | 81 return TUNER_TER; |
82 | |
83 case FE_QPSK: | |
12309 | 84 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-S\n"); |
10560 | 85 return TUNER_SAT; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
86 |
10560 | 87 case FE_QAM: |
12309 | 88 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-C\n"); |
10560 | 89 return TUNER_CBL; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
90 |
14382 | 91 #ifdef DVB_ATSC |
92 case FE_ATSC: | |
93 mp_msg(MSGT_DEMUX, MSGL_V, "TUNER TYPE SEEMS TO BE DVB-ATSC\n"); | |
94 return TUNER_ATSC; | |
95 #endif | |
10560 | 96 default: |
97 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
|
98 return 0; |
10560 | 99 } |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
100 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
101 } |
10560 | 102 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
103 int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
104 |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
105 int dvb_open_devices(dvb_priv_t *priv, int n, int demux_cnt, int *pids) |
10560 | 106 { |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
107 int i; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
108 |
12309 | 109 priv->fe_fd = open(dvb_frontenddev[n], O_RDWR | O_NONBLOCK); |
10560 | 110 if(priv->fe_fd < 0) |
9610 | 111 { |
12309 | 112 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING FRONTEND DEVICE %s: ERRNO %d\n", dvb_frontenddev[n], errno); |
10560 | 113 return 0; |
9610 | 114 } |
115 #ifdef HAVE_DVB_HEAD | |
21777 | 116 priv->sec_fd=0; |
9610 | 117 #else |
12309 | 118 priv->sec_fd = open(dvb_secdev[n], O_RDWR); |
21777 | 119 if(priv->sec_fd < 0) |
120 { | |
12309 | 121 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING SEC DEVICE %s: ERRNO %d\n", dvb_secdev[n], errno); |
10560 | 122 close(priv->fe_fd); |
21777 | 123 return 0; |
124 } | |
9610 | 125 #endif |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
126 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
|
127 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
|
128 for(i = 0; i < demux_cnt; i++) |
12309 | 129 { |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
130 priv->demux_fds[i] = open(dvb_demuxdev[n], O_RDWR | O_NONBLOCK); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
131 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
|
132 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
133 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
|
134 return 0; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
135 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
136 else |
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 mp_msg(MSGT_DEMUX, MSGL_V, "OPEN(%d), file %s: FD=%d, CNT=%d\n", i, dvb_demuxdev[n], priv->demux_fds[i], 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
|
139 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
|
140 } |
12309 | 141 } |
142 | |
143 | |
144 priv->dvr_fd = open(dvb_dvrdev[n], O_RDONLY| O_NONBLOCK); | |
145 if(priv->dvr_fd < 0) | |
146 { | |
147 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING DVR DEVICE %s: %d\n", dvb_dvrdev[n], errno); | |
148 return 0; | |
149 } | |
10560 | 150 |
21777 | 151 return 1; |
9610 | 152 } |
153 | |
154 | |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
155 int dvb_fix_demuxes(dvb_priv_t *priv, int cnt, int *pids) |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
156 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
157 int i; |
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 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
|
160 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
|
161 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
162 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
|
163 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
164 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
|
165 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
|
166 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
167 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
|
168 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
169 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
|
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; 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 priv->demux_fds[i] = open(dvb_demuxdev[priv->card], O_RDWR | O_NONBLOCK); |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
174 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
|
175 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
|
176 { |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
177 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
|
178 return 0; |
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 else |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
181 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
|
182 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
183 } |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
184 |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
185 return 1; |
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
186 } |
9610 | 187 |
10560 | 188 int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype) |
9610 | 189 { |
190 int i; | |
191 struct dmx_pes_filter_params pesFilterParams; | |
192 | |
193 pesFilterParams.pid = pid; | |
194 pesFilterParams.input = DMX_IN_FRONTEND; | |
195 pesFilterParams.output = DMX_OUT_TS_TAP; | |
196 #ifdef HAVE_DVB_HEAD | |
197 pesFilterParams.pes_type = pestype; | |
198 #else | |
199 pesFilterParams.pesType = pestype; | |
200 #endif | |
201 | |
10560 | 202 pesFilterParams.flags = DMX_IMMEDIATE_START; |
9610 | 203 |
12803
168238f8c715
added multi-pid parsing code (up to 15), pid 0 is always added (for the PAT)
nicodvb
parents:
12309
diff
changeset
|
204 errno = 0; |
9610 | 205 if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) |
206 { | |
10560 | 207 mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno); |
208 return 0; | |
9610 | 209 } |
210 | |
10560 | 211 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 | 212 return 1; |
213 } | |
214 | |
215 | |
10560 | 216 int dvb_demux_stop(int fd) |
9610 | 217 { |
218 int i; | |
219 i = ioctl(fd, DMX_STOP); | |
220 | |
221 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STOPPING FD: %d, RESULT: %d\n", fd, i); | |
222 | |
223 return (i==0); | |
224 } | |
225 | |
226 | |
10560 | 227 int dvb_demux_start(int fd) |
228 { | |
229 int i; | |
230 i = ioctl(fd, DMX_START); | |
9610 | 231 |
10560 | 232 mp_msg(MSGT_DEMUX, MSGL_DBG2, "STARTING FD: %d, RESULT: %d\n", fd, i); |
233 | |
234 return (i==0); | |
235 } | |
236 | |
237 | |
9610 | 238 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, |
239 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
|
240 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, |
18561 | 241 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int tmout); |
9610 | 242 |
243 | |
12309 | 244 int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone, |
9610 | 245 fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval, |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
246 fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate, |
18561 | 247 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) |
9610 | 248 { |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
249 int ris; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
250 |
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
|
251 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
|
252 |
18561 | 253 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); |
9610 | 254 |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
255 if(ris != 0) |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
256 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
|
257 |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
258 return (ris == 0); |
9610 | 259 } |
260 | |
261 | |
262 #ifndef HAVE_DVB_HEAD | |
263 static int SecGetStatus (int fd, struct secStatus *state) | |
264 { | |
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
|
265 if(ioctl(fd, SEC_GET_STATUS, state) < 0) |
9610 | 266 { |
267 mp_msg(MSGT_DEMUX, MSGL_ERR, ("SEC GET STATUS: ")); | |
268 return -1; | |
269 } | |
270 | |
271 switch (state->busMode) | |
272 { | |
273 case SEC_BUS_IDLE: | |
274 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: IDLE (%d)\n",state->busMode); | |
275 break; | |
276 case SEC_BUS_BUSY: | |
277 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: BUSY (%d)\n",state->busMode); | |
278 break; | |
279 case SEC_BUS_OFF: | |
280 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: OFF (%d)\n",state->busMode); | |
281 break; | |
282 case SEC_BUS_OVERLOAD: | |
283 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: OVERLOAD (%d)\n",state->busMode); | |
284 break; | |
285 default: | |
286 mp_msg(MSGT_DEMUX, MSGL_V, "SEC BUS MODE: unknown (%d)\n",state->busMode); | |
287 break; | |
288 } | |
289 | |
290 switch (state->selVolt) | |
291 { | |
292 case SEC_VOLTAGE_OFF: | |
293 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: OFF (%d)\n",state->selVolt); | |
294 break; | |
295 case SEC_VOLTAGE_LT: | |
296 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: LT (%d)\n",state->selVolt); | |
297 break; | |
298 case SEC_VOLTAGE_13: | |
299 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 13 (%d)\n",state->selVolt); | |
300 break; | |
301 case SEC_VOLTAGE_13_5: | |
302 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 13.5 (%d)\n",state->selVolt); | |
303 break; | |
304 case SEC_VOLTAGE_18: | |
305 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 18 (%d)\n",state->selVolt); | |
306 break; | |
307 case SEC_VOLTAGE_18_5: | |
308 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: 18.5 (%d)\n",state->selVolt); | |
309 break; | |
310 default: | |
311 mp_msg(MSGT_DEMUX, MSGL_V, "SEC VOLTAGE: unknown (%d)\n",state->selVolt); | |
312 break; | |
313 } | |
314 | |
21777 | 315 mp_msg(MSGT_DEMUX, MSGL_V, "SEC CONT TONE: %s\n", (state->contTone == SEC_TONE_ON ? "ON" : "OFF")); |
9610 | 316 return 0; |
317 } | |
318 | |
319 #endif | |
320 | |
321 static void print_status(fe_status_t festatus) | |
322 { | |
323 mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:"); | |
324 if (festatus & FE_HAS_SIGNAL) mp_msg(MSGT_DEMUX, MSGL_V," FE_HAS_SIGNAL"); | |
325 #ifdef HAVE_DVB_HEAD | |
326 if (festatus & FE_TIMEDOUT) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TIMEDOUT"); | |
327 #else | |
328 if (festatus & FE_HAS_POWER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_POWER"); | |
329 if (festatus & FE_SPECTRUM_INV) mp_msg(MSGT_DEMUX, MSGL_V, " FE_SPECTRUM_INV"); | |
330 if (festatus & FE_TUNER_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TUNER_HAS_LOCK"); | |
331 #endif | |
332 if (festatus & FE_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_LOCK"); | |
333 if (festatus & FE_HAS_CARRIER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_CARRIER"); | |
334 if (festatus & FE_HAS_VITERBI) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_VITERBI"); | |
335 if (festatus & FE_HAS_SYNC) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SYNC"); | |
336 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); | |
337 } | |
338 | |
339 | |
340 #ifdef HAVE_DVB_HEAD | |
21816 | 341 static int check_status(int fd_frontend, int tmout) |
9610 | 342 { |
343 int32_t strength; | |
344 fe_status_t festatus; | |
345 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
|
346 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
|
347 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
|
348 |
9610 | 349 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
|
350 pfd[0].events = POLLPRI; |
9610 | 351 |
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
|
352 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
|
353 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
|
354 while(!ok) |
9610 | 355 { |
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
|
356 festatus = 0; |
18561 | 357 if(poll(pfd,1,tmout*1000) > 0) |
9610 | 358 { |
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
|
359 if (pfd[0].revents & POLLPRI) |
9610 | 360 { |
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
|
361 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
|
362 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
|
363 locks++; |
9610 | 364 } |
365 } | |
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
|
366 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
|
367 tm2 = time((time_t*) NULL); |
18561 | 368 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
|
369 ok = 1; |
9610 | 370 } |
371 | |
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
|
372 if(festatus & FE_HAS_LOCK) |
9610 | 373 { |
374 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
|
375 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) |
9610 | 376 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); |
377 | |
378 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
|
379 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) |
9610 | 380 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); |
381 | |
382 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
|
383 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) |
9610 | 384 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); |
385 | |
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
|
386 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
|
387 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
|
388 mp_msg(MSGT_DEMUX, MSGL_V, "UNC: %d\n",strength); |
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
|
389 |
9610 | 390 print_status(festatus); |
391 } | |
392 else | |
393 { | |
18561 | 394 mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency, timeout: %d\n", tmout); |
9610 | 395 return -1; |
396 } | |
397 return 0; | |
398 } | |
399 | |
400 #else | |
401 | |
21816 | 402 static int check_status(int fd_frontend, int tmout) |
9610 | 403 { |
404 int i,res; | |
405 int32_t strength; | |
406 fe_status_t festatus; | |
407 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
|
408 |
9610 | 409 struct pollfd pfd[1]; |
410 | |
411 i = 0; res = -1; | |
412 while ((i < 3) && (res < 0)) | |
413 { | |
414 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
|
415 pfd[0].events = POLLIN | POLLPRI; |
9610 | 416 |
18561 | 417 if(poll(pfd,1,tmout*1000) > 0) |
9610 | 418 { |
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
|
419 if (pfd[0].revents & POLLPRI) |
9610 | 420 { |
421 mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); | |
422 if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) | |
423 { | |
424 mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_EVENT"); | |
425 return -1; | |
426 } | |
427 mp_msg(MSGT_DEMUX, MSGL_V, "Received "); | |
428 switch(event.type) | |
429 { | |
430 case FE_UNEXPECTED_EV: | |
431 mp_msg(MSGT_DEMUX, MSGL_V, "unexpected event\n"); | |
432 res = -1; | |
433 break; | |
434 | |
435 case FE_FAILURE_EV: | |
436 mp_msg(MSGT_DEMUX, MSGL_V, "failure event\n"); | |
437 res = -1; | |
438 break; | |
439 | |
440 case FE_COMPLETION_EV: | |
441 mp_msg(MSGT_DEMUX, MSGL_V, "completion event\n"); | |
442 res = 0; | |
443 break; | |
444 } | |
445 } | |
446 i++; | |
447 } | |
448 } | |
449 | |
450 if (res > 0) | |
451 switch (event.type) | |
452 { | |
453 case FE_UNEXPECTED_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_UNEXPECTED_EV\n"); | |
454 break; | |
455 case FE_COMPLETION_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_COMPLETION_EV\n"); | |
456 break; | |
457 case FE_FAILURE_EV: mp_msg(MSGT_DEMUX, MSGL_V, "FE_FAILURE_EV\n"); | |
458 break; | |
459 } | |
460 | |
461 if (event.type == FE_COMPLETION_EV) | |
462 { | |
463 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
|
464 if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) |
9610 | 465 mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); |
466 | |
467 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
|
468 if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) |
9610 | 469 mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); |
470 | |
471 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
|
472 if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) |
9610 | 473 mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); |
474 | |
475 festatus=0; | |
476 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
|
477 |
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
|
478 if(ioctl(fd_frontend,FE_READ_STATUS,&festatus) >= 0) |
21777 | 479 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
|
480 else |
21777 | 481 mp_msg(MSGT_DEMUX, MSGL_ERR, " ERROR, UNABLE TO READ_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
|
482 |
9610 | 483 mp_msg(MSGT_DEMUX, MSGL_V, "\n"); |
484 } | |
485 else | |
486 { | |
487 mp_msg(MSGT_DEMUX, MSGL_V, "Not able to lock to the signal on the given frequency\n"); | |
488 return -1; | |
489 } | |
490 return 0; | |
491 } | |
492 #endif | |
493 | |
494 #ifdef HAVE_DVB_HEAD | |
495 | |
21841
4cdc4b2cd3da
removed static declaration before non-instantiated struct; patch by cehoyos ag or at
nicodvb
parents:
21825
diff
changeset
|
496 struct diseqc_cmd { |
9610 | 497 struct dvb_diseqc_master_cmd cmd; |
498 uint32_t wait; | |
499 }; | |
500 | |
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
|
501 static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd, |
9610 | 502 fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b) |
503 { | |
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
|
504 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
|
505 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
|
506 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
|
507 return -1; |
9610 | 508 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
|
509 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
|
510 return -1; |
9610 | 511 usleep(cmd->wait * 1000); |
512 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
|
513 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
|
514 return -1; |
9610 | 515 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
|
516 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
|
517 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
|
518 |
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 return 0; |
9610 | 520 } |
521 | |
522 /* digital satellite equipment control, | |
523 * specification is available from http://www.eutelsat.com/ | |
524 */ | |
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
|
525 static int do_diseqc(int secfd, int sat_no, int polv, int hi_lo) |
9610 | 526 { |
527 struct diseqc_cmd cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 }; | |
528 | |
529 /* param: high nibble: reset bits, low nibble set bits, | |
530 * bits are: option, position, polarizaion, band | |
531 */ | |
532 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
|
533 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2)); |
9610 | 534 |
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
|
535 return diseqc_send_msg(secfd, polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18, |
9610 | 536 &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF, |
537 (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A); | |
538 } | |
539 | |
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 #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
|
541 |
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 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
|
543 { |
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 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
|
545 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
|
546 |
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.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
|
548 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
|
549 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
|
550 |
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.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
|
552 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
|
553 scmds.commands = &scmd; |
9610 | 554 |
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
|
555 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
|
556 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
|
557 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
|
558 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
|
559 (((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
|
560 (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
|
561 (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
|
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 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
|
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 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
|
566 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
|
567 } |
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
|
568 |
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
|
569 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
|
570 } |
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 #endif |
9610 | 572 |
573 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, | |
574 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
|
575 fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, |
18561 | 576 fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout) |
9610 | 577 { |
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
|
578 int res, hi_lo, dfd; |
9610 | 579 #ifdef HAVE_DVB_HEAD |
580 struct dvb_frontend_parameters feparams; | |
581 struct dvb_frontend_info fe_info; | |
582 #else | |
583 FrontendParameters feparams; | |
584 FrontendInfo fe_info; | |
21815
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
585 FrontendEvent event; |
9610 | 586 struct secStatus sec_state; |
587 #endif | |
588 | |
589 | |
10560 | 590 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 | 591 fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc); |
9610 | 592 |
593 | |
21824 | 594 memset(&feparams, 0, sizeof(feparams)); |
9610 | 595 if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)) |
596 { | |
21825 | 597 mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n"); |
598 return -1; | |
9610 | 599 } |
600 | |
601 | |
602 #ifdef HAVE_DVB_HEAD | |
10560 | 603 mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name); |
9610 | 604 #endif |
605 | |
606 switch(fe_info.type) | |
607 { | |
608 case FE_OFDM: | |
609 #ifdef HAVE_DVB_HEAD | |
610 if (freq < 1000000) freq*=1000UL; | |
611 feparams.frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
612 feparams.inversion=specInv; |
9610 | 613 feparams.u.ofdm.bandwidth=bandwidth; |
614 feparams.u.ofdm.code_rate_HP=HP_CodeRate; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
615 feparams.u.ofdm.code_rate_LP=LP_CodeRate; |
9610 | 616 feparams.u.ofdm.constellation=modulation; |
617 feparams.u.ofdm.transmission_mode=TransmissionMode; | |
618 feparams.u.ofdm.guard_interval=guardInterval; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
619 feparams.u.ofdm.hierarchy_information=hier; |
9610 | 620 #else |
621 if (freq < 1000000) freq*=1000UL; | |
622 feparams.Frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
623 feparams.Inversion=specInv; |
9610 | 624 feparams.u.ofdm.bandWidth=bandwidth; |
625 feparams.u.ofdm.HP_CodeRate=HP_CodeRate; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
626 feparams.u.ofdm.LP_CodeRate=LP_CodeRate; |
9610 | 627 feparams.u.ofdm.Constellation=modulation; |
628 feparams.u.ofdm.TransmissionMode=TransmissionMode; | |
629 feparams.u.ofdm.guardInterval=guardInterval; | |
13155
fd40ef23053b
added forgotten dvb-t params lp_coderate and hierarchy
nicodvb
parents:
12803
diff
changeset
|
630 feparams.u.ofdm.HierarchyInformation=hier; |
9610 | 631 #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
|
632 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth); |
9610 | 633 break; |
634 case FE_QPSK: | |
635 if (freq > 2200000) | |
636 { | |
637 // this must be an absolute frequency | |
638 if (freq < SLOF) | |
21825 | 639 { |
9610 | 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-LOF1); |
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-LOF1); |
9610 | 644 #endif |
21825 | 645 hi_lo = 0; |
9610 | 646 } |
21825 | 647 else |
648 { | |
9610 | 649 #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
|
650 freq = feparams.frequency=(freq-LOF2); |
9610 | 651 #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
|
652 freq = feparams.Frequency=(freq-LOF2); |
9610 | 653 #endif |
21825 | 654 hi_lo = 1; |
9610 | 655 } |
656 } | |
657 else | |
658 { | |
659 // this is an L-Band frequency | |
660 #ifdef HAVE_DVB_HEAD | |
661 feparams.frequency=freq; | |
662 #else | |
663 feparams.Frequency=freq; | |
664 #endif | |
665 } | |
666 | |
667 #ifdef HAVE_DVB_HEAD | |
668 feparams.inversion=specInv; | |
669 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
|
670 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
|
671 dfd = fd_frontend; |
9610 | 672 #else |
673 feparams.Inversion=specInv; | |
674 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
|
675 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
|
676 dfd = fd_sec; |
9610 | 677 #endif |
678 | |
21825 | 679 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 | 680 |
21825 | 681 if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0) |
682 mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n"); | |
683 else | |
684 { | |
685 mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n"); | |
686 return -1; | |
687 } | |
9610 | 688 break; |
689 case FE_QAM: | |
690 mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate); | |
691 #ifdef HAVE_DVB_HEAD | |
692 feparams.frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
693 feparams.inversion=specInv; |
9610 | 694 feparams.u.qam.symbol_rate = srate; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
695 feparams.u.qam.fec_inner = HP_CodeRate; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
696 feparams.u.qam.modulation = modulation; |
9610 | 697 #else |
698 feparams.Frequency=freq; | |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
699 feparams.Inversion=specInv; |
9610 | 700 feparams.u.qam.SymbolRate = srate; |
11872
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
701 feparams.u.qam.FEC_inner = HP_CodeRate; |
d158978a3d3c
Compliance with the DVB power management specification (doesn't close
attila
parents:
11352
diff
changeset
|
702 feparams.u.qam.QAM = modulation; |
9610 | 703 #endif |
704 break; | |
14382 | 705 #ifdef DVB_ATSC |
706 case FE_ATSC: | |
707 mp_msg(MSGT_DEMUX, MSGL_V, "tuning ATSC to %d, modulation=%d\n",freq,modulation); | |
708 feparams.frequency=freq; | |
709 feparams.u.vsb.modulation = modulation; | |
710 break; | |
711 #endif | |
9610 | 712 default: |
713 mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n"); | |
10603 | 714 return 0; |
9610 | 715 } |
716 usleep(100000); | |
717 | |
718 #ifndef HAVE_DVB_HEAD | |
719 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
|
720 while(1) |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
721 { |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
722 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
|
723 break; |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
724 } |
9610 | 725 #endif |
726 | |
21815
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
727 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
|
728 { |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
729 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
|
730 return -1; |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
731 } |
8b2d611f3ade
moved actual tuning code from check_status() to tune_it()
nicodvb
parents:
21777
diff
changeset
|
732 |
21816 | 733 return(check_status(fd_frontend, timeout)); |
9610 | 734 } |