diff options
author | Gianluca Gennari <gennarone@gmail.com> | 2012-04-05 11:47:19 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-04-09 13:55:21 -0400 |
commit | 0a4df239af50650fdcf6bd4911a2f18156c2c9f0 (patch) | |
tree | ef8d5cd01d2c17ffcb43f277ab19cd66f73c572a /drivers/media/dvb | |
parent | f2b61d0c3966c424b85591b6e538183871b8db35 (diff) |
[media] af9033: implement get_frontend
Implement the get_frontend function.
The code is derived from the old af9033 driver by Antti Palosaari.
Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/frontends/af9033.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/drivers/media/dvb/frontends/af9033.c b/drivers/media/dvb/frontends/af9033.c index 5fadee79b325..da91155b8a26 100644 --- a/drivers/media/dvb/frontends/af9033.c +++ b/drivers/media/dvb/frontends/af9033.c | |||
@@ -26,6 +26,7 @@ struct af9033_state { | |||
26 | struct dvb_frontend fe; | 26 | struct dvb_frontend fe; |
27 | struct af9033_config cfg; | 27 | struct af9033_config cfg; |
28 | 28 | ||
29 | u32 frequency; | ||
29 | u32 bandwidth_hz; | 30 | u32 bandwidth_hz; |
30 | bool ts_mode_parallel; | 31 | bool ts_mode_parallel; |
31 | bool ts_mode_serial; | 32 | bool ts_mode_serial; |
@@ -406,6 +407,8 @@ static int af9033_set_frontend(struct dvb_frontend *fe) | |||
406 | pr_debug("%s: frequency=%d bandwidth_hz=%d\n", __func__, c->frequency, | 407 | pr_debug("%s: frequency=%d bandwidth_hz=%d\n", __func__, c->frequency, |
407 | c->bandwidth_hz); | 408 | c->bandwidth_hz); |
408 | 409 | ||
410 | state->frequency = c->frequency; | ||
411 | |||
409 | /* check bandwidth */ | 412 | /* check bandwidth */ |
410 | switch (c->bandwidth_hz) { | 413 | switch (c->bandwidth_hz) { |
411 | case 6000000: | 414 | case 6000000: |
@@ -523,6 +526,135 @@ err: | |||
523 | return ret; | 526 | return ret; |
524 | } | 527 | } |
525 | 528 | ||
529 | static int af9033_get_frontend(struct dvb_frontend *fe) | ||
530 | { | ||
531 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; | ||
532 | struct af9033_state *state = fe->demodulator_priv; | ||
533 | int ret; | ||
534 | u8 buf[8]; | ||
535 | |||
536 | pr_debug("%s\n", __func__); | ||
537 | |||
538 | /* read all needed registers */ | ||
539 | ret = af9033_rd_regs(state, 0x80f900, buf, sizeof(buf)); | ||
540 | if (ret) | ||
541 | goto error; | ||
542 | |||
543 | switch ((buf[0] >> 0) & 3) { | ||
544 | case 0: | ||
545 | p->transmission_mode = TRANSMISSION_MODE_2K; | ||
546 | break; | ||
547 | case 1: | ||
548 | p->transmission_mode = TRANSMISSION_MODE_8K; | ||
549 | break; | ||
550 | } | ||
551 | |||
552 | switch ((buf[1] >> 0) & 3) { | ||
553 | case 0: | ||
554 | p->guard_interval = GUARD_INTERVAL_1_32; | ||
555 | break; | ||
556 | case 1: | ||
557 | p->guard_interval = GUARD_INTERVAL_1_16; | ||
558 | break; | ||
559 | case 2: | ||
560 | p->guard_interval = GUARD_INTERVAL_1_8; | ||
561 | break; | ||
562 | case 3: | ||
563 | p->guard_interval = GUARD_INTERVAL_1_4; | ||
564 | break; | ||
565 | } | ||
566 | |||
567 | switch ((buf[2] >> 0) & 7) { | ||
568 | case 0: | ||
569 | p->hierarchy = HIERARCHY_NONE; | ||
570 | break; | ||
571 | case 1: | ||
572 | p->hierarchy = HIERARCHY_1; | ||
573 | break; | ||
574 | case 2: | ||
575 | p->hierarchy = HIERARCHY_2; | ||
576 | break; | ||
577 | case 3: | ||
578 | p->hierarchy = HIERARCHY_4; | ||
579 | break; | ||
580 | } | ||
581 | |||
582 | switch ((buf[3] >> 0) & 3) { | ||
583 | case 0: | ||
584 | p->modulation = QPSK; | ||
585 | break; | ||
586 | case 1: | ||
587 | p->modulation = QAM_16; | ||
588 | break; | ||
589 | case 2: | ||
590 | p->modulation = QAM_64; | ||
591 | break; | ||
592 | } | ||
593 | |||
594 | switch ((buf[4] >> 0) & 3) { | ||
595 | case 0: | ||
596 | p->bandwidth_hz = 6000000; | ||
597 | break; | ||
598 | case 1: | ||
599 | p->bandwidth_hz = 7000000; | ||
600 | break; | ||
601 | case 2: | ||
602 | p->bandwidth_hz = 8000000; | ||
603 | break; | ||
604 | } | ||
605 | |||
606 | switch ((buf[6] >> 0) & 7) { | ||
607 | case 0: | ||
608 | p->code_rate_HP = FEC_1_2; | ||
609 | break; | ||
610 | case 1: | ||
611 | p->code_rate_HP = FEC_2_3; | ||
612 | break; | ||
613 | case 2: | ||
614 | p->code_rate_HP = FEC_3_4; | ||
615 | break; | ||
616 | case 3: | ||
617 | p->code_rate_HP = FEC_5_6; | ||
618 | break; | ||
619 | case 4: | ||
620 | p->code_rate_HP = FEC_7_8; | ||
621 | break; | ||
622 | case 5: | ||
623 | p->code_rate_HP = FEC_NONE; | ||
624 | break; | ||
625 | } | ||
626 | |||
627 | switch ((buf[7] >> 0) & 7) { | ||
628 | case 0: | ||
629 | p->code_rate_LP = FEC_1_2; | ||
630 | break; | ||
631 | case 1: | ||
632 | p->code_rate_LP = FEC_2_3; | ||
633 | break; | ||
634 | case 2: | ||
635 | p->code_rate_LP = FEC_3_4; | ||
636 | break; | ||
637 | case 3: | ||
638 | p->code_rate_LP = FEC_5_6; | ||
639 | break; | ||
640 | case 4: | ||
641 | p->code_rate_LP = FEC_7_8; | ||
642 | break; | ||
643 | case 5: | ||
644 | p->code_rate_LP = FEC_NONE; | ||
645 | break; | ||
646 | } | ||
647 | |||
648 | p->inversion = INVERSION_AUTO; | ||
649 | p->frequency = state->frequency; | ||
650 | |||
651 | error: | ||
652 | if (ret) | ||
653 | pr_debug("%s: failed:%d\n", __func__, ret); | ||
654 | |||
655 | return ret; | ||
656 | } | ||
657 | |||
526 | static int af9033_read_status(struct dvb_frontend *fe, fe_status_t *status) | 658 | static int af9033_read_status(struct dvb_frontend *fe, fe_status_t *status) |
527 | { | 659 | { |
528 | struct af9033_state *state = fe->demodulator_priv; | 660 | struct af9033_state *state = fe->demodulator_priv; |
@@ -776,6 +908,7 @@ static struct dvb_frontend_ops af9033_ops = { | |||
776 | 908 | ||
777 | .get_tune_settings = af9033_get_tune_settings, | 909 | .get_tune_settings = af9033_get_tune_settings, |
778 | .set_frontend = af9033_set_frontend, | 910 | .set_frontend = af9033_set_frontend, |
911 | .get_frontend = af9033_get_frontend, | ||
779 | 912 | ||
780 | .read_status = af9033_read_status, | 913 | .read_status = af9033_read_status, |
781 | .read_snr = af9033_read_snr, | 914 | .read_snr = af9033_read_snr, |