Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89040136 authored by Martin Blumenstingl's avatar Martin Blumenstingl Committed by Mauro Carvalho Chehab
Browse files

[media] em28xx: Better support for the Terratec Cinergy HTC USB XS



This intializes the card just like the windows driver does

- the "HTC USB XS HD" uses the same firmware as the "HTC Stick HD";
- both have different GPIO and reg init sequences;

Tested only with DVB-C.

Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 74df06da
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1979,6 +1979,15 @@ struct em28xx_board em28xx_boards[] = {
				EM28XX_I2C_CLK_WAIT_ENABLE |
				EM28XX_I2C_FREQ_400_KHZ,
	},
	[EM2884_BOARD_TERRATEC_HTC_USB_XS] = {
		.name         = "Terratec Cinergy HTC USB XS",
		.has_dvb      = 1,
		.ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
		.tuner_type   = TUNER_ABSENT,
		.i2c_speed    = EM2874_I2C_SECONDARY_BUS_SELECT |
				EM28XX_I2C_CLK_WAIT_ENABLE |
				EM28XX_I2C_FREQ_400_KHZ,
	},
};
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);

@@ -2057,9 +2066,9 @@ struct usb_device_id em28xx_id_table[] = {
	{ USB_DEVICE(0x0ccd, 0x0043),
			.driver_info = EM2870_BOARD_TERRATEC_XS },
	{ USB_DEVICE(0x0ccd, 0x008e),	/* Cinergy HTC USB XS Rev. 1 */
			.driver_info = EM2884_BOARD_TERRATEC_H5 },
			.driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
	{ USB_DEVICE(0x0ccd, 0x00ac),	/* Cinergy HTC USB XS Rev. 2 */
			.driver_info = EM2884_BOARD_TERRATEC_H5 },
			.driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
	{ USB_DEVICE(0x0ccd, 0x10a2),	/* H5 Rev. 1 */
			.driver_info = EM2884_BOARD_TERRATEC_H5 },
	{ USB_DEVICE(0x0ccd, 0x10ad),	/* H5 Rev. 2 */
+82 −2
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ static struct drxk_config hauppauge_930c_drxk = {
	.load_firmware_sync = true,
};

struct drxk_config terratec_htc_stick_drxk = {
static struct drxk_config terratec_htc_stick_drxk = {
	.adr = 0x29,
	.single_master = 1,
	.no_i2c_bridge = 1,
@@ -520,7 +520,10 @@ static void terratec_htc_stick_init(struct em28xx *dev)
		{ -1,                   -1,     -1,     -1},
	};

	/* Init the analog decoder? */
	/*
	 * Init the analog decoder (not yet supported), but
	 * it's probably still a good idea.
	 */
	struct {
		unsigned char r[4];
		int len;
@@ -547,6 +550,64 @@ static void terratec_htc_stick_init(struct em28xx *dev)
	em28xx_gpio_set(dev, terratec_htc_stick_end);
};

static void terratec_htc_usb_xs_init(struct em28xx *dev)
{
	int i;

	struct em28xx_reg_seq terratec_htc_usb_xs_init[] = {
		{EM28XX_R08_GPIO,	0xff,	0xff,	10},
		{EM2874_R80_GPIO,	0xb2,	0xff,	100},
		{EM2874_R80_GPIO,	0xb2,	0xff,	50},
		{EM2874_R80_GPIO,	0xb6,	0xff,	100},
		{ -1,                   -1,     -1,     -1},
	};
	struct em28xx_reg_seq terratec_htc_usb_xs_end[] = {
		{EM2874_R80_GPIO,	0xa6,	0xff,	100},
		{EM2874_R80_GPIO,	0xa6,	0xff,	50},
		{EM2874_R80_GPIO,	0xe6,	0xff,	100},
		{ -1,                   -1,     -1,     -1},
	};

	/*
	 * Init the analog decoder (not yet supported), but
	 * it's probably still a good idea.
	 */
	struct {
		unsigned char r[4];
		int len;
	} regs[] = {
		{{ 0x06, 0x02, 0x00, 0x31 }, 4},
		{{ 0x01, 0x02 }, 2},
		{{ 0x01, 0x02, 0x00, 0xc6 }, 4},
		{{ 0x01, 0x00 }, 2},
		{{ 0x01, 0x00, 0xff, 0xaf }, 4},
		{{ 0x01, 0x00, 0x03, 0xa0 }, 4},
		{{ 0x01, 0x00 }, 2},
		{{ 0x01, 0x00, 0x73, 0xaf }, 4},
		{{ 0x04, 0x00 }, 2},
		{{ 0x00, 0x04 }, 2},
		{{ 0x00, 0x04, 0x00, 0x0a }, 4},
		{{ 0x04, 0x14 }, 2},
		{{ 0x04, 0x14, 0x00, 0x00 }, 4},
	};

	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);

	em28xx_gpio_set(dev, terratec_htc_usb_xs_init);

	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
	msleep(10);
	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44);
	msleep(10);

	dev->i2c_client.addr = 0x82 >> 1;

	for (i = 0; i < ARRAY_SIZE(regs); i++)
		i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len);

	em28xx_gpio_set(dev, terratec_htc_usb_xs_end);
};

static void pctv_520e_init(struct em28xx *dev)
{
	/*
@@ -1147,6 +1208,25 @@ static int em28xx_dvb_init(struct em28xx *dev)
			goto out_free;
		}

		/* Attach the demodulator. */
		if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
				&dev->i2c_adap,
				&em28xx_cxd2820r_tda18271_config)) {
			result = -EINVAL;
			goto out_free;
		}
		break;
	case EM2884_BOARD_TERRATEC_HTC_USB_XS:
		terratec_htc_usb_xs_init(dev);

		/* attach demodulator */
		dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk,
					&dev->i2c_adap);
		if (!dvb->fe[0]) {
			result = -EINVAL;
			goto out_free;
		}

		/* Attach the demodulator. */
		if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
				&dev->i2c_adap,
+1 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@
#define EM2874_BOARD_MAXMEDIA_UB425_TC            84
#define EM2884_BOARD_PCTV_510E                    85
#define EM2884_BOARD_PCTV_520E                    86
#define EM2884_BOARD_TERRATEC_HTC_USB_XS	  87

/* Limits minimum and default number of buffers */
#define EM28XX_MIN_BUF 4