Commit 5de75b1d authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Mauro Carvalho Chehab

[media] rcar-vin: refactor pad lookup code

The pad lookup code can be broken out to increase readability and to
reduce code duplication.
Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 1eb36419
...@@ -870,11 +870,25 @@ static void rvin_notify(struct v4l2_subdev *sd, ...@@ -870,11 +870,25 @@ static void rvin_notify(struct v4l2_subdev *sd,
} }
} }
static int rvin_find_pad(struct v4l2_subdev *sd, int direction)
{
unsigned int pad;
if (sd->entity.num_pads <= 1)
return 0;
for (pad = 0; pad < sd->entity.num_pads; pad++)
if (sd->entity.pads[pad].flags & direction)
return pad;
return -EINVAL;
}
int rvin_v4l2_probe(struct rvin_dev *vin) int rvin_v4l2_probe(struct rvin_dev *vin)
{ {
struct video_device *vdev = &vin->vdev; struct video_device *vdev = &vin->vdev;
struct v4l2_subdev *sd = vin_to_source(vin); struct v4l2_subdev *sd = vin_to_source(vin);
int pad_idx, ret; int ret;
v4l2_set_subdev_hostdata(sd, vin); v4l2_set_subdev_hostdata(sd, vin);
...@@ -920,21 +934,13 @@ int rvin_v4l2_probe(struct rvin_dev *vin) ...@@ -920,21 +934,13 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE; V4L2_CAP_READWRITE;
vin->digital.source_pad = 0; ret = rvin_find_pad(sd, MEDIA_PAD_FL_SOURCE);
for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++) if (ret < 0)
if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SOURCE) return ret;
break; vin->digital.source_pad = ret;
if (pad_idx >= sd->entity.num_pads)
return -EINVAL;
vin->digital.source_pad = pad_idx;
vin->digital.sink_pad = 0; ret = rvin_find_pad(sd, MEDIA_PAD_FL_SINK);
for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++) vin->digital.sink_pad = ret < 0 ? 0 : ret;
if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SINK) {
vin->digital.sink_pad = pad_idx;
break;
}
vin->format.pixelformat = RVIN_DEFAULT_FORMAT; vin->format.pixelformat = RVIN_DEFAULT_FORMAT;
rvin_reset_format(vin); rvin_reset_format(vin);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment