diff options
Diffstat (limited to 'drivers/media/platform/am437x/am437x-vpfe.c')
-rw-r--r-- | drivers/media/platform/am437x/am437x-vpfe.c | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c index 56a5cb0d2152..a30cc2f7e4f1 100644 --- a/drivers/media/platform/am437x/am437x-vpfe.c +++ b/drivers/media/platform/am437x/am437x-vpfe.c @@ -1645,6 +1645,7 @@ static int vpfe_enum_size(struct file *file, void *priv, fse.index = fsize->index; fse.pad = 0; fse.code = mbus.code; + fse.which = V4L2_SUBDEV_FORMAT_ACTIVE; ret = v4l2_subdev_call(sdinfo->sd, pad, enum_frame_size, NULL, &fse); if (ret) return -EINVAL; @@ -1700,11 +1701,16 @@ static int vpfe_get_app_input_index(struct vpfe_device *vpfe, { struct vpfe_config *cfg = vpfe->cfg; struct vpfe_subdev_info *sdinfo; + struct i2c_client *client; + struct i2c_client *curr_client; int i, j = 0; + curr_client = v4l2_get_subdevdata(vpfe->current_subdev->sd); for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) { sdinfo = &cfg->sub_devs[i]; - if (!strcmp(sdinfo->name, vpfe->current_subdev->name)) { + client = v4l2_get_subdevdata(sdinfo->sd); + if (client->addr == curr_client->addr && + client->adapter->nr == client->adapter->nr) { if (vpfe->current_input >= 1) return -1; *app_input_index = j + vpfe->current_input; @@ -2296,20 +2302,10 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier, vpfe_dbg(1, vpfe, "vpfe_async_bound\n"); for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) { - sdinfo = &vpfe->cfg->sub_devs[i]; - - if (!strcmp(sdinfo->name, subdev->name)) { + if (vpfe->cfg->asd[i]->match.of.node == asd[i].match.of.node) { + sdinfo = &vpfe->cfg->sub_devs[i]; vpfe->sd[i] = subdev; - vpfe_info(vpfe, - "v4l2 sub device %s registered\n", - subdev->name); - vpfe->sd[i]->grp_id = - sdinfo->grp_id; - /* update tvnorms from the sub devices */ - for (j = 0; j < 1; j++) - vpfe->video_dev->tvnorms |= - sdinfo->inputs[j].std; - + vpfe->sd[i]->grp_id = sdinfo->grp_id; found = true; break; } @@ -2320,6 +2316,8 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier, return -EINVAL; } + vpfe->video_dev.tvnorms |= sdinfo->inputs[0].std; + /* setup the supported formats & indexes */ for (j = 0, i = 0; ; ++j) { struct vpfe_fmt *fmt; @@ -2327,6 +2325,7 @@ vpfe_async_bound(struct v4l2_async_notifier *notifier, memset(&mbus_code, 0, sizeof(mbus_code)); mbus_code.index = j; + mbus_code.which = V4L2_SUBDEV_FORMAT_ACTIVE; ret = v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &mbus_code); if (ret) @@ -2390,9 +2389,9 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe) INIT_LIST_HEAD(&vpfe->dma_queue); - vdev = vpfe->video_dev; + vdev = &vpfe->video_dev; strlcpy(vdev->name, VPFE_MODULE_NAME, sizeof(vdev->name)); - vdev->release = video_device_release; + vdev->release = video_device_release_empty; vdev->fops = &vpfe_fops; vdev->ioctl_ops = &vpfe_ioctl_ops; vdev->v4l2_dev = &vpfe->v4l2_dev; @@ -2400,7 +2399,7 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe) vdev->queue = q; vdev->lock = &vpfe->lock; video_set_drvdata(vdev, vpfe); - err = video_register_device(vpfe->video_dev, VFL_TYPE_GRABBER, -1); + err = video_register_device(&vpfe->video_dev, VFL_TYPE_GRABBER, -1); if (err) { vpfe_err(vpfe, "Unable to register video device.\n"); @@ -2425,7 +2424,7 @@ static int vpfe_async_complete(struct v4l2_async_notifier *notifier) static struct vpfe_config * vpfe_get_pdata(struct platform_device *pdev) { - struct device_node *endpoint = NULL, *rem = NULL; + struct device_node *endpoint = NULL; struct v4l2_of_endpoint bus_cfg; struct vpfe_subdev_info *sdinfo; struct vpfe_config *pdata; @@ -2443,6 +2442,8 @@ vpfe_get_pdata(struct platform_device *pdev) return NULL; for (i = 0; ; i++) { + struct device_node *rem; + endpoint = of_graph_get_next_endpoint(pdev->dev.of_node, endpoint); if (!endpoint) @@ -2497,14 +2498,17 @@ vpfe_get_pdata(struct platform_device *pdev) goto done; } - strncpy(sdinfo->name, rem->name, sizeof(sdinfo->name)); - pdata->asd[i] = devm_kzalloc(&pdev->dev, sizeof(struct v4l2_async_subdev), GFP_KERNEL); + if (!pdata->asd[i]) { + of_node_put(rem); + pdata = NULL; + goto done; + } + pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_OF; pdata->asd[i]->match.of.node = rem; - of_node_put(endpoint); of_node_put(rem); } @@ -2513,7 +2517,6 @@ vpfe_get_pdata(struct platform_device *pdev) done: of_node_put(endpoint); - of_node_put(rem); return NULL; } @@ -2561,17 +2564,11 @@ static int vpfe_probe(struct platform_device *pdev) return -EINVAL; } - vpfe->video_dev = video_device_alloc(); - if (!vpfe->video_dev) { - dev_err(&pdev->dev, "Unable to allocate video device\n"); - return -ENOMEM; - } - ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev); if (ret) { vpfe_err(vpfe, "Unable to register v4l2 device.\n"); - goto probe_out_video_release; + return ret; } /* set the driver data in platform device */ @@ -2609,9 +2606,6 @@ static int vpfe_probe(struct platform_device *pdev) probe_out_v4l2_unregister: v4l2_device_unregister(&vpfe->v4l2_dev); -probe_out_video_release: - if (!video_is_registered(vpfe->video_dev)) - video_device_release(vpfe->video_dev); return ret; } @@ -2628,7 +2622,7 @@ static int vpfe_remove(struct platform_device *pdev) v4l2_async_notifier_unregister(&vpfe->notifier); v4l2_device_unregister(&vpfe->v4l2_dev); - video_unregister_device(vpfe->video_dev); + video_unregister_device(&vpfe->video_dev); return 0; } |