From 95c4cd1d19e3e1d4894457a6f015e3a045bc9b06 Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Thu, 6 Jan 2022 23:49:47 +0100 Subject: media: si2157: fix 6MHz & 6.1MHz bandwidth setting Commit 98c65a3dac95 ("media: si2157: add support for 1.7MHz and 6.1 MHz") introduced two bugs: The 6.1MHz setting was always used for any bandwidth less than 7MHz due to missing "else" keywords, and then the setting was not specified as decimal 10, but as hexadecimal 0x10, which makes the tuner refuse the tune command. In sum, it is not possible to tune to any channels of less than 7MHz bandwidth anymore. Add the missing "else" keywords and convert all bandwidth settings to decimal to avoid any future decimal vs. hexadecimal confusion. Remove the use of the undefined bandwidth setting 0x0f for bandwidths greater than 8MHz, which is also refused by the tune command, in favour of using the default bandwidth setting 8 for any bandwidths greater than 7MHz. Link: https://lore.kernel.org/linux-media/trinity-d0015ea1-1da5-4c7d-a75b-781fb26dc339-1641509387112@3c-app-gmx-bap68 Fixes: 98c65a3dac95 ("media: si2157: add support for 1.7MHz and 6.1 MHz") Reported-by: Robert Schlabbach Signed-off-by: Robert Schlabbach Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/si2157.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'drivers/media') diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 481c5c3b577d..76dc10dd2518 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -459,17 +459,15 @@ static int si2157_set_params(struct dvb_frontend *fe) } if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 1700000) - bandwidth = 0x09; - if (c->bandwidth_hz <= 6000000) - bandwidth = 0x06; - if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 6100000) - bandwidth = 0x10; + bandwidth = 9; + else if (c->bandwidth_hz <= 6000000) + bandwidth = 6; + else if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 6100000) + bandwidth = 10; else if (c->bandwidth_hz <= 7000000) - bandwidth = 0x07; - else if (c->bandwidth_hz <= 8000000) - bandwidth = 0x08; + bandwidth = 7; else - bandwidth = 0x0f; + bandwidth = 8; switch (c->delivery_system) { case SYS_ATSC: -- cgit From 9658105d0e5b1437db161b4227721065d44585b9 Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Thu, 6 Jan 2022 23:51:39 +0100 Subject: media: si2157: fix bandwidth stored in dev Make digital tuning store the bandwidth in Hz in the private dev struct, rather than the hardware-specific bandwidth property code, so that the get_bandwidth() function returns the bandwidth in Hz, just as it already does when using analog tuning. Link: https://lore.kernel.org/linux-media/trinity-931c0e68-88af-46cc-91a1-986754798a4f-1641509499366@3c-app-gmx-bap68 Reported-by: Robert Schlabbach Signed-off-by: Robert Schlabbach Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/si2157.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'drivers/media') diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 76dc10dd2518..b1e00b635dbf 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -446,7 +446,8 @@ static int si2157_set_params(struct dvb_frontend *fe) struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret; struct si2157_cmd cmd; - u8 bandwidth, delivery_system; + u8 bw, delivery_system; + u32 bandwidth; u32 if_frequency = 5000000; dev_dbg(&client->dev, @@ -458,16 +459,22 @@ static int si2157_set_params(struct dvb_frontend *fe) goto err; } - if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 1700000) - bandwidth = 9; - else if (c->bandwidth_hz <= 6000000) - bandwidth = 6; - else if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 6100000) - bandwidth = 10; - else if (c->bandwidth_hz <= 7000000) - bandwidth = 7; - else - bandwidth = 8; + if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 1700000) { + bandwidth = 1700000; + bw = 9; + } else if (c->bandwidth_hz <= 6000000) { + bandwidth = 6000000; + bw = 6; + } else if (SUPPORTS_1700KHz(dev) && c->bandwidth_hz <= 6100000) { + bandwidth = 6100000; + bw = 10; + } else if (c->bandwidth_hz <= 7000000) { + bandwidth = 7000000; + bw = 7; + } else { + bandwidth = 8000000; + bw = 8; + } switch (c->delivery_system) { case SYS_ATSC: @@ -497,7 +504,7 @@ static int si2157_set_params(struct dvb_frontend *fe) } memcpy(cmd.args, "\x14\x00\x03\x07\x00\x00", 6); - cmd.args[4] = delivery_system | bandwidth; + cmd.args[4] = delivery_system | bw; if (dev->inversion) cmd.args[5] = 0x01; cmd.wlen = 6; -- cgit From 8d4ff8187bb2b0c9025269f0da42ed16c878cb18 Mon Sep 17 00:00:00 2001 From: Robert Schlabbach Date: Thu, 6 Jan 2022 23:52:49 +0100 Subject: media: si2157: add support for DVB-C Annex C DVB-C Annex C is mostly DVB-C Annex A with only minor differences, so simply add it to the DVB-C Annex A switch case, so that tuning attempts no longer result in -EINVAL. Link: https://lore.kernel.org/linux-media/trinity-fd7dd9e4-c319-4761-89b6-555fa7b23776-1641509569422@3c-app-gmx-bap68 Signed-off-by: Robert Schlabbach Signed-off-by: Mauro Carvalho Chehab --- drivers/media/tuners/si2157.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/media') diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index b1e00b635dbf..47029746b89e 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -490,6 +490,7 @@ static int si2157_set_params(struct dvb_frontend *fe) delivery_system = 0x20; break; case SYS_DVBC_ANNEX_A: + case SYS_DVBC_ANNEX_C: delivery_system = 0x30; break; case SYS_ISDBT: -- cgit