From patchwork Thu Nov 27 19:42:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olli Salonen X-Patchwork-Id: 5399021 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8B770BEEA8 for ; Thu, 27 Nov 2014 19:42:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9A9420155 for ; Thu, 27 Nov 2014 19:42:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 865FA2016C for ; Thu, 27 Nov 2014 19:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751174AbaK0Tmj (ORCPT ); Thu, 27 Nov 2014 14:42:39 -0500 Received: from mail-la0-f48.google.com ([209.85.215.48]:45226 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbaK0Tmh (ORCPT ); Thu, 27 Nov 2014 14:42:37 -0500 Received: by mail-la0-f48.google.com with SMTP id s18so4574400lam.7 for ; Thu, 27 Nov 2014 11:42:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Lyc5H2cFSc0XgUtqGfuXbCPYR4UP0AamHOZ9wIR8wX4=; b=Cnm/fwpZHrXwnvoTJSPbNOr2+i5yd2Gr//SArmC6rWJlTWU/2dQ+XkdMeQ0x7rOS+Q I+GCi3+dgCtKIl5kL9pwXfVLm6xpv9jvbmX8G3xWJ3MB3GJ/MTnnZeSJtaya9QD/YDDC B4TAUFDMs1t78a+BzQsbM1Ogsc9iBKH77CUt8qEA+STehZ6Yu13VcQeZKDwjj9vLKK6j OpJ6C/wDaUPDUNKho0e1eIpOspvPtx/zaaBla6RZShRaMKTuUSLIYqX7kXtIqoC5ibDM 4bHuO4F8V4uC8Ilnxr+C9j28pIyaWn2bvZIyuKZBiqnqjEU7sTrdM0jboKTbefXQLh1J 706g== X-Gm-Message-State: ALoCoQmRFPafC+IGTR4Evsq7jxAvlg8ClDOd6+GI2jllrBRFA6QbBIaCVaR7jBUtS37vsHSbKjwm X-Received: by 10.112.254.162 with SMTP id aj2mr41118909lbd.70.1417117355829; Thu, 27 Nov 2014 11:42:35 -0800 (PST) Received: from dl160.lan (188-67-15-102.bb.dnainternet.fi. [188.67.15.102]) by mx.google.com with ESMTPSA id eg2sm2083915lbb.29.2014.11.27.11.42.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Nov 2014 11:42:34 -0800 (PST) From: Olli Salonen To: linux-media@vger.kernel.org Cc: Olli Salonen Subject: [PATCH 2/2] si2168: add support for firmware files in new format Date: Thu, 27 Nov 2014 21:42:23 +0200 Message-Id: <1417117343-1793-2-git-send-email-olli.salonen@iki.fi> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417117343-1793-1-git-send-email-olli.salonen@iki.fi> References: <1417117343-1793-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, T_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 This patch adds support for new type of firmware versions of Si2168 chip. Old type: n x 8 bytes (all data, first byte seems to be 04 or 05) New type: n x 17 bytes (1 byte indicates len and max 16 bytes data) New version of TechnoTrend CT2-4400 drivers (http://www.tt-downloads.de/bda-treiber_4.3.0.0.zip) contains newer firmware for Si2168-B40 that is in the new format. It can be extracted with the following command: dd if=ttTVStick4400_64.sys ibs=1 skip=323872 count=6919 of=dvb-demod-si2168-b40-01.fw Signed-off-by: Olli Salonen Reviewed-by: Antti Palosaari --- drivers/media/dvb-frontends/si2168.c | 46 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 6da38e8..ce9ab44 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c @@ -462,20 +462,38 @@ static int si2168_init(struct dvb_frontend *fe) dev_info(&s->client->dev, "downloading firmware from file '%s'\n", fw_file); - for (remaining = fw->size; remaining > 0; remaining -= i2c_wr_max) { - len = remaining; - if (len > i2c_wr_max) - len = i2c_wr_max; - - memcpy(cmd.args, &fw->data[fw->size - remaining], len); - cmd.wlen = len; - cmd.rlen = 1; - ret = si2168_cmd_execute(s, &cmd); - if (ret) { - dev_err(&s->client->dev, - "firmware download failed=%d\n", - ret); - goto error_fw_release; + if ((fw->size % 17 == 0) && (fw->data[0] > 5)) { + /* firmware is in the new format */ + for (remaining = fw->size; remaining > 0; remaining -= 17) { + len = fw->data[fw->size - remaining]; + memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); + cmd.wlen = len; + cmd.rlen = 1; + ret = si2168_cmd_execute(s, &cmd); + if (ret) { + dev_err(&s->client->dev, + "firmware download failed=%d\n", + ret); + goto error_fw_release; + } + } + } else { + /* firmware is in the old format */ + for (remaining = fw->size; remaining > 0; remaining -= i2c_wr_max) { + len = remaining; + if (len > i2c_wr_max) + len = i2c_wr_max; + + memcpy(cmd.args, &fw->data[fw->size - remaining], len); + cmd.wlen = len; + cmd.rlen = 1; + ret = si2168_cmd_execute(s, &cmd); + if (ret) { + dev_err(&s->client->dev, + "firmware download failed=%d\n", + ret); + goto error_fw_release; + } } }