| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * drxd_hard.c: DVB-T Demodulator Micronas DRX3975D-A2,DRX397xD-B1 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2003-2007 Micronas |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of the GNU General Public License |
|---|
| 8 | | - * version 2 only, as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * To obtain the license, point your browser to |
|---|
| 17 | | - * http://www.gnu.org/copyleft/gpl.html |
|---|
| 18 | 6 | */ |
|---|
| 19 | 7 | |
|---|
| 20 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 1144 | 1132 | |
|---|
| 1145 | 1133 | static int InitCC(struct drxd_state *state) |
|---|
| 1146 | 1134 | { |
|---|
| 1135 | + int status = 0; |
|---|
| 1136 | + |
|---|
| 1147 | 1137 | if (state->osc_clock_freq == 0 || |
|---|
| 1148 | 1138 | state->osc_clock_freq > 20000 || |
|---|
| 1149 | 1139 | (state->osc_clock_freq % 4000) != 0) { |
|---|
| .. | .. |
|---|
| 1151 | 1141 | return -1; |
|---|
| 1152 | 1142 | } |
|---|
| 1153 | 1143 | |
|---|
| 1154 | | - Write16(state, CC_REG_OSC_MODE__A, CC_REG_OSC_MODE_M20, 0); |
|---|
| 1155 | | - Write16(state, CC_REG_PLL_MODE__A, CC_REG_PLL_MODE_BYPASS_PLL | |
|---|
| 1156 | | - CC_REG_PLL_MODE_PUMP_CUR_12, 0); |
|---|
| 1157 | | - Write16(state, CC_REG_REF_DIVIDE__A, state->osc_clock_freq / 4000, 0); |
|---|
| 1158 | | - Write16(state, CC_REG_PWD_MODE__A, CC_REG_PWD_MODE_DOWN_PLL, 0); |
|---|
| 1159 | | - Write16(state, CC_REG_UPDATE__A, CC_REG_UPDATE_KEY, 0); |
|---|
| 1144 | + status |= Write16(state, CC_REG_OSC_MODE__A, CC_REG_OSC_MODE_M20, 0); |
|---|
| 1145 | + status |= Write16(state, CC_REG_PLL_MODE__A, |
|---|
| 1146 | + CC_REG_PLL_MODE_BYPASS_PLL | |
|---|
| 1147 | + CC_REG_PLL_MODE_PUMP_CUR_12, 0); |
|---|
| 1148 | + status |= Write16(state, CC_REG_REF_DIVIDE__A, |
|---|
| 1149 | + state->osc_clock_freq / 4000, 0); |
|---|
| 1150 | + status |= Write16(state, CC_REG_PWD_MODE__A, CC_REG_PWD_MODE_DOWN_PLL, |
|---|
| 1151 | + 0); |
|---|
| 1152 | + status |= Write16(state, CC_REG_UPDATE__A, CC_REG_UPDATE_KEY, 0); |
|---|
| 1160 | 1153 | |
|---|
| 1161 | | - return 0; |
|---|
| 1154 | + return status; |
|---|
| 1162 | 1155 | } |
|---|
| 1163 | 1156 | |
|---|
| 1164 | 1157 | static int ResetECOD(struct drxd_state *state) |
|---|
| .. | .. |
|---|
| 1312 | 1305 | int status = 0, ret; |
|---|
| 1313 | 1306 | u16 errCode; |
|---|
| 1314 | 1307 | |
|---|
| 1315 | | - Write16(state, SC_RA_RAM_CMD__A, cmd, 0); |
|---|
| 1308 | + status = Write16(state, SC_RA_RAM_CMD__A, cmd, 0); |
|---|
| 1309 | + if (status < 0) |
|---|
| 1310 | + return status; |
|---|
| 1311 | + |
|---|
| 1316 | 1312 | SC_WaitForReady(state); |
|---|
| 1317 | 1313 | |
|---|
| 1318 | 1314 | ret = Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0); |
|---|
| .. | .. |
|---|
| 1339 | 1335 | break; |
|---|
| 1340 | 1336 | } |
|---|
| 1341 | 1337 | SC_WaitForReady(state); |
|---|
| 1342 | | - Write16(state, SC_RA_RAM_CMD_ADDR__A, subCmd, 0); |
|---|
| 1343 | | - Write16(state, SC_RA_RAM_PARAM1__A, param1, 0); |
|---|
| 1344 | | - Write16(state, SC_RA_RAM_PARAM0__A, param0, 0); |
|---|
| 1338 | + status |= Write16(state, SC_RA_RAM_CMD_ADDR__A, subCmd, 0); |
|---|
| 1339 | + status |= Write16(state, SC_RA_RAM_PARAM1__A, param1, 0); |
|---|
| 1340 | + status |= Write16(state, SC_RA_RAM_PARAM0__A, param0, 0); |
|---|
| 1345 | 1341 | |
|---|
| 1346 | 1342 | SC_SendCommand(state, SC_RA_RAM_CMD_PROC_START); |
|---|
| 1347 | 1343 | } while (0); |
|---|
| .. | .. |
|---|
| 1516 | 1512 | switch (deviceId) { |
|---|
| 1517 | 1513 | case 4: |
|---|
| 1518 | 1514 | state->diversity = 1; |
|---|
| 1519 | | - /* fall through */ |
|---|
| 1515 | + fallthrough; |
|---|
| 1520 | 1516 | case 3: |
|---|
| 1521 | 1517 | case 7: |
|---|
| 1522 | 1518 | state->PGA = 1; |
|---|
| 1523 | 1519 | break; |
|---|
| 1524 | 1520 | case 6: |
|---|
| 1525 | 1521 | state->diversity = 1; |
|---|
| 1526 | | - /* fall through */ |
|---|
| 1522 | + fallthrough; |
|---|
| 1527 | 1523 | case 5: |
|---|
| 1528 | 1524 | case 8: |
|---|
| 1529 | 1525 | break; |
|---|
| .. | .. |
|---|
| 1970 | 1966 | switch (p->transmission_mode) { |
|---|
| 1971 | 1967 | default: /* Not set, detect it automatically */ |
|---|
| 1972 | 1968 | operationMode |= SC_RA_RAM_OP_AUTO_MODE__M; |
|---|
| 1973 | | - /* fall through - try first guess DRX_FFTMODE_8K */ |
|---|
| 1969 | + fallthrough; /* try first guess DRX_FFTMODE_8K */ |
|---|
| 1974 | 1970 | case TRANSMISSION_MODE_8K: |
|---|
| 1975 | 1971 | transmissionParams |= SC_RA_RAM_OP_PARAM_MODE_8K; |
|---|
| 1976 | 1972 | if (state->type_A) { |
|---|
| .. | .. |
|---|
| 2143 | 2139 | switch (p->modulation) { |
|---|
| 2144 | 2140 | default: |
|---|
| 2145 | 2141 | operationMode |= SC_RA_RAM_OP_AUTO_CONST__M; |
|---|
| 2146 | | - /* fall through - try first guess DRX_CONSTELLATION_QAM64 */ |
|---|
| 2142 | + fallthrough; /* try first guess DRX_CONSTELLATION_QAM64 */ |
|---|
| 2147 | 2143 | case QAM_64: |
|---|
| 2148 | 2144 | transmissionParams |= SC_RA_RAM_OP_PARAM_CONST_QAM64; |
|---|
| 2149 | 2145 | if (state->type_A) { |
|---|
| .. | .. |
|---|
| 2255 | 2251 | case DRX_CHANNEL_LOW: |
|---|
| 2256 | 2252 | transmissionParams |= SC_RA_RAM_OP_PARAM_PRIO_LO; |
|---|
| 2257 | 2253 | status = Write16(state, EC_SB_REG_PRIOR__A, EC_SB_REG_PRIOR_LO, 0x0000); |
|---|
| 2258 | | - if (status < 0) |
|---|
| 2259 | | - break; |
|---|
| 2260 | 2254 | break; |
|---|
| 2261 | 2255 | case DRX_CHANNEL_HIGH: |
|---|
| 2262 | 2256 | transmissionParams |= SC_RA_RAM_OP_PARAM_PRIO_HI; |
|---|
| 2263 | 2257 | status = Write16(state, EC_SB_REG_PRIOR__A, EC_SB_REG_PRIOR_HI, 0x0000); |
|---|
| 2264 | | - if (status < 0) |
|---|
| 2265 | | - break; |
|---|
| 2266 | 2258 | break; |
|---|
| 2267 | | - |
|---|
| 2268 | 2259 | } |
|---|
| 2269 | 2260 | |
|---|
| 2270 | 2261 | switch (p->code_rate_HP) { |
|---|
| 2271 | 2262 | case FEC_1_2: |
|---|
| 2272 | 2263 | transmissionParams |= SC_RA_RAM_OP_PARAM_RATE_1_2; |
|---|
| 2273 | | - if (state->type_A) { |
|---|
| 2264 | + if (state->type_A) |
|---|
| 2274 | 2265 | status = Write16(state, EC_VD_REG_SET_CODERATE__A, EC_VD_REG_SET_CODERATE_C1_2, 0x0000); |
|---|
| 2275 | | - if (status < 0) |
|---|
| 2276 | | - break; |
|---|
| 2277 | | - } |
|---|
| 2278 | 2266 | break; |
|---|
| 2279 | 2267 | default: |
|---|
| 2280 | 2268 | operationMode |= SC_RA_RAM_OP_AUTO_RATE__M; |
|---|
| 2281 | | - /* fall through */ |
|---|
| 2269 | + fallthrough; |
|---|
| 2282 | 2270 | case FEC_2_3: |
|---|
| 2283 | 2271 | transmissionParams |= SC_RA_RAM_OP_PARAM_RATE_2_3; |
|---|
| 2284 | | - if (state->type_A) { |
|---|
| 2272 | + if (state->type_A) |
|---|
| 2285 | 2273 | status = Write16(state, EC_VD_REG_SET_CODERATE__A, EC_VD_REG_SET_CODERATE_C2_3, 0x0000); |
|---|
| 2286 | | - if (status < 0) |
|---|
| 2287 | | - break; |
|---|
| 2288 | | - } |
|---|
| 2289 | 2274 | break; |
|---|
| 2290 | 2275 | case FEC_3_4: |
|---|
| 2291 | 2276 | transmissionParams |= SC_RA_RAM_OP_PARAM_RATE_3_4; |
|---|
| 2292 | | - if (state->type_A) { |
|---|
| 2277 | + if (state->type_A) |
|---|
| 2293 | 2278 | status = Write16(state, EC_VD_REG_SET_CODERATE__A, EC_VD_REG_SET_CODERATE_C3_4, 0x0000); |
|---|
| 2294 | | - if (status < 0) |
|---|
| 2295 | | - break; |
|---|
| 2296 | | - } |
|---|
| 2297 | 2279 | break; |
|---|
| 2298 | 2280 | case FEC_5_6: |
|---|
| 2299 | 2281 | transmissionParams |= SC_RA_RAM_OP_PARAM_RATE_5_6; |
|---|
| 2300 | | - if (state->type_A) { |
|---|
| 2282 | + if (state->type_A) |
|---|
| 2301 | 2283 | status = Write16(state, EC_VD_REG_SET_CODERATE__A, EC_VD_REG_SET_CODERATE_C5_6, 0x0000); |
|---|
| 2302 | | - if (status < 0) |
|---|
| 2303 | | - break; |
|---|
| 2304 | | - } |
|---|
| 2305 | 2284 | break; |
|---|
| 2306 | 2285 | case FEC_7_8: |
|---|
| 2307 | 2286 | transmissionParams |= SC_RA_RAM_OP_PARAM_RATE_7_8; |
|---|
| 2308 | | - if (state->type_A) { |
|---|
| 2287 | + if (state->type_A) |
|---|
| 2309 | 2288 | status = Write16(state, EC_VD_REG_SET_CODERATE__A, EC_VD_REG_SET_CODERATE_C7_8, 0x0000); |
|---|
| 2310 | | - if (status < 0) |
|---|
| 2311 | | - break; |
|---|
| 2312 | | - } |
|---|
| 2313 | 2289 | break; |
|---|
| 2314 | 2290 | } |
|---|
| 2315 | 2291 | if (status < 0) |
|---|
| .. | .. |
|---|
| 2325 | 2301 | switch (p->bandwidth_hz) { |
|---|
| 2326 | 2302 | case 0: |
|---|
| 2327 | 2303 | p->bandwidth_hz = 8000000; |
|---|
| 2328 | | - /* fall through */ |
|---|
| 2304 | + fallthrough; |
|---|
| 2329 | 2305 | case 8000000: |
|---|
| 2330 | 2306 | /* (64/7)*(8/8)*1000000 */ |
|---|
| 2331 | 2307 | bandwidth = DRXD_BANDWIDTH_8MHZ_IN_HZ; |
|---|
| .. | .. |
|---|
| 2972 | 2948 | kfree(state); |
|---|
| 2973 | 2949 | return NULL; |
|---|
| 2974 | 2950 | } |
|---|
| 2975 | | -EXPORT_SYMBOL(drxd_attach); |
|---|
| 2951 | +EXPORT_SYMBOL_GPL(drxd_attach); |
|---|
| 2976 | 2952 | |
|---|
| 2977 | 2953 | MODULE_DESCRIPTION("DRXD driver"); |
|---|
| 2978 | 2954 | MODULE_AUTHOR("Micronas"); |
|---|