aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/media-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r--drivers/media/media-device.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 6ba6e8f982fc..6e43c95629ea 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>
@@ -126,6 +129,26 @@ static long media_device_enum_entities(struct media_device *mdev,
126 u_ent.group_id = 0; /* Unused */ 129 u_ent.group_id = 0; /* Unused */
127 u_ent.pads = ent->num_pads; 130 u_ent.pads = ent->num_pads;
128 u_ent.links = ent->num_links - ent->num_backlinks; 131 u_ent.links = ent->num_links - ent->num_backlinks;
132
133 /*
134 * Workaround for a bug at media-ctl <= v1.10 that makes it to
135 * do the wrong thing if the entity function doesn't belong to
136 * either MEDIA_ENT_F_OLD_BASE or MEDIA_ENT_F_OLD_SUBDEV_BASE
137 * Ranges.
138 *
139 * Non-subdevices are expected to be at the MEDIA_ENT_F_OLD_BASE,
140 * or, otherwise, will be silently ignored by media-ctl when
141 * printing the graphviz diagram. So, map them into the devnode
142 * old range.
143 */
144 if (ent->function < MEDIA_ENT_F_OLD_BASE ||
145 ent->function > MEDIA_ENT_T_DEVNODE_UNKNOWN) {
146 if (is_media_entity_v4l2_subdev(ent))
147 u_ent.type = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
148 else if (ent->function != MEDIA_ENT_F_IO_V4L)
149 u_ent.type = MEDIA_ENT_T_DEVNODE_UNKNOWN;
150 }
151
129 memcpy(&u_ent.raw, &ent->info, sizeof(ent->info)); 152 memcpy(&u_ent.raw, &ent->info, sizeof(ent->info));
130 if (copy_to_user(uent, &u_ent, sizeof(u_ent))) 153 if (copy_to_user(uent, &u_ent, sizeof(u_ent)))
131 return -EFAULT; 154 return -EFAULT;