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 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; }