Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] tuner-core: Change config from unsigned int to void *

config looks like a hack that was added to tuner-core to allow some
configuration of TDA8290 tuner (it's not used by any other driver).
But with the new configuration options of tda8290 driver (no_i2c_gate
and std_map), it's no longer sufficient.
Change config to be void * instead, which allows passing tuner-dependent
config struct to drivers.
Also update saa7134 driver to reflect this change (no other driver uses this).

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Ondrej Zary and committed by
Mauro Carvalho Chehab
cdcd141c 5b0e5350

+30 -35
+20 -20
drivers/media/pci/saa7134/saa7134-cards.c
··· 2760 2760 .radio_type = UNSET, 2761 2761 .tuner_addr = ADDR_UNSET, 2762 2762 .radio_addr = ADDR_UNSET, 2763 - .tuner_config = 0, 2763 + .tda829x_conf = { .lna_cfg = 0 }, 2764 2764 .mpeg = SAA7134_MPEG_DVB, 2765 2765 .gpiomask = 0x0200000, 2766 2766 .inputs = {{ ··· 3291 3291 .radio_type = UNSET, 3292 3292 .tuner_addr = ADDR_UNSET, 3293 3293 .radio_addr = ADDR_UNSET, 3294 - .tuner_config = 1, 3294 + .tda829x_conf = { .lna_cfg = 1 }, 3295 3295 .mpeg = SAA7134_MPEG_DVB, 3296 3296 .gpiomask = 0x000200000, 3297 3297 .inputs = {{ ··· 3395 3395 .radio_type = UNSET, 3396 3396 .tuner_addr = ADDR_UNSET, 3397 3397 .radio_addr = ADDR_UNSET, 3398 - .tuner_config = 1, 3398 + .tda829x_conf = { .lna_cfg = 1 }, 3399 3399 .mpeg = SAA7134_MPEG_DVB, 3400 3400 .gpiomask = 0x0200100, 3401 3401 .inputs = {{ ··· 3426 3426 .radio_type = UNSET, 3427 3427 .tuner_addr = ADDR_UNSET, 3428 3428 .radio_addr = ADDR_UNSET, 3429 - .tuner_config = 3, 3429 + .tda829x_conf = { .lna_cfg = 3 }, 3430 3430 .mpeg = SAA7134_MPEG_DVB, 3431 3431 .ts_type = SAA7134_MPEG_TS_SERIAL, 3432 3432 .ts_force_val = 1, ··· 3459 3459 .radio_type = UNSET, 3460 3460 .tuner_addr = ADDR_UNSET, 3461 3461 .radio_addr = ADDR_UNSET, 3462 - .tuner_config = 3, 3462 + .tda829x_conf = { .lna_cfg = 3 }, 3463 3463 .mpeg = SAA7134_MPEG_DVB, 3464 3464 .ts_type = SAA7134_MPEG_TS_SERIAL, 3465 3465 .gpiomask = 0x0800100, /* GPIO 21 is an INPUT */ ··· 3683 3683 .radio_type = UNSET, 3684 3684 .tuner_addr = ADDR_UNSET, 3685 3685 .radio_addr = ADDR_UNSET, 3686 - .tuner_config = 2, 3686 + .tda829x_conf = { .lna_cfg = 2 }, 3687 3687 .mpeg = SAA7134_MPEG_DVB, 3688 3688 .gpiomask = 0x0200000, 3689 3689 .inputs = {{ ··· 3736 3736 .radio_type = UNSET, 3737 3737 .tuner_addr = ADDR_UNSET, 3738 3738 .radio_addr = ADDR_UNSET, 3739 - .tuner_config = 2, 3739 + .tda829x_conf = { .lna_cfg = 2 }, 3740 3740 .mpeg = SAA7134_MPEG_DVB, 3741 3741 .gpiomask = 0x0200000, 3742 3742 .inputs = {{ ··· 3754 3754 .radio_type = UNSET, 3755 3755 .tuner_addr = ADDR_UNSET, 3756 3756 .radio_addr = ADDR_UNSET, 3757 - .tuner_config = 2, 3757 + .tda829x_conf = { .lna_cfg = 2 }, 3758 3758 .gpiomask = 1 << 21, 3759 3759 .mpeg = SAA7134_MPEG_DVB, 3760 3760 .inputs = {{ ··· 3887 3887 .radio_type = UNSET, 3888 3888 .tuner_addr = ADDR_UNSET, 3889 3889 .radio_addr = ADDR_UNSET, 3890 - .tuner_config = 0, 3890 + .tda829x_conf = { .lna_cfg = 0 }, 3891 3891 .mpeg = SAA7134_MPEG_DVB, 3892 3892 .inputs = {{ 3893 3893 .name = name_tv, /* FIXME: analog tv untested */ ··· 3903 3903 .radio_type = UNSET, 3904 3904 .tuner_addr = ADDR_UNSET, 3905 3905 .radio_addr = ADDR_UNSET, 3906 - .tuner_config = 2, 3906 + .tda829x_conf = { .lna_cfg = 2 }, 3907 3907 .gpiomask = 0x020200000, 3908 3908 .inputs = {{ 3909 3909 .name = name_tv, ··· 3937 3937 .radio_type = UNSET, 3938 3938 .tuner_addr = ADDR_UNSET, 3939 3939 .radio_addr = ADDR_UNSET, 3940 - .tuner_config = 0, 3940 + .tda829x_conf = { .lna_cfg = 0 }, 3941 3941 .gpiomask = 0x020200000, 3942 3942 .inputs = {{ 3943 3943 .name = name_tv, ··· 4737 4737 .radio_type = UNSET, 4738 4738 .tuner_addr = ADDR_UNSET, 4739 4739 .radio_addr = ADDR_UNSET, 4740 - .tuner_config = 2, 4740 + .tda829x_conf = { .lna_cfg = 2 }, 4741 4741 .mpeg = SAA7134_MPEG_DVB, 4742 4742 .gpiomask = 0x0200000, 4743 4743 .inputs = {{ ··· 4823 4823 .radio_type = UNSET, 4824 4824 .tuner_addr = ADDR_UNSET, 4825 4825 .radio_addr = ADDR_UNSET, 4826 - .tuner_config = 0, 4826 + .tda829x_conf = { .lna_cfg = 0 }, 4827 4827 .mpeg = SAA7134_MPEG_DVB, 4828 4828 .inputs = {{ 4829 4829 .name = name_tv, ··· 4847 4847 .radio_type = UNSET, 4848 4848 .tuner_addr = ADDR_UNSET, 4849 4849 .radio_addr = ADDR_UNSET, 4850 - .tuner_config = 2, 4850 + .tda829x_conf = { .lna_cfg = 2 }, 4851 4851 .mpeg = SAA7134_MPEG_DVB, 4852 4852 .gpiomask = 0x0200000, 4853 4853 .inputs = { { ··· 5057 5057 .radio_type = UNSET, 5058 5058 .tuner_addr = ADDR_UNSET, 5059 5059 .radio_addr = ADDR_UNSET, 5060 - .tuner_config = 2, 5060 + .tda829x_conf = { .lna_cfg = 2 }, 5061 5061 .gpiomask = 1 << 21, 5062 5062 .mpeg = SAA7134_MPEG_DVB, 5063 5063 .inputs = {{ ··· 5087 5087 .radio_type = UNSET, 5088 5088 .tuner_addr = ADDR_UNSET, 5089 5089 .radio_addr = ADDR_UNSET, 5090 - .tuner_config = 2, 5090 + .tda829x_conf = { .lna_cfg = 2 }, 5091 5091 .gpiomask = 1 << 21, 5092 5092 .mpeg = SAA7134_MPEG_DVB, 5093 5093 .inputs = {{ ··· 5176 5176 .radio_type = UNSET, 5177 5177 .tuner_addr = ADDR_UNSET, 5178 5178 .radio_addr = ADDR_UNSET, 5179 - .tuner_config = 0, 5179 + .tda829x_conf = { .lna_cfg = 0 }, 5180 5180 .mpeg = SAA7134_MPEG_DVB, 5181 5181 .gpiomask = 0x0200000, 5182 5182 .inputs = { { ··· 5406 5406 .radio_type = UNSET, 5407 5407 .tuner_addr = ADDR_UNSET, 5408 5408 .radio_addr = ADDR_UNSET, 5409 - .tuner_config = 0, 5409 + .tda829x_conf = { .lna_cfg = 0 }, 5410 5410 .mpeg = SAA7134_MPEG_DVB, 5411 5411 .ts_type = SAA7134_MPEG_TS_PARALLEL, 5412 5412 .inputs = {{ ··· 5629 5629 .audio_clock = 0x00187de7, 5630 5630 .tuner_type = TUNER_PHILIPS_TDA8290, 5631 5631 .radio_type = UNSET, 5632 - .tuner_config = 3, 5632 + .tda829x_conf = { .lna_cfg = 3 }, 5633 5633 .tuner_addr = ADDR_UNSET, 5634 5634 .radio_addr = ADDR_UNSET, 5635 5635 .gpiomask = 0x02050000, ··· 7633 7633 if ((dev->tuner_type != TUNER_ABSENT) && (dev->tuner_type != UNSET)) { 7634 7634 tun_setup.type = dev->tuner_type; 7635 7635 tun_setup.addr = dev->tuner_addr; 7636 - tun_setup.config = saa7134_boards[dev->board].tuner_config; 7636 + tun_setup.config = &saa7134_boards[dev->board].tda829x_conf; 7637 7637 tun_setup.tuner_callback = saa7134_tuner_callback; 7638 7638 7639 7639 tun_setup.mode_mask = mode_mask;
+2 -1
drivers/media/pci/saa7134/saa7134.h
··· 45 45 #if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB) 46 46 #include <media/videobuf-dvb.h> 47 47 #endif 48 + #include "tda8290.h" 48 49 49 50 #define UNSET (-1U) 50 51 ··· 391 390 unsigned char rds_addr; 392 391 393 392 unsigned int tda9887_conf; 394 - unsigned int tuner_config; 393 + struct tda829x_config tda829x_conf; 395 394 396 395 /* peripheral I/O */ 397 396 enum saa7134_video_out video_out;
+7 -13
drivers/media/v4l2-core/tuner-core.c
··· 132 132 bool standby; /* Standby mode */ 133 133 134 134 unsigned int type; /* chip type id */ 135 - unsigned int config; 135 + void *config; 136 136 const char *name; 137 137 }; 138 138 ··· 270 270 * @c: i2c_client descriptoy 271 271 * @type: type of the tuner (e. g. tuner number) 272 272 * @new_mode_mask: Indicates if tuner supports TV and/or Radio 273 - * @new_config: an optional parameter ranging from 0-255 used by 274 - a few tuners to adjust an internal parameter, 275 - like LNA mode 273 + * @new_config: an optional parameter used by a few tuners to adjust 274 + internal parameters, like LNA mode 276 275 * @tuner_callback: an optional function to be called when switching 277 276 * to analog mode 278 277 * ··· 279 280 * by tun_setup structure. It contains several per-tuner initialization "magic" 280 281 */ 281 282 static void set_type(struct i2c_client *c, unsigned int type, 282 - unsigned int new_mode_mask, unsigned int new_config, 283 + unsigned int new_mode_mask, void *new_config, 283 284 int (*tuner_callback) (void *dev, int component, int cmd, int arg)) 284 285 { 285 286 struct tuner *t = to_tuner(i2c_get_clientdata(c)); ··· 294 295 } 295 296 296 297 t->type = type; 297 - /* prevent invalid config values */ 298 - t->config = new_config < 256 ? new_config : 0; 298 + t->config = new_config; 299 299 if (tuner_callback != NULL) { 300 300 tuner_dbg("defining GPIO callback\n"); 301 301 t->fe.callback = tuner_callback; ··· 312 314 break; 313 315 case TUNER_PHILIPS_TDA8290: 314 316 { 315 - struct tda829x_config cfg = { 316 - .lna_cfg = t->config, 317 - }; 318 317 if (!dvb_attach(tda829x_attach, &t->fe, t->i2c->adapter, 319 - t->i2c->addr, &cfg)) 318 + t->i2c->addr, t->config)) 320 319 goto attach_failed; 321 320 break; 322 321 } ··· 402 407 case TUNER_NXP_TDA18271: 403 408 { 404 409 struct tda18271_config cfg = { 405 - .config = t->config, 406 410 .small_i2c = TDA18271_03_BYTE_CHUNK_INIT, 407 411 }; 408 412 ··· 503 509 struct tuner *t = to_tuner(sd); 504 510 struct i2c_client *c = v4l2_get_subdevdata(sd); 505 511 506 - tuner_dbg("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x, config=0x%02x\n", 512 + tuner_dbg("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x, config=%p\n", 507 513 tun_setup->type, 508 514 tun_setup->addr, 509 515 tun_setup->mode_mask,
+1 -1
include/media/tuner.h
··· 192 192 unsigned short addr; /* I2C address */ 193 193 unsigned int type; /* Tuner type */ 194 194 unsigned int mode_mask; /* Allowed tuner modes */ 195 - unsigned int config; /* configuraion for more complex tuners */ 195 + void *config; /* configuraion for more complex tuners */ 196 196 int (*tuner_callback) (void *dev, int component, int cmd, int arg); 197 197 }; 198 198