Commit 13a5336e authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] em28xx: implement FE set_lna() callback

Make LNA run-time switching possible for PCTV nanoStick T2 290e!
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent aa3c598b
...@@ -81,6 +81,7 @@ struct em28xx_dvb { ...@@ -81,6 +81,7 @@ struct em28xx_dvb {
int (*gate_ctrl)(struct dvb_frontend *, int); int (*gate_ctrl)(struct dvb_frontend *, int);
struct semaphore pll_mutex; struct semaphore pll_mutex;
bool dont_attach_fe1; bool dont_attach_fe1;
int lna_gpio;
}; };
...@@ -568,6 +569,33 @@ static void pctv_520e_init(struct em28xx *dev) ...@@ -568,6 +569,33 @@ static void pctv_520e_init(struct em28xx *dev)
i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len);
}; };
static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe, int val)
{
struct em28xx *dev = fe->dvb->priv;
#ifdef CONFIG_GPIOLIB
struct em28xx_dvb *dvb = dev->dvb;
int ret;
unsigned long flags;
if (val)
flags = GPIOF_OUT_INIT_LOW;
else
flags = GPIOF_OUT_INIT_HIGH;
ret = gpio_request_one(dvb->lna_gpio, flags, NULL);
if (ret)
em28xx_errdev("gpio request failed %d\n", ret);
else
gpio_free(dvb->lna_gpio);
return ret;
#else
dev_warn(&dev->udev->dev, "%s: LNA control is disabled\n",
KBUILD_MODNAME);
return 0;
#endif
}
static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe) static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe)
{ {
/* Values extracted from a USB trace of the Terratec Windows driver */ /* 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,7 +837,7 @@ static void em28xx_unregister_dvb(struct em28xx_dvb *dvb)
static int em28xx_dvb_init(struct em28xx *dev) static int em28xx_dvb_init(struct em28xx *dev)
{ {
int result = 0, mfe_shared = 0, gpio_chip_base; int result = 0, mfe_shared = 0;
struct em28xx_dvb *dvb; struct em28xx_dvb *dvb;
if (!dev->board.has_dvb) { if (!dev->board.has_dvb) {
...@@ -958,7 +986,7 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -958,7 +986,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
dvb->fe[0] = dvb_attach(cxd2820r_attach, dvb->fe[0] = dvb_attach(cxd2820r_attach,
&em28xx_cxd2820r_config, &em28xx_cxd2820r_config,
&dev->i2c_adap, &dev->i2c_adap,
&gpio_chip_base); &dvb->lna_gpio);
if (dvb->fe[0]) { if (dvb->fe[0]) {
/* FE 0 attach tuner */ /* FE 0 attach tuner */
if (!dvb_attach(tda18271_attach, if (!dvb_attach(tda18271_attach,
...@@ -973,15 +1001,18 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -973,15 +1001,18 @@ static int em28xx_dvb_init(struct em28xx *dev)
} }
} }
#ifdef CONFIG_GPIOLIB
/* enable LNA for DVB-T, DVB-T2 and DVB-C */ /* enable LNA for DVB-T, DVB-T2 and DVB-C */
result = gpio_request_one(gpio_chip_base, GPIOF_INIT_LOW, result = gpio_request_one(dvb->lna_gpio, GPIOF_OUT_INIT_LOW,
"LNA"); NULL);
if (result) if (result)
em28xx_errdev("gpio request failed %d\n", result); em28xx_errdev("gpio request failed %d\n", result);
else else
gpio_free(gpio_chip_base); gpio_free(dvb->lna_gpio);
result = 0; /* continue even set LNA fails */ result = 0; /* continue even set LNA fails */
#endif
dvb->fe[0]->ops.set_lna = em28xx_pctv_290e_set_lna;
break; break;
case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment