diff options
Diffstat (limited to 'drivers/media/video/tda8290.c')
-rw-r--r-- | drivers/media/video/tda8290.c | 681 |
1 files changed, 524 insertions, 157 deletions
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index c65f0c7680a2..b2dfe07e9f9d 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c | |||
@@ -1,172 +1,406 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | |
3 | * i2c tv tuner chip device driver | 3 | i2c tv tuner chip device driver |
4 | * controls the philips tda8290+75 tuner chip combo. | 4 | controls the philips tda8290+75 tuner chip combo. |
5 | */ | 5 | |
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
6 | #include <linux/i2c.h> | 21 | #include <linux/i2c.h> |
7 | #include <linux/videodev.h> | 22 | #include <linux/videodev.h> |
8 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
9 | #include <media/tuner.h> | 24 | #include <media/tuner.h> |
10 | 25 | ||
11 | #define I2C_ADDR_TDA8290 0x4b | ||
12 | #define I2C_ADDR_TDA8275 0x61 | ||
13 | |||
14 | /* ---------------------------------------------------------------------- */ | 26 | /* ---------------------------------------------------------------------- */ |
15 | 27 | ||
16 | struct freq_entry { | 28 | struct tda827x_data { |
17 | u16 freq; | 29 | u32 lomax; |
18 | u8 value; | 30 | u8 spd; |
31 | u8 bs; | ||
32 | u8 bp; | ||
33 | u8 cp; | ||
34 | u8 gc3; | ||
35 | u8 div1p5; | ||
19 | }; | 36 | }; |
20 | 37 | ||
21 | static struct freq_entry band_table[] = { | 38 | /* Note lomax entry is lo / 62500 */ |
22 | { 0x2DF4, 0x1C }, | 39 | |
23 | { 0x2574, 0x14 }, | 40 | static struct tda827x_data tda827x_analog[] = { |
24 | { 0x22B4, 0x0C }, | 41 | { .lomax = 992, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, /* 62 MHz */ |
25 | { 0x20D4, 0x0B }, | 42 | { .lomax = 1056, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1}, /* 66 MHz */ |
26 | { 0x1E74, 0x3B }, | 43 | { .lomax = 1216, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, /* 76 MHz */ |
27 | { 0x1C34, 0x33 }, | 44 | { .lomax = 1344, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0}, /* 84 MHz */ |
28 | { 0x16F4, 0x5B }, | 45 | { .lomax = 1488, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 93 MHz */ |
29 | { 0x1454, 0x53 }, | 46 | { .lomax = 1568, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 98 MHz */ |
30 | { 0x12D4, 0x52 }, | 47 | { .lomax = 1744, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 109 MHz */ |
31 | { 0x1034, 0x4A }, | 48 | { .lomax = 1968, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 123 MHz */ |
32 | { 0x0EE4, 0x7A }, | 49 | { .lomax = 2128, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 133 MHz */ |
33 | { 0x0D34, 0x72 }, | 50 | { .lomax = 2416, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 151 MHz */ |
34 | { 0x0B54, 0x9A }, | 51 | { .lomax = 2464, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 154 MHz */ |
35 | { 0x0914, 0x91 }, | 52 | { .lomax = 2896, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 181 MHz */ |
36 | { 0x07F4, 0x89 }, | 53 | { .lomax = 2960, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 185 MHz */ |
37 | { 0x0774, 0xB9 }, | 54 | { .lomax = 3472, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 217 MHz */ |
38 | { 0x067B, 0xB1 }, | 55 | { .lomax = 3904, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 244 MHz */ |
39 | { 0x0634, 0xD9 }, | 56 | { .lomax = 4240, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 265 MHz */ |
40 | { 0x05A4, 0xD8 }, // FM radio | 57 | { .lomax = 4832, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 302 MHz */ |
41 | { 0x0494, 0xD0 }, | 58 | { .lomax = 5184, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 324 MHz */ |
42 | { 0x03BC, 0xC8 }, | 59 | { .lomax = 5920, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 370 MHz */ |
43 | { 0x0394, 0xF8 }, // 57250000 Hz | 60 | { .lomax = 7264, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 454 MHz */ |
44 | { 0x0000, 0xF0 }, // 0 | 61 | { .lomax = 7888, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 493 MHz */ |
62 | { .lomax = 8480, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1}, /* 530 MHz */ | ||
63 | { .lomax = 8864, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0}, /* 554 MHz */ | ||
64 | { .lomax = 9664, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 604 MHz */ | ||
65 | { .lomax = 11088, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 696 MHz */ | ||
66 | { .lomax = 11840, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0}, /* 740 MHz */ | ||
67 | { .lomax = 13120, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0}, /* 820 MHz */ | ||
68 | { .lomax = 13840, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0}, /* 865 MHz */ | ||
69 | { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0} /* End */ | ||
45 | }; | 70 | }; |
46 | 71 | ||
47 | static struct freq_entry div_table[] = { | 72 | static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq) |
48 | { 0x1C34, 3 }, | 73 | { |
49 | { 0x0D34, 2 }, | 74 | unsigned char tuner_reg[8]; |
50 | { 0x067B, 1 }, | 75 | unsigned char reg2[2]; |
51 | { 0x0000, 0 }, | 76 | u32 N; |
52 | }; | 77 | int i; |
78 | struct tuner *t = i2c_get_clientdata(c); | ||
79 | struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0}; | ||
53 | 80 | ||
54 | static struct freq_entry agc_table[] = { | 81 | if (t->mode == V4L2_TUNER_RADIO) |
55 | { 0x22B4, 0x8F }, | 82 | freq = freq / 1000; |
56 | { 0x0B54, 0x9F }, | ||
57 | { 0x09A4, 0x8F }, | ||
58 | { 0x0554, 0x9F }, | ||
59 | { 0x0000, 0xBF }, | ||
60 | }; | ||
61 | 83 | ||
62 | static __u8 get_freq_entry( struct freq_entry* table, __u16 freq) | 84 | N = freq + ifc; |
63 | { | 85 | i = 0; |
64 | while(table->freq && table->freq > freq) | 86 | while (tda827x_analog[i].lomax < N) { |
65 | table++; | 87 | if(tda827x_analog[i + 1].lomax == 0) |
66 | return table->value; | 88 | break; |
67 | } | 89 | i++; |
90 | } | ||
91 | |||
92 | N = N << tda827x_analog[i].spd; | ||
93 | |||
94 | tuner_reg[0] = 0; | ||
95 | tuner_reg[1] = (unsigned char)(N>>8); | ||
96 | tuner_reg[2] = (unsigned char) N; | ||
97 | tuner_reg[3] = 0x40; | ||
98 | tuner_reg[4] = 0x52 + (t->tda827x_lpsel << 5); | ||
99 | tuner_reg[5] = (tda827x_analog[i].spd << 6) + (tda827x_analog[i].div1p5 <<5) + | ||
100 | (tda827x_analog[i].bs <<3) + tda827x_analog[i].bp; | ||
101 | tuner_reg[6] = 0x8f + (tda827x_analog[i].gc3 << 4); | ||
102 | tuner_reg[7] = 0x8f; | ||
103 | |||
104 | msg.buf = tuner_reg; | ||
105 | msg.len = 8; | ||
106 | i2c_transfer(c->adapter, &msg, 1); | ||
107 | |||
108 | msg.buf= reg2; | ||
109 | msg.len = 2; | ||
110 | reg2[0] = 0x80; | ||
111 | reg2[1] = 0; | ||
112 | i2c_transfer(c->adapter, &msg, 1); | ||
113 | |||
114 | reg2[0] = 0x60; | ||
115 | reg2[1] = 0xbf; | ||
116 | i2c_transfer(c->adapter, &msg, 1); | ||
117 | |||
118 | reg2[0] = 0x30; | ||
119 | reg2[1] = tuner_reg[4] + 0x80; | ||
120 | i2c_transfer(c->adapter, &msg, 1); | ||
121 | |||
122 | msleep(1); | ||
123 | reg2[0] = 0x30; | ||
124 | reg2[1] = tuner_reg[4] + 4; | ||
125 | i2c_transfer(c->adapter, &msg, 1); | ||
126 | |||
127 | msleep(1); | ||
128 | reg2[0] = 0x30; | ||
129 | reg2[1] = tuner_reg[4]; | ||
130 | i2c_transfer(c->adapter, &msg, 1); | ||
68 | 131 | ||
69 | /* ---------------------------------------------------------------------- */ | 132 | msleep(550); |
133 | reg2[0] = 0x30; | ||
134 | reg2[1] = (tuner_reg[4] & 0xfc) + tda827x_analog[i].cp ; | ||
135 | i2c_transfer(c->adapter, &msg, 1); | ||
70 | 136 | ||
71 | static unsigned char i2c_enable_bridge[2] = { 0x21, 0xC0 }; | 137 | reg2[0] = 0x60; |
72 | static unsigned char i2c_disable_bridge[2] = { 0x21, 0x80 }; | 138 | reg2[1] = 0x3f; |
73 | static unsigned char i2c_init_tda8275[14] = { 0x00, 0x00, 0x00, 0x00, | 139 | i2c_transfer(c->adapter, &msg, 1); |
74 | 0xfC, 0x04, 0xA3, 0x3F, | ||
75 | 0x2A, 0x04, 0xFF, 0x00, | ||
76 | 0x00, 0x40 }; | ||
77 | static unsigned char i2c_set_VS[2] = { 0x30, 0x6F }; | ||
78 | static unsigned char i2c_set_GP01_CF[2] = { 0x20, 0x0B }; | ||
79 | static unsigned char i2c_tda8290_reset[2] = { 0x00, 0x00 }; | ||
80 | static unsigned char i2c_tda8290_standby[2] = { 0x00, 0x02 }; | ||
81 | static unsigned char i2c_gainset_off[2] = { 0x28, 0x14 }; | ||
82 | static unsigned char i2c_gainset_on[2] = { 0x28, 0x54 }; | ||
83 | static unsigned char i2c_agc3_00[2] = { 0x80, 0x00 }; | ||
84 | static unsigned char i2c_agc2_BF[2] = { 0x60, 0xBF }; | ||
85 | static unsigned char i2c_cb1_D0[2] = { 0x30, 0xD0 }; | ||
86 | static unsigned char i2c_cb1_D2[2] = { 0x30, 0xD2 }; | ||
87 | static unsigned char i2c_cb1_56[2] = { 0x30, 0x56 }; | ||
88 | static unsigned char i2c_cb1_52[2] = { 0x30, 0x52 }; | ||
89 | static unsigned char i2c_cb1_50[2] = { 0x30, 0x50 }; | ||
90 | static unsigned char i2c_agc2_7F[2] = { 0x60, 0x7F }; | ||
91 | static unsigned char i2c_agc3_08[2] = { 0x80, 0x08 }; | ||
92 | |||
93 | static struct i2c_msg i2c_msg_init[] = { | ||
94 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_init_tda8275), i2c_init_tda8275 }, | ||
95 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge }, | ||
96 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_set_VS), i2c_set_VS }, | ||
97 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_set_GP01_CF), i2c_set_GP01_CF }, | ||
98 | }; | ||
99 | 140 | ||
100 | static struct i2c_msg i2c_msg_prolog[] = { | 141 | reg2[0] = 0x80; |
101 | // { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_easy_mode), i2c_easy_mode }, | 142 | reg2[1] = 0x08; // Vsync en |
102 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_off), i2c_gainset_off }, | 143 | i2c_transfer(c->adapter, &msg, 1); |
103 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_reset), i2c_tda8290_reset }, | 144 | } |
104 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge }, | ||
105 | }; | ||
106 | 145 | ||
107 | static struct i2c_msg i2c_msg_config[] = { | 146 | static void tda827x_agcf(struct i2c_client *c) |
108 | // { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_set_freq), i2c_set_freq }, | 147 | { |
109 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc3_00), i2c_agc3_00 }, | 148 | struct tuner *t = i2c_get_clientdata(c); |
110 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc2_BF), i2c_agc2_BF }, | 149 | unsigned char data[] = {0x80, 0x0c}; |
111 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D2), i2c_cb1_D2 }, | 150 | struct i2c_msg msg = {.addr = t->tda827x_addr, .buf = data, |
112 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_56), i2c_cb1_56 }, | 151 | .flags = 0, .len = 2}; |
113 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_52), i2c_cb1_52 }, | 152 | i2c_transfer(c->adapter, &msg, 1); |
114 | }; | 153 | } |
115 | 154 | ||
116 | static struct i2c_msg i2c_msg_epilog[] = { | 155 | /* ---------------------------------------------------------------------- */ |
117 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_50), i2c_cb1_50 }, | 156 | |
118 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc2_7F), i2c_agc2_7F }, | 157 | struct tda827xa_data { |
119 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_agc3_08), i2c_agc3_08 }, | 158 | u32 lomax; |
120 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge }, | 159 | u8 svco; |
121 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_gainset_on), i2c_gainset_on }, | 160 | u8 spd; |
161 | u8 scr; | ||
162 | u8 sbs; | ||
163 | u8 gc3; | ||
122 | }; | 164 | }; |
123 | 165 | ||
124 | static struct i2c_msg i2c_msg_standby[] = { | 166 | static struct tda827xa_data tda827xa_analog[] = { |
125 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_enable_bridge), i2c_enable_bridge }, | 167 | { .lomax = 910, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 3}, /* 56.875 MHz */ |
126 | { I2C_ADDR_TDA8275, 0, ARRAY_SIZE(i2c_cb1_D0), i2c_cb1_D0 }, | 168 | { .lomax = 1076, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, /* 67.25 MHz */ |
127 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_disable_bridge), i2c_disable_bridge }, | 169 | { .lomax = 1300, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, /* 81.25 MHz */ |
128 | { I2C_ADDR_TDA8290, 0, ARRAY_SIZE(i2c_tda8290_standby), i2c_tda8290_standby }, | 170 | { .lomax = 1560, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3}, /* 97.5 MHz */ |
171 | { .lomax = 1820, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1}, /* 113.75 MHz */ | ||
172 | { .lomax = 2152, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 134.5 MHz */ | ||
173 | { .lomax = 2464, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 154 MHz */ | ||
174 | { .lomax = 2600, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 162.5 MHz */ | ||
175 | { .lomax = 2928, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1}, /* 183 MHz */ | ||
176 | { .lomax = 3120, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1}, /* 195 MHz */ | ||
177 | { .lomax = 3640, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 3}, /* 227.5 MHz */ | ||
178 | { .lomax = 4304, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 3}, /* 269 MHz */ | ||
179 | { .lomax = 5200, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1}, /* 325 MHz */ | ||
180 | { .lomax = 6240, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3}, /* 390 MHz */ | ||
181 | { .lomax = 7280, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3}, /* 455 MHz */ | ||
182 | { .lomax = 8320, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, /* 520 MHz */ | ||
183 | { .lomax = 8608, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1}, /* 538 MHz */ | ||
184 | { .lomax = 8864, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1}, /* 554 MHz */ | ||
185 | { .lomax = 9920, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, /* 620 MHz */ | ||
186 | { .lomax = 10400, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, /* 650 MHz */ | ||
187 | { .lomax = 11200, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, /* 700 MHz */ | ||
188 | { .lomax = 12480, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, /* 780 MHz */ | ||
189 | { .lomax = 13120, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0}, /* 820 MHz */ | ||
190 | { .lomax = 13920, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0}, /* 870 MHz */ | ||
191 | { .lomax = 14576, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0}, /* 911 MHz */ | ||
192 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} /* End */ | ||
129 | }; | 193 | }; |
130 | 194 | ||
131 | static int tda8290_tune(struct i2c_client *c) | 195 | static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq) |
132 | { | 196 | { |
197 | unsigned char tuner_reg[14]; | ||
198 | unsigned char reg2[2]; | ||
199 | u32 N; | ||
200 | int i; | ||
133 | struct tuner *t = i2c_get_clientdata(c); | 201 | struct tuner *t = i2c_get_clientdata(c); |
134 | struct i2c_msg easy_mode = | 202 | struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0}; |
135 | { I2C_ADDR_TDA8290, 0, 2, t->i2c_easy_mode }; | ||
136 | struct i2c_msg set_freq = | ||
137 | { I2C_ADDR_TDA8275, 0, 8, t->i2c_set_freq }; | ||
138 | 203 | ||
139 | i2c_transfer(c->adapter, &easy_mode, 1); | 204 | if (t->mode == V4L2_TUNER_RADIO) |
140 | i2c_transfer(c->adapter, i2c_msg_prolog, ARRAY_SIZE(i2c_msg_prolog)); | 205 | freq = freq / 1000; |
141 | 206 | ||
142 | i2c_transfer(c->adapter, &set_freq, 1); | 207 | N = freq + ifc; |
143 | i2c_transfer(c->adapter, i2c_msg_config, ARRAY_SIZE(i2c_msg_config)); | 208 | i = 0; |
209 | while (tda827xa_analog[i].lomax < N) { | ||
210 | if(tda827xa_analog[i + 1].lomax == 0) | ||
211 | break; | ||
212 | i++; | ||
213 | } | ||
214 | |||
215 | N = N << tda827xa_analog[i].spd; | ||
216 | |||
217 | tuner_reg[0] = 0; | ||
218 | tuner_reg[1] = (unsigned char)(N>>8); | ||
219 | tuner_reg[2] = (unsigned char) N; | ||
220 | tuner_reg[3] = 0; | ||
221 | tuner_reg[4] = 0x16; | ||
222 | tuner_reg[5] = (tda827xa_analog[i].spd << 5) + (tda827xa_analog[i].svco << 3) + | ||
223 | tda827xa_analog[i].sbs; | ||
224 | tuner_reg[6] = 0x8b + (tda827xa_analog[i].gc3 << 4); | ||
225 | tuner_reg[7] = 0x0c; | ||
226 | tuner_reg[8] = 4; | ||
227 | tuner_reg[9] = 0x20; | ||
228 | tuner_reg[10] = 0xff; | ||
229 | tuner_reg[11] = 0xe0; | ||
230 | tuner_reg[12] = 0; | ||
231 | tuner_reg[13] = 0x39 + (t->tda827x_lpsel << 1); | ||
232 | |||
233 | msg.buf = tuner_reg; | ||
234 | msg.len = 14; | ||
235 | i2c_transfer(c->adapter, &msg, 1); | ||
236 | |||
237 | msg.buf= reg2; | ||
238 | msg.len = 2; | ||
239 | reg2[0] = 0x60; | ||
240 | reg2[1] = 0x3c; | ||
241 | i2c_transfer(c->adapter, &msg, 1); | ||
242 | |||
243 | reg2[0] = 0xa0; | ||
244 | reg2[1] = 0xc0; | ||
245 | i2c_transfer(c->adapter, &msg, 1); | ||
246 | |||
247 | msleep(2); | ||
248 | reg2[0] = 0x30; | ||
249 | reg2[1] = 0x10 + tda827xa_analog[i].scr; | ||
250 | i2c_transfer(c->adapter, &msg, 1); | ||
144 | 251 | ||
145 | msleep(550); | 252 | msleep(550); |
146 | i2c_transfer(c->adapter, i2c_msg_epilog, ARRAY_SIZE(i2c_msg_epilog)); | 253 | reg2[0] = 0x50; |
147 | return 0; | 254 | reg2[1] = 0x8f + (tda827xa_analog[i].gc3 << 4); |
255 | i2c_transfer(c->adapter, &msg, 1); | ||
256 | |||
257 | reg2[0] = 0x80; | ||
258 | reg2[1] = 0x28; | ||
259 | i2c_transfer(c->adapter, &msg, 1); | ||
260 | |||
261 | reg2[0] = 0xb0; | ||
262 | reg2[1] = 0x01; | ||
263 | i2c_transfer(c->adapter, &msg, 1); | ||
264 | |||
265 | reg2[0] = 0xc0; | ||
266 | reg2[1] = 0x19 + (t->tda827x_lpsel << 1); | ||
267 | i2c_transfer(c->adapter, &msg, 1); | ||
148 | } | 268 | } |
149 | 269 | ||
150 | static void set_frequency(struct tuner *t, u16 ifc, unsigned int freq) | 270 | static void tda827xa_agcf(struct i2c_client *c) |
151 | { | 271 | { |
152 | u32 N; | 272 | struct tuner *t = i2c_get_clientdata(c); |
273 | unsigned char data[] = {0x80, 0x2c}; | ||
274 | struct i2c_msg msg = {.addr = t->tda827x_addr, .buf = data, | ||
275 | .flags = 0, .len = 2}; | ||
276 | i2c_transfer(c->adapter, &msg, 1); | ||
277 | } | ||
153 | 278 | ||
154 | if (t->mode == V4L2_TUNER_RADIO) | 279 | /*---------------------------------------------------------------------*/ |
155 | freq = freq / 1000; | ||
156 | 280 | ||
157 | N = (((freq<<3)+ifc)&0x3fffc); | 281 | static void tda8290_i2c_bridge(struct i2c_client *c, int close) |
158 | 282 | { | |
159 | N = N >> get_freq_entry(div_table, freq); | 283 | unsigned char enable[2] = { 0x21, 0xC0 }; |
160 | t->i2c_set_freq[0] = 0; | 284 | unsigned char disable[2] = { 0x21, 0x80 }; |
161 | t->i2c_set_freq[1] = (unsigned char)(N>>8); | 285 | unsigned char *msg; |
162 | t->i2c_set_freq[2] = (unsigned char) N; | 286 | if(close) { |
163 | t->i2c_set_freq[3] = 0x40; | 287 | msg = enable; |
164 | t->i2c_set_freq[4] = 0x52; | 288 | i2c_master_send(c, msg, 2); |
165 | t->i2c_set_freq[5] = get_freq_entry(band_table, freq); | 289 | /* let the bridge stabilize */ |
166 | t->i2c_set_freq[6] = get_freq_entry(agc_table, freq); | 290 | msleep(20); |
167 | t->i2c_set_freq[7] = 0x8f; | 291 | } else { |
292 | msg = disable; | ||
293 | i2c_master_send(c, msg, 2); | ||
294 | } | ||
168 | } | 295 | } |
169 | 296 | ||
297 | /*---------------------------------------------------------------------*/ | ||
298 | |||
299 | static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) | ||
300 | { | ||
301 | struct tuner *t = i2c_get_clientdata(c); | ||
302 | unsigned char soft_reset[] = { 0x00, 0x00 }; | ||
303 | unsigned char easy_mode[] = { 0x01, t->tda8290_easy_mode }; | ||
304 | unsigned char expert_mode[] = { 0x01, 0x80 }; | ||
305 | unsigned char gainset_off[] = { 0x28, 0x14 }; | ||
306 | unsigned char if_agc_spd[] = { 0x0f, 0x88 }; | ||
307 | unsigned char adc_head_6[] = { 0x05, 0x04 }; | ||
308 | unsigned char adc_head_9[] = { 0x05, 0x02 }; | ||
309 | unsigned char adc_head_12[] = { 0x05, 0x01 }; | ||
310 | unsigned char pll_bw_nom[] = { 0x0d, 0x47 }; | ||
311 | unsigned char pll_bw_low[] = { 0x0d, 0x27 }; | ||
312 | unsigned char gainset_2[] = { 0x28, 0x64 }; | ||
313 | unsigned char agc_rst_on[] = { 0x0e, 0x0b }; | ||
314 | unsigned char agc_rst_off[] = { 0x0e, 0x09 }; | ||
315 | unsigned char if_agc_set[] = { 0x0f, 0x81 }; | ||
316 | unsigned char addr_adc_sat = 0x1a; | ||
317 | unsigned char addr_agc_stat = 0x1d; | ||
318 | unsigned char addr_pll_stat = 0x1b; | ||
319 | unsigned char adc_sat, agc_stat, | ||
320 | pll_stat; | ||
321 | |||
322 | i2c_master_send(c, easy_mode, 2); | ||
323 | i2c_master_send(c, soft_reset, 2); | ||
324 | msleep(1); | ||
325 | |||
326 | expert_mode[1] = t->tda8290_easy_mode + 0x80; | ||
327 | i2c_master_send(c, expert_mode, 2); | ||
328 | i2c_master_send(c, gainset_off, 2); | ||
329 | i2c_master_send(c, if_agc_spd, 2); | ||
330 | if (t->tda8290_easy_mode & 0x60) | ||
331 | i2c_master_send(c, adc_head_9, 2); | ||
332 | else | ||
333 | i2c_master_send(c, adc_head_6, 2); | ||
334 | i2c_master_send(c, pll_bw_nom, 2); | ||
335 | |||
336 | tda8290_i2c_bridge(c, 1); | ||
337 | if (t->tda827x_ver != 0) | ||
338 | tda827xa_tune(c, ifc, freq); | ||
339 | else | ||
340 | tda827x_tune(c, ifc, freq); | ||
341 | /* adjust headroom resp. gain */ | ||
342 | i2c_master_send(c, &addr_adc_sat, 1); | ||
343 | i2c_master_recv(c, &adc_sat, 1); | ||
344 | i2c_master_send(c, &addr_agc_stat, 1); | ||
345 | i2c_master_recv(c, &agc_stat, 1); | ||
346 | i2c_master_send(c, &addr_pll_stat, 1); | ||
347 | i2c_master_recv(c, &pll_stat, 1); | ||
348 | if (pll_stat & 0x80) | ||
349 | tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat); | ||
350 | else | ||
351 | tuner_dbg("tda8290 not locked, no signal?\n"); | ||
352 | if ((agc_stat > 115) || (!(pll_stat & 0x80) && (adc_sat < 20))) { | ||
353 | tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n", | ||
354 | agc_stat, adc_sat, pll_stat & 0x80); | ||
355 | i2c_master_send(c, gainset_2, 2); | ||
356 | msleep(100); | ||
357 | i2c_master_send(c, &addr_agc_stat, 1); | ||
358 | i2c_master_recv(c, &agc_stat, 1); | ||
359 | i2c_master_send(c, &addr_pll_stat, 1); | ||
360 | i2c_master_recv(c, &pll_stat, 1); | ||
361 | if ((agc_stat > 115) || !(pll_stat & 0x80)) { | ||
362 | tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", | ||
363 | agc_stat, pll_stat & 0x80); | ||
364 | if (t->tda827x_ver != 0) | ||
365 | tda827xa_agcf(c); | ||
366 | else | ||
367 | tda827x_agcf(c); | ||
368 | msleep(100); | ||
369 | i2c_master_send(c, &addr_agc_stat, 1); | ||
370 | i2c_master_recv(c, &agc_stat, 1); | ||
371 | i2c_master_send(c, &addr_pll_stat, 1); | ||
372 | i2c_master_recv(c, &pll_stat, 1); | ||
373 | if((agc_stat > 115) || !(pll_stat & 0x80)) { | ||
374 | tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat); | ||
375 | i2c_master_send(c, adc_head_12, 2); | ||
376 | i2c_master_send(c, pll_bw_low, 2); | ||
377 | msleep(100); | ||
378 | } | ||
379 | } | ||
380 | } | ||
381 | |||
382 | /* l/ l' deadlock? */ | ||
383 | if(t->tda8290_easy_mode & 0x60) { | ||
384 | i2c_master_send(c, &addr_adc_sat, 1); | ||
385 | i2c_master_recv(c, &adc_sat, 1); | ||
386 | i2c_master_send(c, &addr_pll_stat, 1); | ||
387 | i2c_master_recv(c, &pll_stat, 1); | ||
388 | if ((adc_sat > 20) || !(pll_stat & 0x80)) { | ||
389 | tuner_dbg("trying to resolve SECAM L deadlock\n"); | ||
390 | i2c_master_send(c, agc_rst_on, 2); | ||
391 | msleep(40); | ||
392 | i2c_master_send(c, agc_rst_off, 2); | ||
393 | } | ||
394 | } | ||
395 | |||
396 | tda8290_i2c_bridge(c, 0); | ||
397 | i2c_master_send(c, if_agc_set, 2); | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | |||
402 | /*---------------------------------------------------------------------*/ | ||
403 | |||
170 | #define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) | 404 | #define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) |
171 | #define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) | 405 | #define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) |
172 | #define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) | 406 | #define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H) |
@@ -174,20 +408,37 @@ static void set_frequency(struct tuner *t, u16 ifc, unsigned int freq) | |||
174 | 408 | ||
175 | static void set_audio(struct tuner *t) | 409 | static void set_audio(struct tuner *t) |
176 | { | 410 | { |
177 | t->i2c_easy_mode[0] = 0x01; | 411 | char* mode; |
178 | 412 | ||
179 | if (t->std & V4L2_STD_MN) | 413 | t->tda827x_lpsel = 0; |
180 | t->i2c_easy_mode[1] = 0x01; | 414 | mode = "xx"; |
181 | else if (t->std & V4L2_STD_B) | 415 | if (t->std & V4L2_STD_MN) { |
182 | t->i2c_easy_mode[1] = 0x02; | 416 | t->sgIF = 92; |
183 | else if (t->std & V4L2_STD_GH) | 417 | t->tda8290_easy_mode = 0x01; |
184 | t->i2c_easy_mode[1] = 0x04; | 418 | t->tda827x_lpsel = 1; |
185 | else if (t->std & V4L2_STD_PAL_I) | 419 | mode = "MN"; |
186 | t->i2c_easy_mode[1] = 0x08; | 420 | } else if (t->std & V4L2_STD_B) { |
187 | else if (t->std & V4L2_STD_DK) | 421 | t->sgIF = 108; |
188 | t->i2c_easy_mode[1] = 0x10; | 422 | t->tda8290_easy_mode = 0x02; |
189 | else if (t->std & V4L2_STD_SECAM_L) | 423 | mode = "B"; |
190 | t->i2c_easy_mode[1] = 0x20; | 424 | } else if (t->std & V4L2_STD_GH) { |
425 | t->sgIF = 124; | ||
426 | t->tda8290_easy_mode = 0x04; | ||
427 | mode = "GH"; | ||
428 | } else if (t->std & V4L2_STD_PAL_I) { | ||
429 | t->sgIF = 124; | ||
430 | t->tda8290_easy_mode = 0x08; | ||
431 | mode = "I"; | ||
432 | } else if (t->std & V4L2_STD_DK) { | ||
433 | t->sgIF = 124; | ||
434 | t->tda8290_easy_mode = 0x10; | ||
435 | mode = "DK"; | ||
436 | } else if (t->std & V4L2_STD_SECAM_L) { | ||
437 | t->sgIF = 124; | ||
438 | t->tda8290_easy_mode = 0x20; | ||
439 | mode = "L"; | ||
440 | } | ||
441 | tuner_dbg("setting tda8290 to system %s\n", mode); | ||
191 | } | 442 | } |
192 | 443 | ||
193 | static void set_tv_freq(struct i2c_client *c, unsigned int freq) | 444 | static void set_tv_freq(struct i2c_client *c, unsigned int freq) |
@@ -195,15 +446,13 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
195 | struct tuner *t = i2c_get_clientdata(c); | 446 | struct tuner *t = i2c_get_clientdata(c); |
196 | 447 | ||
197 | set_audio(t); | 448 | set_audio(t); |
198 | set_frequency(t, 864, freq); | 449 | tda8290_tune(c, t->sgIF, freq); |
199 | tda8290_tune(c); | ||
200 | } | 450 | } |
201 | 451 | ||
202 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) | 452 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) |
203 | { | 453 | { |
204 | struct tuner *t = i2c_get_clientdata(c); | 454 | /* if frequency is 5.5 MHz */ |
205 | set_frequency(t, 704, freq); | 455 | tda8290_tune(c, 88, freq); |
206 | tda8290_tune(c); | ||
207 | } | 456 | } |
208 | 457 | ||
209 | static int has_signal(struct i2c_client *c) | 458 | static int has_signal(struct i2c_client *c) |
@@ -216,27 +465,145 @@ static int has_signal(struct i2c_client *c) | |||
216 | return (afc & 0x80)? 65535:0; | 465 | return (afc & 0x80)? 65535:0; |
217 | } | 466 | } |
218 | 467 | ||
468 | /*---------------------------------------------------------------------*/ | ||
469 | |||
219 | static void standby(struct i2c_client *c) | 470 | static void standby(struct i2c_client *c) |
220 | { | 471 | { |
221 | i2c_transfer(c->adapter, i2c_msg_standby, ARRAY_SIZE(i2c_msg_standby)); | 472 | struct tuner *t = i2c_get_clientdata(c); |
473 | unsigned char cb1[] = { 0x30, 0xD0 }; | ||
474 | unsigned char tda8290_standby[] = { 0x00, 0x02 }; | ||
475 | struct i2c_msg msg = {.addr = t->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; | ||
476 | |||
477 | tda8290_i2c_bridge(c, 1); | ||
478 | if (t->tda827x_ver != 0) | ||
479 | cb1[1] = 0x90; | ||
480 | i2c_transfer(c->adapter, &msg, 1); | ||
481 | tda8290_i2c_bridge(c, 0); | ||
482 | i2c_master_send(c, tda8290_standby, 2); | ||
222 | } | 483 | } |
223 | 484 | ||
224 | int tda8290_init(struct i2c_client *c) | 485 | |
486 | static void tda8290_init_if(struct i2c_client *c) | ||
487 | { | ||
488 | unsigned char set_VS[] = { 0x30, 0x6F }; | ||
489 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; | ||
490 | |||
491 | i2c_master_send(c, set_VS, 2); | ||
492 | i2c_master_send(c, set_GP01_CF, 2); | ||
493 | } | ||
494 | |||
495 | static void tda8290_init_tuner(struct i2c_client *c) | ||
225 | { | 496 | { |
226 | struct tuner *t = i2c_get_clientdata(c); | 497 | struct tuner *t = i2c_get_clientdata(c); |
498 | unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, | ||
499 | 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; | ||
500 | unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, | ||
501 | 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; | ||
502 | struct i2c_msg msg = {.addr = t->tda827x_addr, .flags=0, | ||
503 | .buf=tda8275_init, .len = 14}; | ||
504 | if (t->tda827x_ver != 0) | ||
505 | msg.buf = tda8275a_init; | ||
506 | |||
507 | tda8290_i2c_bridge(c, 1); | ||
508 | i2c_transfer(c->adapter, &msg, 1); | ||
509 | tda8290_i2c_bridge(c, 0); | ||
510 | } | ||
227 | 511 | ||
228 | strlcpy(c->name, "tda8290+75", sizeof(c->name)); | 512 | /*---------------------------------------------------------------------*/ |
513 | |||
514 | int tda8290_init(struct i2c_client *c) | ||
515 | { | ||
516 | struct tuner *t = i2c_get_clientdata(c); | ||
517 | u8 data; | ||
518 | int i, ret, tuners_found; | ||
519 | u32 tuner_addrs; | ||
520 | struct i2c_msg msg = {.flags=I2C_M_RD, .buf=&data, .len = 1}; | ||
521 | |||
522 | tda8290_i2c_bridge(c, 1); | ||
523 | /* probe for tuner chip */ | ||
524 | tuners_found = 0; | ||
525 | tuner_addrs = 0; | ||
526 | for (i=0x60; i<= 0x63; i++) { | ||
527 | msg.addr = i; | ||
528 | ret = i2c_transfer(c->adapter, &msg, 1); | ||
529 | if (ret == 1) { | ||
530 | tuners_found++; | ||
531 | tuner_addrs = (tuner_addrs << 8) + i; | ||
532 | } | ||
533 | } | ||
534 | /* if there is more than one tuner, we expect the right one is | ||
535 | behind the bridge and we choose the highest address that doesn't | ||
536 | give a response now | ||
537 | */ | ||
538 | tda8290_i2c_bridge(c, 0); | ||
539 | if(tuners_found > 1) | ||
540 | for (i = 0; i < tuners_found; i++) { | ||
541 | msg.addr = tuner_addrs & 0xff; | ||
542 | ret = i2c_transfer(c->adapter, &msg, 1); | ||
543 | if(ret == 1) | ||
544 | tuner_addrs = tuner_addrs >> 8; | ||
545 | else | ||
546 | break; | ||
547 | } | ||
548 | if (tuner_addrs == 0) { | ||
549 | tuner_addrs = 0x61; | ||
550 | tuner_info ("could not clearly identify tuner address, defaulting to %x\n", | ||
551 | tuner_addrs); | ||
552 | } else { | ||
553 | tuner_addrs = tuner_addrs & 0xff; | ||
554 | tuner_info ("setting tuner address to %x\n", tuner_addrs); | ||
555 | } | ||
556 | t->tda827x_addr = tuner_addrs; | ||
557 | msg.addr = tuner_addrs; | ||
558 | |||
559 | tda8290_i2c_bridge(c, 1); | ||
560 | ret = i2c_transfer(c->adapter, &msg, 1); | ||
561 | if( ret != 1) | ||
562 | tuner_warn ("TDA827x access failed!\n"); | ||
563 | if ((data & 0x3c) == 0) { | ||
564 | strlcpy(c->name, "tda8290+75", sizeof(c->name)); | ||
565 | t->tda827x_ver = 0; | ||
566 | } else { | ||
567 | strlcpy(c->name, "tda8290+75a", sizeof(c->name)); | ||
568 | t->tda827x_ver = 2; | ||
569 | } | ||
229 | tuner_info("tuner: type set to %s\n", c->name); | 570 | tuner_info("tuner: type set to %s\n", c->name); |
571 | |||
230 | t->tv_freq = set_tv_freq; | 572 | t->tv_freq = set_tv_freq; |
231 | t->radio_freq = set_radio_freq; | 573 | t->radio_freq = set_radio_freq; |
232 | t->has_signal = has_signal; | 574 | t->has_signal = has_signal; |
233 | t->standby = standby; | 575 | t->standby = standby; |
576 | t->tda827x_lpsel = 0; | ||
234 | 577 | ||
235 | i2c_master_send(c, i2c_enable_bridge, ARRAY_SIZE(i2c_enable_bridge)); | 578 | tda8290_init_tuner(c); |
236 | i2c_transfer(c->adapter, i2c_msg_init, ARRAY_SIZE(i2c_msg_init)); | 579 | tda8290_init_if(c); |
237 | return 0; | 580 | return 0; |
238 | } | 581 | } |
239 | 582 | ||
583 | int tda8290_probe(struct i2c_client *c) | ||
584 | { | ||
585 | unsigned char soft_reset[] = { 0x00, 0x00 }; | ||
586 | unsigned char easy_mode_b[] = { 0x01, 0x02 }; | ||
587 | unsigned char easy_mode_g[] = { 0x01, 0x04 }; | ||
588 | unsigned char addr_dto_lsb = 0x07; | ||
589 | unsigned char data; | ||
590 | |||
591 | i2c_master_send(c, easy_mode_b, 2); | ||
592 | i2c_master_send(c, soft_reset, 2); | ||
593 | i2c_master_send(c, &addr_dto_lsb, 1); | ||
594 | i2c_master_recv(c, &data, 1); | ||
595 | if (data == 0) { | ||
596 | i2c_master_send(c, easy_mode_g, 2); | ||
597 | i2c_master_send(c, soft_reset, 2); | ||
598 | i2c_master_send(c, &addr_dto_lsb, 1); | ||
599 | i2c_master_recv(c, &data, 1); | ||
600 | if (data == 0x7b) { | ||
601 | return 0; | ||
602 | } | ||
603 | } | ||
604 | return -1; | ||
605 | } | ||
606 | |||
240 | /* | 607 | /* |
241 | * Overrides for Emacs so that we follow Linus's tabbing style. | 608 | * Overrides for Emacs so that we follow Linus's tabbing style. |
242 | * --------------------------------------------------------------------------- | 609 | * --------------------------------------------------------------------------- |