msm: camera: common: Add component helper support in camera
Due to the asynchronous nature of platform probes, inter dependency between drivers needs to be taken care during kernel boot up. Component helper provides the facility of adding matching drivers in a list ordered in the way we want to bind those drivers. The CRM driver acts as component master to make sure all slave drivers are bound before it returns from its own bind call. Add support for serializing platform probes through component framework. CRs-Fixed: 2584631 Change-Id: I345da1d2b9cccf6021ac6fc899143013b7714ec4 Signed-off-by: Mukund Madhusudan Atre <matre@codeaurora.org>
这个提交包含在:
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "cam_jpeg_dev.h"
|
||||
#include "cam_debug_util.h"
|
||||
#include "cam_smmu_api.h"
|
||||
#include "camera_main.h"
|
||||
|
||||
#define CAM_JPEG_DEV_NAME "cam-jpeg"
|
||||
|
||||
@@ -92,32 +93,15 @@ static const struct v4l2_subdev_internal_ops cam_jpeg_subdev_internal_ops = {
|
||||
.open = cam_jpeg_subdev_open,
|
||||
};
|
||||
|
||||
static int cam_jpeg_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
int rc;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CAM_JPEG_CTX_MAX; i++) {
|
||||
rc = cam_jpeg_context_deinit(&g_jpeg_dev.ctx_jpeg[i]);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_JPEG, "JPEG context %d deinit failed %d",
|
||||
i, rc);
|
||||
}
|
||||
|
||||
rc = cam_subdev_remove(&g_jpeg_dev.sd);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_JPEG, "Unregister failed %d", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_jpeg_dev_probe(struct platform_device *pdev)
|
||||
static int cam_jpeg_dev_component_bind(struct device *dev,
|
||||
struct device *master_dev, void *data)
|
||||
{
|
||||
int rc;
|
||||
int i;
|
||||
struct cam_hw_mgr_intf hw_mgr_intf;
|
||||
struct cam_node *node;
|
||||
int iommu_hdl = -1;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
|
||||
g_jpeg_dev.sd.internal_ops = &cam_jpeg_subdev_internal_ops;
|
||||
rc = cam_subdev_probe(&g_jpeg_dev.sd, pdev, CAM_JPEG_DEV_NAME,
|
||||
@@ -159,7 +143,7 @@ static int cam_jpeg_dev_probe(struct platform_device *pdev)
|
||||
|
||||
mutex_init(&g_jpeg_dev.jpeg_mutex);
|
||||
|
||||
CAM_INFO(CAM_JPEG, "Camera JPEG probe complete");
|
||||
CAM_INFO(CAM_JPEG, "Component bound successfully");
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -174,7 +158,49 @@ err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static struct platform_driver jpeg_driver = {
|
||||
static void cam_jpeg_dev_component_unbind(struct device *dev,
|
||||
struct device *master_dev, void *data)
|
||||
{
|
||||
int rc;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CAM_CTX_MAX; i++) {
|
||||
rc = cam_jpeg_context_deinit(&g_jpeg_dev.ctx_jpeg[i]);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_JPEG, "JPEG context %d deinit failed %d",
|
||||
i, rc);
|
||||
}
|
||||
|
||||
rc = cam_subdev_remove(&g_jpeg_dev.sd);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_JPEG, "Unregister failed %d", rc);
|
||||
}
|
||||
|
||||
const static struct component_ops cam_jpeg_dev_component_ops = {
|
||||
.bind = cam_jpeg_dev_component_bind,
|
||||
.unbind = cam_jpeg_dev_component_unbind,
|
||||
};
|
||||
|
||||
static int cam_jpeg_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
component_del(&pdev->dev, &cam_jpeg_dev_component_ops);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cam_jpeg_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
CAM_DBG(CAM_JPEG, "Adding JPEG component");
|
||||
rc = component_add(&pdev->dev, &cam_jpeg_dev_component_ops);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_JPEG, "failed to add component rc: %d", rc);
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
struct platform_driver jpeg_driver = {
|
||||
.probe = cam_jpeg_dev_probe,
|
||||
.remove = cam_jpeg_dev_remove,
|
||||
.driver = {
|
||||
|
在新工单中引用
屏蔽一个用户