From patchwork Thu Jan 6 22:49:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Schlabbach X-Patchwork-Id: 530762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2E1CC433F5 for ; Thu, 6 Jan 2022 22:49:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245271AbiAFWtw (ORCPT ); Thu, 6 Jan 2022 17:49:52 -0500 Received: from mout.gmx.net ([212.227.17.21]:54411 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245167AbiAFWtv (ORCPT ); Thu, 6 Jan 2022 17:49:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1641509387; bh=B2ZEmT9Gh5ABnR3Ac9FJbisLyN2YFewVRt3F9UqwsQM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=TH/acN3FlN3+wth//RbNRdy+j1ItbAkzAr+8/3uFWa3sS0QD/X3FJxHfdLJSDI6P2 P0sX667kv4AioXdShS6vmrUfxdFyXAtWkaWwRYnWvYpcx88LBgToKR9X+sN7bhSdtg 3uU5ZKWkCtKa2SZEaHjFOauoCZoIzRYnOl1OjGSg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [91.65.60.26] ([91.65.60.26]) by web-mail.gmx.net (3c-app-gmx-bap68.server.lan [172.19.172.68]) (via HTTP); Thu, 6 Jan 2022 23:49:47 +0100 MIME-Version: 1.0 Message-ID: From: Robert Schlabbach To: linux-media@vger.kernel.org Cc: mchehab@kernel.org Subject: [PATCH 1/3] media: si2157: fix 6MHz & 6.1MHz bandwidth setting Date: Thu, 6 Jan 2022 23:49:47 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:dYXUa1myVh1tNHmF2rCOtvFXnvLkJc2lNeFnm77LIblQjUcbuf850AZelwe7tWEzW++vY dXL5lJR/f9xpkOUvA+p/i9qX86smXJ3aPZwyK35Q3i8ua3OerXZRi8Bt10oUunuWslujPUqBh/8n Ja0dxvYPfQqWuvDAsUh8SO0B8IrjBcaN2bHzJhsagFwkw01c+xC+FAMfv5d5HqTSZgB5wzsf/Hem kVEkrdGXYH9VMmxGZreUiRY4AlHfcwG/DwEKLhUP30JFEUxGEgyqldDVenF8KRKiLgMLWD9bbYOX tE= X-UI-Out-Filterresults: notjunk:1;V03:K0:svet0m3gs/w=:E8nV6wj7mnCDoo7ZHkWVUo guGq3ZzUJ2C/cNNy9dVa8Xy3rK++ouWGTCV79F98WSV/oUhed3UiPWGrMRsxGJk5rlZ3/x6/w ovYZ5P691yCO2gU2dSOxtNXVIzVgtHaDc3WNC+vjUPPPKdlVwBXJwNy/+TbOCibPUq5rhGUyv byDo6b//GdcJNlwYPuHFbP4kO6wIEOc9ZrutM6mvBkuleClpwe/7iArEaAKN2HU8kORVFmK/H JS3vsiSWRwu6uNSlQ37K9ihV+zgipEzspM6itxBTN6vhrNESJg7x/4tYBXYAOfsAKJvuUqEnW +UMv1xau87abjC3GbZynf6SUtFQNKLLKzkDaru32nlwQf7u6JkhacgOWhIqQYoywwFZ1ncM71 yV7MzpJOwI7Ss1Z+7cYELpiUoygKL0/m19tm7T9fDdkaUkrL5vtIQl4IOr7fXkvHUECzUAA51 bph392bLp/YvO+Zgy8M5e/dDqSe5klykm+6jjF2tcu55hJBsP2lHTAxKpoMQ5HtJelCDJZ9u/ yoWgUCLn6gdXylEL8nPgNdJSwgW/VTVBPhpjmADCKS/tRsoyztPjnDdHLuDYYcUDo9DwZc1I2 g34fqzmRnJQHA7tT/qokjoYbKCjDUsG/BxE3WYc3HoydP/2cWsWxpVzPaJ5yTC9Mt1LQMlyvK uxHhaMkXha9OoAD2SdDxEetLgcbElgXm1DU1ByDTRVq7ihaEqSOiOXA0A6buqxDiK58j4Xx51 pYPEnWs8rrAW/wGM6FLroJtoPnTkQ2UEm+R0tPNFwiBZWCXJ0v3wQgAhkOmgx+NlCnblrCeai cmoapD+ Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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. Fixes: 98c65a3dac95 ("media: si2157: add support for 1.7MHz and 6.1 MHz") Reported-by: Robert Schlabbach Signed-off-by: Robert Schlabbach --- drivers/media/tuners/si2157.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.17.1 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: From patchwork Thu Jan 6 22:51:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Schlabbach X-Patchwork-Id: 530418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C73FC433EF for ; Thu, 6 Jan 2022 22:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245283AbiAFWvo (ORCPT ); Thu, 6 Jan 2022 17:51:44 -0500 Received: from mout.gmx.net ([212.227.17.20]:33093 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245279AbiAFWvn (ORCPT ); Thu, 6 Jan 2022 17:51:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1641509499; bh=AL6ELuGvESOTCneu0XvbjXIp415GjO8nACjeZHMPuyI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=cOr10opSE2BMwiGZsGardZLssZLyw3yNXkEnhJpv3Q50n3AjgaZR1eOOsL6257wEa rsPHk3frSmW2ozXXsp87Y/04JFJFgCit+svkB99ndpnQ44W//2Gw0i14LUlbhORBm/ ffyMD5omYFvYOJOJ/Qt+Kj95kZTxkffB2rOwJMEQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [91.65.60.26] ([91.65.60.26]) by web-mail.gmx.net (3c-app-gmx-bap68.server.lan [172.19.172.68]) (via HTTP); Thu, 6 Jan 2022 23:51:39 +0100 MIME-Version: 1.0 Message-ID: From: Robert Schlabbach To: linux-media@vger.kernel.org Cc: mchehab@kernel.org Subject: [PATCH 2/3] media: si2157: fix bandwidth stored in dev Date: Thu, 6 Jan 2022 23:51:39 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:8f7UHs1w3+HIZW1VqwYJq4Mei2zePxS2KS3OUdpzsvHBLqJm2xGbUIZutZR3ZGBFqDD7a pObJLKm+D3XBx78Hb6wTOOYIq6pM3lf43y99t9sQGecJT6glZHR3vqSvDxqxD6YX9Rb2WeKaEbOE LMxVMai1FgC1xXNH+bBZlvQ22j7EJ6C38qTKB8P7spskmIUHTRUoCIDMjkVBL+LxZFbKpQMY0oBH +bijISeGHhUeNmrY1XowrI4xIyJjXfusE93MNxJM4K8unWsrbbL9n5K48F0MM+ZddGrW51enIgIr M8= X-UI-Out-Filterresults: notjunk:1;V03:K0:jWJbbwCC5+s=:lj0GtpJNY0YGwWykZrEYl0 LfstOCZfnkdgKmYSV6ivRiz4imegIjWVAXwt0FawAPFT8Oy8tFCajmuJJyp7uCIINIqEJiJJ9 KsxdPoAeG33AtU/Kc9TwjxhjKh7A5UN1HWbw5vw7xDwD+cf47R31kvyWbZP+vVYAQPZDjYGwe KpJ3Pi07M0fD+omKoCpxAE6l3CfJ+6BcdSqOWcEuQVHwS2xm3Ra/Xbv4fvNmVGqozjP61cl9O DO2n4rb9ZWiAJBjGJl2y15FCZ3quKaGT6y7eAPp2F8LEULOSlbSEqHrgPfq024g5v5TI2z9ji QUW2/eg+O0iVcllh/uP2Gt9BHGqUemf3dkiMg+dpqYE5WepFk1Llti2AX73y1jg5QnJKey5BN vCIaNbK3o7mjEE1PN6Gx5INT4lO8Q7ZsDFQ3Bu1R3vij4ozEU9Md9nt1Ec0z4vASxvTh6+CIR dKwc2qkjXIGO4i1w1AbO2ZQhzh1sUcKk9RQxDpx1KN5GJL0UDnYTdpwDWRUjkrh16EZ3hBfWa P1cxOZAPojeWFeGuJQ9EQEDKg5qNwkvnnB7ftrA2K7yeSbET1uWBxEODocseFn7DvAumTHQrp fk85Lw07DCCN0n6ihWTKDEEh/ZJR7XR1Mi1c74smsO94y2GnnWLP1zFhjbPLeRuY+hDMbAumX QCBnSPnL9MLb9pAIwSH8Rp6MYqchLDyfk5nxOndMhumRcbMhDQn1798H/qBtekBYlE0ZINIZG dQQIjP5XovcxiQ8eI8bhEzszGzLOqmes7v6cjuiyV36B4Y9HWmOSDcy0ZNL+gw2MWyVpSqR1d b9aVYzS Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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. Reported-by: Robert Schlabbach Signed-off-by: Robert Schlabbach --- drivers/media/tuners/si2157.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) -- 2.17.1 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; From patchwork Thu Jan 6 22:52:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Schlabbach X-Patchwork-Id: 530761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB3DDC433EF for ; Thu, 6 Jan 2022 22:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245283AbiAFWwy (ORCPT ); Thu, 6 Jan 2022 17:52:54 -0500 Received: from mout.gmx.net ([212.227.17.22]:43707 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245250AbiAFWwx (ORCPT ); Thu, 6 Jan 2022 17:52:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1641509569; bh=OFJIwTYCdIIXZtQINVCM1irJhNraFWh3Qx/pLhuoMlo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=NsXsA0/BuAfX5G5E11pqWJkr7GLwNOWn2y7CSiVZyg/2YFxIZ5GQFijAZjvoRjWs8 9EYt7fJrd9dLNabRbztRvHLseoHE363URzIfK4A19qaAYHV2hJ/5qFEVNnUH9xVTm1 98lHG4X5c8B5aGRFKRXZGi8LtgI+mp+weP8kN4q0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [91.65.60.26] ([91.65.60.26]) by web-mail.gmx.net (3c-app-gmx-bap68.server.lan [172.19.172.68]) (via HTTP); Thu, 6 Jan 2022 23:52:49 +0100 MIME-Version: 1.0 Message-ID: From: Robert Schlabbach To: linux-media@vger.kernel.org Cc: mchehab@kernel.org Subject: [PATCH 3/3] media: si2157: add support for DVB-C Annex C Date: Thu, 6 Jan 2022 23:52:49 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:zZML3Fv1pUO8KwmKzCCpStxV1uwCQgnZehFoq24QiEPXxk3HpEPEpX5E+uvV3h6sMk8EF PoNJyIvm9qcjvZCBXZU20HL8ZIV+Xv6j33JPY0G1yVh81R7iUA1UYhpwl9InTb6QUGq8hetdRoA0 UM/RRjrau7YabM1TtJH/0ciLkxoIVGbj0PZ2CYEEhvgwEdF5jJ1Yg1sA6B0mBei4hcvrzZ3PcCLi pCF1Dst59xJJLKhM9SIvFkpycRzrgZbHG4p23dK0wQkvIF6Y0QWbzSSXrB243sPHvMuh4/ytOCyB 7U= X-UI-Out-Filterresults: notjunk:1;V03:K0:VJWNVLw/3qs=:8szHsvz8c1EDKAr7d1v5Sm Uu9tHvpZsOPsQg8H1onnB6Mwxs6FfQrwukR00+exozaJQNm+2MSzy5R8LHPSkAPXBhnM0Nngr 57y9SCPmGRvWyNdiyyfS1U5oKaLzjxRFyY/TDpku2gifXK4n4PtmKDBDwDH25JJOnaWCSvih/ xomBwCSy8f5IFEWfDNTSqjT7lFIQOOVYj/OHI0NPouFHJqW13MzaH45LK21gIoLbPtOzr25D9 THdbbnjD17iP7nEPRQRpUHlXmMIXohFb2yOkmqIhFFsX7RreiIzbb5poB9xtzC5sAIoDhC3o1 b/cv35UM0H48pQdhazo6QMLGJr00QyR5k8N8ty3lvs7ubianxHhh7IYj4kyfUs2yxBtKLKWQD PtCog96R+RTDn0T3fSXkMv+e4ud2o20Hlg49LscneGtVW5J45LSq1CfOflVRSMkNE7NTxKNM+ Odt4o9n5WZTFJJ3FiO+uuUmdlz1Av3n4gV5nPgSGfp0uQLSOWzPG39G0tTm1rHqfYrN6uqxL2 54TBJHrl/oHwOdxy+McdD5kDsD1fLrOb1RT/3uExwzvWWxJtj7d0LZ4fRcj4l+ROqO2SW9jHq wPEDAmdIp+XmOFX0lt/XTwoyo+YLMxp1hV2Q7D7wqgQySCDH3FWkLq7QoHYeC3l4HHsP6T3k7 +ScicnF53p++wPS3hjf0M5WeS8tgdhdJflejC3RDehzUKBDfsdqsFVKe3SCwteJAbdzvZHRqb +bKDb0VrCF2CLZl654VvF0h2EMkumQc2BmatQ8uAP0Z8tjIZDwxFFGZ2CyO0XTqQiE9gPCjTm 5XLgNoL Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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. Signed-off-by: Robert Schlabbach --- drivers/media/tuners/si2157.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 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: