mirror of
https://github.com/LibreELEC/LibreELEC.tv
synced 2025-09-24 19:46:01 +07:00
218 lines
7.1 KiB
Diff
218 lines
7.1 KiB
Diff
From: Thomas Hollstegge <thomas.hollstegge@gmail.com>
|
|
[v3] media: dvbsky: Add support for MyGica T230C v2
|
|
https://lore.kernel.org/patchwork/cover/904817/
|
|
|
|
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
|
|
index 4d43424..3402b96 100644
|
|
--- a/drivers/media/dvb-frontends/si2168.c
|
|
+++ b/drivers/media/dvb-frontends/si2168.c
|
|
@@ -96,13 +96,15 @@ static int si2168_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
|
|
dev_dbg(&client->dev, "%s acquire: %d\n", __func__, acquire);
|
|
|
|
/* set TS_MODE property */
|
|
- memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
|
|
+ memcpy(cmd.args, "\x14\x00\x01\x10\x00\x00", 6);
|
|
if (acquire)
|
|
cmd.args[4] |= dev->ts_mode;
|
|
else
|
|
cmd.args[4] |= SI2168_TS_TRISTATE;
|
|
if (dev->ts_clock_gapped)
|
|
cmd.args[4] |= 0x40;
|
|
+ cmd.args[4] |= (dev->ts_clock_mode & 0x03) << 4;
|
|
+
|
|
cmd.wlen = 6;
|
|
cmd.rlen = 4;
|
|
ret = si2168_cmd_execute(client, &cmd);
|
|
@@ -644,6 +646,18 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
|
|
if (ret)
|
|
goto err;
|
|
|
|
+ /* set TS frequency */
|
|
+ if (dev->ts_clock_freq) {
|
|
+ memcpy(cmd.args, "\x14\x00\x0d\x10", 4);
|
|
+ cmd.args[4] = ((dev->ts_clock_freq / 10000) >> 0) & 0xff;
|
|
+ cmd.args[5] = ((dev->ts_clock_freq / 10000) >> 8) & 0xff;
|
|
+ cmd.wlen = 6;
|
|
+ cmd.rlen = 4;
|
|
+ ret = si2168_cmd_execute(client, &cmd);
|
|
+ if (ret)
|
|
+ goto err;
|
|
+ }
|
|
+
|
|
memcpy(cmd.args, "\x14\x00\x08\x10\xd7\x05", 6);
|
|
cmd.args[5] |= dev->ts_clock_inv ? 0x00 : 0x10;
|
|
cmd.wlen = 6;
|
|
@@ -1057,6 +1071,10 @@ static int si2168_probe(struct i2c_client *client,
|
|
dev->ts_mode = config->ts_mode;
|
|
dev->ts_clock_inv = config->ts_clock_inv;
|
|
dev->ts_clock_gapped = config->ts_clock_gapped;
|
|
+ dev->ts_clock_mode = config->ts_clock_mode;
|
|
+ if (dev->ts_clock_mode == 0)
|
|
+ dev->ts_clock_mode = SI2168_TS_CLOCK_MODE_AUTO_ADAPT;
|
|
+ dev->ts_clock_freq = config->ts_clock_freq;
|
|
dev->spectral_inversion = config->spectral_inversion;
|
|
|
|
dev_info(&client->dev, "Silicon Labs Si2168-%c%d%d successfully identified\n",
|
|
diff --git a/drivers/media/dvb-frontends/si2168.h b/drivers/media/dvb-frontends/si2168.h
|
|
index d519edd..3f52ee8 100644
|
|
--- a/drivers/media/dvb-frontends/si2168.h
|
|
+++ b/drivers/media/dvb-frontends/si2168.h
|
|
@@ -47,6 +47,14 @@ struct si2168_config {
|
|
/* TS clock gapped */
|
|
bool ts_clock_gapped;
|
|
|
|
+ /* TS clock mode */
|
|
+#define SI2168_TS_CLOCK_MODE_AUTO_ADAPT 0x01
|
|
+#define SI2168_TS_CLOCK_MODE_MANUAL 0x02
|
|
+ u8 ts_clock_mode;
|
|
+
|
|
+ /* TS clock frequency (for manual mode) */
|
|
+ u32 ts_clock_freq;
|
|
+
|
|
/* Inverted spectrum */
|
|
bool spectral_inversion;
|
|
};
|
|
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h
|
|
index 2d362e1..8173d6c 100644
|
|
--- a/drivers/media/dvb-frontends/si2168_priv.h
|
|
+++ b/drivers/media/dvb-frontends/si2168_priv.h
|
|
@@ -48,6 +48,8 @@ struct si2168_dev {
|
|
u8 ts_mode;
|
|
bool ts_clock_inv;
|
|
bool ts_clock_gapped;
|
|
+ u8 ts_clock_mode;
|
|
+ u32 ts_clock_freq;
|
|
bool spectral_inversion;
|
|
};
|
|
|
|
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
|
|
index e28bd88..4a4c6ae 100644
|
|
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
|
|
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
|
|
@@ -583,6 +583,66 @@ static int dvbsky_mygica_t230c_attach(struct dvb_usb_adapter *adap)
|
|
return 0;
|
|
}
|
|
|
|
+static int dvbsky_mygica_t230c_v2_attach(struct dvb_usb_adapter *adap)
|
|
+{
|
|
+ struct dvbsky_state *state = adap_to_priv(adap);
|
|
+ struct dvb_usb_device *d = adap_to_d(adap);
|
|
+ struct i2c_adapter *i2c_adapter;
|
|
+ struct i2c_client *client_demod, *client_tuner;
|
|
+ struct i2c_board_info info;
|
|
+ struct si2168_config si2168_config;
|
|
+ struct si2157_config si2157_config;
|
|
+
|
|
+ /* attach demod */
|
|
+ memset(&si2168_config, 0, sizeof(si2168_config));
|
|
+ si2168_config.i2c_adapter = &i2c_adapter;
|
|
+ si2168_config.fe = &adap->fe[0];
|
|
+ si2168_config.ts_mode = SI2168_TS_PARALLEL;
|
|
+ si2168_config.ts_clock_inv = 1;
|
|
+ si2168_config.ts_clock_mode = SI2168_TS_CLOCK_MODE_MANUAL;
|
|
+ si2168_config.ts_clock_freq = 10000000;
|
|
+ memset(&info, 0, sizeof(struct i2c_board_info));
|
|
+ strlcpy(info.type, "si2168", sizeof(info.type));
|
|
+ info.addr = 0x64;
|
|
+ info.platform_data = &si2168_config;
|
|
+
|
|
+ request_module("si2168");
|
|
+ client_demod = i2c_new_device(&d->i2c_adap, &info);
|
|
+ if (!client_demod || !client_demod->dev.driver)
|
|
+ goto fail_demod_device;
|
|
+ if (!try_module_get(client_demod->dev.driver->owner))
|
|
+ goto fail_demod_module;
|
|
+
|
|
+ /* attach tuner */
|
|
+ memset(&si2157_config, 0, sizeof(si2157_config));
|
|
+ si2157_config.fe = adap->fe[0];
|
|
+ si2157_config.if_port = 0;
|
|
+ memset(&info, 0, sizeof(struct i2c_board_info));
|
|
+ strlcpy(info.type, "si2141", sizeof(info.type));
|
|
+ info.addr = 0x60;
|
|
+ info.platform_data = &si2157_config;
|
|
+
|
|
+ request_module("si2157");
|
|
+ client_tuner = i2c_new_device(i2c_adapter, &info);
|
|
+ if (!client_tuner || !client_tuner->dev.driver)
|
|
+ goto fail_tuner_device;
|
|
+ if (!try_module_get(client_tuner->dev.driver->owner))
|
|
+ goto fail_tuner_module;
|
|
+
|
|
+ state->i2c_client_demod = client_demod;
|
|
+ state->i2c_client_tuner = client_tuner;
|
|
+ return 0;
|
|
+
|
|
+fail_tuner_module:
|
|
+ i2c_unregister_device(client_tuner);
|
|
+fail_tuner_device:
|
|
+ module_put(client_demod->dev.driver->owner);
|
|
+fail_demod_module:
|
|
+ i2c_unregister_device(client_demod);
|
|
+fail_demod_device:
|
|
+ return -ENODEV;
|
|
+}
|
|
+
|
|
|
|
static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name)
|
|
{
|
|
@@ -762,6 +822,33 @@ static struct dvb_usb_device_properties mygica_t230c_props = {
|
|
}
|
|
};
|
|
|
|
+static struct dvb_usb_device_properties mygica_t230c_v2_props = {
|
|
+ .driver_name = KBUILD_MODNAME,
|
|
+ .owner = THIS_MODULE,
|
|
+ .adapter_nr = adapter_nr,
|
|
+ .size_of_priv = sizeof(struct dvbsky_state),
|
|
+
|
|
+ .generic_bulk_ctrl_endpoint = 0x01,
|
|
+ .generic_bulk_ctrl_endpoint_response = 0x81,
|
|
+ .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
|
|
+
|
|
+ .i2c_algo = &dvbsky_i2c_algo,
|
|
+ .frontend_attach = dvbsky_mygica_t230c_v2_attach,
|
|
+ .init = dvbsky_init,
|
|
+ .get_rc_config = dvbsky_get_rc_config,
|
|
+ .streaming_ctrl = dvbsky_streaming_ctrl,
|
|
+ .identify_state = dvbsky_identify_state,
|
|
+ .exit = dvbsky_exit,
|
|
+
|
|
+ .num_adapters = 1,
|
|
+ .adapter = {
|
|
+ {
|
|
+ .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
|
|
+ }
|
|
+ }
|
|
+};
|
|
+
|
|
+
|
|
static const struct usb_device_id dvbsky_id_table[] = {
|
|
{ DVB_USB_DEVICE(0x0572, 0x6831,
|
|
&dvbsky_s960_props, "DVBSky S960/S860", RC_MAP_DVBSKY) },
|
|
@@ -797,6 +884,9 @@ static const struct usb_device_id dvbsky_id_table[] = {
|
|
{ DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C,
|
|
&mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C",
|
|
RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
|
|
+ { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C_V2,
|
|
+ &mygica_t230c_v2_props, "MyGica Mini DVB-T2 USB Stick T230C v2",
|
|
+ RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
|
|
diff --git a/include/media/dvb-usb-ids.h b/include/media/dvb-usb-ids.h
|
|
index f9e73b4..d606248 100644
|
|
--- a/include/media/dvb-usb-ids.h
|
|
+++ b/include/media/dvb-usb-ids.h
|
|
@@ -387,6 +387,7 @@
|
|
#define USB_PID_MYGICA_D689 0xd811
|
|
#define USB_PID_MYGICA_T230 0xc688
|
|
#define USB_PID_MYGICA_T230C 0xc689
|
|
+#define USB_PID_MYGICA_T230C_V2 0xc68a
|
|
#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
|
|
#define USB_PID_ELGATO_EYETV_DTT 0x0021
|
|
#define USB_PID_ELGATO_EYETV_DTT_2 0x003f
|
|
--
|
|
2.17.1
|
|
|