From patchwork Sun Jul 13 13:52:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olli Salonen X-Patchwork-Id: 4541241 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 B459A9F36A for ; Sun, 13 Jul 2014 13:53:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2A5920158 for ; Sun, 13 Jul 2014 13:53:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16CA420142 for ; Sun, 13 Jul 2014 13:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753496AbaGMNxX (ORCPT ); Sun, 13 Jul 2014 09:53:23 -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 S1752642AbaGMNxX (ORCPT ); Sun, 13 Jul 2014 09:53:23 -0400 Received: from devlin.trsqr.net (84.249.202.144) by jenni2.inet.fi (8.5.140.03) id 53A17F6001E57E78; Sun, 13 Jul 2014 16:53:22 +0300 From: Olli Salonen To: linux-media@vger.kernel.org Cc: Olli Salonen Subject: [PATCH 3/6] si2157: Move chip initialization to si2157_init Date: Sun, 13 Jul 2014 16:52:19 +0300 Message-Id: <1405259542-32529-4-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/tuners/si2157.c | 71 ++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index a4908ee..a92570f9 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -80,12 +80,41 @@ err: static int si2157_init(struct dvb_frontend *fe) { struct si2157 *s = fe->tuner_priv; + int ret; + struct si2157_cmd cmd; dev_dbg(&s->client->dev, "%s:\n", __func__); + /* configure? */ + memcpy(cmd.args, "\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15); + cmd.wlen = 15; + cmd.rlen = 1; + ret = si2157_cmd_execute(s, &cmd); + if (ret) + goto err; + + /* query chip revision */ + memcpy(cmd.args, "\x02", 1); + cmd.wlen = 1; + cmd.rlen = 13; + ret = si2157_cmd_execute(s, &cmd); + if (ret) + goto err; + + /* reboot the tuner with new firmware? */ + memcpy(cmd.args, "\x01\x01", 2); + cmd.wlen = 2; + cmd.rlen = 1; + ret = si2157_cmd_execute(s, &cmd); + if (ret) + goto err; + s->active = true; return 0; +err: + dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret); + return ret; } static int si2157_sleep(struct dvb_frontend *fe) @@ -128,48 +157,8 @@ static int si2157_set_params(struct dvb_frontend *fe) goto err; } - /* configure? */ - cmd.args[0] = 0xc0; - cmd.args[1] = 0x00; - cmd.args[2] = 0x0c; - cmd.args[3] = 0x00; - cmd.args[4] = 0x00; - cmd.args[5] = 0x01; - cmd.args[6] = 0x01; - cmd.args[7] = 0x01; - cmd.args[8] = 0x01; - cmd.args[9] = 0x01; - cmd.args[10] = 0x01; - cmd.args[11] = 0x02; - cmd.args[12] = 0x00; - cmd.args[13] = 0x00; - cmd.args[14] = 0x01; - cmd.wlen = 15; - cmd.rlen = 1; - ret = si2157_cmd_execute(s, &cmd); - if (ret) - goto err; - - cmd.args[0] = 0x02; - cmd.wlen = 1; - cmd.rlen = 13; - ret = si2157_cmd_execute(s, &cmd); - if (ret) - goto err; - - cmd.args[0] = 0x01; - cmd.args[1] = 0x01; - cmd.wlen = 2; - cmd.rlen = 1; - ret = si2157_cmd_execute(s, &cmd); - if (ret) - goto err; - /* set frequency */ - cmd.args[0] = 0x41; - cmd.args[1] = 0x00; - cmd.args[2] = 0x00; - cmd.args[3] = 0x00; + memcpy(cmd.args, "\x41\x00\x00\x00\x00\x00\x00\x00", 8); cmd.args[4] = (c->frequency >> 0) & 0xff; cmd.args[5] = (c->frequency >> 8) & 0xff; cmd.args[6] = (c->frequency >> 16) & 0xff;