All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Longerbeam <slongerbeam@gmail.com>
To: lars@metafoo.de
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Steve Longerbeam <steve_longerbeam@mentor.com>
Subject: [PATCH v4 8/8] media: adv7180: enable lock/unlock interrupts
Date: Wed,  3 Aug 2016 11:03:50 -0700	[thread overview]
Message-ID: <1470247430-11168-9-git-send-email-steve_longerbeam@mentor.com> (raw)
In-Reply-To: <1470247430-11168-1-git-send-email-steve_longerbeam@mentor.com>

Enable the SD lock/unlock interrupts and send V4L2_EVENT_SRC_CH_LOCK_STATUS
in the interrupt handler on a detected lock/unlock.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>

---

v4: no changes
v3: no changes

v2:
- last version of this patch was based on the old reverted autodetect
  code. This version now only enables the interrupt and sends the
  event in the interrupt handler.
---
 drivers/media/i2c/adv7180.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index abdc519..d017b05 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -874,19 +874,29 @@ static const struct v4l2_subdev_ops adv7180_ops = {
 static irqreturn_t adv7180_irq(int irq, void *devid)
 {
 	struct adv7180_state *state = devid;
-	u8 isr3;
+	u8 isr1, isr3;
 
 	mutex_lock(&state->mutex);
+	isr1 = adv7180_read(state, ADV7180_REG_ISR1);
 	isr3 = adv7180_read(state, ADV7180_REG_ISR3);
 	/* clear */
+	adv7180_write(state, ADV7180_REG_ICR1, isr1);
 	adv7180_write(state, ADV7180_REG_ICR3, isr3);
 
-	if (isr3 & ADV7180_IRQ3_AD_CHANGE) {
-		static const struct v4l2_event src_ch = {
+	if ((isr3 & ADV7180_IRQ3_AD_CHANGE) ||
+	    (isr1 & (ADV7180_IRQ1_LOCK | ADV7180_IRQ1_UNLOCK))) {
+		static struct v4l2_event src_ch = {
 			.type = V4L2_EVENT_SOURCE_CHANGE,
-			.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
 		};
 
+		if (isr3 & ADV7180_IRQ3_AD_CHANGE)
+			src_ch.u.src_change.changes |=
+				V4L2_EVENT_SRC_CH_RESOLUTION;
+
+		if (isr1 & (ADV7180_IRQ1_LOCK | ADV7180_IRQ1_UNLOCK))
+			src_ch.u.src_change.changes |=
+				V4L2_EVENT_SRC_CH_LOCK_STATUS;
+
 		v4l2_subdev_notify_event(&state->sd, &src_ch);
 	}
 	mutex_unlock(&state->mutex);
@@ -1287,7 +1297,9 @@ static int init_device(struct adv7180_state *state)
 		if (ret < 0)
 			goto out_unlock;
 
-		ret = adv7180_write(state, ADV7180_REG_IMR1, 0);
+		/* enable lock/unlock interrupts */
+		ret = adv7180_write(state, ADV7180_REG_IMR1,
+				    ADV7180_IRQ1_LOCK | ADV7180_IRQ1_UNLOCK);
 		if (ret < 0)
 			goto out_unlock;
 
-- 
1.9.1

  parent reply	other threads:[~2016-08-03 18:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 18:03 [PATCH v4 0/8] adv7180 subdev fixes, v4 Steve Longerbeam
2016-08-03 18:03 ` [PATCH v4 1/8] media: adv7180: fix field type Steve Longerbeam
2016-08-19 14:40   ` Lars-Peter Clausen
2016-11-14 11:19   ` Hans Verkuil
2016-08-03 18:03 ` [PATCH v4 2/8] media: adv7180: define more registers Steve Longerbeam
2016-08-03 18:03 ` [PATCH v4 3/8] media: adv7180: add support for NEWAVMODE Steve Longerbeam
2016-10-16 12:18   ` Laurent Pinchart
2016-10-17 22:36     ` Steve Longerbeam
2016-10-18  8:31       ` Laurent Pinchart
2016-11-14 11:28   ` Hans Verkuil
2016-11-14 18:21     ` Steve Longerbeam
2016-08-03 18:03 ` [PATCH v4 4/8] media: adv7180: add power pin control Steve Longerbeam
2016-08-03 18:03 ` [PATCH v4 5/8] media: adv7180: implement g_parm Steve Longerbeam
2016-11-14 11:17   ` Hans Verkuil
2016-08-03 18:03 ` [PATCH v4 6/8] media: adv7180: change mbus format to UYVY Steve Longerbeam
2016-08-03 18:03 ` [PATCH v4 7/8] v4l: Add signal lock status to source change events Steve Longerbeam
2016-11-14 11:36   ` Hans Verkuil
2016-11-14 14:16     ` Devin Heitmueller
2016-11-14 19:19     ` Steve Longerbeam
2016-11-14 19:32       ` Steve Longerbeam
2016-08-03 18:03 ` Steve Longerbeam [this message]
2016-09-19 14:19 ` [PATCH v4 0/8] adv7180 subdev fixes, v4 Jack Mitchell
2016-09-19 15:22   ` Hans Verkuil

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=1470247430-11168-9-git-send-email-steve_longerbeam@mentor.com \
    --to=slongerbeam@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=steve_longerbeam@mentor.com \
    /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.