Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

+76 -67
+32 -32
drivers/media/dvb/frontends/it913x-fe-priv.h
··· 22 22 /* clock and coeff tables only table 3 is used with IT9137*/ 23 23 /* TODO other tables relate AF9035 may be removed */ 24 24 static struct adctable tab1[] = { 25 - { 20156250, BANDWIDTH_6_MHZ, 25 + { 20156250, 6000000, 26 26 0x02b8ba6e, 0x015c5d37, 0x00ae340d, 0x00ae2e9b, 0x00ae292a, 27 27 0x015c5d37, 0x00ae2e9b, 0x0057174e, 0x02f1, 0x015c }, 28 - { 20156250, BANDWIDTH_7_MHZ, 28 + { 20156250, 7000000, 29 29 0x032cd980, 0x01966cc0, 0x00cb3cba, 0x00cb3660, 0x00cb3007, 30 30 0x01966cc0, 0x00cb3660, 0x00659b30, 0x0285, 0x0196 }, 31 - { 20156250, BANDWIDTH_8_MHZ, 31 + { 20156250, 8000000, 32 32 0x03a0f893, 0x01d07c49, 0x00e84567, 0x00e83e25, 0x00e836e3, 33 33 0x01d07c49, 0x00e83e25, 0x00741f12, 0x0234, 0x01d0 }, 34 - { 20156250, BANDWIDTH_5_MHZ, 34 + { 20156250, 5000000, 35 35 0x02449b5c, 0x01224dae, 0x00912b60, 0x009126d7, 0x0091224e, 36 36 0x01224dae, 0x009126d7, 0x0048936b, 0x0387, 0x0122 } 37 37 }; 38 38 39 39 static struct adctable tab2[] = { 40 - { 20187500, BANDWIDTH_6_MHZ, 40 + { 20187500, 6000000, 41 41 0x02b7a654, 0x015bd32a, 0x00adef04, 0x00ade995, 0x00ade426, 42 42 0x015bd32a, 0x00ade995, 0x0056f4ca, 0x02f2, 0x015c }, 43 - { 20187500, BANDWIDTH_7_MHZ, 43 + { 20187500, 7000000, 44 44 0x032b9761, 0x0195cbb1, 0x00caec30, 0x00cae5d8, 0x00cadf81, 45 45 0x0195cbb1, 0x00cae5d8, 0x006572ec, 0x0286, 0x0196 }, 46 - { 20187500, BANDWIDTH_8_MHZ, 46 + { 20187500, 8000000, 47 47 0x039f886f, 0x01cfc438, 0x00e7e95b, 0x00e7e21c, 0x00e7dadd, 48 48 0x01cfc438, 0x00e7e21c, 0x0073f10e, 0x0235, 0x01d0 }, 49 - { 20187500, BANDWIDTH_5_MHZ, 49 + { 20187500, 5000000, 50 50 0x0243b546, 0x0121daa3, 0x0090f1d9, 0x0090ed51, 0x0090e8ca, 51 51 0x0121daa3, 0x0090ed51, 0x004876a9, 0x0388, 0x0122 } 52 52 53 53 }; 54 54 55 55 static struct adctable tab3[] = { 56 - { 20250000, BANDWIDTH_6_MHZ, 56 + { 20250000, 6000000, 57 57 0x02b580ad, 0x015ac057, 0x00ad6597, 0x00ad602b, 0x00ad5ac1, 58 58 0x015ac057, 0x00ad602b, 0x0056b016, 0x02f4, 0x015b }, 59 - { 20250000, BANDWIDTH_7_MHZ, 59 + { 20250000, 7000000, 60 60 0x03291620, 0x01948b10, 0x00ca4bda, 0x00ca4588, 0x00ca3f36, 61 61 0x01948b10, 0x00ca4588, 0x006522c4, 0x0288, 0x0195 }, 62 - { 20250000, BANDWIDTH_8_MHZ, 62 + { 20250000, 8000000, 63 63 0x039cab92, 0x01ce55c9, 0x00e7321e, 0x00e72ae4, 0x00e723ab, 64 64 0x01ce55c9, 0x00e72ae4, 0x00739572, 0x0237, 0x01ce }, 65 - { 20250000, BANDWIDTH_5_MHZ, 65 + { 20250000, 5000000, 66 66 0x0241eb3b, 0x0120f59e, 0x00907f53, 0x00907acf, 0x0090764b, 67 67 0x0120f59e, 0x00907acf, 0x00483d67, 0x038b, 0x0121 } 68 68 69 69 }; 70 70 71 71 static struct adctable tab4[] = { 72 - { 20583333, BANDWIDTH_6_MHZ, 72 + { 20583333, 6000000, 73 73 0x02aa4598, 0x015522cc, 0x00aa96bb, 0x00aa9166, 0x00aa8c12, 74 74 0x015522cc, 0x00aa9166, 0x005548b3, 0x0300, 0x0155 }, 75 - { 20583333, BANDWIDTH_7_MHZ, 75 + { 20583333, 7000000, 76 76 0x031bfbdc, 0x018dfdee, 0x00c7052f, 0x00c6fef7, 0x00c6f8bf, 77 77 0x018dfdee, 0x00c6fef7, 0x00637f7b, 0x0293, 0x018e }, 78 - { 20583333, BANDWIDTH_8_MHZ, 78 + { 20583333, 8000000, 79 79 0x038db21f, 0x01c6d910, 0x00e373a3, 0x00e36c88, 0x00e3656d, 80 80 0x01c6d910, 0x00e36c88, 0x0071b644, 0x0240, 0x01c7 }, 81 - { 20583333, BANDWIDTH_5_MHZ, 81 + { 20583333, 5000000, 82 82 0x02388f54, 0x011c47aa, 0x008e2846, 0x008e23d5, 0x008e1f64, 83 83 0x011c47aa, 0x008e23d5, 0x004711ea, 0x039a, 0x011c } 84 84 85 85 }; 86 86 87 87 static struct adctable tab5[] = { 88 - { 20416667, BANDWIDTH_6_MHZ, 88 + { 20416667, 6000000, 89 89 0x02afd765, 0x0157ebb3, 0x00abfb39, 0x00abf5d9, 0x00abf07a, 90 90 0x0157ebb3, 0x00abf5d9, 0x0055faed, 0x02fa, 0x0158 }, 91 - { 20416667, BANDWIDTH_7_MHZ, 91 + { 20416667, 7000000, 92 92 0x03227b4b, 0x01913da6, 0x00c8a518, 0x00c89ed3, 0x00c8988e, 93 93 0x01913da6, 0x00c89ed3, 0x00644f69, 0x028d, 0x0191 }, 94 - { 20416667, BANDWIDTH_8_MHZ, 94 + { 20416667, 8000000, 95 95 0x03951f32, 0x01ca8f99, 0x00e54ef7, 0x00e547cc, 0x00e540a2, 96 96 0x01ca8f99, 0x00e547cc, 0x0072a3e6, 0x023c, 0x01cb }, 97 - { 20416667, BANDWIDTH_5_MHZ, 97 + { 20416667, 5000000, 98 98 0x023d337f, 0x011e99c0, 0x008f515a, 0x008f4ce0, 0x008f4865, 99 99 0x011e99c0, 0x008f4ce0, 0x0047a670, 0x0393, 0x011f } 100 100 101 101 }; 102 102 103 103 static struct adctable tab6[] = { 104 - { 20480000, BANDWIDTH_6_MHZ, 104 + { 20480000, 6000000, 105 105 0x02adb6db, 0x0156db6e, 0x00ab7312, 0x00ab6db7, 0x00ab685c, 106 106 0x0156db6e, 0x00ab6db7, 0x0055b6db, 0x02fd, 0x0157 }, 107 - { 20480000, BANDWIDTH_7_MHZ, 107 + { 20480000, 7000000, 108 108 0x03200000, 0x01900000, 0x00c80640, 0x00c80000, 0x00c7f9c0, 109 109 0x01900000, 0x00c80000, 0x00640000, 0x028f, 0x0190 }, 110 - { 20480000, BANDWIDTH_8_MHZ, 110 + { 20480000, 8000000, 111 111 0x03924925, 0x01c92492, 0x00e4996e, 0x00e49249, 0x00e48b25, 112 112 0x01c92492, 0x00e49249, 0x00724925, 0x023d, 0x01c9 }, 113 - { 20480000, BANDWIDTH_5_MHZ, 113 + { 20480000, 5000000, 114 114 0x023b6db7, 0x011db6db, 0x008edfe5, 0x008edb6e, 0x008ed6f7, 115 115 0x011db6db, 0x008edb6e, 0x00476db7, 0x0396, 0x011e } 116 116 }; 117 117 118 118 static struct adctable tab7[] = { 119 - { 20500000, BANDWIDTH_6_MHZ, 119 + { 20500000, 6000000, 120 120 0x02ad0b99, 0x015685cc, 0x00ab4840, 0x00ab42e6, 0x00ab3d8c, 121 121 0x015685cc, 0x00ab42e6, 0x0055a173, 0x02fd, 0x0157 }, 122 - { 20500000, BANDWIDTH_7_MHZ, 122 + { 20500000, 7000000, 123 123 0x031f3832, 0x018f9c19, 0x00c7d44b, 0x00c7ce0c, 0x00c7c7ce, 124 124 0x018f9c19, 0x00c7ce0c, 0x0063e706, 0x0290, 0x0190 }, 125 - { 20500000, BANDWIDTH_8_MHZ, 125 + { 20500000, 8000000, 126 126 0x039164cb, 0x01c8b266, 0x00e46056, 0x00e45933, 0x00e45210, 127 127 0x01c8b266, 0x00e45933, 0x00722c99, 0x023e, 0x01c9 }, 128 - { 20500000, BANDWIDTH_5_MHZ, 128 + { 20500000, 5000000, 129 129 0x023adeff, 0x011d6f80, 0x008ebc36, 0x008eb7c0, 0x008eb34a, 130 130 0x011d6f80, 0x008eb7c0, 0x00475be0, 0x0396, 0x011d } 131 131 132 132 }; 133 133 134 134 static struct adctable tab8[] = { 135 - { 20625000, BANDWIDTH_6_MHZ, 135 + { 20625000, 6000000, 136 136 0x02a8e4bd, 0x0154725e, 0x00aa3e81, 0x00aa392f, 0x00aa33de, 137 137 0x0154725e, 0x00aa392f, 0x00551c98, 0x0302, 0x0154 }, 138 - { 20625000, BANDWIDTH_7_MHZ, 138 + { 20625000, 7000000, 139 139 0x031a6032, 0x018d3019, 0x00c69e41, 0x00c6980c, 0x00c691d8, 140 140 0x018d3019, 0x00c6980c, 0x00634c06, 0x0294, 0x018d }, 141 - { 20625000, BANDWIDTH_8_MHZ, 141 + { 20625000, 8000000, 142 142 0x038bdba6, 0x01c5edd3, 0x00e2fe02, 0x00e2f6ea, 0x00e2efd2, 143 143 0x01c5edd3, 0x00e2f6ea, 0x00717b75, 0x0242, 0x01c6 }, 144 - { 20625000, BANDWIDTH_5_MHZ, 144 + { 20625000, 5000000, 145 145 0x02376948, 0x011bb4a4, 0x008ddec1, 0x008dda52, 0x008dd5e3, 146 146 0x011bb4a4, 0x008dda52, 0x0046ed29, 0x039c, 0x011c } 147 147
+44 -35
drivers/media/dvb/frontends/it913x-fe.c
··· 232 232 } 233 233 234 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 237 struct it913xset *set_tuner = set_it9137_template; 238 238 int ret, reg; ··· 286 286 return -EINVAL; 287 287 set_tuner[0].reg[0] = lna_band; 288 288 289 - if (bandwidth == BANDWIDTH_5_MHZ) 289 + switch (bandwidth) { 290 + case 5000000: 290 291 bw = 0; 291 - else if (bandwidth == BANDWIDTH_6_MHZ) 292 + break; 293 + case 6000000: 292 294 bw = 2; 293 - else if (bandwidth == BANDWIDTH_7_MHZ) 295 + break; 296 + case 7000000: 294 297 bw = 4; 295 - else if (bandwidth == BANDWIDTH_8_MHZ) 298 + break; 299 + default: 300 + case 8000000: 296 301 bw = 6; 297 - else 298 - bw = 6; 302 + break; 303 + } 299 304 300 305 set_tuner[1].reg[0] = bw; 301 306 set_tuner[2].reg[0] = 0xa0 | (l_band << 3); ··· 379 374 } 380 375 381 376 static int it913x_fe_select_bw(struct it913x_fe_state *state, 382 - enum fe_bandwidth bandwidth, u32 adcFrequency) 377 + u32 bandwidth, u32 adcFrequency) 383 378 { 384 379 int ret, i; 385 380 u8 buffer[256]; ··· 392 387 393 388 deb_info("Bandwidth %d Adc %d", bandwidth, adcFrequency); 394 389 395 - if (bandwidth == BANDWIDTH_5_MHZ) 390 + switch (bandwidth) { 391 + case 5000000: 396 392 bw = 3; 397 - else if (bandwidth == BANDWIDTH_6_MHZ) 393 + break; 394 + case 6000000: 398 395 bw = 0; 399 - else if (bandwidth == BANDWIDTH_7_MHZ) 396 + break; 397 + case 7000000: 400 398 bw = 1; 401 - else if (bandwidth == BANDWIDTH_8_MHZ) 399 + break; 400 + default: 401 + case 8000000: 402 402 bw = 2; 403 - else 404 - bw = 2; 405 - 403 + break; 404 + } 406 405 ret = it913x_write_reg(state, PRO_DMOD, REG_BW, bw); 407 406 408 407 if (state->table == NULL) ··· 573 564 } 574 565 575 566 static int it913x_fe_get_frontend(struct dvb_frontend *fe, 576 - struct dvb_frontend_parameters *p) 567 + struct dtv_frontend_properties *p) 577 568 { 578 569 struct it913x_fe_state *state = fe->demodulator_priv; 579 570 int ret; ··· 582 573 ret = it913x_read_reg(state, REG_TPSD_TX_MODE, reg, sizeof(reg)); 583 574 584 575 if (reg[3] < 3) 585 - p->u.ofdm.constellation = fe_con[reg[3]]; 586 - 587 - state->constellation = p->u.ofdm.constellation; 576 + p->modulation = fe_con[reg[3]]; 588 577 589 578 if (reg[0] < 3) 590 - p->u.ofdm.transmission_mode = fe_mode[reg[0]]; 591 - 592 - state->transmission_mode = p->u.ofdm.transmission_mode; 579 + p->transmission_mode = fe_mode[reg[0]]; 593 580 594 581 if (reg[1] < 4) 595 - p->u.ofdm.guard_interval = fe_gi[reg[1]]; 582 + p->guard_interval = fe_gi[reg[1]]; 596 583 597 584 if (reg[2] < 4) 598 - p->u.ofdm.hierarchy_information = fe_hi[reg[2]]; 585 + p->hierarchy = fe_hi[reg[2]]; 599 586 600 - p->u.ofdm.code_rate_HP = (reg[6] < 6) ? fe_code[reg[6]] : FEC_NONE; 601 - p->u.ofdm.code_rate_LP = (reg[7] < 6) ? fe_code[reg[7]] : FEC_NONE; 587 + p->code_rate_HP = (reg[6] < 6) ? fe_code[reg[6]] : FEC_NONE; 588 + p->code_rate_LP = (reg[7] < 6) ? fe_code[reg[7]] : FEC_NONE; 589 + 590 + /* Update internal state to reflect the autodetected props */ 591 + state->constellation = p->modulation; 592 + state->transmission_mode = p->transmission_mode; 602 593 603 594 return 0; 604 595 } 605 596 606 - static int it913x_fe_set_frontend(struct dvb_frontend *fe, 607 - struct dvb_frontend_parameters *p) 597 + static int it913x_fe_set_frontend(struct dvb_frontend *fe) 608 598 { 599 + struct dtv_frontend_properties *p = &fe->dtv_property_cache; 609 600 struct it913x_fe_state *state = fe->demodulator_priv; 610 601 int ret, i; 611 602 u8 empty_ch, last_ch; ··· 613 604 state->it913x_status = 0; 614 605 615 606 /* Set bw*/ 616 - ret = it913x_fe_select_bw(state, p->u.ofdm.bandwidth, 607 + ret = it913x_fe_select_bw(state, p->bandwidth_hz, 617 608 state->adcFrequency); 618 609 619 610 /* Training Mode Off */ ··· 633 624 i = 1; 634 625 else if ((p->frequency >= 1450000000) && (p->frequency <= 1680000000)) 635 626 i = 2; 636 - else 637 - return -EOPNOTSUPP; 627 + else 628 + return -EOPNOTSUPP; 638 629 639 630 ret = it913x_write_reg(state, PRO_DMOD, FREE_BAND, i); 640 631 ··· 647 638 case IT9135_61: 648 639 case IT9135_62: 649 640 ret = it9137_set_tuner(state, 650 - p->u.ofdm.bandwidth, p->frequency); 641 + p->bandwidth_hz, p->frequency); 651 642 break; 652 643 default: 653 644 if (fe->ops.tuner_ops.set_params) { ··· 927 918 EXPORT_SYMBOL(it913x_fe_attach); 928 919 929 920 static struct dvb_frontend_ops it913x_fe_ofdm_ops = { 930 - 921 + .delsys = { SYS_DVBT }, 931 922 .info = { 932 923 .name = "it913x-fe DVB-T", 933 924 .type = FE_OFDM, ··· 948 939 .init = it913x_fe_init, 949 940 .sleep = it913x_fe_sleep, 950 941 951 - .set_frontend_legacy = it913x_fe_set_frontend, 952 - .get_frontend_legacy = it913x_fe_get_frontend, 942 + .set_frontend = it913x_fe_set_frontend, 943 + .get_frontend = it913x_fe_get_frontend, 953 944 954 945 .read_status = it913x_fe_read_status, 955 946 .read_signal_strength = it913x_fe_read_signal_strength,