Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions drivers/src/main/java/info/martinmarinov/drivers/DvbDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ protected DvbDevice(DvbDemux dvbDemux) {
// Debug string to identify device for debugging purposes
public abstract String getDebugString();

protected abstract void tuneTo(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem) throws DvbException;
protected abstract void tuneTo(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem, long dvbcSymbolRate) throws DvbException;

public final void tune(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem) throws DvbException {
tuneTo(freqHz, bandwidthHz, deliverySystem);
public final void tune(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem, long dvbcSymbolRate) throws DvbException {
tuneTo(freqHz, bandwidthHz, deliverySystem, dvbcSymbolRate);
if (dvbDemux != null) dvbDemux.reset();
}

public final void tune(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem) throws DvbException {
tune(freqHz, bandwidthHz, deliverySystem, 0L);
}

public int readDroppedUsbFps() throws DvbException {
return dvbDemux.getDroppedUsbFps();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public DeviceFilter getDeviceFilter() {
}

@Override
protected void tuneTo(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem) throws DvbException {
protected void tuneTo(long freqHz, long bandwidthHz, @NonNull DeliverySystem deliverySystem, long dvbcSymbolRate) throws DvbException {
this.isTuned = freqHz == this.freq && bandwidthHz == this.bandwidth;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ public interface DvbFrontend {
Set<DvbStatus> getStatus() throws DvbException;
void setPids(int ... pids) throws DvbException;
void disablePidFilter() throws DvbException;

// Optional: called before setParams() to set DVB-C symbol rate (default no-op)
default void setDvbcSymbolRate(long symbolRate) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ public DvbCapabilities readCapabilities() throws DvbException {
}

@Override
protected void tuneTo(final long freqHz, final long bandwidthHz, @NonNull final DeliverySystem deliverySystem) throws DvbException {
protected void tuneTo(final long freqHz, final long bandwidthHz, @NonNull final DeliverySystem deliverySystem, final long dvbcSymbolRate) throws DvbException {
Check.notNull(frontend, "Frontend not initialized");
if (dvbcSymbolRate > 0) {
frontend.setDvbcSymbolRate(dvbcSymbolRate);
}
retry(RETRIES, new ThrowingRunnable<DvbException>() {
@Override
public void run() throws DvbException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Si2168 implements DvbFrontend {
private final static int TIMEOUT_MS = 70;
private final static int NO_STREAM_ID_FILTER = 0xFFFFFFFF;
private final static int DVBT2_STREAM_ID = 0;
private final static int DVBC_SYMBOL_RATE = 0;
private final static long DEFAULT_DVBC_SYMBOL_RATE = 6_900_000L;

private final Resources resources;
private final I2cAdapter i2c;
Expand All @@ -81,6 +81,7 @@ public class Si2168 implements DvbFrontend {
private Si2168Data.Si2168Chip chip;
private DvbTuner tuner;
private DeliverySystem deliverySystem;
private long dvbcSymbolRate = DEFAULT_DVBC_SYMBOL_RATE;

private boolean hasLockStatus = false;

Expand Down Expand Up @@ -353,7 +354,7 @@ public synchronized void setParams(long frequency, long bandwidthHz, @NonNull De
if (deliverySystem == DeliverySystem.DVBC) {
//noinspection PointlessBitwiseExpression
si2168_cmd_execute(new byte[] {
(byte) 0x14, (byte) 0x00, (byte) 0x02 , (byte) 0x11, (byte) (((DVBC_SYMBOL_RATE / 1000) >> 0) & 0xff), (byte) ( ((DVBC_SYMBOL_RATE / 1000) >> 8) & 0xff)
(byte) 0x14, (byte) 0x00, (byte) 0x02 , (byte) 0x11, (byte) (((dvbcSymbolRate / 1000) >> 0) & 0xff), (byte) ( ((dvbcSymbolRate / 1000) >> 8) & 0xff)
}, 6, 4);
}

Expand Down Expand Up @@ -465,6 +466,10 @@ public I2cAdapter.I2GateControl gateControl() {
return gateControl;
}

public void setDvbcSymbolRate(long symbolRate) {
this.dvbcSymbolRate = (symbolRate > 0) ? symbolRate : DEFAULT_DVBC_SYMBOL_RATE;
}

private final I2cAdapter.I2GateControl gateControl = new I2cAdapter.I2GateControl() {
@Override
protected synchronized void i2cGateCtrl(boolean enable) throws DvbException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ public Response execute(DvbDevice dvbDevice, long... payload) throws DvbExceptio
// Typical value for DVB-T is 8_000_000
DeliverySystem deliverySystem = DeliverySystem.values()[(int) payload[2]];
// Check enum for actual values
long dvbcSymbolRate = (payload.length > 3) ? payload[3] : 0L;
// DVB-C symbol rate in symbols/sec (e.g. 6_900_000); 0 = use device default

Log.d(TAG, "Client requested tune to " + frequency + " Hz with bandwidth " + bandwidth + " Hz with delivery system " + deliverySystem);
dvbDevice.tune(frequency, bandwidth, deliverySystem);
dvbDevice.tune(frequency, bandwidth, deliverySystem, dvbcSymbolRate);
return Response.SUCCESS;
}
}),
Expand Down