Skip to content

Commit

Permalink
[media] rtl28xxu: add support for Rafael Micro r820t
Browse files Browse the repository at this point in the history
This tuner is used on some rtl2882 dongles. Add it to the driver.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Tested-by: Antti Palosaari <crope@iki.fi>
  • Loading branch information
Mauro Carvalho Chehab committed Apr 17, 2013
1 parent a80abc5 commit 6889ab2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/media/usb/dvb-usb-v2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ config DVB_USB_RTL28XXU
select MEDIA_TUNER_FC0013 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_E4000 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_FC2580 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_R820T if MEDIA_SUBDRV_AUTOSELECT
help
Say Y here to support the Realtek RTL28xxU DVB USB receiver.

30 changes: 30 additions & 0 deletions drivers/media/usb/dvb-usb-v2/rtl28xxu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "e4000.h"
#include "fc2580.h"
#include "tua9001.h"
#include "r820t.h"

DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);

Expand Down Expand Up @@ -375,6 +376,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d)
struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf};
struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf};
struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf};
struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 5, buf};

dev_dbg(&d->udev->dev, "%s:\n", __func__);

Expand Down Expand Up @@ -479,6 +481,14 @@ static int rtl2832u_read_config(struct dvb_usb_device *d)
goto found;
}

/* check R820T by reading tuner stats at I2C addr 0x1a */
ret = rtl28xxu_ctrl_msg(d, &req_r820t);
if (ret == 0) {
priv->tuner = TUNER_RTL2832_R820T;
priv->tuner_name = "R820T";
goto found;
}

found:
dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name);

Expand Down Expand Up @@ -589,6 +599,12 @@ static struct rtl2832_config rtl28xxu_rtl2832_e4000_config = {
.tuner = TUNER_RTL2832_E4000,
};

static struct rtl2832_config rtl28xxu_rtl2832_r820t_config = {
.i2c_addr = 0x10,
.xtal = 28800000,
.tuner = TUNER_RTL2832_R820T,
};

static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d,
int cmd, int arg)
{
Expand Down Expand Up @@ -728,6 +744,9 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
case TUNER_RTL2832_E4000:
rtl2832_config = &rtl28xxu_rtl2832_e4000_config;
break;
case TUNER_RTL2832_R820T:
rtl2832_config = &rtl28xxu_rtl2832_r820t_config;
break;
default:
dev_err(&d->udev->dev, "%s: unknown tuner=%s\n",
KBUILD_MODNAME, priv->tuner_name);
Expand Down Expand Up @@ -840,6 +859,13 @@ static const struct fc0012_config rtl2832u_fc0012_config = {
.xtal_freq = FC_XTAL_28_8_MHZ,
};

static const struct r820t_config rtl2832u_r820t_config = {
.i2c_addr = 0x1a,
.xtal = 28800000,
.max_i2c_msg_len = 2,
.rafael_chip = CHIP_R820T,
};

static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
{
int ret;
Expand Down Expand Up @@ -889,6 +915,10 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
fe = dvb_attach(tua9001_attach, adap->fe[0], &d->i2c_adap,
&rtl2832u_tua9001_config);
break;
case TUNER_RTL2832_R820T:
fe = dvb_attach(r820t_attach, adap->fe[0], &d->i2c_adap,
&rtl2832u_r820t_config);
break;
default:
fe = NULL;
dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
Expand Down
1 change: 1 addition & 0 deletions drivers/media/usb/dvb-usb-v2/rtl28xxu.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ enum rtl28xxu_tuner {
TUNER_RTL2832_E4000,
TUNER_RTL2832_TDA18272,
TUNER_RTL2832_FC0013,
TUNER_RTL2832_R820T,
};

struct rtl28xxu_req {
Expand Down

0 comments on commit 6889ab2

Please sign in to comment.