annotate libmpdemux/dvb_tune.c @ 11155:4a21e1672c91

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