aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2020-03-12 11:31:51 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-03-12 16:40:28 +0100
commite953c10300055694c976edfe8c7a71a5bfc5ade7 (patch)
tree8a7738bd3758e3450c3a0a823b059970ded7ad32 /drivers/media/i2c
parentmedia: tvp5150: move irq en-/disable into runtime-pm ops (diff)
downloadwireguard-linux-e953c10300055694c976edfe8c7a71a5bfc5ade7.tar.xz
wireguard-linux-e953c10300055694c976edfe8c7a71a5bfc5ade7.zip
media: tvp5150: add v4l2-event support
Currently the driver notifies internal subdevs if the signal is locked or not. This information is also useful for userpace applications e.g. to switch to another input device upon a signal lost event. This commit adds the support for the userspace to subscribe to the V4L2_EVENT_SOURCE_CHANGE and V4L2_EVENT_CTRL events. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/tvp5150.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 06ca3081f3d1..d59b52775334 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -17,6 +17,7 @@
#include <linux/regmap.h>
#include <media/v4l2-async.h>
#include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-mc.h>
@@ -1526,6 +1527,19 @@ static int tvp5150_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi
}
#endif
+static int tvp5150_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 int tvp5150_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{
int status = tvp5150_read(sd, 0x88);
@@ -1617,6 +1631,8 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
.g_register = tvp5150_g_register,
.s_register = tvp5150_s_register,
#endif
+ .subscribe_event = tvp5150_subscribe_event,
+ .unsubscribe_event = v4l2_event_subdev_unsubscribe,
};
static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
@@ -2045,7 +2061,7 @@ static int tvp5150_probe(struct i2c_client *c)
sd = &core->sd;
v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
sd->internal_ops = &tvp5150_internal_ops;
- sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
if (IS_ENABLED(CONFIG_OF) && np) {
res = tvp5150_parse_dt(core, np);