media: rcar-vin: Rework parallel firmware parsing

Rework the parallel firmware parsing code to not use the soon to be
removed v4l2_async_notifier_parse_fwnode_endpoints_by_port() helper. The
change only aims to prepare for the removing of the old helper and there
are no functional change.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Niklas Söderlund 2020-11-25 17:44:47 +01:00 committed by Mauro Carvalho Chehab
parent d7592b2ec9
commit b9ad52aafe

View file

@ -604,32 +604,56 @@ static const struct v4l2_async_notifier_operations rvin_parallel_notify_ops = {
.complete = rvin_parallel_notify_complete, .complete = rvin_parallel_notify_complete,
}; };
static int rvin_parallel_parse_v4l2(struct device *dev, static int rvin_parallel_parse_of(struct rvin_dev *vin)
struct v4l2_fwnode_endpoint *vep,
struct v4l2_async_subdev *asd)
{ {
struct rvin_dev *vin = dev_get_drvdata(dev); struct fwnode_handle *ep, *fwnode;
struct v4l2_fwnode_endpoint vep = {
.bus_type = V4L2_MBUS_UNKNOWN,
};
struct v4l2_async_subdev *asd;
int ret;
if (vep->base.port || vep->base.id) ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(vin->dev), 0, 0, 0);
return -ENOTCONN; if (!ep)
return 0;
vin->parallel.mbus_type = vep->bus_type; fwnode = fwnode_graph_get_remote_endpoint(ep);
ret = v4l2_fwnode_endpoint_parse(ep, &vep);
fwnode_handle_put(ep);
if (ret) {
vin_err(vin, "Failed to parse %pOF\n", to_of_node(fwnode));
ret = -EINVAL;
goto out;
}
switch (vin->parallel.mbus_type) { switch (vep.bus_type) {
case V4L2_MBUS_PARALLEL: case V4L2_MBUS_PARALLEL:
case V4L2_MBUS_BT656: case V4L2_MBUS_BT656:
vin_dbg(vin, "Found %s media bus\n", vin_dbg(vin, "Found %s media bus\n",
vin->parallel.mbus_type == V4L2_MBUS_PARALLEL ? vep.bus_type == V4L2_MBUS_PARALLEL ?
"PARALLEL" : "BT656"); "PARALLEL" : "BT656");
vin->parallel.bus = vep->bus.parallel; vin->parallel.mbus_type = vep.bus_type;
vin->parallel.bus = vep.bus.parallel;
break; break;
default: default:
vin_err(vin, "Unknown media bus type\n"); vin_err(vin, "Unknown media bus type\n");
return -EINVAL; ret = -EINVAL;
goto out;
}
asd = v4l2_async_notifier_add_fwnode_subdev(&vin->notifier, fwnode,
sizeof(*asd));
if (IS_ERR(asd)) {
ret = PTR_ERR(asd);
goto out;
} }
vin->parallel.asd = asd; vin->parallel.asd = asd;
vin_dbg(vin, "Add parallel OF device %pOF\n", to_of_node(fwnode));
out:
fwnode_handle_put(fwnode);
return 0; return 0;
} }
@ -639,9 +663,7 @@ static int rvin_parallel_init(struct rvin_dev *vin)
v4l2_async_notifier_init(&vin->notifier); v4l2_async_notifier_init(&vin->notifier);
ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port( ret = rvin_parallel_parse_of(vin);
vin->dev, &vin->notifier, sizeof(*vin->parallel.asd),
0, rvin_parallel_parse_v4l2);
if (ret) if (ret)
return ret; return ret;