diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-26 09:00:09 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-31 06:19:35 -0500 |
commit | f908cf1dfe16e0a998ffd03d4d98454ef0860285 (patch) | |
tree | c3d256a30bf99b032fecccc9e27a0665f03d2913 /drivers/media/dvb/frontends/it913x-fe.c | |
parent | 41943eaf15b1e18f3800e39d3356f409048c5d41 (diff) |
[media] it913x-fe: convert set_fontend to use DVBv5 parameters
Instead of using dvb_frontend_parameters struct, that were
designed for a subset of the supported standards, use the DVBv5
cache information.
Also, fill the supported delivery systems at dvb_frontend_ops
struct.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/it913x-fe.c')
-rw-r--r-- | drivers/media/dvb/frontends/it913x-fe.c | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/drivers/media/dvb/frontends/it913x-fe.c b/drivers/media/dvb/frontends/it913x-fe.c index a13f897a7d81..a75dee83bb3b 100644 --- a/drivers/media/dvb/frontends/it913x-fe.c +++ b/drivers/media/dvb/frontends/it913x-fe.c | |||
@@ -232,7 +232,7 @@ static int it913x_init_tuner(struct it913x_fe_state *state) | |||
232 | } | 232 | } |
233 | 233 | ||
234 | static int it9137_set_tuner(struct it913x_fe_state *state, | 234 | static int it9137_set_tuner(struct it913x_fe_state *state, |
235 | enum fe_bandwidth bandwidth, u32 frequency_m) | 235 | u32 bandwidth, u32 frequency_m) |
236 | { | 236 | { |
237 | struct it913xset *set_tuner = set_it9137_template; | 237 | struct it913xset *set_tuner = set_it9137_template; |
238 | int ret, reg; | 238 | int ret, reg; |
@@ -286,16 +286,21 @@ static int it9137_set_tuner(struct it913x_fe_state *state, | |||
286 | return -EINVAL; | 286 | return -EINVAL; |
287 | set_tuner[0].reg[0] = lna_band; | 287 | set_tuner[0].reg[0] = lna_band; |
288 | 288 | ||
289 | if (bandwidth == BANDWIDTH_5_MHZ) | 289 | switch (bandwidth) { |
290 | case 5000000: | ||
290 | bw = 0; | 291 | bw = 0; |
291 | else if (bandwidth == BANDWIDTH_6_MHZ) | 292 | break; |
293 | case 6000000: | ||
292 | bw = 2; | 294 | bw = 2; |
293 | else if (bandwidth == BANDWIDTH_7_MHZ) | 295 | break; |
296 | case 7000000: | ||
294 | bw = 4; | 297 | bw = 4; |
295 | else if (bandwidth == BANDWIDTH_8_MHZ) | 298 | break; |
296 | bw = 6; | 299 | default: |
297 | else | 300 | case 8000000: |
298 | bw = 6; | 301 | bw = 6; |
302 | break; | ||
303 | } | ||
299 | 304 | ||
300 | set_tuner[1].reg[0] = bw; | 305 | set_tuner[1].reg[0] = bw; |
301 | set_tuner[2].reg[0] = 0xa0 | (l_band << 3); | 306 | set_tuner[2].reg[0] = 0xa0 | (l_band << 3); |
@@ -374,7 +379,7 @@ static int it9137_set_tuner(struct it913x_fe_state *state, | |||
374 | } | 379 | } |
375 | 380 | ||
376 | static int it913x_fe_select_bw(struct it913x_fe_state *state, | 381 | static int it913x_fe_select_bw(struct it913x_fe_state *state, |
377 | enum fe_bandwidth bandwidth, u32 adcFrequency) | 382 | u32 bandwidth, u32 adcFrequency) |
378 | { | 383 | { |
379 | int ret, i; | 384 | int ret, i; |
380 | u8 buffer[256]; | 385 | u8 buffer[256]; |
@@ -387,17 +392,21 @@ static int it913x_fe_select_bw(struct it913x_fe_state *state, | |||
387 | 392 | ||
388 | deb_info("Bandwidth %d Adc %d", bandwidth, adcFrequency); | 393 | deb_info("Bandwidth %d Adc %d", bandwidth, adcFrequency); |
389 | 394 | ||
390 | if (bandwidth == BANDWIDTH_5_MHZ) | 395 | switch (bandwidth) { |
396 | case 5000000: | ||
391 | bw = 3; | 397 | bw = 3; |
392 | else if (bandwidth == BANDWIDTH_6_MHZ) | 398 | break; |
399 | case 6000000: | ||
393 | bw = 0; | 400 | bw = 0; |
394 | else if (bandwidth == BANDWIDTH_7_MHZ) | 401 | break; |
402 | case 7000000: | ||
395 | bw = 1; | 403 | bw = 1; |
396 | else if (bandwidth == BANDWIDTH_8_MHZ) | 404 | break; |
397 | bw = 2; | 405 | default: |
398 | else | 406 | case 8000000: |
399 | bw = 2; | 407 | bw = 2; |
400 | 408 | break; | |
409 | } | ||
401 | ret = it913x_write_reg(state, PRO_DMOD, REG_BW, bw); | 410 | ret = it913x_write_reg(state, PRO_DMOD, REG_BW, bw); |
402 | 411 | ||
403 | if (state->table == NULL) | 412 | if (state->table == NULL) |
@@ -564,7 +573,7 @@ static int it913x_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
564 | } | 573 | } |
565 | 574 | ||
566 | static int it913x_fe_get_frontend(struct dvb_frontend *fe, | 575 | static int it913x_fe_get_frontend(struct dvb_frontend *fe, |
567 | struct dvb_frontend_parameters *p) | 576 | struct dtv_frontend_properties *p) |
568 | { | 577 | { |
569 | struct it913x_fe_state *state = fe->demodulator_priv; | 578 | struct it913x_fe_state *state = fe->demodulator_priv; |
570 | int ret; | 579 | int ret; |
@@ -573,30 +582,30 @@ static int it913x_fe_get_frontend(struct dvb_frontend *fe, | |||
573 | ret = it913x_read_reg(state, REG_TPSD_TX_MODE, reg, sizeof(reg)); | 582 | ret = it913x_read_reg(state, REG_TPSD_TX_MODE, reg, sizeof(reg)); |
574 | 583 | ||
575 | if (reg[3] < 3) | 584 | if (reg[3] < 3) |
576 | p->u.ofdm.constellation = fe_con[reg[3]]; | 585 | p->modulation = fe_con[reg[3]]; |
577 | |||
578 | state->constellation = p->u.ofdm.constellation; | ||
579 | 586 | ||
580 | if (reg[0] < 3) | 587 | if (reg[0] < 3) |
581 | p->u.ofdm.transmission_mode = fe_mode[reg[0]]; | 588 | p->transmission_mode = fe_mode[reg[0]]; |
582 | |||
583 | state->transmission_mode = p->u.ofdm.transmission_mode; | ||
584 | 589 | ||
585 | if (reg[1] < 4) | 590 | if (reg[1] < 4) |
586 | p->u.ofdm.guard_interval = fe_gi[reg[1]]; | 591 | p->guard_interval = fe_gi[reg[1]]; |
587 | 592 | ||
588 | if (reg[2] < 4) | 593 | if (reg[2] < 4) |
589 | p->u.ofdm.hierarchy_information = fe_hi[reg[2]]; | 594 | p->hierarchy = fe_hi[reg[2]]; |
595 | |||
596 | p->code_rate_HP = (reg[6] < 6) ? fe_code[reg[6]] : FEC_NONE; | ||
597 | p->code_rate_LP = (reg[7] < 6) ? fe_code[reg[7]] : FEC_NONE; | ||
590 | 598 | ||
591 | p->u.ofdm.code_rate_HP = (reg[6] < 6) ? fe_code[reg[6]] : FEC_NONE; | 599 | /* Update internal state to reflect the autodetected props */ |
592 | p->u.ofdm.code_rate_LP = (reg[7] < 6) ? fe_code[reg[7]] : FEC_NONE; | 600 | state->constellation = p->modulation; |
601 | state->transmission_mode = p->transmission_mode; | ||
593 | 602 | ||
594 | return 0; | 603 | return 0; |
595 | } | 604 | } |
596 | 605 | ||
597 | static int it913x_fe_set_frontend(struct dvb_frontend *fe, | 606 | static int it913x_fe_set_frontend(struct dvb_frontend *fe) |
598 | struct dvb_frontend_parameters *p) | ||
599 | { | 607 | { |
608 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; | ||
600 | struct it913x_fe_state *state = fe->demodulator_priv; | 609 | struct it913x_fe_state *state = fe->demodulator_priv; |
601 | int ret, i; | 610 | int ret, i; |
602 | u8 empty_ch, last_ch; | 611 | u8 empty_ch, last_ch; |
@@ -604,7 +613,7 @@ static int it913x_fe_set_frontend(struct dvb_frontend *fe, | |||
604 | state->it913x_status = 0; | 613 | state->it913x_status = 0; |
605 | 614 | ||
606 | /* Set bw*/ | 615 | /* Set bw*/ |
607 | ret = it913x_fe_select_bw(state, p->u.ofdm.bandwidth, | 616 | ret = it913x_fe_select_bw(state, p->bandwidth_hz, |
608 | state->adcFrequency); | 617 | state->adcFrequency); |
609 | 618 | ||
610 | /* Training Mode Off */ | 619 | /* Training Mode Off */ |
@@ -624,8 +633,8 @@ static int it913x_fe_set_frontend(struct dvb_frontend *fe, | |||
624 | i = 1; | 633 | i = 1; |
625 | else if ((p->frequency >= 1450000000) && (p->frequency <= 1680000000)) | 634 | else if ((p->frequency >= 1450000000) && (p->frequency <= 1680000000)) |
626 | i = 2; | 635 | i = 2; |
627 | else | 636 | else |
628 | return -EOPNOTSUPP; | 637 | return -EOPNOTSUPP; |
629 | 638 | ||
630 | ret = it913x_write_reg(state, PRO_DMOD, FREE_BAND, i); | 639 | ret = it913x_write_reg(state, PRO_DMOD, FREE_BAND, i); |
631 | 640 | ||
@@ -638,7 +647,7 @@ static int it913x_fe_set_frontend(struct dvb_frontend *fe, | |||
638 | case IT9135_61: | 647 | case IT9135_61: |
639 | case IT9135_62: | 648 | case IT9135_62: |
640 | ret = it9137_set_tuner(state, | 649 | ret = it9137_set_tuner(state, |
641 | p->u.ofdm.bandwidth, p->frequency); | 650 | p->bandwidth_hz, p->frequency); |
642 | break; | 651 | break; |
643 | default: | 652 | default: |
644 | if (fe->ops.tuner_ops.set_params) { | 653 | if (fe->ops.tuner_ops.set_params) { |
@@ -918,7 +927,7 @@ error: | |||
918 | EXPORT_SYMBOL(it913x_fe_attach); | 927 | EXPORT_SYMBOL(it913x_fe_attach); |
919 | 928 | ||
920 | static struct dvb_frontend_ops it913x_fe_ofdm_ops = { | 929 | static struct dvb_frontend_ops it913x_fe_ofdm_ops = { |
921 | 930 | .delsys = { SYS_DVBT }, | |
922 | .info = { | 931 | .info = { |
923 | .name = "it913x-fe DVB-T", | 932 | .name = "it913x-fe DVB-T", |
924 | .type = FE_OFDM, | 933 | .type = FE_OFDM, |
@@ -939,8 +948,8 @@ static struct dvb_frontend_ops it913x_fe_ofdm_ops = { | |||
939 | .init = it913x_fe_init, | 948 | .init = it913x_fe_init, |
940 | .sleep = it913x_fe_sleep, | 949 | .sleep = it913x_fe_sleep, |
941 | 950 | ||
942 | .set_frontend_legacy = it913x_fe_set_frontend, | 951 | .set_frontend = it913x_fe_set_frontend, |
943 | .get_frontend_legacy = it913x_fe_get_frontend, | 952 | .get_frontend = it913x_fe_get_frontend, |
944 | 953 | ||
945 | .read_status = it913x_fe_read_status, | 954 | .read_status = it913x_fe_read_status, |
946 | .read_signal_strength = it913x_fe_read_signal_strength, | 955 | .read_signal_strength = it913x_fe_read_signal_strength, |