Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3f90c75 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: dvb: convert tuner_info frequencies to Hz



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: default avatarKatsuhiro Suzuki <suzuki.katsuhiro@socionext.com>
Acked-by: default avatarMichael Büsch <m@bues.ch>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 6706fe55
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -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,
+3 −3
Original line number Diff line number Diff line
@@ -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,
+4 −4
Original line number Diff line number Diff line
@@ -534,9 +534,9 @@ 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,
		.frequency_min_hz  =  950 * MHz,
		.frequency_max_hz  = 2150 * MHz,
		.frequency_step_hz =  125 * kHz,
	},

	.release       = cx24113_release,
+4 −4
Original line number Diff line number Diff line
@@ -727,9 +727,9 @@ 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,
		.frequency_min_hz  =  45 * MHz,
		.frequency_max_hz  = 860 * MHz,
		.frequency_step_hz =   1 * kHz,
	},
	.release       = dib0070_release,

+6 −6
Original line number Diff line number Diff line
@@ -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,

@@ -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,

Loading