diff options
Diffstat (limited to 'drivers/media/video/tea5767.c')
-rw-r--r-- | drivers/media/video/tea5767.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c index b53c748caf2a..4d27ac1b7fb8 100644 --- a/drivers/media/video/tea5767.c +++ b/drivers/media/video/tea5767.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview | 2 | * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview |
3 | * I2C address is allways 0xC0. | 3 | * I2C address is allways 0xC0. |
4 | * | 4 | * |
5 | * $Id: tea5767.c,v 1.18 2005/07/07 03:02:55 mchehab Exp $ | 5 | * $Id: tea5767.c,v 1.21 2005/07/14 03:06:43 mchehab Exp $ |
6 | * | 6 | * |
7 | * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) | 7 | * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) |
8 | * This code is placed under the terms of the GNU General Public License | 8 | * This code is placed under the terms of the GNU General Public License |
@@ -153,17 +153,17 @@ static void tea5767_status_dump(unsigned char *buffer) | |||
153 | 153 | ||
154 | switch (TEA5767_HIGH_LO_32768) { | 154 | switch (TEA5767_HIGH_LO_32768) { |
155 | case TEA5767_HIGH_LO_13MHz: | 155 | case TEA5767_HIGH_LO_13MHz: |
156 | frq = 1000 * (div * 50 - 700 - 225) / 4; /* Freq in KHz */ | 156 | frq = (div * 50000 - 700000 - 225000) / 4; /* Freq in KHz */ |
157 | break; | 157 | break; |
158 | case TEA5767_LOW_LO_13MHz: | 158 | case TEA5767_LOW_LO_13MHz: |
159 | frq = 1000 * (div * 50 + 700 + 225) / 4; /* Freq in KHz */ | 159 | frq = (div * 50000 + 700000 + 225000) / 4; /* Freq in KHz */ |
160 | break; | 160 | break; |
161 | case TEA5767_LOW_LO_32768: | 161 | case TEA5767_LOW_LO_32768: |
162 | frq = 1000 * (div * 32768 / 1000 + 700 + 225) / 4; /* Freq in KHz */ | 162 | frq = (div * 32768 + 700000 + 225000) / 4; /* Freq in KHz */ |
163 | break; | 163 | break; |
164 | case TEA5767_HIGH_LO_32768: | 164 | case TEA5767_HIGH_LO_32768: |
165 | default: | 165 | default: |
166 | frq = 1000 * (div * 32768 / 1000 - 700 - 225) / 4; /* Freq in KHz */ | 166 | frq = (div * 32768 - 700000 - 225000) / 4; /* Freq in KHz */ |
167 | break; | 167 | break; |
168 | } | 168 | } |
169 | buffer[0] = (div >> 8) & 0x3f; | 169 | buffer[0] = (div >> 8) & 0x3f; |
@@ -196,7 +196,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) | |||
196 | unsigned div; | 196 | unsigned div; |
197 | int rc; | 197 | int rc; |
198 | 198 | ||
199 | tuner_dbg (PREFIX "radio freq counter %d\n", frq); | 199 | tuner_dbg (PREFIX "radio freq = %d.%03d MHz\n", frq/16000,(frq/16)%1000); |
200 | 200 | ||
201 | /* Rounds freq to next decimal value - for 62.5 KHz step */ | 201 | /* Rounds freq to next decimal value - for 62.5 KHz step */ |
202 | /* frq = 20*(frq/16)+radio_frq[frq%16]; */ | 202 | /* frq = 20*(frq/16)+radio_frq[frq%16]; */ |
@@ -224,19 +224,19 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) | |||
224 | tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n"); | 224 | tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n"); |
225 | buffer[2] |= TEA5767_HIGH_LO_INJECT; | 225 | buffer[2] |= TEA5767_HIGH_LO_INJECT; |
226 | buffer[4] |= TEA5767_PLLREF_ENABLE; | 226 | buffer[4] |= TEA5767_PLLREF_ENABLE; |
227 | div = (frq * 4 / 16 + 700 + 225 + 25) / 50; | 227 | div = (frq * 4000 / 16 + 700000 + 225000 + 25000) / 50000; |
228 | break; | 228 | break; |
229 | case TEA5767_LOW_LO_13MHz: | 229 | case TEA5767_LOW_LO_13MHz: |
230 | tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n"); | 230 | tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n"); |
231 | 231 | ||
232 | buffer[4] |= TEA5767_PLLREF_ENABLE; | 232 | buffer[4] |= TEA5767_PLLREF_ENABLE; |
233 | div = (frq * 4 / 16 - 700 - 225 + 25) / 50; | 233 | div = (frq * 4000 / 16 - 700000 - 225000 + 25000) / 50000; |
234 | break; | 234 | break; |
235 | case TEA5767_LOW_LO_32768: | 235 | case TEA5767_LOW_LO_32768: |
236 | tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n"); | 236 | tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n"); |
237 | buffer[3] |= TEA5767_XTAL_32768; | 237 | buffer[3] |= TEA5767_XTAL_32768; |
238 | /* const 700=4000*175 Khz - to adjust freq to right value */ | 238 | /* const 700=4000*175 Khz - to adjust freq to right value */ |
239 | div = (1000 * (frq * 4 / 16 - 700 - 225) + 16384) >> 15; | 239 | div = ((frq * 4000 / 16 - 700000 - 225000) + 16384) >> 15; |
240 | break; | 240 | break; |
241 | case TEA5767_HIGH_LO_32768: | 241 | case TEA5767_HIGH_LO_32768: |
242 | default: | 242 | default: |
@@ -244,17 +244,21 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) | |||
244 | 244 | ||
245 | buffer[2] |= TEA5767_HIGH_LO_INJECT; | 245 | buffer[2] |= TEA5767_HIGH_LO_INJECT; |
246 | buffer[3] |= TEA5767_XTAL_32768; | 246 | buffer[3] |= TEA5767_XTAL_32768; |
247 | div = (1000 * (frq * 4 / 16 + 700 + 225) + 16384) >> 15; | 247 | div = ((frq * (4000 / 16) + 700000 + 225000) + 16384) >> 15; |
248 | break; | 248 | break; |
249 | } | 249 | } |
250 | buffer[0] = (div >> 8) & 0x3f; | 250 | buffer[0] = (div >> 8) & 0x3f; |
251 | buffer[1] = div & 0xff; | 251 | buffer[1] = div & 0xff; |
252 | 252 | ||
253 | if (tuner_debug) | ||
254 | tea5767_status_dump(buffer); | ||
255 | |||
256 | if (5 != (rc = i2c_master_send(c, buffer, 5))) | 253 | if (5 != (rc = i2c_master_send(c, buffer, 5))) |
257 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); | 254 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); |
255 | |||
256 | if (tuner_debug) { | ||
257 | if (5 != (rc = i2c_master_recv(c, buffer, 5))) | ||
258 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); | ||
259 | else | ||
260 | tea5767_status_dump(buffer); | ||
261 | } | ||
258 | } | 262 | } |
259 | 263 | ||
260 | static int tea5767_signal(struct i2c_client *c) | 264 | static int tea5767_signal(struct i2c_client *c) |
@@ -294,7 +298,7 @@ int tea5767_autodetection(struct i2c_client *c) | |||
294 | struct tuner *t = i2c_get_clientdata(c); | 298 | struct tuner *t = i2c_get_clientdata(c); |
295 | 299 | ||
296 | if (5 != (rc = i2c_master_recv(c, buffer, 5))) { | 300 | if (5 != (rc = i2c_master_recv(c, buffer, 5))) { |
297 | tuner_warn("it is not a TEA5767. Received %i chars.\n", rc); | 301 | tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc); |
298 | return EINVAL; | 302 | return EINVAL; |
299 | } | 303 | } |
300 | 304 | ||
@@ -310,11 +314,11 @@ int tea5767_autodetection(struct i2c_client *c) | |||
310 | * bit 0 : internally set to 0 | 314 | * bit 0 : internally set to 0 |
311 | * Byte 5: bit 7:0 : == 0 | 315 | * Byte 5: bit 7:0 : == 0 |
312 | */ | 316 | */ |
313 | |||
314 | if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { | 317 | if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { |
315 | tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); | 318 | tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); |
316 | return EINVAL; | 319 | return EINVAL; |
317 | } | 320 | } |
321 | |||
318 | tuner_warn("TEA5767 detected.\n"); | 322 | tuner_warn("TEA5767 detected.\n"); |
319 | return 0; | 323 | return 0; |
320 | } | 324 | } |