struct imx_media_async_subdev *imxasd;
struct v4l2_async_subdev *asd;
const char *devname = NULL;
- int ret = 0;
-
- mutex_lock(&imxmd->mutex);
+ int ret;
- if (pdev)
+ if (fwnode) {
+ asd = v4l2_async_notifier_add_fwnode_subdev(
+ &imxmd->notifier, fwnode, sizeof(*imxasd));
+ } else {
devname = dev_name(&pdev->dev);
-
- /* return -EEXIST if this asd already added */
- if (find_async_subdev(imxmd, fwnode, devname)) {
- if (np)
- dev_dbg(imxmd->md.dev, "%s: already added %pOFn\n",
- __func__, np);
- else
- dev_dbg(imxmd->md.dev, "%s: already added %s\n",
- __func__, devname);
- ret = -EEXIST;
- goto out;
+ asd = v4l2_async_notifier_add_devname_subdev(
+ &imxmd->notifier, devname, sizeof(*imxasd));
}
- imxasd = devm_kzalloc(imxmd->md.dev, sizeof(*imxasd), GFP_KERNEL);
- if (!imxasd) {
- ret = -ENOMEM;
- goto out;
+ if (IS_ERR(asd)) {
+ ret = PTR_ERR(asd);
- if (ret == -EEXIST)
- dev_dbg(imxmd->md.dev, "%s: already added %s\n",
- __func__, np ? np->name : devname);
++ if (ret == -EEXIST) {
++ if (np)
++ dev_dbg(imxmd->md.dev, "%s: already added %pOFn\n",
++ __func__, np);
++ else
++ dev_dbg(imxmd->md.dev, "%s: already added %s\n",
++ __func__, devname);
++ }
+ return ret;
}
- asd = &imxasd->asd;
- if (fwnode) {
- asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
- asd->match.fwnode = fwnode;
+ imxasd = to_imx_media_asd(asd);
+
+ if (devname)
+ imxasd->pdev = pdev;
+
- dev_dbg(imxmd->md.dev, "%s: added %s, match type %s\n",
- __func__, np ? np->name : devname, np ? "FWNODE" : "DEVNAME");
++ if (np)
+ dev_dbg(imxmd->md.dev, "%s: added %pOFn, match type FWNODE\n",
+ __func__, np);
- } else {
- asd->match_type = V4L2_ASYNC_MATCH_DEVNAME;
- asd->match.device_name = devname;
- imxasd->pdev = pdev;
++ else
+ dev_dbg(imxmd->md.dev, "%s: added %s, match type DEVNAME\n",
+ __func__, devname);
- }
-
- list_add_tail(&imxasd->list, &imxmd->asd_list);
-
- imxmd->subdev_notifier.num_subdevs++;
- out:
- mutex_unlock(&imxmd->mutex);
- return ret;
+ return 0;
}
/*
#include <video/imx-ipu-v3.h>
#include "imx-media.h"
- static int of_get_port_count(const struct device_node *np)
+ static int of_add_csi(struct imx_media_dev *imxmd, struct device_node *csi_np)
{
- struct device_node *ports, *child;
- int num = 0;
+ int ret;
- /* check if this node has a ports subnode */
- ports = of_get_child_by_name(np, "ports");
- if (ports)
- np = ports;
-
- for_each_child_of_node(np, child)
- if (of_node_cmp(child->name, "port") == 0)
- num++;
-
- of_node_put(ports);
- return num;
- }
-
- /*
- * find the remote device node given local endpoint node
- */
- static bool of_get_remote(struct device_node *epnode,
- struct device_node **remote_node)
- {
- struct device_node *rp, *rpp;
- struct device_node *remote;
- bool is_csi_port;
-
- rp = of_graph_get_remote_port(epnode);
- rpp = of_graph_get_remote_port_parent(epnode);
-
- if (of_device_is_compatible(rpp, "fsl,imx6q-ipu")) {
- /* the remote is one of the CSI ports */
- remote = rp;
- of_node_put(rpp);
- is_csi_port = true;
- } else {
- remote = rpp;
- of_node_put(rp);
- is_csi_port = false;
- }
-
- if (!of_device_is_available(remote)) {
- of_node_put(remote);
- *remote_node = NULL;
- } else {
- *remote_node = remote;
- }
-
- return is_csi_port;
- }
-
- static int
- of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
- bool is_csi_port)
- {
- int i, num_ports, ret;
-
- if (!of_device_is_available(sd_np)) {
+ if (!of_device_is_available(csi_np)) {
- dev_dbg(imxmd->md.dev, "%s: %s not enabled\n", __func__,
- csi_np->name);
+ dev_dbg(imxmd->md.dev, "%s: %pOFn not enabled\n", __func__,
- sd_np);
++ csi_np);
/* unavailable is not an error */
return 0;
}