-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpt3_tc.c
772 lines (616 loc) · 14.7 KB
/
pt3_tc.c
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
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
/*******************************************************************************
earthsoft PT3 Linux driver
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 3, as published by the Free Software Foundation.
This program is distributed in the hope 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.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
*******************************************************************************/
#if defined(__FreeBSD__)
#include "pt3_misc.h"
#else
#include "version.h"
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/version.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
#include <asm/system.h>
#endif
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
#include "pt3_com.h"
#include "pt3_pci.h"
#include "pt3_tc.h"
#endif
static __u32
byten(const __u8 *data, __u32 n)
{
__u32 value, i;
value = 0;
for (i = 0; i < n; i++) {
value <<= 8;
value |= data[i];
}
return value;
}
static __u16
byte2(const __u8 *data)
{
return (__u16)byten(data, 2);
}
static __u32
byte3(const __u8 *data)
{
return byten(data, 3);
}
__u8
pt3_tc_address(__u32 pin, int isdb, __u32 index)
{
__u8 isdb2 = (isdb == PT3_ISDB_S) ? 1 : 0;
return (__u8)(1 << 4 | pin << 2 | index << 1 | isdb2);
}
STATUS
pt3_tc_write(PT3_TC *tc, PT3_BUS *bus, __u8 addr, const __u8 *data, __u32 size)
{
STATUS status;
__u8 buf;
PT3_BUS *p;
p = bus ? bus : create_pt3_bus();
if (p == NULL) {
PT3_PRINTK(0, KERN_ERR, "out of memory.\n");
return STATUS_OUT_OF_MEMORY_ERROR;
}
pt3_bus_start(p);
buf = tc->tc_addr << 1;
pt3_bus_write(p, &buf, 1);
pt3_bus_write(p, &addr, 1);
pt3_bus_write(p, data, size);
pt3_bus_stop(p);
if (bus) {
status = STATUS_OK;
} else {
pt3_bus_end(p);
status = pt3_i2c_run(tc->i2c, p, NULL, 1);
}
if (!bus)
free_pt3_bus(p);
return status;
}
static STATUS
tc_read(PT3_TC *tc, PT3_BUS *bus, __u8 addr, __u8 *data, __u32 size)
{
STATUS status;
__u8 buf[size];
__u32 i, rindex;
PT3_BUS *p;
p = bus ? bus : create_pt3_bus();
if (p == NULL) {
PT3_PRINTK(0, KERN_ERR, "out of memory.\n");
return STATUS_OUT_OF_MEMORY_ERROR;
}
pt3_bus_start(p);
buf[0] = tc->tc_addr << 1;
pt3_bus_write(p, &buf[0], 1);
pt3_bus_write(p, &addr, 1);
pt3_bus_start(p);
buf[0] = tc->tc_addr << 1 | 1;
pt3_bus_write(p, &buf[0], 1);
rindex = pt3_bus_read(p, &buf[0], size);
pt3_bus_stop(p);
if (bus) {
status = STATUS_OK;
} else {
pt3_bus_end(p);
status = pt3_i2c_run(tc->i2c, p, NULL, 1);
for (i = 0; i < size; i++)
data[i] = pt3_bus_data1(p, rindex + i);
}
if (!bus)
free_pt3_bus(p);
return status;
}
STATUS
pt3_tc_read_tuner_without_addr(PT3_TC *tc, PT3_BUS *bus, __u8 *data, __u32 size)
{
STATUS status;
__u8 buf[size];
__u32 i;
__u32 rindex;
PT3_BUS *p;
memset(buf, 0, size);
p = bus ? bus : create_pt3_bus();
if (p == NULL) {
PT3_PRINTK(0, KERN_ERR, "out of memory.\n");
return STATUS_OUT_OF_MEMORY_ERROR;
}
pt3_bus_start(p);
buf[0] = tc->tc_addr << 1;
pt3_bus_write(p, &buf[0], 1);
buf[0] = TC_THROUGH;
pt3_bus_write(p, &buf[0], 1);
buf[0] = (tc->tuner_addr << 1) | 0x01;
pt3_bus_write(p, &buf[0], 1);
pt3_bus_start(p);
buf[0] = (tc->tc_addr << 1) | 0x01;
pt3_bus_write(p, &buf[0], 1);
rindex = pt3_bus_read(p, &buf[0], size);
pt3_bus_stop(p);
if (bus) {
status = STATUS_OK;
} else {
pt3_bus_end(p);
status = pt3_i2c_run(tc->i2c, p, NULL, 1);
for (i = 0; i < size; i++)
data[i] = pt3_bus_data1(p, rindex + i);
}
if (!bus)
free_pt3_bus(p);
#if 0
PT3_PRINTK(7, KERN_DEBUG, "read_tuner_without tc_addr=0x%x tuner_addr=0x%x\n",
tc->tc_addr, tc->tuner_addr);
#endif
return status;
}
STATUS
pt3_tc_write_tuner_without_addr(PT3_TC *tc, PT3_BUS *bus, const __u8 *data, __u32 size)
{
STATUS status;
__u8 buf;
PT3_BUS *p;
p = bus ? bus : create_pt3_bus();
if (p == NULL) {
PT3_PRINTK(0, KERN_ERR, "out of memory.\n");
return STATUS_OUT_OF_MEMORY_ERROR;
}
pt3_bus_start(p);
buf = tc->tc_addr << 1;
pt3_bus_write(p, &buf, 1);
buf = TC_THROUGH;
pt3_bus_write(p, &buf, 1);
buf = tc->tuner_addr << 1;
pt3_bus_write(p, &buf, 1);
pt3_bus_write(p, data, size);
pt3_bus_stop(p);
if (bus)
status = STATUS_OK;
else {
pt3_bus_end(p);
status = pt3_i2c_run(tc->i2c, p, NULL, 1);
}
if (!bus)
free_pt3_bus(p);
return status;
}
STATUS
pt3_tc_read_tuner(PT3_TC *tc, PT3_BUS *bus, __u8 addr, __u8 *data, __u32 size)
{
STATUS status;
__u8 buf[size];
__u32 i;
size_t rindex;
PT3_BUS *p;
memset(buf, 0, size);
p = bus ? bus : create_pt3_bus();
if (p == NULL) {
PT3_PRINTK(0, KERN_ERR, "out of memory.\n");
return STATUS_OUT_OF_MEMORY_ERROR;
}
pt3_bus_start(p);
buf[0] = tc->tc_addr << 1;
pt3_bus_write(p, &buf[0], 1);
buf[0] = TC_THROUGH;
pt3_bus_write(p, &buf[0], 1);
buf[0] = tc->tuner_addr << 1;
pt3_bus_write(p, &buf[0], 1);
pt3_bus_write(p, &addr, 1);
pt3_bus_start(p);
buf[0] = tc->tc_addr << 1;
pt3_bus_write(p, &buf[0], 1);
buf[0] = TC_THROUGH;
pt3_bus_write(p, &buf[0], 1);
buf[0] = (tc->tuner_addr << 1) | 1;
pt3_bus_write(p, &buf[0], 1);
pt3_bus_start(p);
buf[0] = (tc->tc_addr << 1) | 1;
pt3_bus_write(p, &buf[0], 1);
rindex = pt3_bus_read(p, &buf[0], size);
pt3_bus_stop(p);
if (bus) {
status = STATUS_OK;
} else {
pt3_bus_end(p);
status = pt3_i2c_run(tc->i2c, p, NULL, 1);
for (i = 0; i < size; i++)
data[i] = pt3_bus_data1(p, rindex + i);
}
if (!bus)
free_pt3_bus(p);
#if 0
PT3_PRINTK(7, KERN_DEBUG, "read_tuner tc_addr=0x%x tuner_addr=0x%x\n",
tc->tc_addr, tc->tuner_addr);
#endif
return status;
}
STATUS
pt3_tc_write_tuner(PT3_TC *tc, PT3_BUS *bus, __u8 addr, const __u8 *data, __u32 size)
{
STATUS status;
__u8 buf;
PT3_BUS *p;
p = bus ? bus : create_pt3_bus();
if (p == NULL) {
PT3_PRINTK(0, KERN_ERR, "out of memory.\n");
return STATUS_OUT_OF_MEMORY_ERROR;
}
pt3_bus_start(p);
buf = tc->tc_addr << 1;
pt3_bus_write(p, &buf, 1);
buf = TC_THROUGH;
pt3_bus_write(p, &buf, 1);
buf = tc->tuner_addr << 1;
pt3_bus_write(p, &buf, 1);
pt3_bus_write(p, &addr, 1);
pt3_bus_write(p, data, size);
pt3_bus_stop(p);
if (bus)
status = STATUS_OK;
else {
pt3_bus_end(p);
status = pt3_i2c_run(tc->i2c, p, NULL, 1);
}
if (!bus)
free_pt3_bus(p);
return status;
}
/* TC_S */
static STATUS
write_pskmsrst(PT3_TC *tc, PT3_BUS *bus)
{
__u8 buf;
buf = 0x01;
return pt3_tc_write(tc, bus, 0x03, &buf, 1);
}
STATUS
pt3_tc_init_s(PT3_TC *tc, PT3_BUS *bus)
{
STATUS status;
__u8 buf;
status = write_pskmsrst(tc, bus);
if (status)
return status;
buf = 0x10;
status = pt3_tc_write(tc, bus, 0x1e, &buf, 1);
if (status)
return status;
return status;
}
/* TC_T */
static STATUS
write_imsrst(PT3_TC *tc, PT3_BUS *bus)
{
__u8 buf;
buf = 0x01 << 6;
return pt3_tc_write(tc, bus, 0x01, &buf, 1);
}
STATUS
pt3_tc_init_t(PT3_TC *tc, PT3_BUS *bus)
{
STATUS status;
__u8 buf;
status = write_imsrst(tc, bus);
if (status)
return status;
buf = 0x10;
status = pt3_tc_write(tc, bus, 0x1c, &buf, 1);
if (status)
return status;
return status;
}
STATUS
pt3_tc_set_powers(PT3_TC *tc, PT3_BUS *bus, int tuner, int amp)
{
STATUS status;
__u8 tuner_power = tuner ? 0x03 : 0x02;
__u8 amp_power = amp ? 0x03 : 0x02;
__u8 data = (tuner_power << 6) | (0x01 << 4) | (amp_power << 2) | 0x01 << 0;
status = pt3_tc_write(tc, bus, 0x1e, &data, 1);
return status;
}
static __u8 agc_data_s[2] = { 0xb0, 0x30 };
STATUS
pt3_tc_set_agc_s(PT3_TC *tc, PT3_BUS *bus, PT3_TC_AGC agc)
{
STATUS status;
__u8 data;
data = (agc == PT3_TC_AGC_AUTO) ? 0xff : 0x00;
status = pt3_tc_write(tc, bus, 0x0a, &data, 1);
if (status)
return status;
data = agc_data_s[pt3_tc_index(tc)];
data |= (agc == PT3_TC_AGC_AUTO) ? 0x01 : 0x00;
status = pt3_tc_write(tc, bus, 0x10, &data, 1);
if (status)
return status;
data = (agc == PT3_TC_AGC_AUTO) ? 0x40 : 0x00;
status = pt3_tc_write(tc, bus, 0x11, &data, 1);
if (status)
return status;
status = write_pskmsrst(tc, bus);
return status;
}
STATUS
pt3_tc_set_agc_t(PT3_TC *tc, PT3_BUS *bus, PT3_TC_AGC agc)
{
STATUS status;
__u8 data;
data = (agc == PT3_TC_AGC_AUTO) ? 64 : 0;
status = pt3_tc_write(tc, bus, 0x25, &data, 1);
if (status)
return status;
data = 0x4c;
data |= (agc == PT3_TC_AGC_AUTO) ? 0x00 : 0x01;
status = pt3_tc_write(tc, bus, 0x23, &data, 1);
if (status)
return status;
status = write_imsrst(tc, bus);
return status;
}
STATUS
pt3_tc_set_sleep_s(PT3_TC *tc, PT3_BUS *bus, int sleep)
{
STATUS status;
__u8 buf;
buf = sleep ? 1 : 0;
status = pt3_tc_write(tc, bus, 0x17, &buf, 1);
return status;
}
STATUS
pt3_tc_set_ts_pins_mode_s(PT3_TC *tc, PT3_BUS *bus, PT3_TS_PINS_MODE *mode)
{
__u32 clock_data, byte, valid;
__u8 data[2];
STATUS status;
clock_data = mode->clock_data;
byte = mode->byte;
valid = mode->valid;
if (clock_data)
clock_data++;
if (byte)
byte++;
if (valid)
valid++;
data[0] = 0x15 | (valid << 6);
data[1] = 0x04 | (clock_data << 4) | byte;
status = pt3_tc_write(tc, bus, 0x1c, &data[0], 1);
if (status)
return status;
status = pt3_tc_write(tc, bus, 0x1f, &data[1], 1);
if (status)
return status;
return status;
}
STATUS
pt3_tc_set_ts_pins_mode_t(PT3_TC *tc, PT3_BUS *bus, PT3_TS_PINS_MODE *mode)
{
__u32 clock_data, byte, valid;
__u8 data;
STATUS status;
clock_data = mode->clock_data;
byte = mode->byte;
valid = mode->valid;
if (clock_data)
clock_data++;
if (byte)
byte++;
if (valid)
valid++;
data = (__u8)(0x01 | (clock_data << 6) | (byte << 4) | (valid << 2)) ;
status = pt3_tc_write(tc, bus, 0x1d, &data, 1);
return status;
}
STATUS
pt3_tc_read_retryov_tmunvld_fulock(PT3_TC *tc, PT3_BUS *bus, int *retryov, int *tmunvld, int *fulock)
{
STATUS status;
__u8 data;
status = tc_read(tc, bus, 0x80, &data, 1);
if (status)
return status;
*retryov = BIT_SHIFT_MASK(data, 7, 1) ? 1 : 0;
*tmunvld = BIT_SHIFT_MASK(data, 5, 1) ? 1 : 0;
*fulock = BIT_SHIFT_MASK(data, 3, 1) ? 1 : 0;
return status;
}
STATUS
pt3_tc_read_tmcc_s(PT3_TC *tc, PT3_BUS *bus, TMCC_S *tmcc)
{
enum {
BASE = 0xc5,
SIZE = 0xe5 - BASE + 1
};
STATUS status;
__u8 data[SIZE];
__u32 i, byte_offset, bit_offset;
status = tc_read(tc, bus, 0xc3, data, 1);
if (status)
return status;
if (BIT_SHIFT_MASK(data[0], 4, 1))
return STATUS_GENERAL_ERROR;
status = tc_read(tc, bus, 0xce, data, 2);
if (status)
return status;
if (byte2(data) == 0)
return STATUS_GENERAL_ERROR;
status = tc_read(tc, bus, 0xc3, data, 1);
if (status)
return status;
tmcc->emergency = BIT_SHIFT_MASK(data[0], 2, 1);
tmcc->extflag = BIT_SHIFT_MASK(data[0], 1, 1);
status = tc_read(tc, bus, 0xc5, data, SIZE);
if (status)
return status;
tmcc->indicator = BIT_SHIFT_MASK(data[0xc5 - BASE], 3, 5);
tmcc->uplink = BIT_SHIFT_MASK(data[0xc7 - BASE], 0, 4);
for (i = 0; i < 4; i++) {
byte_offset = i / 2;
bit_offset = (i % 2) ? 0 : 4;
tmcc->mode[i] = BIT_SHIFT_MASK(data[0xc8 + byte_offset - BASE], bit_offset, 4);
tmcc->slot[i] = BIT_SHIFT_MASK(data[0xca + i - BASE], 0, 6);
}
for (i = 0; i < 8; i++)
tmcc->id[i] = byte2(data + 0xce + i * 2 - BASE);
return status;
}
STATUS
pt3_tc_read_tmcc_t(PT3_TC *tc, PT3_BUS *bus, TMCC_T *tmcc)
{
STATUS status;
__u8 data[8];
__u32 interleave0h, interleave0l, segment1h, segment1l;
status = tc_read(tc, bus, 0xb2+0, &data[0], 4);
if (status)
return status;
status = tc_read(tc, bus, 0xb2+4, &data[4], 4);
if (status)
return status;
tmcc->system = BIT_SHIFT_MASK(data[0], 6, 2);
tmcc->indicator = BIT_SHIFT_MASK(data[0], 2, 4);
tmcc->emergency = BIT_SHIFT_MASK(data[0], 1, 1);
tmcc->partial = BIT_SHIFT_MASK(data[0], 0, 1);
tmcc->mode[0] = BIT_SHIFT_MASK(data[1], 5, 3);
tmcc->mode[1] = BIT_SHIFT_MASK(data[2], 0, 3);
tmcc->mode[2] = BIT_SHIFT_MASK(data[4], 3, 3);
tmcc->rate[0] = BIT_SHIFT_MASK(data[1], 2, 3);
tmcc->rate[1] = BIT_SHIFT_MASK(data[3], 5, 3);
tmcc->rate[2] = BIT_SHIFT_MASK(data[4], 0, 3);
interleave0h = BIT_SHIFT_MASK(data[1], 0, 2);
interleave0l = BIT_SHIFT_MASK(data[2], 7, 1);
tmcc->interleave[0] = interleave0h << 1 | interleave0l << 0;
tmcc->interleave[1] = BIT_SHIFT_MASK(data[3], 2, 3);
tmcc->interleave[2] = BIT_SHIFT_MASK(data[5], 5, 3);
segment1h = BIT_SHIFT_MASK(data[3], 0, 2);
segment1l = BIT_SHIFT_MASK(data[4], 6, 2);
tmcc->segment[0] = BIT_SHIFT_MASK(data[2], 3, 4);
tmcc->segment[1] = segment1h << 2 | segment1l << 0;
tmcc->segment[2] = BIT_SHIFT_MASK(data[5], 1, 4);
return status;
}
STATUS
pt3_tc_write_id_s(PT3_TC *tc, PT3_BUS *bus, __u16 id)
{
STATUS status;
__u8 data[2] = { id >> 8, (__u8)id };
status = pt3_tc_write(tc, bus, 0x8f, data, sizeof(data));
return status;
}
STATUS
pt3_tc_read_id_s(PT3_TC *tc, PT3_BUS *bus, __u16 *id)
{
STATUS status;
__u8 data[2];
status = tc_read(tc, bus, 0xe6, data, sizeof(data));
if (status)
return status;
*id = byte2(data);
return status;
}
__u32
pt3_tc_index(PT3_TC *tc)
{
return BIT_SHIFT_MASK(tc->tc_addr, 1, 1);
}
STATUS
pt3_tc_write_slptim(PT3_TC *tc, PT3_BUS *bus, int sleep)
{
STATUS status;
__u8 data;
data = (1 << 7) | ((sleep ? 1 :0) <<4);
status = pt3_tc_write(tc, bus, 0x03, &data, 1);
return status;
}
STATUS
pt3_tc_read_agc_s(PT3_TC *tc, PT3_BUS *bus, __u8 *agc)
{
STATUS status;
__u8 data;
status = tc_read(tc, bus, 0xba, &data, 1);
if (status)
return status;
*agc = data & 0x7f;
return status;
}
STATUS
pt3_tc_read_ifagc_dt(PT3_TC *tc, PT3_BUS *bus, __u8 *ifagc_dt)
{
STATUS status;
status = tc_read(tc, bus, 0x82, ifagc_dt, 1);
if (status)
return status;
return status;
}
STATUS
pt3_tc_read_cn_s(PT3_TC *tc, PT3_BUS *bus, __u32 *cn)
{
STATUS status;
__u8 data[2];
status = tc_read(tc, bus, 0xbc, data, sizeof(data));
if (status)
return status;
*cn = byte2(data);
return status;
}
STATUS
pt3_tc_read_cndat_t(PT3_TC *tc, PT3_BUS *bus, __u32 *cn)
{
STATUS status;
__u8 data[3];
status = tc_read(tc, bus, 0x8b, data, sizeof(data));
if (status)
return status;
*cn = byte3(data);
return status;
}
PT3_TC *
create_pt3_tc(PT3_I2C *i2c, __u8 tc_addr, __u8 tuner_addr)
{
PT3_TC *tc;
tc = NULL;
tc = pt3_vzalloc(sizeof(PT3_TC));
if (tc == NULL)
goto fail;
tc->i2c = i2c;
tc->tc_addr = tc_addr;
tc->tuner_addr = tuner_addr;
tc->master_clock_freq = 78;
return tc;
fail:
if (tc != NULL)
vfree(tc);
return NULL;
}
void
free_pt3_tc(PT3_TC *tc)
{
vfree(tc);
}
__u32
time_diff(struct timeval *st, struct timeval *et)
{
__u32 diff;
diff = (et->tv_sec - st->tv_sec) * 1000000 + (et->tv_usec - st->tv_usec);
#if 0
PT3_PRINTK(7, KERN_DEBUG, "time diff = %d\n", diff / 1000);
#endif
return diff / 1000;
}