aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-07-19 21:28:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-01 16:07:05 -0400
commit13a5336e88b5b23047db643bb9cac2cef7548c6c (patch)
tree2ea4ef2381e6f7cf2d0bbf2394d56635f37ac366 /drivers/media
parentaa3c598b008782afd9b7c4ccef670d114786cece (diff)
[media] em28xx: implement FE set_lna() callback
Make LNA run-time switching possible for PCTV nanoStick T2 290e! Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 34c5ea996031..3e5c42de6359 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -81,6 +81,7 @@ struct em28xx_dvb {
81 int (*gate_ctrl)(struct dvb_frontend *, int); 81 int (*gate_ctrl)(struct dvb_frontend *, int);
82 struct semaphore pll_mutex; 82 struct semaphore pll_mutex;
83 bool dont_attach_fe1; 83 bool dont_attach_fe1;
84 int lna_gpio;
84}; 85};
85 86
86 87
@@ -568,6 +569,33 @@ static void pctv_520e_init(struct em28xx *dev)
568 i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); 569 i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len);
569}; 570};
570 571
572static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe, int val)
573{
574 struct em28xx *dev = fe->dvb->priv;
575#ifdef CONFIG_GPIOLIB
576 struct em28xx_dvb *dvb = dev->dvb;
577 int ret;
578 unsigned long flags;
579
580 if (val)
581 flags = GPIOF_OUT_INIT_LOW;
582 else
583 flags = GPIOF_OUT_INIT_HIGH;
584
585 ret = gpio_request_one(dvb->lna_gpio, flags, NULL);
586 if (ret)
587 em28xx_errdev("gpio request failed %d\n", ret);
588 else
589 gpio_free(dvb->lna_gpio);
590
591 return ret;
592#else
593 dev_warn(&dev->udev->dev, "%s: LNA control is disabled\n",
594 KBUILD_MODNAME);
595 return 0;
596#endif
597}
598
571static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe) 599static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe)
572{ 600{
573 /* Values extracted from a USB trace of the Terratec Windows driver */ 601 /* Values extracted from a USB trace of the Terratec Windows driver */
@@ -809,7 +837,7 @@ static void em28xx_unregister_dvb(struct em28xx_dvb *dvb)
809 837
810static int em28xx_dvb_init(struct em28xx *dev) 838static int em28xx_dvb_init(struct em28xx *dev)
811{ 839{
812 int result = 0, mfe_shared = 0, gpio_chip_base; 840 int result = 0, mfe_shared = 0;
813 struct em28xx_dvb *dvb; 841 struct em28xx_dvb *dvb;
814 842
815 if (!dev->board.has_dvb) { 843 if (!dev->board.has_dvb) {
@@ -958,7 +986,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
958 dvb->fe[0] = dvb_attach(cxd2820r_attach, 986 dvb->fe[0] = dvb_attach(cxd2820r_attach,
959 &em28xx_cxd2820r_config, 987 &em28xx_cxd2820r_config,
960 &dev->i2c_adap, 988 &dev->i2c_adap,
961 &gpio_chip_base); 989 &dvb->lna_gpio);
962 if (dvb->fe[0]) { 990 if (dvb->fe[0]) {
963 /* FE 0 attach tuner */ 991 /* FE 0 attach tuner */
964 if (!dvb_attach(tda18271_attach, 992 if (!dvb_attach(tda18271_attach,
@@ -973,15 +1001,18 @@ static int em28xx_dvb_init(struct em28xx *dev)
973 } 1001 }
974 } 1002 }
975 1003
1004#ifdef CONFIG_GPIOLIB
976 /* enable LNA for DVB-T, DVB-T2 and DVB-C */ 1005 /* enable LNA for DVB-T, DVB-T2 and DVB-C */
977 result = gpio_request_one(gpio_chip_base, GPIOF_INIT_LOW, 1006 result = gpio_request_one(dvb->lna_gpio, GPIOF_OUT_INIT_LOW,
978 "LNA"); 1007 NULL);
979 if (result) 1008 if (result)
980 em28xx_errdev("gpio request failed %d\n", result); 1009 em28xx_errdev("gpio request failed %d\n", result);
981 else 1010 else
982 gpio_free(gpio_chip_base); 1011 gpio_free(dvb->lna_gpio);
983 1012
984 result = 0; /* continue even set LNA fails */ 1013 result = 0; /* continue even set LNA fails */
1014#endif
1015 dvb->fe[0]->ops.set_lna = em28xx_pctv_290e_set_lna;
985 break; 1016 break;
986 case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: 1017 case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
987 { 1018 {