diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2009-12-09 06:40:03 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 03:53:16 -0400 |
commit | 97548ed4c4661502cdfd1aabd5d3876fa4f5cc2e (patch) | |
tree | c85b85954f53e3a97b6590de8d5d5396e7c43358 /drivers/media/media-device.c | |
parent | 1651333b09743887bc2dd3d158a11853a2be3fe7 (diff) |
[media] media: Links setup
Create the following ioctl and implement it at the media device level to
setup links.
- MEDIA_IOC_SETUP_LINK: Modify the properties of a given link
The only property that can currently be modified is the ENABLED link
flag to enable/disable a link. Links marked with the IMMUTABLE link flag
can not be enabled or disabled.
Enabling or disabling a link has effects on entities' use count. Those
changes are automatically propagated through the graph.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Stanimir Varbanov <svarbanov@mm-sol.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r-- | drivers/media/media-device.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 648a9d892ac1..16b70b4412f7 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c | |||
@@ -172,6 +172,44 @@ static long media_device_enum_links(struct media_device *mdev, | |||
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | 174 | ||
175 | static long media_device_setup_link(struct media_device *mdev, | ||
176 | struct media_link_desc __user *_ulink) | ||
177 | { | ||
178 | struct media_link *link = NULL; | ||
179 | struct media_link_desc ulink; | ||
180 | struct media_entity *source; | ||
181 | struct media_entity *sink; | ||
182 | int ret; | ||
183 | |||
184 | if (copy_from_user(&ulink, _ulink, sizeof(ulink))) | ||
185 | return -EFAULT; | ||
186 | |||
187 | /* Find the source and sink entities and link. | ||
188 | */ | ||
189 | source = find_entity(mdev, ulink.source.entity); | ||
190 | sink = find_entity(mdev, ulink.sink.entity); | ||
191 | |||
192 | if (source == NULL || sink == NULL) | ||
193 | return -EINVAL; | ||
194 | |||
195 | if (ulink.source.index >= source->num_pads || | ||
196 | ulink.sink.index >= sink->num_pads) | ||
197 | return -EINVAL; | ||
198 | |||
199 | link = media_entity_find_link(&source->pads[ulink.source.index], | ||
200 | &sink->pads[ulink.sink.index]); | ||
201 | if (link == NULL) | ||
202 | return -EINVAL; | ||
203 | |||
204 | /* Setup the link on both entities. */ | ||
205 | ret = __media_entity_setup_link(link, ulink.flags); | ||
206 | |||
207 | if (copy_to_user(_ulink, &ulink, sizeof(ulink))) | ||
208 | return -EFAULT; | ||
209 | |||
210 | return ret; | ||
211 | } | ||
212 | |||
175 | static long media_device_ioctl(struct file *filp, unsigned int cmd, | 213 | static long media_device_ioctl(struct file *filp, unsigned int cmd, |
176 | unsigned long arg) | 214 | unsigned long arg) |
177 | { | 215 | { |
@@ -197,6 +235,13 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd, | |||
197 | mutex_unlock(&dev->graph_mutex); | 235 | mutex_unlock(&dev->graph_mutex); |
198 | break; | 236 | break; |
199 | 237 | ||
238 | case MEDIA_IOC_SETUP_LINK: | ||
239 | mutex_lock(&dev->graph_mutex); | ||
240 | ret = media_device_setup_link(dev, | ||
241 | (struct media_link_desc __user *)arg); | ||
242 | mutex_unlock(&dev->graph_mutex); | ||
243 | break; | ||
244 | |||
200 | default: | 245 | default: |
201 | ret = -ENOIOCTLCMD; | 246 | ret = -ENOIOCTLCMD; |
202 | } | 247 | } |