Statistics
| Branch: | Tag: | Revision:

dvbd / src / tune.c @ 904d298f

History | View | Annotate | Download (17.4 KB)

1 bfdb7446 jak
/* dvbtune - tune.c
2

3
   Copyright (C) Dave Chapman 2001,2002
4
  
5
   This program is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU General Public License
7
   as published by the Free Software Foundation; either version 2
8
   of the License, or (at your option) any later version.
9

10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14

15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, write to the Free Software
17
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
   Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19

20
*/
21
   
22
#include "config.h"
23
#include <stdio.h>
24
#include <stdlib.h>
25
#include <ctype.h>
26
#include <sys/ioctl.h>
27
#include <sys/poll.h>
28
#include <unistd.h>
29
#include <error.h>
30
#include <errno.h>
31
32
#ifdef NEWSTRUCT
33
#include <linux/dvb/dmx.h>
34
#include <linux/dvb/frontend.h>
35
#else
36
#include <ost/dmx.h>
37
#include <ost/sec.h>
38
#include <ost/frontend.h>
39
#endif
40
41
#include "tune.h"
42
43
#ifndef NEWSTRUCT
44
int OSTSelftest(int fd)
45
{
46
    int ans;
47
48
    if ( (ans = ioctl(fd,FE_SELFTEST,0) < 0)){
49
        perror("FE SELF TEST: ");
50
        return -1;
51
    }
52
53
    return 0;
54
}
55
56
int OSTSetPowerState(int fd, uint32_t state)
57
{
58
    int ans;
59
60
    if ( (ans = ioctl(fd,FE_SET_POWER_STATE,state) < 0)){
61
        perror("OST SET POWER STATE: ");
62
        return -1;
63
    }
64
65
    return 0;
66
}
67
68
int OSTGetPowerState(int fd, uint32_t *state)
69
{
70
    int ans;
71
72
    if ( (ans = ioctl(fd,FE_GET_POWER_STATE,state) < 0)){
73
        perror("OST GET POWER STATE: ");
74
        return -1;
75
    }
76
77
    switch(*state){
78
    case FE_POWER_ON:
79
        fprintf(stderr,"POWER ON (%d)\n",*state);
80
        break;
81
    case FE_POWER_STANDBY:
82
        fprintf(stderr,"POWER STANDBY (%d)\n",*state);
83
        break;
84
    case FE_POWER_SUSPEND:
85
        fprintf(stderr,"POWER SUSPEND (%d)\n",*state);
86
        break;
87
    case FE_POWER_OFF:
88
        fprintf(stderr,"POWER OFF (%d)\n",*state);
89
        break;
90
    default:
91
        fprintf(stderr,"unknown (%d)\n",*state);
92
        break;
93
    }
94
95
    return 0;
96
}
97
98
int SecGetStatus (int fd, struct secStatus *state)
99
{
100
    int ans;
101
102
    if ( (ans = ioctl(fd,SEC_GET_STATUS, state) < 0)){
103
        perror("SEC GET STATUS: ");
104
        return -1;
105
    }
106
107
    switch (state->busMode){
108
    case SEC_BUS_IDLE:
109
        fprintf(stderr,"SEC BUS MODE:  IDLE (%d)\n",state->busMode);
110
        break;
111
    case SEC_BUS_BUSY:
112
        fprintf(stderr,"SEC BUS MODE:  BUSY (%d)\n",state->busMode);
113
        break;
114
    case SEC_BUS_OFF:
115
        fprintf(stderr,"SEC BUS MODE:  OFF  (%d)\n",state->busMode);
116
        break;
117
    case SEC_BUS_OVERLOAD:
118
        fprintf(stderr,"SEC BUS MODE:  OVERLOAD (%d)\n",state->busMode);
119
        break;
120
    default:
121
        fprintf(stderr,"SEC BUS MODE:  unknown  (%d)\n",state->busMode);
122
        break;
123
    }
124
125
    switch (state->selVolt){
126
    case SEC_VOLTAGE_OFF:
127
        fprintf(stderr,"SEC VOLTAGE:  OFF (%d)\n",state->selVolt);
128
        break;
129
    case SEC_VOLTAGE_LT:
130
        fprintf(stderr,"SEC VOLTAGE:  LT  (%d)\n",state->selVolt);
131
        break;
132
    case SEC_VOLTAGE_13:
133
        fprintf(stderr,"SEC VOLTAGE:  13  (%d)\n",state->selVolt);
134
        break;
135
    case SEC_VOLTAGE_13_5:
136
        fprintf(stderr,"SEC VOLTAGE:  13.5 (%d)\n",state->selVolt);
137
        break;
138
    case SEC_VOLTAGE_18:
139
        fprintf(stderr,"SEC VOLTAGE:  18 (%d)\n",state->selVolt);
140
        break;
141
    case SEC_VOLTAGE_18_5:
142
        fprintf(stderr,"SEC VOLTAGE:  18.5 (%d)\n",state->selVolt);
143
        break;
144
    default:
145
        fprintf(stderr,"SEC VOLTAGE:  unknown (%d)\n",state->selVolt);
146
        break;
147
    }
148
149
    fprintf(stderr,"SEC CONT TONE: %s\n", (state->contTone == SEC_TONE_ON ? "ON" : "OFF"));
150
    return 0;
151
}
152
#endif
153
154
void print_status(FILE* fd,fe_status_t festatus) {
155
  fprintf(fd,"FE_STATUS:");
156
  if (festatus & FE_HAS_SIGNAL) fprintf(fd," FE_HAS_SIGNAL");
157
#ifdef NEWSTRUCT
158
  if (festatus & FE_TIMEDOUT) fprintf(fd," FE_TIMEDOUT");
159
#else
160
  if (festatus & FE_HAS_POWER) fprintf(fd," FE_HAS_POWER");
161
  if (festatus & FE_SPECTRUM_INV) fprintf(fd," FE_SPECTRUM_INV");
162
  if (festatus & FE_TUNER_HAS_LOCK) fprintf(fd," FE_TUNER_HAS_LOCK");
163
#endif
164
  if (festatus & FE_HAS_LOCK) fprintf(fd," FE_HAS_LOCK");
165
  if (festatus & FE_HAS_CARRIER) fprintf(fd," FE_HAS_CARRIER");
166
  if (festatus & FE_HAS_VITERBI) fprintf(fd," FE_HAS_VITERBI");
167
  if (festatus & FE_HAS_SYNC) fprintf(fd," FE_HAS_SYNC");
168
  fprintf(fd,"\n");
169
}
170
171
#ifdef NEWSTRUCT
172
struct diseqc_cmd {
173
   struct dvb_diseqc_master_cmd cmd;
174
   uint32_t wait;
175
};
176
177
void diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd,
178
                     fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
179
{
180
   ioctl(fd, FE_SET_TONE, SEC_TONE_OFF);
181
   ioctl(fd, FE_SET_VOLTAGE, v);
182
   usleep(15 * 1000);
183
   ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd);
184
   usleep(cmd->wait * 1000);
185
   usleep(15 * 1000);
186
   ioctl(fd, FE_DISEQC_SEND_BURST, b);
187
   usleep(15 * 1000);
188
   ioctl(fd, FE_SET_TONE, t);
189
}
190
191
192
193
194
/* digital satellite equipment control,
195
 * specification is available from http://www.eutelsat.com/ 
196
 */
197
static int do_diseqc(int secfd, int sat_no, int pol, int hi_lo)
198
{
199
   struct diseqc_cmd cmd =
200
       { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
201
202
   /* param: high nibble: reset bits, low nibble set bits,
203
    * bits are: option, position, polarizaion, band
204
    */
205
   cmd.cmd.msg[3] =
206
       0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (pol ? 0 : 2));
207
208
   diseqc_send_msg(secfd, pol,
209
                   &cmd, hi_lo,
210
                   (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
211
212
   return 1;
213
}
214
215
int check_status(int fd_frontend,struct dvb_frontend_parameters* feparams,int tone) {
216
  int32_t strength;
217
  fe_status_t festatus;
218
  struct dvb_frontend_event event;
219
  struct dvb_frontend_info fe_info;
220
  struct pollfd pfd[1];
221
  int status;
222
223
  if (ioctl(fd_frontend,FE_SET_FRONTEND,feparams) < 0) {
224
    perror("ERROR tuning channel\n");
225
    return -1;
226
  }
227
228
  pfd[0].fd = fd_frontend;
229
  pfd[0].events = POLLIN;
230
231
  event.status=0;
232
  while (((event.status & FE_TIMEDOUT)==0) && ((event.status & FE_HAS_LOCK)==0)) {
233
    fprintf(stderr,"polling....\n");
234
    if (poll(pfd,1,10000)){
235
      if (pfd[0].revents & POLLIN){
236
        fprintf(stderr,"Getting frontend event\n");
237
        if ((status = ioctl(fd_frontend, FE_GET_EVENT, &event)) < 0){
238
          if (errno != EOVERFLOW) {
239
            perror("FE_GET_EVENT");
240
            fprintf(stderr,"status = %d\n", status);
241
            fprintf(stderr,"errno = %d\n", errno);
242
            return -1;
243
          }
244
          else fprintf(stderr,"Overflow error, trying again (status = %d, errno = %d)", status, errno);
245
        }
246
      }
247
      print_status(stderr,event.status);
248
    }
249
  }
250
251
  if (event.status & FE_HAS_LOCK) {
252
      switch(fe_info.type) {
253
         case FE_OFDM:
254
           fprintf(stderr,"Event:  Frequency: %d\n",event.parameters.frequency);
255
           break;
256
         case FE_QPSK:
257
           fprintf(stderr,"Event:  Frequency: %d\n",(unsigned int)((event.parameters.frequency)+(tone==SEC_TONE_OFF ? LOF1 : LOF2)));
258
           fprintf(stderr,"        SymbolRate: %d\n",event.parameters.u.qpsk.symbol_rate);
259
           fprintf(stderr,"        FEC_inner:  %d\n",event.parameters.u.qpsk.fec_inner);
260
           fprintf(stderr,"\n");
261
           break;
262
         case FE_QAM:
263
           fprintf(stderr,"Event:  Frequency: %d\n",event.parameters.frequency);
264
           fprintf(stderr,"        SymbolRate: %d\n",event.parameters.u.qpsk.symbol_rate);
265
           fprintf(stderr,"        FEC_inner:  %d\n",event.parameters.u.qpsk.fec_inner);
266
           break;
267
         default:
268
           break;
269
      }
270
271
      strength=0;
272
      ioctl(fd_frontend,FE_READ_BER,&strength);
273
      fprintf(stderr,"Bit error rate: %d\n",strength);
274
275
      strength=0;
276
      ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength);
277
      fprintf(stderr,"Signal strength: %d\n",strength);
278
279
      strength=0;
280
      ioctl(fd_frontend,FE_READ_SNR,&strength);
281
      fprintf(stderr,"SNR: %d\n",strength);
282
283
      festatus=0;
284
      ioctl(fd_frontend,FE_READ_STATUS,&festatus);
285
      print_status(stderr,festatus);
286
    } else {
287
    fprintf(stderr,"Not able to lock to the signal on the given frequency\n");
288
    return -1;
289
  }
290
  return 0;
291
}
292
#else
293
int check_status(int fd_frontend,FrontendParameters* feparams,int tone) {
294
  int i,res;
295
  int32_t strength;
296
  fe_status_t festatus;
297
  FrontendEvent event;
298
  FrontendInfo fe_info;
299
  struct pollfd pfd[1];
300
301
  i = 0; res = -1;
302
  while ((i < 3) && (res < 0)) {
303
    if (ioctl(fd_frontend,FE_SET_FRONTEND,feparams) < 0) {
304
      perror("ERROR tuning channel\n");
305
      return -1;
306
    }
307
308
    pfd[0].fd = fd_frontend;
309
    pfd[0].events = POLLIN;
310
311
    if (poll(pfd,1,10000)){
312
      if (pfd[0].revents & POLLIN){
313
        fprintf(stderr,"Getting frontend event\n");
314
        if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) {
315
          perror("FE_GET_EVENT");
316
          return -1;
317
        }
318
        fprintf(stderr,"Received ");
319
        switch(event.type){
320
          case FE_UNEXPECTED_EV:
321
            fprintf(stderr,"unexpected event\n");
322
            res = -1;
323
            break;
324
          case FE_FAILURE_EV:
325
            fprintf(stderr,"failure event\n");
326
            res = -1;
327
            break;
328
          case FE_COMPLETION_EV:
329
            fprintf(stderr,"completion event\n");
330
            res = 0;
331
          break;
332
        }
333
      }
334
      i++;
335
    }
336
  }
337
338
  if (res > 0)
339
    switch (event.type) {
340
       case FE_UNEXPECTED_EV: fprintf(stderr,"FE_UNEXPECTED_EV\n");
341
                                break;
342
       case FE_COMPLETION_EV: fprintf(stderr,"FE_COMPLETION_EV\n");
343
                                break;
344
       case FE_FAILURE_EV: fprintf(stderr,"FE_FAILURE_EV\n");
345
                                break;
346
    }
347
348
    if (event.type == FE_COMPLETION_EV) {
349
      switch(fe_info.type) {
350
         case FE_OFDM:
351
           fprintf(stderr,"Event:  Frequency: %d\n",event.u.completionEvent.Frequency);
352
           break;
353
         case FE_QPSK:
354
           fprintf(stderr,"Event:  Frequency: %d\n",(unsigned int)((event.u.completionEvent.Frequency)+(tone==SEC_TONE_OFF ? LOF1 : LOF2)));
355
           fprintf(stderr,"        SymbolRate: %d\n",event.u.completionEvent.u.qpsk.SymbolRate);
356
           fprintf(stderr,"        FEC_inner:  %d\n",event.u.completionEvent.u.qpsk.FEC_inner);
357
           fprintf(stderr,"\n");
358
           break;
359
         case FE_QAM:
360
           fprintf(stderr,"Event:  Frequency: %d\n",event.u.completionEvent.Frequency);
361
           fprintf(stderr,"        SymbolRate: %d\n",event.u.completionEvent.u.qpsk.SymbolRate);
362
           fprintf(stderr,"        FEC_inner:  %d\n",event.u.completionEvent.u.qpsk.FEC_inner);
363
           break;
364
         default:
365
           break;
366
      }
367
368
      strength=0;
369
      ioctl(fd_frontend,FE_READ_BER,&strength);
370
      fprintf(stderr,"Bit error rate: %d\n",strength);
371
372
      strength=0;
373
      ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength);
374
      fprintf(stderr,"Signal strength: %d\n",strength);
375
376
      strength=0;
377
      ioctl(fd_frontend,FE_READ_SNR,&strength);
378
      fprintf(stderr,"SNR: %d\n",strength);
379
380
      festatus=0;
381
      ioctl(fd_frontend,FE_READ_STATUS,&festatus);
382
383
      fprintf(stderr,"FE_STATUS:");
384
      if (festatus & FE_HAS_POWER) fprintf(stderr," FE_HAS_POWER");
385
      if (festatus & FE_HAS_SIGNAL) fprintf(stderr," FE_HAS_SIGNAL");
386
      if (festatus & FE_SPECTRUM_INV) fprintf(stderr," FE_SPECTRUM_INV");
387
      if (festatus & FE_HAS_LOCK) fprintf(stderr," FE_HAS_LOCK");
388
      if (festatus & FE_HAS_CARRIER) fprintf(stderr," FE_HAS_CARRIER");
389
      if (festatus & FE_HAS_VITERBI) fprintf(stderr," FE_HAS_VITERBI");
390
      if (festatus & FE_HAS_SYNC) fprintf(stderr," FE_HAS_SYNC");
391
      if (festatus & FE_TUNER_HAS_LOCK) fprintf(stderr," FE_TUNER_HAS_LOCK");
392
      fprintf(stderr,"\n");
393
    } else {
394
    fprintf(stderr,"Not able to lock to the signal on the given frequency\n");
395
    return -1;
396
  }
397
  return 0;
398
}
399
#endif
400
401
int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone, fe_spectral_inversion_t specInv, unsigned int diseqc,fe_modulation_t modulation,fe_code_rate_t HP_CodeRate,fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth) {
402
  int res;
403
#ifdef NEWSTRUCT
404
  struct dvb_frontend_parameters feparams;
405
  struct dvb_frontend_info fe_info;
406
  fe_sec_voltage_t voltage;
407
#else
408
  FrontendParameters feparams;
409
  FrontendInfo fe_info;
410
  secVoltage voltage;
411
  struct secStatus sec_state;
412
#endif
413
414
  /* discard stale frontend events */
415
  /*
416
  pfd[0].fd = fd_frontend;
417
  pfd[0].events = POLLIN;
418

419
  if (poll(pfd,1,500)){
420
    if (pfd[0].revents & POLLIN){
421
      while (1) {
422
        if (ioctl (fd_frontend, FE_GET_EVENT, &event) == -1) { break; }
423
      }
424
    }
425
  }
426
  */
427
  if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)){
428
     perror("FE_GET_INFO: ");
429
     return -1;
430
  }
431
  
432
//  OSTSelftest(fd_frontend);
433
//  OSTSetPowerState(fd_frontend, FE_POWER_ON);
434
//  OSTGetPowerState(fd_frontend, &festatus);
435
436
#ifdef NEWSTRUCT
437
  fprintf(stderr,"Using DVB card \"%s\"\n",fe_info.name);
438
#endif
439
440
  switch(fe_info.type) {
441
    case FE_OFDM:
442
#ifdef NEWSTRUCT
443
      if (freq < 1000000) freq*=1000UL;
444
      feparams.frequency=freq;
445
      feparams.inversion=INVERSION_OFF;
446
      feparams.u.ofdm.bandwidth=bandwidth;
447
      feparams.u.ofdm.code_rate_HP=HP_CodeRate;
448
      feparams.u.ofdm.code_rate_LP=LP_CODERATE_DEFAULT;
449
      feparams.u.ofdm.constellation=modulation;
450
      feparams.u.ofdm.transmission_mode=TransmissionMode;
451
      feparams.u.ofdm.guard_interval=guardInterval;
452
      feparams.u.ofdm.hierarchy_information=HIERARCHY_DEFAULT;
453
#else
454
      if (freq < 1000000) freq*=1000UL;
455
      feparams.Frequency=freq;
456
      feparams.Inversion=INVERSION_OFF;
457
      feparams.u.ofdm.bandWidth=bandwidth;
458
      feparams.u.ofdm.HP_CodeRate=HP_CodeRate;
459
      feparams.u.ofdm.LP_CodeRate=LP_CODERATE_DEFAULT;
460
      feparams.u.ofdm.Constellation=modulation;
461
      feparams.u.ofdm.TransmissionMode=TransmissionMode;
462
      feparams.u.ofdm.guardInterval=guardInterval;
463
      feparams.u.ofdm.HierarchyInformation=HIERARCHY_DEFAULT;
464
#endif
465
      fprintf(stderr,"tuning DVB-T (%s) to %d Hz\n",DVB_T_LOCATION,freq);
466
      break;
467
    case FE_QPSK:
468
#ifdef NEWSTRUCT
469
      fprintf(stderr,"tuning DVB-S to L-Band:%d, Pol:%c Srate=%d, 22kHz=%s\n",feparams.frequency,pol,srate,tone == SEC_TONE_ON ? "on" : "off");
470
#else
471
      fprintf(stderr,"tuning DVB-S to L-Band:%d, Pol:%c Srate=%d, 22kHz=%s\n",feparams.Frequency,pol,srate,tone == SEC_TONE_ON ? "on" : "off");
472
#endif
473
      if ((pol=='h') || (pol=='H')) {
474
        voltage = SEC_VOLTAGE_18;
475
      } else {
476
        voltage = SEC_VOLTAGE_13;
477
      }
478
#ifdef NEWSTRUCT
479
if (diseqc==0) if (ioctl(fd_frontend,FE_SET_VOLTAGE,voltage) < 0) {
480
#else
481
      if (ioctl(fd_sec,SEC_SET_VOLTAGE,voltage) < 0) {
482
#endif
483
         perror("ERROR setting voltage\n");
484
      }
485
486
      if (freq > 2200000) {
487
        // this must be an absolute frequency
488
        if (freq < SLOF) {
489
#ifdef NEWSTRUCT
490
          feparams.frequency=(freq-LOF1);
491
#else
492
          feparams.Frequency=(freq-LOF1);
493
#endif
494
          if (tone < 0) tone = SEC_TONE_OFF;
495
        } else {
496
#ifdef NEWSTRUCT
497
          feparams.frequency=(freq-LOF2);
498
#else
499
          feparams.Frequency=(freq-LOF2);
500
#endif
501
          if (tone < 0) tone = SEC_TONE_ON;
502
        }
503
      } else {
504
        // this is an L-Band frequency
505
#ifdef NEWSTRUCT
506
       feparams.frequency=freq;
507
#else
508
       feparams.Frequency=freq;
509
#endif
510
      }
511
512
#ifdef NEWSTRUCT
513
      feparams.inversion=specInv;
514
      feparams.u.qpsk.symbol_rate=srate;
515
      feparams.u.qpsk.fec_inner=FEC_AUTO;
516
#else
517
      feparams.Inversion=specInv;
518
      feparams.u.qpsk.SymbolRate=srate;
519
      feparams.u.qpsk.FEC_inner=FEC_AUTO;
520
#endif
521
522
#ifdef NEWSTRUCT
523
      if (diseqc==0) {
524
      if (ioctl(fd_frontend,FE_SET_TONE,tone) < 0) {
525
               perror("ERROR setting tone\n");
526
      }
527
      }
528
#else
529
      if (ioctl(fd_sec,SEC_SET_TONE,tone) < 0) {
530
         perror("ERROR setting tone\n");
531
      }
532
#endif
533
534
#ifdef NEWSTRUCT
535
              if (diseqc > 0) {
536
                do_diseqc(fd_frontend, diseqc-1,voltage,tone);
537
                sleep(1);
538
              }
539
#else
540
      if (diseqc > 0) {
541
        struct secCommand scmd;
542
        struct secCmdSequence scmds;
543
544
        scmds.continuousTone = tone;
545
        scmds.voltage = voltage;
546
        /*
547
        scmds.miniCommand = toneBurst ? SEC_MINI_B : SEC_MINI_A;
548
        */
549
        scmds.miniCommand = SEC_MINI_NONE;
550
551
        scmd.type = 0;
552
        scmds.numCommands = 1;
553
        scmds.commands = &scmd;
554
555
        scmd.u.diseqc.addr = 0x10;
556
        scmd.u.diseqc.cmd = 0x38;
557
        scmd.u.diseqc.numParams = 1;
558
        scmd.u.diseqc.params[0] = 0xf0 | 
559
                                  (((diseqc - 1) << 2) & 0x0c) |
560
                                  (voltage==SEC_VOLTAGE_18 ? 0x02 : 0) |
561
                                  (tone==SEC_TONE_ON ? 0x01 : 0);
562
563
        if (ioctl(fd_sec,SEC_SEND_SEQUENCE,&scmds) < 0) {
564
          perror("Error sending DisEqC");
565
          return -1;
566
        }
567
      }
568
#endif
569
      break;
570
    case FE_QAM:
571
      fprintf(stderr,"tuning DVB-C to %d, srate=%d\n",freq,srate);
572
#ifdef NEWSTRUCT
573 de53ce58 jak
      feparams.frequency = freq;
574
      feparams.inversion = specInv;
575 bfdb7446 jak
      feparams.u.qam.symbol_rate = srate;
576 de53ce58 jak
      feparams.u.qam.fec_inner = HP_CodeRate;
577
      feparams.u.qam.modulation = modulation;
578 bfdb7446 jak
#else
579 de53ce58 jak
      feparams.Frequency = freq;
580
      feparams.Inversion = specInv;
581 bfdb7446 jak
      feparams.u.qam.SymbolRate = srate;
582 de53ce58 jak
      feparams.u.qam.FEC_inner = HP_CodeRate;
583
      feparams.u.qam.QAM = modulation;
584 bfdb7446 jak
#endif
585
      break;
586
    default:
587
      fprintf(stderr,"Unknown FE type. Aborting\n");
588
      exit(-1);
589
  }
590
  usleep(100000);
591
592
#ifndef NEWSTRUCT   
593
  if (fd_sec) SecGetStatus(fd_sec, &sec_state);
594
#endif
595
596
  return(check_status(fd_frontend,&feparams,tone));
597
}