From patchwork Sun Jul 13 13:52:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olli Salonen X-Patchwork-Id: 4541231 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 271459F36A for ; Sun, 13 Jul 2014 13:53:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E67D20158 for ; Sun, 13 Jul 2014 13:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CBAB20142 for ; Sun, 13 Jul 2014 13:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbaGMNxG (ORCPT ); Sun, 13 Jul 2014 09:53:06 -0400 Received: from mta-out1.inet.fi ([62.71.2.198]:59350 "EHLO jenni2.inet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbaGMNxE (ORCPT ); Sun, 13 Jul 2014 09:53:04 -0400 Received: from devlin.trsqr.net (84.249.202.144) by jenni2.inet.fi (8.5.140.03) id 53A17F6001E57DAD; Sun, 13 Jul 2014 16:53:03 +0300 From: Olli Salonen To: linux-media@vger.kernel.org Cc: Olli Salonen Subject: [PATCH 2/6] si2168: Add handling for different chip revisions and firmwares Date: Sun, 13 Jul 2014 16:52:18 +0300 Message-Id: <1405259542-32529-3-git-send-email-olli.salonen@iki.fi> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405259542-32529-1-git-send-email-olli.salonen@iki.fi> References: <1405259542-32529-1-git-send-email-olli.salonen@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Olli Salonen --- drivers/media/dvb-frontends/si2168.c | 34 ++++++++++++++++++++++++++----- drivers/media/dvb-frontends/si2168_priv.h | 4 +++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index bae7771..268fce3 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c @@ -333,7 +333,7 @@ static int si2168_init(struct dvb_frontend *fe) struct si2168 *s = fe->demodulator_priv; int ret, len, remaining; const struct firmware *fw = NULL; - u8 *fw_file = SI2168_FIRMWARE; + u8 *fw_file; const unsigned int i2c_wr_max = 8; struct si2168_cmd cmd; @@ -353,6 +353,7 @@ static int si2168_init(struct dvb_frontend *fe) if (ret) goto err; + /* query chip revision */ memcpy(cmd.args, "\x02", 1); cmd.wlen = 1; cmd.rlen = 13; @@ -360,6 +361,20 @@ static int si2168_init(struct dvb_frontend *fe) if (ret) goto err; + if (((cmd.args[1] & 0x0f) == 2) && (cmd.args[3] == '4') && + (cmd.args[4] == '0')) + fw_file = SI2168_B40_FIRMWARE; + else if (((cmd.args[1] & 0x0f) == 1) && (cmd.args[3] == '3') && + (cmd.args[4] == '0')) + fw_file = SI2168_A30_FIRMWARE; + else { + dev_err(&s->client->dev, + "%s: no firmware file for Si2168-%c%c defined\n", + KBUILD_MODNAME, cmd.args[3], cmd.args[4]); + ret = -EINVAL; + goto err; + } + /* cold state - try to download firmware */ dev_info(&s->client->dev, "%s: found a '%s' in cold state\n", KBUILD_MODNAME, si2168_ops.info.name); @@ -367,9 +382,18 @@ static int si2168_init(struct dvb_frontend *fe) /* request the firmware, this will block and timeout */ ret = request_firmware(&fw, fw_file, &s->client->dev); if (ret) { - dev_err(&s->client->dev, "%s: firmare file '%s' not found\n", - KBUILD_MODNAME, fw_file); - goto err; + /* fallback mechanism to handle old name for + SI2168_B40_FIRMWARE */ + if (((cmd.args[1] & 0x0f) == 2) && (cmd.args[3] == '4') && + (cmd.args[4] == '0')) { + fw_file = SI2168_B40_FIRMWARE_FALLBACK; + ret = request_firmware(&fw, fw_file, &s->client->dev); + } + if (ret) { + dev_err(&s->client->dev, "%s: firmware file '%s' not found\n", + KBUILD_MODNAME, fw_file); + goto err; + } } dev_info(&s->client->dev, "%s: downloading firmware from file '%s'\n", @@ -629,4 +653,4 @@ module_i2c_driver(si2168_driver); MODULE_AUTHOR("Antti Palosaari "); MODULE_DESCRIPTION("Silicon Labs Si2168 DVB-T/T2/C demodulator driver"); MODULE_LICENSE("GPL"); -MODULE_FIRMWARE(SI2168_FIRMWARE); +MODULE_FIRMWARE(SI2168_B40_FIRMWARE); diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h index 97f9d87..bebb68a 100644 --- a/drivers/media/dvb-frontends/si2168_priv.h +++ b/drivers/media/dvb-frontends/si2168_priv.h @@ -22,7 +22,9 @@ #include #include -#define SI2168_FIRMWARE "dvb-demod-si2168-02.fw" +#define SI2168_A30_FIRMWARE "dvb-demod-si2168-a30-01.fw" +#define SI2168_B40_FIRMWARE "dvb-demod-si2168-b40-01.fw" +#define SI2168_B40_FIRMWARE_FALLBACK "dvb-demod-si2168-02.fw" /* state struct */ struct si2168 {