Skip to content

Commit

Permalink
media: dvb: convert tuner_info frequencies to Hz
Browse files Browse the repository at this point in the history
Right now, satellite tuner drivers specify frequencies in kHz,
while terrestrial/cable ones specify in Hz. That's confusing
for developers.

However, the main problem is that universal tuners 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 tuners.

So, convert everything to specify tuner frequencies in Hz.

Plese notice that a similar patch is also needed for frontends.

Tested-by: Katsuhiro Suzuki <[email protected]>
Acked-by: Michael Büsch <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
mchehab committed Aug 2, 2018
1 parent 6706fe5 commit a3f90c7
Show file tree
Hide file tree
Showing 54 changed files with 221 additions and 196 deletions.
25 changes: 21 additions & 4 deletions drivers/media/dvb-core/dvb_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,14 +896,31 @@ 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)
{
*freq_min = max(fe->ops.info.frequency_min, fe->ops.tuner_ops.info.frequency_min);
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;

/* 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;
break;
default:
break;
}

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

if (fe->ops.info.frequency_max == 0)
*freq_max = fe->ops.tuner_ops.info.frequency_max;
else if (fe->ops.tuner_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, fe->ops.tuner_ops.info.frequency_max);
*freq_max = min(fe->ops.info.frequency_max, tuner_max);

if (*freq_min == 0 || *freq_max == 0)
dev_warn(fe->dvb->device,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/ascot2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ static int ascot2e_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops ascot2e_tuner_ops = {
.info = {
.name = "Sony ASCOT2E",
.frequency_min = 1000000,
.frequency_max = 1200000000,
.frequency_step = 25000,
.frequency_min_hz = 1 * MHz,
.frequency_max_hz = 1200 * MHz,
.frequency_step_hz = 25 * kHz,
},
.init = ascot2e_init,
.release = ascot2e_release,
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/cx24113.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,10 @@ static void cx24113_release(struct dvb_frontend *fe)

static const struct dvb_tuner_ops cx24113_tuner_ops = {
.info = {
.name = "Conexant CX24113",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 125,
.name = "Conexant CX24113",
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_step_hz = 125 * kHz,
},

.release = cx24113_release,
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/dib0070.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,10 @@ static void dib0070_release(struct dvb_frontend *fe)

static const struct dvb_tuner_ops dib0070_ops = {
.info = {
.name = "DiBcom DiB0070",
.frequency_min = 45000000,
.frequency_max = 860000000,
.frequency_step = 1000,
.name = "DiBcom DiB0070",
.frequency_min_hz = 45 * MHz,
.frequency_max_hz = 860 * MHz,
.frequency_step_hz = 1 * kHz,
},
.release = dib0070_release,

Expand Down
12 changes: 6 additions & 6 deletions drivers/media/dvb-frontends/dib0090.c
Original file line number Diff line number Diff line change
Expand Up @@ -2578,9 +2578,9 @@ static int dib0090_set_params(struct dvb_frontend *fe)
static const struct dvb_tuner_ops dib0090_ops = {
.info = {
.name = "DiBcom DiB0090",
.frequency_min = 45000000,
.frequency_max = 860000000,
.frequency_step = 1000,
.frequency_min_hz = 45 * MHz,
.frequency_max_hz = 860 * MHz,
.frequency_step_hz = 1 * kHz,
},
.release = dib0090_release,

Expand All @@ -2593,9 +2593,9 @@ static const struct dvb_tuner_ops dib0090_ops = {
static const struct dvb_tuner_ops dib0090_fw_ops = {
.info = {
.name = "DiBcom DiB0090",
.frequency_min = 45000000,
.frequency_max = 860000000,
.frequency_step = 1000,
.frequency_min_hz = 45 * MHz,
.frequency_max_hz = 860 * MHz,
.frequency_step_hz = 1 * kHz,
},
.release = dib0090_release,

Expand Down
16 changes: 14 additions & 2 deletions drivers/media/dvb-frontends/dvb-pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
struct dvb_pll_priv *priv = NULL;
int ret;
const struct dvb_pll_desc *desc;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;

b1 = kmalloc(1, GFP_KERNEL);
if (!b1)
Expand Down Expand Up @@ -844,8 +845,19 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,

strncpy(fe->ops.tuner_ops.info.name, desc->name,
sizeof(fe->ops.tuner_ops.info.name));
fe->ops.tuner_ops.info.frequency_min = desc->min;
fe->ops.tuner_ops.info.frequency_max = desc->max;
switch (c->delivery_system) {
case SYS_DVBS:
case SYS_DVBS2:
case SYS_TURBO:
case SYS_ISDBS:
fe->ops.tuner_ops.info.frequency_min_hz = desc->min * kHz;
fe->ops.tuner_ops.info.frequency_max_hz = desc->max * kHz;
break;
default:
fe->ops.tuner_ops.info.frequency_min_hz = desc->min;
fe->ops.tuner_ops.info.frequency_max_hz = desc->max;
}

if (!desc->initdata)
fe->ops.tuner_ops.init = NULL;
if (!desc->sleepdata)
Expand Down
12 changes: 6 additions & 6 deletions drivers/media/dvb-frontends/helene.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,9 @@ static int helene_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops helene_tuner_ops = {
.info = {
.name = "Sony HELENE Ter tuner",
.frequency_min = 1000000,
.frequency_max = 1200000000,
.frequency_step = 25000,
.frequency_min_hz = 1 * MHz,
.frequency_max_hz = 1200 * MHz,
.frequency_step_hz = 25 * kHz,
},
.init = helene_init,
.release = helene_release,
Expand All @@ -860,9 +860,9 @@ static const struct dvb_tuner_ops helene_tuner_ops = {
static const struct dvb_tuner_ops helene_tuner_ops_s = {
.info = {
.name = "Sony HELENE Sat tuner",
.frequency_min = 500000,
.frequency_max = 2500000,
.frequency_step = 1000,
.frequency_min_hz = 500 * MHz,
.frequency_max_hz = 2500 * MHz,
.frequency_step_hz = 1 * MHz,
},
.init = helene_init,
.release = helene_release,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/horus3a.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ static int horus3a_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops horus3a_tuner_ops = {
.info = {
.name = "Sony Horus3a",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 1000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_step_hz = 1 * MHz,
},
.init = horus3a_init,
.release = horus3a_release,
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/dvb-frontends/itd1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ static void itd1000_release(struct dvb_frontend *fe)

static const struct dvb_tuner_ops itd1000_tuner_ops = {
.info = {
.name = "Integrant ITD1000",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 125, /* kHz for QPSK frontends */
.name = "Integrant ITD1000",
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_step_hz = 125 * kHz,
},

.release = itd1000_release,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/ix2505v.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ static int ix2505v_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops ix2505v_tuner_ops = {
.info = {
.name = "Sharp IX2505V (B0017)",
.frequency_min = 950000,
.frequency_max = 2175000
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2175 * MHz
},
.release = ix2505v_release,
.set_params = ix2505v_set_params,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/stb6000.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ static int stb6000_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops stb6000_tuner_ops = {
.info = {
.name = "ST STB6000",
.frequency_min = 950000,
.frequency_max = 2150000
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz
},
.release = stb6000_release,
.sleep = stb6000_sleep,
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/dvb-frontends/stb6100.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,8 @@ static int stb6100_set_params(struct dvb_frontend *fe)
static const struct dvb_tuner_ops stb6100_ops = {
.info = {
.name = "STB6100 Silicon Tuner",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 0,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
},

.init = stb6100_init,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/stv6110.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ static int stv6110_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
static const struct dvb_tuner_ops stv6110_tuner_ops = {
.info = {
.name = "ST STV6110",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 1000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_step_hz = 1 * MHz,
},
.init = stv6110_init,
.release = stv6110_release,
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/dvb-frontends/stv6110x.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,9 @@ static void stv6110x_release(struct dvb_frontend *fe)

static const struct dvb_tuner_ops stv6110x_ops = {
.info = {
.name = "STV6110(A) Silicon Tuner",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 0,
.name = "STV6110(A) Silicon Tuner",
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
},
.release = stv6110x_release
};
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/dvb-frontends/stv6111.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,8 @@ static int get_rf_strength(struct dvb_frontend *fe, u16 *st)
static const struct dvb_tuner_ops tuner_ops = {
.info = {
.name = "ST STV6111",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 0
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
},
.set_params = set_params,
.release = release,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/tda18271c2dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,9 @@ static int get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
static const struct dvb_tuner_ops tuner_ops = {
.info = {
.name = "NXP TDA18271C2D",
.frequency_min = 47125000,
.frequency_max = 865000000,
.frequency_step = 62500
.frequency_min_hz = 47125 * kHz,
.frequency_max_hz = 865 * MHz,
.frequency_step_hz = 62500
},
.init = init,
.sleep = sleep,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/tda665x.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ struct dvb_frontend *tda665x_attach(struct dvb_frontend *fe,
info = &fe->ops.tuner_ops.info;

memcpy(info->name, config->name, sizeof(config->name));
info->frequency_min = config->frequency_min;
info->frequency_max = config->frequency_max;
info->frequency_step = config->frequency_offst;
info->frequency_min_hz = config->frequency_min;
info->frequency_max_hz = config->frequency_max;
info->frequency_step_hz = config->frequency_offst;

printk(KERN_DEBUG "%s: Attaching TDA665x (%s) tuner\n", __func__, info->name);

Expand Down
9 changes: 4 additions & 5 deletions drivers/media/dvb-frontends/tda8261.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ static void tda8261_release(struct dvb_frontend *fe)
static const struct dvb_tuner_ops tda8261_ops = {

.info = {
.name = "TDA8261",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 0
.name = "TDA8261",
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
},

.set_params = tda8261_set_params,
Expand All @@ -190,7 +189,7 @@ struct dvb_frontend *tda8261_attach(struct dvb_frontend *fe,
fe->tuner_priv = state;
fe->ops.tuner_ops = tda8261_ops;

fe->ops.tuner_ops.info.frequency_step = div_tab[config->step_size];
fe->ops.tuner_ops.info.frequency_step_hz = div_tab[config->step_size] * kHz;

pr_info("%s: Attaching TDA8261 8PSK/QPSK tuner\n", __func__);

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/tda826x.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ static int tda826x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops tda826x_tuner_ops = {
.info = {
.name = "Philips TDA826X",
.frequency_min = 950000,
.frequency_max = 2175000
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2175 * MHz
},
.release = tda826x_release,
.sleep = tda826x_sleep,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/ts2020.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ static int ts2020_read_signal_strength(struct dvb_frontend *fe,
static const struct dvb_tuner_ops ts2020_tuner_ops = {
.info = {
.name = "TS2020",
.frequency_min = 950000,
.frequency_max = 2150000
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz
},
.init = ts2020_init,
.release = ts2020_release,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb-frontends/tua6100.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ static int tua6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static const struct dvb_tuner_ops tua6100_tuner_ops = {
.info = {
.name = "Infineon TUA6100",
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_step = 1000,
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2150 * MHz,
.frequency_step_hz = 1 * MHz,
},
.release = tua6100_release,
.sleep = tua6100_sleep,
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb-frontends/zl10036.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ static int zl10036_init(struct dvb_frontend *fe)
static const struct dvb_tuner_ops zl10036_tuner_ops = {
.info = {
.name = "Zarlink ZL10036",
.frequency_min = 950000,
.frequency_max = 2175000
.frequency_min_hz = 950 * MHz,
.frequency_max_hz = 2175 * MHz
},
.init = zl10036_init,
.release = zl10036_release,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/tuners/e4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ static int e4000_dvb_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)

static const struct dvb_tuner_ops e4000_dvb_tuner_ops = {
.info = {
.name = "Elonics E4000",
.frequency_min = 174000000,
.frequency_max = 862000000,
.name = "Elonics E4000",
.frequency_min_hz = 174 * MHz,
.frequency_max_hz = 862 * MHz,
},

.init = e4000_dvb_init,
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/tuners/fc0011.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ static int fc0011_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)

static const struct dvb_tuner_ops fc0011_tuner_ops = {
.info = {
.name = "Fitipower FC0011",
.name = "Fitipower FC0011",

.frequency_min = 45000000,
.frequency_max = 1000000000,
.frequency_min_hz = 45 * MHz,
.frequency_max_hz = 1000 * MHz,
},

.release = fc0011_release,
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/tuners/fc0012.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,10 @@ static int fc0012_get_rf_strength(struct dvb_frontend *fe, u16 *strength)

static const struct dvb_tuner_ops fc0012_tuner_ops = {
.info = {
.name = "Fitipower FC0012",
.name = "Fitipower FC0012",

.frequency_min = 37000000, /* estimate */
.frequency_max = 862000000, /* estimate */
.frequency_step = 0,
.frequency_min_hz = 37 * MHz, /* estimate */
.frequency_max_hz = 862 * MHz, /* estimate */
},

.release = fc0012_release,
Expand Down
Loading

0 comments on commit a3f90c7

Please sign in to comment.