@@ -32,6 +32,7 @@
#include <unistd.h>
#include <linux/v4l2-subdev.h>
+#include <linux/videodev2.h>
#include "mediactl.h"
#include "mediactl-priv.h"
@@ -819,6 +820,37 @@ const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code)
return "unknown";
}
+static struct {
+ const char *name;
+ enum v4l2_colorspace cs;
+} colorspaces[] = {
+ { "DEFAULT", V4L2_COLORSPACE_DEFAULT },
+ { "SMPTE170M", V4L2_COLORSPACE_SMPTE170M },
+ { "SMPTE240M", V4L2_COLORSPACE_SMPTE240M },
+ { "REC709", V4L2_COLORSPACE_REC709 },
+ { "BT878", V4L2_COLORSPACE_BT878 },
+ { "470_SYSTEM_M", V4L2_COLORSPACE_470_SYSTEM_M },
+ { "470_SYSTEM_BG", V4L2_COLORSPACE_470_SYSTEM_BG },
+ { "JPEG", V4L2_COLORSPACE_JPEG },
+ { "SRGB", V4L2_COLORSPACE_SRGB },
+ { "ADOBERGB", V4L2_COLORSPACE_ADOBERGB },
+ { "BT2020", V4L2_COLORSPACE_BT2020 },
+ { "RAW", V4L2_COLORSPACE_RAW },
+ { "DCI_P3", V4L2_COLORSPACE_DCI_P3 },
+};
+
+const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(colorspaces); ++i) {
+ if (colorspaces[i].cs == cs)
+ return colorspaces[i].name;
+ }
+
+ return "unknown";
+}
+
enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string,
unsigned int length)
{
@@ -289,6 +289,16 @@ int v4l2_subdev_parse_setup_formats(struct media_device *media, const char *p);
const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code);
/**
+ * @brief Convert colorspace to string.
+ * @param code - input string
+ *
+ * Convert colorspace @a to a human-readable string.
+ *
+ * @return A pointer to a string on success, NULL on failure.
+ */
+const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs);
+
+/**
* @brief Parse string to media bus pixel code.
* @param string - input string
* @param length - length of the string