From patchwork Sat May 12 18:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hollstegge X-Patchwork-Id: 10395963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C391F60215 for ; Sat, 12 May 2018 18:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B258928F86 for ; Sat, 12 May 2018 18:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4FBD28F95; Sat, 12 May 2018 18:25:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F96428F86 for ; Sat, 12 May 2018 18:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbeELSZQ (ORCPT ); Sat, 12 May 2018 14:25:16 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53683 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbeELSZP (ORCPT ); Sat, 12 May 2018 14:25:15 -0400 Received: by mail-wm0-f66.google.com with SMTP id a67-v6so7220006wmf.3; Sat, 12 May 2018 11:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Fk/8/6n9XRP/qxxNzcmRop7GRFPWv9JzAVDNffRy2yg=; b=tEmdWnngB+aTkHKSaDqHam9LWWfv5smCK8LaMOs14rqyaJQPhFyBVfxDPl8zWvG+bZ X1KdhfcRTgk/3yW9lFIjltn0no9aApXz0Ciuxv8tKcIdHQ6XakI/kMkn1cV0P7POhmQC ZFh/qlynMceq9qALRXg9Tv4sxdwBihl7NWba9iyZA0G1YEwkZ3DCtbYiSvbqDxxD6xcF Q62QZFs/N5EHQ5FRBkY25jdUaSlEvtllUMLjW4C/7c1INWrlSxye6Ccd9pttOOgJo1VS Q54485WtqlJ7LUc+sdBTeQhlqJ4QvkiKJ3o59+M527NiD3TXE7Wn3RGUkm46NSbzh94x veNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Fk/8/6n9XRP/qxxNzcmRop7GRFPWv9JzAVDNffRy2yg=; b=gzwRxDxAMGZEWnOaQUjk8QocWxv7jCFpLEOFyH8km7KdeybgK5S5BbqXLGexI2y8IZ w60+4LORLZySL/R74127QovZA+C5XxDtl+timW6Zj8nY7vZIsGWUgCMRXT4dvF6PR24u TcGpMXQha47j2zXEI+tp7/royNikjWZRwEbUHZZv5pAfz9qv4p5KygQaq+K4fGqaTcqh 7sbshyjK9j8SOtnougzI2440LQeaEvheXVYINqAYUBogVvyK8HhxUCPNOgQd8yEheetw 5HjGfJIsRHrb+PAtIxJ21qEV61x966KE8IZV+gRGhtmkzTT3MXy0iaoIQ9osxVwZ3dme niAw== X-Gm-Message-State: ALKqPwcLon96F4q/u72QlaBZEHfTrYlJxgdB8eEzVKN0ABp5arMU1jLk fA7WPL75QsB+FP+oabt+1j2Zo/XvBoM= X-Google-Smtp-Source: AB8JxZr+ioltbbPC0SnpiQRKycE/N2HnM4YjEIQAdVY7lu3K7j69DOanOUhwWdFZyx7jwrJA+TO2lg== X-Received: by 2002:a1c:455d:: with SMTP id s90-v6mr1546084wma.156.1526149513313; Sat, 12 May 2018 11:25:13 -0700 (PDT) Received: from x1.local (p200300E55F2109000000000000000281.dip0.t-ipconnect.de. [2003:e5:5f21:900::281]) by smtp.googlemail.com with ESMTPSA id i30-v6sm9556468wra.38.2018.05.12.11.25.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 12 May 2018 11:25:12 -0700 (PDT) From: Thomas Hollstegge To: linux-media@vger.kernel.org Cc: thomas.hollstegge@gmail.com, Antti Palosaari , Mauro Carvalho Chehab , Sean Young , Hans Verkuil , =?UTF-8?q?Stefan=20Br=C3=BCns?= , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] si2168: Set TS clock mode and frequency Date: Sat, 12 May 2018 20:24:58 +0200 Message-Id: <1526149500-9256-1-git-send-email-thomas.hollstegge@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some devices require a higher TS clock frequency to demodulate some muxes. This adds two optional parameters to control the TS clock frequency mode as well as the frequency. Signed-off-by: Thomas Hollstegge --- drivers/media/dvb-frontends/si2168.c | 20 +++++++++++++++++++- drivers/media/dvb-frontends/si2168.h | 8 ++++++++ drivers/media/dvb-frontends/si2168_priv.h | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 324493e..b05e677 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c @@ -92,13 +92,15 @@ static int si2168_ts_bus_ctrl(struct dvb_frontend *fe, int acquire) dev_dbg(&client->dev, "%s acquire: %d\n", __func__, acquire); /* set TS_MODE property */ - memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6); + memcpy(cmd.args, "\x14\x00\x01\x10\x00\x00", 6); if (acquire) cmd.args[4] |= dev->ts_mode; else cmd.args[4] |= SI2168_TS_TRISTATE; if (dev->ts_clock_gapped) cmd.args[4] |= 0x40; + cmd.args[4] |= (dev->ts_clock_mode & 0x03) << 4; + cmd.wlen = 6; cmd.rlen = 4; ret = si2168_cmd_execute(client, &cmd); @@ -398,6 +400,18 @@ static int si2168_set_frontend(struct dvb_frontend *fe) if (ret) goto err; + /* set TS frequency */ + if (dev->ts_clock_freq) { + memcpy(cmd.args, "\x14\x00\x0d\x10", 4); + cmd.args[4] = ((dev->ts_clock_freq / 10000) >> 0) & 0xff; + cmd.args[5] = ((dev->ts_clock_freq / 10000) >> 8) & 0xff; + cmd.wlen = 6; + cmd.rlen = 4; + ret = si2168_cmd_execute(client, &cmd); + if (ret) + goto err; + } + memcpy(cmd.args, "\x14\x00\x08\x10\xd7\x05", 6); cmd.args[5] |= dev->ts_clock_inv ? 0x00 : 0x10; cmd.wlen = 6; @@ -806,6 +820,10 @@ static int si2168_probe(struct i2c_client *client, dev->ts_mode = config->ts_mode; dev->ts_clock_inv = config->ts_clock_inv; dev->ts_clock_gapped = config->ts_clock_gapped; + dev->ts_clock_mode = config->ts_clock_mode; + if (dev->ts_clock_mode == 0) + dev->ts_clock_mode = SI2168_TS_CLOCK_MODE_AUTO_ADAPT; + dev->ts_clock_freq = config->ts_clock_freq; dev->spectral_inversion = config->spectral_inversion; dev_info(&client->dev, "Silicon Labs Si2168-%c%d%d successfully identified\n", diff --git a/drivers/media/dvb-frontends/si2168.h b/drivers/media/dvb-frontends/si2168.h index d519edd..3f52ee8 100644 --- a/drivers/media/dvb-frontends/si2168.h +++ b/drivers/media/dvb-frontends/si2168.h @@ -47,6 +47,14 @@ struct si2168_config { /* TS clock gapped */ bool ts_clock_gapped; + /* TS clock mode */ +#define SI2168_TS_CLOCK_MODE_AUTO_ADAPT 0x01 +#define SI2168_TS_CLOCK_MODE_MANUAL 0x02 + u8 ts_clock_mode; + + /* TS clock frequency (for manual mode) */ + u32 ts_clock_freq; + /* Inverted spectrum */ bool spectral_inversion; }; diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h index 2d362e1..8173d6c 100644 --- a/drivers/media/dvb-frontends/si2168_priv.h +++ b/drivers/media/dvb-frontends/si2168_priv.h @@ -48,6 +48,8 @@ struct si2168_dev { u8 ts_mode; bool ts_clock_inv; bool ts_clock_gapped; + u8 ts_clock_mode; + u32 ts_clock_freq; bool spectral_inversion; };