v4l: subdev: Improve link format validation debug messages
PATCH 1/1 v4l: subdev: Improve link format validation debug messages
The existing link format validation failure debug message in media-entity.c helped to poinpoint the point of failure but provided no additional information what's wrong. Tell the user exactly why the validation failed.
---
I pulled this old patch from the VC patchset. It can be merged now without the rest.
drivers/media/v4l2-core/v4l2-subdev.c | 40 ++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-)
drivers/media/v4l2-core/v4l2-subdev.c +33 -7
@@ -792,21 +792,47 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,struct v4l2_subdev_format *source_fmt, struct v4l2_subdev_format *sink_fmt) { + bool pass = true; +/* The width, height and code must match. */ -if (source_fmt->format.width != sink_fmt->format.width - || source_fmt->format.height != sink_fmt->format.height - || source_fmt->format.code != sink_fmt->format.code) -return -EPIPE ; +if (source_fmt->format.width != sink_fmt->format.width) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: width does not match (source %u, sink %u)\n" , + __func__, + source_fmt->format.width, sink_fmt->format.width); + pass = false; + } + +if (source_fmt->format.height != sink_fmt->format.height) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: height does not match (source %u, sink %u)\n" , + __func__, + source_fmt->format.height, sink_fmt->format.height); + pass = false; + } + +if (source_fmt->format.code != sink_fmt->format.code) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: media bus code does not match (source 0x%8.8x, sink 0x%8.8x)\n" , + __func__, + source_fmt->format.code, sink_fmt->format.code); + pass = false; + }/* The field order must match, or the sink field order must be NONE * to support interlaced hardware connected to bridges that support * progressive formats only. */ if (source_fmt->format.field != sink_fmt->format.field && - sink_fmt->format.field !=V4L2_FIELD_NONE ) -return -EPIPE ; + sink_fmt->format.field !=V4L2_FIELD_NONE ) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: field does not match (source %u, sink %u)\n" , + __func__, + source_fmt->format.field, sink_fmt->format.field); + pass = false; + } -return 0 ; +return pass ?0 : -EPIPE ; }EXPORT_SYMBOL_GPL (v4l2_subdev_link_validate_default);
Signature · 1 line
2.27.0
Hi Sakari,
Thank you for the patch.
Quoted 22 lines · Sakari Ailus
The existing link format validation failure debug message in
media-entity.chelped to poinpoint the point of failure but provided no additional information what's wrong. Tell the user exactly why the validation failed.Signed-off-by Sakari Ailus <[email protected]>---
I pulled this old patch from the VC patchset. It can be merged now without the rest.drivers/media/v4l2-core/v4l2-subdev.c | 40 ++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-)drivers/media/v4l2-core/v4l2-subdev.c +2
-0@@ -792,21 +792,47 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,struct v4l2_subdev_format *source_fmt, struct v4l2_subdev_format *sink_fmt) { + bool pass = true; +
drivers/media/v4l2-core/v4l2-subdev.c int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd, · line 802
Quoted 10 lines
drivers/media/v4l2-core/v4l2-subdev.c +5
-4/* The width, height and code must match. */ -if (source_fmt->format.width != sink_fmt->format.width - || source_fmt->format.height != sink_fmt->format.height - || source_fmt->format.code != sink_fmt->format.code) -return -EPIPE ; +if (source_fmt->format.width != sink_fmt->format.width) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: width does not match (source %u, sink %u)\n" , + __func__, + source_fmt->format.width, sink_fmt->format.width);
It would be nice to print the sink and source names and pads, but we don't have that information. Do you think we should print sd->name to help identifying which link is faulty ?
Quoted 39 lines
drivers/media/v4l2-core/v4l2-subdev.c +26
-3+ pass = false; + } + +if (source_fmt->format.height != sink_fmt->format.height) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: height does not match (source %u, sink %u)\n" , + __func__, + source_fmt->format.height, sink_fmt->format.height); + pass = false; + } + +if (source_fmt->format.code != sink_fmt->format.code) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: media bus code does not match (source 0x%8.8x, sink 0x%8.8x)\n" , + __func__, + source_fmt->format.code, sink_fmt->format.code); + pass = false; + }/* The field order must match, or the sink field order must be NONE * to support interlaced hardware connected to bridges that support * progressive formats only. */ if (source_fmt->format.field != sink_fmt->format.field && - sink_fmt->format.field !=V4L2_FIELD_NONE ) -return -EPIPE ; + sink_fmt->format.field !=V4L2_FIELD_NONE ) { +dev_dbg (sd->entity.graph_obj.mdev->dev, +"%s: field does not match (source %u, sink %u)\n" , + __func__, + source_fmt->format.field, sink_fmt->format.field); + pass = false; + } -return 0 ; +return pass ?0 : -EPIPE ; }EXPORT_SYMBOL_GPL (v4l2_subdev_link_validate_default);
Signature · 3 lines
Regards, Laurent Pinchart