diff options
Diffstat (limited to 'drivers/media/dvb/frontends/nxt6000.c')
| -rw-r--r-- | drivers/media/dvb/frontends/nxt6000.c | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c index a41f7da8b842..966de9853d18 100644 --- a/drivers/media/dvb/frontends/nxt6000.c +++ b/drivers/media/dvb/frontends/nxt6000.c | |||
| @@ -176,11 +176,16 @@ static int nxt6000_set_transmission_mode(struct nxt6000_state* state, fe_transmi | |||
| 176 | 176 | ||
| 177 | static void nxt6000_setup(struct dvb_frontend* fe) | 177 | static void nxt6000_setup(struct dvb_frontend* fe) |
| 178 | { | 178 | { |
| 179 | struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; | 179 | struct nxt6000_state* state = fe->demodulator_priv; |
| 180 | 180 | ||
| 181 | nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM); | 181 | nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM); |
| 182 | nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01); | 182 | nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01); |
| 183 | nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC); | 183 | nxt6000_writereg(state, VIT_BERTIME_2, 0x00); // BER Timer = 0x000200 * 256 = 131072 bits |
| 184 | nxt6000_writereg(state, VIT_BERTIME_1, 0x02); // | ||
| 185 | nxt6000_writereg(state, VIT_BERTIME_0, 0x00); // | ||
| 186 | nxt6000_writereg(state, VIT_COR_INTEN, 0x98); // Enable BER interrupts | ||
| 187 | nxt6000_writereg(state, VIT_COR_CTL, 0x82); // Enable BER measurement | ||
| 188 | nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC | 0x02 ); | ||
| 184 | nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F)); | 189 | nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F)); |
| 185 | nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02); | 190 | nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02); |
| 186 | nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW); | 191 | nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW); |
| @@ -422,7 +427,7 @@ static void nxt6000_dump_status(struct nxt6000_state *state) | |||
| 422 | static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status) | 427 | static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status) |
| 423 | { | 428 | { |
| 424 | u8 core_status; | 429 | u8 core_status; |
| 425 | struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; | 430 | struct nxt6000_state* state = fe->demodulator_priv; |
| 426 | 431 | ||
| 427 | *status = 0; | 432 | *status = 0; |
| 428 | 433 | ||
| @@ -451,7 +456,7 @@ static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 451 | 456 | ||
| 452 | static int nxt6000_init(struct dvb_frontend* fe) | 457 | static int nxt6000_init(struct dvb_frontend* fe) |
| 453 | { | 458 | { |
| 454 | struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; | 459 | struct nxt6000_state* state = fe->demodulator_priv; |
| 455 | 460 | ||
| 456 | nxt6000_reset(state); | 461 | nxt6000_reset(state); |
| 457 | nxt6000_setup(fe); | 462 | nxt6000_setup(fe); |
| @@ -461,7 +466,7 @@ static int nxt6000_init(struct dvb_frontend* fe) | |||
| 461 | 466 | ||
| 462 | static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *param) | 467 | static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *param) |
| 463 | { | 468 | { |
| 464 | struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; | 469 | struct nxt6000_state* state = fe->demodulator_priv; |
| 465 | int result; | 470 | int result; |
| 466 | 471 | ||
| 467 | nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */ | 472 | nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01); /* open i2c bus switch */ |
| @@ -482,10 +487,44 @@ static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 482 | 487 | ||
| 483 | static void nxt6000_release(struct dvb_frontend* fe) | 488 | static void nxt6000_release(struct dvb_frontend* fe) |
| 484 | { | 489 | { |
| 485 | struct nxt6000_state* state = (struct nxt6000_state*) fe->demodulator_priv; | 490 | struct nxt6000_state* state = fe->demodulator_priv; |
| 486 | kfree(state); | 491 | kfree(state); |
| 487 | } | 492 | } |
| 488 | 493 | ||
| 494 | static int nxt6000_read_snr(struct dvb_frontend* fe, u16* snr) | ||
| 495 | { | ||
| 496 | struct nxt6000_state* state = fe->demodulator_priv; | ||
| 497 | |||
| 498 | *snr = nxt6000_readreg( state, OFDM_CHC_SNR) / 8; | ||
| 499 | |||
| 500 | return 0; | ||
| 501 | } | ||
| 502 | |||
| 503 | static int nxt6000_read_ber(struct dvb_frontend* fe, u32* ber) | ||
| 504 | { | ||
| 505 | struct nxt6000_state* state = fe->demodulator_priv; | ||
| 506 | |||
| 507 | nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18 ); | ||
| 508 | |||
| 509 | *ber = (nxt6000_readreg( state, VIT_BER_1 ) << 8 ) | | ||
| 510 | nxt6000_readreg( state, VIT_BER_0 ); | ||
| 511 | |||
| 512 | nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18); // Clear BER Done interrupts | ||
| 513 | |||
| 514 | return 0; | ||
| 515 | } | ||
| 516 | |||
| 517 | static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) | ||
| 518 | { | ||
| 519 | struct nxt6000_state* state = fe->demodulator_priv; | ||
| 520 | |||
| 521 | *signal_strength = (short) (511 - | ||
| 522 | (nxt6000_readreg(state, AGC_GAIN_1) + | ||
| 523 | ((nxt6000_readreg(state, AGC_GAIN_2) & 0x03) << 8))); | ||
| 524 | |||
| 525 | return 0; | ||
| 526 | } | ||
| 527 | |||
| 489 | static struct dvb_frontend_ops nxt6000_ops; | 528 | static struct dvb_frontend_ops nxt6000_ops; |
| 490 | 529 | ||
| 491 | struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, | 530 | struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, |
| @@ -494,7 +533,7 @@ struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, | |||
| 494 | struct nxt6000_state* state = NULL; | 533 | struct nxt6000_state* state = NULL; |
| 495 | 534 | ||
| 496 | /* allocate memory for the internal state */ | 535 | /* allocate memory for the internal state */ |
| 497 | state = (struct nxt6000_state*) kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL); | 536 | state = kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL); |
| 498 | if (state == NULL) goto error; | 537 | if (state == NULL) goto error; |
| 499 | 538 | ||
| 500 | /* setup the state */ | 539 | /* setup the state */ |
| @@ -542,6 +581,9 @@ static struct dvb_frontend_ops nxt6000_ops = { | |||
| 542 | .set_frontend = nxt6000_set_frontend, | 581 | .set_frontend = nxt6000_set_frontend, |
| 543 | 582 | ||
| 544 | .read_status = nxt6000_read_status, | 583 | .read_status = nxt6000_read_status, |
| 584 | .read_ber = nxt6000_read_ber, | ||
| 585 | .read_signal_strength = nxt6000_read_signal_strength, | ||
| 586 | .read_snr = nxt6000_read_snr, | ||
| 545 | }; | 587 | }; |
| 546 | 588 | ||
| 547 | module_param(debug, int, 0644); | 589 | module_param(debug, int, 0644); |
