[media] af9035: Add fc0011 tuner support

This adds Fitipower fc0011 tuner support to the af9035 driver.

Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Michael Büsch 2012-04-02 12:18:36 -03:00 committed by Mauro Carvalho Chehab
parent eea977ed63
commit ffc501f654
4 changed files with 154 additions and 0 deletions

View File

@ -428,6 +428,7 @@ config DVB_USB_AF9035
depends on DVB_USB
select DVB_AF9033
select MEDIA_TUNER_TUA9001 if !MEDIA_TUNER_CUSTOMISE
select MEDIA_TUNER_FC0011 if !MEDIA_TUNER_CUSTOMISE
help
Say Y here to support the Afatech AF9035 based DVB USB receiver.

View File

@ -22,6 +22,7 @@
#include "af9035.h"
#include "af9033.h"
#include "tua9001.h"
#include "fc0011.h"
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
static DEFINE_MUTEX(af9035_usb_mutex);
@ -498,6 +499,7 @@ static int af9035_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
switch (tmp) {
case AF9033_TUNER_TUA9001:
case AF9033_TUNER_FC0011:
af9035_af9033_config[i].spec_inv = 1;
break;
default:
@ -542,6 +544,83 @@ err:
return ret;
}
static int af9035_fc0011_tuner_callback(struct dvb_usb_device *d,
int cmd, int arg)
{
int err;
switch (cmd) {
case FC0011_FE_CALLBACK_POWER:
/* Tuner enable */
err = af9035_wr_reg_mask(d, 0xd8eb, 1, 1);
if (err)
return err;
err = af9035_wr_reg_mask(d, 0xd8ec, 1, 1);
if (err)
return err;
err = af9035_wr_reg_mask(d, 0xd8ed, 1, 1);
if (err)
return err;
/* LED */
err = af9035_wr_reg_mask(d, 0xd8d0, 1, 1);
if (err)
return err;
err = af9035_wr_reg_mask(d, 0xd8d1, 1, 1);
if (err)
return err;
msleep(10);
break;
case FC0011_FE_CALLBACK_RESET:
err = af9035_wr_reg(d, 0xd8e9, 1);
if (err)
return err;
err = af9035_wr_reg(d, 0xd8e8, 1);
if (err)
return err;
err = af9035_wr_reg(d, 0xd8e7, 1);
if (err)
return err;
msleep(10);
err = af9035_wr_reg(d, 0xd8e7, 0);
if (err)
return err;
msleep(10);
break;
default:
return -EINVAL;
}
return 0;
}
static int af9035_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
{
switch (af9035_af9033_config[0].tuner) {
case AF9033_TUNER_FC0011:
return af9035_fc0011_tuner_callback(d, cmd, arg);
default:
break;
}
return -ENODEV;
}
static int af9035_frontend_callback(void *adapter_priv, int component,
int cmd, int arg)
{
struct i2c_adapter *adap = adapter_priv;
struct dvb_usb_device *d = i2c_get_adapdata(adap);
switch (component) {
case DVB_FRONTEND_COMPONENT_TUNER:
return af9035_tuner_callback(d, cmd, arg);
default:
break;
}
return -EINVAL;
}
static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
{
int ret;
@ -570,6 +649,7 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
ret = -ENODEV;
goto err;
}
adap->fe_adap[0].fe->callback = af9035_frontend_callback;
return 0;
@ -583,6 +663,10 @@ static struct tua9001_config af9035_tua9001_config = {
.i2c_addr = 0x60,
};
static const struct fc0011_config af9035_fc0011_config = {
.i2c_address = 0x60,
};
static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
{
int ret;
@ -631,6 +715,10 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
fe = dvb_attach(tua9001_attach, adap->fe_adap[0].fe,
&adap->dev->i2c_adap, &af9035_tua9001_config);
break;
case AF9033_TUNER_FC0011:
fe = dvb_attach(fc0011_attach, adap->fe_adap[0].fe,
&adap->dev->i2c_adap, &af9035_fc0011_config);
break;
default:
fe = NULL;
}

View File

@ -297,6 +297,10 @@ static int af9033_init(struct dvb_frontend *fe)
len = ARRAY_SIZE(tuner_init_tua9001);
init = tuner_init_tua9001;
break;
case AF9033_TUNER_FC0011:
len = ARRAY_SIZE(tuner_init_fc0011);
init = tuner_init_fc0011;
break;
default:
pr_debug("%s: unsupported tuner ID=%d\n", __func__,
state->cfg.tuner);

View File

@ -336,5 +336,66 @@ static const struct reg_val tuner_init_tua9001[] = {
{ 0x80f1e6, 0x00 },
};
/* Fitipower fc0011 tuner init
AF9033_TUNER_FC0011 = 0x28 */
static const struct reg_val tuner_init_fc0011[] = {
{ 0x800046, AF9033_TUNER_FC0011 },
{ 0x800057, 0x00 },
{ 0x800058, 0x01 },
{ 0x80005f, 0x00 },
{ 0x800060, 0x00 },
{ 0x800068, 0xa5 },
{ 0x80006e, 0x01 },
{ 0x800071, 0x0A },
{ 0x800072, 0x02 },
{ 0x800074, 0x01 },
{ 0x800079, 0x01 },
{ 0x800093, 0x00 },
{ 0x800094, 0x00 },
{ 0x800095, 0x00 },
{ 0x800096, 0x00 },
{ 0x80009b, 0x2D },
{ 0x80009c, 0x60 },
{ 0x80009d, 0x23 },
{ 0x8000a4, 0x50 },
{ 0x8000ad, 0x50 },
{ 0x8000b3, 0x01 },
{ 0x8000b7, 0x88 },
{ 0x8000b8, 0xa6 },
{ 0x8000c3, 0x01 },
{ 0x8000c4, 0x01 },
{ 0x8000c7, 0x69 },
{ 0x80F007, 0x00 },
{ 0x80F00A, 0x1B },
{ 0x80F00B, 0x1B },
{ 0x80F00C, 0x1B },
{ 0x80F00D, 0x1B },
{ 0x80F00E, 0xFF },
{ 0x80F00F, 0x01 },
{ 0x80F010, 0x00 },
{ 0x80F011, 0x02 },
{ 0x80F012, 0xFF },
{ 0x80F013, 0x01 },
{ 0x80F014, 0x00 },
{ 0x80F015, 0x02 },
{ 0x80F01B, 0xEF },
{ 0x80F01C, 0x01 },
{ 0x80F01D, 0x0f },
{ 0x80F01E, 0x02 },
{ 0x80F01F, 0x6E },
{ 0x80F020, 0x00 },
{ 0x80F025, 0xDE },
{ 0x80F026, 0x00 },
{ 0x80F027, 0x0A },
{ 0x80F028, 0x03 },
{ 0x80F029, 0x6E },
{ 0x80F02A, 0x00 },
{ 0x80F047, 0x00 },
{ 0x80F054, 0x00 },
{ 0x80F055, 0x00 },
{ 0x80F077, 0x01 },
{ 0x80F1E6, 0x00 },
};
#endif /* AF9033_PRIV_H */