All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Longerbeam <slongerbeam@gmail.com>
To: linux-media@vger.kernel.org
Cc: Steve Longerbeam <steve_longerbeam@mentor.com>
Subject: [PATCH 08/11] adv7180: send V4L2_EVENT_SOURCE_CHANGE on std change
Date: Wed,  6 Jul 2016 16:00:01 -0700	[thread overview]
Message-ID: <1467846004-12731-9-git-send-email-steve_longerbeam@mentor.com> (raw)
In-Reply-To: <1467846004-12731-1-git-send-email-steve_longerbeam@mentor.com>

Subscribe to the V4L2_EVENT_SOURCE_CHANGE event and send
V4L2_EVENT_SRC_CH_RESOLUTION in the interrupt handler on a
detected standard change.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
 drivers/media/i2c/adv7180.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 427695d..f76a0e7 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -28,6 +28,7 @@
 #include <linux/of.h>
 #include <linux/gpio/consumer.h>
 #include <media/v4l2-ioctl.h>
+#include <media/v4l2-event.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
@@ -824,6 +825,20 @@ static int adv7180_g_tvnorms(struct v4l2_subdev *sd, v4l2_std_id *norm)
 	return 0;
 }
 
+static int adv7180_subscribe_event(struct v4l2_subdev *sd,
+				   struct v4l2_fh *fh,
+				   struct v4l2_event_subscription *sub)
+{
+	switch (sub->type) {
+	case V4L2_EVENT_SOURCE_CHANGE:
+		return v4l2_src_change_event_subdev_subscribe(sd, fh, sub);
+	case V4L2_EVENT_CTRL:
+		return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub);
+	default:
+		return -EINVAL;
+	}
+}
+
 static const struct v4l2_subdev_video_ops adv7180_video_ops = {
 	.s_std = adv7180_s_std,
 	.g_std = adv7180_g_std,
@@ -838,6 +853,8 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = {
 
 static const struct v4l2_subdev_core_ops adv7180_core_ops = {
 	.s_power = adv7180_s_power,
+	.subscribe_event = adv7180_subscribe_event,
+	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
 };
 
 static const struct v4l2_subdev_pad_ops adv7180_pad_ops = {
@@ -862,8 +879,18 @@ static irqreturn_t adv7180_irq(int irq, void *devid)
 	/* clear */
 	adv7180_write(state, ADV7180_REG_ICR3, isr3);
 
-	if (isr3 & ADV7180_IRQ3_AD_CHANGE && state->autodetect)
-		__adv7180_status(state, NULL, &state->curr_norm);
+	if (isr3 & ADV7180_IRQ3_AD_CHANGE) {
+		static const struct v4l2_event src_ch = {
+			.type = V4L2_EVENT_SOURCE_CHANGE,
+			.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
+		};
+
+		v4l2_subdev_notify_event(&state->sd, &src_ch);
+
+		if (state->autodetect)
+			__adv7180_status(state, NULL, &state->curr_norm);
+	}
+
 	mutex_unlock(&state->mutex);
 
 	return IRQ_HANDLED;
@@ -1403,7 +1430,7 @@ static int adv7180_probe(struct i2c_client *client,
 	state->input = 0;
 	sd = &state->sd;
 	v4l2_i2c_subdev_init(sd, client, &adv7180_ops);
-	sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
+	sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
 
 	ret = adv7180_init_controls(state);
 	if (ret)
-- 
1.9.1


  parent reply	other threads:[~2016-07-06 23:13 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 22:59 [PATCH 00/11] adv7180 subdev fixes Steve Longerbeam
2016-07-06 22:59 ` [PATCH 01/11] media: adv7180: Fix broken interrupt register access Steve Longerbeam
2016-07-07 14:44   ` Tim Harvey
2016-07-07 15:37   ` Lars-Peter Clausen
2016-07-06 22:59 ` [PATCH 02/11] Revert "[media] adv7180: fix broken standards handling" Steve Longerbeam
2016-07-07 14:48   ` Tim Harvey
2016-07-07 15:45   ` Lars-Peter Clausen
2016-07-09 18:56     ` Steve Longerbeam
2016-07-06 22:59 ` [PATCH 03/11] media: adv7180: add power pin control Steve Longerbeam
2016-07-07 15:04   ` Tim Harvey
2016-07-07 15:35   ` Lars-Peter Clausen
2016-07-06 22:59 ` [PATCH 04/11] media: adv7180: implement g_parm Steve Longerbeam
2016-07-07 15:04   ` Tim Harvey
2016-07-06 22:59 ` [PATCH 05/11] media: adv7180: init chip with AD recommended register settings Steve Longerbeam
2016-07-07 15:23   ` Tim Harvey
2016-07-07 15:29   ` Lars-Peter Clausen
2016-07-06 22:59 ` [PATCH 06/11] media: adv7180: add bt.656-4 OF property Steve Longerbeam
2016-07-07 14:52   ` Lars-Peter Clausen
2016-07-09 18:59     ` Steve Longerbeam
2016-07-09 21:10       ` Steve Longerbeam
2016-07-09 21:36         ` Steve Longerbeam
2016-07-10 12:10           ` Lars-Peter Clausen
2016-07-10 12:55             ` Hans Verkuil
2016-07-10 14:17               ` Ian Arkver
2016-07-10 14:30                 ` Hans Verkuil
2016-07-10 22:34                   ` Steve Longerbeam
2016-07-11  7:06                     ` Ian Arkver
2016-07-11 22:03                       ` Steve Longerbeam
2016-07-12 10:25                         ` Ian Arkver
2016-07-12 17:26                           ` Steve Longerbeam
2016-07-06 23:00 ` [PATCH 07/11] media: adv7180: change mbus format to UYVY Steve Longerbeam
2016-07-07 15:18   ` Lars-Peter Clausen
2016-07-08 10:52     ` Niklas Söderlund
2016-07-07 15:25   ` Tim Harvey
2016-07-06 23:00 ` Steve Longerbeam [this message]
2016-07-07 15:27   ` [PATCH 08/11] adv7180: send V4L2_EVENT_SOURCE_CHANGE on std change Tim Harvey
2016-07-06 23:00 ` [PATCH 09/11] v4l: Add signal lock status to source change events Steve Longerbeam
2016-07-06 23:00 ` [PATCH 10/11] media: adv7180: enable lock/unlock interrupts Steve Longerbeam
2016-07-06 23:00 ` [PATCH 11/11] media: adv7180: fix field type Steve Longerbeam
2016-07-07 14:37 ` [PATCH 00/11] adv7180 subdev fixes Tim Harvey
2016-07-20  0:03 ` [PATCH v2 00/10] adv7180 subdev fixes, v2 Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 01/10] v4l: of: add "newavmode" property for Analog Devices codecs Steve Longerbeam
2016-07-20  7:37     ` Hans Verkuil
2016-07-20 17:14       ` Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 02/10] media: adv7180: Fix broken interrupt register access Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 03/10] media: adv7180: define more registers Steve Longerbeam
2016-07-20  8:54     ` Lars-Peter Clausen
2016-07-20  0:03   ` [PATCH v2 04/10] media: adv7180: add support for NEWAVMODE Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 05/10] media: adv7180: add power pin control Steve Longerbeam
2016-07-20  8:53     ` Lars-Peter Clausen
2016-07-20  0:03   ` [PATCH v2 06/10] media: adv7180: implement g_parm Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 07/10] media: adv7180: change mbus format to UYVY Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 08/10] v4l: Add signal lock status to source change events Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 09/10] media: adv7180: enable lock/unlock interrupts Steve Longerbeam
2016-07-20  0:03   ` [PATCH v2 10/10] media: adv7180: fix field type Steve Longerbeam

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=1467846004-12731-9-git-send-email-steve_longerbeam@mentor.com \
    --to=slongerbeam@gmail.com \
    --cc=linux-media@vger.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.