aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/af9013_priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/af9013_priv.h')
-rw-r--r--drivers/media/dvb/frontends/af9013_priv.h93
1 files changed, 46 insertions, 47 deletions
diff --git a/drivers/media/dvb/frontends/af9013_priv.h b/drivers/media/dvb/frontends/af9013_priv.h
index e00b2a4a2db6..fa848af6e9b4 100644
--- a/drivers/media/dvb/frontends/af9013_priv.h
+++ b/drivers/media/dvb/frontends/af9013_priv.h
@@ -2,6 +2,7 @@
2 * Afatech AF9013 demodulator driver 2 * Afatech AF9013 demodulator driver
3 * 3 *
4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> 4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
5 * Copyright (C) 2011 Antti Palosaari <crope@iki.fi>
5 * 6 *
6 * Thanks to Afatech who kindly provided information. 7 * Thanks to Afatech who kindly provided information.
7 * 8 *
@@ -21,24 +22,19 @@
21 * 22 *
22 */ 23 */
23 24
24#ifndef _AF9013_PRIV_ 25#ifndef AF9013_PRIV_H
25#define _AF9013_PRIV_ 26#define AF9013_PRIV_H
26 27
27#define LOG_PREFIX "af9013" 28#include "dvb_frontend.h"
28extern int af9013_debug; 29#include "af9013.h"
29 30#include <linux/firmware.h>
30#define dprintk(var, level, args...) \
31 do { if ((var & level)) printk(args); } while (0)
32 31
33#define debug_dump(b, l, func) {\ 32#define LOG_PREFIX "af9013"
34 int loop_; \
35 for (loop_ = 0; loop_ < l; loop_++) \
36 func("%02x ", b[loop_]); \
37 func("\n");\
38}
39
40#define deb_info(args...) dprintk(af9013_debug, 0x01, args)
41 33
34#undef dbg
35#define dbg(f, arg...) \
36 if (af9013_debug) \
37 printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
42#undef err 38#undef err
43#define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) 39#define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg)
44#undef info 40#undef info
@@ -48,70 +44,71 @@ extern int af9013_debug;
48 44
49#define AF9013_DEFAULT_FIRMWARE "dvb-fe-af9013.fw" 45#define AF9013_DEFAULT_FIRMWARE "dvb-fe-af9013.fw"
50 46
51struct regdesc { 47struct af9013_reg_bit {
52 u16 addr; 48 u16 addr;
53 u8 pos:4; 49 u8 pos:4;
54 u8 len:4; 50 u8 len:4;
55 u8 val; 51 u8 val;
56}; 52};
57 53
58struct snr_table { 54struct af9013_snr {
59 u32 val; 55 u32 val;
60 u8 snr; 56 u8 snr;
61}; 57};
62 58
63struct coeff { 59struct af9013_coeff {
64 u32 adc_clock; 60 u32 clock;
65 fe_bandwidth_t bw; 61 u32 bandwidth_hz;
66 u8 val[24]; 62 u8 val[24];
67}; 63};
68 64
69/* pre-calculated coeff lookup table */ 65/* pre-calculated coeff lookup table */
70static struct coeff coeff_table[] = { 66static const struct af9013_coeff coeff_lut[] = {
71 /* 28.800 MHz */ 67 /* 28.800 MHz */
72 { 28800, BANDWIDTH_8_MHZ, { 0x02, 0x8a, 0x28, 0xa3, 0x05, 0x14, 68 { 28800000, 8000000, { 0x02, 0x8a, 0x28, 0xa3, 0x05, 0x14,
73 0x51, 0x11, 0x00, 0xa2, 0x8f, 0x3d, 0x00, 0xa2, 0x8a, 69 0x51, 0x11, 0x00, 0xa2, 0x8f, 0x3d, 0x00, 0xa2, 0x8a,
74 0x29, 0x00, 0xa2, 0x85, 0x14, 0x01, 0x45, 0x14, 0x14 } }, 70 0x29, 0x00, 0xa2, 0x85, 0x14, 0x01, 0x45, 0x14, 0x14 } },
75 { 28800, BANDWIDTH_7_MHZ, { 0x02, 0x38, 0xe3, 0x8e, 0x04, 0x71, 71 { 28800000, 7000000, { 0x02, 0x38, 0xe3, 0x8e, 0x04, 0x71,
76 0xc7, 0x07, 0x00, 0x8e, 0x3d, 0x55, 0x00, 0x8e, 0x38, 72 0xc7, 0x07, 0x00, 0x8e, 0x3d, 0x55, 0x00, 0x8e, 0x38,
77 0xe4, 0x00, 0x8e, 0x34, 0x72, 0x01, 0x1c, 0x71, 0x32 } }, 73 0xe4, 0x00, 0x8e, 0x34, 0x72, 0x01, 0x1c, 0x71, 0x32 } },
78 { 28800, BANDWIDTH_6_MHZ, { 0x01, 0xe7, 0x9e, 0x7a, 0x03, 0xcf, 74 { 28800000, 6000000, { 0x01, 0xe7, 0x9e, 0x7a, 0x03, 0xcf,
79 0x3c, 0x3d, 0x00, 0x79, 0xeb, 0x6e, 0x00, 0x79, 0xe7, 75 0x3c, 0x3d, 0x00, 0x79, 0xeb, 0x6e, 0x00, 0x79, 0xe7,
80 0x9e, 0x00, 0x79, 0xe3, 0xcf, 0x00, 0xf3, 0xcf, 0x0f } }, 76 0x9e, 0x00, 0x79, 0xe3, 0xcf, 0x00, 0xf3, 0xcf, 0x0f } },
81 /* 20.480 MHz */ 77 /* 20.480 MHz */
82 { 20480, BANDWIDTH_8_MHZ, { 0x03, 0x92, 0x49, 0x26, 0x07, 0x24, 78 { 20480000, 8000000, { 0x03, 0x92, 0x49, 0x26, 0x07, 0x24,
83 0x92, 0x13, 0x00, 0xe4, 0x99, 0x6e, 0x00, 0xe4, 0x92, 79 0x92, 0x13, 0x00, 0xe4, 0x99, 0x6e, 0x00, 0xe4, 0x92,
84 0x49, 0x00, 0xe4, 0x8b, 0x25, 0x01, 0xc9, 0x24, 0x25 } }, 80 0x49, 0x00, 0xe4, 0x8b, 0x25, 0x01, 0xc9, 0x24, 0x25 } },
85 { 20480, BANDWIDTH_7_MHZ, { 0x03, 0x20, 0x00, 0x01, 0x06, 0x40, 81 { 20480000, 7000000, { 0x03, 0x20, 0x00, 0x01, 0x06, 0x40,
86 0x00, 0x00, 0x00, 0xc8, 0x06, 0x40, 0x00, 0xc8, 0x00, 82 0x00, 0x00, 0x00, 0xc8, 0x06, 0x40, 0x00, 0xc8, 0x00,
87 0x00, 0x00, 0xc7, 0xf9, 0xc0, 0x01, 0x90, 0x00, 0x00 } }, 83 0x00, 0x00, 0xc7, 0xf9, 0xc0, 0x01, 0x90, 0x00, 0x00 } },
88 { 20480, BANDWIDTH_6_MHZ, { 0x02, 0xad, 0xb6, 0xdc, 0x05, 0x5b, 84 { 20480000, 6000000, { 0x02, 0xad, 0xb6, 0xdc, 0x05, 0x5b,
89 0x6d, 0x2e, 0x00, 0xab, 0x73, 0x13, 0x00, 0xab, 0x6d, 85 0x6d, 0x2e, 0x00, 0xab, 0x73, 0x13, 0x00, 0xab, 0x6d,
90 0xb7, 0x00, 0xab, 0x68, 0x5c, 0x01, 0x56, 0xdb, 0x1c } }, 86 0xb7, 0x00, 0xab, 0x68, 0x5c, 0x01, 0x56, 0xdb, 0x1c } },
91 /* 28.000 MHz */ 87 /* 28.000 MHz */
92 { 28000, BANDWIDTH_8_MHZ, { 0x02, 0x9c, 0xbc, 0x15, 0x05, 0x39, 88 { 28000000, 8000000, { 0x02, 0x9c, 0xbc, 0x15, 0x05, 0x39,
93 0x78, 0x0a, 0x00, 0xa7, 0x34, 0x3f, 0x00, 0xa7, 0x2f, 89 0x78, 0x0a, 0x00, 0xa7, 0x34, 0x3f, 0x00, 0xa7, 0x2f,
94 0x05, 0x00, 0xa7, 0x29, 0xcc, 0x01, 0x4e, 0x5e, 0x03 } }, 90 0x05, 0x00, 0xa7, 0x29, 0xcc, 0x01, 0x4e, 0x5e, 0x03 } },
95 { 28000, BANDWIDTH_7_MHZ, { 0x02, 0x49, 0x24, 0x92, 0x04, 0x92, 91 { 28000000, 7000000, { 0x02, 0x49, 0x24, 0x92, 0x04, 0x92,
96 0x49, 0x09, 0x00, 0x92, 0x4d, 0xb7, 0x00, 0x92, 0x49, 92 0x49, 0x09, 0x00, 0x92, 0x4d, 0xb7, 0x00, 0x92, 0x49,
97 0x25, 0x00, 0x92, 0x44, 0x92, 0x01, 0x24, 0x92, 0x12 } }, 93 0x25, 0x00, 0x92, 0x44, 0x92, 0x01, 0x24, 0x92, 0x12 } },
98 { 28000, BANDWIDTH_6_MHZ, { 0x01, 0xf5, 0x8d, 0x10, 0x03, 0xeb, 94 { 28000000, 6000000, { 0x01, 0xf5, 0x8d, 0x10, 0x03, 0xeb,
99 0x1a, 0x08, 0x00, 0x7d, 0x67, 0x2f, 0x00, 0x7d, 0x63, 95 0x1a, 0x08, 0x00, 0x7d, 0x67, 0x2f, 0x00, 0x7d, 0x63,
100 0x44, 0x00, 0x7d, 0x5f, 0x59, 0x00, 0xfa, 0xc6, 0x22 } }, 96 0x44, 0x00, 0x7d, 0x5f, 0x59, 0x00, 0xfa, 0xc6, 0x22 } },
101 /* 25.000 MHz */ 97 /* 25.000 MHz */
102 { 25000, BANDWIDTH_8_MHZ, { 0x02, 0xec, 0xfb, 0x9d, 0x05, 0xd9, 98 { 25000000, 8000000, { 0x02, 0xec, 0xfb, 0x9d, 0x05, 0xd9,
103 0xf7, 0x0e, 0x00, 0xbb, 0x44, 0xc1, 0x00, 0xbb, 0x3e, 99 0xf7, 0x0e, 0x00, 0xbb, 0x44, 0xc1, 0x00, 0xbb, 0x3e,
104 0xe7, 0x00, 0xbb, 0x39, 0x0d, 0x01, 0x76, 0x7d, 0x34 } }, 100 0xe7, 0x00, 0xbb, 0x39, 0x0d, 0x01, 0x76, 0x7d, 0x34 } },
105 { 25000, BANDWIDTH_7_MHZ, { 0x02, 0x8f, 0x5c, 0x29, 0x05, 0x1e, 101 { 25000000, 7000000, { 0x02, 0x8f, 0x5c, 0x29, 0x05, 0x1e,
106 0xb8, 0x14, 0x00, 0xa3, 0xdc, 0x29, 0x00, 0xa3, 0xd7, 102 0xb8, 0x14, 0x00, 0xa3, 0xdc, 0x29, 0x00, 0xa3, 0xd7,
107 0x0a, 0x00, 0xa3, 0xd1, 0xec, 0x01, 0x47, 0xae, 0x05 } }, 103 0x0a, 0x00, 0xa3, 0xd1, 0xec, 0x01, 0x47, 0xae, 0x05 } },
108 { 25000, BANDWIDTH_6_MHZ, { 0x02, 0x31, 0xbc, 0xb5, 0x04, 0x63, 104 { 25000000, 6000000, { 0x02, 0x31, 0xbc, 0xb5, 0x04, 0x63,
109 0x79, 0x1b, 0x00, 0x8c, 0x73, 0x91, 0x00, 0x8c, 0x6f, 105 0x79, 0x1b, 0x00, 0x8c, 0x73, 0x91, 0x00, 0x8c, 0x6f,
110 0x2d, 0x00, 0x8c, 0x6a, 0xca, 0x01, 0x18, 0xde, 0x17 } }, 106 0x2d, 0x00, 0x8c, 0x6a, 0xca, 0x01, 0x18, 0xde, 0x17 } },
111}; 107};
112 108
113/* QPSK SNR lookup table */ 109/* QPSK SNR lookup table */
114static struct snr_table qpsk_snr_table[] = { 110static const struct af9013_snr qpsk_snr_lut[] = {
111 { 0x000000, 0 },
115 { 0x0b4771, 0 }, 112 { 0x0b4771, 0 },
116 { 0x0c1aed, 1 }, 113 { 0x0c1aed, 1 },
117 { 0x0d0d27, 2 }, 114 { 0x0d0d27, 2 },
@@ -131,7 +128,8 @@ static struct snr_table qpsk_snr_table[] = {
131}; 128};
132 129
133/* QAM16 SNR lookup table */ 130/* QAM16 SNR lookup table */
134static struct snr_table qam16_snr_table[] = { 131static const struct af9013_snr qam16_snr_lut[] = {
132 { 0x000000, 0 },
135 { 0x05eb62, 5 }, 133 { 0x05eb62, 5 },
136 { 0x05fecf, 6 }, 134 { 0x05fecf, 6 },
137 { 0x060b80, 7 }, 135 { 0x060b80, 7 },
@@ -151,7 +149,8 @@ static struct snr_table qam16_snr_table[] = {
151}; 149};
152 150
153/* QAM64 SNR lookup table */ 151/* QAM64 SNR lookup table */
154static struct snr_table qam64_snr_table[] = { 152static const struct af9013_snr qam64_snr_lut[] = {
153 { 0x000000, 0 },
155 { 0x03109b, 12 }, 154 { 0x03109b, 12 },
156 { 0x0310d4, 13 }, 155 { 0x0310d4, 13 },
157 { 0x031920, 14 }, 156 { 0x031920, 14 },
@@ -170,7 +169,7 @@ static struct snr_table qam64_snr_table[] = {
170 { 0xffffff, 27 }, 169 { 0xffffff, 27 },
171}; 170};
172 171
173static struct regdesc ofsm_init[] = { 172static const struct af9013_reg_bit ofsm_init[] = {
174 { 0xd73a, 0, 8, 0xa1 }, 173 { 0xd73a, 0, 8, 0xa1 },
175 { 0xd73b, 0, 8, 0x1f }, 174 { 0xd73b, 0, 8, 0x1f },
176 { 0xd73c, 4, 4, 0x0a }, 175 { 0xd73c, 4, 4, 0x0a },
@@ -252,7 +251,7 @@ static struct regdesc ofsm_init[] = {
252 251
253/* Panasonic ENV77H11D5 tuner init 252/* Panasonic ENV77H11D5 tuner init
254 AF9013_TUNER_ENV77H11D5 = 129 */ 253 AF9013_TUNER_ENV77H11D5 = 129 */
255static struct regdesc tuner_init_env77h11d5[] = { 254static const struct af9013_reg_bit tuner_init_env77h11d5[] = {
256 { 0x9bd5, 0, 8, 0x01 }, 255 { 0x9bd5, 0, 8, 0x01 },
257 { 0x9bd6, 0, 8, 0x03 }, 256 { 0x9bd6, 0, 8, 0x03 },
258 { 0x9bbe, 0, 8, 0x01 }, 257 { 0x9bbe, 0, 8, 0x01 },
@@ -318,7 +317,7 @@ static struct regdesc tuner_init_env77h11d5[] = {
318 317
319/* Microtune MT2060 tuner init 318/* Microtune MT2060 tuner init
320 AF9013_TUNER_MT2060 = 130 */ 319 AF9013_TUNER_MT2060 = 130 */
321static struct regdesc tuner_init_mt2060[] = { 320static const struct af9013_reg_bit tuner_init_mt2060[] = {
322 { 0x9bd5, 0, 8, 0x01 }, 321 { 0x9bd5, 0, 8, 0x01 },
323 { 0x9bd6, 0, 8, 0x07 }, 322 { 0x9bd6, 0, 8, 0x07 },
324 { 0xd1a0, 1, 1, 0x01 }, 323 { 0xd1a0, 1, 1, 0x01 },
@@ -395,7 +394,7 @@ static struct regdesc tuner_init_mt2060[] = {
395 394
396/* Microtune MT2060 tuner init 395/* Microtune MT2060 tuner init
397 AF9013_TUNER_MT2060_2 = 147 */ 396 AF9013_TUNER_MT2060_2 = 147 */
398static struct regdesc tuner_init_mt2060_2[] = { 397static const struct af9013_reg_bit tuner_init_mt2060_2[] = {
399 { 0x9bd5, 0, 8, 0x01 }, 398 { 0x9bd5, 0, 8, 0x01 },
400 { 0x9bd6, 0, 8, 0x06 }, 399 { 0x9bd6, 0, 8, 0x06 },
401 { 0x9bbe, 0, 8, 0x01 }, 400 { 0x9bbe, 0, 8, 0x01 },
@@ -462,7 +461,7 @@ static struct regdesc tuner_init_mt2060_2[] = {
462 461
463/* MaxLinear MXL5003 tuner init 462/* MaxLinear MXL5003 tuner init
464 AF9013_TUNER_MXL5003D = 3 */ 463 AF9013_TUNER_MXL5003D = 3 */
465static struct regdesc tuner_init_mxl5003d[] = { 464static const struct af9013_reg_bit tuner_init_mxl5003d[] = {
466 { 0x9bd5, 0, 8, 0x01 }, 465 { 0x9bd5, 0, 8, 0x01 },
467 { 0x9bd6, 0, 8, 0x09 }, 466 { 0x9bd6, 0, 8, 0x09 },
468 { 0xd1a0, 1, 1, 0x01 }, 467 { 0xd1a0, 1, 1, 0x01 },
@@ -534,7 +533,7 @@ static struct regdesc tuner_init_mxl5003d[] = {
534 AF9013_TUNER_MXL5005D = 13 533 AF9013_TUNER_MXL5005D = 13
535 AF9013_TUNER_MXL5005R = 30 534 AF9013_TUNER_MXL5005R = 30
536 AF9013_TUNER_MXL5007T = 177 */ 535 AF9013_TUNER_MXL5007T = 177 */
537static struct regdesc tuner_init_mxl5005[] = { 536static const struct af9013_reg_bit tuner_init_mxl5005[] = {
538 { 0x9bd5, 0, 8, 0x01 }, 537 { 0x9bd5, 0, 8, 0x01 },
539 { 0x9bd6, 0, 8, 0x07 }, 538 { 0x9bd6, 0, 8, 0x07 },
540 { 0xd1a0, 1, 1, 0x01 }, 539 { 0xd1a0, 1, 1, 0x01 },
@@ -613,7 +612,7 @@ static struct regdesc tuner_init_mxl5005[] = {
613/* Quantek QT1010 tuner init 612/* Quantek QT1010 tuner init
614 AF9013_TUNER_QT1010 = 134 613 AF9013_TUNER_QT1010 = 134
615 AF9013_TUNER_QT1010A = 162 */ 614 AF9013_TUNER_QT1010A = 162 */
616static struct regdesc tuner_init_qt1010[] = { 615static const struct af9013_reg_bit tuner_init_qt1010[] = {
617 { 0x9bd5, 0, 8, 0x01 }, 616 { 0x9bd5, 0, 8, 0x01 },
618 { 0x9bd6, 0, 8, 0x09 }, 617 { 0x9bd6, 0, 8, 0x09 },
619 { 0xd1a0, 1, 1, 0x01 }, 618 { 0xd1a0, 1, 1, 0x01 },
@@ -690,7 +689,7 @@ static struct regdesc tuner_init_qt1010[] = {
690 689
691/* Freescale MC44S803 tuner init 690/* Freescale MC44S803 tuner init
692 AF9013_TUNER_MC44S803 = 133 */ 691 AF9013_TUNER_MC44S803 = 133 */
693static struct regdesc tuner_init_mc44s803[] = { 692static const struct af9013_reg_bit tuner_init_mc44s803[] = {
694 { 0x9bd5, 0, 8, 0x01 }, 693 { 0x9bd5, 0, 8, 0x01 },
695 { 0x9bd6, 0, 8, 0x06 }, 694 { 0x9bd6, 0, 8, 0x06 },
696 { 0xd1a0, 1, 1, 0x01 }, 695 { 0xd1a0, 1, 1, 0x01 },
@@ -772,7 +771,7 @@ static struct regdesc tuner_init_mc44s803[] = {
772 771
773/* unknown, probably for tin can tuner, tuner init 772/* unknown, probably for tin can tuner, tuner init
774 AF9013_TUNER_UNKNOWN = 140 */ 773 AF9013_TUNER_UNKNOWN = 140 */
775static struct regdesc tuner_init_unknown[] = { 774static const struct af9013_reg_bit tuner_init_unknown[] = {
776 { 0x9bd5, 0, 8, 0x01 }, 775 { 0x9bd5, 0, 8, 0x01 },
777 { 0x9bd6, 0, 8, 0x02 }, 776 { 0x9bd6, 0, 8, 0x02 },
778 { 0xd1a0, 1, 1, 0x01 }, 777 { 0xd1a0, 1, 1, 0x01 },
@@ -845,7 +844,7 @@ static struct regdesc tuner_init_unknown[] = {
845/* NXP TDA18271 & TDA18218 tuner init 844/* NXP TDA18271 & TDA18218 tuner init
846 AF9013_TUNER_TDA18271 = 156 845 AF9013_TUNER_TDA18271 = 156
847 AF9013_TUNER_TDA18218 = 179 */ 846 AF9013_TUNER_TDA18218 = 179 */
848static struct regdesc tuner_init_tda18271[] = { 847static const struct af9013_reg_bit tuner_init_tda18271[] = {
849 { 0x9bd5, 0, 8, 0x01 }, 848 { 0x9bd5, 0, 8, 0x01 },
850 { 0x9bd6, 0, 8, 0x04 }, 849 { 0x9bd6, 0, 8, 0x04 },
851 { 0xd1a0, 1, 1, 0x01 }, 850 { 0xd1a0, 1, 1, 0x01 },
@@ -920,4 +919,4 @@ static struct regdesc tuner_init_tda18271[] = {
920 { 0x9bee, 0, 1, 0x01 }, 919 { 0x9bee, 0, 1, 0x01 },
921}; 920};
922 921
923#endif /* _AF9013_PRIV_ */ 922#endif /* AF9013_PRIV_H */