diff options
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r-- | drivers/media/dvb/frontends/dib0090.c | 337 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib7000p.c | 205 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib7000p.h | 2 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib8000.c | 163 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib8000.h | 7 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib9000.c | 204 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib9000.h | 5 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dibx000_common.c | 61 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dibx000_common.h | 10 |
9 files changed, 462 insertions, 532 deletions
diff --git a/drivers/media/dvb/frontends/dib0090.c b/drivers/media/dvb/frontends/dib0090.c index 0e87a0bdf7ab..52ff1a252a90 100644 --- a/drivers/media/dvb/frontends/dib0090.c +++ b/drivers/media/dvb/frontends/dib0090.c | |||
@@ -204,8 +204,8 @@ static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg) | |||
204 | { | 204 | { |
205 | u8 b[2]; | 205 | u8 b[2]; |
206 | struct i2c_msg msg[2] = { | 206 | struct i2c_msg msg[2] = { |
207 | {.addr = state->config->i2c_address,.flags = 0,.buf = ®,.len = 1}, | 207 | {.addr = state->config->i2c_address, .flags = 0, .buf = ®, .len = 1}, |
208 | {.addr = state->config->i2c_address,.flags = I2C_M_RD,.buf = b,.len = 2}, | 208 | {.addr = state->config->i2c_address, .flags = I2C_M_RD, .buf = b, .len = 2}, |
209 | }; | 209 | }; |
210 | if (i2c_transfer(state->i2c, msg, 2) != 2) { | 210 | if (i2c_transfer(state->i2c, msg, 2) != 2) { |
211 | printk(KERN_WARNING "DiB0090 I2C read failed\n"); | 211 | printk(KERN_WARNING "DiB0090 I2C read failed\n"); |
@@ -217,7 +217,7 @@ static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg) | |||
217 | static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val) | 217 | static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val) |
218 | { | 218 | { |
219 | u8 b[3] = { reg & 0xff, val >> 8, val & 0xff }; | 219 | u8 b[3] = { reg & 0xff, val >> 8, val & 0xff }; |
220 | struct i2c_msg msg = {.addr = state->config->i2c_address,.flags = 0,.buf = b,.len = 3 }; | 220 | struct i2c_msg msg = {.addr = state->config->i2c_address, .flags = 0, .buf = b, .len = 3 }; |
221 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { | 221 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { |
222 | printk(KERN_WARNING "DiB0090 I2C write failed\n"); | 222 | printk(KERN_WARNING "DiB0090 I2C write failed\n"); |
223 | return -EREMOTEIO; | 223 | return -EREMOTEIO; |
@@ -228,7 +228,7 @@ static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val) | |||
228 | static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg) | 228 | static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg) |
229 | { | 229 | { |
230 | u8 b[2]; | 230 | u8 b[2]; |
231 | struct i2c_msg msg = {.addr = reg,.flags = I2C_M_RD,.buf = b,.len = 2 }; | 231 | struct i2c_msg msg = {.addr = reg, .flags = I2C_M_RD, .buf = b, .len = 2 }; |
232 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { | 232 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { |
233 | printk(KERN_WARNING "DiB0090 I2C read failed\n"); | 233 | printk(KERN_WARNING "DiB0090 I2C read failed\n"); |
234 | return 0; | 234 | return 0; |
@@ -239,7 +239,7 @@ static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg) | |||
239 | static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val) | 239 | static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val) |
240 | { | 240 | { |
241 | u8 b[2] = { val >> 8, val & 0xff }; | 241 | u8 b[2] = { val >> 8, val & 0xff }; |
242 | struct i2c_msg msg = {.addr = reg,.flags = 0,.buf = b,.len = 2 }; | 242 | struct i2c_msg msg = {.addr = reg, .flags = 0, .buf = b, .len = 2 }; |
243 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { | 243 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { |
244 | printk(KERN_WARNING "DiB0090 I2C write failed\n"); | 244 | printk(KERN_WARNING "DiB0090 I2C write failed\n"); |
245 | return -EREMOTEIO; | 245 | return -EREMOTEIO; |
@@ -347,7 +347,7 @@ static int dib0090_identify(struct dvb_frontend *fe) | |||
347 | 347 | ||
348 | return 0; | 348 | return 0; |
349 | 349 | ||
350 | identification_error: | 350 | identification_error: |
351 | return -EIO; | 351 | return -EIO; |
352 | } | 352 | } |
353 | 353 | ||
@@ -371,8 +371,6 @@ static int dib0090_fw_identify(struct dvb_frontend *fe) | |||
371 | if (identity->product != KROSUS) | 371 | if (identity->product != KROSUS) |
372 | goto identification_error; | 372 | goto identification_error; |
373 | 373 | ||
374 | //From the SOC the version definition has changed | ||
375 | |||
376 | if ((identity->version & 0x3) == SOC) { | 374 | if ((identity->version & 0x3) == SOC) { |
377 | identity->in_soc = 1; | 375 | identity->in_soc = 1; |
378 | switch (identity->version) { | 376 | switch (identity->version) { |
@@ -439,7 +437,7 @@ static int dib0090_fw_identify(struct dvb_frontend *fe) | |||
439 | 437 | ||
440 | return 0; | 438 | return 0; |
441 | 439 | ||
442 | identification_error: | 440 | identification_error: |
443 | return -EIO;; | 441 | return -EIO;; |
444 | } | 442 | } |
445 | 443 | ||
@@ -1009,7 +1007,6 @@ void dib0090_pwm_gain_reset(struct dvb_frontend *fe) | |||
1009 | if (state->current_band == BAND_VHF) { | 1007 | if (state->current_band == BAND_VHF) { |
1010 | if (state->identity.in_soc) { | 1008 | if (state->identity.in_soc) { |
1011 | dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal_socs); | 1009 | dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal_socs); |
1012 | //dib0090_set_rframp_pwm(state, rf_ramp_pwm_vhf_socs); /* TODO */ | ||
1013 | } else { | 1010 | } else { |
1014 | dib0090_set_rframp_pwm(state, rf_ramp_pwm_vhf); | 1011 | dib0090_set_rframp_pwm(state, rf_ramp_pwm_vhf); |
1015 | dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal); | 1012 | dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal); |
@@ -1044,9 +1041,8 @@ EXPORT_SYMBOL(dib0090_pwm_gain_reset); | |||
1044 | static u32 dib0090_get_slow_adc_val(struct dib0090_state *state) | 1041 | static u32 dib0090_get_slow_adc_val(struct dib0090_state *state) |
1045 | { | 1042 | { |
1046 | u16 adc_val = dib0090_read_reg(state, 0x1d); | 1043 | u16 adc_val = dib0090_read_reg(state, 0x1d); |
1047 | if (state->identity.in_soc) { | 1044 | if (state->identity.in_soc) |
1048 | adc_val >>= 2; | 1045 | adc_val >>= 2; |
1049 | } | ||
1050 | return adc_val; | 1046 | return adc_val; |
1051 | } | 1047 | } |
1052 | 1048 | ||
@@ -1200,7 +1196,7 @@ int dib0090_gain_control(struct dvb_frontend *fe) | |||
1200 | #ifdef DEBUG_AGC | 1196 | #ifdef DEBUG_AGC |
1201 | dprintk | 1197 | dprintk |
1202 | ("tune state %d, ADC = %3ddB (ADC err %3d) WBD %3ddB (WBD err %3d, WBD val SADC: %4d), RFGainLimit (TOP): %3d, signal: %3ddBm", | 1198 | ("tune state %d, ADC = %3ddB (ADC err %3d) WBD %3ddB (WBD err %3d, WBD val SADC: %4d), RFGainLimit (TOP): %3d, signal: %3ddBm", |
1203 | (u32) * tune_state, (u32) adc, (u32) adc_error, (u32) wbd, (u32) wbd_error, (u32) wbd_val, | 1199 | (u32) *tune_state, (u32) adc, (u32) adc_error, (u32) wbd, (u32) wbd_error, (u32) wbd_val, |
1204 | (u32) state->rf_gain_limit >> WBD_ALPHA, (s32) 200 + adc - (state->current_gain >> GAIN_ALPHA)); | 1200 | (u32) state->rf_gain_limit >> WBD_ALPHA, (s32) 200 + adc - (state->current_gain >> GAIN_ALPHA)); |
1205 | #endif | 1201 | #endif |
1206 | } | 1202 | } |
@@ -1246,26 +1242,20 @@ u16 dib0090_get_wbd_offset(struct dvb_frontend *fe) | |||
1246 | if (current_temp > 128) | 1242 | if (current_temp > 128) |
1247 | current_temp = 128; | 1243 | current_temp = 128; |
1248 | 1244 | ||
1249 | //What Wbd gain to apply for this range of frequency | ||
1250 | state->wbdmux &= ~(7 << 13); | 1245 | state->wbdmux &= ~(7 << 13); |
1251 | if (wbd->wbd_gain != 0) | 1246 | if (wbd->wbd_gain != 0) |
1252 | state->wbdmux |= (wbd->wbd_gain << 13); | 1247 | state->wbdmux |= (wbd->wbd_gain << 13); |
1253 | else | 1248 | else |
1254 | state->wbdmux |= (4 << 13); // 4 is the default WBD gain | 1249 | state->wbdmux |= (4 << 13); |
1255 | 1250 | ||
1256 | dib0090_write_reg(state, 0x10, state->wbdmux); | 1251 | dib0090_write_reg(state, 0x10, state->wbdmux); |
1257 | 1252 | ||
1258 | //All the curves are linear with slope*f/64+offset | ||
1259 | wbd_thot = wbd->offset_hot - (((u32) wbd->slope_hot * f_MHz) >> 6); | 1253 | wbd_thot = wbd->offset_hot - (((u32) wbd->slope_hot * f_MHz) >> 6); |
1260 | wbd_tcold = wbd->offset_cold - (((u32) wbd->slope_cold * f_MHz) >> 6); | 1254 | wbd_tcold = wbd->offset_cold - (((u32) wbd->slope_cold * f_MHz) >> 6); |
1261 | 1255 | ||
1262 | // Iet assumes that thot-tcold = 130 equiv 128, current temperature ref is -30deg | ||
1263 | |||
1264 | wbd_tcold += ((wbd_thot - wbd_tcold) * current_temp) >> 7; | 1256 | wbd_tcold += ((wbd_thot - wbd_tcold) * current_temp) >> 7; |
1265 | 1257 | ||
1266 | //for (offset = 0; offset < 1000; offset += 4) | 1258 | state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + wbd_tcold); |
1267 | // dbgp("offset = %d -> %d\n", offset, dib0090_wbd_to_db(state, offset)); | ||
1268 | state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + wbd_tcold); // get the value in dBm from the offset | ||
1269 | dprintk("wbd-target: %d dB", (u32) state->wbd_target); | 1259 | dprintk("wbd-target: %d dB", (u32) state->wbd_target); |
1270 | dprintk("wbd offset applied is %d", wbd_tcold); | 1260 | dprintk("wbd offset applied is %d", wbd_tcold); |
1271 | 1261 | ||
@@ -1323,7 +1313,6 @@ static const u16 dib0090_defaults[] = { | |||
1323 | }; | 1313 | }; |
1324 | 1314 | ||
1325 | static const u16 dib0090_p1g_additionnal_defaults[] = { | 1315 | static const u16 dib0090_p1g_additionnal_defaults[] = { |
1326 | // additionnal INITIALISATION for p1g to be written after dib0090_defaults | ||
1327 | 1, 0x05, | 1316 | 1, 0x05, |
1328 | 0xabcd, | 1317 | 0xabcd, |
1329 | 1318 | ||
@@ -1362,45 +1351,44 @@ static void dib0090_set_default_config(struct dib0090_state *state, const u16 * | |||
1362 | 1351 | ||
1363 | void dib0090_set_EFUSE(struct dib0090_state *state) | 1352 | void dib0090_set_EFUSE(struct dib0090_state *state) |
1364 | { | 1353 | { |
1365 | u8 c,h,n; | 1354 | u8 c, h, n; |
1366 | u16 e2,e4; | 1355 | u16 e2, e4; |
1367 | u16 cal; | 1356 | u16 cal; |
1368 | 1357 | ||
1369 | e2=dib0090_read_reg(state,0x26); | 1358 | e2 = dib0090_read_reg(state, 0x26); |
1370 | e4=dib0090_read_reg(state,0x28); | 1359 | e4 = dib0090_read_reg(state, 0x28); |
1371 | 1360 | ||
1372 | if ((state->identity.version == P1D_E_F) || // All P1F uses the internal calibration | 1361 | if ((state->identity.version == P1D_E_F) || |
1373 | (state->identity.version == P1G) || (e2 == 0xffff)) { //W0090G11R1 and W0090G11R1-D : We will find the calibration Value of the Baseband | 1362 | (state->identity.version == P1G) || (e2 == 0xffff)) { |
1374 | 1363 | ||
1375 | dib0090_write_reg(state,0x22,0x10); //Start the Calib | 1364 | dib0090_write_reg(state, 0x22, 0x10); |
1376 | cal = (dib0090_read_reg(state,0x22)>>6) & 0x3ff; | 1365 | cal = (dib0090_read_reg(state, 0x22) >> 6) & 0x3ff; |
1377 | 1366 | ||
1378 | if ((cal<670) || (cal==1023)) //Cal at 800 would give too high value for the n | 1367 | if ((cal < 670) || (cal == 1023)) |
1379 | cal=850; //Recenter the n to 32 | 1368 | cal = 850; |
1380 | n = 165 - ((cal * 10)>>6) ; | 1369 | n = 165 - ((cal * 10)>>6) ; |
1381 | e2 = e4 = (3<<12) | (34<<6) | (n); | 1370 | e2 = e4 = (3<<12) | (34<<6) | (n); |
1382 | } | 1371 | } |
1383 | 1372 | ||
1384 | if (e2!=e4) { | 1373 | if (e2 != e4) |
1385 | e2 &= e4; /* Remove the redundancy */ | 1374 | e2 &= e4; /* Remove the redundancy */ |
1386 | } | 1375 | |
1387 | 1376 | if (e2 != 0xffff) { | |
1388 | if (e2 != 0xffff) { | 1377 | c = e2 & 0x3f; |
1389 | c = e2 & 0x3f; | 1378 | n = (e2 >> 12) & 0xf; |
1390 | n = (e2 >> 12) & 0xf; | 1379 | h = (e2 >> 6) & 0x3f; |
1391 | h= (e2 >> 6) & 0x3f; | 1380 | |
1392 | 1381 | if ((c >= CAP_VALUE_MAX) || (c <= CAP_VALUE_MIN)) | |
1393 | if ((c >= CAP_VALUE_MAX) || (c <= CAP_VALUE_MIN)) | 1382 | c = 32; |
1394 | c=32; | 1383 | if ((h >= HR_MAX) || (h <= HR_MIN)) |
1395 | if ((h >= HR_MAX) || (h <= HR_MIN)) | 1384 | h = 34; |
1396 | h=34; | 1385 | if ((n >= POLY_MAX) || (n <= POLY_MIN)) |
1397 | if ((n >= POLY_MAX) || (n <= POLY_MIN)) | 1386 | n = 3; |
1398 | n=3; | 1387 | |
1399 | 1388 | dib0090_write_reg(state, 0x13, (h << 10)) ; | |
1400 | dib0090_write_reg(state,0x13, (h << 10)) ; | 1389 | e2 = (n<<11) | ((h>>2)<<6) | (c); |
1401 | e2 = (n<<11) | ((h>>2)<<6) | (c); | 1390 | dib0090_write_reg(state, 0x2, e2) ; /* Load the BB_2 */ |
1402 | dib0090_write_reg(state,0x2, e2) ; /* Load the BB_2 */ | 1391 | } |
1403 | } | ||
1404 | } | 1392 | } |
1405 | 1393 | ||
1406 | static int dib0090_reset(struct dvb_frontend *fe) | 1394 | static int dib0090_reset(struct dvb_frontend *fe) |
@@ -1425,14 +1413,15 @@ static int dib0090_reset(struct dvb_frontend *fe) | |||
1425 | 1413 | ||
1426 | dib0090_set_default_config(state, dib0090_defaults); | 1414 | dib0090_set_default_config(state, dib0090_defaults); |
1427 | 1415 | ||
1428 | if (state->identity.in_soc) | 1416 | if (state->identity.in_soc) |
1429 | dib0090_write_reg(state, 0x18, 0x2910); /* charge pump current = 0 */ | 1417 | dib0090_write_reg(state, 0x18, 0x2910); /* charge pump current = 0 */ |
1430 | 1418 | ||
1431 | if (state->identity.p1g) | 1419 | if (state->identity.p1g) |
1432 | dib0090_set_default_config(state, dib0090_p1g_additionnal_defaults); | 1420 | dib0090_set_default_config(state, dib0090_p1g_additionnal_defaults); |
1433 | 1421 | ||
1434 | if (((state->identity.version & 0x1f) >= P1D_E_F) || (state->identity.in_soc)) /* Update the efuse : Only available for KROSUS > P1C and SOC as well*/ | 1422 | /* Update the efuse : Only available for KROSUS > P1C and SOC as well*/ |
1435 | dib0090_set_EFUSE(state); | 1423 | if (((state->identity.version & 0x1f) >= P1D_E_F) || (state->identity.in_soc)) |
1424 | dib0090_set_EFUSE(state); | ||
1436 | 1425 | ||
1437 | /* Congigure in function of the crystal */ | 1426 | /* Congigure in function of the crystal */ |
1438 | if (state->config->io.clock_khz >= 24000) | 1427 | if (state->config->io.clock_khz >= 24000) |
@@ -1501,11 +1490,11 @@ static const struct dc_calibration dc_table[] = { | |||
1501 | static const struct dc_calibration dc_p1g_table[] = { | 1490 | static const struct dc_calibration dc_p1g_table[] = { |
1502 | /* Step1 BB gain1= 26 with boost 1, gain 2 = 0 */ | 1491 | /* Step1 BB gain1= 26 with boost 1, gain 2 = 0 */ |
1503 | /* addr ; trim reg offset ; pga ; CTRL_BB1 value ; i or q */ | 1492 | /* addr ; trim reg offset ; pga ; CTRL_BB1 value ; i or q */ |
1504 | {0x06, 5, 1, (1 << 13) | (0 << 8) | (15 << 3), 1}, // offset_trim2_i_chann 0 0 5 0 0 1 6 9 5 | 1493 | {0x06, 5, 1, (1 << 13) | (0 << 8) | (15 << 3), 1}, |
1505 | {0x07, 11, 1, (1 << 13) | (0 << 8) | (15 << 3), 0}, // offset_trim2_q_chann 0 0 5 0 0 1 7 15 11 | 1494 | {0x07, 11, 1, (1 << 13) | (0 << 8) | (15 << 3), 0}, |
1506 | /* Step 2 BB gain 1 = 26 with boost = 1 & gain 2 = 29 */ | 1495 | /* Step 2 BB gain 1 = 26 with boost = 1 & gain 2 = 29 */ |
1507 | {0x06, 0, 0, (1 << 13) | (29 << 8) | (15 << 3), 1}, // offset_trim1_i_chann 0 0 5 0 0 1 6 4 0 | 1496 | {0x06, 0, 0, (1 << 13) | (29 << 8) | (15 << 3), 1}, |
1508 | {0x06, 10, 0, (1 << 13) | (29 << 8) | (15 << 3), 0}, // offset_trim1_q_chann 0 0 5 0 0 1 6 14 10 | 1497 | {0x06, 10, 0, (1 << 13) | (29 << 8) | (15 << 3), 0}, |
1509 | {0}, | 1498 | {0}, |
1510 | }; | 1499 | }; |
1511 | 1500 | ||
@@ -1542,8 +1531,8 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front | |||
1542 | dib0090_write_reg(state, 0x24, reg); | 1531 | dib0090_write_reg(state, 0x24, reg); |
1543 | 1532 | ||
1544 | state->wbdmux = dib0090_read_reg(state, 0x10); | 1533 | state->wbdmux = dib0090_read_reg(state, 0x10); |
1545 | dib0090_write_reg(state, 0x10, (state->wbdmux & ~(0xff << 3)) | (0x7 << 3) | 0x3); // connect BB, disable WDB enable* | 1534 | dib0090_write_reg(state, 0x10, (state->wbdmux & ~(0xff << 3)) | (0x7 << 3) | 0x3); |
1546 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) & ~(1 << 14)); //Discard the DataTX | 1535 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) & ~(1 << 14)); |
1547 | 1536 | ||
1548 | state->dc = dc_table; | 1537 | state->dc = dc_table; |
1549 | 1538 | ||
@@ -1596,11 +1585,11 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front | |||
1596 | if ((state->adc_diff & 0x8000) == (state->min_adc_diff & 0x8000) && steps(state->step) < 15) { | 1585 | if ((state->adc_diff & 0x8000) == (state->min_adc_diff & 0x8000) && steps(state->step) < 15) { |
1597 | /* stop search when the delta the sign is changing and Steps =15 and Step=0 is force for continuance */ | 1586 | /* stop search when the delta the sign is changing and Steps =15 and Step=0 is force for continuance */ |
1598 | state->step++; | 1587 | state->step++; |
1599 | state->min_adc_diff = state->adc_diff; //min is used as N-1 | 1588 | state->min_adc_diff = state->adc_diff; |
1600 | *tune_state = CT_TUNER_STEP_1; | 1589 | *tune_state = CT_TUNER_STEP_1; |
1601 | } else { | 1590 | } else { |
1602 | /* the minimum was what we have seen in the step before */ | 1591 | /* the minimum was what we have seen in the step before */ |
1603 | if (ABS(state->adc_diff) > ABS(state->min_adc_diff)) { //Come back to the previous state since the delta was better | 1592 | if (ABS(state->adc_diff) > ABS(state->min_adc_diff)) { |
1604 | dprintk("Since adc_diff N = %d > adc_diff step N-1 = %d, Come back one step", state->adc_diff, state->min_adc_diff); | 1593 | dprintk("Since adc_diff N = %d > adc_diff step N-1 = %d, Come back one step", state->adc_diff, state->min_adc_diff); |
1605 | state->step--; | 1594 | state->step--; |
1606 | } | 1595 | } |
@@ -1618,7 +1607,7 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front | |||
1618 | break; | 1607 | break; |
1619 | 1608 | ||
1620 | case CT_TUNER_STEP_6: | 1609 | case CT_TUNER_STEP_6: |
1621 | dib0090_write_reg(state, 0x07, state->bb7 & ~0x0008); //Force the test bus to be off | 1610 | dib0090_write_reg(state, 0x07, state->bb7 & ~0x0008); |
1622 | dib0090_write_reg(state, 0x1f, 0x7); | 1611 | dib0090_write_reg(state, 0x1f, 0x7); |
1623 | *tune_state = CT_TUNER_START; /* reset done -> real tuning can now begin */ | 1612 | *tune_state = CT_TUNER_START; /* reset done -> real tuning can now begin */ |
1624 | state->calibrate &= ~DC_CAL; | 1613 | state->calibrate &= ~DC_CAL; |
@@ -1653,9 +1642,9 @@ static int dib0090_wbd_calibration(struct dib0090_state *state, enum frontend_tu | |||
1653 | return 0; | 1642 | return 0; |
1654 | } | 1643 | } |
1655 | 1644 | ||
1656 | dib0090_write_reg(state, 0x10, 0x1b81 | (1 << 10) | (wbd_gain << 13) | (1 << 3)); // Force: WBD enable,gain to 4, mux to WBD | 1645 | dib0090_write_reg(state, 0x10, 0x1b81 | (1 << 10) | (wbd_gain << 13) | (1 << 3)); |
1657 | 1646 | ||
1658 | dib0090_write_reg(state, 0x24, ((EN_UHF & 0x0fff) | (1 << 1))); //Discard all LNA but crystal !!! | 1647 | dib0090_write_reg(state, 0x24, ((EN_UHF & 0x0fff) | (1 << 1))); |
1659 | *tune_state = CT_TUNER_STEP_0; | 1648 | *tune_state = CT_TUNER_STEP_0; |
1660 | state->wbd_calibration_gain = wbd_gain; | 1649 | state->wbd_calibration_gain = wbd_gain; |
1661 | return 90; /* wait for the WBDMUX to switch and for the ADC to sample */ | 1650 | return 90; /* wait for the WBDMUX to switch and for the ADC to sample */ |
@@ -1788,98 +1777,94 @@ static const struct dib0090_tuning dib0090_tuning_table[] = { | |||
1788 | }; | 1777 | }; |
1789 | 1778 | ||
1790 | static const struct dib0090_tuning dib0090_p1g_tuning_table[] = { | 1779 | static const struct dib0090_tuning dib0090_p1g_tuning_table[] = { |
1791 | //max_freq, switch_trim, lna_tune, lna_bias, v2i, mix, load, tuner_enable; | ||
1792 | #ifdef CONFIG_BAND_CBAND | 1780 | #ifdef CONFIG_BAND_CBAND |
1793 | {170000, 4, 1, 0x820f, 0x300, 0x2d22, 0x82cb, EN_CAB}, // FM EN_CAB | 1781 | {170000, 4, 1, 0x820f, 0x300, 0x2d22, 0x82cb, EN_CAB}, |
1794 | #endif | 1782 | #endif |
1795 | #ifdef CONFIG_BAND_VHF | 1783 | #ifdef CONFIG_BAND_VHF |
1796 | {184000, 1, 1, 15, 0x300, 0x4d12, 0xb94e, EN_VHF}, // VHF EN_VHF | 1784 | {184000, 1, 1, 15, 0x300, 0x4d12, 0xb94e, EN_VHF}, |
1797 | {227000, 1, 3, 15, 0x300, 0x4d12, 0xb94e, EN_VHF}, // VHF EN_VHF | 1785 | {227000, 1, 3, 15, 0x300, 0x4d12, 0xb94e, EN_VHF}, |
1798 | {380000, 1, 7, 15, 0x300, 0x4d12, 0xb94e, EN_VHF}, // VHF EN_VHF | 1786 | {380000, 1, 7, 15, 0x300, 0x4d12, 0xb94e, EN_VHF}, |
1799 | #endif | 1787 | #endif |
1800 | #ifdef CONFIG_BAND_UHF | 1788 | #ifdef CONFIG_BAND_UHF |
1801 | {510000, 2, 0, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1789 | {510000, 2, 0, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1802 | {540000, 2, 1, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1790 | {540000, 2, 1, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1803 | {600000, 2, 3, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1791 | {600000, 2, 3, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1804 | {630000, 2, 4, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1792 | {630000, 2, 4, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1805 | {680000, 2, 5, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1793 | {680000, 2, 5, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1806 | {720000, 2, 6, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1794 | {720000, 2, 6, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1807 | {900000, 2, 7, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1795 | {900000, 2, 7, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1808 | #endif | 1796 | #endif |
1809 | #ifdef CONFIG_BAND_LBAND | 1797 | #ifdef CONFIG_BAND_LBAND |
1810 | {1500000, 4, 0, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, // LBD EN_LBD | 1798 | {1500000, 4, 0, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, |
1811 | {1600000, 4, 1, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, // LBD EN_LBD | 1799 | {1600000, 4, 1, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, |
1812 | {1800000, 4, 3, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, // LBD EN_LBD | 1800 | {1800000, 4, 3, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, |
1813 | #endif | 1801 | #endif |
1814 | #ifdef CONFIG_BAND_SBAND | 1802 | #ifdef CONFIG_BAND_SBAND |
1815 | {2300000, 1, 4, 20, 0x300, 0x2d2A, 0x82c7, EN_SBD}, // SBD EN_SBD | 1803 | {2300000, 1, 4, 20, 0x300, 0x2d2A, 0x82c7, EN_SBD}, |
1816 | {2900000, 1, 7, 20, 0x280, 0x2deb, 0x8347, EN_SBD}, // SBD EN_SBD | 1804 | {2900000, 1, 7, 20, 0x280, 0x2deb, 0x8347, EN_SBD}, |
1817 | #endif | 1805 | #endif |
1818 | }; | 1806 | }; |
1819 | 1807 | ||
1820 | static const struct dib0090_pll dib0090_p1g_pll_table[] = { | 1808 | static const struct dib0090_pll dib0090_p1g_pll_table[] = { |
1821 | #ifdef CONFIG_BAND_CBAND | 1809 | #ifdef CONFIG_BAND_CBAND |
1822 | {57000, 0, 11, 48, 6}, // CAB | 1810 | {57000, 0, 11, 48, 6}, |
1823 | {70000, 1, 11, 48, 6}, // CAB | 1811 | {70000, 1, 11, 48, 6}, |
1824 | {86000, 0, 10, 32, 4}, // CAB | 1812 | {86000, 0, 10, 32, 4}, |
1825 | {105000, 1, 10, 32, 4}, // FM | 1813 | {105000, 1, 10, 32, 4}, |
1826 | {115000, 0, 9, 24, 6}, // FM | 1814 | {115000, 0, 9, 24, 6}, |
1827 | {140000, 1, 9, 24, 6}, // MID FM VHF | 1815 | {140000, 1, 9, 24, 6}, |
1828 | {170000, 0, 8, 16, 4}, // MID FM VHF | 1816 | {170000, 0, 8, 16, 4}, |
1829 | #endif | 1817 | #endif |
1830 | #ifdef CONFIG_BAND_VHF | 1818 | #ifdef CONFIG_BAND_VHF |
1831 | {200000, 1, 8, 16, 4}, // VHF | 1819 | {200000, 1, 8, 16, 4}, |
1832 | {230000, 0, 7, 12, 6}, // VHF | 1820 | {230000, 0, 7, 12, 6}, |
1833 | {280000, 1, 7, 12, 6}, // MID VHF UHF | 1821 | {280000, 1, 7, 12, 6}, |
1834 | {340000, 0, 6, 8, 4}, // MID VHF UHF | 1822 | {340000, 0, 6, 8, 4}, |
1835 | {380000, 1, 6, 8, 4}, // MID VHF UHF | 1823 | {380000, 1, 6, 8, 4}, |
1836 | {455000, 0, 5, 6, 6}, // MID VHF UHF | 1824 | {455000, 0, 5, 6, 6}, |
1837 | #endif | 1825 | #endif |
1838 | #ifdef CONFIG_BAND_UHF | 1826 | #ifdef CONFIG_BAND_UHF |
1839 | {580000, 1, 5, 6, 6}, // UHF | 1827 | {580000, 1, 5, 6, 6}, |
1840 | {680000, 0, 4, 4, 4}, // UHF | 1828 | {680000, 0, 4, 4, 4}, |
1841 | {860000, 1, 4, 4, 4}, // UHF | 1829 | {860000, 1, 4, 4, 4}, |
1842 | #endif | 1830 | #endif |
1843 | #ifdef CONFIG_BAND_LBAND | 1831 | #ifdef CONFIG_BAND_LBAND |
1844 | {1800000, 1, 2, 2, 4}, // LBD | 1832 | {1800000, 1, 2, 2, 4}, |
1845 | #endif | 1833 | #endif |
1846 | #ifdef CONFIG_BAND_SBAND | 1834 | #ifdef CONFIG_BAND_SBAND |
1847 | {2900000, 0, 1, 1, 6}, // SBD | 1835 | {2900000, 0, 1, 1, 6}, |
1848 | #endif | 1836 | #endif |
1849 | }; | 1837 | }; |
1850 | 1838 | ||
1851 | static const struct dib0090_tuning dib0090_p1g_tuning_table_fm_vhf_on_cband[] = { | 1839 | static const struct dib0090_tuning dib0090_p1g_tuning_table_fm_vhf_on_cband[] = { |
1852 | //max_freq, switch_trim, lna_tune, lna_bias, v2i, mix, load, tuner_enable; | ||
1853 | #ifdef CONFIG_BAND_CBAND | 1840 | #ifdef CONFIG_BAND_CBAND |
1854 | {184000, 4, 3, 0x4187, 0x2c0, 0x2d22, 0x81cb, EN_CAB}, // FM EN_CAB // 0x8190 Good perf but higher current //0x4187 Low current | 1841 | {184000, 4, 3, 0x4187, 0x2c0, 0x2d22, 0x81cb, EN_CAB}, |
1855 | {227000, 4, 3, 0x4187, 0x2c0, 0x2d22, 0x81cb, EN_CAB}, // FM EN_CAB | 1842 | {227000, 4, 3, 0x4187, 0x2c0, 0x2d22, 0x81cb, EN_CAB}, |
1856 | {380000, 4, 3, 0x4187, 0x2c0, 0x2d22, 0x81cb, EN_CAB}, // FM EN_CAB | 1843 | {380000, 4, 3, 0x4187, 0x2c0, 0x2d22, 0x81cb, EN_CAB}, |
1857 | #endif | 1844 | #endif |
1858 | #ifdef CONFIG_BAND_UHF | 1845 | #ifdef CONFIG_BAND_UHF |
1859 | {520000, 2, 0, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1846 | {520000, 2, 0, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1860 | {550000, 2, 2, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1847 | {550000, 2, 2, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1861 | {650000, 2, 3, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1848 | {650000, 2, 3, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1862 | {750000, 2, 5, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1849 | {750000, 2, 5, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1863 | {850000, 2, 6, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1850 | {850000, 2, 6, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1864 | {900000, 2, 7, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, // UHF | 1851 | {900000, 2, 7, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF}, |
1865 | #endif | 1852 | #endif |
1866 | #ifdef CONFIG_BAND_LBAND | 1853 | #ifdef CONFIG_BAND_LBAND |
1867 | {1500000, 4, 0, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, // LBD EN_LBD | 1854 | {1500000, 4, 0, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, |
1868 | {1600000, 4, 1, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, // LBD EN_LBD | 1855 | {1600000, 4, 1, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, |
1869 | {1800000, 4, 3, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, // LBD EN_LBD | 1856 | {1800000, 4, 3, 20, 0x300, 0x1912, 0x82c9, EN_LBD}, |
1870 | #endif | 1857 | #endif |
1871 | #ifdef CONFIG_BAND_SBAND | 1858 | #ifdef CONFIG_BAND_SBAND |
1872 | {2300000, 1, 4, 20, 0x300, 0x2d2A, 0x82c7, EN_SBD}, // SBD EN_SBD | 1859 | {2300000, 1, 4, 20, 0x300, 0x2d2A, 0x82c7, EN_SBD}, |
1873 | {2900000, 1, 7, 20, 0x280, 0x2deb, 0x8347, EN_SBD}, // SBD EN_SBD | 1860 | {2900000, 1, 7, 20, 0x280, 0x2deb, 0x8347, EN_SBD}, |
1874 | #endif | 1861 | #endif |
1875 | }; | 1862 | }; |
1876 | 1863 | ||
1877 | static const struct dib0090_tuning dib0090_tuning_table_cband_7090[] = { | 1864 | static const struct dib0090_tuning dib0090_tuning_table_cband_7090[] = { |
1878 | //max_freq, switch_trim, lna_tune, lna_bias, v2i, mix, load, tuner_enable; | ||
1879 | #ifdef CONFIG_BAND_CBAND | 1865 | #ifdef CONFIG_BAND_CBAND |
1880 | //{ 184000, 4, 3, 0x018F, 0x2c0, 0x2d22, 0xb9ce, EN_CAB }, // 0x81ce 0x8190 Good perf but higher current //0x4187 Low current | ||
1881 | {300000, 4, 3, 0x018F, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, | 1866 | {300000, 4, 3, 0x018F, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, |
1882 | {380000, 4, 10, 0x018F, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, //0x4187 | 1867 | {380000, 4, 10, 0x018F, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, |
1883 | {570000, 4, 10, 0x8190, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, | 1868 | {570000, 4, 10, 0x8190, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, |
1884 | {858000, 4, 5, 0x8190, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, | 1869 | {858000, 4, 5, 0x8190, 0x2c0, 0x2d22, 0xb9ce, EN_CAB}, |
1885 | #endif | 1870 | #endif |
@@ -1916,17 +1901,15 @@ static int dib0090_captrim_search(struct dib0090_state *state, enum frontend_tun | |||
1916 | state->captrim = state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7f; | 1901 | state->captrim = state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7f; |
1917 | } | 1902 | } |
1918 | } | 1903 | } |
1919 | state->adc_diff = 3000; // start with a unreachable high number : only set for KROSUS < P1G */ | 1904 | state->adc_diff = 3000; |
1920 | *tune_state = CT_TUNER_STEP_0; | 1905 | *tune_state = CT_TUNER_STEP_0; |
1921 | 1906 | ||
1922 | } else if (*tune_state == CT_TUNER_STEP_0) { | 1907 | } else if (*tune_state == CT_TUNER_STEP_0) { |
1923 | if (state->identity.p1g && !force_soft_search) { | 1908 | if (state->identity.p1g && !force_soft_search) { |
1924 | // 30MHz => Code 15 for the ration => 128us to lock. Giving approximately | 1909 | u8 ratio = 31; |
1925 | u8 ratio = 31; // (state->config->io.clock_khz / 1024 + 1) & 0x1f; | ||
1926 | 1910 | ||
1927 | dib0090_write_reg(state, 0x40, (3 << 7) | (ratio << 2) | (1 << 1) | 1); | 1911 | dib0090_write_reg(state, 0x40, (3 << 7) | (ratio << 2) | (1 << 1) | 1); |
1928 | dib0090_read_reg(state, 0x40); | 1912 | dib0090_read_reg(state, 0x40); |
1929 | //dib0090_write_reg(state, 0x40, (3<<7) | ((((state->config->io.clock_khz >> 11)+1) & 0x1f)<<2) | (1<<1) | 1); | ||
1930 | ret = 50; | 1913 | ret = 50; |
1931 | } else { | 1914 | } else { |
1932 | state->step /= 2; | 1915 | state->step /= 2; |
@@ -1968,9 +1951,6 @@ static int dib0090_captrim_search(struct dib0090_state *state, enum frontend_tun | |||
1968 | dprintk("CAPTRIM=%d is closer to target (%d/%d)", (u32) state->captrim, (u32) adc, (u32) state->adc_diff); | 1951 | dprintk("CAPTRIM=%d is closer to target (%d/%d)", (u32) state->captrim, (u32) adc, (u32) state->adc_diff); |
1969 | state->adc_diff = adc; | 1952 | state->adc_diff = adc; |
1970 | state->fcaptrim = state->captrim; | 1953 | state->fcaptrim = state->captrim; |
1971 | //we could break here, to save time, if we reached a close-enough value | ||
1972 | //e.g.: if (state->adc_diff < 20) | ||
1973 | //break; | ||
1974 | } | 1954 | } |
1975 | 1955 | ||
1976 | state->captrim += step_sign * state->step; | 1956 | state->captrim += step_sign * state->step; |
@@ -1979,7 +1959,7 @@ static int dib0090_captrim_search(struct dib0090_state *state, enum frontend_tun | |||
1979 | else | 1959 | else |
1980 | *tune_state = CT_TUNER_STEP_2; | 1960 | *tune_state = CT_TUNER_STEP_2; |
1981 | 1961 | ||
1982 | ret = 25; //LOLO changed from 15 | 1962 | ret = 25; |
1983 | } | 1963 | } |
1984 | } else if (*tune_state == CT_TUNER_STEP_2) { /* this step is only used by krosus < P1G */ | 1964 | } else if (*tune_state == CT_TUNER_STEP_2) { /* this step is only used by krosus < P1G */ |
1985 | /*write the final cptrim config */ | 1965 | /*write the final cptrim config */ |
@@ -2000,28 +1980,27 @@ static int dib0090_get_temperature(struct dib0090_state *state, enum frontend_tu | |||
2000 | int ret = 15; | 1980 | int ret = 15; |
2001 | s16 val; | 1981 | s16 val; |
2002 | 1982 | ||
2003 | //The assumption is that the AGC is not active | ||
2004 | switch (*tune_state) { | 1983 | switch (*tune_state) { |
2005 | case CT_TUNER_START: | 1984 | case CT_TUNER_START: |
2006 | state->wbdmux = dib0090_read_reg(state, 0x10); | 1985 | state->wbdmux = dib0090_read_reg(state, 0x10); |
2007 | dib0090_write_reg(state, 0x10, (state->wbdmux & ~(0xff << 3)) | (0x8 << 3)); //Move to the bias and clear the wbd enable | 1986 | dib0090_write_reg(state, 0x10, (state->wbdmux & ~(0xff << 3)) | (0x8 << 3)); |
2008 | 1987 | ||
2009 | state->bias = dib0090_read_reg(state, 0x13); | 1988 | state->bias = dib0090_read_reg(state, 0x13); |
2010 | dib0090_write_reg(state, 0x13, state->bias | (0x3 << 8)); //Move to the Ref | 1989 | dib0090_write_reg(state, 0x13, state->bias | (0x3 << 8)); |
2011 | 1990 | ||
2012 | *tune_state = CT_TUNER_STEP_0; | 1991 | *tune_state = CT_TUNER_STEP_0; |
2013 | /* wait for the WBDMUX to switch and for the ADC to sample */ | 1992 | /* wait for the WBDMUX to switch and for the ADC to sample */ |
2014 | break; | 1993 | break; |
2015 | 1994 | ||
2016 | case CT_TUNER_STEP_0: | 1995 | case CT_TUNER_STEP_0: |
2017 | state->adc_diff = dib0090_get_slow_adc_val(state); // Get the value for the Ref | 1996 | state->adc_diff = dib0090_get_slow_adc_val(state); |
2018 | dib0090_write_reg(state, 0x13, (state->bias & ~(0x3 << 8)) | (0x2 << 8)); //Move to the Ptat | 1997 | dib0090_write_reg(state, 0x13, (state->bias & ~(0x3 << 8)) | (0x2 << 8)); |
2019 | *tune_state = CT_TUNER_STEP_1; | 1998 | *tune_state = CT_TUNER_STEP_1; |
2020 | break; | 1999 | break; |
2021 | 2000 | ||
2022 | case CT_TUNER_STEP_1: | 2001 | case CT_TUNER_STEP_1: |
2023 | val = dib0090_get_slow_adc_val(state); // Get the value for the Ptat | 2002 | val = dib0090_get_slow_adc_val(state); |
2024 | state->temperature = ((s16) ((val - state->adc_diff) * 180) >> 8) + 55; // +55 is defined as = -30deg | 2003 | state->temperature = ((s16) ((val - state->adc_diff) * 180) >> 8) + 55; |
2025 | 2004 | ||
2026 | dprintk("temperature: %d C", state->temperature - 30); | 2005 | dprintk("temperature: %d C", state->temperature - 30); |
2027 | 2006 | ||
@@ -2029,14 +2008,13 @@ static int dib0090_get_temperature(struct dib0090_state *state, enum frontend_tu | |||
2029 | break; | 2008 | break; |
2030 | 2009 | ||
2031 | case CT_TUNER_STEP_2: | 2010 | case CT_TUNER_STEP_2: |
2032 | //Reload the start values. | ||
2033 | dib0090_write_reg(state, 0x13, state->bias); | 2011 | dib0090_write_reg(state, 0x13, state->bias); |
2034 | dib0090_write_reg(state, 0x10, state->wbdmux); /* write back original WBDMUX */ | 2012 | dib0090_write_reg(state, 0x10, state->wbdmux); /* write back original WBDMUX */ |
2035 | 2013 | ||
2036 | *tune_state = CT_TUNER_START; | 2014 | *tune_state = CT_TUNER_START; |
2037 | state->calibrate &= ~TEMP_CAL; | 2015 | state->calibrate &= ~TEMP_CAL; |
2038 | if (state->config->analog_output == 0) | 2016 | if (state->config->analog_output == 0) |
2039 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) | (1 << 14)); //Set the DataTX | 2017 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) | (1 << 14)); |
2040 | 2018 | ||
2041 | break; | 2019 | break; |
2042 | 2020 | ||
@@ -2070,16 +2048,17 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2070 | /* deactivate DataTX before some calibrations */ | 2048 | /* deactivate DataTX before some calibrations */ |
2071 | if (state->calibrate & (DC_CAL | TEMP_CAL | WBD_CAL)) | 2049 | if (state->calibrate & (DC_CAL | TEMP_CAL | WBD_CAL)) |
2072 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) & ~(1 << 14)); | 2050 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) & ~(1 << 14)); |
2073 | else /* Activate DataTX in case a calibration has been done before */ if (state->config->analog_output == 0) | 2051 | else |
2074 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) | (1 << 14)); | 2052 | /* Activate DataTX in case a calibration has been done before */ |
2053 | if (state->config->analog_output == 0) | ||
2054 | dib0090_write_reg(state, 0x23, dib0090_read_reg(state, 0x23) | (1 << 14)); | ||
2075 | } | 2055 | } |
2076 | 2056 | ||
2077 | if (state->calibrate & DC_CAL) | 2057 | if (state->calibrate & DC_CAL) |
2078 | return dib0090_dc_offset_calibration(state, tune_state); | 2058 | return dib0090_dc_offset_calibration(state, tune_state); |
2079 | else if (state->calibrate & WBD_CAL) { | 2059 | else if (state->calibrate & WBD_CAL) { |
2080 | if (state->current_rf == 0) { | 2060 | if (state->current_rf == 0) |
2081 | state->current_rf = state->fe->dtv_property_cache.frequency / 1000; | 2061 | state->current_rf = state->fe->dtv_property_cache.frequency / 1000; |
2082 | } | ||
2083 | return dib0090_wbd_calibration(state, tune_state); | 2062 | return dib0090_wbd_calibration(state, tune_state); |
2084 | } else if (state->calibrate & TEMP_CAL) | 2063 | } else if (state->calibrate & TEMP_CAL) |
2085 | return dib0090_get_temperature(state, tune_state); | 2064 | return dib0090_get_temperature(state, tune_state); |
@@ -2091,7 +2070,7 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2091 | if (state->config->use_pwm_agc && state->identity.in_soc) { | 2070 | if (state->config->use_pwm_agc && state->identity.in_soc) { |
2092 | tmp = dib0090_read_reg(state, 0x39); | 2071 | tmp = dib0090_read_reg(state, 0x39); |
2093 | if ((tmp >> 10) & 0x1) | 2072 | if ((tmp >> 10) & 0x1) |
2094 | dib0090_write_reg(state, 0x39, tmp & ~(1 << 10)); // disengage mux : en_mux_bb1 = 0 | 2073 | dib0090_write_reg(state, 0x39, tmp & ~(1 << 10)); |
2095 | } | 2074 | } |
2096 | 2075 | ||
2097 | state->current_band = (u8) BAND_OF_FREQUENCY(state->fe->dtv_property_cache.frequency / 1000); | 2076 | state->current_band = (u8) BAND_OF_FREQUENCY(state->fe->dtv_property_cache.frequency / 1000); |
@@ -2172,22 +2151,17 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2172 | state->current_tune_table_index = tune; | 2151 | state->current_tune_table_index = tune; |
2173 | state->current_pll_table_index = pll; | 2152 | state->current_pll_table_index = pll; |
2174 | 2153 | ||
2175 | // select internal switch | ||
2176 | dib0090_write_reg(state, 0x0b, 0xb800 | (tune->switch_trim)); | 2154 | dib0090_write_reg(state, 0x0b, 0xb800 | (tune->switch_trim)); |
2177 | 2155 | ||
2178 | // Find the VCO frequency in MHz | ||
2179 | VCOF_kHz = (pll->hfdiv * state->rf_request) * 2; | 2156 | VCOF_kHz = (pll->hfdiv * state->rf_request) * 2; |
2180 | 2157 | ||
2181 | FREF = state->config->io.clock_khz; // REFDIV is 1FREF Has to be as Close as possible to 10MHz | 2158 | FREF = state->config->io.clock_khz; |
2182 | if (state->config->fref_clock_ratio != 0) | 2159 | if (state->config->fref_clock_ratio != 0) |
2183 | FREF /= state->config->fref_clock_ratio; | 2160 | FREF /= state->config->fref_clock_ratio; |
2184 | 2161 | ||
2185 | // Determine the FB divider | ||
2186 | // The reference is 10MHz, Therefore the FBdivider is on the first digits | ||
2187 | FBDiv = (VCOF_kHz / pll->topresc / FREF); | 2162 | FBDiv = (VCOF_kHz / pll->topresc / FREF); |
2188 | Rest = (VCOF_kHz / pll->topresc) - FBDiv * FREF; //in kHz | 2163 | Rest = (VCOF_kHz / pll->topresc) - FBDiv * FREF; |
2189 | 2164 | ||
2190 | // Avoid Spurs in the loopfilter bandwidth | ||
2191 | if (Rest < LPF) | 2165 | if (Rest < LPF) |
2192 | Rest = 0; | 2166 | Rest = 0; |
2193 | else if (Rest < 2 * LPF) | 2167 | else if (Rest < 2 * LPF) |
@@ -2195,8 +2169,7 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2195 | else if (Rest > (FREF - LPF)) { | 2169 | else if (Rest > (FREF - LPF)) { |
2196 | Rest = 0; | 2170 | Rest = 0; |
2197 | FBDiv += 1; | 2171 | FBDiv += 1; |
2198 | } //Go to the next FB | 2172 | } else if (Rest > (FREF - 2 * LPF)) |
2199 | else if (Rest > (FREF - 2 * LPF)) | ||
2200 | Rest = FREF - 2 * LPF; | 2173 | Rest = FREF - 2 * LPF; |
2201 | Rest = (Rest * 6528) / (FREF / 10); | 2174 | Rest = (Rest * 6528) / (FREF / 10); |
2202 | state->rest = Rest; | 2175 | state->rest = Rest; |
@@ -2208,8 +2181,6 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2208 | if (Rest == 0) { | 2181 | if (Rest == 0) { |
2209 | if (pll->vco_band) | 2182 | if (pll->vco_band) |
2210 | lo5 = 0x049f; | 2183 | lo5 = 0x049f; |
2211 | //else if (state->config->analog_output) | ||
2212 | // lo5 = 0x041f; | ||
2213 | else | 2184 | else |
2214 | lo5 = 0x041f; | 2185 | lo5 = 0x041f; |
2215 | } else { | 2186 | } else { |
@@ -2228,12 +2199,11 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2228 | else | 2199 | else |
2229 | lo5 = 0x42f; | 2200 | lo5 = 0x42f; |
2230 | } else | 2201 | } else |
2231 | lo5 = 0x42c; //BIAS Lo set to 4 by default in case of the Captrim search does not take care of the VCO Bias | 2202 | lo5 = 0x42c; |
2232 | } | 2203 | } |
2233 | 2204 | ||
2234 | lo5 |= (pll->hfdiv_code << 11) | (pll->vco_band << 7); /* bit 15 is the split to the slave, we do not do it here */ | 2205 | lo5 |= (pll->hfdiv_code << 11) | (pll->vco_band << 7); /* bit 15 is the split to the slave, we do not do it here */ |
2235 | 2206 | ||
2236 | //Internal loop filter set... | ||
2237 | if (!state->config->io.pll_int_loop_filt) { | 2207 | if (!state->config->io.pll_int_loop_filt) { |
2238 | if (state->identity.in_soc) | 2208 | if (state->identity.in_soc) |
2239 | lo6 = 0xff98; | 2209 | lo6 = 0xff98; |
@@ -2242,40 +2212,30 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2242 | else | 2212 | else |
2243 | lo6 = 0xff28; | 2213 | lo6 = 0xff28; |
2244 | } else | 2214 | } else |
2245 | lo6 = (state->config->io.pll_int_loop_filt << 3); // take the loop filter value given by the layout | 2215 | lo6 = (state->config->io.pll_int_loop_filt << 3); |
2246 | //dprintk("lo6 = 0x%04x", (u32)lo6); | ||
2247 | 2216 | ||
2248 | Den = 1; | 2217 | Den = 1; |
2249 | 2218 | ||
2250 | if (Rest > 0) { | 2219 | if (Rest > 0) { |
2251 | if (state->config->analog_output) | 2220 | if (state->config->analog_output) |
2252 | lo6 |= (1 << 2) | 2; //SigmaDelta and Dither | 2221 | lo6 |= (1 << 2) | 2; |
2253 | else { | 2222 | else { |
2254 | if (state->identity.in_soc) | 2223 | if (state->identity.in_soc) |
2255 | lo6 |= (1 << 2) | 2; //SigmaDelta and Dither | 2224 | lo6 |= (1 << 2) | 2; |
2256 | else | 2225 | else |
2257 | lo6 |= (1 << 2) | 2; //SigmaDelta and Dither | 2226 | lo6 |= (1 << 2) | 2; |
2258 | } | 2227 | } |
2259 | Den = 255; | 2228 | Den = 255; |
2260 | } | 2229 | } |
2261 | // Now we have to define the Num and Denum | ||
2262 | // LO1 gets the FBdiv | ||
2263 | dib0090_write_reg(state, 0x15, (u16) FBDiv); | 2230 | dib0090_write_reg(state, 0x15, (u16) FBDiv); |
2264 | // LO2 gets the REFDiv | ||
2265 | if (state->config->fref_clock_ratio != 0) | 2231 | if (state->config->fref_clock_ratio != 0) |
2266 | dib0090_write_reg(state, 0x16, (Den << 8) | state->config->fref_clock_ratio); | 2232 | dib0090_write_reg(state, 0x16, (Den << 8) | state->config->fref_clock_ratio); |
2267 | else | 2233 | else |
2268 | dib0090_write_reg(state, 0x16, (Den << 8) | 1); | 2234 | dib0090_write_reg(state, 0x16, (Den << 8) | 1); |
2269 | // LO3 for the Numerator | ||
2270 | dib0090_write_reg(state, 0x17, (u16) Rest); | 2235 | dib0090_write_reg(state, 0x17, (u16) Rest); |
2271 | // VCO and HF DIV | ||
2272 | dib0090_write_reg(state, 0x19, lo5); | 2236 | dib0090_write_reg(state, 0x19, lo5); |
2273 | // SIGMA Delta | ||
2274 | dib0090_write_reg(state, 0x1c, lo6); | 2237 | dib0090_write_reg(state, 0x1c, lo6); |
2275 | 2238 | ||
2276 | // Check if the 0090 is analogged configured | ||
2277 | //Disable ADC and DigPLL =0xFF9F, 0xffbf for test purposes. | ||
2278 | //Enable The Outputs of the BB on DATA_Tx | ||
2279 | lo6 = tune->tuner_enable; | 2239 | lo6 = tune->tuner_enable; |
2280 | if (state->config->analog_output) | 2240 | if (state->config->analog_output) |
2281 | lo6 = (lo6 & 0xff9f) | 0x2; | 2241 | lo6 = (lo6 & 0xff9f) | 0x2; |
@@ -2294,10 +2254,8 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2294 | else if (*tune_state == CT_TUNER_STEP_0) { /* Warning : because of captrim cal, if you change this step, change it also in _cal.c file because it is the step following captrim cal state machine */ | 2254 | else if (*tune_state == CT_TUNER_STEP_0) { /* Warning : because of captrim cal, if you change this step, change it also in _cal.c file because it is the step following captrim cal state machine */ |
2295 | const struct dib0090_wbd_slope *wbd = state->current_wbd_table; | 2255 | const struct dib0090_wbd_slope *wbd = state->current_wbd_table; |
2296 | 2256 | ||
2297 | // if(!state->identity.p1g) { | ||
2298 | while (state->current_rf / 1000 > wbd->max_freq) | 2257 | while (state->current_rf / 1000 > wbd->max_freq) |
2299 | wbd++; | 2258 | wbd++; |
2300 | // } | ||
2301 | 2259 | ||
2302 | dib0090_write_reg(state, 0x1e, 0x07ff); | 2260 | dib0090_write_reg(state, 0x1e, 0x07ff); |
2303 | dprintk("Final Captrim: %d", (u32) state->fcaptrim); | 2261 | dprintk("Final Captrim: %d", (u32) state->fcaptrim); |
@@ -2311,12 +2269,11 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2311 | 2269 | ||
2312 | #define WBD 0x781 /* 1 1 1 1 0000 0 0 1 */ | 2270 | #define WBD 0x781 /* 1 1 1 1 0000 0 0 1 */ |
2313 | c = 4; | 2271 | c = 4; |
2314 | i = 3; //wbdmux_bias | 2272 | i = 3; |
2315 | 2273 | ||
2316 | if (wbd->wbd_gain != 0) //&& !state->identity.p1g) | 2274 | if (wbd->wbd_gain != 0) |
2317 | c = wbd->wbd_gain; | 2275 | c = wbd->wbd_gain; |
2318 | 2276 | ||
2319 | //Store wideband mux register. | ||
2320 | state->wbdmux = (c << 13) | (i << 11) | (WBD | (state->config->use_pwm_agc << 1)); | 2277 | state->wbdmux = (c << 13) | (i << 11) | (WBD | (state->config->use_pwm_agc << 1)); |
2321 | dib0090_write_reg(state, 0x10, state->wbdmux); | 2278 | dib0090_write_reg(state, 0x10, state->wbdmux); |
2322 | 2279 | ||
@@ -2335,15 +2292,12 @@ static int dib0090_tune(struct dvb_frontend *fe) | |||
2335 | } else if (*tune_state == CT_TUNER_STEP_1) { | 2292 | } else if (*tune_state == CT_TUNER_STEP_1) { |
2336 | /* initialize the lt gain register */ | 2293 | /* initialize the lt gain register */ |
2337 | state->rf_lt_def = 0x7c00; | 2294 | state->rf_lt_def = 0x7c00; |
2338 | // dib0090_write_reg(state, 0x0f, state->rf_lt_def); | ||
2339 | 2295 | ||
2340 | dib0090_set_bandwidth(state); | 2296 | dib0090_set_bandwidth(state); |
2341 | state->tuner_is_tuned = 1; | 2297 | state->tuner_is_tuned = 1; |
2342 | 2298 | ||
2343 | // if(!state->identity.p1g) | 2299 | state->calibrate |= WBD_CAL; |
2344 | state->calibrate |= WBD_CAL; // TODO: only do the WBD calibration for new tune | 2300 | state->calibrate |= TEMP_CAL; |
2345 | // | ||
2346 | state->calibrate |= TEMP_CAL; // Force the Temperature to be remesured at next TUNE. | ||
2347 | *tune_state = CT_TUNER_STOP; | 2301 | *tune_state = CT_TUNER_STOP; |
2348 | } else | 2302 | } else |
2349 | ret = FE_CALLBACK_TIME_NEVER; | 2303 | ret = FE_CALLBACK_TIME_NEVER; |
@@ -2435,8 +2389,8 @@ static const struct dvb_tuner_ops dib0090_fw_ops = { | |||
2435 | static const struct dib0090_wbd_slope dib0090_wbd_table_default[] = { | 2389 | static const struct dib0090_wbd_slope dib0090_wbd_table_default[] = { |
2436 | {470, 0, 250, 0, 100, 4}, | 2390 | {470, 0, 250, 0, 100, 4}, |
2437 | {860, 51, 866, 21, 375, 4}, | 2391 | {860, 51, 866, 21, 375, 4}, |
2438 | {1700, 0, 800, 0, 850, 4}, //LBAND Predefinition , to calibrate | 2392 | {1700, 0, 800, 0, 850, 4}, |
2439 | {2900, 0, 250, 0, 100, 6}, //SBAND Predefinition , NOT tested Yet | 2393 | {2900, 0, 250, 0, 100, 6}, |
2440 | {0xFFFF, 0, 0, 0, 0, 0}, | 2394 | {0xFFFF, 0, 0, 0, 0, 0}, |
2441 | }; | 2395 | }; |
2442 | 2396 | ||
@@ -2489,12 +2443,11 @@ struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_ada | |||
2489 | memcpy(&fe->ops.tuner_ops, &dib0090_fw_ops, sizeof(struct dvb_tuner_ops)); | 2443 | memcpy(&fe->ops.tuner_ops, &dib0090_fw_ops, sizeof(struct dvb_tuner_ops)); |
2490 | 2444 | ||
2491 | return fe; | 2445 | return fe; |
2492 | free_mem: | 2446 | free_mem: |
2493 | kfree(st); | 2447 | kfree(st); |
2494 | fe->tuner_priv = NULL; | 2448 | fe->tuner_priv = NULL; |
2495 | return NULL; | 2449 | return NULL; |
2496 | } | 2450 | } |
2497 | |||
2498 | EXPORT_SYMBOL(dib0090_fw_register); | 2451 | EXPORT_SYMBOL(dib0090_fw_register); |
2499 | 2452 | ||
2500 | MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); | 2453 | MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>"); |
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c index 18495bd166e6..b3ca3e2f8d53 100644 --- a/drivers/media/dvb/frontends/dib7000p.c +++ b/drivers/media/dvb/frontends/dib7000p.c | |||
@@ -79,8 +79,8 @@ static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg) | |||
79 | u8 wb[2] = { reg >> 8, reg & 0xff }; | 79 | u8 wb[2] = { reg >> 8, reg & 0xff }; |
80 | u8 rb[2]; | 80 | u8 rb[2]; |
81 | struct i2c_msg msg[2] = { | 81 | struct i2c_msg msg[2] = { |
82 | {.addr = state->i2c_addr >> 1,.flags = 0,.buf = wb,.len = 2}, | 82 | {.addr = state->i2c_addr >> 1, .flags = 0, .buf = wb, .len = 2}, |
83 | {.addr = state->i2c_addr >> 1,.flags = I2C_M_RD,.buf = rb,.len = 2}, | 83 | {.addr = state->i2c_addr >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2}, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | if (i2c_transfer(state->i2c_adap, msg, 2) != 2) | 86 | if (i2c_transfer(state->i2c_adap, msg, 2) != 2) |
@@ -96,7 +96,7 @@ static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val) | |||
96 | (val >> 8) & 0xff, val & 0xff, | 96 | (val >> 8) & 0xff, val & 0xff, |
97 | }; | 97 | }; |
98 | struct i2c_msg msg = { | 98 | struct i2c_msg msg = { |
99 | .addr = state->i2c_addr >> 1,.flags = 0,.buf = b,.len = 4 | 99 | .addr = state->i2c_addr >> 1, .flags = 0, .buf = b, .len = 4 |
100 | }; | 100 | }; |
101 | return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; | 101 | return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; |
102 | } | 102 | } |
@@ -129,13 +129,13 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode) | |||
129 | dprintk("setting output mode for demod %p to %d", &state->demod, mode); | 129 | dprintk("setting output mode for demod %p to %d", &state->demod, mode); |
130 | 130 | ||
131 | switch (mode) { | 131 | switch (mode) { |
132 | case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock | 132 | case OUTMODE_MPEG2_PAR_GATED_CLK: |
133 | outreg = (1 << 10); /* 0x0400 */ | 133 | outreg = (1 << 10); /* 0x0400 */ |
134 | break; | 134 | break; |
135 | case OUTMODE_MPEG2_PAR_CONT_CLK: // STBs with parallel continues clock | 135 | case OUTMODE_MPEG2_PAR_CONT_CLK: |
136 | outreg = (1 << 10) | (1 << 6); /* 0x0440 */ | 136 | outreg = (1 << 10) | (1 << 6); /* 0x0440 */ |
137 | break; | 137 | break; |
138 | case OUTMODE_MPEG2_SERIAL: // STBs with serial input | 138 | case OUTMODE_MPEG2_SERIAL: |
139 | outreg = (1 << 10) | (2 << 6) | (0 << 1); /* 0x0480 */ | 139 | outreg = (1 << 10) | (2 << 6) | (0 << 1); /* 0x0480 */ |
140 | break; | 140 | break; |
141 | case OUTMODE_DIVERSITY: | 141 | case OUTMODE_DIVERSITY: |
@@ -144,7 +144,7 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode) | |||
144 | else | 144 | else |
145 | outreg = (1 << 11); | 145 | outreg = (1 << 11); |
146 | break; | 146 | break; |
147 | case OUTMODE_MPEG2_FIFO: // e.g. USB feeding | 147 | case OUTMODE_MPEG2_FIFO: |
148 | smo_mode |= (3 << 1); | 148 | smo_mode |= (3 << 1); |
149 | fifo_threshold = 512; | 149 | fifo_threshold = 512; |
150 | outreg = (1 << 10) | (5 << 6); | 150 | outreg = (1 << 10) | (5 << 6); |
@@ -152,7 +152,7 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode) | |||
152 | case OUTMODE_ANALOG_ADC: | 152 | case OUTMODE_ANALOG_ADC: |
153 | outreg = (1 << 10) | (3 << 6); | 153 | outreg = (1 << 10) | (3 << 6); |
154 | break; | 154 | break; |
155 | case OUTMODE_HIGH_Z: // disable | 155 | case OUTMODE_HIGH_Z: |
156 | outreg = 0; | 156 | outreg = 0; |
157 | break; | 157 | break; |
158 | default: | 158 | default: |
@@ -284,7 +284,7 @@ static void dib7000p_set_adc_state(struct dib7000p_state *state, enum dibx000_ad | |||
284 | reg_909 &= 0x0003; | 284 | reg_909 &= 0x0003; |
285 | break; | 285 | break; |
286 | 286 | ||
287 | case DIBX000_ADC_OFF: // leave the VBG voltage on | 287 | case DIBX000_ADC_OFF: |
288 | reg_908 |= (1 << 14) | (1 << 13) | (1 << 12); | 288 | reg_908 |= (1 << 14) | (1 << 13) | (1 << 12); |
289 | reg_909 |= (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2); | 289 | reg_909 |= (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2); |
290 | break; | 290 | break; |
@@ -336,13 +336,12 @@ static int dib7000p_set_bandwidth(struct dib7000p_state *state, u32 bw) | |||
336 | static int dib7000p_sad_calib(struct dib7000p_state *state) | 336 | static int dib7000p_sad_calib(struct dib7000p_state *state) |
337 | { | 337 | { |
338 | /* internal */ | 338 | /* internal */ |
339 | // dib7000p_write_word(state, 72, (3 << 14) | (1 << 12) | (524 << 0)); // sampling clock of the SAD is writting in set_bandwidth | ||
340 | dib7000p_write_word(state, 73, (0 << 1) | (0 << 0)); | 339 | dib7000p_write_word(state, 73, (0 << 1) | (0 << 0)); |
341 | 340 | ||
342 | if (state->version == SOC7090) | 341 | if (state->version == SOC7090) |
343 | dib7000p_write_word(state, 74, 2048); // P_sad_calib_value = (0.9/1.8)*4096 | 342 | dib7000p_write_word(state, 74, 2048); |
344 | else | 343 | else |
345 | dib7000p_write_word(state, 74, 776); // P_sad_calib_value = 0.625*3.3 / 4096 | 344 | dib7000p_write_word(state, 74, 776); |
346 | 345 | ||
347 | /* do the calibration */ | 346 | /* do the calibration */ |
348 | dib7000p_write_word(state, 73, (1 << 0)); | 347 | dib7000p_write_word(state, 73, (1 << 0)); |
@@ -371,8 +370,8 @@ static void dib7000p_reset_pll(struct dib7000p_state *state) | |||
371 | if (state->version == SOC7090) { | 370 | if (state->version == SOC7090) { |
372 | dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio << 6) | (bw->pll_prediv)); | 371 | dib7000p_write_word(state, 1856, (!bw->pll_reset << 13) | (bw->pll_range << 12) | (bw->pll_ratio << 6) | (bw->pll_prediv)); |
373 | 372 | ||
374 | while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) { | 373 | while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) |
375 | } | 374 | ; |
376 | 375 | ||
377 | dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15)); | 376 | dib7000p_write_word(state, 1857, dib7000p_read_word(state, 1857) | (!bw->pll_bypass << 15)); |
378 | } else { | 377 | } else { |
@@ -420,7 +419,7 @@ int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth_config | |||
420 | dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)", prediv, bw->pll_prediv, loopdiv, bw->pll_ratio); | 419 | dprintk("Updating pll (prediv: old = %d new = %d ; loopdiv : old = %d new = %d)", prediv, bw->pll_prediv, loopdiv, bw->pll_ratio); |
421 | reg_1856 &= 0xf000; | 420 | reg_1856 &= 0xf000; |
422 | reg_1857 = dib7000p_read_word(state, 1857); | 421 | reg_1857 = dib7000p_read_word(state, 1857); |
423 | dib7000p_write_word(state, 1857, reg_1857 & ~(1 << 15)); // desable pll | 422 | dib7000p_write_word(state, 1857, reg_1857 & ~(1 << 15)); |
424 | 423 | ||
425 | dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f)); | 424 | dib7000p_write_word(state, 1856, reg_1856 | ((bw->pll_ratio & 0x3f) << 6) | (bw->pll_prediv & 0x3f)); |
426 | 425 | ||
@@ -431,11 +430,10 @@ int dib7000p_update_pll(struct dvb_frontend *fe, struct dibx000_bandwidth_config | |||
431 | dib7000p_write_word(state, 18, (u16) ((internal >> 16) & 0xffff)); | 430 | dib7000p_write_word(state, 18, (u16) ((internal >> 16) & 0xffff)); |
432 | dib7000p_write_word(state, 19, (u16) (internal & 0xffff)); | 431 | dib7000p_write_word(state, 19, (u16) (internal & 0xffff)); |
433 | 432 | ||
434 | dib7000p_write_word(state, 1857, reg_1857 | (1 << 15)); // enable pll | 433 | dib7000p_write_word(state, 1857, reg_1857 | (1 << 15)); |
435 | 434 | ||
436 | while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) { | 435 | while (((dib7000p_read_word(state, 1856) >> 15) & 0x1) != 1) |
437 | dprintk("Waiting for PLL to lock"); | 436 | dprintk("Waiting for PLL to lock"); |
438 | } | ||
439 | 437 | ||
440 | return 0; | 438 | return 0; |
441 | } | 439 | } |
@@ -503,7 +501,7 @@ static u16 dib7000p_defaults[] = { | |||
503 | 0xd4c0, | 501 | 0xd4c0, |
504 | 502 | ||
505 | 1, 26, | 503 | 1, 26, |
506 | 0x6680, // P_timf_alpha=6, P_corm_alpha=6, P_corm_thres=128 default: 6,4,26 | 504 | 0x6680, |
507 | 505 | ||
508 | /* set ADC level to -16 */ | 506 | /* set ADC level to -16 */ |
509 | 11, 79, | 507 | 11, 79, |
@@ -520,7 +518,7 @@ static u16 dib7000p_defaults[] = { | |||
520 | (1 << 13) - 501 - 117, | 518 | (1 << 13) - 501 - 117, |
521 | 519 | ||
522 | 1, 142, | 520 | 1, 142, |
523 | 0x0410, // P_palf_filter_on=1, P_palf_filter_freeze=0, P_palf_alpha_regul=16 | 521 | 0x0410, |
524 | 522 | ||
525 | /* disable power smoothing */ | 523 | /* disable power smoothing */ |
526 | 8, 145, | 524 | 8, 145, |
@@ -534,42 +532,39 @@ static u16 dib7000p_defaults[] = { | |||
534 | 0, | 532 | 0, |
535 | 533 | ||
536 | 1, 154, | 534 | 1, 154, |
537 | 1 << 13, // P_fft_freq_dir=1, P_fft_nb_to_cut=0 | 535 | 1 << 13, |
538 | 536 | ||
539 | 1, 168, | 537 | 1, 168, |
540 | 0x0ccd, // P_pha3_thres, default 0x3000 | 538 | 0x0ccd, |
541 | |||
542 | // 1, 169, | ||
543 | // 0x0010, // P_cti_use_cpe=0, P_cti_use_prog=0, P_cti_win_len=16, default: 0x0010 | ||
544 | 539 | ||
545 | 1, 183, | 540 | 1, 183, |
546 | 0x200f, // P_cspu_regul=512, P_cspu_win_cut=15, default: 0x2005 | 541 | 0x200f, |
547 | 542 | ||
548 | 1, 212, | 543 | 1, 212, |
549 | 0x169, // P_vit_ksi_dwn = 5 P_vit_ksi_up = 5 0x1e1, // P_vit_ksi_dwn = 4 P_vit_ksi_up = 7 | 544 | 0x169, |
550 | 545 | ||
551 | 5, 187, | 546 | 5, 187, |
552 | 0x023d, // P_adp_regul_cnt=573, default: 410 | 547 | 0x023d, |
553 | 0x00a4, // P_adp_noise_cnt= | 548 | 0x00a4, |
554 | 0x00a4, // P_adp_regul_ext | 549 | 0x00a4, |
555 | 0x7ff0, // P_adp_noise_ext | 550 | 0x7ff0, |
556 | 0x3ccc, // P_adp_fil | 551 | 0x3ccc, |
557 | 552 | ||
558 | 1, 198, | 553 | 1, 198, |
559 | 0x800, // P_equal_thres_wgn | 554 | 0x800, |
560 | 555 | ||
561 | 1, 222, | 556 | 1, 222, |
562 | 0x0010, // P_fec_ber_rs_len=2 | 557 | 0x0010, |
563 | 558 | ||
564 | 1, 235, | 559 | 1, 235, |
565 | 0x0062, // P_smo_mode, P_smo_rs_discard, P_smo_fifo_flush, P_smo_pid_parse, P_smo_error_discard | 560 | 0x0062, |
566 | 561 | ||
567 | 2, 901, | 562 | 2, 901, |
568 | 0x0006, // P_clk_cfg1 | 563 | 0x0006, |
569 | (3 << 10) | (1 << 6), // P_divclksel=3 P_divbitsel=1 | 564 | (3 << 10) | (1 << 6), |
570 | 565 | ||
571 | 1, 905, | 566 | 1, 905, |
572 | 0x2c8e, // Tuner IO bank: max drive (14mA) + divout pads max drive | 567 | 0x2c8e, |
573 | 568 | ||
574 | 0, | 569 | 0, |
575 | }; | 570 | }; |
@@ -609,8 +604,7 @@ static int dib7000p_demod_reset(struct dib7000p_state *state) | |||
609 | dib7000p_write_word(state, 42, (1<<5) | 3); /* P_iqc_thsat_ipc = 1 ; P_iqc_win2 = 3 */ | 604 | dib7000p_write_word(state, 42, (1<<5) | 3); /* P_iqc_thsat_ipc = 1 ; P_iqc_win2 = 3 */ |
610 | dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ | 605 | dib7000p_write_word(state, 43, 0x2d4); /*-300 fag P_iqc_dect_min = -280 */ |
611 | dib7000p_write_word(state, 44, 300); /* 300 fag P_iqc_dect_min = +280 */ | 606 | dib7000p_write_word(state, 44, 300); /* 300 fag P_iqc_dect_min = +280 */ |
612 | //dib7000p_write_word(state, 273, (1<<6) | 10); /* P_vit_inoise_sel = 1, P_vit_inoise_gain = 10*/ | 607 | dib7000p_write_word(state, 273, (1<<6) | 30); |
613 | dib7000p_write_word(state, 273, (1<<6) | 30); //26/* P_vit_inoise_sel = 1, P_vit_inoise_gain = 26*/// FAG | ||
614 | } | 608 | } |
615 | if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0) | 609 | if (dib7000p_set_output_mode(state, OUTMODE_HIGH_Z) != 0) |
616 | dprintk("OUTPUT_MODE could not be reset."); | 610 | dprintk("OUTPUT_MODE could not be reset."); |
@@ -624,9 +618,9 @@ static int dib7000p_demod_reset(struct dib7000p_state *state) | |||
624 | 618 | ||
625 | dib7000p_set_bandwidth(state, 8000); | 619 | dib7000p_set_bandwidth(state, 8000); |
626 | 620 | ||
627 | if(state->version == SOC7090) { | 621 | if (state->version == SOC7090) { |
628 | dib7000p_write_word(state, 36, 0x5755);/* P_iqc_impnc_on =1 & P_iqc_corr_inh = 1 for impulsive noise */ | 622 | dib7000p_write_word(state, 36, 0x5755);/* P_iqc_impnc_on =1 & P_iqc_corr_inh = 1 for impulsive noise */ |
629 | } else { // P_iqc_alpha_pha, P_iqc_alpha_amp_dcc_alpha, ... | 623 | } else { |
630 | if (state->cfg.tuner_is_baseband) | 624 | if (state->cfg.tuner_is_baseband) |
631 | dib7000p_write_word(state, 36, 0x0755); | 625 | dib7000p_write_word(state, 36, 0x0755); |
632 | else | 626 | else |
@@ -644,9 +638,9 @@ static void dib7000p_pll_clk_cfg(struct dib7000p_state *state) | |||
644 | { | 638 | { |
645 | u16 tmp = 0; | 639 | u16 tmp = 0; |
646 | tmp = dib7000p_read_word(state, 903); | 640 | tmp = dib7000p_read_word(state, 903); |
647 | dib7000p_write_word(state, 903, (tmp | 0x1)); //pwr-up pll | 641 | dib7000p_write_word(state, 903, (tmp | 0x1)); |
648 | tmp = dib7000p_read_word(state, 900); | 642 | tmp = dib7000p_read_word(state, 900); |
649 | dib7000p_write_word(state, 900, (tmp & 0x7fff) | (1 << 6)); //use High freq clock | 643 | dib7000p_write_word(state, 900, (tmp & 0x7fff) | (1 << 6)); |
650 | } | 644 | } |
651 | 645 | ||
652 | static void dib7000p_restart_agc(struct dib7000p_state *state) | 646 | static void dib7000p_restart_agc(struct dib7000p_state *state) |
@@ -660,11 +654,9 @@ static int dib7000p_update_lna(struct dib7000p_state *state) | |||
660 | { | 654 | { |
661 | u16 dyn_gain; | 655 | u16 dyn_gain; |
662 | 656 | ||
663 | // when there is no LNA to program return immediatly | ||
664 | if (state->cfg.update_lna) { | 657 | if (state->cfg.update_lna) { |
665 | // read dyn_gain here (because it is demod-dependent and not fe) | ||
666 | dyn_gain = dib7000p_read_word(state, 394); | 658 | dyn_gain = dib7000p_read_word(state, 394); |
667 | if (state->cfg.update_lna(&state->demod, dyn_gain)) { // LNA has changed | 659 | if (state->cfg.update_lna(&state->demod, dyn_gain)) { |
668 | dib7000p_restart_agc(state); | 660 | dib7000p_restart_agc(state); |
669 | return 1; | 661 | return 1; |
670 | } | 662 | } |
@@ -763,12 +755,11 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod, struct dvb_frontend_ | |||
763 | 755 | ||
764 | switch (state->agc_state) { | 756 | switch (state->agc_state) { |
765 | case 0: | 757 | case 0: |
766 | // set power-up level: interf+analog+AGC | ||
767 | dib7000p_set_power_mode(state, DIB7000P_POWER_ALL); | 758 | dib7000p_set_power_mode(state, DIB7000P_POWER_ALL); |
768 | if (state->version == SOC7090) { | 759 | if (state->version == SOC7090) { |
769 | reg = dib7000p_read_word(state, 0x79b) & 0xff00; | 760 | reg = dib7000p_read_word(state, 0x79b) & 0xff00; |
770 | dib7000p_write_word(state, 0x79a, upd_demod_gain_period & 0xFFFF); /* lsb */ | 761 | dib7000p_write_word(state, 0x79a, upd_demod_gain_period & 0xFFFF); /* lsb */ |
771 | dib7000p_write_word(state, 0x79b, reg | (1 << 14) | ((upd_demod_gain_period >> 16) & 0xFF)); // bit 14 = enDemodGain | 762 | dib7000p_write_word(state, 0x79b, reg | (1 << 14) | ((upd_demod_gain_period >> 16) & 0xFF)); |
772 | 763 | ||
773 | /* enable adc i & q */ | 764 | /* enable adc i & q */ |
774 | reg = dib7000p_read_word(state, 0x780); | 765 | reg = dib7000p_read_word(state, 0x780); |
@@ -787,7 +778,6 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod, struct dvb_frontend_ | |||
787 | break; | 778 | break; |
788 | 779 | ||
789 | case 1: | 780 | case 1: |
790 | // AGC initialization | ||
791 | if (state->cfg.agc_control) | 781 | if (state->cfg.agc_control) |
792 | state->cfg.agc_control(&state->demod, 1); | 782 | state->cfg.agc_control(&state->demod, 1); |
793 | 783 | ||
@@ -831,13 +821,11 @@ static int dib7000p_agc_startup(struct dvb_frontend *demod, struct dvb_frontend_ | |||
831 | break; | 821 | break; |
832 | 822 | ||
833 | case 4: /* LNA startup */ | 823 | case 4: /* LNA startup */ |
834 | // wait AGC accurate lock time | ||
835 | ret = 7; | 824 | ret = 7; |
836 | 825 | ||
837 | if (dib7000p_update_lna(state)) | 826 | if (dib7000p_update_lna(state)) |
838 | // wait only AGC rough lock time | ||
839 | ret = 5; | 827 | ret = 5; |
840 | else // nothing was done, go to the next state | 828 | else |
841 | (*agc_state)++; | 829 | (*agc_state)++; |
842 | break; | 830 | break; |
843 | 831 | ||
@@ -971,10 +959,10 @@ static void dib7000p_set_channel(struct dib7000p_state *state, struct dvb_fronte | |||
971 | dib7000p_write_word(state, 208, value); | 959 | dib7000p_write_word(state, 208, value); |
972 | 960 | ||
973 | /* offset loop parameters */ | 961 | /* offset loop parameters */ |
974 | dib7000p_write_word(state, 26, 0x6680); // timf(6xxx) | 962 | dib7000p_write_word(state, 26, 0x6680); |
975 | dib7000p_write_word(state, 32, 0x0003); // pha_off_max(xxx3) | 963 | dib7000p_write_word(state, 32, 0x0003); |
976 | dib7000p_write_word(state, 29, 0x1273); // isi | 964 | dib7000p_write_word(state, 29, 0x1273); |
977 | dib7000p_write_word(state, 33, 0x0005); // sfreq(xxx5) | 965 | dib7000p_write_word(state, 33, 0x0005); |
978 | 966 | ||
979 | /* P_dvsy_sync_wait */ | 967 | /* P_dvsy_sync_wait */ |
980 | switch (ch->u.ofdm.transmission_mode) { | 968 | switch (ch->u.ofdm.transmission_mode) { |
@@ -1005,9 +993,9 @@ static void dib7000p_set_channel(struct dib7000p_state *state, struct dvb_fronte | |||
1005 | break; | 993 | break; |
1006 | } | 994 | } |
1007 | if (state->cfg.diversity_delay == 0) | 995 | if (state->cfg.diversity_delay == 0) |
1008 | state->div_sync_wait = (value * 3) / 2 + 48; // add 50% SFN margin + compensate for one DVSY-fifo | 996 | state->div_sync_wait = (value * 3) / 2 + 48; |
1009 | else | 997 | else |
1010 | state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; // add 50% SFN margin + compensate for one DVSY-fifo | 998 | state->div_sync_wait = (value * 3) / 2 + state->cfg.diversity_delay; |
1011 | 999 | ||
1012 | /* deactive the possibility of diversity reception if extended interleaver */ | 1000 | /* deactive the possibility of diversity reception if extended interleaver */ |
1013 | state->div_force_off = !1 && ch->u.ofdm.transmission_mode != TRANSMISSION_MODE_8K; | 1001 | state->div_force_off = !1 && ch->u.ofdm.transmission_mode != TRANSMISSION_MODE_8K; |
@@ -1061,16 +1049,15 @@ static int dib7000p_autosearch_start(struct dvb_frontend *demod, struct dvb_fron | |||
1061 | else | 1049 | else |
1062 | factor = 6; | 1050 | factor = 6; |
1063 | 1051 | ||
1064 | // always use the setting for 8MHz here lock_time for 7,6 MHz are longer | ||
1065 | value = 30 * internal * factor; | 1052 | value = 30 * internal * factor; |
1066 | dib7000p_write_word(state, 6, (u16) ((value >> 16) & 0xffff)); // lock0 wait time | 1053 | dib7000p_write_word(state, 6, (u16) ((value >> 16) & 0xffff)); |
1067 | dib7000p_write_word(state, 7, (u16) (value & 0xffff)); // lock0 wait time | 1054 | dib7000p_write_word(state, 7, (u16) (value & 0xffff)); |
1068 | value = 100 * internal * factor; | 1055 | value = 100 * internal * factor; |
1069 | dib7000p_write_word(state, 8, (u16) ((value >> 16) & 0xffff)); // lock1 wait time | 1056 | dib7000p_write_word(state, 8, (u16) ((value >> 16) & 0xffff)); |
1070 | dib7000p_write_word(state, 9, (u16) (value & 0xffff)); // lock1 wait time | 1057 | dib7000p_write_word(state, 9, (u16) (value & 0xffff)); |
1071 | value = 500 * internal * factor; | 1058 | value = 500 * internal * factor; |
1072 | dib7000p_write_word(state, 10, (u16) ((value >> 16) & 0xffff)); // lock2 wait time | 1059 | dib7000p_write_word(state, 10, (u16) ((value >> 16) & 0xffff)); |
1073 | dib7000p_write_word(state, 11, (u16) (value & 0xffff)); // lock2 wait time | 1060 | dib7000p_write_word(state, 11, (u16) (value & 0xffff)); |
1074 | 1061 | ||
1075 | value = dib7000p_read_word(state, 0); | 1062 | value = dib7000p_read_word(state, 0); |
1076 | dib7000p_write_word(state, 0, (u16) ((1 << 9) | value)); | 1063 | dib7000p_write_word(state, 0, (u16) ((1 << 9) | value)); |
@@ -1085,13 +1072,13 @@ static int dib7000p_autosearch_is_irq(struct dvb_frontend *demod) | |||
1085 | struct dib7000p_state *state = demod->demodulator_priv; | 1072 | struct dib7000p_state *state = demod->demodulator_priv; |
1086 | u16 irq_pending = dib7000p_read_word(state, 1284); | 1073 | u16 irq_pending = dib7000p_read_word(state, 1284); |
1087 | 1074 | ||
1088 | if (irq_pending & 0x1) // failed | 1075 | if (irq_pending & 0x1) |
1089 | return 1; | 1076 | return 1; |
1090 | 1077 | ||
1091 | if (irq_pending & 0x2) // succeeded | 1078 | if (irq_pending & 0x2) |
1092 | return 2; | 1079 | return 2; |
1093 | 1080 | ||
1094 | return 0; // still pending | 1081 | return 0; |
1095 | } | 1082 | } |
1096 | 1083 | ||
1097 | static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32 bw) | 1084 | static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32 bw) |
@@ -1202,9 +1189,9 @@ static int dib7000p_tune(struct dvb_frontend *demod, struct dvb_frontend_paramet | |||
1202 | if (state->sfn_workaround_active) { | 1189 | if (state->sfn_workaround_active) { |
1203 | dprintk("SFN workaround is active"); | 1190 | dprintk("SFN workaround is active"); |
1204 | tmp |= (1 << 9); | 1191 | tmp |= (1 << 9); |
1205 | dib7000p_write_word(state, 166, 0x4000); // P_pha3_force_pha_shift | 1192 | dib7000p_write_word(state, 166, 0x4000); |
1206 | } else { | 1193 | } else { |
1207 | dib7000p_write_word(state, 166, 0x0000); // P_pha3_force_pha_shift | 1194 | dib7000p_write_word(state, 166, 0x0000); |
1208 | } | 1195 | } |
1209 | dib7000p_write_word(state, 29, tmp); | 1196 | dib7000p_write_word(state, 29, tmp); |
1210 | 1197 | ||
@@ -1425,8 +1412,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa | |||
1425 | if (state->version == SOC7090) { | 1412 | if (state->version == SOC7090) { |
1426 | dib7090_set_diversity_in(fe, 0); | 1413 | dib7090_set_diversity_in(fe, 0); |
1427 | dib7090_set_output_mode(fe, OUTMODE_HIGH_Z); | 1414 | dib7090_set_output_mode(fe, OUTMODE_HIGH_Z); |
1428 | } | 1415 | } else |
1429 | else | ||
1430 | dib7000p_set_output_mode(state, OUTMODE_HIGH_Z); | 1416 | dib7000p_set_output_mode(state, OUTMODE_HIGH_Z); |
1431 | 1417 | ||
1432 | /* maybe the parameter has been changed */ | 1418 | /* maybe the parameter has been changed */ |
@@ -1455,7 +1441,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_pa | |||
1455 | 1441 | ||
1456 | dprintk("autosearch returns: %d", found); | 1442 | dprintk("autosearch returns: %d", found); |
1457 | if (found == 0 || found == 1) | 1443 | if (found == 0 || found == 1) |
1458 | return 0; // no channel found | 1444 | return 0; |
1459 | 1445 | ||
1460 | dib7000p_get_frontend(fe, fep); | 1446 | dib7000p_get_frontend(fe, fep); |
1461 | } | 1447 | } |
@@ -1566,8 +1552,8 @@ int dib7000pc_detection(struct i2c_adapter *i2c_adap) | |||
1566 | { | 1552 | { |
1567 | u8 tx[2], rx[2]; | 1553 | u8 tx[2], rx[2]; |
1568 | struct i2c_msg msg[2] = { | 1554 | struct i2c_msg msg[2] = { |
1569 | {.addr = 18 >> 1,.flags = 0,.buf = tx,.len = 2}, | 1555 | {.addr = 18 >> 1, .flags = 0, .buf = tx, .len = 2}, |
1570 | {.addr = 18 >> 1,.flags = I2C_M_RD,.buf = rx,.len = 2}, | 1556 | {.addr = 18 >> 1, .flags = I2C_M_RD, .buf = rx, .len = 2}, |
1571 | }; | 1557 | }; |
1572 | 1558 | ||
1573 | tx[0] = 0x03; | 1559 | tx[0] = 0x03; |
@@ -1725,9 +1711,8 @@ static int map_addr_to_serpar_number(struct i2c_msg *msg) | |||
1725 | msg->buf[0] -= 3; | 1711 | msg->buf[0] -= 3; |
1726 | else if (msg->buf[0] == 28) | 1712 | else if (msg->buf[0] == 28) |
1727 | msg->buf[0] = 23; | 1713 | msg->buf[0] = 23; |
1728 | else { | 1714 | else |
1729 | return -EINVAL; | 1715 | return -EINVAL; |
1730 | } | ||
1731 | return 0; | 1716 | return 0; |
1732 | } | 1717 | } |
1733 | 1718 | ||
@@ -1909,7 +1894,7 @@ static int dib7090_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[] | |||
1909 | if (num == 1) { /* write */ | 1894 | if (num == 1) { /* write */ |
1910 | word = (u16) ((msg[0].buf[1] << 8) | msg[0].buf[2]); | 1895 | word = (u16) ((msg[0].buf[1] << 8) | msg[0].buf[2]); |
1911 | word &= 0x3; | 1896 | word &= 0x3; |
1912 | word = (dib7000p_read_word(state, 72) & ~(3 << 12)) | (word << 12); //Mask bit 12,13 | 1897 | word = (dib7000p_read_word(state, 72) & ~(3 << 12)) | (word << 12); |
1913 | dib7000p_write_word(state, 72, word); /* Set the proper input */ | 1898 | dib7000p_write_word(state, 72, word); /* Set the proper input */ |
1914 | return num; | 1899 | return num; |
1915 | } | 1900 | } |
@@ -1996,7 +1981,7 @@ static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout | |||
1996 | u16 rx_copy_buf[22]; | 1981 | u16 rx_copy_buf[22]; |
1997 | 1982 | ||
1998 | dprintk("Configure DibStream Tx"); | 1983 | dprintk("Configure DibStream Tx"); |
1999 | for (index_buf = 0; index_buf<22; index_buf++) | 1984 | for (index_buf = 0; index_buf < 22; index_buf++) |
2000 | rx_copy_buf[index_buf] = dib7000p_read_word(state, 1536+index_buf); | 1985 | rx_copy_buf[index_buf] = dib7000p_read_word(state, 1536+index_buf); |
2001 | 1986 | ||
2002 | dib7000p_write_word(state, 1615, 1); | 1987 | dib7000p_write_word(state, 1615, 1); |
@@ -2009,7 +1994,7 @@ static int dib7090_cfg_DibTx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout | |||
2009 | dib7000p_write_word(state, 1612, syncSize); | 1994 | dib7000p_write_word(state, 1612, syncSize); |
2010 | dib7000p_write_word(state, 1615, 0); | 1995 | dib7000p_write_word(state, 1615, 0); |
2011 | 1996 | ||
2012 | for (index_buf = 0; index_buf<22; index_buf++) | 1997 | for (index_buf = 0; index_buf < 22; index_buf++) |
2013 | dib7000p_write_word(state, 1536+index_buf, rx_copy_buf[index_buf]); | 1998 | dib7000p_write_word(state, 1536+index_buf, rx_copy_buf[index_buf]); |
2014 | 1999 | ||
2015 | return 0; | 2000 | return 0; |
@@ -2021,8 +2006,7 @@ static int dib7090_cfg_DibRx(struct dib7000p_state *state, u32 P_Kin, u32 P_Kout | |||
2021 | u32 syncFreq; | 2006 | u32 syncFreq; |
2022 | 2007 | ||
2023 | dprintk("Configure DibStream Rx"); | 2008 | dprintk("Configure DibStream Rx"); |
2024 | if ((P_Kin != 0) && (P_Kout != 0)) | 2009 | if ((P_Kin != 0) && (P_Kout != 0)) { |
2025 | { | ||
2026 | syncFreq = dib7090_calcSyncFreq(P_Kin, P_Kout, insertExtSynchro, syncSize); | 2010 | syncFreq = dib7090_calcSyncFreq(P_Kin, P_Kout, insertExtSynchro, syncSize); |
2027 | dib7000p_write_word(state, 1542, syncFreq); | 2011 | dib7000p_write_word(state, 1542, syncFreq); |
2028 | } | 2012 | } |
@@ -2044,7 +2028,7 @@ static int dib7090_enDivOnHostBus(struct dib7000p_state *state) | |||
2044 | u16 reg; | 2028 | u16 reg; |
2045 | 2029 | ||
2046 | dprintk("Enable Diversity on host bus"); | 2030 | dprintk("Enable Diversity on host bus"); |
2047 | reg = (1 << 8) | (1 << 5); // P_enDivOutOnDibTx = 1 ; P_enDibTxOnHostBus = 1 | 2031 | reg = (1 << 8) | (1 << 5); |
2048 | dib7000p_write_word(state, 1288, reg); | 2032 | dib7000p_write_word(state, 1288, reg); |
2049 | 2033 | ||
2050 | return dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0); | 2034 | return dib7090_cfg_DibTx(state, 5, 5, 0, 0, 0, 0); |
@@ -2055,7 +2039,7 @@ static int dib7090_enAdcOnHostBus(struct dib7000p_state *state) | |||
2055 | u16 reg; | 2039 | u16 reg; |
2056 | 2040 | ||
2057 | dprintk("Enable ADC on host bus"); | 2041 | dprintk("Enable ADC on host bus"); |
2058 | reg = (1 << 7) | (1 << 5); //P_enAdcOnDibTx = 1 ; P_enDibTxOnHostBus = 1 | 2042 | reg = (1 << 7) | (1 << 5); |
2059 | dib7000p_write_word(state, 1288, reg); | 2043 | dib7000p_write_word(state, 1288, reg); |
2060 | 2044 | ||
2061 | return dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); | 2045 | return dib7090_cfg_DibTx(state, 20, 5, 10, 0, 0, 0); |
@@ -2066,7 +2050,7 @@ static int dib7090_enMpegOnHostBus(struct dib7000p_state *state) | |||
2066 | u16 reg; | 2050 | u16 reg; |
2067 | 2051 | ||
2068 | dprintk("Enable Mpeg on host bus"); | 2052 | dprintk("Enable Mpeg on host bus"); |
2069 | reg = (1 << 9) | (1 << 5); //P_enMpegOnDibTx = 1 ; P_enDibTxOnHostBus = 1 | 2053 | reg = (1 << 9) | (1 << 5); |
2070 | dib7000p_write_word(state, 1288, reg); | 2054 | dib7000p_write_word(state, 1288, reg); |
2071 | 2055 | ||
2072 | return dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0); | 2056 | return dib7090_cfg_DibTx(state, 8, 5, 0, 0, 0, 0); |
@@ -2085,10 +2069,10 @@ static int dib7090_enMpegMux(struct dib7000p_state *state, u16 pulseWidth, u16 e | |||
2085 | dprintk("Enable Mpeg mux"); | 2069 | dprintk("Enable Mpeg mux"); |
2086 | dib7000p_write_word(state, 1287, reg); | 2070 | dib7000p_write_word(state, 1287, reg); |
2087 | 2071 | ||
2088 | reg &= ~(1 << 7); // P_restart_mpegMux = 0 | 2072 | reg &= ~(1 << 7); |
2089 | dib7000p_write_word(state, 1287, reg); | 2073 | dib7000p_write_word(state, 1287, reg); |
2090 | 2074 | ||
2091 | reg = (1 << 4); //P_enMpegMuxOnHostBus = 1 | 2075 | reg = (1 << 4); |
2092 | dib7000p_write_word(state, 1288, reg); | 2076 | dib7000p_write_word(state, 1288, reg); |
2093 | 2077 | ||
2094 | return 0; | 2078 | return 0; |
@@ -2099,10 +2083,10 @@ static int dib7090_disableMpegMux(struct dib7000p_state *state) | |||
2099 | u16 reg; | 2083 | u16 reg; |
2100 | 2084 | ||
2101 | dprintk("Disable Mpeg mux"); | 2085 | dprintk("Disable Mpeg mux"); |
2102 | dib7000p_write_word(state, 1288, 0); //P_enMpegMuxOnHostBus = 0 | 2086 | dib7000p_write_word(state, 1288, 0); |
2103 | 2087 | ||
2104 | reg = dib7000p_read_word(state, 1287); | 2088 | reg = dib7000p_read_word(state, 1287); |
2105 | reg &= ~(1 << 7); // P_restart_mpegMux = 0 | 2089 | reg &= ~(1 << 7); |
2106 | dib7000p_write_word(state, 1287, reg); | 2090 | dib7000p_write_word(state, 1287, reg); |
2107 | 2091 | ||
2108 | return 0; | 2092 | return 0; |
@@ -2112,19 +2096,19 @@ static int dib7090_set_input_mode(struct dvb_frontend *fe, int mode) | |||
2112 | { | 2096 | { |
2113 | struct dib7000p_state *state = fe->demodulator_priv; | 2097 | struct dib7000p_state *state = fe->demodulator_priv; |
2114 | 2098 | ||
2115 | switch(mode) { | 2099 | switch (mode) { |
2116 | case INPUT_MODE_DIVERSITY: | 2100 | case INPUT_MODE_DIVERSITY: |
2117 | dprintk("Enable diversity INPUT"); | 2101 | dprintk("Enable diversity INPUT"); |
2118 | dib7090_cfg_DibRx(state, 5,5,0,0,0,0,0); | 2102 | dib7090_cfg_DibRx(state, 5, 5, 0, 0, 0, 0, 0); |
2119 | break; | 2103 | break; |
2120 | case INPUT_MODE_MPEG: | 2104 | case INPUT_MODE_MPEG: |
2121 | dprintk("Enable Mpeg INPUT"); | 2105 | dprintk("Enable Mpeg INPUT"); |
2122 | dib7090_cfg_DibRx(state, 8,5,0,0,0,8,0); /*outputRate = 8 */ | 2106 | dib7090_cfg_DibRx(state, 8, 5, 0, 0, 0, 8, 0); /*outputRate = 8 */ |
2123 | break; | 2107 | break; |
2124 | case INPUT_MODE_OFF: | 2108 | case INPUT_MODE_OFF: |
2125 | default: | 2109 | default: |
2126 | dprintk("Disable INPUT"); | 2110 | dprintk("Disable INPUT"); |
2127 | dib7090_cfg_DibRx(state, 0,0,0,0,0,0,0); | 2111 | dib7090_cfg_DibRx(state, 0, 0, 0, 0, 0, 0, 0); |
2128 | break; | 2112 | break; |
2129 | } | 2113 | } |
2130 | return 0; | 2114 | return 0; |
@@ -2175,7 +2159,7 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode) | |||
2175 | } else { /* Use Smooth block */ | 2159 | } else { /* Use Smooth block */ |
2176 | dprintk("Sip 7090P setting output mode TS_SERIAL using Smooth bloc"); | 2160 | dprintk("Sip 7090P setting output mode TS_SERIAL using Smooth bloc"); |
2177 | dib7090_disableMpegMux(state); | 2161 | dib7090_disableMpegMux(state); |
2178 | dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 | 2162 | dib7000p_write_word(state, 1288, (1 << 6)); |
2179 | outreg |= (2 << 6) | (0 << 1); | 2163 | outreg |= (2 << 6) | (0 << 1); |
2180 | } | 2164 | } |
2181 | break; | 2165 | break; |
@@ -2190,7 +2174,7 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode) | |||
2190 | } else { /* Use Smooth block */ | 2174 | } else { /* Use Smooth block */ |
2191 | dprintk("Sip 7090P setting output mode TS_PARALLEL_GATED using Smooth block"); | 2175 | dprintk("Sip 7090P setting output mode TS_PARALLEL_GATED using Smooth block"); |
2192 | dib7090_disableMpegMux(state); | 2176 | dib7090_disableMpegMux(state); |
2193 | dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 | 2177 | dib7000p_write_word(state, 1288, (1 << 6)); |
2194 | outreg |= (0 << 6); | 2178 | outreg |= (0 << 6); |
2195 | } | 2179 | } |
2196 | break; | 2180 | break; |
@@ -2198,14 +2182,14 @@ static int dib7090_set_output_mode(struct dvb_frontend *fe, int mode) | |||
2198 | case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */ | 2182 | case OUTMODE_MPEG2_PAR_CONT_CLK: /* Using Smooth block only */ |
2199 | dprintk("Sip 7090P setting output mode TS_PARALLEL_CONT using Smooth block"); | 2183 | dprintk("Sip 7090P setting output mode TS_PARALLEL_CONT using Smooth block"); |
2200 | dib7090_disableMpegMux(state); | 2184 | dib7090_disableMpegMux(state); |
2201 | dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 | 2185 | dib7000p_write_word(state, 1288, (1 << 6)); |
2202 | outreg |= (1 << 6); | 2186 | outreg |= (1 << 6); |
2203 | break; | 2187 | break; |
2204 | 2188 | ||
2205 | case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */ | 2189 | case OUTMODE_MPEG2_FIFO: /* Using Smooth block because not supported by new Mpeg Mux bloc */ |
2206 | dprintk("Sip 7090P setting output mode TS_FIFO using Smooth block"); | 2190 | dprintk("Sip 7090P setting output mode TS_FIFO using Smooth block"); |
2207 | dib7090_disableMpegMux(state); | 2191 | dib7090_disableMpegMux(state); |
2208 | dib7000p_write_word(state, 1288, (1 << 6)); //P_enDemOutInterfOnHostBus = 1 | 2192 | dib7000p_write_word(state, 1288, (1 << 6)); |
2209 | outreg |= (5 << 6); | 2193 | outreg |= (5 << 6); |
2210 | smo_mode |= (3 << 1); | 2194 | smo_mode |= (3 << 1); |
2211 | fifo_threshold = 512; | 2195 | fifo_threshold = 512; |
@@ -2242,12 +2226,11 @@ int dib7090_tuner_sleep(struct dvb_frontend *fe, int onoff) | |||
2242 | 2226 | ||
2243 | en_cur_state = dib7000p_read_word(state, 1922); | 2227 | en_cur_state = dib7000p_read_word(state, 1922); |
2244 | 2228 | ||
2245 | if (en_cur_state > 0xff) { //LNAs and MIX are ON and therefore it is a valid configuration | 2229 | if (en_cur_state > 0xff) |
2246 | state->tuner_enable = en_cur_state; | 2230 | state->tuner_enable = en_cur_state; |
2247 | } | ||
2248 | 2231 | ||
2249 | if (onoff) | 2232 | if (onoff) |
2250 | en_cur_state &= 0x00ff; //Mask to be applied | 2233 | en_cur_state &= 0x00ff; |
2251 | else { | 2234 | else { |
2252 | if (state->tuner_enable != 0) | 2235 | if (state->tuner_enable != 0) |
2253 | en_cur_state = state->tuner_enable; | 2236 | en_cur_state = state->tuner_enable; |
@@ -2275,13 +2258,13 @@ EXPORT_SYMBOL(dib7090_get_adc_power); | |||
2275 | int dib7090_slave_reset(struct dvb_frontend *fe) | 2258 | int dib7090_slave_reset(struct dvb_frontend *fe) |
2276 | { | 2259 | { |
2277 | struct dib7000p_state *state = fe->demodulator_priv; | 2260 | struct dib7000p_state *state = fe->demodulator_priv; |
2278 | u16 reg; | 2261 | u16 reg; |
2279 | 2262 | ||
2280 | reg = dib7000p_read_word(state, 1794); | 2263 | reg = dib7000p_read_word(state, 1794); |
2281 | dib7000p_write_word(state, 1794, reg | (4 << 12)); | 2264 | dib7000p_write_word(state, 1794, reg | (4 << 12)); |
2282 | 2265 | ||
2283 | dib7000p_write_word(state, 1032, 0xffff); | 2266 | dib7000p_write_word(state, 1032, 0xffff); |
2284 | return 0; | 2267 | return 0; |
2285 | } | 2268 | } |
2286 | EXPORT_SYMBOL(dib7090_slave_reset); | 2269 | EXPORT_SYMBOL(dib7090_slave_reset); |
2287 | 2270 | ||
@@ -2340,7 +2323,7 @@ struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, | |||
2340 | 2323 | ||
2341 | return demod; | 2324 | return demod; |
2342 | 2325 | ||
2343 | error: | 2326 | error: |
2344 | kfree(st); | 2327 | kfree(st); |
2345 | return NULL; | 2328 | return NULL; |
2346 | } | 2329 | } |
diff --git a/drivers/media/dvb/frontends/dib7000p.h b/drivers/media/dvb/frontends/dib7000p.h index 4e3ffc888341..0179f9474bac 100644 --- a/drivers/media/dvb/frontends/dib7000p.h +++ b/drivers/media/dvb/frontends/dib7000p.h | |||
@@ -39,7 +39,7 @@ struct dib7000p_config { | |||
39 | u16 diversity_delay; | 39 | u16 diversity_delay; |
40 | 40 | ||
41 | u8 default_i2c_addr; | 41 | u8 default_i2c_addr; |
42 | u8 enMpegOutput : 1; | 42 | u8 enMpegOutput:1; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | #define DEFAULT_DIB7000P_I2C_ADDRESS 18 | 45 | #define DEFAULT_DIB7000P_I2C_ADDRESS 18 |
diff --git a/drivers/media/dvb/frontends/dib8000.c b/drivers/media/dvb/frontends/dib8000.c index 625e4210d2dd..3961fed9da6e 100644 --- a/drivers/media/dvb/frontends/dib8000.c +++ b/drivers/media/dvb/frontends/dib8000.c | |||
@@ -261,7 +261,8 @@ static int dib8000_set_output_mode(struct dvb_frontend *fe, int mode) | |||
261 | fifo_threshold = 1792; | 261 | fifo_threshold = 1792; |
262 | smo_mode = (dib8000_read_word(state, 299) & 0x0050) | (1 << 1); | 262 | smo_mode = (dib8000_read_word(state, 299) & 0x0050) | (1 << 1); |
263 | 263 | ||
264 | dprintk("-I- Setting output mode for demod %p to %d", &state->fe[0], mode); | 264 | dprintk("-I- Setting output mode for demod %p to %d", |
265 | &state->fe[0], mode); | ||
265 | 266 | ||
266 | switch (mode) { | 267 | switch (mode) { |
267 | case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock | 268 | case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock |
@@ -295,7 +296,8 @@ static int dib8000_set_output_mode(struct dvb_frontend *fe, int mode) | |||
295 | break; | 296 | break; |
296 | 297 | ||
297 | default: | 298 | default: |
298 | dprintk("Unhandled output_mode passed to be set for demod %p", &state->fe[0]); | 299 | dprintk("Unhandled output_mode passed to be set for demod %p", |
300 | &state->fe[0]); | ||
299 | return -EINVAL; | 301 | return -EINVAL; |
300 | } | 302 | } |
301 | 303 | ||
@@ -345,7 +347,8 @@ static void dib8000_set_power_mode(struct dib8000_state *state, enum dib8000_pow | |||
345 | { | 347 | { |
346 | /* by default everything is going to be powered off */ | 348 | /* by default everything is going to be powered off */ |
347 | u16 reg_774 = 0x3fff, reg_775 = 0xffff, reg_776 = 0xffff, | 349 | u16 reg_774 = 0x3fff, reg_775 = 0xffff, reg_776 = 0xffff, |
348 | reg_900 = (dib8000_read_word(state, 900) & 0xfffc) | 0x3, reg_1280 = (dib8000_read_word(state, 1280) & 0x00ff) | 0xff00; | 350 | reg_900 = (dib8000_read_word(state, 900) & 0xfffc) | 0x3, |
351 | reg_1280 = (dib8000_read_word(state, 1280) & 0x00ff) | 0xff00; | ||
349 | 352 | ||
350 | /* now, depending on the requested mode, we power on */ | 353 | /* now, depending on the requested mode, we power on */ |
351 | switch (mode) { | 354 | switch (mode) { |
@@ -482,7 +485,8 @@ static void dib8000_reset_pll(struct dib8000_state *state) | |||
482 | 485 | ||
483 | // clk_cfg1 | 486 | // clk_cfg1 |
484 | clk_cfg1 = (1 << 10) | (0 << 9) | (pll->IO_CLK_en_core << 8) | | 487 | clk_cfg1 = (1 << 10) | (0 << 9) | (pll->IO_CLK_en_core << 8) | |
485 | (pll->bypclk_div << 5) | (pll->enable_refdiv << 4) | (1 << 3) | (pll->pll_range << 1) | (pll->pll_reset << 0); | 488 | (pll->bypclk_div << 5) | (pll->enable_refdiv << 4) | (1 << 3) | |
489 | (pll->pll_range << 1) | (pll->pll_reset << 0); | ||
486 | 490 | ||
487 | dib8000_write_word(state, 902, clk_cfg1); | 491 | dib8000_write_word(state, 902, clk_cfg1); |
488 | clk_cfg1 = (clk_cfg1 & 0xfff7) | (pll->pll_bypass << 3); | 492 | clk_cfg1 = (clk_cfg1 & 0xfff7) | (pll->pll_bypass << 3); |
@@ -492,11 +496,12 @@ static void dib8000_reset_pll(struct dib8000_state *state) | |||
492 | 496 | ||
493 | /* smpl_cfg: P_refclksel=2, P_ensmplsel=1 nodivsmpl=1 */ | 497 | /* smpl_cfg: P_refclksel=2, P_ensmplsel=1 nodivsmpl=1 */ |
494 | if (state->cfg.pll->ADClkSrc == 0) | 498 | if (state->cfg.pll->ADClkSrc == 0) |
495 | dib8000_write_word(state, 904, (0 << 15) | (0 << 12) | (0 << 10) | (pll->modulo << 8) | (pll->ADClkSrc << 7) | (0 << 1)); | 499 | dib8000_write_word(state, 904, (0 << 15) | (0 << 12) | (0 << 10) | |
500 | (pll->modulo << 8) | (pll->ADClkSrc << 7) | (0 << 1)); | ||
496 | else if (state->cfg.refclksel != 0) | 501 | else if (state->cfg.refclksel != 0) |
497 | dib8000_write_word(state, 904, | 502 | dib8000_write_word(state, 904, (0 << 15) | (1 << 12) | |
498 | (0 << 15) | (1 << 12) | ((state->cfg.refclksel & 0x3) << 10) | (pll->modulo << 8) | (pll-> | 503 | ((state->cfg.refclksel & 0x3) << 10) | (pll->modulo << 8) | |
499 | ADClkSrc << 7) | (0 << 1)); | 504 | (pll->ADClkSrc << 7) | (0 << 1)); |
500 | else | 505 | else |
501 | dib8000_write_word(state, 904, (0 << 15) | (1 << 12) | (3 << 10) | (pll->modulo << 8) | (pll->ADClkSrc << 7) | (0 << 1)); | 506 | dib8000_write_word(state, 904, (0 << 15) | (1 << 12) | (3 << 10) | (pll->modulo << 8) | (pll->ADClkSrc << 7) | (0 << 1)); |
502 | 507 | ||
@@ -627,14 +632,14 @@ static const u16 dib8000_defaults[] = { | |||
627 | 1, 285, | 632 | 1, 285, |
628 | 0x0020, //p_fec_ | 633 | 0x0020, //p_fec_ |
629 | 1, 299, | 634 | 1, 299, |
630 | 0x0062, // P_smo_mode, P_smo_rs_discard, P_smo_fifo_flush, P_smo_pid_parse, P_smo_error_discard | 635 | 0x0062, /* P_smo_mode, P_smo_rs_discard, P_smo_fifo_flush, P_smo_pid_parse, P_smo_error_discard */ |
631 | 636 | ||
632 | 1, 338, | 637 | 1, 338, |
633 | (1 << 12) | // P_ctrl_corm_thres4pre_freq_inh=1 | 638 | (1 << 12) | // P_ctrl_corm_thres4pre_freq_inh=1 |
634 | (1 << 10) | // P_ctrl_pre_freq_mode_sat=1 | 639 | (1 << 10) | |
635 | (0 << 9) | // P_ctrl_pre_freq_inh=0 | 640 | (0 << 9) | /* P_ctrl_pre_freq_inh=0 */ |
636 | (3 << 5) | // P_ctrl_pre_freq_step=3 | 641 | (3 << 5) | /* P_ctrl_pre_freq_step=3 */ |
637 | (1 << 0), // P_pre_freq_win_len=1 | 642 | (1 << 0), /* P_pre_freq_win_len=1 */ |
638 | 643 | ||
639 | 1, 903, | 644 | 1, 903, |
640 | (0 << 4) | 2, // P_divclksel=0 P_divbitsel=2 (was clk=3,bit=1 for MPW) | 645 | (0 << 4) | 2, // P_divclksel=0 P_divbitsel=2 (was clk=3,bit=1 for MPW) |
@@ -782,7 +787,7 @@ static int dib8000_update_lna(struct dib8000_state *state) | |||
782 | // read dyn_gain here (because it is demod-dependent and not tuner) | 787 | // read dyn_gain here (because it is demod-dependent and not tuner) |
783 | dyn_gain = dib8000_read_word(state, 390); | 788 | dyn_gain = dib8000_read_word(state, 390); |
784 | 789 | ||
785 | if (state->cfg.update_lna(state->fe[0], dyn_gain)) { // LNA has changed | 790 | if (state->cfg.update_lna(state->fe[0], dyn_gain)) { |
786 | dib8000_restart_agc(state); | 791 | dib8000_restart_agc(state); |
787 | return 1; | 792 | return 1; |
788 | } | 793 | } |
@@ -869,7 +874,8 @@ static int dib8000_agc_soft_split(struct dib8000_state *state) | |||
869 | split_offset = state->current_agc->split.max; | 874 | split_offset = state->current_agc->split.max; |
870 | else | 875 | else |
871 | split_offset = state->current_agc->split.max * | 876 | split_offset = state->current_agc->split.max * |
872 | (agc - state->current_agc->split.min_thres) / (state->current_agc->split.max_thres - state->current_agc->split.min_thres); | 877 | (agc - state->current_agc->split.min_thres) / |
878 | (state->current_agc->split.max_thres - state->current_agc->split.min_thres); | ||
873 | 879 | ||
874 | dprintk("AGC split_offset: %d", split_offset); | 880 | dprintk("AGC split_offset: %d", split_offset); |
875 | 881 | ||
@@ -952,14 +958,13 @@ s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode) | |||
952 | s32 val; | 958 | s32 val; |
953 | 959 | ||
954 | val = dib8000_read32(state, 384); | 960 | val = dib8000_read32(state, 384); |
955 | /* mode = 1 : ln_agcpower calc using mant-exp conversion and mantis look up table */ | ||
956 | if (mode) { | 961 | if (mode) { |
957 | tmp_val = val; | 962 | tmp_val = val; |
958 | while (tmp_val >>= 1) | 963 | while (tmp_val >>= 1) |
959 | exp++; | 964 | exp++; |
960 | mant = (val * 1000 / (1<<exp)); | 965 | mant = (val * 1000 / (1<<exp)); |
961 | ix = (u8)((mant-1000)/100); /* index of the LUT */ | 966 | ix = (u8)((mant-1000)/100); /* index of the LUT */ |
962 | val = (lut_1000ln_mant[ix] + 693*(exp-20) - 6908); /* 1000 * ln(adcpower_real) ; 693 = 1000ln(2) ; 6908 = 1000*ln(1000) ; 20 comes from adc_real = adc_pow_int / 2**20 */ | 967 | val = (lut_1000ln_mant[ix] + 693*(exp-20) - 6908); |
963 | val = (val*256)/1000; | 968 | val = (val*256)/1000; |
964 | } | 969 | } |
965 | return val; | 970 | return val; |
@@ -1006,18 +1011,19 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1006 | dib8000_write_word(state, 285, dib8000_read_word(state, 285) & 0x60); | 1011 | dib8000_write_word(state, 285, dib8000_read_word(state, 285) & 0x60); |
1007 | 1012 | ||
1008 | i = dib8000_read_word(state, 26) & 1; // P_dds_invspec | 1013 | i = dib8000_read_word(state, 26) & 1; // P_dds_invspec |
1009 | dib8000_write_word(state, 26, state->fe[0]->dtv_property_cache.inversion ^ i); | 1014 | dib8000_write_word(state, 26, state->fe[0]->dtv_property_cache.inversion^i); |
1010 | 1015 | ||
1011 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode) { | 1016 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode) { |
1012 | //compute new dds_freq for the seg and adjust prbs | 1017 | //compute new dds_freq for the seg and adjust prbs |
1013 | int seg_offset = | 1018 | int seg_offset = |
1014 | state->fe[0]->dtv_property_cache.isdbt_sb_segment_idx - (state->fe[0]->dtv_property_cache.isdbt_sb_segment_count / 2) - | 1019 | state->fe[0]->dtv_property_cache.isdbt_sb_segment_idx - |
1020 | (state->fe[0]->dtv_property_cache.isdbt_sb_segment_count / 2) - | ||
1015 | (state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2); | 1021 | (state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2); |
1016 | int clk = state->cfg.pll->internal; | 1022 | int clk = state->cfg.pll->internal; |
1017 | u32 segtodds = ((u32) (430 << 23) / clk) << 3; // segtodds = SegBW / Fclk * pow(2,26) | 1023 | u32 segtodds = ((u32) (430 << 23) / clk) << 3; // segtodds = SegBW / Fclk * pow(2,26) |
1018 | int dds_offset = seg_offset * segtodds; | 1024 | int dds_offset = seg_offset * segtodds; |
1019 | int new_dds, sub_channel; | 1025 | int new_dds, sub_channel; |
1020 | if ((state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2) == 0) // if even | 1026 | if ((state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2) == 0) |
1021 | dds_offset -= (int)(segtodds / 2); | 1027 | dds_offset -= (int)(segtodds / 2); |
1022 | 1028 | ||
1023 | if (state->cfg.pll->ifreq == 0) { | 1029 | if (state->cfg.pll->ifreq == 0) { |
@@ -1031,7 +1037,8 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1031 | // - the segment of center frequency with an odd total number of segments | 1037 | // - the segment of center frequency with an odd total number of segments |
1032 | // - the segment to the left of center frequency with an even total number of segments | 1038 | // - the segment to the left of center frequency with an even total number of segments |
1033 | // - the segment to the right of center frequency with an even total number of segments | 1039 | // - the segment to the right of center frequency with an even total number of segments |
1034 | if ((state->fe[0]->dtv_property_cache.delivery_system == SYS_ISDBT) && (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) | 1040 | if ((state->fe[0]->dtv_property_cache.delivery_system == SYS_ISDBT) |
1041 | && (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) | ||
1035 | && (((state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2) | 1042 | && (((state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2) |
1036 | && (state->fe[0]->dtv_property_cache.isdbt_sb_segment_idx == | 1043 | && (state->fe[0]->dtv_property_cache.isdbt_sb_segment_idx == |
1037 | ((state->fe[0]->dtv_property_cache.isdbt_sb_segment_count / 2) + 1))) | 1044 | ((state->fe[0]->dtv_property_cache.isdbt_sb_segment_count / 2) + 1))) |
@@ -1051,9 +1058,9 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1051 | } | 1058 | } |
1052 | dib8000_write_word(state, 27, (u16) ((new_dds >> 16) & 0x01ff)); | 1059 | dib8000_write_word(state, 27, (u16) ((new_dds >> 16) & 0x01ff)); |
1053 | dib8000_write_word(state, 28, (u16) (new_dds & 0xffff)); | 1060 | dib8000_write_word(state, 28, (u16) (new_dds & 0xffff)); |
1054 | if (state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2) // if odd | 1061 | if (state->fe[0]->dtv_property_cache.isdbt_sb_segment_count % 2) |
1055 | sub_channel = ((state->fe[0]->dtv_property_cache.isdbt_sb_subchannel + (3 * seg_offset) + 1) % 41) / 3; | 1062 | sub_channel = ((state->fe[0]->dtv_property_cache.isdbt_sb_subchannel + (3 * seg_offset) + 1) % 41) / 3; |
1056 | else // if even | 1063 | else |
1057 | sub_channel = ((state->fe[0]->dtv_property_cache.isdbt_sb_subchannel + (3 * seg_offset)) % 41) / 3; | 1064 | sub_channel = ((state->fe[0]->dtv_property_cache.isdbt_sb_subchannel + (3 * seg_offset)) % 41) / 3; |
1058 | sub_channel -= 6; | 1065 | sub_channel -= 6; |
1059 | 1066 | ||
@@ -1212,7 +1219,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1212 | } | 1219 | } |
1213 | break; | 1220 | break; |
1214 | } | 1221 | } |
1215 | } else { // if not state->fe[0]->dtv_property_cache.isdbt_sb_mode | 1222 | } else { |
1216 | dib8000_write_word(state, 27, (u16) ((state->cfg.pll->ifreq >> 16) & 0x01ff)); | 1223 | dib8000_write_word(state, 27, (u16) ((state->cfg.pll->ifreq >> 16) & 0x01ff)); |
1217 | dib8000_write_word(state, 28, (u16) (state->cfg.pll->ifreq & 0xffff)); | 1224 | dib8000_write_word(state, 28, (u16) (state->cfg.pll->ifreq & 0xffff)); |
1218 | dib8000_write_word(state, 26, (u16) ((state->cfg.pll->ifreq >> 25) & 0x0003)); | 1225 | dib8000_write_word(state, 26, (u16) ((state->cfg.pll->ifreq >> 25) & 0x0003)); |
@@ -1332,8 +1339,8 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1332 | state->differential_constellation = (seg_diff_mask != 0); | 1339 | state->differential_constellation = (seg_diff_mask != 0); |
1333 | dib8000_set_diversity_in(state->fe[0], state->diversity_onoff); | 1340 | dib8000_set_diversity_in(state->fe[0], state->diversity_onoff); |
1334 | 1341 | ||
1335 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { // ISDB-Tsb | 1342 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1336 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 1) // 3-segments | 1343 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 1) |
1337 | seg_mask13 = 0x00E0; | 1344 | seg_mask13 = 0x00E0; |
1338 | else // 1-segment | 1345 | else // 1-segment |
1339 | seg_mask13 = 0x0040; | 1346 | seg_mask13 = 0x0040; |
@@ -1355,25 +1362,24 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1355 | dib8000_write_word(state, 353, seg_mask13); // ADDR 353 | 1362 | dib8000_write_word(state, 353, seg_mask13); // ADDR 353 |
1356 | 1363 | ||
1357 | /* // P_small_narrow_band=0, P_small_last_seg=13, P_small_offset_num_car=5 */ | 1364 | /* // P_small_narrow_band=0, P_small_last_seg=13, P_small_offset_num_car=5 */ |
1358 | // dib8000_write_word(state, 351, (state->fe[0]->dtv_property_cache.isdbt_sb_mode << 8) | (13 << 4) | 5 ); | ||
1359 | 1365 | ||
1360 | // ---- SMALL ---- | 1366 | // ---- SMALL ---- |
1361 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { | 1367 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1362 | switch (state->fe[0]->dtv_property_cache.transmission_mode) { | 1368 | switch (state->fe[0]->dtv_property_cache.transmission_mode) { |
1363 | case TRANSMISSION_MODE_2K: | 1369 | case TRANSMISSION_MODE_2K: |
1364 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { // 1-seg | 1370 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { |
1365 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) // DQPSK | 1371 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) |
1366 | ncoeff = coeff_2k_sb_1seg_dqpsk; | 1372 | ncoeff = coeff_2k_sb_1seg_dqpsk; |
1367 | else // QPSK or QAM | 1373 | else // QPSK or QAM |
1368 | ncoeff = coeff_2k_sb_1seg; | 1374 | ncoeff = coeff_2k_sb_1seg; |
1369 | } else { // 3-segments | 1375 | } else { // 3-segments |
1370 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) { // DQPSK on central segment | 1376 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) { |
1371 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) // DQPSK on external segments | 1377 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) |
1372 | ncoeff = coeff_2k_sb_3seg_0dqpsk_1dqpsk; | 1378 | ncoeff = coeff_2k_sb_3seg_0dqpsk_1dqpsk; |
1373 | else // QPSK or QAM on external segments | 1379 | else // QPSK or QAM on external segments |
1374 | ncoeff = coeff_2k_sb_3seg_0dqpsk; | 1380 | ncoeff = coeff_2k_sb_3seg_0dqpsk; |
1375 | } else { // QPSK or QAM on central segment | 1381 | } else { // QPSK or QAM on central segment |
1376 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) // DQPSK on external segments | 1382 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) |
1377 | ncoeff = coeff_2k_sb_3seg_1dqpsk; | 1383 | ncoeff = coeff_2k_sb_3seg_1dqpsk; |
1378 | else // QPSK or QAM on external segments | 1384 | else // QPSK or QAM on external segments |
1379 | ncoeff = coeff_2k_sb_3seg; | 1385 | ncoeff = coeff_2k_sb_3seg; |
@@ -1382,20 +1388,20 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1382 | break; | 1388 | break; |
1383 | 1389 | ||
1384 | case TRANSMISSION_MODE_4K: | 1390 | case TRANSMISSION_MODE_4K: |
1385 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { // 1-seg | 1391 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { |
1386 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) // DQPSK | 1392 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) |
1387 | ncoeff = coeff_4k_sb_1seg_dqpsk; | 1393 | ncoeff = coeff_4k_sb_1seg_dqpsk; |
1388 | else // QPSK or QAM | 1394 | else // QPSK or QAM |
1389 | ncoeff = coeff_4k_sb_1seg; | 1395 | ncoeff = coeff_4k_sb_1seg; |
1390 | } else { // 3-segments | 1396 | } else { // 3-segments |
1391 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) { // DQPSK on central segment | 1397 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) { |
1392 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { // DQPSK on external segments | 1398 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { |
1393 | ncoeff = coeff_4k_sb_3seg_0dqpsk_1dqpsk; | 1399 | ncoeff = coeff_4k_sb_3seg_0dqpsk_1dqpsk; |
1394 | } else { // QPSK or QAM on external segments | 1400 | } else { // QPSK or QAM on external segments |
1395 | ncoeff = coeff_4k_sb_3seg_0dqpsk; | 1401 | ncoeff = coeff_4k_sb_3seg_0dqpsk; |
1396 | } | 1402 | } |
1397 | } else { // QPSK or QAM on central segment | 1403 | } else { // QPSK or QAM on central segment |
1398 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { // DQPSK on external segments | 1404 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { |
1399 | ncoeff = coeff_4k_sb_3seg_1dqpsk; | 1405 | ncoeff = coeff_4k_sb_3seg_1dqpsk; |
1400 | } else // QPSK or QAM on external segments | 1406 | } else // QPSK or QAM on external segments |
1401 | ncoeff = coeff_4k_sb_3seg; | 1407 | ncoeff = coeff_4k_sb_3seg; |
@@ -1406,20 +1412,20 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1406 | case TRANSMISSION_MODE_AUTO: | 1412 | case TRANSMISSION_MODE_AUTO: |
1407 | case TRANSMISSION_MODE_8K: | 1413 | case TRANSMISSION_MODE_8K: |
1408 | default: | 1414 | default: |
1409 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { // 1-seg | 1415 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { |
1410 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) // DQPSK | 1416 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) |
1411 | ncoeff = coeff_8k_sb_1seg_dqpsk; | 1417 | ncoeff = coeff_8k_sb_1seg_dqpsk; |
1412 | else // QPSK or QAM | 1418 | else // QPSK or QAM |
1413 | ncoeff = coeff_8k_sb_1seg; | 1419 | ncoeff = coeff_8k_sb_1seg; |
1414 | } else { // 3-segments | 1420 | } else { // 3-segments |
1415 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) { // DQPSK on central segment | 1421 | if (state->fe[0]->dtv_property_cache.layer[0].modulation == DQPSK) { |
1416 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { // DQPSK on external segments | 1422 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { |
1417 | ncoeff = coeff_8k_sb_3seg_0dqpsk_1dqpsk; | 1423 | ncoeff = coeff_8k_sb_3seg_0dqpsk_1dqpsk; |
1418 | } else { // QPSK or QAM on external segments | 1424 | } else { // QPSK or QAM on external segments |
1419 | ncoeff = coeff_8k_sb_3seg_0dqpsk; | 1425 | ncoeff = coeff_8k_sb_3seg_0dqpsk; |
1420 | } | 1426 | } |
1421 | } else { // QPSK or QAM on central segment | 1427 | } else { // QPSK or QAM on central segment |
1422 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { // DQPSK on external segments | 1428 | if (state->fe[0]->dtv_property_cache.layer[1].modulation == DQPSK) { |
1423 | ncoeff = coeff_8k_sb_3seg_1dqpsk; | 1429 | ncoeff = coeff_8k_sb_3seg_1dqpsk; |
1424 | } else // QPSK or QAM on external segments | 1430 | } else // QPSK or QAM on external segments |
1425 | ncoeff = coeff_8k_sb_3seg; | 1431 | ncoeff = coeff_8k_sb_3seg; |
@@ -1437,7 +1443,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1437 | 1443 | ||
1438 | // ---- COFF ---- | 1444 | // ---- COFF ---- |
1439 | // Carloff, the most robust | 1445 | // Carloff, the most robust |
1440 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { // Sound Broadcasting mode - use both TMCC and AC pilots | 1446 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1441 | 1447 | ||
1442 | // P_coff_cpil_alpha=4, P_coff_inh=0, P_coff_cpil_winlen=64 | 1448 | // P_coff_cpil_alpha=4, P_coff_inh=0, P_coff_cpil_winlen=64 |
1443 | // P_coff_narrow_band=1, P_coff_square_val=1, P_coff_one_seg=~partial_rcpt, P_coff_use_tmcc=1, P_coff_use_ac=1 | 1449 | // P_coff_narrow_band=1, P_coff_square_val=1, P_coff_one_seg=~partial_rcpt, P_coff_use_tmcc=1, P_coff_use_ac=1 |
@@ -1448,7 +1454,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1448 | /* // P_small_coef_ext_enable = 1 */ | 1454 | /* // P_small_coef_ext_enable = 1 */ |
1449 | /* dib8000_write_word(state, 351, dib8000_read_word(state, 351) | 0x200); */ | 1455 | /* dib8000_write_word(state, 351, dib8000_read_word(state, 351) | 0x200); */ |
1450 | 1456 | ||
1451 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { // Sound Broadcasting mode 1 seg | 1457 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { |
1452 | 1458 | ||
1453 | // P_coff_winlen=63, P_coff_thres_lock=15, P_coff_one_seg_width= (P_mode == 3) , P_coff_one_seg_sym= (P_mode-1) | 1459 | // P_coff_winlen=63, P_coff_thres_lock=15, P_coff_one_seg_width= (P_mode == 3) , P_coff_one_seg_sym= (P_mode-1) |
1454 | if (mode == 3) | 1460 | if (mode == 3) |
@@ -1512,7 +1518,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1512 | dib8000_write_word(state, 341, (4 << 3) | (1 << 2) | (1 << 1) | (1 << 0)); | 1518 | dib8000_write_word(state, 341, (4 << 3) | (1 << 2) | (1 << 1) | (1 << 0)); |
1513 | } | 1519 | } |
1514 | // ---- FFT ---- | 1520 | // ---- FFT ---- |
1515 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1 && state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) // 1-seg | 1521 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1 && state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) |
1516 | dib8000_write_word(state, 178, 64); // P_fft_powrange=64 | 1522 | dib8000_write_word(state, 178, 64); // P_fft_powrange=64 |
1517 | else | 1523 | else |
1518 | dib8000_write_word(state, 178, 32); // P_fft_powrange=32 | 1524 | dib8000_write_word(state, 178, 32); // P_fft_powrange=32 |
@@ -1542,7 +1548,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1542 | 1548 | ||
1543 | /* offset loop parameters */ | 1549 | /* offset loop parameters */ |
1544 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { | 1550 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1545 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) // Sound Broadcasting mode 1 seg | 1551 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) |
1546 | /* P_timf_alpha = (11-P_mode), P_corm_alpha=6, P_corm_thres=0x80 */ | 1552 | /* P_timf_alpha = (11-P_mode), P_corm_alpha=6, P_corm_thres=0x80 */ |
1547 | dib8000_write_word(state, 32, ((11 - mode) << 12) | (6 << 8) | 0x40); | 1553 | dib8000_write_word(state, 32, ((11 - mode) << 12) | (6 << 8) | 0x40); |
1548 | 1554 | ||
@@ -1555,7 +1561,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1555 | dib8000_write_word(state, 32, ((9 - mode) << 12) | (6 << 8) | 0x80); | 1561 | dib8000_write_word(state, 32, ((9 - mode) << 12) | (6 << 8) | 0x80); |
1556 | 1562 | ||
1557 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { | 1563 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1558 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) // Sound Broadcasting mode 1 seg | 1564 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) |
1559 | /* P_ctrl_pha_off_max=3 P_ctrl_sfreq_inh =0 P_ctrl_sfreq_step = (11-P_mode) */ | 1565 | /* P_ctrl_pha_off_max=3 P_ctrl_sfreq_inh =0 P_ctrl_sfreq_step = (11-P_mode) */ |
1560 | dib8000_write_word(state, 37, (3 << 5) | (0 << 4) | (10 - mode)); | 1566 | dib8000_write_word(state, 37, (3 << 5) | (0 << 4) | (10 - mode)); |
1561 | 1567 | ||
@@ -1628,7 +1634,7 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1628 | 1634 | ||
1629 | // ---- ANA_FE ---- | 1635 | // ---- ANA_FE ---- |
1630 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode) { | 1636 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode) { |
1631 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 1) // 3-segments | 1637 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 1) |
1632 | ana_fe = ana_fe_coeff_3seg; | 1638 | ana_fe = ana_fe_coeff_3seg; |
1633 | else // 1-segment | 1639 | else // 1-segment |
1634 | ana_fe = ana_fe_coeff_1seg; | 1640 | ana_fe = ana_fe_coeff_1seg; |
@@ -1651,10 +1657,10 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear | |||
1651 | // "P_cspu_left_edge" not used => do not care | 1657 | // "P_cspu_left_edge" not used => do not care |
1652 | // "P_cspu_right_edge" not used => do not care | 1658 | // "P_cspu_right_edge" not used => do not care |
1653 | 1659 | ||
1654 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { // ISDB-Tsb | 1660 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1655 | dib8000_write_word(state, 228, 1); // P_2d_mode_byp=1 | 1661 | dib8000_write_word(state, 228, 1); // P_2d_mode_byp=1 |
1656 | dib8000_write_word(state, 205, dib8000_read_word(state, 205) & 0xfff0); // P_cspu_win_cut = 0 | 1662 | dib8000_write_word(state, 205, dib8000_read_word(state, 205) & 0xfff0); // P_cspu_win_cut = 0 |
1657 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0 // 1-segment | 1663 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0 |
1658 | && state->fe[0]->dtv_property_cache.transmission_mode == TRANSMISSION_MODE_2K) { | 1664 | && state->fe[0]->dtv_property_cache.transmission_mode == TRANSMISSION_MODE_2K) { |
1659 | //dib8000_write_word(state, 219, dib8000_read_word(state, 219) & 0xfffe); // P_adp_pass = 0 | 1665 | //dib8000_write_word(state, 219, dib8000_read_word(state, 219) & 0xfffe); // P_adp_pass = 0 |
1660 | dib8000_write_word(state, 265, 15); // P_equal_noise_sel = 15 | 1666 | dib8000_write_word(state, 265, 15); // P_equal_noise_sel = 15 |
@@ -1803,7 +1809,7 @@ static int dib8000_tune(struct dvb_frontend *fe) | |||
1803 | // never achieved a lock before - wait for timfreq to update | 1809 | // never achieved a lock before - wait for timfreq to update |
1804 | if (state->timf == 0) { | 1810 | if (state->timf == 0) { |
1805 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { | 1811 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1806 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) // Sound Broadcasting mode 1 seg | 1812 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) |
1807 | msleep(300); | 1813 | msleep(300); |
1808 | else // Sound Broadcasting mode 3 seg | 1814 | else // Sound Broadcasting mode 3 seg |
1809 | msleep(500); | 1815 | msleep(500); |
@@ -1811,7 +1817,7 @@ static int dib8000_tune(struct dvb_frontend *fe) | |||
1811 | msleep(200); | 1817 | msleep(200); |
1812 | } | 1818 | } |
1813 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { | 1819 | if (state->fe[0]->dtv_property_cache.isdbt_sb_mode == 1) { |
1814 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { // Sound Broadcasting mode 1 seg | 1820 | if (state->fe[0]->dtv_property_cache.isdbt_partial_reception == 0) { |
1815 | 1821 | ||
1816 | /* P_timf_alpha = (13-P_mode) , P_corm_alpha=6, P_corm_thres=0x40 alpha to check on board */ | 1822 | /* P_timf_alpha = (13-P_mode) , P_corm_alpha=6, P_corm_thres=0x40 alpha to check on board */ |
1817 | dib8000_write_word(state, 32, ((13 - mode) << 12) | (6 << 8) | 0x40); | 1823 | dib8000_write_word(state, 32, ((13 - mode) << 12) | (6 << 8) | 0x40); |
@@ -1864,9 +1870,9 @@ static int dib8000_wakeup(struct dvb_frontend *fe) | |||
1864 | if (dib8000_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0) | 1870 | if (dib8000_set_adc_state(state, DIBX000_SLOW_ADC_ON) != 0) |
1865 | dprintk("could not start Slow ADC"); | 1871 | dprintk("could not start Slow ADC"); |
1866 | 1872 | ||
1867 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1873 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1868 | ret = state->fe[index_frontend]->ops.init(state->fe[index_frontend]); | 1874 | ret = state->fe[index_frontend]->ops.init(state->fe[index_frontend]); |
1869 | if (ret<0) | 1875 | if (ret < 0) |
1870 | return ret; | 1876 | return ret; |
1871 | } | 1877 | } |
1872 | 1878 | ||
@@ -1879,7 +1885,7 @@ static int dib8000_sleep(struct dvb_frontend *fe) | |||
1879 | u8 index_frontend; | 1885 | u8 index_frontend; |
1880 | int ret; | 1886 | int ret; |
1881 | 1887 | ||
1882 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1888 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1883 | ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]); | 1889 | ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]); |
1884 | if (ret < 0) | 1890 | if (ret < 0) |
1885 | return ret; | 1891 | return ret; |
@@ -1914,13 +1920,13 @@ static int dib8000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1914 | 1920 | ||
1915 | fe->dtv_property_cache.bandwidth_hz = 6000000; | 1921 | fe->dtv_property_cache.bandwidth_hz = 6000000; |
1916 | 1922 | ||
1917 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1923 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1918 | state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); | 1924 | state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); |
1919 | if (stat&FE_HAS_SYNC) { | 1925 | if (stat&FE_HAS_SYNC) { |
1920 | dprintk("TMCC lock on the slave%i", index_frontend); | 1926 | dprintk("TMCC lock on the slave%i", index_frontend); |
1921 | /* synchronize the cache with the other frontends */ | 1927 | /* synchronize the cache with the other frontends */ |
1922 | state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], fep); | 1928 | state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], fep); |
1923 | for (sub_index_frontend=0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) { | 1929 | for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) { |
1924 | if (sub_index_frontend != index_frontend) { | 1930 | if (sub_index_frontend != index_frontend) { |
1925 | state->fe[sub_index_frontend]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode; | 1931 | state->fe[sub_index_frontend]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode; |
1926 | state->fe[sub_index_frontend]->dtv_property_cache.inversion = state->fe[index_frontend]->dtv_property_cache.inversion; | 1932 | state->fe[sub_index_frontend]->dtv_property_cache.inversion = state->fe[index_frontend]->dtv_property_cache.inversion; |
@@ -2032,7 +2038,7 @@ static int dib8000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2032 | } | 2038 | } |
2033 | 2039 | ||
2034 | /* synchronize the cache with the other frontends */ | 2040 | /* synchronize the cache with the other frontends */ |
2035 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2041 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2036 | state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = fe->dtv_property_cache.isdbt_sb_mode; | 2042 | state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = fe->dtv_property_cache.isdbt_sb_mode; |
2037 | state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion; | 2043 | state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion; |
2038 | state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode; | 2044 | state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode; |
@@ -2066,7 +2072,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2066 | state->fe[0]->dtv_property_cache.bandwidth_hz = 6000000; | 2072 | state->fe[0]->dtv_property_cache.bandwidth_hz = 6000000; |
2067 | } | 2073 | } |
2068 | 2074 | ||
2069 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2075 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2070 | /* synchronization of the cache */ | 2076 | /* synchronization of the cache */ |
2071 | state->fe[index_frontend]->dtv_property_cache.delivery_system = SYS_ISDBT; | 2077 | state->fe[index_frontend]->dtv_property_cache.delivery_system = SYS_ISDBT; |
2072 | memcpy(&state->fe[index_frontend]->dtv_property_cache, &fe->dtv_property_cache, sizeof(struct dtv_frontend_properties)); | 2078 | memcpy(&state->fe[index_frontend]->dtv_property_cache, &fe->dtv_property_cache, sizeof(struct dtv_frontend_properties)); |
@@ -2081,7 +2087,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2081 | /* start up the AGC */ | 2087 | /* start up the AGC */ |
2082 | do { | 2088 | do { |
2083 | time = dib8000_agc_startup(state->fe[0]); | 2089 | time = dib8000_agc_startup(state->fe[0]); |
2084 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2090 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2085 | time_slave = dib8000_agc_startup(state->fe[index_frontend]); | 2091 | time_slave = dib8000_agc_startup(state->fe[index_frontend]); |
2086 | if (time == FE_CALLBACK_TIME_NEVER) | 2092 | if (time == FE_CALLBACK_TIME_NEVER) |
2087 | time = time_slave; | 2093 | time = time_slave; |
@@ -2093,7 +2099,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2093 | else | 2099 | else |
2094 | break; | 2100 | break; |
2095 | exit_condition = 1; | 2101 | exit_condition = 1; |
2096 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2102 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2097 | if (dib8000_get_tune_state(state->fe[index_frontend]) != CT_AGC_STOP) { | 2103 | if (dib8000_get_tune_state(state->fe[index_frontend]) != CT_AGC_STOP) { |
2098 | exit_condition = 0; | 2104 | exit_condition = 0; |
2099 | break; | 2105 | break; |
@@ -2101,7 +2107,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2101 | } | 2107 | } |
2102 | } while (exit_condition == 0); | 2108 | } while (exit_condition == 0); |
2103 | 2109 | ||
2104 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) | 2110 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2105 | dib8000_set_tune_state(state->fe[index_frontend], CT_DEMOD_START); | 2111 | dib8000_set_tune_state(state->fe[index_frontend], CT_DEMOD_START); |
2106 | 2112 | ||
2107 | if ((state->fe[0]->dtv_property_cache.delivery_system != SYS_ISDBT) || | 2113 | if ((state->fe[0]->dtv_property_cache.delivery_system != SYS_ISDBT) || |
@@ -2132,31 +2138,30 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2132 | u8 found = 0; | 2138 | u8 found = 0; |
2133 | u8 tune_failed = 0; | 2139 | u8 tune_failed = 0; |
2134 | 2140 | ||
2135 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2141 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2136 | dib8000_set_bandwidth(state->fe[index_frontend], fe->dtv_property_cache.bandwidth_hz / 1000); | 2142 | dib8000_set_bandwidth(state->fe[index_frontend], fe->dtv_property_cache.bandwidth_hz / 1000); |
2137 | dib8000_autosearch_start(state->fe[index_frontend]); | 2143 | dib8000_autosearch_start(state->fe[index_frontend]); |
2138 | } | 2144 | } |
2139 | 2145 | ||
2140 | do { | 2146 | do { |
2141 | msleep(10); | 2147 | msleep(20); |
2142 | nbr_pending = 0; | 2148 | nbr_pending = 0; |
2143 | exit_condition = 0; /* 0: tune pending; 1: tune failed; 2:tune success */ | 2149 | exit_condition = 0; /* 0: tune pending; 1: tune failed; 2:tune success */ |
2144 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2150 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2145 | if (((tune_failed >> index_frontend) & 0x1) == 0) { | 2151 | if (((tune_failed >> index_frontend) & 0x1) == 0) { |
2146 | found = dib8000_autosearch_irq(state->fe[index_frontend]); | 2152 | found = dib8000_autosearch_irq(state->fe[index_frontend]); |
2147 | switch (found) { | 2153 | switch (found) { |
2148 | case 0: /* tune pending */ | 2154 | case 0: /* tune pending */ |
2149 | nbr_pending++; | 2155 | nbr_pending++; |
2150 | break; | 2156 | break; |
2151 | case 2: | 2157 | case 2: |
2152 | dprintk("autosearch succeed on the frontend%i", index_frontend); | 2158 | dprintk("autosearch succeed on the frontend%i", index_frontend); |
2153 | exit_condition = 2; | 2159 | exit_condition = 2; |
2154 | index_frontend_success = index_frontend; | 2160 | index_frontend_success = index_frontend; |
2155 | break; | 2161 | break; |
2156 | default: | 2162 | default: |
2157 | dprintk("unhandled autosearch result"); | 2163 | dprintk("unhandled autosearch result"); |
2158 | case 1: | 2164 | case 1: |
2159 | tune_failed |= (1 << index_frontend); | ||
2160 | dprintk("autosearch failed for the frontend%i", index_frontend); | 2165 | dprintk("autosearch failed for the frontend%i", index_frontend); |
2161 | break; | 2166 | break; |
2162 | } | 2167 | } |
@@ -2178,13 +2183,12 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2178 | dib8000_get_frontend(fe, fep); | 2183 | dib8000_get_frontend(fe, fep); |
2179 | } | 2184 | } |
2180 | 2185 | ||
2181 | for (index_frontend=0, ret=0; (ret >= 0) && (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2186 | for (index_frontend = 0, ret = 0; (ret >= 0) && (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2182 | ret = dib8000_tune(state->fe[index_frontend]); | 2187 | ret = dib8000_tune(state->fe[index_frontend]); |
2183 | } | ||
2184 | 2188 | ||
2185 | /* set output mode and diversity input */ | 2189 | /* set output mode and diversity input */ |
2186 | dib8000_set_output_mode(state->fe[0], state->cfg.output_mode); | 2190 | dib8000_set_output_mode(state->fe[0], state->cfg.output_mode); |
2187 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2191 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2188 | dib8000_set_output_mode(state->fe[index_frontend], OUTMODE_DIVERSITY); | 2192 | dib8000_set_output_mode(state->fe[index_frontend], OUTMODE_DIVERSITY); |
2189 | dib8000_set_diversity_in(state->fe[index_frontend-1], 1); | 2193 | dib8000_set_diversity_in(state->fe[index_frontend-1], 1); |
2190 | } | 2194 | } |
@@ -2195,7 +2199,8 @@ static int dib8000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
2195 | return ret; | 2199 | return ret; |
2196 | } | 2200 | } |
2197 | 2201 | ||
2198 | static u16 dib8000_read_lock(struct dvb_frontend *fe) { | 2202 | static u16 dib8000_read_lock(struct dvb_frontend *fe) |
2203 | { | ||
2199 | struct dib8000_state *state = fe->demodulator_priv; | 2204 | struct dib8000_state *state = fe->demodulator_priv; |
2200 | 2205 | ||
2201 | return dib8000_read_word(state, 568); | 2206 | return dib8000_read_word(state, 568); |
@@ -2207,7 +2212,7 @@ static int dib8000_read_status(struct dvb_frontend *fe, fe_status_t * stat) | |||
2207 | u16 lock_slave = 0, lock = dib8000_read_word(state, 568); | 2212 | u16 lock_slave = 0, lock = dib8000_read_word(state, 568); |
2208 | u8 index_frontend; | 2213 | u8 index_frontend; |
2209 | 2214 | ||
2210 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) | 2215 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2211 | lock_slave |= dib8000_read_lock(state->fe[index_frontend]); | 2216 | lock_slave |= dib8000_read_lock(state->fe[index_frontend]); |
2212 | 2217 | ||
2213 | *stat = 0; | 2218 | *stat = 0; |
@@ -2262,7 +2267,7 @@ static int dib8000_read_signal_strength(struct dvb_frontend *fe, u16 * strength) | |||
2262 | u16 val; | 2267 | u16 val; |
2263 | 2268 | ||
2264 | *strength = 0; | 2269 | *strength = 0; |
2265 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2270 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2266 | state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val); | 2271 | state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val); |
2267 | if (val > 65535 - *strength) | 2272 | if (val > 65535 - *strength) |
2268 | *strength = 65535; | 2273 | *strength = 65535; |
@@ -2312,7 +2317,7 @@ static int dib8000_read_snr(struct dvb_frontend *fe, u16 * snr) | |||
2312 | u32 snr_master; | 2317 | u32 snr_master; |
2313 | 2318 | ||
2314 | snr_master = dib8000_get_snr(fe); | 2319 | snr_master = dib8000_get_snr(fe); |
2315 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) | 2320 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2316 | snr_master += dib8000_get_snr(state->fe[index_frontend]); | 2321 | snr_master += dib8000_get_snr(state->fe[index_frontend]); |
2317 | 2322 | ||
2318 | if (snr_master != 0) { | 2323 | if (snr_master != 0) { |
@@ -2361,7 +2366,7 @@ int dib8000_remove_slave_frontend(struct dvb_frontend *fe) | |||
2361 | } | 2366 | } |
2362 | EXPORT_SYMBOL(dib8000_remove_slave_frontend); | 2367 | EXPORT_SYMBOL(dib8000_remove_slave_frontend); |
2363 | 2368 | ||
2364 | struct dvb_frontend * dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) | 2369 | struct dvb_frontend *dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) |
2365 | { | 2370 | { |
2366 | struct dib8000_state *state = fe->demodulator_priv; | 2371 | struct dib8000_state *state = fe->demodulator_priv; |
2367 | 2372 | ||
@@ -2432,7 +2437,7 @@ static void dib8000_release(struct dvb_frontend *fe) | |||
2432 | struct dib8000_state *st = fe->demodulator_priv; | 2437 | struct dib8000_state *st = fe->demodulator_priv; |
2433 | u8 index_frontend; | 2438 | u8 index_frontend; |
2434 | 2439 | ||
2435 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (st->fe[index_frontend] != NULL); index_frontend++) | 2440 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (st->fe[index_frontend] != NULL); index_frontend++) |
2436 | dvb_frontend_detach(st->fe[index_frontend]); | 2441 | dvb_frontend_detach(st->fe[index_frontend]); |
2437 | 2442 | ||
2438 | dibx000_exit_i2c_master(&st->i2c_master); | 2443 | dibx000_exit_i2c_master(&st->i2c_master); |
diff --git a/drivers/media/dvb/frontends/dib8000.h b/drivers/media/dvb/frontends/dib8000.h index 558b7e83c722..617f9eba3a09 100644 --- a/drivers/media/dvb/frontends/dib8000.h +++ b/drivers/media/dvb/frontends/dib8000.h | |||
@@ -52,7 +52,7 @@ extern void dib8000_pwm_agc_reset(struct dvb_frontend *fe); | |||
52 | extern s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode); | 52 | extern s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode); |
53 | extern int dib8000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); | 53 | extern int dib8000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); |
54 | extern int dib8000_remove_slave_frontend(struct dvb_frontend *fe); | 54 | extern int dib8000_remove_slave_frontend(struct dvb_frontend *fe); |
55 | extern struct dvb_frontend * dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index); | 55 | extern struct dvb_frontend *dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index); |
56 | #else | 56 | #else |
57 | static inline struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg) | 57 | static inline struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg) |
58 | { | 58 | { |
@@ -126,9 +126,10 @@ int dib8000_remove_slave_frontend(struct dvb_frontend *fe) | |||
126 | return -ENODEV; | 126 | return -ENODEV; |
127 | } | 127 | } |
128 | 128 | ||
129 | static inline struct dvb_frontend * dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) { | 129 | static inline struct dvb_frontend *dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) |
130 | { | ||
130 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 131 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
131 | return NULL; | 132 | return NULL; |
132 | } | 133 | } |
133 | #endif | 134 | #endif |
134 | 135 | ||
diff --git a/drivers/media/dvb/frontends/dib9000.c b/drivers/media/dvb/frontends/dib9000.c index a41e02dc08ec..43fb6e45424a 100644 --- a/drivers/media/dvb/frontends/dib9000.c +++ b/drivers/media/dvb/frontends/dib9000.c | |||
@@ -31,7 +31,7 @@ struct i2c_device { | |||
31 | 31 | ||
32 | /* lock */ | 32 | /* lock */ |
33 | #define DIB_LOCK struct mutex | 33 | #define DIB_LOCK struct mutex |
34 | #define DibAcquireLock(lock) do { if (mutex_lock_interruptible(lock)<0) dprintk("could not get the lock"); } while (0) | 34 | #define DibAcquireLock(lock) do { if (mutex_lock_interruptible(lock) < 0) dprintk("could not get the lock"); } while (0) |
35 | #define DibReleaseLock(lock) mutex_unlock(lock) | 35 | #define DibReleaseLock(lock) mutex_unlock(lock) |
36 | #define DibInitLock(lock) mutex_init(lock) | 36 | #define DibInitLock(lock) mutex_init(lock) |
37 | #define DibFreeLock(lock) | 37 | #define DibFreeLock(lock) |
@@ -187,8 +187,7 @@ enum dib9000_in_messages { | |||
187 | 187 | ||
188 | #define FE_MM_W_COMPONENT_ACCESS 16 | 188 | #define FE_MM_W_COMPONENT_ACCESS 16 |
189 | #define FE_MM_RW_COMPONENT_ACCESS_BUFFER 17 | 189 | #define FE_MM_RW_COMPONENT_ACCESS_BUFFER 17 |
190 | static int dib9000_risc_apb_access_read(struct dib9000_state *state, u32 address, u16 attribute, const u8 * tx, u32 txlen, | 190 | static int dib9000_risc_apb_access_read(struct dib9000_state *state, u32 address, u16 attribute, const u8 * tx, u32 txlen, u8 * b, u32 len); |
191 | u8 * b, u32 len); | ||
192 | static int dib9000_risc_apb_access_write(struct dib9000_state *state, u32 address, u16 attribute, const u8 * b, u32 len); | 191 | static int dib9000_risc_apb_access_write(struct dib9000_state *state, u32 address, u16 attribute, const u8 * b, u32 len); |
193 | 192 | ||
194 | static u16 to_fw_output_mode(u16 mode) | 193 | static u16 to_fw_output_mode(u16 mode) |
@@ -220,8 +219,8 @@ static u16 dib9000_read16_attr(struct dib9000_state *state, u16 reg, u8 * b, u32 | |||
220 | int ret; | 219 | int ret; |
221 | u8 wb[2] = { reg >> 8, reg & 0xff }; | 220 | u8 wb[2] = { reg >> 8, reg & 0xff }; |
222 | struct i2c_msg msg[2] = { | 221 | struct i2c_msg msg[2] = { |
223 | {.addr = state->i2c.i2c_addr >> 1,.flags = 0,.buf = wb,.len = 2}, | 222 | {.addr = state->i2c.i2c_addr >> 1, .flags = 0, .buf = wb, .len = 2}, |
224 | {.addr = state->i2c.i2c_addr >> 1,.flags = I2C_M_RD,.buf = b,.len = len}, | 223 | {.addr = state->i2c.i2c_addr >> 1, .flags = I2C_M_RD, .buf = b, .len = len}, |
225 | }; | 224 | }; |
226 | 225 | ||
227 | if (state->platform.risc.fw_is_running && (reg < 1024)) | 226 | if (state->platform.risc.fw_is_running && (reg < 1024)) |
@@ -257,8 +256,8 @@ static u16 dib9000_i2c_read16(struct i2c_device *i2c, u16 reg) | |||
257 | u8 b[2]; | 256 | u8 b[2]; |
258 | u8 wb[2] = { reg >> 8, reg & 0xff }; | 257 | u8 wb[2] = { reg >> 8, reg & 0xff }; |
259 | struct i2c_msg msg[2] = { | 258 | struct i2c_msg msg[2] = { |
260 | {.addr = i2c->i2c_addr >> 1,.flags = 0,.buf = wb,.len = 2}, | 259 | {.addr = i2c->i2c_addr >> 1, .flags = 0, .buf = wb, .len = 2}, |
261 | {.addr = i2c->i2c_addr >> 1,.flags = I2C_M_RD,.buf = b,.len = 2}, | 260 | {.addr = i2c->i2c_addr >> 1, .flags = I2C_M_RD, .buf = b, .len = 2}, |
262 | }; | 261 | }; |
263 | 262 | ||
264 | if (i2c_transfer(i2c->i2c_adap, msg, 2) != 2) { | 263 | if (i2c_transfer(i2c->i2c_adap, msg, 2) != 2) { |
@@ -295,12 +294,12 @@ static u16 dib9000_write16_attr(struct dib9000_state *state, u16 reg, const u8 * | |||
295 | int ret; | 294 | int ret; |
296 | 295 | ||
297 | struct i2c_msg msg = { | 296 | struct i2c_msg msg = { |
298 | .addr = state->i2c.i2c_addr >> 1,.flags = 0,.buf = b,.len = len + 2 | 297 | .addr = state->i2c.i2c_addr >> 1, .flags = 0, .buf = b, .len = len + 2 |
299 | }; | 298 | }; |
300 | 299 | ||
301 | if (state->platform.risc.fw_is_running && (reg < 1024)) { | 300 | if (state->platform.risc.fw_is_running && (reg < 1024)) { |
302 | if (dib9000_risc_apb_access_write | 301 | if (dib9000_risc_apb_access_write |
303 | (state, reg, DATA_BUS_ACCESS_MODE_16BIT | DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT | attribute, buf, len) != 0) | 302 | (state, reg, DATA_BUS_ACCESS_MODE_16BIT | DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT | attribute, buf, len) != 0) |
304 | return -EINVAL; | 303 | return -EINVAL; |
305 | return 0; | 304 | return 0; |
306 | } | 305 | } |
@@ -334,7 +333,7 @@ static int dib9000_i2c_write16(struct i2c_device *i2c, u16 reg, u16 val) | |||
334 | { | 333 | { |
335 | u8 b[4] = { (reg >> 8) & 0xff, reg & 0xff, (val >> 8) & 0xff, val & 0xff }; | 334 | u8 b[4] = { (reg >> 8) & 0xff, reg & 0xff, (val >> 8) & 0xff, val & 0xff }; |
336 | struct i2c_msg msg = { | 335 | struct i2c_msg msg = { |
337 | .addr = i2c->i2c_addr >> 1,.flags = 0,.buf = b,.len = 4 | 336 | .addr = i2c->i2c_addr >> 1, .flags = 0, .buf = b, .len = 4 |
338 | }; | 337 | }; |
339 | 338 | ||
340 | return i2c_transfer(i2c->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; | 339 | return i2c_transfer(i2c->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; |
@@ -369,24 +368,24 @@ static void dib9000_risc_mem_setup_cmd(struct dib9000_state *state, u32 addr, u3 | |||
369 | { | 368 | { |
370 | u8 b[14] = { 0 }; | 369 | u8 b[14] = { 0 }; |
371 | 370 | ||
372 | // dprintk("%d memcmd: %d %d %d\n", state->fe_id, addr, addr+len, len); | 371 | /* dprintk("%d memcmd: %d %d %d\n", state->fe_id, addr, addr+len, len); */ |
373 | // b[0] = 0 << 7; | 372 | /* b[0] = 0 << 7; */ |
374 | b[1] = 1; | 373 | b[1] = 1; |
375 | 374 | ||
376 | // b[2] = 0; // 1057 | 375 | /* b[2] = 0; */ |
377 | // b[3] = 0; | 376 | /* b[3] = 0; */ |
378 | b[4] = (u8) (addr >> 8); // 1058 | 377 | b[4] = (u8) (addr >> 8); |
379 | b[5] = (u8) (addr & 0xff); | 378 | b[5] = (u8) (addr & 0xff); |
380 | 379 | ||
381 | // b[10] = 0; // 1061 | 380 | /* b[10] = 0; */ |
382 | // b[11] = 0; | 381 | /* b[11] = 0; */ |
383 | b[12] = (u8) (addr >> 8); // 1062 | 382 | b[12] = (u8) (addr >> 8); |
384 | b[13] = (u8) (addr & 0xff); | 383 | b[13] = (u8) (addr & 0xff); |
385 | 384 | ||
386 | addr += len; | 385 | addr += len; |
387 | // b[6] = 0; // 1059 | 386 | /* b[6] = 0; */ |
388 | // b[7] = 0; | 387 | /* b[7] = 0; */ |
389 | b[8] = (u8) (addr >> 8); // 1060 | 388 | b[8] = (u8) (addr >> 8); |
390 | b[9] = (u8) (addr & 0xff); | 389 | b[9] = (u8) (addr & 0xff); |
391 | 390 | ||
392 | dib9000_write(state, 1056, b, 14); | 391 | dib9000_write(state, 1056, b, 14); |
@@ -400,7 +399,7 @@ static void dib9000_risc_mem_setup(struct dib9000_state *state, u8 cmd) | |||
400 | struct dib9000_fe_memory_map *m = &state->platform.risc.fe_mm[cmd & 0x7f]; | 399 | struct dib9000_fe_memory_map *m = &state->platform.risc.fe_mm[cmd & 0x7f]; |
401 | /* decide whether we need to "refresh" the memory controller */ | 400 | /* decide whether we need to "refresh" the memory controller */ |
402 | if (state->platform.risc.memcmd == cmd && /* same command */ | 401 | if (state->platform.risc.memcmd == cmd && /* same command */ |
403 | !(cmd & 0x80 && m->size < 67)) /* and we do not want to read something with less than 67 bytes looping - working around a bug in the memory controller */ | 402 | !(cmd & 0x80 && m->size < 67)) /* and we do not want to read something with less than 67 bytes looping - working around a bug in the memory controller */ |
404 | return; | 403 | return; |
405 | dib9000_risc_mem_setup_cmd(state, m->addr, m->size, cmd & 0x80); | 404 | dib9000_risc_mem_setup_cmd(state, m->addr, m->size, cmd & 0x80); |
406 | state->platform.risc.memcmd = cmd; | 405 | state->platform.risc.memcmd = cmd; |
@@ -506,7 +505,7 @@ static int dib9000_mbx_send_attr(struct dib9000_state *state, u8 id, u16 * data, | |||
506 | break; | 505 | break; |
507 | } while (1); | 506 | } while (1); |
508 | 507 | ||
509 | //dprintk( "MBX: size: %d", size); | 508 | /*dprintk( "MBX: size: %d", size); */ |
510 | 509 | ||
511 | if (tmp == 0) { | 510 | if (tmp == 0) { |
512 | ret = -EINVAL; | 511 | ret = -EINVAL; |
@@ -538,7 +537,7 @@ static int dib9000_mbx_send_attr(struct dib9000_state *state, u8 id, u16 * data, | |||
538 | /* update register nb_mes_in_RX */ | 537 | /* update register nb_mes_in_RX */ |
539 | ret = (u8) dib9000_write_word_attr(state, 1043, 1 << 14, attr); | 538 | ret = (u8) dib9000_write_word_attr(state, 1043, 1 << 14, attr); |
540 | 539 | ||
541 | out: | 540 | out: |
542 | DibReleaseLock(&state->platform.risc.mbx_if_lock); | 541 | DibReleaseLock(&state->platform.risc.mbx_if_lock); |
543 | 542 | ||
544 | return ret; | 543 | return ret; |
@@ -625,7 +624,7 @@ static int dib9000_mbx_fetch_to_cache(struct dib9000_state *state, u16 attr) | |||
625 | if (*block == 0) { | 624 | if (*block == 0) { |
626 | size = dib9000_mbx_read(state, block, 1, attr); | 625 | size = dib9000_mbx_read(state, block, 1, attr); |
627 | 626 | ||
628 | // dprintk( "MBX: fetched %04x message to cache", *block); | 627 | /* dprintk( "MBX: fetched %04x message to cache", *block); */ |
629 | 628 | ||
630 | switch (*block >> 8) { | 629 | switch (*block >> 8) { |
631 | case IN_MSG_DEBUG_BUF: | 630 | case IN_MSG_DEBUG_BUF: |
@@ -671,8 +670,8 @@ static int dib9000_mbx_process(struct dib9000_state *state, u16 attr) | |||
671 | ret = dib9000_mbx_fetch_to_cache(state, attr); | 670 | ret = dib9000_mbx_fetch_to_cache(state, attr); |
672 | 671 | ||
673 | tmp = dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */ | 672 | tmp = dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */ |
674 | // if (tmp) | 673 | /* if (tmp) */ |
675 | // dprintk( "cleared IRQ: %x", tmp); | 674 | /* dprintk( "cleared IRQ: %x", tmp); */ |
676 | DibReleaseLock(&state->platform.risc.mbx_lock); | 675 | DibReleaseLock(&state->platform.risc.mbx_lock); |
677 | 676 | ||
678 | return ret; | 677 | return ret; |
@@ -805,7 +804,8 @@ static u16 dib9000_identify(struct i2c_device *client) | |||
805 | { | 804 | { |
806 | u16 value; | 805 | u16 value; |
807 | 806 | ||
808 | if ((value = dib9000_i2c_read16(client, 896)) != 0x01b3) { | 807 | value = dib9000_i2c_read16(client, 896); |
808 | if (value != 0x01b3) { | ||
809 | dprintk("wrong Vendor ID (0x%x)", value); | 809 | dprintk("wrong Vendor ID (0x%x)", value); |
810 | return 0; | 810 | return 0; |
811 | } | 811 | } |
@@ -916,7 +916,7 @@ static int dib9000_fw_reset(struct dvb_frontend *fe) | |||
916 | { | 916 | { |
917 | struct dib9000_state *state = fe->demodulator_priv; | 917 | struct dib9000_state *state = fe->demodulator_priv; |
918 | 918 | ||
919 | dib9000_write_word(state, 1817, 0x0003); // SRAM read lead in + P_host_rdy_cmos=1 | 919 | dib9000_write_word(state, 1817, 0x0003); |
920 | 920 | ||
921 | dib9000_write_word(state, 1227, 1); | 921 | dib9000_write_word(state, 1227, 1); |
922 | dib9000_write_word(state, 1227, 0); | 922 | dib9000_write_word(state, 1227, 0); |
@@ -961,8 +961,7 @@ static int dib9000_fw_reset(struct dvb_frontend *fe) | |||
961 | return 0; | 961 | return 0; |
962 | } | 962 | } |
963 | 963 | ||
964 | static int dib9000_risc_apb_access_read(struct dib9000_state *state, u32 address, u16 attribute, const u8 * tx, u32 txlen, | 964 | static int dib9000_risc_apb_access_read(struct dib9000_state *state, u32 address, u16 attribute, const u8 * tx, u32 txlen, u8 * b, u32 len) |
965 | u8 * b, u32 len) | ||
966 | { | 965 | { |
967 | u16 mb[10]; | 966 | u16 mb[10]; |
968 | u8 i, s; | 967 | u8 i, s; |
@@ -970,14 +969,14 @@ static int dib9000_risc_apb_access_read(struct dib9000_state *state, u32 address | |||
970 | if (address >= 1024 || !state->platform.risc.fw_is_running) | 969 | if (address >= 1024 || !state->platform.risc.fw_is_running) |
971 | return -EINVAL; | 970 | return -EINVAL; |
972 | 971 | ||
973 | //dprintk( "APB access thru rd fw %d %x", address, attribute); | 972 | /* dprintk( "APB access thru rd fw %d %x", address, attribute); */ |
974 | 973 | ||
975 | mb[0] = (u16) address; | 974 | mb[0] = (u16) address; |
976 | mb[1] = len / 2; | 975 | mb[1] = len / 2; |
977 | dib9000_mbx_send_attr(state, OUT_MSG_BRIDGE_APB_R, mb, 2, attribute); | 976 | dib9000_mbx_send_attr(state, OUT_MSG_BRIDGE_APB_R, mb, 2, attribute); |
978 | switch (dib9000_mbx_get_message_attr(state, IN_MSG_END_BRIDGE_APB_RW, mb, &s, attribute)) { | 977 | switch (dib9000_mbx_get_message_attr(state, IN_MSG_END_BRIDGE_APB_RW, mb, &s, attribute)) { |
979 | case 1: | 978 | case 1: |
980 | s--; // address | 979 | s--; |
981 | for (i = 0; i < s; i++) { | 980 | for (i = 0; i < s; i++) { |
982 | b[i * 2] = (mb[i + 1] >> 8) & 0xff; | 981 | b[i * 2] = (mb[i + 1] >> 8) & 0xff; |
983 | b[i * 2 + 1] = (mb[i + 1]) & 0xff; | 982 | b[i * 2 + 1] = (mb[i + 1]) & 0xff; |
@@ -997,10 +996,10 @@ static int dib9000_risc_apb_access_write(struct dib9000_state *state, u32 addres | |||
997 | if (address >= 1024 || !state->platform.risc.fw_is_running) | 996 | if (address >= 1024 || !state->platform.risc.fw_is_running) |
998 | return -EINVAL; | 997 | return -EINVAL; |
999 | 998 | ||
1000 | //dprintk( "APB access thru wr fw %d %x", address, attribute); | 999 | /* dprintk( "APB access thru wr fw %d %x", address, attribute); */ |
1001 | 1000 | ||
1002 | mb[0] = (unsigned short)address; | 1001 | mb[0] = (unsigned short)address; |
1003 | for (i = 0; i < len && i < 20; i += 2) // 20 bytes max | 1002 | for (i = 0; i < len && i < 20; i += 2) |
1004 | mb[1 + (i / 2)] = (b[i] << 8 | b[i + 1]); | 1003 | mb[1 + (i / 2)] = (b[i] << 8 | b[i + 1]); |
1005 | 1004 | ||
1006 | dib9000_mbx_send_attr(state, OUT_MSG_BRIDGE_APB_W, mb, 1 + len / 2, attribute); | 1005 | dib9000_mbx_send_attr(state, OUT_MSG_BRIDGE_APB_W, mb, 1 + len / 2, attribute); |
@@ -1031,7 +1030,6 @@ static int dib9000_fw_init(struct dib9000_state *state) | |||
1031 | u8 size; | 1030 | u8 size; |
1032 | 1031 | ||
1033 | if (dib9000_fw_boot(state, NULL, 0, state->chip.d9.cfg.microcode_B_fe_buffer, state->chip.d9.cfg.microcode_B_fe_size) != 0) | 1032 | if (dib9000_fw_boot(state, NULL, 0, state->chip.d9.cfg.microcode_B_fe_buffer, state->chip.d9.cfg.microcode_B_fe_size) != 0) |
1034 | //if (dib9000_fw_boot(state, microcode_A_buffer, microcode_A_size, microcode_B_buffer, microcode_B_size) != 0) | ||
1035 | return -EIO; | 1033 | return -EIO; |
1036 | 1034 | ||
1037 | /* initialize the firmware */ | 1035 | /* initialize the firmware */ |
@@ -1062,7 +1060,6 @@ static int dib9000_fw_init(struct dib9000_state *state) | |||
1062 | b[2 + i * 4] = (u16) state->chip.d9.cfg.subband.subband[i].gpio.mask; | 1060 | b[2 + i * 4] = (u16) state->chip.d9.cfg.subband.subband[i].gpio.mask; |
1063 | b[3 + i * 4] = (u16) state->chip.d9.cfg.subband.subband[i].gpio.direction; | 1061 | b[3 + i * 4] = (u16) state->chip.d9.cfg.subband.subband[i].gpio.direction; |
1064 | b[4 + i * 4] = (u16) state->chip.d9.cfg.subband.subband[i].gpio.value; | 1062 | b[4 + i * 4] = (u16) state->chip.d9.cfg.subband.subband[i].gpio.value; |
1065 | //dprintk( "SBS: %d %d %x %x %x\n", i, b[1 + i*4], b[2 + i*4], b[3 + i*4], b[4 + i*4]); | ||
1066 | } | 1063 | } |
1067 | b[1 + i * 4] = 0; /* fe_id */ | 1064 | b[1 + i * 4] = 0; /* fe_id */ |
1068 | if (dib9000_mbx_send(state, OUT_MSG_SUBBAND_SEL, b, 2 + 4 * i) != 0) | 1065 | if (dib9000_mbx_send(state, OUT_MSG_SUBBAND_SEL, b, 2 + 4 * i) != 0) |
@@ -1071,7 +1068,7 @@ static int dib9000_fw_init(struct dib9000_state *state) | |||
1071 | /* 0 - id, 1 - no_of_frontends */ | 1068 | /* 0 - id, 1 - no_of_frontends */ |
1072 | b[0] = (0 << 8) | 1; | 1069 | b[0] = (0 << 8) | 1; |
1073 | /* 0 = i2c-address demod, 0 = tuner */ | 1070 | /* 0 = i2c-address demod, 0 = tuner */ |
1074 | b[1] = (0 << 8) | (0); //st->i2c_addr ) ); | 1071 | b[1] = (0 << 8) | (0); |
1075 | b[2] = (u16) (((state->chip.d9.cfg.xtal_clock_khz * 1000) >> 16) & 0xffff); | 1072 | b[2] = (u16) (((state->chip.d9.cfg.xtal_clock_khz * 1000) >> 16) & 0xffff); |
1076 | b[3] = (u16) (((state->chip.d9.cfg.xtal_clock_khz * 1000)) & 0xffff); | 1073 | b[3] = (u16) (((state->chip.d9.cfg.xtal_clock_khz * 1000)) & 0xffff); |
1077 | b[4] = (u16) ((state->chip.d9.cfg.vcxo_timer >> 16) & 0xffff); | 1074 | b[4] = (u16) ((state->chip.d9.cfg.vcxo_timer >> 16) & 0xffff); |
@@ -1089,14 +1086,14 @@ static int dib9000_fw_init(struct dib9000_state *state) | |||
1089 | return -EIO; | 1086 | return -EIO; |
1090 | 1087 | ||
1091 | if (size > ARRAY_SIZE(b)) { | 1088 | if (size > ARRAY_SIZE(b)) { |
1092 | dprintk("error : firmware returned %dbytes needed but the used buffer has only %dbytes\n Firmware init ABORTED", size, (int)ARRAY_SIZE(b)); | 1089 | dprintk("error : firmware returned %dbytes needed but the used buffer has only %dbytes\n Firmware init ABORTED", size, |
1090 | (int)ARRAY_SIZE(b)); | ||
1093 | return -EINVAL; | 1091 | return -EINVAL; |
1094 | } | 1092 | } |
1095 | 1093 | ||
1096 | for (i = 0; i < size; i += 2) { | 1094 | for (i = 0; i < size; i += 2) { |
1097 | state->platform.risc.fe_mm[i / 2].addr = b[i + 0]; | 1095 | state->platform.risc.fe_mm[i / 2].addr = b[i + 0]; |
1098 | state->platform.risc.fe_mm[i / 2].size = b[i + 1]; | 1096 | state->platform.risc.fe_mm[i / 2].size = b[i + 1]; |
1099 | //dprintk( "MM: %d %d %d", state->platform.risc.fe_mm[i/2].addr, state->platform.risc.fe_mm[i/2].size, ARRAY_SIZE(state->platform.risc.fe_mm)); | ||
1100 | } | 1097 | } |
1101 | 1098 | ||
1102 | return 0; | 1099 | return 0; |
@@ -1150,9 +1147,9 @@ static int dib9000_fw_get_channel(struct dvb_frontend *fe, struct dvb_frontend_p | |||
1150 | ret = -EIO; | 1147 | ret = -EIO; |
1151 | } | 1148 | } |
1152 | 1149 | ||
1153 | dib9000_risc_mem_read(state, FE_MM_R_CHANNEL_UNION, (u8 *) & ch, sizeof(struct dibDVBTChannel)); | 1150 | dib9000_risc_mem_read(state, FE_MM_R_CHANNEL_UNION, (u8 *) &ch, sizeof(struct dibDVBTChannel)); |
1154 | 1151 | ||
1155 | switch (ch.spectrum_inversion&0x7) { | 1152 | switch (ch.spectrum_inversion & 0x7) { |
1156 | case 1: | 1153 | case 1: |
1157 | state->fe[0]->dtv_property_cache.inversion = INVERSION_ON; | 1154 | state->fe[0]->dtv_property_cache.inversion = INVERSION_ON; |
1158 | break; | 1155 | break; |
@@ -1267,7 +1264,7 @@ static int dib9000_fw_get_channel(struct dvb_frontend *fe, struct dvb_frontend_p | |||
1267 | break; | 1264 | break; |
1268 | } | 1265 | } |
1269 | 1266 | ||
1270 | error: | 1267 | error: |
1271 | DibReleaseLock(&state->platform.risc.mem_mbx_lock); | 1268 | DibReleaseLock(&state->platform.risc.mem_mbx_lock); |
1272 | return ret; | 1269 | return ret; |
1273 | } | 1270 | } |
@@ -1412,7 +1409,7 @@ static int dib9000_fw_set_channel_union(struct dvb_frontend *fe, struct dvb_fron | |||
1412 | ch.select_hp = 1; | 1409 | ch.select_hp = 1; |
1413 | ch.intlv_native = 1; | 1410 | ch.intlv_native = 1; |
1414 | 1411 | ||
1415 | dib9000_risc_mem_write(state, FE_MM_W_CHANNEL_UNION, (u8 *) & ch); | 1412 | dib9000_risc_mem_write(state, FE_MM_W_CHANNEL_UNION, (u8 *) &ch); |
1416 | 1413 | ||
1417 | return 0; | 1414 | return 0; |
1418 | } | 1415 | } |
@@ -1441,9 +1438,9 @@ static int dib9000_fw_tune(struct dvb_frontend *fe, struct dvb_frontend_paramete | |||
1441 | break; | 1438 | break; |
1442 | case CT_DEMOD_STEP_1: | 1439 | case CT_DEMOD_STEP_1: |
1443 | if (search) | 1440 | if (search) |
1444 | dib9000_risc_mem_read(state, FE_MM_R_CHANNEL_SEARCH_STATE, (u8 *) & i, 1); | 1441 | dib9000_risc_mem_read(state, FE_MM_R_CHANNEL_SEARCH_STATE, (u8 *) &i, 1); |
1445 | else | 1442 | else |
1446 | dib9000_risc_mem_read(state, FE_MM_R_CHANNEL_TUNE_STATE, (u8 *) & i, 1); | 1443 | dib9000_risc_mem_read(state, FE_MM_R_CHANNEL_TUNE_STATE, (u8 *) &i, 1); |
1447 | switch (i) { /* something happened */ | 1444 | switch (i) { /* something happened */ |
1448 | case 0: | 1445 | case 0: |
1449 | break; | 1446 | break; |
@@ -1484,22 +1481,22 @@ static int dib9000_fw_set_output_mode(struct dvb_frontend *fe, int mode) | |||
1484 | dprintk("setting output mode for demod %p to %d", fe, mode); | 1481 | dprintk("setting output mode for demod %p to %d", fe, mode); |
1485 | 1482 | ||
1486 | switch (mode) { | 1483 | switch (mode) { |
1487 | case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock | 1484 | case OUTMODE_MPEG2_PAR_GATED_CLK: |
1488 | outreg = (1 << 10); /* 0x0400 */ | 1485 | outreg = (1 << 10); /* 0x0400 */ |
1489 | break; | 1486 | break; |
1490 | case OUTMODE_MPEG2_PAR_CONT_CLK: // STBs with parallel continues clock | 1487 | case OUTMODE_MPEG2_PAR_CONT_CLK: |
1491 | outreg = (1 << 10) | (1 << 6); /* 0x0440 */ | 1488 | outreg = (1 << 10) | (1 << 6); /* 0x0440 */ |
1492 | break; | 1489 | break; |
1493 | case OUTMODE_MPEG2_SERIAL: // STBs with serial input | 1490 | case OUTMODE_MPEG2_SERIAL: |
1494 | outreg = (1 << 10) | (2 << 6) | (0 << 1); /* 0x0482 */ | 1491 | outreg = (1 << 10) | (2 << 6) | (0 << 1); /* 0x0482 */ |
1495 | break; | 1492 | break; |
1496 | case OUTMODE_DIVERSITY: | 1493 | case OUTMODE_DIVERSITY: |
1497 | outreg = (1 << 10) | (4 << 6); /* 0x0500 */ | 1494 | outreg = (1 << 10) | (4 << 6); /* 0x0500 */ |
1498 | break; | 1495 | break; |
1499 | case OUTMODE_MPEG2_FIFO: // e.g. USB feeding | 1496 | case OUTMODE_MPEG2_FIFO: |
1500 | outreg = (1 << 10) | (5 << 6); | 1497 | outreg = (1 << 10) | (5 << 6); |
1501 | break; | 1498 | break; |
1502 | case OUTMODE_HIGH_Z: // disable | 1499 | case OUTMODE_HIGH_Z: |
1503 | outreg = 0; | 1500 | outreg = 0; |
1504 | break; | 1501 | break; |
1505 | default: | 1502 | default: |
@@ -1507,7 +1504,7 @@ static int dib9000_fw_set_output_mode(struct dvb_frontend *fe, int mode) | |||
1507 | return -EINVAL; | 1504 | return -EINVAL; |
1508 | } | 1505 | } |
1509 | 1506 | ||
1510 | dib9000_write_word(state, 1795, outreg); // has to be written from outside | 1507 | dib9000_write_word(state, 1795, outreg); |
1511 | 1508 | ||
1512 | switch (mode) { | 1509 | switch (mode) { |
1513 | case OUTMODE_MPEG2_PAR_GATED_CLK: | 1510 | case OUTMODE_MPEG2_PAR_GATED_CLK: |
@@ -1596,10 +1593,9 @@ EXPORT_SYMBOL(dib9000_fw_set_component_bus_speed); | |||
1596 | static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num) | 1593 | static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num) |
1597 | { | 1594 | { |
1598 | struct dib9000_state *state = i2c_get_adapdata(i2c_adap); | 1595 | struct dib9000_state *state = i2c_get_adapdata(i2c_adap); |
1599 | u8 type = 0; /* I2C */ | 1596 | u8 type = 0; /* I2C */ |
1600 | u8 port = DIBX000_I2C_INTERFACE_GPIO_3_4; | 1597 | u8 port = DIBX000_I2C_INTERFACE_GPIO_3_4; |
1601 | u16 scl = state->component_bus_speed; /* SCL frequency */ | 1598 | u16 scl = state->component_bus_speed; /* SCL frequency */ |
1602 | //u16 scl = 208; /* SCL frequency */ | ||
1603 | struct dib9000_fe_memory_map *m = &state->platform.risc.fe_mm[FE_MM_RW_COMPONENT_ACCESS_BUFFER]; | 1599 | struct dib9000_fe_memory_map *m = &state->platform.risc.fe_mm[FE_MM_RW_COMPONENT_ACCESS_BUFFER]; |
1604 | u8 p[13] = { 0 }; | 1600 | u8 p[13] = { 0 }; |
1605 | 1601 | ||
@@ -1610,11 +1606,6 @@ static int dib9000_fw_component_bus_xfer(struct i2c_adapter *i2c_adap, struct i2 | |||
1610 | p[3] = (u8) scl & 0xff; /* scl */ | 1606 | p[3] = (u8) scl & 0xff; /* scl */ |
1611 | p[4] = (u8) (scl >> 8); | 1607 | p[4] = (u8) (scl >> 8); |
1612 | 1608 | ||
1613 | // p[5] = 0; /* attr */ | ||
1614 | // p[6] = 0; | ||
1615 | |||
1616 | // p[7] = (u8) (msg[0].addr << 1 ); | ||
1617 | // p[8] = (u8) (msg[0].addr >> 7 ); | ||
1618 | p[7] = 0; | 1609 | p[7] = 0; |
1619 | p[8] = 0; | 1610 | p[8] = 0; |
1620 | 1611 | ||
@@ -1672,7 +1663,6 @@ struct i2c_adapter *dib9000_get_tuner_interface(struct dvb_frontend *fe) | |||
1672 | struct dib9000_state *st = fe->demodulator_priv; | 1663 | struct dib9000_state *st = fe->demodulator_priv; |
1673 | return &st->tuner_adap; | 1664 | return &st->tuner_adap; |
1674 | } | 1665 | } |
1675 | |||
1676 | EXPORT_SYMBOL(dib9000_get_tuner_interface); | 1666 | EXPORT_SYMBOL(dib9000_get_tuner_interface); |
1677 | 1667 | ||
1678 | struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe) | 1668 | struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe) |
@@ -1680,7 +1670,6 @@ struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe) | |||
1680 | struct dib9000_state *st = fe->demodulator_priv; | 1670 | struct dib9000_state *st = fe->demodulator_priv; |
1681 | return &st->component_bus; | 1671 | return &st->component_bus; |
1682 | } | 1672 | } |
1683 | |||
1684 | EXPORT_SYMBOL(dib9000_get_component_bus_interface); | 1673 | EXPORT_SYMBOL(dib9000_get_component_bus_interface); |
1685 | 1674 | ||
1686 | struct i2c_adapter *dib9000_get_i2c_master(struct dvb_frontend *fe, enum dibx000_i2c_interface intf, int gating) | 1675 | struct i2c_adapter *dib9000_get_i2c_master(struct dvb_frontend *fe, enum dibx000_i2c_interface intf, int gating) |
@@ -1688,7 +1677,6 @@ struct i2c_adapter *dib9000_get_i2c_master(struct dvb_frontend *fe, enum dibx000 | |||
1688 | struct dib9000_state *st = fe->demodulator_priv; | 1677 | struct dib9000_state *st = fe->demodulator_priv; |
1689 | return dibx000_get_i2c_adapter(&st->i2c_master, intf, gating); | 1678 | return dibx000_get_i2c_adapter(&st->i2c_master, intf, gating); |
1690 | } | 1679 | } |
1691 | |||
1692 | EXPORT_SYMBOL(dib9000_get_i2c_master); | 1680 | EXPORT_SYMBOL(dib9000_get_i2c_master); |
1693 | 1681 | ||
1694 | int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c) | 1682 | int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c) |
@@ -1698,7 +1686,6 @@ int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c) | |||
1698 | st->i2c.i2c_adap = i2c; | 1686 | st->i2c.i2c_adap = i2c; |
1699 | return 0; | 1687 | return 0; |
1700 | } | 1688 | } |
1701 | |||
1702 | EXPORT_SYMBOL(dib9000_set_i2c_adapter); | 1689 | EXPORT_SYMBOL(dib9000_set_i2c_adapter); |
1703 | 1690 | ||
1704 | static int dib9000_cfg_gpio(struct dib9000_state *st, u8 num, u8 dir, u8 val) | 1691 | static int dib9000_cfg_gpio(struct dib9000_state *st, u8 num, u8 dir, u8 val) |
@@ -1723,8 +1710,8 @@ int dib9000_set_gpio(struct dvb_frontend *fe, u8 num, u8 dir, u8 val) | |||
1723 | struct dib9000_state *state = fe->demodulator_priv; | 1710 | struct dib9000_state *state = fe->demodulator_priv; |
1724 | return dib9000_cfg_gpio(state, num, dir, val); | 1711 | return dib9000_cfg_gpio(state, num, dir, val); |
1725 | } | 1712 | } |
1726 | |||
1727 | EXPORT_SYMBOL(dib9000_set_gpio); | 1713 | EXPORT_SYMBOL(dib9000_set_gpio); |
1714 | |||
1728 | int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff) | 1715 | int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff) |
1729 | { | 1716 | { |
1730 | struct dib9000_state *state = fe->demodulator_priv; | 1717 | struct dib9000_state *state = fe->demodulator_priv; |
@@ -1734,15 +1721,14 @@ int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff) | |||
1734 | dprintk("PID filter enabled %d", onoff); | 1721 | dprintk("PID filter enabled %d", onoff); |
1735 | return dib9000_write_word(state, 294 + 1, val); | 1722 | return dib9000_write_word(state, 294 + 1, val); |
1736 | } | 1723 | } |
1737 | |||
1738 | EXPORT_SYMBOL(dib9000_fw_pid_filter_ctrl); | 1724 | EXPORT_SYMBOL(dib9000_fw_pid_filter_ctrl); |
1725 | |||
1739 | int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff) | 1726 | int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff) |
1740 | { | 1727 | { |
1741 | struct dib9000_state *state = fe->demodulator_priv; | 1728 | struct dib9000_state *state = fe->demodulator_priv; |
1742 | dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff); | 1729 | dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff); |
1743 | return dib9000_write_word(state, 300 + 1 + id, onoff ? (1 << 13) | pid : 0); | 1730 | return dib9000_write_word(state, 300 + 1 + id, onoff ? (1 << 13) | pid : 0); |
1744 | } | 1731 | } |
1745 | |||
1746 | EXPORT_SYMBOL(dib9000_fw_pid_filter); | 1732 | EXPORT_SYMBOL(dib9000_fw_pid_filter); |
1747 | 1733 | ||
1748 | int dib9000_firmware_post_pll_init(struct dvb_frontend *fe) | 1734 | int dib9000_firmware_post_pll_init(struct dvb_frontend *fe) |
@@ -1750,7 +1736,6 @@ int dib9000_firmware_post_pll_init(struct dvb_frontend *fe) | |||
1750 | struct dib9000_state *state = fe->demodulator_priv; | 1736 | struct dib9000_state *state = fe->demodulator_priv; |
1751 | return dib9000_fw_init(state); | 1737 | return dib9000_fw_init(state); |
1752 | } | 1738 | } |
1753 | |||
1754 | EXPORT_SYMBOL(dib9000_firmware_post_pll_init); | 1739 | EXPORT_SYMBOL(dib9000_firmware_post_pll_init); |
1755 | 1740 | ||
1756 | static void dib9000_release(struct dvb_frontend *demod) | 1741 | static void dib9000_release(struct dvb_frontend *demod) |
@@ -1758,7 +1743,7 @@ static void dib9000_release(struct dvb_frontend *demod) | |||
1758 | struct dib9000_state *st = demod->demodulator_priv; | 1743 | struct dib9000_state *st = demod->demodulator_priv; |
1759 | u8 index_frontend; | 1744 | u8 index_frontend; |
1760 | 1745 | ||
1761 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (st->fe[index_frontend] != NULL); index_frontend++) | 1746 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (st->fe[index_frontend] != NULL); index_frontend++) |
1762 | dvb_frontend_detach(st->fe[index_frontend]); | 1747 | dvb_frontend_detach(st->fe[index_frontend]); |
1763 | 1748 | ||
1764 | DibFreeLock(&state->platform.risc.mbx_if_lock); | 1749 | DibFreeLock(&state->platform.risc.mbx_if_lock); |
@@ -1784,7 +1769,7 @@ static int dib9000_sleep(struct dvb_frontend *fe) | |||
1784 | u8 index_frontend; | 1769 | u8 index_frontend; |
1785 | int ret; | 1770 | int ret; |
1786 | 1771 | ||
1787 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1772 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1788 | ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]); | 1773 | ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]); |
1789 | if (ret < 0) | 1774 | if (ret < 0) |
1790 | return ret; | 1775 | return ret; |
@@ -1805,23 +1790,32 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1805 | fe_status_t stat; | 1790 | fe_status_t stat; |
1806 | int ret; | 1791 | int ret; |
1807 | 1792 | ||
1808 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1793 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1809 | state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); | 1794 | state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat); |
1810 | if (stat & FE_HAS_SYNC) { | 1795 | if (stat & FE_HAS_SYNC) { |
1811 | dprintk("TPS lock on the slave%i", index_frontend); | 1796 | dprintk("TPS lock on the slave%i", index_frontend); |
1812 | 1797 | ||
1813 | /* synchronize the cache with the other frontends */ | 1798 | /* synchronize the cache with the other frontends */ |
1814 | state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], fep); | 1799 | state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], fep); |
1815 | for (sub_index_frontend=0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) { | 1800 | for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); |
1801 | sub_index_frontend++) { | ||
1816 | if (sub_index_frontend != index_frontend) { | 1802 | if (sub_index_frontend != index_frontend) { |
1817 | state->fe[sub_index_frontend]->dtv_property_cache.modulation = state->fe[index_frontend]->dtv_property_cache.modulation; | 1803 | state->fe[sub_index_frontend]->dtv_property_cache.modulation = |
1818 | state->fe[sub_index_frontend]->dtv_property_cache.inversion = state->fe[index_frontend]->dtv_property_cache.inversion; | 1804 | state->fe[index_frontend]->dtv_property_cache.modulation; |
1819 | state->fe[sub_index_frontend]->dtv_property_cache.transmission_mode = state->fe[index_frontend]->dtv_property_cache.transmission_mode; | 1805 | state->fe[sub_index_frontend]->dtv_property_cache.inversion = |
1820 | state->fe[sub_index_frontend]->dtv_property_cache.guard_interval = state->fe[index_frontend]->dtv_property_cache.guard_interval; | 1806 | state->fe[index_frontend]->dtv_property_cache.inversion; |
1821 | state->fe[sub_index_frontend]->dtv_property_cache.hierarchy = state->fe[index_frontend]->dtv_property_cache.hierarchy; | 1807 | state->fe[sub_index_frontend]->dtv_property_cache.transmission_mode = |
1822 | state->fe[sub_index_frontend]->dtv_property_cache.code_rate_HP = state->fe[index_frontend]->dtv_property_cache.code_rate_HP; | 1808 | state->fe[index_frontend]->dtv_property_cache.transmission_mode; |
1823 | state->fe[sub_index_frontend]->dtv_property_cache.code_rate_LP = state->fe[index_frontend]->dtv_property_cache.code_rate_LP; | 1809 | state->fe[sub_index_frontend]->dtv_property_cache.guard_interval = |
1824 | state->fe[sub_index_frontend]->dtv_property_cache.rolloff = state->fe[index_frontend]->dtv_property_cache.rolloff; | 1810 | state->fe[index_frontend]->dtv_property_cache.guard_interval; |
1811 | state->fe[sub_index_frontend]->dtv_property_cache.hierarchy = | ||
1812 | state->fe[index_frontend]->dtv_property_cache.hierarchy; | ||
1813 | state->fe[sub_index_frontend]->dtv_property_cache.code_rate_HP = | ||
1814 | state->fe[index_frontend]->dtv_property_cache.code_rate_HP; | ||
1815 | state->fe[sub_index_frontend]->dtv_property_cache.code_rate_LP = | ||
1816 | state->fe[index_frontend]->dtv_property_cache.code_rate_LP; | ||
1817 | state->fe[sub_index_frontend]->dtv_property_cache.rolloff = | ||
1818 | state->fe[index_frontend]->dtv_property_cache.rolloff; | ||
1825 | } | 1819 | } |
1826 | } | 1820 | } |
1827 | return 0; | 1821 | return 0; |
@@ -1834,7 +1828,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1834 | return ret; | 1828 | return ret; |
1835 | 1829 | ||
1836 | /* synchronize the cache with the other frontends */ | 1830 | /* synchronize the cache with the other frontends */ |
1837 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1831 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1838 | state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion; | 1832 | state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion; |
1839 | state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode; | 1833 | state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode; |
1840 | state->fe[index_frontend]->dtv_property_cache.guard_interval = fe->dtv_property_cache.guard_interval; | 1834 | state->fe[index_frontend]->dtv_property_cache.guard_interval = fe->dtv_property_cache.guard_interval; |
@@ -1894,14 +1888,14 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1894 | 1888 | ||
1895 | /* set the master status */ | 1889 | /* set the master status */ |
1896 | if (fep->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO || | 1890 | if (fep->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO || |
1897 | fep->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO || fep->u.ofdm.constellation == QAM_AUTO || fep->u.ofdm.code_rate_HP == FEC_AUTO) { | 1891 | fep->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO || fep->u.ofdm.constellation == QAM_AUTO || fep->u.ofdm.code_rate_HP == FEC_AUTO) { |
1898 | /* no channel specified, autosearch the channel */ | 1892 | /* no channel specified, autosearch the channel */ |
1899 | state->channel_status.status = CHANNEL_STATUS_PARAMETERS_UNKNOWN; | 1893 | state->channel_status.status = CHANNEL_STATUS_PARAMETERS_UNKNOWN; |
1900 | } else | 1894 | } else |
1901 | state->channel_status.status = CHANNEL_STATUS_PARAMETERS_SET; | 1895 | state->channel_status.status = CHANNEL_STATUS_PARAMETERS_SET; |
1902 | 1896 | ||
1903 | /* set mode and status for the different frontends */ | 1897 | /* set mode and status for the different frontends */ |
1904 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1898 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1905 | dib9000_fw_set_diversity_in(state->fe[index_frontend], 1); | 1899 | dib9000_fw_set_diversity_in(state->fe[index_frontend], 1); |
1906 | 1900 | ||
1907 | /* synchronization of the cache */ | 1901 | /* synchronization of the cache */ |
@@ -1915,11 +1909,11 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1915 | } | 1909 | } |
1916 | 1910 | ||
1917 | /* actual tune */ | 1911 | /* actual tune */ |
1918 | exit_condition = 0; /* 0: tune pending; 1: tune failed; 2:tune success */ | 1912 | exit_condition = 0; /* 0: tune pending; 1: tune failed; 2:tune success */ |
1919 | index_frontend_success = 0; | 1913 | index_frontend_success = 0; |
1920 | do { | 1914 | do { |
1921 | sleep_time = dib9000_fw_tune(state->fe[0], NULL); | 1915 | sleep_time = dib9000_fw_tune(state->fe[0], NULL); |
1922 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1916 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1923 | sleep_time_slave = dib9000_fw_tune(state->fe[index_frontend], NULL); | 1917 | sleep_time_slave = dib9000_fw_tune(state->fe[index_frontend], NULL); |
1924 | if (sleep_time == FE_CALLBACK_TIME_NEVER) | 1918 | if (sleep_time == FE_CALLBACK_TIME_NEVER) |
1925 | sleep_time = sleep_time_slave; | 1919 | sleep_time = sleep_time_slave; |
@@ -1934,23 +1928,23 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1934 | nbr_pending = 0; | 1928 | nbr_pending = 0; |
1935 | exit_condition = 0; | 1929 | exit_condition = 0; |
1936 | index_frontend_success = 0; | 1930 | index_frontend_success = 0; |
1937 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1931 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1938 | frontend_status = -dib9000_get_status(state->fe[index_frontend]); | 1932 | frontend_status = -dib9000_get_status(state->fe[index_frontend]); |
1939 | if (frontend_status > -FE_STATUS_TUNE_PENDING) { | 1933 | if (frontend_status > -FE_STATUS_TUNE_PENDING) { |
1940 | exit_condition = 2; /* tune success */ | 1934 | exit_condition = 2; /* tune success */ |
1941 | index_frontend_success = index_frontend; | 1935 | index_frontend_success = index_frontend; |
1942 | break; | 1936 | break; |
1943 | } | 1937 | } |
1944 | if (frontend_status == -FE_STATUS_TUNE_PENDING) | 1938 | if (frontend_status == -FE_STATUS_TUNE_PENDING) |
1945 | nbr_pending++; /* some frontends are still tuning */ | 1939 | nbr_pending++; /* some frontends are still tuning */ |
1946 | } | 1940 | } |
1947 | if ((exit_condition != 2) && (nbr_pending == 0)) | 1941 | if ((exit_condition != 2) && (nbr_pending == 0)) |
1948 | exit_condition = 1; /* if all tune are done and no success, exit: tune failed */ | 1942 | exit_condition = 1; /* if all tune are done and no success, exit: tune failed */ |
1949 | 1943 | ||
1950 | } while (exit_condition == 0); | 1944 | } while (exit_condition == 0); |
1951 | 1945 | ||
1952 | /* check the tune result */ | 1946 | /* check the tune result */ |
1953 | if (exit_condition == 1) { /* tune failed */ | 1947 | if (exit_condition == 1) { /* tune failed */ |
1954 | dprintk("tune failed"); | 1948 | dprintk("tune failed"); |
1955 | return 0; | 1949 | return 0; |
1956 | } | 1950 | } |
@@ -1962,7 +1956,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1962 | 1956 | ||
1963 | /* retune the other frontends with the found channel */ | 1957 | /* retune the other frontends with the found channel */ |
1964 | channel_status.status = CHANNEL_STATUS_PARAMETERS_SET; | 1958 | channel_status.status = CHANNEL_STATUS_PARAMETERS_SET; |
1965 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1959 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1966 | /* only retune the frontends which was not tuned success */ | 1960 | /* only retune the frontends which was not tuned success */ |
1967 | if (index_frontend != index_frontend_success) { | 1961 | if (index_frontend != index_frontend_success) { |
1968 | dib9000_set_channel_status(state->fe[index_frontend], &channel_status); | 1962 | dib9000_set_channel_status(state->fe[index_frontend], &channel_status); |
@@ -1971,7 +1965,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1971 | } | 1965 | } |
1972 | do { | 1966 | do { |
1973 | sleep_time = FE_CALLBACK_TIME_NEVER; | 1967 | sleep_time = FE_CALLBACK_TIME_NEVER; |
1974 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1968 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1975 | if (index_frontend != index_frontend_success) { | 1969 | if (index_frontend != index_frontend_success) { |
1976 | sleep_time_slave = dib9000_fw_tune(state->fe[index_frontend], NULL); | 1970 | sleep_time_slave = dib9000_fw_tune(state->fe[index_frontend], NULL); |
1977 | if (sleep_time == FE_CALLBACK_TIME_NEVER) | 1971 | if (sleep_time == FE_CALLBACK_TIME_NEVER) |
@@ -1986,22 +1980,22 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
1986 | break; | 1980 | break; |
1987 | 1981 | ||
1988 | nbr_pending = 0; | 1982 | nbr_pending = 0; |
1989 | for (index_frontend=0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 1983 | for (index_frontend = 0; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
1990 | if (index_frontend != index_frontend_success) { | 1984 | if (index_frontend != index_frontend_success) { |
1991 | frontend_status = -dib9000_get_status(state->fe[index_frontend]); | 1985 | frontend_status = -dib9000_get_status(state->fe[index_frontend]); |
1992 | if ((index_frontend != index_frontend_success) && (frontend_status == -FE_STATUS_TUNE_PENDING)) | 1986 | if ((index_frontend != index_frontend_success) && (frontend_status == -FE_STATUS_TUNE_PENDING)) |
1993 | nbr_pending++; /* some frontends are still tuning */ | 1987 | nbr_pending++; /* some frontends are still tuning */ |
1994 | } | 1988 | } |
1995 | } | 1989 | } |
1996 | } while (nbr_pending != 0); | 1990 | } while (nbr_pending != 0); |
1997 | 1991 | ||
1998 | /* set the output mode */ | 1992 | /* set the output mode */ |
1999 | dib9000_fw_set_output_mode(state->fe[0], state->chip.d9.cfg.output_mode); | 1993 | dib9000_fw_set_output_mode(state->fe[0], state->chip.d9.cfg.output_mode); |
2000 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) | 1994 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2001 | dib9000_fw_set_output_mode(state->fe[index_frontend], OUTMODE_DIVERSITY); | 1995 | dib9000_fw_set_output_mode(state->fe[index_frontend], OUTMODE_DIVERSITY); |
2002 | 1996 | ||
2003 | /* turn off the diversity for the last frontend */ | 1997 | /* turn off the diversity for the last frontend */ |
2004 | dib9000_fw_set_diversity_in(state->fe[index_frontend-1], 0); | 1998 | dib9000_fw_set_diversity_in(state->fe[index_frontend - 1], 0); |
2005 | 1999 | ||
2006 | return 0; | 2000 | return 0; |
2007 | } | 2001 | } |
@@ -2019,7 +2013,7 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat) | |||
2019 | u8 index_frontend; | 2013 | u8 index_frontend; |
2020 | u16 lock = 0, lock_slave = 0; | 2014 | u16 lock = 0, lock_slave = 0; |
2021 | 2015 | ||
2022 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) | 2016 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2023 | lock_slave |= dib9000_read_lock(state->fe[index_frontend]); | 2017 | lock_slave |= dib9000_read_lock(state->fe[index_frontend]); |
2024 | 2018 | ||
2025 | lock = dib9000_read_word(state, 535); | 2019 | lock = dib9000_read_word(state, 535); |
@@ -2063,7 +2057,7 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength) | |||
2063 | u16 val; | 2057 | u16 val; |
2064 | 2058 | ||
2065 | *strength = 0; | 2059 | *strength = 0; |
2066 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { | 2060 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) { |
2067 | state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val); | 2061 | state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val); |
2068 | if (val > 65535 - *strength) | 2062 | if (val > 65535 - *strength) |
2069 | *strength = 65535; | 2063 | *strength = 65535; |
@@ -2127,7 +2121,7 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr) | |||
2127 | u32 snr_master; | 2121 | u32 snr_master; |
2128 | 2122 | ||
2129 | snr_master = dib9000_get_snr(fe); | 2123 | snr_master = dib9000_get_snr(fe); |
2130 | for (index_frontend=1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) | 2124 | for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) |
2131 | snr_master += dib9000_get_snr(state->fe[index_frontend]); | 2125 | snr_master += dib9000_get_snr(state->fe[index_frontend]); |
2132 | 2126 | ||
2133 | if ((snr_master >> 16) != 0) { | 2127 | if ((snr_master >> 16) != 0) { |
@@ -2161,7 +2155,7 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul | |||
2161 | struct i2c_device client = {.i2c_adap = i2c }; | 2155 | struct i2c_device client = {.i2c_adap = i2c }; |
2162 | 2156 | ||
2163 | client.i2c_addr = default_addr + 16; | 2157 | client.i2c_addr = default_addr + 16; |
2164 | dib9000_i2c_write16(&client, 1796, 0x0); // select DVB-T output | 2158 | dib9000_i2c_write16(&client, 1796, 0x0); |
2165 | 2159 | ||
2166 | for (k = no_of_demods - 1; k >= 0; k--) { | 2160 | for (k = no_of_demods - 1; k >= 0; k--) { |
2167 | /* designated i2c address */ | 2161 | /* designated i2c address */ |
@@ -2203,7 +2197,6 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul | |||
2203 | 2197 | ||
2204 | return 0; | 2198 | return 0; |
2205 | } | 2199 | } |
2206 | |||
2207 | EXPORT_SYMBOL(dib9000_i2c_enumeration); | 2200 | EXPORT_SYMBOL(dib9000_i2c_enumeration); |
2208 | 2201 | ||
2209 | int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave) | 2202 | int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave) |
@@ -2232,7 +2225,7 @@ int dib9000_remove_slave_frontend(struct dvb_frontend *fe) | |||
2232 | while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) | 2225 | while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL)) |
2233 | index_frontend++; | 2226 | index_frontend++; |
2234 | if (index_frontend != 1) { | 2227 | if (index_frontend != 1) { |
2235 | dprintk("remove slave fe %p (index %i)", state->fe[index_frontend-1], index_frontend-1); | 2228 | dprintk("remove slave fe %p (index %i)", state->fe[index_frontend - 1], index_frontend - 1); |
2236 | state->fe[index_frontend] = NULL; | 2229 | state->fe[index_frontend] = NULL; |
2237 | return 0; | 2230 | return 0; |
2238 | } | 2231 | } |
@@ -2242,7 +2235,7 @@ int dib9000_remove_slave_frontend(struct dvb_frontend *fe) | |||
2242 | } | 2235 | } |
2243 | EXPORT_SYMBOL(dib9000_remove_slave_frontend); | 2236 | EXPORT_SYMBOL(dib9000_remove_slave_frontend); |
2244 | 2237 | ||
2245 | struct dvb_frontend * dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) | 2238 | struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) |
2246 | { | 2239 | { |
2247 | struct dib9000_state *state = fe->demodulator_priv; | 2240 | struct dib9000_state *state = fe->demodulator_priv; |
2248 | 2241 | ||
@@ -2313,13 +2306,12 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c | |||
2313 | 2306 | ||
2314 | return fe; | 2307 | return fe; |
2315 | 2308 | ||
2316 | component_bus_add_error: | 2309 | component_bus_add_error: |
2317 | i2c_del_adapter(&st->tuner_adap); | 2310 | i2c_del_adapter(&st->tuner_adap); |
2318 | error: | 2311 | error: |
2319 | kfree(st); | 2312 | kfree(st); |
2320 | return NULL; | 2313 | return NULL; |
2321 | } | 2314 | } |
2322 | |||
2323 | EXPORT_SYMBOL(dib9000_attach); | 2315 | EXPORT_SYMBOL(dib9000_attach); |
2324 | 2316 | ||
2325 | static struct dvb_frontend_ops dib9000_ops = { | 2317 | static struct dvb_frontend_ops dib9000_ops = { |
diff --git a/drivers/media/dvb/frontends/dib9000.h b/drivers/media/dvb/frontends/dib9000.h index 995e4bc48a7d..b5781a48034c 100644 --- a/drivers/media/dvb/frontends/dib9000.h +++ b/drivers/media/dvb/frontends/dib9000.h | |||
@@ -38,7 +38,7 @@ extern int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 ono | |||
38 | extern int dib9000_firmware_post_pll_init(struct dvb_frontend *fe); | 38 | extern int dib9000_firmware_post_pll_init(struct dvb_frontend *fe); |
39 | extern int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); | 39 | extern int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); |
40 | extern int dib9000_remove_slave_frontend(struct dvb_frontend *fe); | 40 | extern int dib9000_remove_slave_frontend(struct dvb_frontend *fe); |
41 | extern struct dvb_frontend * dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index); | 41 | extern struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index); |
42 | extern struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe); | 42 | extern struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe); |
43 | extern int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c); | 43 | extern int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c); |
44 | extern int dib9000_fw_set_component_bus_speed(struct dvb_frontend *fe, u16 speed); | 44 | extern int dib9000_fw_set_component_bus_speed(struct dvb_frontend *fe, u16 speed); |
@@ -103,7 +103,8 @@ int dib9000_remove_slave_frontend(struct dvb_frontend *fe) | |||
103 | return -ENODEV; | 103 | return -ENODEV; |
104 | } | 104 | } |
105 | 105 | ||
106 | static inline struct dvb_frontend * dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) { | 106 | static inline struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) |
107 | { | ||
107 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 108 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
108 | return NULL; | 109 | return NULL; |
109 | } | 110 | } |
diff --git a/drivers/media/dvb/frontends/dibx000_common.c b/drivers/media/dvb/frontends/dibx000_common.c index 9bd95a978a1c..f6938f97feb4 100644 --- a/drivers/media/dvb/frontends/dibx000_common.c +++ b/drivers/media/dvb/frontends/dibx000_common.c | |||
@@ -26,8 +26,8 @@ static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg) | |||
26 | u8 wb[2] = { reg >> 8, reg & 0xff }; | 26 | u8 wb[2] = { reg >> 8, reg & 0xff }; |
27 | u8 rb[2]; | 27 | u8 rb[2]; |
28 | struct i2c_msg msg[2] = { | 28 | struct i2c_msg msg[2] = { |
29 | {.addr = mst->i2c_addr,.flags = 0,.buf = wb,.len = 2}, | 29 | {.addr = mst->i2c_addr, .flags = 0, .buf = wb, .len = 2}, |
30 | {.addr = mst->i2c_addr,.flags = I2C_M_RD,.buf = rb,.len = 2}, | 30 | {.addr = mst->i2c_addr, .flags = I2C_M_RD, .buf = rb, .len = 2}, |
31 | }; | 31 | }; |
32 | 32 | ||
33 | if (i2c_transfer(mst->i2c_adap, msg, 2) != 2) | 33 | if (i2c_transfer(mst->i2c_adap, msg, 2) != 2) |
@@ -38,10 +38,11 @@ static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg) | |||
38 | 38 | ||
39 | static int dibx000_is_i2c_done(struct dibx000_i2c_master *mst) | 39 | static int dibx000_is_i2c_done(struct dibx000_i2c_master *mst) |
40 | { | 40 | { |
41 | int i = 100; // max_i2c_polls; | 41 | int i = 100; |
42 | u16 status; | 42 | u16 status; |
43 | 43 | ||
44 | while (((status = dibx000_read_word(mst, mst->base_reg + 2)) & 0x0100) == 0 && --i > 0); | 44 | while (((status = dibx000_read_word(mst, mst->base_reg + 2)) & 0x0100) == 0 && --i > 0) |
45 | ; | ||
45 | 46 | ||
46 | /* i2c timed out */ | 47 | /* i2c timed out */ |
47 | if (i == 0) | 48 | if (i == 0) |
@@ -63,7 +64,7 @@ static int dibx000_master_i2c_write(struct dibx000_i2c_master *mst, struct i2c_m | |||
63 | const u8 *b = msg->buf; | 64 | const u8 *b = msg->buf; |
64 | 65 | ||
65 | while (txlen) { | 66 | while (txlen) { |
66 | dibx000_read_word(mst, mst->base_reg + 2); // reset fifo ptr | 67 | dibx000_read_word(mst, mst->base_reg + 2); |
67 | 68 | ||
68 | len = txlen > 8 ? 8 : txlen; | 69 | len = txlen > 8 ? 8 : txlen; |
69 | for (i = 0; i < len; i += 2) { | 70 | for (i = 0; i < len; i += 2) { |
@@ -72,14 +73,14 @@ static int dibx000_master_i2c_write(struct dibx000_i2c_master *mst, struct i2c_m | |||
72 | data |= *b++; | 73 | data |= *b++; |
73 | dibx000_write_word(mst, mst->base_reg, data); | 74 | dibx000_write_word(mst, mst->base_reg, data); |
74 | } | 75 | } |
75 | da = (((u8) (msg->addr)) << 9) | // addr | 76 | da = (((u8) (msg->addr)) << 9) | |
76 | (1 << 8) | // master | 77 | (1 << 8) | |
77 | (1 << 7) | // rq | 78 | (1 << 7) | |
78 | (0 << 6) | // stop | 79 | (0 << 6) | |
79 | (0 << 5) | // start | 80 | (0 << 5) | |
80 | ((len & 0x7) << 2) | // nb 8 bytes == 0 here | 81 | ((len & 0x7) << 2) | |
81 | (0 << 1) | // rw | 82 | (0 << 1) | |
82 | (0 << 0); // irqen | 83 | (0 << 0); |
83 | 84 | ||
84 | if (txlen == msg->len) | 85 | if (txlen == msg->len) |
85 | da |= 1 << 5; /* start */ | 86 | da |= 1 << 5; /* start */ |
@@ -105,14 +106,14 @@ static int dibx000_master_i2c_read(struct dibx000_i2c_master *mst, struct i2c_ms | |||
105 | 106 | ||
106 | while (rxlen) { | 107 | while (rxlen) { |
107 | len = rxlen > 8 ? 8 : rxlen; | 108 | len = rxlen > 8 ? 8 : rxlen; |
108 | da = (((u8) (msg->addr)) << 9) | // addr | 109 | da = (((u8) (msg->addr)) << 9) | |
109 | (1 << 8) | // master | 110 | (1 << 8) | |
110 | (1 << 7) | // rq | 111 | (1 << 7) | |
111 | (0 << 6) | // stop | 112 | (0 << 6) | |
112 | (0 << 5) | // start | 113 | (0 << 5) | |
113 | ((len & 0x7) << 2) | // nb | 114 | ((len & 0x7) << 2) | |
114 | (1 << 1) | // rw | 115 | (1 << 1) | |
115 | (0 << 0); // irqen | 116 | (0 << 0); |
116 | 117 | ||
117 | if (rxlen == msg->len) | 118 | if (rxlen == msg->len) |
118 | da |= 1 << 5; /* start */ | 119 | da |= 1 << 5; /* start */ |
@@ -174,15 +175,12 @@ static int dibx000_i2c_master_xfer_gpio12(struct i2c_adapter *i2c_adap, struct i | |||
174 | int ret = 0; | 175 | int ret = 0; |
175 | 176 | ||
176 | dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_1_2); | 177 | dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_1_2); |
177 | for (msg_index = 0; msg_index<num; msg_index++) { | 178 | for (msg_index = 0; msg_index < num; msg_index++) { |
178 | if (msg[msg_index].flags & I2C_M_RD) | 179 | if (msg[msg_index].flags & I2C_M_RD) { |
179 | { | ||
180 | ret = dibx000_master_i2c_read(mst, &msg[msg_index]); | 180 | ret = dibx000_master_i2c_read(mst, &msg[msg_index]); |
181 | if (ret != 0) | 181 | if (ret != 0) |
182 | return 0; | 182 | return 0; |
183 | } | 183 | } else { |
184 | else | ||
185 | { | ||
186 | ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1); | 184 | ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1); |
187 | if (ret != 0) | 185 | if (ret != 0) |
188 | return 0; | 186 | return 0; |
@@ -199,15 +197,12 @@ static int dibx000_i2c_master_xfer_gpio34(struct i2c_adapter *i2c_adap, struct i | |||
199 | int ret = 0; | 197 | int ret = 0; |
200 | 198 | ||
201 | dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_3_4); | 199 | dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_3_4); |
202 | for (msg_index = 0; msg_index<num; msg_index++) { | 200 | for (msg_index = 0; msg_index < num; msg_index++) { |
203 | if (msg[msg_index].flags & I2C_M_RD) | 201 | if (msg[msg_index].flags & I2C_M_RD) { |
204 | { | ||
205 | ret = dibx000_master_i2c_read(mst, &msg[msg_index]); | 202 | ret = dibx000_master_i2c_read(mst, &msg[msg_index]); |
206 | if (ret != 0) | 203 | if (ret != 0) |
207 | return 0; | 204 | return 0; |
208 | } | 205 | } else { |
209 | else | ||
210 | { | ||
211 | ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1); | 206 | ret = dibx000_master_i2c_write(mst, &msg[msg_index], 1); |
212 | if (ret != 0) | 207 | if (ret != 0) |
213 | return 0; | 208 | return 0; |
diff --git a/drivers/media/dvb/frontends/dibx000_common.h b/drivers/media/dvb/frontends/dibx000_common.h index cc0fafe0436d..977d343369aa 100644 --- a/drivers/media/dvb/frontends/dibx000_common.h +++ b/drivers/media/dvb/frontends/dibx000_common.h | |||
@@ -18,7 +18,7 @@ struct dibx000_i2c_master { | |||
18 | 18 | ||
19 | enum dibx000_i2c_interface selected_interface; | 19 | enum dibx000_i2c_interface selected_interface; |
20 | 20 | ||
21 | // struct i2c_adapter tuner_i2c_adap; | 21 | /* struct i2c_adapter tuner_i2c_adap; */ |
22 | struct i2c_adapter gated_tuner_i2c_adap; | 22 | struct i2c_adapter gated_tuner_i2c_adap; |
23 | struct i2c_adapter master_i2c_adap_gpio12; | 23 | struct i2c_adapter master_i2c_adap_gpio12; |
24 | struct i2c_adapter master_i2c_adap_gpio34; | 24 | struct i2c_adapter master_i2c_adap_gpio34; |
@@ -50,7 +50,7 @@ extern u32 systime(void); | |||
50 | #define BAND_FM 0x10 | 50 | #define BAND_FM 0x10 |
51 | #define BAND_CBAND 0x20 | 51 | #define BAND_CBAND 0x20 |
52 | 52 | ||
53 | #define BAND_OF_FREQUENCY(freq_kHz) ( (freq_kHz) <= 170000 ? BAND_CBAND : \ | 53 | #define BAND_OF_FREQUENCY(freq_kHz) ((freq_kHz) <= 170000 ? BAND_CBAND : \ |
54 | (freq_kHz) <= 115000 ? BAND_FM : \ | 54 | (freq_kHz) <= 115000 ? BAND_FM : \ |
55 | (freq_kHz) <= 250000 ? BAND_VHF : \ | 55 | (freq_kHz) <= 250000 ? BAND_VHF : \ |
56 | (freq_kHz) <= 863000 ? BAND_UHF : \ | 56 | (freq_kHz) <= 863000 ? BAND_UHF : \ |
@@ -140,9 +140,9 @@ enum dibx000_adc_states { | |||
140 | DIBX000_VBG_DISABLE, | 140 | DIBX000_VBG_DISABLE, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | #define BANDWIDTH_TO_KHZ(v) ( (v) == BANDWIDTH_8_MHZ ? 8000 : \ | 143 | #define BANDWIDTH_TO_KHZ(v) ((v) == BANDWIDTH_8_MHZ ? 8000 : \ |
144 | (v) == BANDWIDTH_7_MHZ ? 7000 : \ | 144 | (v) == BANDWIDTH_7_MHZ ? 7000 : \ |
145 | (v) == BANDWIDTH_6_MHZ ? 6000 : 8000 ) | 145 | (v) == BANDWIDTH_6_MHZ ? 6000 : 8000) |
146 | 146 | ||
147 | #define BANDWIDTH_TO_INDEX(v) ( \ | 147 | #define BANDWIDTH_TO_INDEX(v) ( \ |
148 | (v) == 8000 ? BANDWIDTH_8_MHZ : \ | 148 | (v) == 8000 ? BANDWIDTH_8_MHZ : \ |
@@ -223,7 +223,7 @@ struct dvb_frontend_parametersContext { | |||
223 | 223 | ||
224 | #define FE_CALLBACK_TIME_NEVER 0xffffffff | 224 | #define FE_CALLBACK_TIME_NEVER 0xffffffff |
225 | 225 | ||
226 | #define ABS(x) ((x<0)?(-x):(x)) | 226 | #define ABS(x) ((x < 0) ? (-x) : (x)) |
227 | 227 | ||
228 | #define DATA_BUS_ACCESS_MODE_8BIT 0x01 | 228 | #define DATA_BUS_ACCESS_MODE_8BIT 0x01 |
229 | #define DATA_BUS_ACCESS_MODE_16BIT 0x02 | 229 | #define DATA_BUS_ACCESS_MODE_16BIT 0x02 |