summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-08 21:02:10 +0100
committerHans Verkuil <hverkuil@xs4all.nl>2009-03-08 21:02:10 +0100
commit3d3fd89aabd81c1e33baf3dcf16329457cd82c77 (patch)
tree796ab96b90893424381daa2b874058a3ef5d94df /linux
parent1bd1aedc7af71728404f5d7b059dd8ca52d01f9f (diff)
downloadmediapointer-dvb-s2-3d3fd89aabd81c1e33baf3dcf16329457cd82c77.tar.gz
mediapointer-dvb-s2-3d3fd89aabd81c1e33baf3dcf16329457cd82c77.tar.bz2
v4l2-device: add a notify callback.
From: Hans Verkuil <hverkuil@xs4all.nl> Add a notify callback to v4l2_device to let sub-devices notify their parent of special events. Priority: normal Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux')
-rw-r--r--linux/Documentation/video4linux/v4l2-framework.txt10
-rw-r--r--linux/include/media/v4l2-device.h3
-rw-r--r--linux/include/media/v4l2-subdev.h5
3 files changed, 18 insertions, 0 deletions
diff --git a/linux/Documentation/video4linux/v4l2-framework.txt b/linux/Documentation/video4linux/v4l2-framework.txt
index accc376e9..1232f3066 100644
--- a/linux/Documentation/video4linux/v4l2-framework.txt
+++ b/linux/Documentation/video4linux/v4l2-framework.txt
@@ -93,6 +93,11 @@ The first 'dev' argument is normally the struct device pointer of a pci_dev,
usb_device or platform_device. It is rare for dev to be NULL, but it happens
with ISA devices, for example.
+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);
@@ -280,6 +285,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
diff --git a/linux/include/media/v4l2-device.h b/linux/include/media/v4l2-device.h
index 5d7146dc2..3d8e96f6c 100644
--- a/linux/include/media/v4l2-device.h
+++ b/linux/include/media/v4l2-device.h
@@ -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.
diff --git a/linux/include/media/v4l2-subdev.h b/linux/include/media/v4l2-subdev.h
index 05b69652e..1b97a2c33 100644
--- a/linux/include/media/v4l2-subdev.h
+++ b/linux/include/media/v4l2-subdev.h
@@ -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