| 1 |
|
| |
| 2 |
|
| |
| 3 |
|
| |
| 4 |
|
| # /*---------------------------------------------------------------------------------------------------*/ |
| 5 |
|
| # /* Use the specified parameters (or AUTO) to tune the frontend */ |
| 6 |
|
| |
| 7 |
|
| int |
| 8 |
|
| dvb_tune (DVB *dvb, HV *parameters) |
| 9 |
|
| INIT: |
| 10 |
|
| SV **val; |
| 11 |
|
| |
| 12 |
0 |
| int frequency=0; |
| 13 |
|
| |
| 14 |
|
| /* We hope that any unset params will cope just using the AUTO option */ |
| 15 |
0 |
| int inversion=TUNING_AUTO; |
| 16 |
0 |
| int bandwidth=TUNING_AUTO; |
| 17 |
0 |
| int code_rate_high=TUNING_AUTO; |
| 18 |
0 |
| int code_rate_low=TUNING_AUTO; |
| 19 |
0 |
| int modulation=TUNING_AUTO; |
| 20 |
0 |
| int transmission=TUNING_AUTO; |
| 21 |
0 |
| int guard_interval=TUNING_AUTO; |
| 22 |
0 |
| int hierarchy=TUNING_AUTO; |
| 23 |
|
| |
| 24 |
0 |
| int timeout=DEFAULT_TIMEOUT; |
| 25 |
|
| |
| 26 |
|
| CODE: |
| 27 |
|
| |
| 28 |
0 |
▶ | if (DVBT_DEBUG >= 10) |
Branch: 1 branch
| Branch | True | False | Total |
| if (DVBT_DEBUG >= 10) |
0 |
0 |
0 |
|
| 29 |
|
| { |
| 30 |
0 |
| fprintf(stderr, " == DVBT.xs::dvb_tune() ================\n") ; |
| 31 |
|
| } |
| 32 |
|
| |
| 33 |
|
| /* Read all those HASH values that are actually set into discrete variables */ |
| 34 |
0 |
▶ | HVF_I(parameters, frequency) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, frequency) ; |
0 |
0 |
0 |
| HVF_I(parameters, frequency) ; |
0 |
0 |
0 |
| HVF_I(parameters, frequency) ; |
0 |
0 |
0 |
|
| 35 |
0 |
▶ | HVF_I(parameters, inversion) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, inversion) ; |
0 |
0 |
0 |
| HVF_I(parameters, inversion) ; |
0 |
0 |
0 |
| HVF_I(parameters, inversion) ; |
0 |
0 |
0 |
|
| 36 |
0 |
▶ | HVF_I(parameters, bandwidth) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, bandwidth) ; |
0 |
0 |
0 |
| HVF_I(parameters, bandwidth) ; |
0 |
0 |
0 |
| HVF_I(parameters, bandwidth) ; |
0 |
0 |
0 |
|
| 37 |
0 |
▶ | HVF_I(parameters, code_rate_high) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, code_rate_high) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_high) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_high) ; |
0 |
0 |
0 |
|
| 38 |
0 |
▶ | HVF_I(parameters, code_rate_low) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, code_rate_low) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_low) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_low) ; |
0 |
0 |
0 |
|
| 39 |
0 |
▶ | HVF_I(parameters, modulation) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, modulation) ; |
0 |
0 |
0 |
| HVF_I(parameters, modulation) ; |
0 |
0 |
0 |
| HVF_I(parameters, modulation) ; |
0 |
0 |
0 |
|
| 40 |
0 |
▶ | HVF_I(parameters, transmission) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, transmission) ; |
0 |
0 |
0 |
| HVF_I(parameters, transmission) ; |
0 |
0 |
0 |
| HVF_I(parameters, transmission) ; |
0 |
0 |
0 |
|
| 41 |
0 |
▶ | HVF_I(parameters, guard_interval) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, guard_interval) ; |
0 |
0 |
0 |
| HVF_I(parameters, guard_interval) ; |
0 |
0 |
0 |
| HVF_I(parameters, guard_interval) ; |
0 |
0 |
0 |
|
| 42 |
0 |
▶ | HVF_I(parameters, hierarchy) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, hierarchy) ; |
0 |
0 |
0 |
| HVF_I(parameters, hierarchy) ; |
0 |
0 |
0 |
| HVF_I(parameters, hierarchy) ; |
0 |
0 |
0 |
|
| 43 |
0 |
▶ | HVF_I(parameters, timeout) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, timeout) ; |
0 |
0 |
0 |
| HVF_I(parameters, timeout) ; |
0 |
0 |
0 |
| HVF_I(parameters, timeout) ; |
0 |
0 |
0 |
|
| 44 |
|
| |
| 45 |
0 |
▶ | if (frequency <= 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (frequency <= 0) |
0 |
0 |
0 |
|
| 46 |
0 |
| croak ("Linux::DVB::DVBT::dvb_tune requires a valid frequency"); |
| 47 |
|
| |
| 48 |
|
| /* use 3x global timeout for tuning */ |
| 49 |
0 |
| timeout *= 3 ; |
| 50 |
|
| |
| 51 |
0 |
▶ | if (DVBT_DEBUG >= 10) |
Branch: 1 branch
| Branch | True | False | Total |
| if (DVBT_DEBUG >= 10) |
0 |
0 |
0 |
|
| 52 |
|
| { |
| 53 |
0 |
| fprintf(stderr, "#@f DVBT.xs::dvb_tune() : tuning freq=%d Hz, inv=(%d) " |
| 54 |
|
| "bandwidth=(%d) code_rate=(%d - %d) constellation=(%d) " |
| 55 |
|
| "transmission=(%d) guard=(%d) hierarchy=(%d)\n", |
| 56 |
|
| frequency, |
| 57 |
|
| inversion, |
| 58 |
|
| bandwidth, |
| 59 |
|
| code_rate_high, |
| 60 |
|
| code_rate_low, |
| 61 |
|
| modulation, |
| 62 |
|
| transmission, |
| 63 |
|
| guard_interval, |
| 64 |
|
| hierarchy |
| 65 |
|
| ) ; |
| 66 |
|
| } |
| 67 |
|
| |
| 68 |
|
| // set tuning |
| 69 |
0 |
| RETVAL = dvb_tune(dvb, |
| 70 |
|
| /* For frontend tuning */ |
| 71 |
|
| frequency, |
| 72 |
|
| inversion, |
| 73 |
|
| bandwidth, |
| 74 |
|
| code_rate_high, |
| 75 |
|
| code_rate_low, |
| 76 |
|
| modulation, |
| 77 |
|
| transmission, |
| 78 |
|
| guard_interval, |
| 79 |
|
| hierarchy, |
| 80 |
|
| timeout) ; |
| 81 |
|
| |
| 82 |
0 |
▶ | if (DVBT_DEBUG >= 10) |
Branch: 1 branch
| Branch | True | False | Total |
| if (DVBT_DEBUG >= 10) |
0 |
0 |
0 |
|
| 83 |
|
| { |
| 84 |
0 |
| fprintf(stderr, " rc = %d\n", RETVAL) ; |
| 85 |
0 |
| fprintf(stderr, " == DVBT.xs::dvb_tune() - END ================\n") ; |
| 86 |
|
| } |
| 87 |
|
| |
| 88 |
|
| OUTPUT: |
| 89 |
|
| RETVAL |
| 90 |
|
| |
| 91 |
|
| |
| 92 |
|
| # /*---------------------------------------------------------------------------------------------------*/ |
| 93 |
|
| # /* Same as dvb_tune() but ensures that the frequency tuned to is added to the scan list */ |
| 94 |
|
| int |
| 95 |
|
| dvb_scan_tune (DVB *dvb, HV *parameters) |
| 96 |
|
| INIT: |
| 97 |
|
| SV **val; |
| 98 |
|
| |
| 99 |
0 |
| int frequency=0; |
| 100 |
|
| |
| 101 |
|
| /* We hope that any unset params will cope just using the AUTO option */ |
| 102 |
0 |
| int inversion=TUNING_AUTO; |
| 103 |
0 |
| int bandwidth=TUNING_AUTO; |
| 104 |
0 |
| int code_rate_high=TUNING_AUTO; |
| 105 |
0 |
| int code_rate_low=TUNING_AUTO; |
| 106 |
0 |
| int modulation=TUNING_AUTO; |
| 107 |
0 |
| int transmission=TUNING_AUTO; |
| 108 |
0 |
| int guard_interval=TUNING_AUTO; |
| 109 |
0 |
| int hierarchy=TUNING_AUTO; |
| 110 |
|
| |
| 111 |
0 |
| int timeout=DEFAULT_TIMEOUT; |
| 112 |
|
| |
| 113 |
|
| CODE: |
| 114 |
|
| |
| 115 |
0 |
▶ | if (DVBT_DEBUG >= 10) |
Branch: 1 branch
| Branch | True | False | Total |
| if (DVBT_DEBUG >= 10) |
0 |
0 |
0 |
|
| 116 |
|
| { |
| 117 |
0 |
| fprintf(stderr, " == DVBT.xs::dvb_scan_tune() ================\n") ; |
| 118 |
|
| } |
| 119 |
|
| |
| 120 |
|
| /* Read all those HASH values that are actually set into discrete variables */ |
| 121 |
0 |
▶ | HVF_I(parameters, frequency) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, frequency) ; |
0 |
0 |
0 |
| HVF_I(parameters, frequency) ; |
0 |
0 |
0 |
| HVF_I(parameters, frequency) ; |
0 |
0 |
0 |
|
| 122 |
0 |
▶ | HVF_I(parameters, inversion) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, inversion) ; |
0 |
0 |
0 |
| HVF_I(parameters, inversion) ; |
0 |
0 |
0 |
| HVF_I(parameters, inversion) ; |
0 |
0 |
0 |
|
| 123 |
0 |
▶ | HVF_I(parameters, bandwidth) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, bandwidth) ; |
0 |
0 |
0 |
| HVF_I(parameters, bandwidth) ; |
0 |
0 |
0 |
| HVF_I(parameters, bandwidth) ; |
0 |
0 |
0 |
|
| 124 |
0 |
▶ | HVF_I(parameters, code_rate_high) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, code_rate_high) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_high) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_high) ; |
0 |
0 |
0 |
|
| 125 |
0 |
▶ | HVF_I(parameters, code_rate_low) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, code_rate_low) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_low) ; |
0 |
0 |
0 |
| HVF_I(parameters, code_rate_low) ; |
0 |
0 |
0 |
|
| 126 |
0 |
▶ | HVF_I(parameters, modulation) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, modulation) ; |
0 |
0 |
0 |
| HVF_I(parameters, modulation) ; |
0 |
0 |
0 |
| HVF_I(parameters, modulation) ; |
0 |
0 |
0 |
|
| 127 |
0 |
▶ | HVF_I(parameters, transmission) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, transmission) ; |
0 |
0 |
0 |
| HVF_I(parameters, transmission) ; |
0 |
0 |
0 |
| HVF_I(parameters, transmission) ; |
0 |
0 |
0 |
|
| 128 |
0 |
▶ | HVF_I(parameters, guard_interval) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, guard_interval) ; |
0 |
0 |
0 |
| HVF_I(parameters, guard_interval) ; |
0 |
0 |
0 |
| HVF_I(parameters, guard_interval) ; |
0 |
0 |
0 |
|
| 129 |
0 |
▶ | HVF_I(parameters, hierarchy) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, hierarchy) ; |
0 |
0 |
0 |
| HVF_I(parameters, hierarchy) ; |
0 |
0 |
0 |
| HVF_I(parameters, hierarchy) ; |
0 |
0 |
0 |
|
| 130 |
0 |
▶ | HVF_I(parameters, timeout) ; |
Branch: 3 branches
| Branch | True | False | Total |
| HVF_I(parameters, timeout) ; |
0 |
0 |
0 |
| HVF_I(parameters, timeout) ; |
0 |
0 |
0 |
| HVF_I(parameters, timeout) ; |
0 |
0 |
0 |
|
| 131 |
|
| |
| 132 |
0 |
▶ | if (frequency <= 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (frequency <= 0) |
0 |
0 |
0 |
|
| 133 |
0 |
| croak ("Linux::DVB::DVBT::dvb_tune requires a valid frequency"); |
| 134 |
|
| |
| 135 |
|
| /* use 3x global timeout for tuning */ |
| 136 |
0 |
| timeout *= 3 ; |
| 137 |
|
| |
| 138 |
0 |
▶ | if (DVBT_DEBUG >= 10) |
Branch: 1 branch
| Branch | True | False | Total |
| if (DVBT_DEBUG >= 10) |
0 |
0 |
0 |
|
| 139 |
|
| { |
| 140 |
0 |
| fprintf(stderr, "#@f DVBT.xs::dvb_scan_tune() : tuning freq=%d Hz, inv=(%d) " |
| 141 |
|
| "bandwidth=(%d) code_rate=(%d - %d) constellation=(%d) " |
| 142 |
|
| "transmission=(%d) guard=(%d) hierarchy=(%d)\n", |
| 143 |
|
| frequency, |
| 144 |
|
| inversion, |
| 145 |
|
| bandwidth, |
| 146 |
|
| code_rate_high, |
| 147 |
|
| code_rate_low, |
| 148 |
|
| modulation, |
| 149 |
|
| transmission, |
| 150 |
|
| guard_interval, |
| 151 |
|
| hierarchy |
| 152 |
|
| ) ; |
| 153 |
|
| } |
| 154 |
|
| |
| 155 |
|
| // set tuning |
| 156 |
0 |
| RETVAL = dvb_scan_tune(dvb, |
| 157 |
|
| /* For frontend tuning */ |
| 158 |
|
| frequency, |
| 159 |
|
| inversion, |
| 160 |
|
| bandwidth, |
| 161 |
|
| code_rate_high, |
| 162 |
|
| code_rate_low, |
| 163 |
|
| modulation, |
| 164 |
|
| transmission, |
| 165 |
|
| guard_interval, |
| 166 |
|
| hierarchy, |
| 167 |
|
| timeout) ; |
| 168 |
|
| |
| 169 |
|
| OUTPUT: |
| 170 |
|
| RETVAL |
| 171 |
|
| |
| 172 |
|
| |
| 173 |
|
| # /*---------------------------------------------------------------------------------------------------*/ |
| 174 |
|
| # /* Get frontend signal stats */ |
| 175 |
|
| SV * |
| 176 |
|
| dvb_signal_quality(DVB *dvb) |
| 177 |
|
| |
| 178 |
|
| INIT: |
| 179 |
|
| HV * results; |
| 180 |
|
| unsigned ber ; |
| 181 |
|
| unsigned snr ; |
| 182 |
|
| unsigned strength ; |
| 183 |
|
| unsigned uncorrected_blocks ; |
| 184 |
|
| int ok ; |
| 185 |
|
| |
| 186 |
0 |
| results = (HV *)sv_2mortal((SV *)newHV()); |
| 187 |
|
| |
| 188 |
|
| CODE: |
| 189 |
|
| /* get info */ |
| 190 |
0 |
| ok = dvb_signal_quality(dvb, &ber, &snr, &strength, &uncorrected_blocks) ; |
| 191 |
|
| |
| 192 |
|
| /** Create Perl data **/ |
| 193 |
0 |
| HVS(results, ber, newSViv((int)ber)) ; |
| 194 |
0 |
| HVS(results, snr, newSViv((int)snr)) ; |
| 195 |
0 |
| HVS(results, strength, newSViv((int)strength)) ; |
| 196 |
0 |
| HVS(results, uncorrected_blocks, newSViv((int)uncorrected_blocks)) ; |
| 197 |
0 |
| HVS(results, ok, newSViv(ok)) ; |
| 198 |
|
| |
| 199 |
0 |
| RETVAL = newRV((SV *)results); |
| 200 |
|
| OUTPUT: |
| 201 |
|
| RETVAL |
| 202 |
|
| |
| 203 |
|
| # /*---------------------------------------------------------------------------------------------------*/ |
| 204 |
|
| # /* Round up frequency */ |
| 205 |
|
| int |
| 206 |
|
| dvb_round_freq(int freqin) |
| 207 |
|
| |
| 208 |
|
| CODE: |
| 209 |
2 |
▶ | RETVAL = ROUND_FREQUENCY(freqin) ; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = ROUND_FREQUENCY(freqin) ; |
1 |
1 |
2 |
|
| 210 |
|
| OUTPUT: |
| 211 |
|
| RETVAL |
| 212 |
|
| |
| 213 |
|
| # /*---------------------------------------------------------------------------------------------------*/ |
| 214 |
|
| # /* See if this adapter frontend is busy */ |
| 215 |
|
| int |
| 216 |
|
| dvb_is_busy(DVB *dvb) |
| 217 |
|
| |
| 218 |
|
| CODE: |
| 219 |
0 |
| RETVAL = dvb_frontend_is_busy(dvb) ; |
| 220 |
|
| OUTPUT: |
| 221 |
|
| RETVAL |
| 222 |
|
| |