All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] media-ctl: frame interval propagation and colorimetry
@ 2017-02-07 16:08 Philipp Zabel
  2017-02-07 16:08 ` [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval Philipp Zabel
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-02-07 16:08 UTC (permalink / raw)
  To: linux-media
  Cc: Laurent Pinchart, Hans Verkuil, Steve Longerbeam, Philipp Zabel

Hi,

while testing the i.MX6 CSI drivers I noticed that media-ctl currently does not
propagate frame intervals between source and sink pads of connected entities
like it does pad formats. It doesn't even support setting the frame interval
of pads with an index other than 0.
The first three patches fix that and also print the frame interval if set.
The final patch adds colorimetry support to the pad formats.

regards
Philipp

Philipp Zabel (4):
  media-ctl: add pad support to set/get_frame_interval
  media-ctl: print the configured frame interval
  media-ctl: propagate frame interval
  media-ctl: add colorimetry support

 utils/media-ctl/libv4l2subdev.c | 295 ++++++++++++++++++++++++++++++++++++++--
 utils/media-ctl/media-ctl.c     |  25 ++++
 utils/media-ctl/options.c       |  22 ++-
 utils/media-ctl/v4l2subdev.h    |  84 +++++++++++-
 4 files changed, 411 insertions(+), 15 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval
  2017-02-07 16:08 [PATCH 0/4] media-ctl: frame interval propagation and colorimetry Philipp Zabel
@ 2017-02-07 16:08 ` Philipp Zabel
  2017-02-12 22:31   ` Sakari Ailus
  2017-02-07 16:08 ` [PATCH 2/4] media-ctl: print the configured frame interval Philipp Zabel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Philipp Zabel @ 2017-02-07 16:08 UTC (permalink / raw)
  To: linux-media
  Cc: Laurent Pinchart, Hans Verkuil, Steve Longerbeam, Philipp Zabel

This allows to set and get the frame interval on pads other than pad 0.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 utils/media-ctl/libv4l2subdev.c | 24 ++++++++++++++----------
 utils/media-ctl/v4l2subdev.h    |  4 ++--
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 3dcf943c..eadfc875 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -262,7 +262,8 @@ int v4l2_subdev_set_dv_timings(struct media_entity *entity,
 }
 
 int v4l2_subdev_get_frame_interval(struct media_entity *entity,
-				   struct v4l2_fract *interval)
+				   struct v4l2_fract *interval,
+				   unsigned int pad)
 {
 	struct v4l2_subdev_frame_interval ival;
 	int ret;
@@ -272,6 +273,7 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
 		return ret;
 
 	memset(&ival, 0, sizeof(ival));
+	ival.pad = pad;
 
 	ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, &ival);
 	if (ret < 0)
@@ -282,7 +284,8 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
 }
 
 int v4l2_subdev_set_frame_interval(struct media_entity *entity,
-				   struct v4l2_fract *interval)
+				   struct v4l2_fract *interval,
+				   unsigned int pad)
 {
 	struct v4l2_subdev_frame_interval ival;
 	int ret;
@@ -292,6 +295,7 @@ int v4l2_subdev_set_frame_interval(struct media_entity *entity,
 		return ret;
 
 	memset(&ival, 0, sizeof(ival));
+	ival.pad = pad;
 	ival.interval = *interval;
 
 	ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL, &ival);
@@ -617,7 +621,7 @@ static int set_selection(struct media_pad *pad, unsigned int target,
 	return 0;
 }
 
-static int set_frame_interval(struct media_entity *entity,
+static int set_frame_interval(struct media_pad *pad,
 			      struct v4l2_fract *interval)
 {
 	int ret;
@@ -625,20 +629,20 @@ static int set_frame_interval(struct media_entity *entity,
 	if (interval->numerator == 0)
 		return 0;
 
-	media_dbg(entity->media,
-		  "Setting up frame interval %u/%u on entity %s\n",
+	media_dbg(pad->entity->media,
+		  "Setting up frame interval %u/%u on entity %s pad %u\n",
 		  interval->numerator, interval->denominator,
-		  entity->info.name);
+		  pad->entity->info.name, pad->index);
 
-	ret = v4l2_subdev_set_frame_interval(entity, interval);
+	ret = v4l2_subdev_set_frame_interval(pad->entity, interval, pad->index);
 	if (ret < 0) {
-		media_dbg(entity->media,
+		media_dbg(pad->entity->media,
 			  "Unable to set frame interval: %s (%d)",
 			  strerror(-ret), ret);
 		return ret;
 	}
 
-	media_dbg(entity->media, "Frame interval set: %u/%u\n",
+	media_dbg(pad->entity->media, "Frame interval set: %u/%u\n",
 		  interval->numerator, interval->denominator);
 
 	return 0;
@@ -685,7 +689,7 @@ static int v4l2_subdev_parse_setup_format(struct media_device *media,
 			return ret;
 	}
 
-	ret = set_frame_interval(pad->entity, &interval);
+	ret = set_frame_interval(pad, &interval);
 	if (ret < 0)
 		return ret;
 
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 9c8fee89..413094d5 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -200,7 +200,7 @@ int v4l2_subdev_set_dv_timings(struct media_entity *entity,
  */
 
 int v4l2_subdev_get_frame_interval(struct media_entity *entity,
-	struct v4l2_fract *interval);
+	struct v4l2_fract *interval, unsigned int pad);
 
 /**
  * @brief Set the frame interval on a sub-device.
@@ -217,7 +217,7 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
  * @return 0 on success, or a negative error code on failure.
  */
 int v4l2_subdev_set_frame_interval(struct media_entity *entity,
-	struct v4l2_fract *interval);
+	struct v4l2_fract *interval, unsigned int pad);
 
 /**
  * @brief Parse a string and apply format, crop and frame interval settings.
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] media-ctl: print the configured frame interval
  2017-02-07 16:08 [PATCH 0/4] media-ctl: frame interval propagation and colorimetry Philipp Zabel
  2017-02-07 16:08 ` [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval Philipp Zabel
@ 2017-02-07 16:08 ` Philipp Zabel
  2017-02-12 22:38   ` Sakari Ailus
  2017-02-07 16:08 ` [PATCH 3/4] media-ctl: propagate " Philipp Zabel
  2017-02-07 16:08 ` [PATCH 4/4] media-ctl: add colorimetry support Philipp Zabel
  3 siblings, 1 reply; 9+ messages in thread
From: Philipp Zabel @ 2017-02-07 16:08 UTC (permalink / raw)
  To: linux-media
  Cc: Laurent Pinchart, Hans Verkuil, Steve Longerbeam, Philipp Zabel

After the pad format, also print the frame interval, if already configured.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 utils/media-ctl/media-ctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
index 50adbe91..1be880c6 100644
--- a/utils/media-ctl/media-ctl.c
+++ b/utils/media-ctl/media-ctl.c
@@ -79,6 +79,7 @@ static void v4l2_subdev_print_format(struct media_entity *entity,
 	unsigned int pad, enum v4l2_subdev_format_whence which)
 {
 	struct v4l2_mbus_framefmt format;
+	struct v4l2_fract interval = { 0, 0 };
 	struct v4l2_rect rect;
 	int ret;
 
@@ -86,10 +87,17 @@ static void v4l2_subdev_print_format(struct media_entity *entity,
 	if (ret != 0)
 		return;
 
+	ret = v4l2_subdev_get_frame_interval(entity, &interval, pad);
+	if (ret != 0 && ret != -ENOTTY)
+		return;
+
 	printf("\t\t[fmt:%s/%ux%u",
 	       v4l2_subdev_pixelcode_to_string(format.code),
 	       format.width, format.height);
 
+	if (interval.numerator || interval.denominator)
+		printf("@%u/%u", interval.numerator, interval.denominator);
+
 	if (format.field)
 		printf(" field:%s", v4l2_subdev_field_to_string(format.field));
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] media-ctl: propagate frame interval
  2017-02-07 16:08 [PATCH 0/4] media-ctl: frame interval propagation and colorimetry Philipp Zabel
  2017-02-07 16:08 ` [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval Philipp Zabel
  2017-02-07 16:08 ` [PATCH 2/4] media-ctl: print the configured frame interval Philipp Zabel
@ 2017-02-07 16:08 ` Philipp Zabel
  2017-02-12 22:44   ` Sakari Ailus
  2017-02-07 16:08 ` [PATCH 4/4] media-ctl: add colorimetry support Philipp Zabel
  3 siblings, 1 reply; 9+ messages in thread
From: Philipp Zabel @ 2017-02-07 16:08 UTC (permalink / raw)
  To: linux-media
  Cc: Laurent Pinchart, Hans Verkuil, Steve Longerbeam, Philipp Zabel

Same as the media bus format, the frame interval should be propagated
from output pads to connected entities' input pads.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 utils/media-ctl/libv4l2subdev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index eadfc875..81d6420f 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -694,8 +694,8 @@ static int v4l2_subdev_parse_setup_format(struct media_device *media,
 		return ret;
 
 
-	/* If the pad is an output pad, automatically set the same format on
-	 * the remote subdev input pads, if any.
+	/* If the pad is an output pad, automatically set the same format and
+	 * frame interval on the remote subdev input pads, if any.
 	 */
 	if (pad->flags & MEDIA_PAD_FL_SOURCE) {
 		for (i = 0; i < pad->entity->num_links; ++i) {
@@ -709,6 +709,10 @@ static int v4l2_subdev_parse_setup_format(struct media_device *media,
 			    link->sink->entity->info.type == MEDIA_ENT_T_V4L2_SUBDEV) {
 				remote_format = format;
 				set_format(link->sink, &remote_format);
+
+				ret = set_frame_interval(link->sink, &interval);
+				if (ret < 0)
+					return ret;
 			}
 		}
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] media-ctl: add colorimetry support
  2017-02-07 16:08 [PATCH 0/4] media-ctl: frame interval propagation and colorimetry Philipp Zabel
                   ` (2 preceding siblings ...)
  2017-02-07 16:08 ` [PATCH 3/4] media-ctl: propagate " Philipp Zabel
@ 2017-02-07 16:08 ` Philipp Zabel
  2017-02-12 22:50   ` Sakari Ailus
  3 siblings, 1 reply; 9+ messages in thread
From: Philipp Zabel @ 2017-02-07 16:08 UTC (permalink / raw)
  To: linux-media
  Cc: Laurent Pinchart, Hans Verkuil, Steve Longerbeam, Philipp Zabel

media-ctl can be used to propagate v4l2 subdevice pad formats from
source pads of one subdevice to another one's sink pads. These formats
include colorimetry information, so media-ctl should be able to print
or change it using the --set/get-v4l2 option.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 utils/media-ctl/libv4l2subdev.c | 263 ++++++++++++++++++++++++++++++++++++++++
 utils/media-ctl/media-ctl.c     |  17 +++
 utils/media-ctl/options.c       |  22 +++-
 utils/media-ctl/v4l2subdev.h    |  80 ++++++++++++
 4 files changed, 381 insertions(+), 1 deletion(-)

diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 81d6420f..f01ed89c 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -511,6 +511,118 @@ static struct media_pad *v4l2_subdev_parse_pad_format(
 			continue;
 		}
 
+		if (strhazit("colorspace:", &p)) {
+			enum v4l2_colorspace colorspace;
+			char *strfield;
+
+			for (end = (char *)p; isalnum(*end) || *end == '-';
+			     ++end);
+
+			strfield = strndup(p, end - p);
+			if (!strfield) {
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			colorspace = v4l2_subdev_string_to_colorspace(strfield);
+			free(strfield);
+			if (colorspace == (enum v4l2_colorspace)-1) {
+				media_dbg(media, "Invalid colorspace value '%*s'\n",
+					  end - p, p);
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			format->colorspace = colorspace;
+
+			p = end;
+			continue;
+		}
+
+		if (strhazit("xfer:", &p)) {
+			enum v4l2_xfer_func xfer_func;
+			char *strfield;
+
+			for (end = (char *)p; isalnum(*end) || *end == '-';
+			     ++end);
+
+			strfield = strndup(p, end - p);
+			if (!strfield) {
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			xfer_func = v4l2_subdev_string_to_xfer_func(strfield);
+			free(strfield);
+			if (xfer_func == (enum v4l2_xfer_func)-1) {
+				media_dbg(media, "Invalid transfer function value '%*s'\n",
+					  end - p, p);
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			format->xfer_func = xfer_func;
+
+			p = end;
+			continue;
+		}
+
+		if (strhazit("ycbcr:", &p)) {
+			enum v4l2_ycbcr_encoding ycbcr_enc;
+			char *strfield;
+
+			for (end = (char *)p; isalnum(*end) || *end == '-';
+			     ++end);
+
+			strfield = strndup(p, end - p);
+			if (!strfield) {
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			ycbcr_enc = v4l2_subdev_string_to_ycbcr_encoding(strfield);
+			free(strfield);
+			if (ycbcr_enc == (enum v4l2_ycbcr_encoding)-1) {
+				media_dbg(media, "Invalid YCbCr encoding value '%*s'\n",
+					  end - p, p);
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			format->ycbcr_enc = ycbcr_enc;
+
+			p = end;
+			continue;
+		}
+
+		if (strhazit("quantization:", &p)) {
+			enum v4l2_quantization quantization;
+			char *strfield;
+
+			for (end = (char *)p; isalnum(*end) || *end == '-';
+			     ++end);
+
+			strfield = strndup(p, end - p);
+			if (!strfield) {
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			quantization = v4l2_subdev_string_to_quantization(strfield);
+			free(strfield);
+			if (quantization == (enum v4l2_quantization)-1) {
+				media_dbg(media, "Invalid quantization value '%*s'\n",
+					  end - p, p);
+				*endp = (char *)p;
+				return NULL;
+			}
+
+			format->quantization = quantization;
+
+			p = end;
+			continue;
+		}
+
 		/*
 		 * Backward compatibility: crop rectangles can be specified
 		 * implicitly without the 'crop:' property name.
@@ -839,6 +951,157 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string)
 	return (enum v4l2_field)-1;
 }
 
+static struct {
+	const char *name;
+	enum v4l2_colorspace colorspace;
+} colorspaces[] = {
+	{ "default", V4L2_COLORSPACE_DEFAULT },
+	{ "smpte170m", V4L2_COLORSPACE_SMPTE170M },
+	{ "smpte240m", V4L2_COLORSPACE_SMPTE240M },
+	{ "rec709", V4L2_COLORSPACE_REC709 },
+	{ "bt878", V4L2_COLORSPACE_BT878 },
+	{ "470m", V4L2_COLORSPACE_470_SYSTEM_M },
+	{ "470bg", V4L2_COLORSPACE_470_SYSTEM_BG },
+	{ "jpeg", V4L2_COLORSPACE_JPEG },
+	{ "srgb", V4L2_COLORSPACE_SRGB },
+	{ "adobergb", V4L2_COLORSPACE_ADOBERGB },
+	{ "bt2020", V4L2_COLORSPACE_BT2020 },
+	{ "dcip3", V4L2_COLORSPACE_DCI_P3 },
+};
+
+const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace colorspace)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(colorspaces); ++i) {
+		if (colorspaces[i].colorspace == colorspace)
+			return colorspaces[i].name;
+	}
+
+	return "unknown";
+}
+
+enum v4l2_colorspace v4l2_subdev_string_to_colorspace(const char *string)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(colorspaces); ++i) {
+		if (strcasecmp(colorspaces[i].name, string) == 0)
+			return colorspaces[i].colorspace;
+	}
+
+	return (enum v4l2_colorspace)-1;
+}
+
+static struct {
+	const char *name;
+	enum v4l2_xfer_func xfer_func;
+} xfer_funcs[] = {
+	{ "default", V4L2_XFER_FUNC_DEFAULT },
+	{ "709", V4L2_XFER_FUNC_709 },
+	{ "srgb", V4L2_XFER_FUNC_SRGB },
+	{ "adobergb", V4L2_XFER_FUNC_ADOBERGB },
+	{ "smpte240m", V4L2_XFER_FUNC_SMPTE240M },
+	{ "smpte2084", V4L2_XFER_FUNC_SMPTE2084 },
+	{ "dcip3", V4L2_XFER_FUNC_DCI_P3 },
+	{ "none", V4L2_XFER_FUNC_NONE },
+};
+
+const char *v4l2_subdev_xfer_func_to_string(enum v4l2_xfer_func xfer_func)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(xfer_funcs); ++i) {
+		if (xfer_funcs[i].xfer_func == xfer_func)
+			return xfer_funcs[i].name;
+	}
+
+	return "unknown";
+}
+
+enum v4l2_xfer_func v4l2_subdev_string_to_xfer_func(const char *string)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(xfer_funcs); ++i) {
+		if (strcasecmp(xfer_funcs[i].name, string) == 0)
+			return xfer_funcs[i].xfer_func;
+	}
+
+	return (enum v4l2_xfer_func)-1;
+}
+
+static struct {
+	const char *name;
+	enum v4l2_ycbcr_encoding ycbcr_enc;
+} ycbcr_encs[] = {
+	{ "default", V4L2_YCBCR_ENC_DEFAULT },
+	{ "601", V4L2_YCBCR_ENC_601 },
+	{ "709", V4L2_YCBCR_ENC_709 },
+	{ "xv601", V4L2_YCBCR_ENC_XV601 },
+	{ "xv709", V4L2_YCBCR_ENC_XV709 },
+	{ "bt2020", V4L2_YCBCR_ENC_BT2020 },
+	{ "bt2020c", V4L2_YCBCR_ENC_BT2020_CONST_LUM },
+	{ "smpte240m", V4L2_YCBCR_ENC_SMPTE240M },
+};
+
+const char *v4l2_subdev_ycbcr_encoding_to_string(enum v4l2_ycbcr_encoding ycbcr_enc)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(ycbcr_encs); ++i) {
+		if (ycbcr_encs[i].ycbcr_enc == ycbcr_enc)
+			return ycbcr_encs[i].name;
+	}
+
+	return "unknown";
+}
+
+enum v4l2_ycbcr_encoding v4l2_subdev_string_to_ycbcr_encoding(const char *string)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(ycbcr_encs); ++i) {
+		if (strcasecmp(ycbcr_encs[i].name, string) == 0)
+			return ycbcr_encs[i].ycbcr_enc;
+	}
+
+	return (enum v4l2_ycbcr_encoding)-1;
+}
+
+static struct {
+	const char *name;
+	enum v4l2_quantization quantization;
+} quantizations[] = {
+	{ "default", V4L2_QUANTIZATION_DEFAULT },
+	{ "full-range", V4L2_QUANTIZATION_FULL_RANGE },
+	{ "lim-range", V4L2_QUANTIZATION_LIM_RANGE },
+};
+
+const char *v4l2_subdev_quantization_to_string(enum v4l2_quantization quantization)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(quantizations); ++i) {
+		if (quantizations[i].quantization == quantization)
+			return quantizations[i].name;
+	}
+
+	return "unknown";
+}
+
+enum v4l2_quantization v4l2_subdev_string_to_quantization(const char *string)
+{
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(quantizations); ++i) {
+		if (strcasecmp(quantizations[i].name, string) == 0)
+			return quantizations[i].quantization;
+	}
+
+	return (enum v4l2_quantization)-1;
+}
+
 static const enum v4l2_mbus_pixelcode mbus_codes[] = {
 #include "media-bus-format-codes.h"
 };
diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c
index 1be880c6..9c8cff6a 100644
--- a/utils/media-ctl/media-ctl.c
+++ b/utils/media-ctl/media-ctl.c
@@ -101,6 +101,23 @@ static void v4l2_subdev_print_format(struct media_entity *entity,
 	if (format.field)
 		printf(" field:%s", v4l2_subdev_field_to_string(format.field));
 
+	if (format.colorspace) {
+		printf(" colorspace:%s",
+		       v4l2_subdev_colorspace_to_string(format.colorspace));
+
+		if (format.xfer_func)
+			printf(" xfer:%s",
+			       v4l2_subdev_xfer_func_to_string(format.xfer_func));
+
+		if (format.ycbcr_enc)
+			printf(" ycbcr:%s",
+			       v4l2_subdev_ycbcr_encoding_to_string(format.ycbcr_enc));
+
+		if (format.quantization)
+			printf(" quantization:%s",
+			       v4l2_subdev_quantization_to_string(format.quantization));
+	}
+
 	ret = v4l2_subdev_get_selection(entity, &rect, pad,
 					V4L2_SEL_TGT_CROP_BOUNDS,
 					which);
diff --git a/utils/media-ctl/options.c b/utils/media-ctl/options.c
index 59841bbe..83ca1cac 100644
--- a/utils/media-ctl/options.c
+++ b/utils/media-ctl/options.c
@@ -68,7 +68,9 @@ static void usage(const char *argv0)
 	printf("\tv4l2-properties = v4l2-property { ',' v4l2-property } ;\n");
 	printf("\tv4l2-property   = v4l2-mbusfmt | v4l2-crop | v4l2-interval\n");
 	printf("\t                | v4l2-compose | v4l2-interval ;\n");
-	printf("\tv4l2-mbusfmt    = 'fmt:' fcc '/' size ; { 'field:' v4l2-field ; }\n");
+	printf("\tv4l2-mbusfmt    = 'fmt:' fcc '/' size ; { 'field:' v4l2-field ; } { 'colorspace:' v4l2-colorspace ; }\n");
+	printf("\t                   { 'xfer:' v4l2-xfer-func ; } { 'ycbcr-enc:' v4l2-ycbcr-enc-func ; }\n");
+	printf("\t                   { 'quantization:' v4l2-quant ; }\n");
 	printf("\tv4l2-crop       = 'crop:' rectangle ;\n");
 	printf("\tv4l2-compose    = 'compose:' rectangle ;\n");
 	printf("\tv4l2-interval   = '@' numerator '/' denominator ;\n");
@@ -91,6 +93,24 @@ static void usage(const char *argv0)
 	for (i = V4L2_FIELD_ANY; i <= V4L2_FIELD_INTERLACED_BT; i++)
 		printf("\t                %s\n",
 		       v4l2_subdev_field_to_string(i));
+
+	printf("\tv4l2-colorspace One of the following:\n");
+
+	for (i = V4L2_COLORSPACE_DEFAULT; i <= V4L2_COLORSPACE_DCI_P3; i++)
+		printf("\t                %s\n",
+		       v4l2_subdev_colorspace_to_string(i));
+
+	printf("\tv4l2-xfer-func  One of the following:\n");
+
+	for (i = V4L2_XFER_FUNC_DEFAULT; i <= V4L2_XFER_FUNC_SMPTE2084; i++)
+		printf("\t                %s\n",
+		       v4l2_subdev_xfer_func_to_string(i));
+
+	printf("\tv4l2-quant      One of the following:\n");
+
+	for (i = V4L2_QUANTIZATION_DEFAULT; i <= V4L2_QUANTIZATION_LIM_RANGE; i++)
+		printf("\t                %s\n",
+		       v4l2_subdev_quantization_to_string(i));
 }
 
 #define OPT_PRINT_DOT			256
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 413094d5..a1813911 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -276,6 +276,86 @@ const char *v4l2_subdev_field_to_string(enum v4l2_field field);
 enum v4l2_field v4l2_subdev_string_to_field(const char *string);
 
 /**
+ * @brief Convert a colorspace to string.
+ * @param colorspace - colorspace
+ *
+ * Convert colorspace @a colorspace 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 colorspace);
+
+/**
+ * @brief Parse string to colorspace.
+ * @param string - nul terminated string, textual colorspace
+ *
+ * Parse human readable string @a string to colorspace.
+ *
+ * @return colorspace on success, -1 on failure.
+ */
+enum v4l2_colorspace v4l2_subdev_string_to_colorspace(const char *string);
+
+/**
+ * @brief Convert a transfer function to string.
+ * @param xfer_func - transfer function
+ *
+ * Convert transfer function @a xfer_func to a human-readable string.
+ *
+ * @return A pointer to a string on success, NULL on failure.
+ */
+const char *v4l2_subdev_xfer_func_to_string(enum v4l2_xfer_func xfer_func);
+
+/**
+ * @brief Parse string to transfer function.
+ * @param string - nul terminated string, textual transfer function
+ *
+ * Parse human readable string @a string to xfer_func.
+ *
+ * @return xfer_func on success, -1 on failure.
+ */
+enum v4l2_xfer_func v4l2_subdev_string_to_xfer_func(const char *string);
+
+/**
+ * @brief Convert a YCbCr encoding to string.
+ * @param ycbcr_enc - YCbCr encoding
+ *
+ * Convert YCbCr encoding @a ycbcr_enc to a human-readable string.
+ *
+ * @return A pointer to a string on success, NULL on failure.
+ */
+const char *v4l2_subdev_ycbcr_encoding_to_string(enum v4l2_ycbcr_encoding ycbcr_enc);
+
+/**
+ * @brief Parse string to YCbCr encoding.
+ * @param string - nul terminated string, textual YCbCr encoding
+ *
+ * Parse human readable string @a string to YCbCr encoding.
+ *
+ * @return ycbcr_enc on success, -1 on failure.
+ */
+enum v4l2_ycbcr_encoding v4l2_subdev_string_to_ycbcr_encoding(const char *string);
+
+/**
+ * @brief Convert a quantization to string.
+ * @param quantization - quantization
+ *
+ * Convert quantization @a quantization to a human-readable string.
+ *
+ * @return A pointer to a string on success, NULL on failure.
+ */
+const char *v4l2_subdev_quantization_to_string(enum v4l2_quantization quantization);
+
+/**
+ * @brief Parse string to quantization.
+ * @param string - nul terminated string, textual quantization
+ *
+ * Parse human readable string @a string to quantization.
+ *
+ * @return quantization on success, -1 on failure.
+ */
+enum v4l2_quantization v4l2_subdev_string_to_quantization(const char *string);
+
+/**
  * @brief Enumerate library supported media bus pixel codes.
  * @param length - the number of the supported pixel codes
  *
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval
  2017-02-07 16:08 ` [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval Philipp Zabel
@ 2017-02-12 22:31   ` Sakari Ailus
  0 siblings, 0 replies; 9+ messages in thread
From: Sakari Ailus @ 2017-02-12 22:31 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-media, Laurent Pinchart, Hans Verkuil, Steve Longerbeam

Hi Philipp,

On Tue, Feb 07, 2017 at 05:08:47PM +0100, Philipp Zabel wrote:
> This allows to set and get the frame interval on pads other than pad 0.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  utils/media-ctl/libv4l2subdev.c | 24 ++++++++++++++----------
>  utils/media-ctl/v4l2subdev.h    |  4 ++--
>  2 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
> index 3dcf943c..eadfc875 100644
> --- a/utils/media-ctl/libv4l2subdev.c
> +++ b/utils/media-ctl/libv4l2subdev.c
> @@ -262,7 +262,8 @@ int v4l2_subdev_set_dv_timings(struct media_entity *entity,
>  }
>  
>  int v4l2_subdev_get_frame_interval(struct media_entity *entity,
> -				   struct v4l2_fract *interval)
> +				   struct v4l2_fract *interval,
> +				   unsigned int pad)
>  {
>  	struct v4l2_subdev_frame_interval ival;
>  	int ret;
> @@ -272,6 +273,7 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
>  		return ret;
>  
>  	memset(&ival, 0, sizeof(ival));
> +	ival.pad = pad;
>  
>  	ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, &ival);
>  	if (ret < 0)
> @@ -282,7 +284,8 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
>  }
>  
>  int v4l2_subdev_set_frame_interval(struct media_entity *entity,
> -				   struct v4l2_fract *interval)
> +				   struct v4l2_fract *interval,
> +				   unsigned int pad)
>  {
>  	struct v4l2_subdev_frame_interval ival;
>  	int ret;
> @@ -292,6 +295,7 @@ int v4l2_subdev_set_frame_interval(struct media_entity *entity,
>  		return ret;
>  
>  	memset(&ival, 0, sizeof(ival));
> +	ival.pad = pad;
>  	ival.interval = *interval;
>  
>  	ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL, &ival);
> @@ -617,7 +621,7 @@ static int set_selection(struct media_pad *pad, unsigned int target,
>  	return 0;
>  }
>  
> -static int set_frame_interval(struct media_entity *entity,
> +static int set_frame_interval(struct media_pad *pad,
>  			      struct v4l2_fract *interval)
>  {
>  	int ret;
> @@ -625,20 +629,20 @@ static int set_frame_interval(struct media_entity *entity,
>  	if (interval->numerator == 0)
>  		return 0;
>  
> -	media_dbg(entity->media,
> -		  "Setting up frame interval %u/%u on entity %s\n",
> +	media_dbg(pad->entity->media,
> +		  "Setting up frame interval %u/%u on entity %s pad %u\n",

The usual notation for specifying the pad in debug messages has been
"%s/%u", entity, pad. Although the syntax appears to use %s:%u. So please
use %s/%u for now.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

>  		  interval->numerator, interval->denominator,
> -		  entity->info.name);
> +		  pad->entity->info.name, pad->index);
>  
> -	ret = v4l2_subdev_set_frame_interval(entity, interval);
> +	ret = v4l2_subdev_set_frame_interval(pad->entity, interval, pad->index);
>  	if (ret < 0) {
> -		media_dbg(entity->media,
> +		media_dbg(pad->entity->media,
>  			  "Unable to set frame interval: %s (%d)",
>  			  strerror(-ret), ret);
>  		return ret;
>  	}
>  
> -	media_dbg(entity->media, "Frame interval set: %u/%u\n",
> +	media_dbg(pad->entity->media, "Frame interval set: %u/%u\n",
>  		  interval->numerator, interval->denominator);
>  
>  	return 0;
> @@ -685,7 +689,7 @@ static int v4l2_subdev_parse_setup_format(struct media_device *media,
>  			return ret;
>  	}
>  
> -	ret = set_frame_interval(pad->entity, &interval);
> +	ret = set_frame_interval(pad, &interval);
>  	if (ret < 0)
>  		return ret;
>  
> diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
> index 9c8fee89..413094d5 100644
> --- a/utils/media-ctl/v4l2subdev.h
> +++ b/utils/media-ctl/v4l2subdev.h
> @@ -200,7 +200,7 @@ int v4l2_subdev_set_dv_timings(struct media_entity *entity,
>   */
>  
>  int v4l2_subdev_get_frame_interval(struct media_entity *entity,
> -	struct v4l2_fract *interval);
> +	struct v4l2_fract *interval, unsigned int pad);
>  
>  /**
>   * @brief Set the frame interval on a sub-device.
> @@ -217,7 +217,7 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
>   * @return 0 on success, or a negative error code on failure.
>   */
>  int v4l2_subdev_set_frame_interval(struct media_entity *entity,
> -	struct v4l2_fract *interval);
> +	struct v4l2_fract *interval, unsigned int pad);
>  
>  /**
>   * @brief Parse a string and apply format, crop and frame interval settings.
> -- 
> 2.11.0
> 

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] media-ctl: print the configured frame interval
  2017-02-07 16:08 ` [PATCH 2/4] media-ctl: print the configured frame interval Philipp Zabel
@ 2017-02-12 22:38   ` Sakari Ailus
  0 siblings, 0 replies; 9+ messages in thread
From: Sakari Ailus @ 2017-02-12 22:38 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-media, Laurent Pinchart, Hans Verkuil, Steve Longerbeam

On Tue, Feb 07, 2017 at 05:08:48PM +0100, Philipp Zabel wrote:
> After the pad format, also print the frame interval, if already configured.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] media-ctl: propagate frame interval
  2017-02-07 16:08 ` [PATCH 3/4] media-ctl: propagate " Philipp Zabel
@ 2017-02-12 22:44   ` Sakari Ailus
  0 siblings, 0 replies; 9+ messages in thread
From: Sakari Ailus @ 2017-02-12 22:44 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-media, Laurent Pinchart, Hans Verkuil, Steve Longerbeam

Hi Philipp,

On Tue, Feb 07, 2017 at 05:08:49PM +0100, Philipp Zabel wrote:
> Same as the media bus format, the frame interval should be propagated
> from output pads to connected entities' input pads.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] media-ctl: add colorimetry support
  2017-02-07 16:08 ` [PATCH 4/4] media-ctl: add colorimetry support Philipp Zabel
@ 2017-02-12 22:50   ` Sakari Ailus
  0 siblings, 0 replies; 9+ messages in thread
From: Sakari Ailus @ 2017-02-12 22:50 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-media, Laurent Pinchart, Hans Verkuil, Steve Longerbeam

On Tue, Feb 07, 2017 at 05:08:50PM +0100, Philipp Zabel wrote:
> media-ctl can be used to propagate v4l2 subdevice pad formats from
> source pads of one subdevice to another one's sink pads. These formats
> include colorimetry information, so media-ctl should be able to print
> or change it using the --set/get-v4l2 option.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-02-12 22:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 16:08 [PATCH 0/4] media-ctl: frame interval propagation and colorimetry Philipp Zabel
2017-02-07 16:08 ` [PATCH 1/4] media-ctl: add pad support to set/get_frame_interval Philipp Zabel
2017-02-12 22:31   ` Sakari Ailus
2017-02-07 16:08 ` [PATCH 2/4] media-ctl: print the configured frame interval Philipp Zabel
2017-02-12 22:38   ` Sakari Ailus
2017-02-07 16:08 ` [PATCH 3/4] media-ctl: propagate " Philipp Zabel
2017-02-12 22:44   ` Sakari Ailus
2017-02-07 16:08 ` [PATCH 4/4] media-ctl: add colorimetry support Philipp Zabel
2017-02-12 22:50   ` Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.