HDHomeRun OTA tuning improvements
1) Make OTA tuning more robust
After tuning to physical channel, let the tuner settle for 1 second before
collecting the first tuner status sample. If needed, collect 4 more tuner
status samples at 500 msec intervals. Normally, on a good quality channel,
the first sample is already good (SEQ=100).
Once the tuner status is good, immediately get the first stream info sample
and try to translate virtual channel to program number. If needed, collect
4 more stream info samples at 500 msec intervals and try to translate again.
Normally, on a good quality channel, the first sample is enough.
2) Add tuner status logging
chsrv: hdhr:hdhomerun tuner status: lock=8vsb ss=91 snq=69 seq=100
Change-Id: I585ccb17a59442761c704343d6056ec18bb180df
diff --git a/hdhomerun_tuner.c b/hdhomerun_tuner.c
index bff2315..137af3c 100644
--- a/hdhomerun_tuner.c
+++ b/hdhomerun_tuner.c
@@ -192,31 +192,39 @@
goto out;
}
- // Wait for SER to hit 100% (max 3 secs)
- usleep(500000);
- for (i = 0; i < 10; i++) {
+ // Wait for symbol error quality to hit 100% (max 3 secs)
+ for (i = 0; i < 5; i++) {
+ usleep(i == 0 ? 1000000 : 500000);
ret = hdhomerun_device_get_tuner_status(hd, NULL, &ts);
if (ret > 0 && ts.symbol_error_quality >= 100) {
break;
}
- usleep(250000);
}
- // Get MPEG2-TS stream info
- ret = hdhomerun_device_get_tuner_streaminfo(hd, &streaminfo);
- if (ret <= 0) {
- printf("hdhr:ERROR: get tuner streaminfo\n");
- goto out;
- }
- printf("hdhr:hdhomerun streaminfo:\n%s", streaminfo);
+ printf("hdhr:hdhomerun tuner status: lock=%s ss=%u snq=%u seq=%u\n",
+ ts.lock_str, ts.signal_strength, ts.signal_to_noise_quality,
+ ts.symbol_error_quality);
- // Translate virtual channel (major.minor) to program number
- ret = vchan_to_prog_num(streaminfo, vchannel_major, vchannel_minor, &program);
+ // Translate virtual channel to program number (max 2 secs)
+ for (i = 0; i < 5; i++) {
+ usleep(i == 0 ? 0 : 500000);
+ ret = hdhomerun_device_get_tuner_streaminfo(hd, &streaminfo);
+ if (ret > 0) {
+ printf("hdhr:hdhomerun streaminfo:\n%s", streaminfo);
+ ret = vchan_to_prog_num(streaminfo, vchannel_major, vchannel_minor,
+ &program);
+ if (ret > 0) {
+ break;
+ }
+ }
+ }
+
if (ret <= 0) {
printf("hdhr:ERROR: vchannel %d.%d not found in streaminfo\n",
vchannel_major, vchannel_minor);
goto out;
}
+
printf("hdhr:hdhomerun vchannel %u.%u -> program %u\n", vchannel_major,
vchannel_minor, program);