diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2006-06-25 14:34:39 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-30 14:59:32 -0400 |
commit | ba8fc39954bf3bc51f502e8a02f959d45edd096c (patch) | |
tree | 3846895bb42d759c6650e1487300296955ba2833 /drivers/media/video/tuner-simple.c | |
parent | 0a1153736f97db48e6bc9ab27e90b51ab50729c7 (diff) |
V4L/DVB (4270): Add tda9887-specific tuner configuration
Many tda9887 settings depend on the chosen tuner. Expand the tuner parameters
to include these tda9887 settings.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tuner-simple.c')
-rw-r--r-- | drivers/media/video/tuner-simple.c | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 6da6f82b8c88..d071c5cbf013 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/i2c.h> | 7 | #include <linux/i2c.h> |
8 | #include <linux/videodev.h> | 8 | #include <linux/videodev.h> |
9 | #include <media/tuner.h> | 9 | #include <media/tuner.h> |
10 | #include <media/v4l2-common.h> | ||
10 | 11 | ||
11 | static int offset = 0; | 12 | static int offset = 0; |
12 | module_param(offset, int, 0666); | 13 | module_param(offset, int, 0666); |
@@ -128,6 +129,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
128 | u8 buffer[4]; | 129 | u8 buffer[4]; |
129 | int rc, IFPCoff, i, j; | 130 | int rc, IFPCoff, i, j; |
130 | enum param_type desired_type; | 131 | enum param_type desired_type; |
132 | struct tuner_params *params; | ||
131 | 133 | ||
132 | tun = &tuners[t->type]; | 134 | tun = &tuners[t->type]; |
133 | 135 | ||
@@ -169,19 +171,20 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
169 | IFPCoff,t->type); | 171 | IFPCoff,t->type); |
170 | j = 0; | 172 | j = 0; |
171 | } | 173 | } |
174 | params = &tun->params[j]; | ||
172 | 175 | ||
173 | for (i = 0; i < tun->params[j].count; i++) { | 176 | for (i = 0; i < params->count; i++) { |
174 | if (freq > tun->params[j].ranges[i].limit) | 177 | if (freq > params->ranges[i].limit) |
175 | continue; | 178 | continue; |
176 | break; | 179 | break; |
177 | } | 180 | } |
178 | if (i == tun->params[j].count) { | 181 | if (i == params->count) { |
179 | tuner_dbg("TV frequency out of range (%d > %d)", | 182 | tuner_dbg("TV frequency out of range (%d > %d)", |
180 | freq, tun->params[j].ranges[i - 1].limit); | 183 | freq, params->ranges[i - 1].limit); |
181 | freq = tun->params[j].ranges[--i].limit; | 184 | freq = params->ranges[--i].limit; |
182 | } | 185 | } |
183 | config = tun->params[j].ranges[i].config; | 186 | config = params->ranges[i].config; |
184 | cb = tun->params[j].ranges[i].cb; | 187 | cb = params->ranges[i].cb; |
185 | /* i == 0 -> VHF_LO | 188 | /* i == 0 -> VHF_LO |
186 | * i == 1 -> VHF_HI | 189 | * i == 1 -> VHF_HI |
187 | * i == 2 -> UHF */ | 190 | * i == 2 -> UHF */ |
@@ -281,7 +284,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
281 | break; | 284 | break; |
282 | } | 285 | } |
283 | 286 | ||
284 | if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) { | 287 | if (params->cb_first_if_lower_freq && div < t->last_div) { |
285 | buffer[0] = config; | 288 | buffer[0] = config; |
286 | buffer[1] = cb; | 289 | buffer[1] = cb; |
287 | buffer[2] = (div>>8) & 0x7f; | 290 | buffer[2] = (div>>8) & 0x7f; |
@@ -293,6 +296,43 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) | |||
293 | buffer[3] = cb; | 296 | buffer[3] = cb; |
294 | } | 297 | } |
295 | t->last_div = div; | 298 | t->last_div = div; |
299 | if (params->has_tda9887) { | ||
300 | int config = 0; | ||
301 | int is_secam_l = (t->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) && | ||
302 | !(t->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)); | ||
303 | |||
304 | if (t->std == V4L2_STD_SECAM_LC) { | ||
305 | if (params->port1_active ^ params->port1_invert_for_secam_lc) | ||
306 | config |= TDA9887_PORT1_ACTIVE; | ||
307 | if (params->port2_active ^ params->port2_invert_for_secam_lc) | ||
308 | config |= TDA9887_PORT2_ACTIVE; | ||
309 | } | ||
310 | else { | ||
311 | if (params->port1_active) | ||
312 | config |= TDA9887_PORT1_ACTIVE; | ||
313 | if (params->port2_active) | ||
314 | config |= TDA9887_PORT2_ACTIVE; | ||
315 | } | ||
316 | if (params->intercarrier_mode) | ||
317 | config |= TDA9887_INTERCARRIER; | ||
318 | if (is_secam_l) { | ||
319 | if (i == 0 && params->default_top_secam_low) | ||
320 | config |= TDA9887_TOP(params->default_top_secam_low); | ||
321 | else if (i == 1 && params->default_top_secam_mid) | ||
322 | config |= TDA9887_TOP(params->default_top_secam_mid); | ||
323 | else if (params->default_top_secam_high) | ||
324 | config |= TDA9887_TOP(params->default_top_secam_high); | ||
325 | } | ||
326 | else { | ||
327 | if (i == 0 && params->default_top_low) | ||
328 | config |= TDA9887_TOP(params->default_top_low); | ||
329 | else if (i == 1 && params->default_top_mid) | ||
330 | config |= TDA9887_TOP(params->default_top_mid); | ||
331 | else if (params->default_top_high) | ||
332 | config |= TDA9887_TOP(params->default_top_high); | ||
333 | } | ||
334 | i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); | ||
335 | } | ||
296 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", | 336 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", |
297 | buffer[0],buffer[1],buffer[2],buffer[3]); | 337 | buffer[0],buffer[1],buffer[2],buffer[3]); |
298 | 338 | ||
@@ -339,6 +379,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
339 | u16 div; | 379 | u16 div; |
340 | int rc, j; | 380 | int rc, j; |
341 | enum param_type desired_type = TUNER_PARAM_TYPE_RADIO; | 381 | enum param_type desired_type = TUNER_PARAM_TYPE_RADIO; |
382 | struct tuner_params *params; | ||
342 | 383 | ||
343 | tun = &tuners[t->type]; | 384 | tun = &tuners[t->type]; |
344 | 385 | ||
@@ -352,7 +393,8 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
352 | j = 0; | 393 | j = 0; |
353 | 394 | ||
354 | div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */ | 395 | div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */ |
355 | buffer[2] = (tun->params[j].ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */ | 396 | params = &tun->params[j]; |
397 | buffer[2] = (params->ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */ | ||
356 | 398 | ||
357 | switch (t->type) { | 399 | switch (t->type) { |
358 | case TUNER_TENA_9533_DI: | 400 | case TUNER_TENA_9533_DI: |
@@ -384,7 +426,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
384 | } | 426 | } |
385 | buffer[0] = (div>>8) & 0x7f; | 427 | buffer[0] = (div>>8) & 0x7f; |
386 | buffer[1] = div & 0xff; | 428 | buffer[1] = div & 0xff; |
387 | if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) { | 429 | if (params->cb_first_if_lower_freq && div < t->last_div) { |
388 | buffer[0] = buffer[2]; | 430 | buffer[0] = buffer[2]; |
389 | buffer[1] = buffer[3]; | 431 | buffer[1] = buffer[3]; |
390 | buffer[2] = (div>>8) & 0x7f; | 432 | buffer[2] = (div>>8) & 0x7f; |
@@ -398,6 +440,18 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) | |||
398 | buffer[0],buffer[1],buffer[2],buffer[3]); | 440 | buffer[0],buffer[1],buffer[2],buffer[3]); |
399 | t->last_div = div; | 441 | t->last_div = div; |
400 | 442 | ||
443 | if (params->has_tda9887) { | ||
444 | int config = 0; | ||
445 | if (params->port1_active && !params->port1_fm_high_sensitivity) | ||
446 | config |= TDA9887_PORT1_ACTIVE; | ||
447 | if (params->port2_active && !params->port2_fm_high_sensitivity) | ||
448 | config |= TDA9887_PORT2_ACTIVE; | ||
449 | if (params->intercarrier_mode) | ||
450 | config |= TDA9887_INTERCARRIER; | ||
451 | /* if (params->port1_set_for_fm_mono) | ||
452 | config &= ~TDA9887_PORT1_ACTIVE;*/ | ||
453 | i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); | ||
454 | } | ||
401 | if (4 != (rc = i2c_master_send(c,buffer,4))) | 455 | if (4 != (rc = i2c_master_send(c,buffer,4))) |
402 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | 456 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); |
403 | } | 457 | } |