Skip to content

Commit f1b1eab

Browse files
committed
media: dvb: represent min/max/step/tolerance freqs in Hz
Right now, satellite frontend drivers specify frequencies in kHz, while terrestrial/cable ones specify in Hz. That's confusing for developers. However, the main problem is that universal frontends capable of handling both satellite and non-satelite delivery systems are appearing. We end by needing to hack the drivers in order to support such hybrid frontends. So, convert everything to specify frontend frequencies in Hz. Tested-by: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
1 parent a3f90c7 commit f1b1eab

96 files changed

Lines changed: 428 additions & 399 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/media/common/siano/smsdvb-main.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,9 @@ static void smsdvb_release(struct dvb_frontend *fe)
10471047
static const struct dvb_frontend_ops smsdvb_fe_ops = {
10481048
.info = {
10491049
.name = "Siano Mobile Digital MDTV Receiver",
1050-
.frequency_min = 44250000,
1051-
.frequency_max = 867250000,
1052-
.frequency_stepsize = 250000,
1050+
.frequency_min_hz = 44250 * kHz,
1051+
.frequency_max_hz = 867250 * kHz,
1052+
.frequency_stepsize_hz = 250 * kHz,
10531053
.caps = FE_CAN_INVERSION_AUTO |
10541054
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
10551055
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |

‎drivers/media/dvb-core/dvb_frontend.c‎

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -894,38 +894,64 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
894894
}
895895

896896
static void dvb_frontend_get_frequency_limits(struct dvb_frontend *fe,
897-
u32 *freq_min, u32 *freq_max)
897+
u32 *freq_min, u32 *freq_max,
898+
u32 *tolerance)
898899
{
899900
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
900-
__u32 tuner_min = fe->ops.tuner_ops.info.frequency_min_hz;
901-
__u32 tuner_max = fe->ops.tuner_ops.info.frequency_max_hz;
901+
u32 tuner_min = fe->ops.tuner_ops.info.frequency_min_hz;
902+
u32 tuner_max = fe->ops.tuner_ops.info.frequency_max_hz;
903+
u32 frontend_min = fe->ops.info.frequency_min_hz;
904+
u32 frontend_max = fe->ops.info.frequency_max_hz;
905+
906+
*freq_min = max(frontend_min, tuner_min);
907+
908+
if (frontend_max == 0)
909+
*freq_max = tuner_max;
910+
else if (tuner_max == 0)
911+
*freq_max = frontend_max;
912+
else
913+
*freq_max = min(frontend_max, tuner_max);
914+
915+
if (*freq_min == 0 || *freq_max == 0)
916+
dev_warn(fe->dvb->device,
917+
"DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n",
918+
fe->dvb->num, fe->id);
902919

903920
/* If the standard is for satellite, convert frequencies to kHz */
904921
switch (c->delivery_system) {
905922
case SYS_DVBS:
906923
case SYS_DVBS2:
907924
case SYS_TURBO:
908925
case SYS_ISDBS:
909-
tuner_max /= kHz;
910-
tuner_min /= kHz;
926+
*freq_min /= kHz;
927+
*freq_max /= kHz;
928+
if (tolerance)
929+
*tolerance = fe->ops.info.frequency_tolerance_hz / kHz;
930+
911931
break;
912932
default:
933+
if (tolerance)
934+
*tolerance = fe->ops.info.frequency_tolerance_hz;
913935
break;
914936
}
937+
}
915938

916-
*freq_min = max(fe->ops.info.frequency_min, tuner_min);
917-
918-
if (fe->ops.info.frequency_max == 0)
919-
*freq_max = tuner_max;
920-
else if (tuner_max == 0)
921-
*freq_max = fe->ops.info.frequency_max;
922-
else
923-
*freq_max = min(fe->ops.info.frequency_max, tuner_max);
939+
static u32 dvb_frontend_get_stepsize(struct dvb_frontend *fe)
940+
{
941+
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
942+
u32 step = fe->ops.info.frequency_stepsize_hz;
943+
switch (c->delivery_system) {
944+
case SYS_DVBS:
945+
case SYS_DVBS2:
946+
case SYS_TURBO:
947+
case SYS_ISDBS:
948+
step /= kHz;
949+
break;
950+
default:
951+
break;
952+
}
924953

925-
if (*freq_min == 0 || *freq_max == 0)
926-
dev_warn(fe->dvb->device,
927-
"DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n",
928-
fe->dvb->num, fe->id);
954+
return step;
929955
}
930956

931957
static int dvb_frontend_check_parameters(struct dvb_frontend *fe)
@@ -935,7 +961,7 @@ static int dvb_frontend_check_parameters(struct dvb_frontend *fe)
935961
u32 freq_max;
936962

937963
/* range check: frequency */
938-
dvb_frontend_get_frequency_limits(fe, &freq_min, &freq_max);
964+
dvb_frontend_get_frequency_limits(fe, &freq_min, &freq_max, NULL);
939965
if ((freq_min && c->frequency < freq_min) ||
940966
(freq_max && c->frequency > freq_max)) {
941967
dev_warn(fe->dvb->device, "DVB: adapter %i frontend %i frequency %u out of range (%u..%u)\n",
@@ -2261,8 +2287,8 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
22612287
case SYS_ISDBT:
22622288
case SYS_DTMB:
22632289
fepriv->min_delay = HZ / 20;
2264-
fepriv->step_size = fe->ops.info.frequency_stepsize * 2;
2265-
fepriv->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
2290+
fepriv->step_size = dvb_frontend_get_stepsize(fe) * 2;
2291+
fepriv->max_drift = (dvb_frontend_get_stepsize(fe) * 2) + 1;
22662292
break;
22672293
default:
22682294
/*
@@ -2391,9 +2417,17 @@ static int dvb_frontend_handle_ioctl(struct file *file,
23912417

23922418
case FE_GET_INFO: {
23932419
struct dvb_frontend_info *info = parg;
2394-
2395-
memcpy(info, &fe->ops.info, sizeof(struct dvb_frontend_info));
2396-
dvb_frontend_get_frequency_limits(fe, &info->frequency_min, &info->frequency_max);
2420+
memset(info, 0, sizeof(*info));
2421+
2422+
strcpy(info->name, fe->ops.info.name);
2423+
info->symbol_rate_min = fe->ops.info.symbol_rate_min;
2424+
info->symbol_rate_max = fe->ops.info.symbol_rate_max;
2425+
info->symbol_rate_tolerance = fe->ops.info.symbol_rate_tolerance;
2426+
info->caps = fe->ops.info.caps;
2427+
info->frequency_stepsize = dvb_frontend_get_stepsize(fe);
2428+
dvb_frontend_get_frequency_limits(fe, &info->frequency_min,
2429+
&info->frequency_max,
2430+
&info->frequency_tolerance);
23972431

23982432
/*
23992433
* Associate the 4 delivery systems supported by DVBv3
@@ -2423,10 +2457,10 @@ static int dvb_frontend_handle_ioctl(struct file *file,
24232457
dev_err(fe->dvb->device,
24242458
"%s: doesn't know how to handle a DVBv3 call to delivery system %i\n",
24252459
__func__, c->delivery_system);
2426-
fe->ops.info.type = FE_OFDM;
2460+
info->type = FE_OFDM;
24272461
}
24282462
dev_dbg(fe->dvb->device, "%s: current delivery system on cache: %d, V3 type: %d\n",
2429-
__func__, c->delivery_system, fe->ops.info.type);
2463+
__func__, c->delivery_system, info->type);
24302464

24312465
/* Set CAN_INVERSION_AUTO bit on in other than oneshot mode */
24322466
if (!(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT))

‎drivers/media/dvb-frontends/af9013.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,10 +1136,9 @@ static const struct dvb_frontend_ops af9013_ops = {
11361136
.delsys = { SYS_DVBT },
11371137
.info = {
11381138
.name = "Afatech AF9013",
1139-
.frequency_min = 174000000,
1140-
.frequency_max = 862000000,
1141-
.frequency_stepsize = 250000,
1142-
.frequency_tolerance = 0,
1139+
.frequency_min_hz = 174 * MHz,
1140+
.frequency_max_hz = 862 * MHz,
1141+
.frequency_stepsize_hz = 250 * kHz,
11431142
.caps = FE_CAN_FEC_1_2 |
11441143
FE_CAN_FEC_2_3 |
11451144
FE_CAN_FEC_3_4 |

‎drivers/media/dvb-frontends/af9033.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,9 @@ static const struct dvb_frontend_ops af9033_ops = {
10201020
.delsys = {SYS_DVBT},
10211021
.info = {
10221022
.name = "Afatech AF9033 (DVB-T)",
1023-
.frequency_min = 174000000,
1024-
.frequency_max = 862000000,
1025-
.frequency_stepsize = 250000,
1026-
.frequency_tolerance = 0,
1023+
.frequency_min_hz = 174 * MHz,
1024+
.frequency_max_hz = 862 * MHz,
1025+
.frequency_stepsize_hz = 250 * kHz,
10271026
.caps = FE_CAN_FEC_1_2 |
10281027
FE_CAN_FEC_2_3 |
10291028
FE_CAN_FEC_3_4 |

‎drivers/media/dvb-frontends/as102_fe.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ static const struct dvb_frontend_ops as102_fe_ops = {
419419
.delsys = { SYS_DVBT },
420420
.info = {
421421
.name = "Abilis AS102 DVB-T",
422-
.frequency_min = 174000000,
423-
.frequency_max = 862000000,
424-
.frequency_stepsize = 166667,
422+
.frequency_min_hz = 174 * MHz,
423+
.frequency_max_hz = 862 * MHz,
424+
.frequency_stepsize_hz = 166667,
425425
.caps = FE_CAN_INVERSION_AUTO
426426
| FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4
427427
| FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO

‎drivers/media/dvb-frontends/atbm8830.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ static const struct dvb_frontend_ops atbm8830_ops = {
428428
.delsys = { SYS_DTMB },
429429
.info = {
430430
.name = "AltoBeam ATBM8830/8831 DMB-TH",
431-
.frequency_min = 474000000,
432-
.frequency_max = 858000000,
433-
.frequency_stepsize = 10000,
431+
.frequency_min_hz = 474 * MHz,
432+
.frequency_max_hz = 858 * MHz,
433+
.frequency_stepsize_hz = 10 * kHz,
434434
.caps =
435435
FE_CAN_FEC_AUTO |
436436
FE_CAN_QAM_AUTO |

‎drivers/media/dvb-frontends/au8522_dig.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,9 @@ static const struct dvb_frontend_ops au8522_ops = {
897897
.delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
898898
.info = {
899899
.name = "Auvitek AU8522 QAM/8VSB Frontend",
900-
.frequency_min = 54000000,
901-
.frequency_max = 858000000,
902-
.frequency_stepsize = 62500,
900+
.frequency_min_hz = 54 * MHz,
901+
.frequency_max_hz = 858 * MHz,
902+
.frequency_stepsize_hz = 62500,
903903
.caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
904904
},
905905

‎drivers/media/dvb-frontends/bcm3510.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,8 @@ static const struct dvb_frontend_ops bcm3510_ops = {
840840
.delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
841841
.info = {
842842
.name = "Broadcom BCM3510 VSB/QAM frontend",
843-
.frequency_min = 54000000,
844-
.frequency_max = 803000000,
845-
/* stepsize is just a guess */
846-
.frequency_stepsize = 0,
843+
.frequency_min_hz = 54 * MHz,
844+
.frequency_max_hz = 803 * MHz,
847845
.caps =
848846
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
849847
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |

‎drivers/media/dvb-frontends/cx22700.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ static const struct dvb_frontend_ops cx22700_ops = {
412412
.delsys = { SYS_DVBT },
413413
.info = {
414414
.name = "Conexant CX22700 DVB-T",
415-
.frequency_min = 470000000,
416-
.frequency_max = 860000000,
417-
.frequency_stepsize = 166667,
415+
.frequency_min_hz = 470 * MHz,
416+
.frequency_max_hz = 860 * MHz,
417+
.frequency_stepsize_hz = 166667,
418418
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
419419
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
420420
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |

‎drivers/media/dvb-frontends/cx22702.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,9 @@ static const struct dvb_frontend_ops cx22702_ops = {
622622
.delsys = { SYS_DVBT },
623623
.info = {
624624
.name = "Conexant CX22702 DVB-T",
625-
.frequency_min = 177000000,
626-
.frequency_max = 858000000,
627-
.frequency_stepsize = 166666,
625+
.frequency_min_hz = 177 * MHz,
626+
.frequency_max_hz = 858 * MHz,
627+
.frequency_stepsize_hz = 166666,
628628
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
629629
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
630630
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |

0 commit comments

Comments
 (0)