diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2009-12-09 06:38:49 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:32:42 -0400 |
commit | 2096a5dcf9704f5a86ecba37169eb813aaf0431c (patch) | |
tree | 21e7d870302a7c6748667a785b465a7a84805228 /include/media | |
parent | 0070d91e5b5ae594116202ab7d62d8264830b1cd (diff) |
[media] v4l: subdev: Add device node support
Create a device node named subdevX for every registered subdev.
As the device node is registered before the subdev core::s_config
function is called, return -EGAIN on open until initialization
completes.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Vimarsh Zutshi <vimarsh.zutshi@gmail.com>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/v4l2-dev.h | 18 | ||||
-rw-r--r-- | include/media/v4l2-device.h | 6 | ||||
-rw-r--r-- | include/media/v4l2-subdev.h | 14 |
3 files changed, 33 insertions, 5 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 15802a067a12..4fe6831b1851 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -21,7 +21,8 @@ | |||
21 | #define VFL_TYPE_GRABBER 0 | 21 | #define VFL_TYPE_GRABBER 0 |
22 | #define VFL_TYPE_VBI 1 | 22 | #define VFL_TYPE_VBI 1 |
23 | #define VFL_TYPE_RADIO 2 | 23 | #define VFL_TYPE_RADIO 2 |
24 | #define VFL_TYPE_MAX 3 | 24 | #define VFL_TYPE_SUBDEV 3 |
25 | #define VFL_TYPE_MAX 4 | ||
25 | 26 | ||
26 | struct v4l2_ioctl_callbacks; | 27 | struct v4l2_ioctl_callbacks; |
27 | struct video_device; | 28 | struct video_device; |
@@ -102,15 +103,26 @@ struct video_device | |||
102 | /* dev to video-device */ | 103 | /* dev to video-device */ |
103 | #define to_video_device(cd) container_of(cd, struct video_device, dev) | 104 | #define to_video_device(cd) container_of(cd, struct video_device, dev) |
104 | 105 | ||
106 | int __must_check __video_register_device(struct video_device *vdev, int type, | ||
107 | int nr, int warn_if_nr_in_use, struct module *owner); | ||
108 | |||
105 | /* Register video devices. Note that if video_register_device fails, | 109 | /* Register video devices. Note that if video_register_device fails, |
106 | the release() callback of the video_device structure is *not* called, so | 110 | the release() callback of the video_device structure is *not* called, so |
107 | the caller is responsible for freeing any data. Usually that means that | 111 | the caller is responsible for freeing any data. Usually that means that |
108 | you call video_device_release() on failure. */ | 112 | you call video_device_release() on failure. */ |
109 | int __must_check video_register_device(struct video_device *vdev, int type, int nr); | 113 | static inline int __must_check video_register_device(struct video_device *vdev, |
114 | int type, int nr) | ||
115 | { | ||
116 | return __video_register_device(vdev, type, nr, 1, vdev->fops->owner); | ||
117 | } | ||
110 | 118 | ||
111 | /* Same as video_register_device, but no warning is issued if the desired | 119 | /* Same as video_register_device, but no warning is issued if the desired |
112 | device node number was already in use. */ | 120 | device node number was already in use. */ |
113 | int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); | 121 | static inline int __must_check video_register_device_no_warn( |
122 | struct video_device *vdev, int type, int nr) | ||
123 | { | ||
124 | return __video_register_device(vdev, type, nr, 0, vdev->fops->owner); | ||
125 | } | ||
114 | 126 | ||
115 | /* Unregister video devices. Will do nothing if vdev == NULL or | 127 | /* Unregister video devices. Will do nothing if vdev == NULL or |
116 | video_is_registered() returns false. */ | 128 | video_is_registered() returns false. */ |
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h index b16f307d471a..78b11e5a6db7 100644 --- a/include/media/v4l2-device.h +++ b/include/media/v4l2-device.h | |||
@@ -96,6 +96,12 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | |||
96 | wasn't registered. In that case it will do nothing. */ | 96 | wasn't registered. In that case it will do nothing. */ |
97 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); | 97 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); |
98 | 98 | ||
99 | /* Register device nodes for all subdev of the v4l2 device that are marked with | ||
100 | * the V4L2_SUBDEV_FL_HAS_DEVNODE flag. | ||
101 | */ | ||
102 | int __must_check | ||
103 | v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev); | ||
104 | |||
99 | /* Iterate over all subdevs. */ | 105 | /* Iterate over all subdevs. */ |
100 | #define v4l2_device_for_each_subdev(sd, v4l2_dev) \ | 106 | #define v4l2_device_for_each_subdev(sd, v4l2_dev) \ |
101 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) | 107 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) |
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index da16d2f4a00b..474ef009fd3d 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define _V4L2_SUBDEV_H | 22 | #define _V4L2_SUBDEV_H |
23 | 23 | ||
24 | #include <media/v4l2-common.h> | 24 | #include <media/v4l2-common.h> |
25 | #include <media/v4l2-dev.h> | ||
25 | #include <media/v4l2-mediabus.h> | 26 | #include <media/v4l2-mediabus.h> |
26 | 27 | ||
27 | /* generic v4l2_device notify callback notification values */ | 28 | /* generic v4l2_device notify callback notification values */ |
@@ -431,9 +432,11 @@ struct v4l2_subdev_internal_ops { | |||
431 | #define V4L2_SUBDEV_NAME_SIZE 32 | 432 | #define V4L2_SUBDEV_NAME_SIZE 32 |
432 | 433 | ||
433 | /* Set this flag if this subdev is a i2c device. */ | 434 | /* Set this flag if this subdev is a i2c device. */ |
434 | #define V4L2_SUBDEV_FL_IS_I2C (1U << 0) | 435 | #define V4L2_SUBDEV_FL_IS_I2C (1U << 0) |
435 | /* Set this flag if this subdev is a spi device. */ | 436 | /* Set this flag if this subdev is a spi device. */ |
436 | #define V4L2_SUBDEV_FL_IS_SPI (1U << 1) | 437 | #define V4L2_SUBDEV_FL_IS_SPI (1U << 1) |
438 | /* Set this flag if this subdev needs a device node. */ | ||
439 | #define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2) | ||
437 | 440 | ||
438 | /* Each instance of a subdev driver should create this struct, either | 441 | /* Each instance of a subdev driver should create this struct, either |
439 | stand-alone or embedded in a larger struct. | 442 | stand-alone or embedded in a larger struct. |
@@ -455,8 +458,15 @@ struct v4l2_subdev { | |||
455 | /* pointer to private data */ | 458 | /* pointer to private data */ |
456 | void *dev_priv; | 459 | void *dev_priv; |
457 | void *host_priv; | 460 | void *host_priv; |
461 | /* subdev device node */ | ||
462 | struct video_device devnode; | ||
458 | }; | 463 | }; |
459 | 464 | ||
465 | #define vdev_to_v4l2_subdev(vdev) \ | ||
466 | container_of(vdev, struct v4l2_subdev, devnode) | ||
467 | |||
468 | extern const struct v4l2_file_operations v4l2_subdev_fops; | ||
469 | |||
460 | static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p) | 470 | static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p) |
461 | { | 471 | { |
462 | sd->dev_priv = p; | 472 | sd->dev_priv = p; |