diff options
-rw-r--r-- | drivers/media/media-device.c | 23 | ||||
-rw-r--r-- | include/uapi/linux/media.h | 6 |
2 files changed, 28 insertions, 1 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 7dae0ac0f3ae..e9219f528d7e 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c | |||
@@ -20,6 +20,9 @@ | |||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /* We need to access legacy defines from linux/media.h */ | ||
24 | #define __NEED_MEDIA_LEGACY_API | ||
25 | |||
23 | #include <linux/compat.h> | 26 | #include <linux/compat.h> |
24 | #include <linux/export.h> | 27 | #include <linux/export.h> |
25 | #include <linux/idr.h> | 28 | #include <linux/idr.h> |
@@ -115,6 +118,26 @@ static long media_device_enum_entities(struct media_device *mdev, | |||
115 | u_ent.group_id = 0; /* Unused */ | 118 | u_ent.group_id = 0; /* Unused */ |
116 | u_ent.pads = ent->num_pads; | 119 | u_ent.pads = ent->num_pads; |
117 | u_ent.links = ent->num_links - ent->num_backlinks; | 120 | u_ent.links = ent->num_links - ent->num_backlinks; |
121 | |||
122 | /* | ||
123 | * Workaround for a bug at media-ctl <= v1.10 that makes it to | ||
124 | * do the wrong thing if the entity function doesn't belong to | ||
125 | * either MEDIA_ENT_F_OLD_BASE or MEDIA_ENT_F_OLD_SUBDEV_BASE | ||
126 | * Ranges. | ||
127 | * | ||
128 | * Non-subdevices are expected to be at the MEDIA_ENT_F_OLD_BASE, | ||
129 | * or, otherwise, will be silently ignored by media-ctl when | ||
130 | * printing the graphviz diagram. So, map them into the devnode | ||
131 | * old range. | ||
132 | */ | ||
133 | if (ent->function < MEDIA_ENT_F_OLD_BASE || | ||
134 | ent->function > MEDIA_ENT_T_DEVNODE_UNKNOWN) { | ||
135 | if (is_media_entity_v4l2_subdev(ent)) | ||
136 | u_ent.type = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; | ||
137 | else if (ent->function != MEDIA_ENT_F_IO_V4L) | ||
138 | u_ent.type = MEDIA_ENT_T_DEVNODE_UNKNOWN; | ||
139 | } | ||
140 | |||
118 | memcpy(&u_ent.raw, &ent->info, sizeof(ent->info)); | 141 | memcpy(&u_ent.raw, &ent->info, sizeof(ent->info)); |
119 | if (copy_to_user(uent, &u_ent, sizeof(u_ent))) | 142 | if (copy_to_user(uent, &u_ent, sizeof(u_ent))) |
120 | return -EFAULT; | 143 | return -EFAULT; |
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 625b38f65764..a8e3a8c0d85a 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h | |||
@@ -120,7 +120,7 @@ struct media_device_info { | |||
120 | 120 | ||
121 | #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE | 121 | #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE |
122 | 122 | ||
123 | #ifndef __KERNEL__ | 123 | #if !defined(__KERNEL__) || defined(__NEED_MEDIA_LEGACY_API) |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * Legacy symbols used to avoid userspace compilation breakages | 126 | * Legacy symbols used to avoid userspace compilation breakages |
@@ -133,6 +133,10 @@ struct media_device_info { | |||
133 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 | 133 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 |
134 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | 134 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff |
135 | 135 | ||
136 | /* End of the old subdev reserved numberspace */ | ||
137 | #define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_T_DEVNODE | \ | ||
138 | MEDIA_ENT_SUBTYPE_MASK) | ||
139 | |||
136 | #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE | 140 | #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE |
137 | #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L | 141 | #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L |
138 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) | 142 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) |