Skip to content

Commit

Permalink
media: dvb: represent min/max/step/tolerance freqs in Hz
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mchehab committed Aug 2, 2018
1 parent a3f90c7 commit f1b1eab
Show file tree
Hide file tree
Showing 96 changed files with 428 additions and 399 deletions.
6 changes: 3 additions & 3 deletions drivers/media/common/siano/smsdvb-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,9 @@ static void smsdvb_release(struct dvb_frontend *fe)
static const struct dvb_frontend_ops smsdvb_fe_ops = {
.info = {
.name = "Siano Mobile Digital MDTV Receiver",
.frequency_min = 44250000,
.frequency_max = 867250000,
.frequency_stepsize = 250000,
.frequency_min_hz = 44250 * kHz,
.frequency_max_hz = 867250 * kHz,
.frequency_stepsize_hz = 250 * kHz,
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
Expand Down
84 changes: 59 additions & 25 deletions drivers/media/dvb-core/dvb_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,38 +894,64 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
}

static void dvb_frontend_get_frequency_limits(struct dvb_frontend *fe,
u32 *freq_min, u32 *freq_max)
u32 *freq_min, u32 *freq_max,
u32 *tolerance)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
__u32 tuner_min = fe->ops.tuner_ops.info.frequency_min_hz;
__u32 tuner_max = fe->ops.tuner_ops.info.frequency_max_hz;
u32 tuner_min = fe->ops.tuner_ops.info.frequency_min_hz;
u32 tuner_max = fe->ops.tuner_ops.info.frequency_max_hz;
u32 frontend_min = fe->ops.info.frequency_min_hz;
u32 frontend_max = fe->ops.info.frequency_max_hz;

*freq_min = max(frontend_min, tuner_min);

if (frontend_max == 0)
*freq_max = tuner_max;
else if (tuner_max == 0)
*freq_max = frontend_max;
else
*freq_max = min(frontend_max, tuner_max);

if (*freq_min == 0 || *freq_max == 0)
dev_warn(fe->dvb->device,
"DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n",
fe->dvb->num, fe->id);

/* If the standard is for satellite, convert frequencies to kHz */
switch (c->delivery_system) {
case SYS_DVBS:
case SYS_DVBS2:
case SYS_TURBO:
case SYS_ISDBS:
tuner_max /= kHz;
tuner_min /= kHz;
*freq_min /= kHz;
*freq_max /= kHz;
if (tolerance)
*tolerance = fe->ops.info.frequency_tolerance_hz / kHz;

break;
default:
if (tolerance)
*tolerance = fe->ops.info.frequency_tolerance_hz;
break;
}
}

*freq_min = max(fe->ops.info.frequency_min, tuner_min);

if (fe->ops.info.frequency_max == 0)
*freq_max = tuner_max;
else if (tuner_max == 0)
*freq_max = fe->ops.info.frequency_max;
else
*freq_max = min(fe->ops.info.frequency_max, tuner_max);
static u32 dvb_frontend_get_stepsize(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u32 step = fe->ops.info.frequency_stepsize_hz;
switch (c->delivery_system) {
case SYS_DVBS:
case SYS_DVBS2:
case SYS_TURBO:
case SYS_ISDBS:
step /= kHz;
break;
default:
break;
}

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

static int dvb_frontend_check_parameters(struct dvb_frontend *fe)
Expand All @@ -935,7 +961,7 @@ static int dvb_frontend_check_parameters(struct dvb_frontend *fe)
u32 freq_max;

/* range check: frequency */
dvb_frontend_get_frequency_limits(fe, &freq_min, &freq_max);
dvb_frontend_get_frequency_limits(fe, &freq_min, &freq_max, NULL);
if ((freq_min && c->frequency < freq_min) ||
(freq_max && c->frequency > freq_max)) {
dev_warn(fe->dvb->device, "DVB: adapter %i frontend %i frequency %u out of range (%u..%u)\n",
Expand Down Expand Up @@ -2261,8 +2287,8 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
case SYS_ISDBT:
case SYS_DTMB:
fepriv->min_delay = HZ / 20;
fepriv->step_size = fe->ops.info.frequency_stepsize * 2;
fepriv->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
fepriv->step_size = dvb_frontend_get_stepsize(fe) * 2;
fepriv->max_drift = (dvb_frontend_get_stepsize(fe) * 2) + 1;
break;
default:
/*
Expand Down Expand Up @@ -2391,9 +2417,17 @@ static int dvb_frontend_handle_ioctl(struct file *file,

case FE_GET_INFO: {
struct dvb_frontend_info *info = parg;

memcpy(info, &fe->ops.info, sizeof(struct dvb_frontend_info));
dvb_frontend_get_frequency_limits(fe, &info->frequency_min, &info->frequency_max);
memset(info, 0, sizeof(*info));

strcpy(info->name, fe->ops.info.name);
info->symbol_rate_min = fe->ops.info.symbol_rate_min;
info->symbol_rate_max = fe->ops.info.symbol_rate_max;
info->symbol_rate_tolerance = fe->ops.info.symbol_rate_tolerance;
info->caps = fe->ops.info.caps;
info->frequency_stepsize = dvb_frontend_get_stepsize(fe);
dvb_frontend_get_frequency_limits(fe, &info->frequency_min,
&info->frequency_max,
&info->frequency_tolerance);

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

/* Set CAN_INVERSION_AUTO bit on in other than oneshot mode */
if (!(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT))
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/dvb-frontends/af9013.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,10 +1136,9 @@ static const struct dvb_frontend_ops af9013_ops = {
.delsys = { SYS_DVBT },
.info = {
.name = "Afatech AF9013",
.frequency_min = 174000000,
.frequency_max = 862000000,
.frequency_stepsize = 250000,
.frequency_tolerance = 0,
.frequency_min_hz = 174 * MHz,
.frequency_max_hz = 862 * MHz,
.frequency_stepsize_hz = 250 * kHz,
.caps = FE_CAN_FEC_1_2 |
FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 |
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/dvb-frontends/af9033.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,9 @@ static const struct dvb_frontend_ops af9033_ops = {
.delsys = {SYS_DVBT},
.info = {
.name = "Afatech AF9033 (DVB-T)",
.frequency_min = 174000000,
.frequency_max = 862000000,
.frequency_stepsize = 250000,
.frequency_tolerance = 0,
.frequency_min_hz = 174 * MHz,
.frequency_max_hz = 862 * MHz,
.frequency_stepsize_hz = 250 * kHz,
.caps = FE_CAN_FEC_1_2 |
FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 |
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/as102_fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ static const struct dvb_frontend_ops as102_fe_ops = {
.delsys = { SYS_DVBT },
.info = {
.name = "Abilis AS102 DVB-T",
.frequency_min = 174000000,
.frequency_max = 862000000,
.frequency_stepsize = 166667,
.frequency_min_hz = 174 * MHz,
.frequency_max_hz = 862 * MHz,
.frequency_stepsize_hz = 166667,
.caps = FE_CAN_INVERSION_AUTO
| FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4
| FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/atbm8830.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ static const struct dvb_frontend_ops atbm8830_ops = {
.delsys = { SYS_DTMB },
.info = {
.name = "AltoBeam ATBM8830/8831 DMB-TH",
.frequency_min = 474000000,
.frequency_max = 858000000,
.frequency_stepsize = 10000,
.frequency_min_hz = 474 * MHz,
.frequency_max_hz = 858 * MHz,
.frequency_stepsize_hz = 10 * kHz,
.caps =
FE_CAN_FEC_AUTO |
FE_CAN_QAM_AUTO |
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/au8522_dig.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,9 @@ static const struct dvb_frontend_ops au8522_ops = {
.delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
.info = {
.name = "Auvitek AU8522 QAM/8VSB Frontend",
.frequency_min = 54000000,
.frequency_max = 858000000,
.frequency_stepsize = 62500,
.frequency_min_hz = 54 * MHz,
.frequency_max_hz = 858 * MHz,
.frequency_stepsize_hz = 62500,
.caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
},

Expand Down
6 changes: 2 additions & 4 deletions drivers/media/dvb-frontends/bcm3510.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,10 +840,8 @@ static const struct dvb_frontend_ops bcm3510_ops = {
.delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
.info = {
.name = "Broadcom BCM3510 VSB/QAM frontend",
.frequency_min = 54000000,
.frequency_max = 803000000,
/* stepsize is just a guess */
.frequency_stepsize = 0,
.frequency_min_hz = 54 * MHz,
.frequency_max_hz = 803 * MHz,
.caps =
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/cx22700.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ static const struct dvb_frontend_ops cx22700_ops = {
.delsys = { SYS_DVBT },
.info = {
.name = "Conexant CX22700 DVB-T",
.frequency_min = 470000000,
.frequency_max = 860000000,
.frequency_stepsize = 166667,
.frequency_min_hz = 470 * MHz,
.frequency_max_hz = 860 * MHz,
.frequency_stepsize_hz = 166667,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/cx22702.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ static const struct dvb_frontend_ops cx22702_ops = {
.delsys = { SYS_DVBT },
.info = {
.name = "Conexant CX22702 DVB-T",
.frequency_min = 177000000,
.frequency_max = 858000000,
.frequency_stepsize = 166666,
.frequency_min_hz = 177 * MHz,
.frequency_max_hz = 858 * MHz,
.frequency_stepsize_hz = 166666,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/cx24110.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ static const struct dvb_frontend_ops cx24110_ops = {
.delsys = { SYS_DVBS },
.info = {
.name = "Conexant CX24110 DVB-S",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 1011, /* kHz for QPSK frontends */
.frequency_tolerance = 29500,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_stepsize_hz = 1011 * kHz,
.frequency_tolerance_hz = 29500 * kHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.caps = FE_CAN_INVERSION_AUTO |
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/cx24116.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,10 +1465,10 @@ static const struct dvb_frontend_ops cx24116_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 },
.info = {
.name = "Conexant CX24116/CX24118",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 1011, /* kHz for QPSK frontends */
.frequency_tolerance = 5000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_stepsize_hz = 1011 * kHz,
.frequency_tolerance_hz = 5 * MHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.caps = FE_CAN_INVERSION_AUTO |
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/cx24117.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,10 +1622,10 @@ static const struct dvb_frontend_ops cx24117_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 },
.info = {
.name = "Conexant CX24117/CX24132",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 1011, /* kHz for QPSK frontends */
.frequency_tolerance = 5000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_stepsize_hz = 1011 * kHz,
.frequency_tolerance_hz = 5 * MHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.caps = FE_CAN_INVERSION_AUTO |
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/cx24120.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,10 +1555,10 @@ static const struct dvb_frontend_ops cx24120_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 },
.info = {
.name = "Conexant CX24120/CX24118",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 1011, /* kHz for QPSK frontends */
.frequency_tolerance = 5000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_stepsize_hz = 1011 * kHz,
.frequency_tolerance_hz = 5 * MHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.caps = FE_CAN_INVERSION_AUTO |
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/cx24123.c
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,10 @@ static const struct dvb_frontend_ops cx24123_ops = {
.delsys = { SYS_DVBS },
.info = {
.name = "Conexant CX24123/CX24109",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 1011, /* kHz for QPSK frontends */
.frequency_tolerance = 5000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_stepsize_hz = 1011 * kHz,
.frequency_tolerance_hz = 5 * MHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.caps = FE_CAN_INVERSION_AUTO |
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/cxd2820r_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *s)
{
s->min_delay_ms = 500;
s->step_size = fe->ops.info.frequency_stepsize * 2;
s->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
s->step_size = fe->ops.info.frequency_stepsize_hz * 2;
s->max_drift = (fe->ops.info.frequency_stepsize_hz * 2) + 1;

return 0;
}
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/cxd2820r_t2.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *s)
{
s->min_delay_ms = 1500;
s->step_size = fe->ops.info.frequency_stepsize * 2;
s->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
s->step_size = fe->ops.info.frequency_stepsize_hz * 2;
s->max_drift = (fe->ops.info.frequency_stepsize_hz * 2) + 1;

return 0;
}
9 changes: 4 additions & 5 deletions drivers/media/dvb-frontends/cxd2841er.c
Original file line number Diff line number Diff line change
Expand Up @@ -3942,9 +3942,8 @@ static const struct dvb_frontend_ops cxd2841er_dvbs_s2_ops = {
.delsys = { SYS_DVBS, SYS_DVBS2 },
.info = {
.name = "Sony CXD2841ER DVB-S/S2 demodulator",
.frequency_min = 500000,
.frequency_max = 2500000,
.frequency_stepsize = 0,
.frequency_min_hz = 500 * MHz,
.frequency_max_hz = 2500 * MHz,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
.symbol_rate_tolerance = 500,
Expand Down Expand Up @@ -3988,8 +3987,8 @@ static struct dvb_frontend_ops cxd2841er_t_c_ops = {
FE_CAN_HIERARCHY_AUTO |
FE_CAN_MUTE_TS |
FE_CAN_2G_MODULATION,
.frequency_min = 42000000,
.frequency_max = 1002000000,
.frequency_min_hz = 42 * MHz,
.frequency_max_hz = 1002 * MHz,
.symbol_rate_min = 870000,
.symbol_rate_max = 11700000
},
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1833,9 +1833,9 @@ static enum dvbfe_algo cxd2880_get_frontend_algo(struct dvb_frontend *fe)
static struct dvb_frontend_ops cxd2880_dvbt_t2_ops = {
.info = {
.name = "Sony CXD2880",
.frequency_min = 174000000,
.frequency_max = 862000000,
.frequency_stepsize = 1000,
.frequency_min_hz = 174 * MHz,
.frequency_max_hz = 862 * MHz,
.frequency_stepsize_hz = 1 * kHz,
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 |
FE_CAN_FEC_2_3 |
Expand Down
Loading

0 comments on commit f1b1eab

Please sign in to comment.