Skip to content

Commit

Permalink
media: v4l: subdev: Improve link format validation debug messages
Browse files Browse the repository at this point in the history
Commit db8e94e upstream

The existing link format validation failure debug message in media-entity.c
helped to pinpoint 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]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Sakari Ailus authored and yafen committed May 30, 2022
1 parent 35cde69 commit ab55574
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions drivers/media/v4l2-core/v4l2-subdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,21 +768,55 @@ 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;
if (pass)
return 0;

dev_dbg(sd->entity.graph_obj.mdev->dev,
"%s: link was \"%s\":%u -> \"%s\":%u\n", __func__,
link->source->entity->name, link->source->index,
link->sink->entity->name, link->sink->index);

return -EPIPE;
}
EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate_default);

Expand Down

0 comments on commit ab55574

Please sign in to comment.