]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (11021): v4l2-device: add a notify callback.
authorHans Verkuil <hverkuil@xs4all.nl>
Sun, 8 Mar 2009 20:02:10 +0000 (17:02 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:20 +0000 (12:43 -0300)
Add a notify callback to v4l2_device to let sub-devices notify their
parent of special events.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Documentation/video4linux/v4l2-framework.txt
include/media/v4l2-device.h
include/media/v4l2-subdev.h

index df0247ed13d8f15a9b29581f15666bebff21ac78..4207590b2ac853cccbae4014209a4d0a2388e29d 100644 (file)
@@ -94,6 +94,11 @@ usb_device or platform_device. It is rare for dev to be NULL, but it happens
 with ISA devices or when one device creates multiple PCI devices, thus making
 it impossible to associate v4l2_dev with a particular parent.
 
+You can also supply a notify() callback that can be called by sub-devices to
+notify you of events. Whether you need to set this depends on the sub-device.
+Any notifications a sub-device supports must be defined in a header in
+include/media/<subdevice>.h.
+
 You unregister with:
 
        v4l2_device_unregister(struct v4l2_device *v4l2_dev);
@@ -281,6 +286,11 @@ e.g. AUDIO_CONTROLLER and specify that as the group ID value when calling
 v4l2_device_call_all(). That ensures that it will only go to the subdev
 that needs it.
 
+If the sub-device needs to notify its v4l2_device parent of an event, then
+it can call v4l2_subdev_notify(sd, notification, arg). This macro checks
+whether there is a notify() callback defined and returns -ENODEV if not.
+Otherwise the result of the notify() call is returned.
+
 The advantage of using v4l2_subdev is that it is a generic struct and does
 not contain any knowledge about the underlying hardware. So a driver might
 contain several subdevs that use an I2C bus, but also a subdev that is
index 5d7146dc2913881bc30a34007e393b53d1478690..3d8e96f6ceb30716d29c6f6e83793e26f1aef2e8 100644 (file)
@@ -44,6 +44,9 @@ struct v4l2_device {
        spinlock_t lock;
        /* unique device name, by default the driver name + bus ID */
        char name[V4L2_DEVICE_NAME_SIZE];
+       /* notify callback called by some sub-devices. */
+       void (*notify)(struct v4l2_subdev *sd,
+                       unsigned int notification, void *arg);
 };
 
 /* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
index 05b69652e6c45b2841030224e951212abbc1e6f0..1b97a2c33a7371779b4945ed49afb51385b7e80c 100644 (file)
@@ -191,4 +191,9 @@ static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
        (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \
                (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
 
+/* Send a notification to v4l2_device. */
+#define v4l2_subdev_notify(sd, notification, arg)                         \
+       ((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
+        (sd)->v4l2_dev->notify((sd), (notification), (arg)))
+
 #endif