static int rvin_digitial_parse_v4l2(struct rvin_dev *vin, struct device_node *ep, struct v4l2_mbus_config *mbus_cfg) { struct v4l2_fwnode_endpoint v4l2_ep; int ret; ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &v4l2_ep); if (ret) { vin_err(vin, "Could not parse v4l2 endpoint\n"); return -EINVAL; } mbus_cfg->type = v4l2_ep.bus_type; switch (mbus_cfg->type) { case V4L2_MBUS_PARALLEL: vin_dbg(vin, "Found PARALLEL media bus\n"); mbus_cfg->flags = v4l2_ep.bus.parallel.flags; break; case V4L2_MBUS_BT656: vin_dbg(vin, "Found BT656 media bus\n"); mbus_cfg->flags = 0; break; default: vin_err(vin, "Unknown media bus type\n"); return -EINVAL; } return 0; }
static int rvin_digital_graph_parse(struct rvin_dev *vin) { struct device_node *ep, *np; int ret; vin->digital.asd.match.fwnode.fwnode = NULL; vin->digital.subdev = NULL; /* * Port 0 id 0 is local digital input, try to get it. * Not all instances can or will have this, that is OK */ ep = of_graph_get_endpoint_by_regs(vin->dev->of_node, 0, 0); if (!ep) return 0; np = of_graph_get_remote_port_parent(ep); if (!np) { vin_err(vin, "No remote parent for digital input\n"); of_node_put(ep); return -EINVAL; } of_node_put(np); ret = rvin_digitial_parse_v4l2(vin, ep, &vin->digital.mbus_cfg); of_node_put(ep); if (ret) return ret; vin->digital.asd.match.fwnode.fwnode = of_fwnode_handle(np); vin->digital.asd.match_type = V4L2_ASYNC_MATCH_FWNODE; return 0; }
static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, struct v4l2_fwnode_endpoint *ep, bool skip_mux) { struct device_node *endpoint, *port; struct media_entity *src; struct v4l2_subdev *sd; struct media_pad *pad; if (!csi->src_sd) return -EPIPE; src = &csi->src_sd->entity; skip_video_mux: /* get source pad of entity directly upstream from src */ pad = imx_media_pipeline_pad(src, 0, 0, true); if (IS_ERR(pad)) return PTR_ERR(pad); sd = media_entity_to_v4l2_subdev(pad->entity); /* To get bus type we may need to skip video mux */ if (skip_mux && src->function == MEDIA_ENT_F_VID_MUX) { src = &sd->entity; goto skip_video_mux; } /* * NOTE: this assumes an OF-graph port id is the same as a * media pad index. */ port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); if (!port) return -ENODEV; endpoint = of_get_next_child(port, NULL); of_node_put(port); if (!endpoint) return -ENODEV; v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); of_node_put(endpoint); return 0; }