mirror of https://gitee.com/openkylin/linux.git
media: imx: mipi csi-2: Register a subdev notifier
Parse neighbor remote devices on the MIPI CSI-2 input port, add them to a subdev notifier, and register the subdev notifier for the MIPI CSI-2 receiver, by calling v4l2_async_register_fwnode_subdev(). csi2_parse_endpoints() is modified to be the parse_endpoint callback. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
c893500a16
commit
c5040f1b71
|
@ -551,35 +551,34 @@ static const struct v4l2_subdev_internal_ops csi2_internal_ops = {
|
||||||
.registered = csi2_registered,
|
.registered = csi2_registered,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int csi2_parse_endpoints(struct csi2_dev *csi2)
|
static int csi2_parse_endpoint(struct device *dev,
|
||||||
|
struct v4l2_fwnode_endpoint *vep,
|
||||||
|
struct v4l2_async_subdev *asd)
|
||||||
{
|
{
|
||||||
struct device_node *node = csi2->dev->of_node;
|
struct v4l2_subdev *sd = dev_get_drvdata(dev);
|
||||||
struct device_node *epnode;
|
struct csi2_dev *csi2 = sd_to_dev(sd);
|
||||||
struct v4l2_fwnode_endpoint ep;
|
|
||||||
|
|
||||||
epnode = of_graph_get_endpoint_by_regs(node, 0, -1);
|
if (!fwnode_device_is_available(asd->match.fwnode)) {
|
||||||
if (!epnode) {
|
v4l2_err(&csi2->sd, "remote is not available\n");
|
||||||
v4l2_err(&csi2->sd, "failed to get sink endpoint node\n");
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v4l2_fwnode_endpoint_parse(of_fwnode_handle(epnode), &ep);
|
if (vep->bus_type != V4L2_MBUS_CSI2) {
|
||||||
of_node_put(epnode);
|
|
||||||
|
|
||||||
if (ep.bus_type != V4L2_MBUS_CSI2) {
|
|
||||||
v4l2_err(&csi2->sd, "invalid bus type, must be MIPI CSI2\n");
|
v4l2_err(&csi2->sd, "invalid bus type, must be MIPI CSI2\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
csi2->bus = ep.bus.mipi_csi2;
|
csi2->bus = vep->bus.mipi_csi2;
|
||||||
|
|
||||||
dev_dbg(csi2->dev, "data lanes: %d\n", csi2->bus.num_data_lanes);
|
dev_dbg(csi2->dev, "data lanes: %d\n", csi2->bus.num_data_lanes);
|
||||||
dev_dbg(csi2->dev, "flags: 0x%08x\n", csi2->bus.flags);
|
dev_dbg(csi2->dev, "flags: 0x%08x\n", csi2->bus.flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int csi2_probe(struct platform_device *pdev)
|
static int csi2_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
unsigned int sink_port = 0;
|
||||||
struct csi2_dev *csi2;
|
struct csi2_dev *csi2;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -601,10 +600,6 @@ static int csi2_probe(struct platform_device *pdev)
|
||||||
csi2->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
|
csi2->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
|
||||||
csi2->sd.grp_id = IMX_MEDIA_GRP_ID_CSI2;
|
csi2->sd.grp_id = IMX_MEDIA_GRP_ID_CSI2;
|
||||||
|
|
||||||
ret = csi2_parse_endpoints(csi2);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
csi2->pllref_clk = devm_clk_get(&pdev->dev, "ref");
|
csi2->pllref_clk = devm_clk_get(&pdev->dev, "ref");
|
||||||
if (IS_ERR(csi2->pllref_clk)) {
|
if (IS_ERR(csi2->pllref_clk)) {
|
||||||
v4l2_err(&csi2->sd, "failed to get pll reference clock\n");
|
v4l2_err(&csi2->sd, "failed to get pll reference clock\n");
|
||||||
|
@ -654,7 +649,9 @@ static int csi2_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, &csi2->sd);
|
platform_set_drvdata(pdev, &csi2->sd);
|
||||||
|
|
||||||
ret = v4l2_async_register_subdev(&csi2->sd);
|
ret = v4l2_async_register_fwnode_subdev(
|
||||||
|
&csi2->sd, sizeof(struct v4l2_async_subdev),
|
||||||
|
&sink_port, 1, csi2_parse_endpoint);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto dphy_off;
|
goto dphy_off;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue