diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-06-02 16:39:13 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-06-02 17:06:04 +0200 |
commit | 0700edb0d8fb3965cc80a2c30b101cab35d0b93f (patch) | |
tree | 58eab877f98f26012ebceeb4b6218e860b9299c1 /subdev.c | |
parent | 293ec4a8813e6d7d68dc147dff102d3a61396515 (diff) |
Print active formats when printing device topology
When run with the -p argument, print the active format on all subdev
pads.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'subdev.c')
-rw-r--r-- | subdev.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -31,6 +31,45 @@ #include "media.h" #include "subdev.h" +#include "tools.h" + +static struct { + const char *name; + enum v4l2_mbus_pixelcode code; +} mbus_formats[] = { + { "YUYV", V4L2_MBUS_FMT_YUYV16_1X16 }, + { "UYVY", V4L2_MBUS_FMT_UYVY16_1X16 }, + { "SGRBG10", V4L2_MBUS_FMT_SGRBG10_1X10 }, + { "SGRBG10_DPCM8", V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8 }, +}; + +const char *pixelcode_to_string(enum v4l2_mbus_pixelcode code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(mbus_formats); ++i) { + if (mbus_formats[i].code == code) + return mbus_formats[i].name; + } + + return "unknown"; +} + +enum v4l2_mbus_pixelcode string_to_pixelcode(const char *string, + unsigned int length) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(mbus_formats); ++i) { + if (strncmp(mbus_formats[i].name, string, length) == 0) + break; + } + + if (i == ARRAY_SIZE(mbus_formats)) + return (enum v4l2_mbus_pixelcode)-1; + + return mbus_formats[i].code; +} static int v4l2_subdev_open(struct media_entity *entity) { |