1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
|
/*
Driver for VES1893 and VES1993 QPSK Frontends
Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
Copyright (C) 2001 Ronny Strutz <3des@elitedvb.de>
Copyright (C) 2002 Dennis Noermann <dennis.noermann@noernet.de>
Copyright (C) 2002-2003 Andreas Oberritter <obi@linuxtv.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/slab.h>
#include "dvb_frontend.h"
#include "dvb_functions.h"
/* fixme: add this to i2c-id.h */
#define I2C_DRIVERID_VES1X93 I2C_DRIVERID_EXP1
static int debug = 0;
#define dprintk if (debug) printk
static int board_type = 0;
#define BOARD_SIEMENS_PCI 0
#define BOARD_NOKIA_DBOX2 1
#define BOARD_SAGEM_DBOX2 2
static int demod_type = 0;
#define DEMOD_VES1893 0
#define DEMOD_VES1993 1
static struct dvb_frontend_info ves1x93_info = {
.name = "VES1x93",
.type = FE_QPSK,
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 250, /* kHz for QPSK frontends */
.frequency_tolerance = 29500,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
/* .symbol_rate_tolerance = ???,*/
.notifier_delay = 50, /* 1/20 s */
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK
};
/**
* nokia dbox2 (ves1893) and sagem dbox2 (ves1993)
* need bit AGCR[PWMS] set to 1
*/
static u8 init_1893_tab [] = {
0x01, 0xa4, 0x35, 0x80, 0x2a, 0x0b, 0x55, 0xc4,
0x09, 0x69, 0x00, 0x86, 0x4c, 0x28, 0x7f, 0x00,
0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x21, 0xb0, 0x14, 0x00, 0xdc, 0x00,
0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x55, 0x00, 0x00, 0x7f, 0x00
};
static u8 init_1993_tab [] = {
0x00, 0x9c, 0x35, 0x80, 0x6a, 0x09, 0x72, 0x8c,
0x09, 0x6b, 0x00, 0x00, 0x4c, 0x08, 0x00, 0x00,
0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x40, 0x21, 0xb0, 0x00, 0x00, 0x00, 0x10,
0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x55, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x0e, 0x80, 0x00
};
static u8 * init_1x93_tab;
static u8 init_1893_wtab[] =
{
1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
0,1,0,0,0,0,0,0, 1,0,1,1,0,0,0,1,
1,1,1,0,0,0,0,0, 0,0,1,1,0,0,0,0,
1,1,1,0,1,1
};
static u8 init_1993_wtab[] =
{
1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
0,1,0,0,0,0,0,0, 1,1,1,1,0,0,0,1,
1,1,1,0,0,0,0,0, 0,0,1,1,0,0,0,0,
1,1,1,0,1,1,1,1, 1,1,1,1,1
};
struct ves1x93_state {
fe_spectral_inversion_t inversion;
struct i2c_adapter *i2c;
};
static int ves1x93_writereg (struct i2c_adapter *i2c, u8 reg, u8 data)
{
u8 buf [] = { 0x00, reg, data };
struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 3 };
int err;
if ((err = i2c_transfer (i2c, &msg, 1)) != 1) {
dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
return -EREMOTEIO;
}
return 0;
}
static u8 ves1x93_readreg (struct i2c_adapter *i2c, u8 reg)
{
int ret;
u8 b0 [] = { 0x00, reg };
u8 b1 [] = { 0 };
struct i2c_msg msg [] = { { .addr = 0x08, .flags = 0, .buf = b0, .len = 2 },
{ .addr = 0x08, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
ret = i2c_transfer (i2c, msg, 2);
if (ret != 2)
dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
return b1[0];
}
static int tuner_write (struct i2c_adapter *i2c, u8 *data, u8 len)
{
int ret;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = len };
ves1x93_writereg(i2c, 0x00, 0x11);
ret = i2c_transfer (i2c, &msg, 1);
ves1x93_writereg(i2c, 0x00, 0x01);
if (ret != 1)
printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
return (ret != 1) ? -1 : 0;
}
/**
* set up the downconverter frequency divisor for a
* reference clock comparision frequency of 125 kHz.
*/
static int sp5659_set_tv_freq (struct i2c_adapter *i2c, u32 freq, u8 pwr)
{
u32 div = (freq + 479500) / 125;
u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x95, (pwr << 5) | 0x30 };
return tuner_write (i2c, buf, sizeof(buf));
}
static int tsa5059_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
{
int ret;
u8 buf [2];
freq /= 1000;
buf[0] = (freq >> 8) & 0x7F;
buf[1] = freq & 0xFF;
ret = tuner_write(i2c, buf, sizeof(buf));
return ret;
}
static int tuner_set_tv_freq (struct i2c_adapter *i2c, u32 freq, u8 pwr)
{
if ((demod_type == DEMOD_VES1893) && (board_type == BOARD_SIEMENS_PCI))
return sp5659_set_tv_freq (i2c, freq, pwr);
else if (demod_type == DEMOD_VES1993)
return tsa5059_set_tv_freq (i2c, freq);
return -EINVAL;
}
static int ves1x93_init (struct i2c_adapter *i2c)
{
int i;
int size;
u8 *init_1x93_wtab;
dprintk("%s: init chip\n", __FUNCTION__);
switch (demod_type) {
case DEMOD_VES1893:
init_1x93_tab = init_1893_tab;
init_1x93_wtab = init_1893_wtab;
size = sizeof(init_1893_tab);
if (board_type == BOARD_NOKIA_DBOX2)
init_1x93_tab[0x05] |= 0x20; /* invert PWM */
break;
case DEMOD_VES1993:
init_1x93_tab = init_1993_tab;
init_1x93_wtab = init_1993_wtab;
size = sizeof(init_1993_tab);
if (board_type == BOARD_SAGEM_DBOX2)
init_1x93_tab[0x05] |= 0x20; /* invert PWM */
break;
default:
return -EINVAL;
}
for (i = 0; i < size; i++)
if (init_1x93_wtab[i])
ves1x93_writereg (i2c, i, init_1x93_tab[i]);
if (demod_type == DEMOD_VES1993) {
if (board_type == BOARD_NOKIA_DBOX2)
tuner_write(i2c, "\x06\x5c\x83\x60", 4);
else if (board_type == BOARD_SAGEM_DBOX2)
tuner_write(i2c, "\x25\x70\x92\x40", 4);
}
return 0;
}
static int ves1x93_clr_bit (struct i2c_adapter *i2c)
{
ves1x93_writereg (i2c, 0, init_1x93_tab[0] & 0xfe);
ves1x93_writereg (i2c, 0, init_1x93_tab[0]);
dvb_delay(5);
return 0;
}
static int ves1x93_init_aquire (struct i2c_adapter *i2c)
{
ves1x93_writereg (i2c, 3, 0x00);
ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
dvb_delay(5);
return 0;
}
static int ves1x93_set_inversion (struct i2c_adapter *i2c, fe_spectral_inversion_t inversion)
{
u8 val;
/*
* inversion on/off are interchanged because i and q seem to
* be swapped on the hardware
*/
switch (inversion) {
case INVERSION_OFF:
val = 0xc0;
break;
case INVERSION_ON:
val = 0x80;
break;
case INVERSION_AUTO:
val = 0x00;
break;
default:
return -EINVAL;
}
return ves1x93_writereg (i2c, 0x0c, (init_1x93_tab[0x0c] & 0x3f) | val);
}
static int ves1x93_set_fec (struct i2c_adapter *i2c, fe_code_rate_t fec)
{
if (fec == FEC_AUTO)
return ves1x93_writereg (i2c, 0x0d, 0x08);
else if (fec < FEC_1_2 || fec > FEC_8_9)
return -EINVAL;
else
return ves1x93_writereg (i2c, 0x0d, fec - FEC_1_2);
}
static fe_code_rate_t ves1x93_get_fec (struct i2c_adapter *i2c)
{
return FEC_1_2 + ((ves1x93_readreg (i2c, 0x0d) >> 4) & 0x7);
}
static int ves1x93_set_symbolrate (struct i2c_adapter *i2c, u32 srate)
{
u32 BDR;
u32 ratio;
u8 ADCONF, FCONF, FNR;
u32 BDRI;
u32 tmp;
u32 XIN, FIN;
dprintk("%s: srate == %d\n", __FUNCTION__, (unsigned int) srate);
switch (board_type) {
case BOARD_SIEMENS_PCI:
XIN = 90100000UL;
break;
case BOARD_NOKIA_DBOX2:
if (demod_type == DEMOD_VES1893)
XIN = 91000000UL;
else if (demod_type == DEMOD_VES1993)
XIN = 96000000UL;
else
return -EINVAL;
break;
case BOARD_SAGEM_DBOX2:
XIN = 92160000UL;
break;
default:
return -EINVAL;
}
if (srate > XIN/2)
srate = XIN/2;
if (srate < 500000)
srate = 500000;
#define MUL (1UL<<26)
FIN = (XIN + 6000) >> 4;
tmp = srate << 6;
ratio = tmp / FIN;
tmp = (tmp % FIN) << 8;
ratio = (ratio << 8) + tmp / FIN;
tmp = (tmp % FIN) << 8;
ratio = (ratio << 8) + tmp / FIN;
FNR = 0xff;
if (ratio < MUL/3) FNR = 0;
if (ratio < (MUL*11)/50) FNR = 1;
if (ratio < MUL/6) FNR = 2;
if (ratio < MUL/9) FNR = 3;
if (ratio < MUL/12) FNR = 4;
if (ratio < (MUL*11)/200) FNR = 5;
if (ratio < MUL/24) FNR = 6;
if (ratio < (MUL*27)/1000) FNR = 7;
if (ratio < MUL/48) FNR = 8;
if (ratio < (MUL*137)/10000) FNR = 9;
if (FNR == 0xff) {
ADCONF = 0x89;
FCONF = 0x80;
FNR = 0;
} else {
ADCONF = 0x81;
FCONF = 0x88 | (FNR >> 1) | ((FNR & 0x01) << 5);
/*FCONF = 0x80 | ((FNR & 0x01) << 5) | (((FNR > 1) & 0x03) << 3) | ((FNR >> 1) & 0x07);*/
}
BDR = (( (ratio << (FNR >> 1)) >> 4) + 1) >> 1;
BDRI = ( ((FIN << 8) / ((srate << (FNR >> 1)) >> 2)) + 1) >> 1;
dprintk("FNR= %d\n", FNR);
dprintk("ratio= %08x\n", (unsigned int) ratio);
dprintk("BDR= %08x\n", (unsigned int) BDR);
dprintk("BDRI= %02x\n", (unsigned int) BDRI);
if (BDRI > 0xff)
BDRI = 0xff;
ves1x93_writereg (i2c, 0x06, 0xff & BDR);
ves1x93_writereg (i2c, 0x07, 0xff & (BDR >> 8));
ves1x93_writereg (i2c, 0x08, 0x0f & (BDR >> 16));
ves1x93_writereg (i2c, 0x09, BDRI);
ves1x93_writereg (i2c, 0x20, ADCONF);
ves1x93_writereg (i2c, 0x21, FCONF);
if (srate < 6000000)
ves1x93_writereg (i2c, 0x05, init_1x93_tab[0x05] | 0x80);
else
ves1x93_writereg (i2c, 0x05, init_1x93_tab[0x05] & 0x7f);
/* ves1993 hates this, will lose lock */
if (demod_type != DEMOD_VES1993)
ves1x93_clr_bit (i2c);
return 0;
}
static int ves1x93_afc (struct i2c_adapter *i2c, u32 freq, u32 srate)
{
int afc;
afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
afc = (afc * (int)(srate/1000/8))/16;
if (afc) {
freq -= afc;
tuner_set_tv_freq (i2c, freq, 0);
ves1x93_init_aquire (i2c);
}
return 0;
}
static int ves1x93_set_voltage (struct i2c_adapter *i2c, fe_sec_voltage_t voltage)
{
switch (voltage) {
case SEC_VOLTAGE_13:
return ves1x93_writereg (i2c, 0x1f, 0x20);
case SEC_VOLTAGE_18:
return ves1x93_writereg (i2c, 0x1f, 0x30);
case SEC_VOLTAGE_OFF:
return ves1x93_writereg (i2c, 0x1f, 0x00);
default:
return -EINVAL;
}
}
static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct ves1x93_state *state = (struct ves1x93_state *) fe->data;
struct i2c_adapter *i2c = state->i2c;
switch (cmd) {
case FE_GET_INFO:
memcpy (arg, &ves1x93_info, sizeof(struct dvb_frontend_info));
break;
case FE_READ_STATUS:
{
fe_status_t *status = arg;
u8 sync = ves1x93_readreg (i2c, 0x0e);
*status = 0;
if (sync & 1)
*status |= FE_HAS_SIGNAL;
if (sync & 2)
*status |= FE_HAS_CARRIER;
if (sync & 4)
*status |= FE_HAS_VITERBI;
if (sync & 8)
*status |= FE_HAS_SYNC;
if ((sync & 0x1f) == 0x1f)
*status |= FE_HAS_LOCK;
break;
}
case FE_READ_BER:
{
u32 *ber = (u32 *) arg;
*ber = ves1x93_readreg (i2c, 0x15);
*ber |= (ves1x93_readreg (i2c, 0x16) << 8);
*ber |= ((ves1x93_readreg (i2c, 0x17) & 0x0F) << 16);
*ber *= 10;
break;
}
case FE_READ_SIGNAL_STRENGTH:
{
u8 signal = ~ves1x93_readreg (i2c, 0x0b);
*((u16*) arg) = (signal << 8) | signal;
break;
}
case FE_READ_SNR:
{
u8 snr = ~ves1x93_readreg (i2c, 0x1c);
*(u16*) arg = (snr << 8) | snr;
break;
}
case FE_READ_UNCORRECTED_BLOCKS:
{
*(u32*) arg = ves1x93_readreg (i2c, 0x18) & 0x7f;
if (*(u32*) arg == 0x7f)
*(u32*) arg = 0xffffffff; /* counter overflow... */
ves1x93_writereg (i2c, 0x18, 0x00); /* reset the counter */
ves1x93_writereg (i2c, 0x18, 0x80); /* dto. */
break;
}
case FE_SET_FRONTEND:
{
struct dvb_frontend_parameters *p = arg;
tuner_set_tv_freq (i2c, p->frequency, 0);
ves1x93_set_inversion (i2c, p->inversion);
ves1x93_set_fec (i2c, p->u.qpsk.fec_inner);
ves1x93_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
ves1x93_afc (i2c, p->frequency, p->u.qpsk.symbol_rate);
state->inversion = p->inversion;
break;
}
case FE_GET_FRONTEND:
{
struct dvb_frontend_parameters *p = arg;
int afc;
afc = ((int)((char)(ves1x93_readreg (i2c, 0x0a) << 1)))/2;
afc = (afc * (int)(p->u.qpsk.symbol_rate/1000/8))/16;
p->frequency -= afc;
/*
* inversion indicator is only valid
* if auto inversion was used
*/
if (state->inversion == INVERSION_AUTO)
p->inversion = (ves1x93_readreg (i2c, 0x0f) & 2) ?
INVERSION_OFF : INVERSION_ON;
p->u.qpsk.fec_inner = ves1x93_get_fec (i2c);
/* XXX FIXME: timing offset !! */
break;
}
case FE_SLEEP:
if (board_type == BOARD_SIEMENS_PCI)
ves1x93_writereg (i2c, 0x1f, 0x00); /* LNB power off */
return ves1x93_writereg (i2c, 0x00, 0x08);
case FE_INIT:
return ves1x93_init (i2c);
case FE_SET_TONE:
return -EOPNOTSUPP; /* the ves1893 can generate the 22k */
/* let's implement this when we have */
/* a box that uses the 22K_0 pin... */
case FE_SET_VOLTAGE:
return ves1x93_set_voltage (i2c, (fe_sec_voltage_t) arg);
default:
return -EOPNOTSUPP;
};
return 0;
}
static struct i2c_client client_template;
static int attach_adapter(struct i2c_adapter *adapter)
{
struct i2c_client *client;
struct ves1x93_state* state;
u8 identity = ves1x93_readreg(adapter, 0x1e);
switch (identity) {
case 0xdc: /* VES1893A rev1 */
printk("ves1x93: Detected ves1893a rev1\n");
demod_type = DEMOD_VES1893;
ves1x93_info.name[4] = '8';
break;
case 0xdd: /* VES1893A rev2 */
printk("ves1x93: Detected ves1893a rev2\n");
demod_type = DEMOD_VES1893;
ves1x93_info.name[4] = '8';
break;
case 0xde: /* VES1993 */
printk("ves1x93: Detected ves1993\n");
demod_type = DEMOD_VES1993;
ves1x93_info.name[4] = '9';
break;
default:
dprintk("VES1x93 not found (identity %02x)\n", identity);
return -ENODEV;
}
if ((state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL)) == NULL) {
return -ENOMEM;
}
if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
kfree(state);
return -ENOMEM;
}
state->inversion = INVERSION_OFF;
state->i2c = adapter;
memcpy(client, &client_template, sizeof(struct i2c_client));
client->adapter = adapter;
client->addr = (0x08>>1);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
client->data = state;
#else
i2c_set_clientdata(client, (void*)state);
#endif
if (0 != i2c_attach_client(client)) {
kfree(client);
kfree(state);
return -EFAULT;
}
return 0;
}
static int detach_client(struct i2c_client *client)
{
i2c_detach_client(client);
kfree(client);
return 0;
}
static int command (struct i2c_client *client, unsigned int cmd, void *arg)
{
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
struct stv0299_data *data = (struct stv0299_data*)client->data;
#else
struct stv0299_data *data = (struct stv0299_data*)i2c_get_clientdata(client);
#endif
dprintk ("%s\n", __FUNCTION__);
switch (cmd) {
case FE_REGISTER: {
struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg;
return dvb_register_frontend_new (ves1x93_ioctl, dvb_adapter, (void*) data, &ves1x93_info);
}
case FE_UNREGISTER: {
struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg;
dvb_unregister_frontend_new (ves1x93_ioctl, dvb_adapter);
break;
}
default:
return -EOPNOTSUPP;
}
return 0;
}
static struct i2c_driver driver = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
.owner = THIS_MODULE,
#endif
.name = "ves1x93",
.id = I2C_DRIVERID_VES1X93,
.flags = I2C_DF_NOTIFY,
.attach_adapter = attach_adapter,
.detach_client = detach_client,
.command = command,
};
static struct i2c_client client_template = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
I2C_DEVNAME("stv0299"),
#else
.name = "ves1x93",
#endif
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static int __init init_ves1x93 (void)
{
switch (board_type) {
case BOARD_NOKIA_DBOX2:
dprintk("%s: NOKIA_DBOX2\n", __FILE__);
break;
case BOARD_SAGEM_DBOX2:
dprintk("%s: SAGEM_DBOX2\n", __FILE__);
break;
case BOARD_SIEMENS_PCI:
dprintk("%s: SIEMENS_PCI\n", __FILE__);
break;
default:
return -EIO;
}
return i2c_add_driver(&driver);
}
static void __exit exit_ves1x93 (void)
{
if (i2c_del_driver(&driver))
printk("vex1x93: driver deregistration failed\n");
}
module_init(init_ves1x93);
module_exit(exit_ves1x93);
MODULE_DESCRIPTION("VES1x93 DVB-S Frontend");
MODULE_AUTHOR("Ralph Metzler");
MODULE_LICENSE("GPL");
MODULE_PARM(debug,"i");
MODULE_PARM(board_type,"i");
|