@@ -1260,3 +1260,9 @@ int media_entity_get_fd(struct media_entity *entity)
{
return entity->fd;
}
+
+void media_entity_set_subdev_fmt(struct media_entity *entity,
+ struct v4l2_subdev_format *fmt)
+{
+ entity->subdev_fmt = *fmt;
+}
@@ -786,3 +786,37 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
entity->info.name);
return 0;
}
+
+int 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\n");
+ return 0;
+ }
+
+ if (fmt1->height != fmt2->height) {
+ printf("height mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->code != fmt2->code) {
+ printf("mbus code mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->field != fmt2->field) {
+ printf("field mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->colorspace != fmt2->colorspace) {
+ printf("colorspace mismatch\n");
+ return 0;
+ }
+
+ return 1;
+}
@@ -23,6 +23,7 @@
#define __MEDIA_PRIV_H__
#include <linux/media.h>
+#include <linux/v4l2-subdev.h>
#include "mediactl.h"
@@ -34,6 +35,8 @@ struct media_entity {
unsigned int max_links;
unsigned int num_links;
+ struct v4l2_subdev_format subdev_fmt;
+
char devname[32];
int fd;
};
@@ -42,6 +42,7 @@ struct media_pad {
struct media_device;
struct media_entity;
+struct v4l2_subdev_format;
/**
* @brief Create a new media device.
@@ -611,4 +612,15 @@ int media_entity_get_sink_pad_index(struct media_entity *entity);
*/
int media_entity_get_fd(struct media_entity *entity);
+/**
+ * @brief Set sub-device format
+ * @param entity - media entity
+ * @param fmt - pointer to the sub-device format structure
+ *
+ * This function sets the format of the sub-device related
+ * to this entity.
+ */
+void media_entity_set_subdev_fmt(struct media_entity *entity,
+ struct v4l2_subdev_format *fmt);
+
#endif
@@ -270,4 +270,16 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
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
+ */
+int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1,
+ struct v4l2_mbus_framefmt *fmt2);
+
#endif