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