Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 138164
b: refs/heads/master
c: 98ec633
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent 4f0d6f3 commit e484184
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 005759613b95264fba9138010f112bc138c857c2
refs/heads/master: 98ec633972a70cf71d71bc8762804f0af4792d08
10 changes: 10 additions & 0 deletions trunk/Documentation/video4linux/v4l2-framework.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/media/v4l2-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/media/v4l2-subdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e484184

Please sign in to comment.