Re: [PATCH v4l-utils v7 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats

2016-11-24 Thread Jacek Anaszewski

On 11/24/2016 03:36 PM, Sakari Ailus wrote:

Hi Jacek,

On Wed, Oct 12, 2016 at 04:35:21PM +0200, Jacek Anaszewski wrote:

This patch adds a function for checking whether two mbus formats
are compatible.


Compatible doesn't in general case mean the same as... the same.

On parallel busses a 10-bit source can be connected to an 8-bit sink-for
instance.

How about moving this to the plugin, and if someone else needs it, then we
move it out later?


This is a good idea, as I am checking not all fields of
v4l2_mbus_framefmt, but only those which matter during Exynos4 media
devuce pipeline format negotiation.

--
Best regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4l-utils v7 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats

2016-11-24 Thread Sakari Ailus
Hi Jacek,

On Wed, Oct 12, 2016 at 04:35:21PM +0200, Jacek Anaszewski wrote:
> This patch adds a function for checking whether two mbus formats
> are compatible.

Compatible doesn't in general case mean the same as... the same.

On parallel busses a 10-bit source can be connected to an 8-bit sink-for
instance.

How about moving this to the plugin, and if someone else needs it, then we
move it out later?

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4l-utils v7 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats

2016-10-12 Thread Jacek Anaszewski
This patch adds a function for checking whether two mbus formats
are compatible.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 utils/media-ctl/libv4l2subdev.c | 42 +
 utils/media-ctl/v4l2subdev.h| 21 +
 2 files changed, 63 insertions(+)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 31393bb..2ec9b5e 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -948,3 +948,45 @@ int v4l2_subdev_supports_v4l2_ctrl(struct media_device 
*media,
 
return 0;
 }
+
+enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare(
+   struct v4l2_mbus_framefmt *fmt1,
+   struct v4l2_mbus_framefmt *fmt2)
+{
+   if (fmt1 == NULL || fmt2 == NULL)
+   return 0;
+
+   if (fmt1->width != fmt2->width) {
+   printf("width mismatch (fmt1: %d, fmt2: %d)\n",
+  fmt1->width, fmt2->width);
+   return FMT_MISMATCH_WIDTH;
+   }
+
+   if (fmt1->height != fmt2->height) {
+   printf("height mismatch (fmt1: %d, fmt2: %d)\n",
+  fmt1->height, fmt2->height);
+   return FMT_MISMATCH_HEIGHT;
+   }
+
+   if (fmt1->code != fmt2->code) {
+   printf("mbus code mismatch (fmt1: %s, fmt2: %s)\n",
+   v4l2_subdev_pixelcode_to_string(fmt1->code),
+   v4l2_subdev_pixelcode_to_string(fmt2->code));
+   return FMT_MISMATCH_CODE;
+   }
+
+   if (fmt1->field != fmt2->field) {
+   printf("field mismatch (fmt1: %d, fmt2: %d)\n",
+  fmt1->field, fmt2->field);
+   return FMT_MISMATCH_FIELD;
+   }
+
+   if (fmt1->colorspace != fmt2->colorspace) {
+   printf("colorspace mismatch (fmt1: %s, fmt2: %s)\n",
+   v4l2_subdev_colorspace_to_string(fmt1->colorspace),
+   v4l2_subdev_colorspace_to_string(fmt2->colorspace));
+   return FMT_MISMATCH_COLORSPACE;
+   }
+
+   return FMT_MISMATCH_NONE;
+}
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index cf1250d..c438f71 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -28,6 +28,15 @@ struct media_device;
 struct media_entity;
 struct media_device;
 
+enum v4l2_subdev_fmt_mismatch {
+   FMT_MISMATCH_NONE = 0,
+   FMT_MISMATCH_WIDTH,
+   FMT_MISMATCH_HEIGHT,
+   FMT_MISMATCH_CODE,
+   FMT_MISMATCH_FIELD,
+   FMT_MISMATCH_COLORSPACE,
+};
+
 struct v4l2_subdev {
int fd;
unsigned int fd_owner:1;
@@ -342,5 +351,17 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(
 int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device,
   struct media_entity *entity,
   __u32 ctrl_id);
+/**
+ * @brief Compare mbus formats
+ * @param fmt1 - 1st mbus format to compare.
+ * @param fmt2 - 2nd mbus format to compare.
+ *
+ * Check whether two mbus formats are compatible.
+ *
+ * @return 1 if formats are compatible, 0 otherwise.
+ */
+enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare(
+   struct v4l2_mbus_framefmt *fmt1,
+   struct v4l2_mbus_framefmt *fmt2);
 
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html