linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gon Solo <gonsolo@gmail.com>
To: mchehab+samsung@kernel.org
Cc: sean@mess.org, crope@iki.fi, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, Gon Solo <gonsolo@gmail.com>
Subject: [PATCH] si2157: Add support for Logilink VG0022A.
Date: Wed,  2 Oct 2019 16:13:59 +0200	[thread overview]
Message-ID: <20191002141359.30166-2-gonsolo@gmail.com> (raw)
In-Reply-To: <20191002141359.30166-1-gonsolo@gmail.com>

---
 drivers/media/tuners/si2157.c         | 68 +++++++++++++++++----------
 drivers/media/tuners/si2157_priv.h    |  1 +
 drivers/media/usb/dvb-usb-v2/af9035.c | 47 ++++++++++++++++++
 3 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e87040d6eca7..8f9df2485d51 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -66,6 +66,24 @@ static int si2157_cmd_execute(struct i2c_client *client, struct si2157_cmd *cmd)
 	return ret;
 }
 
+static int si2157_power_up(struct si2157_dev *dev, struct i2c_client *client)
+{
+	struct si2157_cmd cmd;
+
+	if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
+		memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
+		cmd.wlen = 9;
+	} else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
+		memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 10);
+		cmd.wlen = 10;
+	} else {
+		memcpy(cmd.args, "\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15);
+		cmd.wlen = 15;
+	}
+	cmd.rlen = 1;
+	return si2157_cmd_execute(client, &cmd);
+}
+
 static int si2157_init(struct dvb_frontend *fe)
 {
 	struct i2c_client *client = fe->tuner_priv;
@@ -75,7 +93,7 @@ static int si2157_init(struct dvb_frontend *fe)
 	struct si2157_cmd cmd;
 	const struct firmware *fw;
 	const char *fw_name;
-	unsigned int uitmp, chip_id;
+	unsigned int uitmp;
 
 	dev_dbg(&client->dev, "\n");
 
@@ -93,19 +111,7 @@ static int si2157_init(struct dvb_frontend *fe)
 	if (uitmp == dev->if_frequency / 1000)
 		goto warm;
 
-	/* power up */
-	if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
-		memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
-		cmd.wlen = 9;
-	} else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
-		memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 10);
-		cmd.wlen = 10;
-	} else {
-		memcpy(cmd.args, "\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15);
-		cmd.wlen = 15;
-	}
-	cmd.rlen = 1;
-	ret = si2157_cmd_execute(client, &cmd);
+	ret = si2157_power_up(dev, client);
 	if (ret)
 		goto err;
 
@@ -118,17 +124,6 @@ static int si2157_init(struct dvb_frontend *fe)
 			goto err;
 	}
 
-	/* query chip revision */
-	memcpy(cmd.args, "\x02", 1);
-	cmd.wlen = 1;
-	cmd.rlen = 13;
-	ret = si2157_cmd_execute(client, &cmd);
-	if (ret)
-		goto err;
-
-	chip_id = cmd.args[1] << 24 | cmd.args[2] << 16 | cmd.args[3] << 8 |
-			cmd.args[4] << 0;
-
 	#define SI2177_A30 ('A' << 24 | 77 << 16 | '3' << 8 | '0' << 0)
 	#define SI2158_A20 ('A' << 24 | 58 << 16 | '2' << 8 | '0' << 0)
 	#define SI2148_A20 ('A' << 24 | 48 << 16 | '2' << 8 | '0' << 0)
@@ -137,7 +132,7 @@ static int si2157_init(struct dvb_frontend *fe)
 	#define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0)
 	#define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0)
 
-	switch (chip_id) {
+	switch (dev->chip_id) {
 	case SI2158_A20:
 	case SI2148_A20:
 		fw_name = SI2158_A20_FIRMWARE;
@@ -456,6 +451,27 @@ static int si2157_probe(struct i2c_client *client,
 	memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
 	fe->tuner_priv = client;
 
+	ret = si2157_power_up(dev, client);
+	if (ret)
+		goto err;
+	/* query chip revision */
+	/* hack: do it here because after the si2168 gets 0101, commands will
+	 * still be executed here but no result
+	 */
+	memcpy(cmd.args, "\x02", 1);
+	cmd.wlen = 1;
+	cmd.rlen = 13;
+	ret = si2157_cmd_execute(client, &cmd);
+	if (ret)
+		goto err_kfree;
+	dev->chip_id = cmd.args[1] << 24 |
+		cmd.args[2] << 16 |
+		cmd.args[3] << 8 |
+		cmd.args[4] << 0;
+	dev_info(&client->dev, "found a 'Silicon Labs Si21%d-%c%c%c'\n",
+		cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]);
+
+
 #ifdef CONFIG_MEDIA_CONTROLLER
 	if (cfg->mdev) {
 		dev->mdev = cfg->mdev;
diff --git a/drivers/media/tuners/si2157_priv.h b/drivers/media/tuners/si2157_priv.h
index 2bda903358da..9ab7c88b01b4 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -28,6 +28,7 @@ struct si2157_dev {
 	u8 chiptype;
 	u8 if_port;
 	u32 if_frequency;
+	u32 chip_id;
 	struct delayed_work stat_work;
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 3afd18733614..83e243df59b9 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1246,6 +1246,51 @@ static int it930x_frontend_attach(struct dvb_usb_adapter *adap)
 
 	msleep(200);
 
+	if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_DEXATEK) {
+
+		ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01);
+		if (ret < 0)
+			goto err;
+
+		/* I2C master bus 2 clock speed 300k */
+		ret = af9035_wr_reg(d, 0x00f6a7, 0x07);
+		if (ret < 0)
+			goto err;
+
+		/* I2C master bus 1,3 clock speed 300k */
+		ret = af9035_wr_reg(d, 0x00f103, 0x07);
+		if (ret < 0)
+			goto err;
+
+		/* set gpio11 low */
+		ret = af9035_wr_reg_mask(d, 0xd8d4, 0x01, 0x01);
+		if (ret < 0)
+			goto err;
+
+		ret = af9035_wr_reg_mask(d, 0xd8d5, 0x01, 0x01);
+		if (ret < 0)
+			goto err;
+
+		ret = af9035_wr_reg_mask(d, 0xd8d3, 0x01, 0x01);
+		if (ret < 0)
+			goto err;
+
+		/* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */
+		ret = af9035_wr_reg_mask(d, 0xd8b8, 0x01, 0x01);
+		if (ret < 0)
+			goto err;
+
+		ret = af9035_wr_reg_mask(d, 0xd8b9, 0x01, 0x01);
+		if (ret < 0)
+			goto err;
+
+		ret = af9035_wr_reg_mask(d, 0xd8b7, 0x00, 0x01);
+		if (ret < 0)
+			goto err;
+
+		msleep(200);
+	}
+
 	ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01);
 	if (ret < 0)
 		goto err;
@@ -2119,6 +2164,8 @@ static const struct usb_device_id af9035_id_table[] = {
 	/* IT930x devices */
 	{ DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303,
 		&it930x_props, "ITE 9303 Generic", NULL) },
+	{ DVB_USB_DEVICE(USB_VID_DEXATEK, 0x0100,
+		&it930x_props, "Logilink VG0022A", NULL) },
 	{ DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
 		&it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
 	{ }
-- 
2.20.1


  reply	other threads:[~2019-10-02 14:14 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 10:32 DVB-T2 Stick Gonsolo
2019-02-19 21:30 ` Sean Young
2019-10-01 22:19   ` Gonsolo
2019-10-01 23:52     ` Mauro Carvalho Chehab
2019-10-02 14:13       ` [PATCH] si2157: Add support for Logilink VG0022A Gon Solo
2019-10-02 14:13         ` Gon Solo [this message]
2019-10-02 14:27           ` Sean Young
2019-10-02 14:44             ` Gonsolo
2019-10-02 15:06               ` Sean Young
2019-10-02 15:21                 ` Gonsolo
2019-10-02 17:23                   ` JP
2019-10-02 18:49                     ` Mauro Carvalho Chehab
2019-10-03  8:06                       ` [PATCH 0/1] Testing timing patch " Gon Solo
2019-10-03  8:06                       ` [PATCH 1/1] Test Mauros timing patch Gon Solo
2019-10-03 10:13                       ` [PATCH] si2157: Add support for Logilink VG0022A Gonsolo
2019-10-03 10:57                         ` Gonsolo
2019-10-03 11:17                           ` Mauro Carvalho Chehab
2019-10-03 11:41                             ` Gonsolo
2019-10-03 12:49                               ` Mauro Carvalho Chehab
2019-10-03 12:52                                 ` Mauro Carvalho Chehab
2019-10-03 13:02                                   ` Gon Solo
2019-10-03 13:53                                     ` Gonsolo
2019-10-03 14:05                                       ` Mauro Carvalho Chehab
2019-10-03 14:29                                         ` Gonsolo
2019-10-03 12:01                             ` Gon Solo
2019-10-03 12:12                               ` Mauro Carvalho Chehab
2019-10-03 12:20                                 ` Gon Solo
2019-10-03 12:45                                   ` [PATCH 0/3] " Gon Solo
2019-10-03 12:45                                   ` [PATCH 1/3] [PATCH] af9035: Better explain how i2c bus speed is computed Gon Solo
2019-10-03 12:45                                   ` [PATCH 2/3] [PATCH] s2157: Handle bogus chip version Gon Solo
2019-10-03 12:45                                   ` [PATCH 3/3] [PATCH] af9035: Add Logilink VG0022A id Gon Solo
2019-10-03 11:05                         ` [PATCH] si2157: Add support for Logilink VG0022A Mauro Carvalho Chehab
2019-10-03 15:00                           ` Gonsolo
2019-10-03 15:02                             ` Mauro Carvalho Chehab
2019-10-03 15:17                               ` Gonsolo
2019-10-03 16:03                               ` Gon Solo
2019-10-03 16:09                                 ` Mauro Carvalho Chehab
2019-10-03 16:23                                   ` Gon Solo
2019-10-03 17:42                                     ` Mauro Carvalho Chehab
2019-10-03 17:49                                       ` Gonsolo
2019-10-03 18:32                                       ` Gon Solo
2019-10-03 18:42                                         ` JP
2019-10-03 18:50                                           ` Gonsolo
2019-10-03 18:53                                             ` Gonsolo
2019-10-03 19:19                                           ` Gonsolo
2019-10-03 19:39                                             ` Mauro Carvalho Chehab
2019-10-03 19:44                                               ` Mauro Carvalho Chehab
2019-10-03 19:51                                                 ` Gonsolo
2019-10-03 20:03                                                   ` Mauro Carvalho Chehab
2019-10-03 20:32                                                     ` Gonsolo
2019-10-04 11:50                                                     ` JP
2019-10-04 12:08                                                       ` Mauro Carvalho Chehab
2019-10-04 13:15                                                         ` [PATCH 1/4] media: si2168: use bits instead of bool for flags Mauro Carvalho Chehab
2019-10-04 13:15                                                           ` [PATCH 2/4] media: si2168: add support for not loading a firmware Mauro Carvalho Chehab
2019-10-04 13:15                                                           ` [PATCH 3/4] media: af9035: add support for Logilink VG0022A Mauro Carvalho Chehab
2019-10-09 21:44                                                             ` Gon Solo
2019-10-09 22:04                                                               ` Gon Solo
2019-10-10  8:23                                                                 ` Gon Solo
2019-10-10  9:18                                                                 ` Gon Solo
2019-10-10  9:50                                                                   ` [PATCH 0/4] Add " Gon Solo
2019-10-10 10:10                                                                     ` Mauro Carvalho Chehab
2019-10-10  9:51                                                                   ` [PATCH 1/4] si2168: Use bits and convert to kernel-doc format Gon Solo
2019-10-10  9:51                                                                   ` [PATCH 2/4] si2157: Add option for not downloading firmware Gon Solo
2019-10-10  9:51                                                                   ` [PATCH 3/4] af9035: Make speed computation clear Gon Solo
2019-10-10  9:51                                                                   ` [PATCH 4/4] Add support for Logilink VG0022A Gon Solo
2019-10-10 11:44                                                                     ` Gon Solo
2019-11-15 18:06                                                                       ` Gon Solo
2019-10-04 13:15                                                           ` [PATCH 4/4] media: af9035: add the formula used for the I2C speed Mauro Carvalho Chehab
2019-10-10 10:55                                                           ` [PATCH 1/4] media: si2168: use bits instead of bool for flags Gon Solo
2019-10-10 11:34                                                             ` Mauro Carvalho Chehab
2019-10-10 11:42                                                               ` Mauro Carvalho Chehab
2019-10-04 13:50                                                         ` [PATCH] si2157: Add support for Logilink VG0022A JP
2019-10-04 14:16                                                           ` Mauro Carvalho Chehab
2019-10-03 19:40                                             ` Gonsolo
2019-10-03 19:52                                               ` Mauro Carvalho Chehab
2019-10-03 19:57                                                 ` Gonsolo
2019-10-02 15:00           ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191002141359.30166-2-gonsolo@gmail.com \
    --to=gonsolo@gmail.com \
    --cc=crope@iki.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=sean@mess.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).