23 #include <linux/types.h>
26 #include <linux/export.h>
36 static int media_device_open(
struct file *filp)
41 static int media_device_close(
struct file *filp)
72 id &= ~MEDIA_ENT_ID_FLAG_NEXT;
74 spin_lock(&mdev->
lock);
77 if ((entity->
id ==
id && !next) ||
78 (entity->
id >
id && next)) {
79 spin_unlock(&mdev->
lock);
84 spin_unlock(&mdev->
lock);
89 static long media_device_enum_entities(
struct media_device *mdev,
98 ent = find_entity(mdev, u_ent.id);
104 u_ent.name[0] =
'\0';
106 strlcpy(u_ent.name, ent->
name,
sizeof(u_ent.name));
107 u_ent.type = ent->
type;
109 u_ent.flags = ent->
flags;
119 static void media_device_kpad_to_upad(
const struct media_pad *kpad,
127 static long media_device_enum_links(
struct media_device *mdev,
136 entity = find_entity(mdev,
links.entity);
143 for (p = 0; p < entity->
num_pads; p++) {
145 media_device_kpad_to_upad(&entity->
pads[p], &
pad);
155 for (l = 0, ulink = links.links; l < entity->num_links; l++) {
159 if (entity->
links[l].source->entity != entity)
162 media_device_kpad_to_upad(entity->
links[l].source,
164 media_device_kpad_to_upad(entity->
links[l].sink,
177 static long media_device_setup_link(
struct media_device *mdev,
191 source = find_entity(mdev, ulink.
source.entity);
192 sink = find_entity(mdev, ulink.
sink.entity);
215 static long media_device_ioctl(
struct file *filp,
unsigned int cmd,
224 ret = media_device_get_info(dev,
229 ret = media_device_enum_entities(dev,
235 ret = media_device_enum_links(dev,
242 ret = media_device_setup_link(dev,
256 .open = media_device_open,
257 .ioctl = media_device_ioctl,
258 .release = media_device_close,
306 mdev->
devnode.fops = &media_device_fops;
308 mdev->
devnode.release = media_device_release;
353 spin_lock(&mdev->
lock);
359 spin_unlock(&mdev->
lock);
379 spin_lock(&mdev->
lock);
381 spin_unlock(&mdev->
lock);