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