From patchwork Wed Dec 1 21:08:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Schlabbach X-Patchwork-Id: 519479 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 E198BC433EF for ; Wed, 1 Dec 2021 21:08:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240310AbhLAVMG (ORCPT ); Wed, 1 Dec 2021 16:12:06 -0500 Received: from mout.gmx.net ([212.227.17.20]:41523 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233009AbhLAVMF (ORCPT ); Wed, 1 Dec 2021 16:12:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1638392923; bh=5kQT9sBIyqU6jfWmldbdSc8NEk1+FTFlNwnqT3U4Cdo=; h=X-UI-Sender-Class:From:To:Subject:Date; b=kp4ldW1zyNb0Os3jyWKFK3DRe3ta2bB4loBn+WUQH/LvQsOu+CLGpMd+tJsDDPUzm Avb4I5g+LkEoAtsFoNjYuH0/9cMqBa58XGRb3hQ9abYuNb1nh5CidSWiXIFh02Z/Sx 4gpprgyFbKlZjHEwF6WbqfTdDFDZz1tjZS6c9DgM= 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-bap03.server.lan [172.19.172.73]) (via HTTP); Wed, 1 Dec 2021 22:08:43 +0100 MIME-Version: 1.0 Message-ID: From: Robert Schlabbach To: linux-media@vger.kernel.org Subject: [PATCH 1/2] media: si2157: Fix "warm" tuner state detection Date: Wed, 1 Dec 2021 22:08:43 +0100 Importance: normal Sensitivity: Norm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lAst+oH9Tko897KAj/u0xnSDyyy9CZ9r2dxoDf1/6LM4iFtGE1L8+ R7Fy0T1v5ER1UWR4a4Z4ZF78nCFBuuUo9bB0GFtOtwnnRDmAXEsYhhmx49783fEG1055iFhsh MtxOmFM Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Commit e955f959ac52 ("media: si2157: Better check for running tuner in init") completely broke the "warm" tuner detection of the si2157 driver due to a simple endian error: The Si2157 CRYSTAL_TRIM property code is 0x0402 and needs to be transmitted LSB first. However, it was inserted MSB first, causing the warm detection to always fail and spam the kernel log with tuner initialization messages each time the DVB frontend device was closed and reopened: [ 312.215682] si2157 16-0060: found a 'Silicon Labs Si2157-A30' [ 312.264334] si2157 16-0060: firmware version: 3.0.5 [ 342.248593] si2157 16-0060: found a 'Silicon Labs Si2157-A30' [ 342.295743] si2157 16-0060: firmware version: 3.0.5 [ 372.328574] si2157 16-0060: found a 'Silicon Labs Si2157-A30' [ 372.385035] si2157 16-0060: firmware version: 3.0.5 Also, the reinitializations were observed disturb _other_ tuners on multi-tuner cards such as the Hauppauge WinTV-QuadHD, leading to missed or errored packets when one of the other DVB frontend devices on that card was opened. Fix the order of the property code bytes to make the warm detection work again, also reducing the tuner initialization message in the kernel log to once per power-on, as well as fixing the interference with other tuners. Fixes: e955f959ac52 ("media: si2157: Better check for running tuner in init") Reported-by: Robert Schlabbach Signed-off-by: Robert Schlabbach --- drivers/media/tuners/si2157.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index fefb2625f655..75ddf7ed1faf 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -90,7 +90,7 @@ static int si2157_init(struct dvb_frontend *fe) dev_dbg(&client->dev, "\n"); /* Try to get Xtal trim property, to verify tuner still running */ - memcpy(cmd.args, "\x15\x00\x04\x02", 4); + memcpy(cmd.args, "\x15\x00\x02\x04", 4); cmd.wlen = 4; cmd.rlen = 4; ret = si2157_cmd_execute(client, &cmd); From patchwork Wed Dec 1 21:10:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Schlabbach X-Patchwork-Id: 520031 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 6CA5FC433F5 for ; Wed, 1 Dec 2021 21:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343959AbhLAVOY (ORCPT ); Wed, 1 Dec 2021 16:14:24 -0500 Received: from mout.gmx.net ([212.227.17.20]:42833 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343850AbhLAVOV (ORCPT ); Wed, 1 Dec 2021 16:14:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1638393058; bh=G/m4pUXesMteg/dAQMb8zecjWGGkgArN7Jlr3i5PTKs=; h=X-UI-Sender-Class:From:To:Subject:Date; b=O3DSoCkLBY0W6fQwhfFtHTpNbwjD+mEWU2Af1DwodEVrZdTge5SQrGLna5k/ijoIu goh2KMcqB/eJ1K82/p/K3GtEWm/aIP4aFmg13m+BlvihCCe4HnpZ+Snm1U9FgfJ/o4 nxkkIAm/JkJ9yjCAprMrrikAKcpOl8RfOKb/pLfk= 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-bap03.server.lan [172.19.172.73]) (via HTTP); Wed, 1 Dec 2021 22:10:58 +0100 MIME-Version: 1.0 Message-ID: From: Robert Schlabbach To: linux-media@vger.kernel.org Subject: [PATCH 2/2] media: si2157: Add optional firmware download Date: Wed, 1 Dec 2021 22:10:58 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:VB9J1qPdsZ7zEpwolO9YZwaPicpo/G9+QzvJhLMFPfZdqQytdsyXwpzUQui7iEesuMnVz P39ZkOnW2s3/G4S4a2qemBbq1JGCaUHcsDeWohmQTkvqglkbWAV9dS/7B9qkf8zJTOYOAq5zGYaR JIve7nT98PqkYkuAKK4wFMnpfXi9ibrjzzgK+JBtGEjjHMPdOuDKrzEwyykNO9mx8iOSWZiqGJgH ltH7K76IxW9lcdJwA3Wxi+8S4RijHEEHsuGr/Dl2FEiOzryq6SRGhgL3I0VnXAYHpcV5CnAsGtjs hU= X-UI-Out-Filterresults: notjunk:1;V03:K0:cv8qIS31eEc=:H5MmPmdGCg3yhCa1qBFPEt /NLHtvisGPTLefb48hS+VKlXrII5axSXcQHoCR76RLH+h7Zc/7VccSyC0vwqMsF8NRKQVnc0k tkmbPqHELzT/sTrQW+WEVdyGeifPDf5yqoU+D5PNfQrknCO56xvRWTMyiRaVnxqukDLj9i84s aikCi1uxhWl7p2V+ixupy6dKFrL4B350uPAgVNsptCnoKxH3pu3oPCtG4P5vGtlhQniCVa7YT dSppjm5k+Xva4Tav5Kb/L/nPjGDYMLtbcnwn55iRDGeA0Ml6PbdlbRRVFhopq1xL/fizxUWaA dTXFKTbgfESg/AP3g/Ok8J4u4g4men2DPb46DI/rT2f4TOdzX4PlsEW/n6LGUe/xgFLYgrl7q iGTz/XjesNcQSEUzeuHkx0stw+BcJPxtA/zUUxF1lm9iBr2kp2MJckeNWRhnUCNbOpX3DI3jM 6NQysjSUvPxndbxo+xmkoDjtIsowF581i68ZDvV9T4bDmlsqqOAVYEkL22H/UvwHHijv21bBg WgJWgGzEg9x2HV01I/XQ2is5p5oPAvFNYzYycc5/5NnlZ7nou3ZykOSorom2dM2asbX5Rdrh3 OqOAIzXxJ88MgJg375UvqkIO21PoLZR/yT6icv+8dCIiJUEHsUgAcxREBORVMsNCjvwCwBtrC mv+w/31SXAsy0iX3HHUn3JtVZbZyiGkl5jaG2tu8j7/zm8s1QT/kdlPStWJZoY+9pzOqvE5fo QonbYN8FJf7C4wxixcXs6jR51zlv44yAfG6KXL0sN0/B6bBhXVItryz1WNNgTU0l6ei/CJb+L sHwTXbN Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The Si2157 (A30) is functional with the ROM firmware 3.0.5, but can also be patched at runtime, e.g. to firmware 3.1.3. However, although a firmware filename for its firmware patch exists, that has only been used for the Si2177 (A30) so far (which indeed takes the binary identical firmware patch). Add support for downloading firmware patches into the Si2157 (A30), but make it optional, so that initialization can succeed with and without a firmware patch being available. Keep the use of request_firmware() for this purpose rather than firmware_request_nowarn(), so that the warning in the log makes users aware that it is possible to provide a firmware for this tuner. The firmware patch is probably also optional for other (if not all) tuners supported by the driver, but since I do not have the others available to test, they are kept mandatory for now to avoid regressions. Signed-off-by: Robert Schlabbach --- drivers/media/tuners/si2157.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 75ddf7ed1faf..757b27d1605a 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -85,6 +85,7 @@ static int si2157_init(struct dvb_frontend *fe) struct si2157_cmd cmd; const struct firmware *fw; const char *fw_name; + unsigned int fw_required; unsigned int chip_id, xtal_trim; dev_dbg(&client->dev, "\n"); @@ -151,6 +152,10 @@ static int si2157_init(struct dvb_frontend *fe) #define SI2146_A10 ('A' << 24 | 46 << 16 | '1' << 8 | '0' << 0) #define SI2141_A10 ('A' << 24 | 41 << 16 | '1' << 8 | '0' << 0) + /* assume firmware is required, unless verified not to be */ + /* only the SI2157_A30 has been verified not to yet */ + fw_required = true; + switch (chip_id) { case SI2158_A20: case SI2148_A20: @@ -159,10 +164,13 @@ static int si2157_init(struct dvb_frontend *fe) case SI2141_A10: fw_name = SI2141_A10_FIRMWARE; break; + case SI2157_A30: + fw_name = SI2157_A30_FIRMWARE; + fw_required = false; + break; case SI2177_A30: fw_name = SI2157_A30_FIRMWARE; break; - case SI2157_A30: case SI2147_A30: case SI2146_A10: fw_name = NULL; @@ -184,6 +192,9 @@ static int si2157_init(struct dvb_frontend *fe) /* request the firmware, this will block and timeout */ ret = request_firmware(&fw, fw_name, &client->dev); if (ret) { + if (!fw_required) + goto skip_fw_download; + dev_err(&client->dev, "firmware file '%s' not found\n", fw_name); goto err;