From: Brad Love <brad@nextdimension.cc>
To: linux-media@vger.kernel.org
Cc: Brad Love <brad@nextdimension.cc>
Subject: [PATCH v3 06/14] si2157: module debug option to wait on signal lock
Date: Thu, 14 Nov 2019 14:04:00 -0600 [thread overview]
Message-ID: <20191114200408.28883-7-brad@nextdimension.cc> (raw)
In-Reply-To: <20191114200408.28883-1-brad@nextdimension.cc>
In some debugging cases it is useful to know how long it took
signal lock to happen after tuning. This can help diagnose
line issues.
Signed-off-by: Brad Love <brad@nextdimension.cc>
---
Since v2:
- Split into two parts, tune completion and signal lock
drivers/media/tuners/si2157.c | 46 ++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index cac4870017f5..16d7169f46fb 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -9,6 +9,10 @@
static const struct dvb_tuner_ops si2157_ops;
+static int tuner_lock_debug;
+module_param(tuner_lock_debug, int, 0644);
+MODULE_PARM_DESC(tuner_lock_debug, "if set, signal lock is briefly waited on after setting params");
+
/* execute firmware command */
static int si2157_cmd_execute(struct i2c_client *client, struct si2157_cmd *cmd)
{
@@ -301,14 +305,22 @@ static int si2157_sleep(struct dvb_frontend *fe)
return ret;
}
-static int si2157_tune_wait(struct i2c_client *client)
+static int si2157_tune_wait(struct i2c_client *client, u8 is_digital)
{
#define TUN_TIMEOUT 40
+#define DIG_TIMEOUT 30
+#define ANALOG_TIMEOUT 150
struct si2157_dev *dev = i2c_get_clientdata(client);
int ret;
unsigned long timeout;
unsigned long start_time;
u8 wait_status;
+ u8 tune_lock_mask;
+
+ if (is_digital)
+ tune_lock_mask = 0x04;
+ else
+ tune_lock_mask = 0x02;
mutex_lock(&dev->i2c_mutex);
@@ -335,6 +347,34 @@ static int si2157_tune_wait(struct i2c_client *client)
jiffies_to_msecs(jiffies) - jiffies_to_msecs(start_time),
wait_status);
+ /* if we tuned ok, wait a bit for tuner lock */
+ if (tuner_lock_debug && (wait_status & 0x81) == 0x81) {
+ if (is_digital)
+ timeout = jiffies + msecs_to_jiffies(DIG_TIMEOUT);
+ else
+ timeout = jiffies + msecs_to_jiffies(ANALOG_TIMEOUT);
+
+ while (!time_after(jiffies, timeout)) {
+ ret = i2c_master_recv(client, &wait_status,
+ sizeof(wait_status));
+ if (ret < 0) {
+ goto err_mutex_unlock;
+ } else if (ret != sizeof(wait_status)) {
+ ret = -EREMOTEIO;
+ goto err_mutex_unlock;
+ }
+
+ /* tuner locked? */
+ if (wait_status & tune_lock_mask)
+ break;
+ usleep_range(5000, 10000);
+ }
+
+ dev_dbg(&client->dev, "tuning+lock took %d ms, status=0x%x\n",
+ jiffies_to_msecs(jiffies) - jiffies_to_msecs(start_time),
+ wait_status);
+ }
+
if ((wait_status & 0xc0) != 0x80) {
ret = -ETIMEDOUT;
goto err_mutex_unlock;
@@ -448,7 +488,7 @@ static int si2157_set_params(struct dvb_frontend *fe)
dev->bandwidth = bandwidth;
dev->frequency = c->frequency;
- si2157_tune_wait(client); /* wait to complete, ignore any errors */
+ si2157_tune_wait(client, 1); /* wait to complete, ignore any errors */
return 0;
err:
@@ -644,7 +684,7 @@ static int si2157_set_analog_params(struct dvb_frontend *fe,
dev->bandwidth = bandwidth;
- si2157_tune_wait(client); /* wait to complete, ignore any errors */
+ si2157_tune_wait(client, 0); /* wait to complete, ignore any errors */
return 0;
err:
--
2.23.0
next prev parent reply other threads:[~2019-11-14 20:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 20:03 [PATCH v3 00/14] si2157: Analog tuning and optimizations Brad Love
2019-11-14 20:03 ` [PATCH v3 01/14] si2157: Enable tuner status flags Brad Love
2019-11-14 20:03 ` [PATCH v3 02/14] si2157: Check error status bit on cmd execute Brad Love
2019-11-15 11:09 ` Antti Palosaari
2019-11-14 20:03 ` [PATCH v3 03/14] si2157: Better check for running tuner in init Brad Love
2019-11-15 11:16 ` Antti Palosaari
2019-11-14 20:03 ` [PATCH v3 04/14] si2157: Add analog tuning related functions Brad Love
2019-11-24 5:09 ` Antti Palosaari
2019-12-19 13:13 ` Mauro Carvalho Chehab
2019-12-20 15:32 ` Antti Palosaari
2020-02-01 21:20 ` Brad Love
2019-11-14 20:03 ` [PATCH v3 05/14] si2157: Briefly wait for tuning operation to complete Brad Love
2019-11-15 11:31 ` Antti Palosaari
2019-11-14 20:04 ` Brad Love [this message]
2019-11-14 20:04 ` [PATCH v3 07/14] cx23885: Add analog frontend to Hauppauge QuadHD Brad Love
2019-11-14 20:04 ` [PATCH v3 08/14] cx23885: Add analog frontend to 1265_K4 Brad Love
2019-11-14 20:04 ` [PATCH v3 09/14] cx23885: Add analog frontend to HVR5525 Brad Love
2019-11-14 20:04 ` [PATCH v3 10/14] cx23885: Add i2c device analog tuner support Brad Love
2019-11-14 20:04 ` [PATCH v3 11/14] cx231xx: " Brad Love
2019-11-17 6:53 ` kbuild test robot
2019-11-17 6:53 ` [PATCH] cx231xx: fix semicolon.cocci warnings kbuild test robot
2019-11-14 20:04 ` [PATCH v3 12/14] si2157: add on-demand rf strength func Brad Love
2019-11-15 20:23 ` Antti Palosaari
2019-11-14 20:04 ` [PATCH v3 13/14] lgdt3306a: Add CNR v5 stat Brad Love
2019-11-14 20:04 ` [PATCH v3 14/14] cx25840: Register labeling, chip specific correction Brad Love
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191114200408.28883-7-brad@nextdimension.cc \
--to=brad@nextdimension.cc \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.