diff options
author | Oliver Freyermuth <o.freyermuth@googlemail.com> | 2017-10-03 21:40:19 +0200 |
---|---|---|
committer | Oliver Freyermuth <o.freyermuth@googlemail.com> | 2017-10-09 20:06:29 +0200 |
commit | 22442b421cbfdb8fec3d1cbfcc8a6b5c251d47b8 (patch) | |
tree | 6ab0a5c04c4e542391ab28e7d6cba29d3bc87f7d /stream/dvb_tune.c | |
parent | cdef69103a9c0bed742563a98d21099650ba478f (diff) | |
download | mpv-22442b421cbfdb8fec3d1cbfcc8a6b5c251d47b8.tar.bz2 mpv-22442b421cbfdb8fec3d1cbfcc8a6b5c251d47b8.tar.xz |
dvb: Use more elaborate tuning for DVBv5 tuning.
Also, in case tuning fails with timeout even though the ioctl
was accepted by the device, fall back to DVBv3 tuning.
This may go wrong for multi-delivery-system cards,
so issue an error message in that case.
Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
Diffstat (limited to 'stream/dvb_tune.c')
-rw-r--r-- | stream/dvb_tune.c | 134 |
1 files changed, 111 insertions, 23 deletions
diff --git a/stream/dvb_tune.c b/stream/dvb_tune.c index 09a202790b..da4a8f5ad3 100644 --- a/stream/dvb_tune.c +++ b/stream/dvb_tune.c @@ -606,31 +606,119 @@ static int tune_it(dvb_priv_t *priv, int fd_frontend, unsigned int delsys, } /* Tune. */ - struct dtv_property p[] = { - { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys }, - { .cmd = DTV_FREQUENCY, .u.data = freq }, - { .cmd = DTV_MODULATION, .u.data = modulation }, - { .cmd = DTV_SYMBOL_RATE, .u.data = srate }, - { .cmd = DTV_INNER_FEC, .u.data = HP_CodeRate }, - { .cmd = DTV_INVERSION, .u.data = specInv }, - { .cmd = DTV_ROLLOFF, .u.data = ROLLOFF_AUTO }, - { .cmd = DTV_BANDWIDTH_HZ, .u.data = bandwidth_hz }, - { .cmd = DTV_PILOT, .u.data = PILOT_AUTO }, - { .cmd = DTV_STREAM_ID, .u.data = stream_id }, - { .cmd = DTV_TUNE }, - }; - struct dtv_properties cmdseq = { - .num = sizeof(p) / sizeof(p[0]), - .props = p - }; - MP_VERBOSE(priv, "Tuning via S2API, channel is %s.\n", - get_dvb_delsys(delsys)); - if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq) < 0) { - MP_ERR(priv, "ERROR tuning channel\n"); - goto old_api; + switch (delsys) { + case SYS_DVBS: + case SYS_DVBS2: + { + struct dtv_property p[] = { + { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys }, + { .cmd = DTV_FREQUENCY, .u.data = freq }, + { .cmd = DTV_MODULATION, .u.data = modulation }, + { .cmd = DTV_SYMBOL_RATE, .u.data = srate }, + { .cmd = DTV_INNER_FEC, .u.data = HP_CodeRate }, + { .cmd = DTV_INVERSION, .u.data = specInv }, + { .cmd = DTV_ROLLOFF, .u.data = ROLLOFF_AUTO }, + { .cmd = DTV_PILOT, .u.data = PILOT_AUTO }, + { .cmd = DTV_TUNE }, + }; + struct dtv_properties cmdseq = { + .num = sizeof(p) / sizeof(p[0]), + .props = p + }; + MP_VERBOSE(priv, "Tuning via S2API, channel is %s.\n", + get_dvb_delsys(delsys)); + if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq) < 0) { + MP_ERR(priv, "ERROR tuning channel\n"); + goto old_api; + } + } + break; + case SYS_DVBT: + case SYS_DVBT2: + { + struct dtv_property p[] = { + { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys }, + { .cmd = DTV_FREQUENCY, .u.data = freq }, + { .cmd = DTV_MODULATION, .u.data = modulation }, + { .cmd = DTV_SYMBOL_RATE, .u.data = srate }, + { .cmd = DTV_CODE_RATE_HP, .u.data = HP_CodeRate }, + { .cmd = DTV_CODE_RATE_LP, .u.data = LP_CodeRate }, + { .cmd = DTV_INVERSION, .u.data = specInv }, + { .cmd = DTV_BANDWIDTH_HZ, .u.data = bandwidth_hz }, + { .cmd = DTV_TRANSMISSION_MODE, .u.data = TransmissionMode }, + { .cmd = DTV_GUARD_INTERVAL, .u.data = guardInterval }, + { .cmd = DTV_HIERARCHY, .u.data = hier }, + { .cmd = DTV_STREAM_ID, .u.data = stream_id }, + { .cmd = DTV_TUNE }, + }; + struct dtv_properties cmdseq = { + .num = sizeof(p) / sizeof(p[0]), + .props = p + }; + MP_VERBOSE(priv, "Tuning via S2API, channel is %s.\n", + get_dvb_delsys(delsys)); + if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq) < 0) { + MP_ERR(priv, "ERROR tuning channel\n"); + goto old_api; + } + } + break; + case SYS_DVBC_ANNEX_A: + case SYS_DVBC_ANNEX_C: + { + struct dtv_property p[] = { + { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys }, + { .cmd = DTV_FREQUENCY, .u.data = freq }, + { .cmd = DTV_MODULATION, .u.data = modulation }, + { .cmd = DTV_SYMBOL_RATE, .u.data = srate }, + { .cmd = DTV_INNER_FEC, .u.data = HP_CodeRate }, + { .cmd = DTV_INVERSION, .u.data = specInv }, + { .cmd = DTV_TUNE }, + }; + struct dtv_properties cmdseq = { + .num = sizeof(p) / sizeof(p[0]), + .props = p + }; + MP_VERBOSE(priv, "Tuning via S2API, channel is %s.\n", + get_dvb_delsys(delsys)); + if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq) < 0) { + MP_ERR(priv, "ERROR tuning channel\n"); + goto old_api; + } + } + break; +#ifdef DVB_ATSC + case SYS_ATSC: + { + struct dtv_property p[] = { + { .cmd = DTV_DELIVERY_SYSTEM, .u.data = delsys }, + { .cmd = DTV_FREQUENCY, .u.data = freq }, + { .cmd = DTV_INVERSION, .u.data = specInv }, + { .cmd = DTV_MODULATION, .u.data = modulation }, + { .cmd = DTV_TUNE }, + }; + struct dtv_properties cmdseq = { + .num = sizeof(p) / sizeof(p[0]), + .props = p + }; + MP_VERBOSE(priv, "Tuning via S2API, channel is %s.\n", + get_dvb_delsys(delsys)); + if (ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq) < 0) { + MP_ERR(priv, "ERROR tuning channel\n"); + goto old_api; + } + } + break; +#endif } - return check_status(priv, fd_frontend, timeout); + int tune_status = check_status(priv, fd_frontend, timeout); + if (tune_status != 0) { + MP_ERR(priv, "ERROR locking to channel when tuning with S2API, falling back to DVBv3-tuning.\n"); + goto old_api; + } else { + return tune_status; + } old_api: #endif |