Skip to content

Commit aa8fb86

Browse files
Merge pull request #11 from dmgouriev/master
T230C support add
2 parents 0a42056 + fea754f commit aa8fb86

File tree

11 files changed

+283
-107
lines changed

11 files changed

+283
-107
lines changed

.idea/modules.xml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

drivers/src/main/java/info/martinmarinov/drivers/usb/DvbUsbIds.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class DvbUsbIds {
9191
public static final int USB_VID_EVOLUTEPC = 0x1e59;
9292
public static final int USB_VID_AZUREWAVE = 0x13d3;
9393
public static final int USB_VID_TECHNISAT = 0x14f7;
94+
public static final int USB_VID_LEAGUERME = 0x3344;
9495

9596
/* Product IDs */
9697
public static final int USB_PID_ADSTECH_USB2_COLD = 0xa333;
@@ -394,6 +395,7 @@ public class DvbUsbIds {
394395
public static final int USB_PID_SONY_PLAYTV = 0x0003;
395396
public static final int USB_PID_MYGICA_D689 = 0xd811;
396397
public static final int USB_PID_MYGICA_T230 = 0xc688;
398+
public static final int USB_PID_GENIATECH_T230C = 0xc689;
397399
public static final int USB_PID_ELGATO_EYETV_DIVERSITY = 0x0011;
398400
public static final int USB_PID_ELGATO_EYETV_DTT = 0x0021;
399401
public static final int USB_PID_ELGATO_EYETV_DTT_2 = 0x003f;
@@ -426,4 +428,5 @@ public class DvbUsbIds {
426428
public static final int USB_PID_TURBOX_DTT_2000 = 0xd3a4;
427429
public static final int USB_PID_WINTV_SOLOHD = 0x0264;
428430
public static final int USB_PID_EVOLVEO_XTRATV_STICK = 0xa115;
431+
public static final int USB_PID_SINHON_TDH601 = 0x24a0;
429432
}

drivers/src/main/java/info/martinmarinov/drivers/usb/cxusb/CxUsbDvbDevice.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,44 @@
4444
import static info.martinmarinov.drivers.tools.I2cAdapter.I2cMessage.I2C_M_RD;
4545
import static info.martinmarinov.drivers.usb.DvbUsbIds.USB_VID_MEDION;
4646

47-
abstract class CxUsbDvbDevice extends DvbUsbDevice {
47+
public abstract class CxUsbDvbDevice extends DvbUsbDevice {
4848
private final static String TAG = CxUsbDvbDevice.class.getSimpleName();
4949

5050
private final static byte CMD_I2C_WRITE = 0x08;
51-
private final static byte CMD_I2C_READ = 0x09;
51+
private final static byte CMD_I2C_READ = 0x09;
5252

5353
private final static byte CMD_GPIO_WRITE = 0x0e;
54-
private final static byte GPIO_TUNER = 0x02;
54+
private final static byte CMD_GPIO_READ = 0x0d;
55+
private final static byte GPIO_TUNER = 0x02;
5556

5657
private final static byte CMD_POWER_OFF = (byte) 0xdc;
57-
private final static byte CMD_POWER_ON = (byte) 0xde;
58+
private final static byte CMD_POWER_ON = (byte) 0xde;
5859

59-
private final static byte CMD_STREAMING_ON = 0x36;
60+
private final static byte CMD_STREAMING_ON = 0x36;
6061
private final static byte CMD_STREAMING_OFF = 0x37;
6162

62-
final static byte CMD_DIGITAL = 0x51;
63+
private final static byte CMD_AVER_STREAM_ON = 0x18;
64+
private final static byte CMD_AVER_STREAM_OFF = 0x19;
65+
66+
private final static byte CMD_GET_IR_CODE = 0x47;
67+
68+
public final static byte CMD_ANALOG = 0x50;
69+
public final static byte CMD_DIGITAL = 0x51;
70+
71+
public static final int SI2168_TS_PARALLEL = 0x06;
72+
public static final int SI2168_TS_SERIAL = 0x03;
73+
74+
public static final int SI2168_MP_NOT_USED = 1;
75+
public static final int SI2168_MP_A = 2;
76+
public static final int SI2168_MP_B = 3;
77+
public static final int SI2168_MP_C = 4;
78+
public static final int SI2168_MP_D = 5;
79+
80+
public final static int SI2168_TS_CLK_AUTO_FIXED = 0;
81+
public final static int SI2168_TS_CLK_AUTO_ADAPT = 1;
82+
public final static int SI2168_TS_CLK_MANUAL = 2;
83+
84+
public final static int SI2168_ARGLEN = 30;
6385

6486
/* Max transfer size done by I2C transfer functions */
6587
private final static int MAX_XFER_SIZE = 80;
@@ -99,7 +121,7 @@ protected UsbEndpoint getUsbEndpoint() {
99121
return endpoint;
100122
}
101123

102-
void cxusb_streaming_ctrl(boolean onoff) throws DvbException {
124+
public void cxusb_streaming_ctrl(boolean onoff) throws DvbException {
103125
byte[] buf = new byte[]{ 0x03, 0x00 };
104126
if (onoff) {
105127
cxusb_ctrl_msg(CMD_STREAMING_ON, buf, 2);
@@ -123,11 +145,11 @@ synchronized void cxusb_ctrl_msg(byte cmd, @NonNull byte[] wbuf, int wlen) throw
123145

124146
synchronized void cxusb_ctrl_msg(byte cmd, @NonNull byte[] wbuf, int wlen, @Nullable byte[] rbuf, int rlen) throws DvbException {
125147
if (1 + wlen > MAX_XFER_SIZE) {
126-
throw new DvbException(BAD_API_USAGE, resources.getString(R.string.bad_api_usage));
148+
throw new DvbException(BAD_API_USAGE, resources.getString(R.string.bad_api_usage) + "\n" + "i2c wr: len=" + wlen + " is too big!");
127149
}
128150

129151
if (rlen > MAX_XFER_SIZE) {
130-
throw new DvbException(BAD_API_USAGE, resources.getString(R.string.bad_api_usage));
152+
throw new DvbException(BAD_API_USAGE, resources.getString(R.string.bad_api_usage) + "\n" + "i2c rd: len=" + rlen + " is too big!");
131153
}
132154

133155
byte[] data = new byte[Math.max(wlen + 1, rlen)];
@@ -166,13 +188,9 @@ private void cxusb_gpio_tuner(boolean onoff) throws DvbException {
166188
if (gpio_tuner_write_state == onoff) {
167189
return;
168190
}
169-
byte[] o = new byte[2];
170-
o[0] = GPIO_TUNER;
171-
o[1] = onoff ? (byte) 1 : 0;
172-
191+
byte[] o = new byte[] {GPIO_TUNER, (onoff ? (byte) 1 : 0)};
173192
byte[] i = new byte[1];
174193
cxusb_ctrl_msg(CMD_GPIO_WRITE, o, 2, i, 1);
175-
176194
if (i[0] != 0x01) {
177195
Log.w(TAG, "gpio_write failed.");
178196
}

drivers/src/main/java/info/martinmarinov/drivers/usb/cxusb/CxUsbDvbDeviceCreator.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131

3232
import static info.martinmarinov.drivers.tools.SetUtils.setOf;
3333
import static info.martinmarinov.drivers.usb.cxusb.MygicaT230.MYGICA_T230;
34+
import static info.martinmarinov.drivers.usb.cxusb.MygicaT230C.MYGICA_T230C;
3435

3536
public class CxUsbDvbDeviceCreator implements DvbUsbDevice.Creator {
36-
private final static Set<DeviceFilter> CXUSB_DEVICES = setOf(MYGICA_T230);
37+
private final static Set<DeviceFilter> CXUSB_DEVICES = setOf(MYGICA_T230, MYGICA_T230C);
3738

3839
@Override
3940
public Set<DeviceFilter> getSupportedDevices() {
@@ -42,6 +43,14 @@ public Set<DeviceFilter> getSupportedDevices() {
4243

4344
@Override
4445
public DvbUsbDevice create(UsbDevice usbDevice, Context context, DeviceFilter filter) throws DvbException {
45-
return new MygicaT230(usbDevice, context);
46+
if (MYGICA_T230C.matches(usbDevice)) {
47+
48+
return new MygicaT230C(usbDevice, context);
49+
50+
} else {
51+
52+
return new MygicaT230(usbDevice, context);
53+
54+
}
4655
}
4756
}

drivers/src/main/java/info/martinmarinov/drivers/usb/cxusb/MygicaT230.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
import info.martinmarinov.drivers.usb.DvbFrontend;
3030
import info.martinmarinov.drivers.usb.DvbTuner;
3131
import info.martinmarinov.drivers.usb.DvbUsbIds;
32+
import info.martinmarinov.drivers.usb.silabs.Si2157;
33+
import info.martinmarinov.drivers.usb.silabs.Si2168;
3234

33-
import static info.martinmarinov.drivers.usb.cxusb.Si2157.Type.SI2157_CHIPTYPE_SI2157;
34-
import static info.martinmarinov.drivers.usb.cxusb.Si2168.SI2168_TS_PARALLEL;
35+
import static info.martinmarinov.drivers.usb.silabs.Si2157.Type.SI2157_CHIPTYPE_SI2157;
3536

3637
class MygicaT230 extends CxUsbDvbDevice {
3738
private final static String MYGICA_NAME = "Mygica T230 DVB-T/T2/C";
@@ -70,7 +71,7 @@ protected void readConfig() throws DvbException {
7071

7172
@Override
7273
protected DvbFrontend frontendAttatch() throws DvbException {
73-
return frontend = new Si2168(resources, i2CAdapter, 0x64, SI2168_TS_PARALLEL, true);
74+
return frontend = new Si2168(this, resources, i2CAdapter, 0x64, SI2168_TS_PARALLEL, true, SI2168_TS_CLK_AUTO_FIXED, false);
7475
}
7576

7677
@Override
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package info.martinmarinov.drivers.usb.cxusb;
2+
3+
import android.content.Context;
4+
import android.hardware.usb.UsbDevice;
5+
6+
import info.martinmarinov.drivers.DeviceFilter;
7+
import info.martinmarinov.drivers.DvbException;
8+
import info.martinmarinov.drivers.tools.SleepUtils;
9+
import info.martinmarinov.drivers.usb.DvbFrontend;
10+
import info.martinmarinov.drivers.usb.DvbTuner;
11+
import info.martinmarinov.drivers.usb.DvbUsbIds;
12+
import info.martinmarinov.drivers.usb.silabs.Si2157;
13+
import info.martinmarinov.drivers.usb.silabs.Si2168;
14+
15+
import static info.martinmarinov.drivers.usb.silabs.Si2157.Type.SI2157_CHIPTYPE_SI2141;
16+
17+
18+
/**
19+
* @author dmgouriev
20+
*/
21+
public class MygicaT230C extends CxUsbDvbDevice {
22+
public final static String MYGICA_NAME = "Mygica T230C DVB-T/T2/C";
23+
final static DeviceFilter MYGICA_T230C = new DeviceFilter(DvbUsbIds.USB_VID_CONEXANT, DvbUsbIds.USB_PID_GENIATECH_T230C, MYGICA_NAME);
24+
25+
private Si2168 frontend;
26+
27+
MygicaT230C(UsbDevice usbDevice, Context context) throws DvbException {
28+
super(usbDevice, context, MYGICA_T230C);
29+
}
30+
31+
@Override
32+
public String getDebugString() {
33+
return MYGICA_NAME;
34+
}
35+
36+
@Override
37+
synchronized protected void powerControl(boolean onoff) throws DvbException {
38+
cxusb_d680_dmb_power_ctrl(onoff);
39+
cxusb_streaming_ctrl(onoff);
40+
}
41+
42+
private void cxusb_d680_dmb_power_ctrl(boolean onoff) throws DvbException {
43+
cxusb_power_ctrl(onoff);
44+
if (!onoff) return;
45+
46+
SleepUtils.mdelay(128);
47+
cxusb_ctrl_msg(CMD_DIGITAL, new byte[0], 0, new byte[1], 1);
48+
SleepUtils.mdelay(100);
49+
}
50+
51+
@Override
52+
protected void readConfig() throws DvbException {
53+
// no-op
54+
}
55+
56+
@Override
57+
protected DvbFrontend frontendAttatch() throws DvbException {
58+
return frontend = new Si2168(this, resources, i2CAdapter, 0x64, SI2168_TS_PARALLEL, true, SI2168_TS_CLK_AUTO_ADAPT, false);
59+
}
60+
61+
@Override
62+
protected DvbTuner tunerAttatch() throws DvbException {
63+
return new Si2157(resources, i2CAdapter, frontend.gateControl(), 0x60, false, SI2157_CHIPTYPE_SI2141);
64+
}
65+
66+
@Override
67+
protected void init() throws DvbException {
68+
// no-op
69+
}
70+
71+
72+
}

0 commit comments

Comments
 (0)