@@ -65,6 +65,19 @@ void v4l2_subdev_close(struct media_entity *entity)
}
}
+static int mbus_code_sort(const void *p1, const void *p2)
+{
+ const unsigned int *c1 = p1, *c2 = p2;
+
+ if (*c1 < *c2)
+ return -1;
+
+ if (*c1 > *c2)
+ return 1;
+
+ return 0;
+}
+
struct v4l2_subdev_mbus_codes *
v4l2_subdev_enum_mbus_code(struct media_entity *entity, unsigned int pad)
{
@@ -100,6 +113,7 @@ v4l2_subdev_enum_mbus_code(struct media_entity *entity, unsigned int pad)
}
codes->ncode = c.index;
+ qsort(codes->code, codes->ncode, sizeof(*codes->code), &mbus_code_sort);
v4l2_subdev_close(entity);
return codes;
Sort the enumeration result. This makes e.g. matching formats at both ends of the link much easier. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> --- src/v4l2subdev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)