Merge "msm: camera: common: Add component helper support in camera" into camera-kernel.lnx.4.0

This commit is contained in:
Camera Software Integration
2020-02-07 15:13:17 -08:00
committed by Gerrit - the friendly Code Review server
44 changed files with 1825 additions and 614 deletions

View File

@@ -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 "cam_actuator_dev.h"
@@ -8,6 +8,7 @@
#include "cam_actuator_soc.h"
#include "cam_actuator_core.h"
#include "cam_trace.h"
#include "camera_main.h"
static long cam_actuator_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
@@ -222,86 +223,14 @@ free_ctrl:
return rc;
}
static int32_t cam_actuator_platform_remove(struct platform_device *pdev)
static int cam_actuator_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
int32_t rc = 0;
struct cam_actuator_ctrl_t *a_ctrl;
struct cam_actuator_soc_private *soc_private;
struct cam_sensor_power_ctrl_t *power_info;
a_ctrl = platform_get_drvdata(pdev);
if (!a_ctrl) {
CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
return 0;
}
CAM_INFO(CAM_ACTUATOR, "platform remove invoked");
mutex_lock(&(a_ctrl->actuator_mutex));
cam_actuator_shutdown(a_ctrl);
mutex_unlock(&(a_ctrl->actuator_mutex));
cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
soc_private =
(struct cam_actuator_soc_private *)a_ctrl->soc_info.soc_private;
power_info = &soc_private->power_info;
kfree(a_ctrl->io_master_info.cci_client);
a_ctrl->io_master_info.cci_client = NULL;
kfree(a_ctrl->soc_info.soc_private);
a_ctrl->soc_info.soc_private = NULL;
kfree(a_ctrl->i2c_data.per_frame);
a_ctrl->i2c_data.per_frame = NULL;
v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, NULL);
platform_set_drvdata(pdev, NULL);
devm_kfree(&pdev->dev, a_ctrl);
return rc;
}
static int32_t cam_actuator_driver_i2c_remove(struct i2c_client *client)
{
struct cam_actuator_ctrl_t *a_ctrl =
i2c_get_clientdata(client);
struct cam_actuator_soc_private *soc_private;
struct cam_sensor_power_ctrl_t *power_info;
/* Handle I2C Devices */
if (!a_ctrl) {
CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
return -EINVAL;
}
CAM_INFO(CAM_ACTUATOR, "i2c remove invoked");
mutex_lock(&(a_ctrl->actuator_mutex));
cam_actuator_shutdown(a_ctrl);
mutex_unlock(&(a_ctrl->actuator_mutex));
cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
soc_private =
(struct cam_actuator_soc_private *)a_ctrl->soc_info.soc_private;
power_info = &soc_private->power_info;
/*Free Allocated Mem */
kfree(a_ctrl->i2c_data.per_frame);
a_ctrl->i2c_data.per_frame = NULL;
a_ctrl->soc_info.soc_private = NULL;
v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, NULL);
kfree(a_ctrl);
return 0;
}
static const struct of_device_id cam_actuator_driver_dt_match[] = {
{.compatible = "qcom,actuator"},
{}
};
static int32_t cam_actuator_driver_platform_probe(
struct platform_device *pdev)
{
int32_t rc = 0;
int32_t i = 0;
struct cam_actuator_ctrl_t *a_ctrl = NULL;
struct cam_actuator_soc_private *soc_private = NULL;
int32_t rc = 0;
int32_t i = 0;
struct cam_actuator_ctrl_t *a_ctrl = NULL;
struct cam_actuator_soc_private *soc_private = NULL;
struct platform_device *pdev = to_platform_device(dev);
/* Create actuator control structure */
a_ctrl = devm_kzalloc(&pdev->dev,
@@ -372,6 +301,7 @@ static int32_t cam_actuator_driver_platform_probe(
platform_set_drvdata(pdev, a_ctrl);
a_ctrl->cam_act_state = CAM_ACTUATOR_INIT;
CAM_DBG(CAM_ACTUATOR, "Component bound successfully");
return rc;
@@ -386,9 +316,106 @@ free_ctrl:
return rc;
}
static void cam_actuator_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
struct cam_actuator_ctrl_t *a_ctrl;
struct cam_actuator_soc_private *soc_private;
struct cam_sensor_power_ctrl_t *power_info;
struct platform_device *pdev = to_platform_device(dev);
a_ctrl = platform_get_drvdata(pdev);
if (!a_ctrl) {
CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
return;
}
mutex_lock(&(a_ctrl->actuator_mutex));
cam_actuator_shutdown(a_ctrl);
mutex_unlock(&(a_ctrl->actuator_mutex));
cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
soc_private =
(struct cam_actuator_soc_private *)a_ctrl->soc_info.soc_private;
power_info = &soc_private->power_info;
kfree(a_ctrl->io_master_info.cci_client);
a_ctrl->io_master_info.cci_client = NULL;
kfree(a_ctrl->soc_info.soc_private);
a_ctrl->soc_info.soc_private = NULL;
kfree(a_ctrl->i2c_data.per_frame);
a_ctrl->i2c_data.per_frame = NULL;
v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, NULL);
platform_set_drvdata(pdev, NULL);
devm_kfree(&pdev->dev, a_ctrl);
CAM_INFO(CAM_ACTUATOR, "Actuator component unbinded");
}
const static struct component_ops cam_actuator_component_ops = {
.bind = cam_actuator_component_bind,
.unbind = cam_actuator_component_unbind,
};
static int32_t cam_actuator_platform_remove(
struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_actuator_component_ops);
return 0;
}
static int32_t cam_actuator_driver_i2c_remove(struct i2c_client *client)
{
struct cam_actuator_ctrl_t *a_ctrl =
i2c_get_clientdata(client);
struct cam_actuator_soc_private *soc_private;
struct cam_sensor_power_ctrl_t *power_info;
/* Handle I2C Devices */
if (!a_ctrl) {
CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
return -EINVAL;
}
CAM_INFO(CAM_ACTUATOR, "i2c remove invoked");
mutex_lock(&(a_ctrl->actuator_mutex));
cam_actuator_shutdown(a_ctrl);
mutex_unlock(&(a_ctrl->actuator_mutex));
cam_unregister_subdev(&(a_ctrl->v4l2_dev_str));
soc_private =
(struct cam_actuator_soc_private *)a_ctrl->soc_info.soc_private;
power_info = &soc_private->power_info;
/*Free Allocated Mem */
kfree(a_ctrl->i2c_data.per_frame);
a_ctrl->i2c_data.per_frame = NULL;
a_ctrl->soc_info.soc_private = NULL;
v4l2_set_subdevdata(&a_ctrl->v4l2_dev_str.sd, NULL);
kfree(a_ctrl);
return 0;
}
static const struct of_device_id cam_actuator_driver_dt_match[] = {
{.compatible = "qcom,actuator"},
{}
};
static int32_t cam_actuator_driver_platform_probe(
struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_ACTUATOR, "Adding sensor actuator component");
rc = component_add(&pdev->dev, &cam_actuator_component_ops);
if (rc)
CAM_ERR(CAM_ICP, "failed to add component rc: %d", rc);
return rc;
}
MODULE_DEVICE_TABLE(of, cam_actuator_driver_dt_match);
static struct platform_driver cam_actuator_platform_driver = {
struct platform_driver cam_actuator_platform_driver = {
.probe = cam_actuator_driver_platform_probe,
.driver = {
.name = "qcom,actuator",

View File

@@ -7,6 +7,7 @@
#include "cam_req_mgr_dev.h"
#include "cam_cci_soc.h"
#include "cam_cci_core.h"
#include "camera_main.h"
#define CCI_MAX_DELAY 1000000
@@ -366,12 +367,14 @@ static const struct v4l2_subdev_ops cci_subdev_ops = {
static const struct v4l2_subdev_internal_ops cci_subdev_intern_ops;
static int cam_cci_platform_probe(struct platform_device *pdev)
static int cam_cci_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
struct cam_cpas_register_params cpas_parms;
struct cci_device *new_cci_dev;
struct cam_hw_soc_info *soc_info = NULL;
int rc = 0;
struct platform_device *pdev = to_platform_device(dev);
new_cci_dev = kzalloc(sizeof(struct cci_device),
GFP_KERNEL);
@@ -435,18 +438,22 @@ static int cam_cci_platform_probe(struct platform_device *pdev)
CAM_ERR(CAM_CCI, "CPAS registration failed");
goto cci_no_resource;
}
CAM_DBG(CAM_CCI, "CPAS registration successful handle=%d",
cpas_parms.client_handle);
new_cci_dev->cpas_handle = cpas_parms.client_handle;
CAM_DBG(CAM_CCI, "Component bound successfully");
return rc;
cci_no_resource:
kfree(new_cci_dev);
return rc;
}
static int cam_cci_device_remove(struct platform_device *pdev)
static void cam_cci_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
struct platform_device *pdev = to_platform_device(dev);
struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
struct cci_device *cci_dev =
v4l2_get_subdevdata(subdev);
@@ -454,6 +461,28 @@ static int cam_cci_device_remove(struct platform_device *pdev)
cam_cpas_unregister_client(cci_dev->cpas_handle);
cam_cci_soc_remove(pdev, cci_dev);
devm_kfree(&pdev->dev, cci_dev);
}
const static struct component_ops cam_cci_component_ops = {
.bind = cam_cci_component_bind,
.unbind = cam_cci_component_unbind,
};
static int cam_cci_platform_probe(struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_CCI, "Adding CCI component");
rc = component_add(&pdev->dev, &cam_cci_component_ops);
if (rc)
CAM_ERR(CAM_CCI, "failed to add component rc: %d", rc);
return rc;
}
static int cam_cci_device_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_cci_component_ops);
return 0;
}
@@ -464,7 +493,7 @@ static const struct of_device_id cam_cci_dt_match[] = {
MODULE_DEVICE_TABLE(of, cam_cci_dt_match);
static struct platform_driver cci_driver = {
struct platform_driver cci_driver = {
.probe = cam_cci_platform_probe,
.remove = cam_cci_device_remove,
.driver = {

View File

@@ -378,10 +378,6 @@ int cam_cci_parse_dt_info(struct platform_device *pdev,
cam_cci_init_cci_params(new_cci_dev);
cam_cci_init_clk_params(new_cci_dev);
rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
if (rc)
CAM_ERR(CAM_CCI, "failed to add child nodes, rc=%d", rc);
for (i = 0; i < MASTER_MAX; i++) {
new_cci_dev->write_wq[i] = create_singlethread_workqueue(
"cam_cci_wq");

View File

@@ -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 "cam_csiphy_dev.h"
@@ -8,6 +8,7 @@
#include "cam_csiphy_soc.h"
#include "cam_csiphy_core.h"
#include <media/cam_sensor.h>
#include "camera_main.h"
static long cam_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
@@ -104,11 +105,13 @@ static const struct v4l2_subdev_internal_ops csiphy_subdev_intern_ops = {
.close = cam_csiphy_subdev_close,
};
static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
static int cam_csiphy_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
struct cam_cpas_register_params cpas_parms;
struct csiphy_device *new_csiphy_dev;
int32_t rc = 0;
int32_t rc = 0;
struct platform_device *pdev = to_platform_device(dev);
new_csiphy_dev = devm_kzalloc(&pdev->dev,
sizeof(struct csiphy_device), GFP_KERNEL);
@@ -183,10 +186,12 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
CAM_ERR(CAM_CSIPHY, "CPAS registration failed rc: %d", rc);
goto csiphy_no_resource;
}
CAM_DBG(CAM_CSIPHY, "CPAS registration successful handle=%d",
cpas_parms.client_handle);
new_csiphy_dev->cpas_handle = cpas_parms.client_handle;
CAM_DBG(CAM_CSIPHY, "%s component bound successfully",
pdev->name);
return rc;
csiphy_no_resource:
mutex_destroy(&new_csiphy_dev->mutex);
@@ -195,15 +200,15 @@ csiphy_no_resource:
return rc;
}
static int32_t cam_csiphy_device_remove(struct platform_device *pdev)
static void cam_csiphy_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
struct v4l2_subdev *subdev =
platform_get_drvdata(pdev);
struct csiphy_device *csiphy_dev =
v4l2_get_subdevdata(subdev);
struct platform_device *pdev = to_platform_device(dev);
CAM_INFO(CAM_CSIPHY, "device remove invoked");
struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
struct csiphy_device *csiphy_dev = v4l2_get_subdevdata(subdev);
CAM_INFO(CAM_CSIPHY, "Unbind CSIPHY component");
cam_cpas_unregister_client(csiphy_dev->cpas_handle);
cam_csiphy_soc_release(csiphy_dev);
mutex_lock(&csiphy_dev->mutex);
@@ -215,7 +220,29 @@ static int32_t cam_csiphy_device_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&(csiphy_dev->v4l2_dev_str.sd), NULL);
devm_kfree(&pdev->dev, csiphy_dev);
}
const static struct component_ops cam_csiphy_component_ops = {
.bind = cam_csiphy_component_bind,
.unbind = cam_csiphy_component_unbind,
};
static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_CSIPHY, "Adding CSIPHY component");
rc = component_add(&pdev->dev, &cam_csiphy_component_ops);
if (rc)
CAM_ERR(CAM_CSIPHY, "failed to add component rc: %d", rc);
return rc;
}
static int32_t cam_csiphy_device_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_csiphy_component_ops);
return 0;
}
@@ -226,7 +253,7 @@ static const struct of_device_id cam_csiphy_dt_match[] = {
MODULE_DEVICE_TABLE(of, cam_csiphy_dt_match);
static struct platform_driver csiphy_driver = {
struct platform_driver csiphy_driver = {
.probe = cam_csiphy_platform_probe,
.remove = cam_csiphy_device_remove,
.driver = {

View File

@@ -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 "cam_eeprom_dev.h"
@@ -8,6 +8,7 @@
#include "cam_eeprom_soc.h"
#include "cam_eeprom_core.h"
#include "cam_debug_util.h"
#include "camera_main.h"
static long cam_eeprom_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
@@ -409,12 +410,13 @@ static int cam_eeprom_spi_driver_remove(struct spi_device *sdev)
return 0;
}
static int32_t cam_eeprom_platform_driver_probe(
struct platform_device *pdev)
static int cam_eeprom_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
int32_t rc = 0;
struct cam_eeprom_ctrl_t *e_ctrl = NULL;
struct cam_eeprom_soc_private *soc_private = NULL;
struct platform_device *pdev = to_platform_device(dev);
e_ctrl = kzalloc(sizeof(struct cam_eeprom_ctrl_t), GFP_KERNEL);
if (!e_ctrl)
@@ -469,6 +471,7 @@ static int32_t cam_eeprom_platform_driver_probe(
e_ctrl->bridge_intf.ops.apply_req = NULL;
platform_set_drvdata(pdev, e_ctrl);
e_ctrl->cam_eeprom_state = CAM_EEPROM_INIT;
CAM_DBG(CAM_EEPROM, "Component bound successfully");
return rc;
free_soc:
@@ -481,16 +484,18 @@ free_e_ctrl:
return rc;
}
static int cam_eeprom_platform_driver_remove(struct platform_device *pdev)
static void cam_eeprom_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
int i;
struct cam_eeprom_ctrl_t *e_ctrl;
struct cam_hw_soc_info *soc_info;
struct platform_device *pdev = to_platform_device(dev);
e_ctrl = platform_get_drvdata(pdev);
if (!e_ctrl) {
CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
return -EINVAL;
return;
}
CAM_INFO(CAM_EEPROM, "Platform driver remove invoked");
@@ -509,7 +514,29 @@ static int cam_eeprom_platform_driver_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, NULL);
kfree(e_ctrl);
}
const static struct component_ops cam_eeprom_component_ops = {
.bind = cam_eeprom_component_bind,
.unbind = cam_eeprom_component_unbind,
};
static int32_t cam_eeprom_platform_driver_probe(
struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_EEPROM, "Adding EEPROM Sensor component");
rc = component_add(&pdev->dev, &cam_eeprom_component_ops);
if (rc)
CAM_ERR(CAM_EEPROM, "failed to add component rc: %d", rc);
return rc;
}
static int cam_eeprom_platform_driver_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_eeprom_component_ops);
return 0;
}
@@ -521,7 +548,7 @@ static const struct of_device_id cam_eeprom_dt_match[] = {
MODULE_DEVICE_TABLE(of, cam_eeprom_dt_match);
static struct platform_driver cam_eeprom_platform_driver = {
struct platform_driver cam_eeprom_platform_driver = {
.driver = {
.name = "qcom,eeprom",
.owner = THIS_MODULE,

View File

@@ -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/module.h>
@@ -8,6 +8,7 @@
#include "cam_flash_soc.h"
#include "cam_flash_core.h"
#include "cam_common_util.h"
#include "camera_main.h"
static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
void *arg, struct cam_flash_private_soc *soc_private)
@@ -302,28 +303,6 @@ static long cam_flash_subdev_do_ioctl(struct v4l2_subdev *sd,
}
#endif
static int cam_flash_platform_remove(struct platform_device *pdev)
{
struct cam_flash_ctrl *fctrl;
fctrl = platform_get_drvdata(pdev);
if (!fctrl) {
CAM_ERR(CAM_FLASH, "Flash device is NULL");
return 0;
}
CAM_INFO(CAM_FLASH, "Platform remove invoked");
mutex_lock(&fctrl->flash_mutex);
cam_flash_shutdown(fctrl);
mutex_unlock(&fctrl->flash_mutex);
cam_unregister_subdev(&(fctrl->v4l2_dev_str));
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&fctrl->v4l2_dev_str.sd, NULL);
kfree(fctrl);
return 0;
}
static int32_t cam_flash_i2c_driver_remove(struct i2c_client *client)
{
int32_t rc = 0;
@@ -397,13 +376,15 @@ static int cam_flash_init_subdev(struct cam_flash_ctrl *fctrl)
return rc;
}
static int32_t cam_flash_platform_probe(struct platform_device *pdev)
static int cam_flash_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
int32_t rc = 0, i = 0;
struct cam_flash_ctrl *fctrl = NULL;
struct device_node *of_parent = NULL;
struct platform_device *pdev = to_platform_device(dev);
CAM_DBG(CAM_FLASH, "Enter");
CAM_DBG(CAM_FLASH, "Binding flash component");
if (!pdev->dev.of_node) {
CAM_ERR(CAM_FLASH, "of_node NULL");
return -EINVAL;
@@ -503,7 +484,7 @@ static int32_t cam_flash_platform_probe(struct platform_device *pdev)
mutex_init(&(fctrl->flash_mutex));
fctrl->flash_state = CAM_FLASH_STATE_INIT;
CAM_DBG(CAM_FLASH, "Probe success");
CAM_DBG(CAM_FLASH, "Component bound successfully");
return rc;
free_cci_resource:
@@ -520,6 +501,51 @@ free_resource:
return rc;
}
static void cam_flash_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
struct cam_flash_ctrl *fctrl;
struct platform_device *pdev = to_platform_device(dev);
fctrl = platform_get_drvdata(pdev);
if (!fctrl) {
CAM_ERR(CAM_FLASH, "Flash device is NULL");
return;
}
mutex_lock(&fctrl->flash_mutex);
cam_flash_shutdown(fctrl);
mutex_unlock(&fctrl->flash_mutex);
cam_unregister_subdev(&(fctrl->v4l2_dev_str));
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&fctrl->v4l2_dev_str.sd, NULL);
kfree(fctrl);
CAM_INFO(CAM_FLASH, "Flash Sensor component unbind");
}
const static struct component_ops cam_flash_component_ops = {
.bind = cam_flash_component_bind,
.unbind = cam_flash_component_unbind,
};
static int cam_flash_platform_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_flash_component_ops);
return 0;
}
static int32_t cam_flash_platform_probe(struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_FLASH, "Adding Flash Sensor component");
rc = component_add(&pdev->dev, &cam_flash_component_ops);
if (rc)
CAM_ERR(CAM_FLASH, "failed to add component rc: %d", rc);
return rc;
}
static int32_t cam_flash_i2c_driver_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -601,7 +627,7 @@ free_ctrl:
MODULE_DEVICE_TABLE(of, cam_flash_dt_match);
static struct platform_driver cam_flash_platform_driver = {
struct platform_driver cam_flash_platform_driver = {
.probe = cam_flash_platform_probe,
.remove = cam_flash_platform_remove,
.driver = {

View File

@@ -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 "cam_ois_dev.h"
@@ -8,6 +8,7 @@
#include "cam_ois_soc.h"
#include "cam_ois_core.h"
#include "cam_debug_util.h"
#include "camera_main.h"
static long cam_ois_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
@@ -244,12 +245,13 @@ static int cam_ois_i2c_driver_remove(struct i2c_client *client)
return 0;
}
static int32_t cam_ois_platform_driver_probe(
struct platform_device *pdev)
static int cam_ois_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
int32_t rc = 0;
struct cam_ois_ctrl_t *o_ctrl = NULL;
struct cam_ois_soc_private *soc_private = NULL;
struct platform_device *pdev = to_platform_device(dev);
o_ctrl = kzalloc(sizeof(struct cam_ois_ctrl_t), GFP_KERNEL);
if (!o_ctrl)
@@ -300,7 +302,7 @@ static int32_t cam_ois_platform_driver_probe(
platform_set_drvdata(pdev, o_ctrl);
o_ctrl->cam_ois_state = CAM_OIS_INIT;
CAM_DBG(CAM_OIS, "Component bound successfully");
return rc;
unreg_subdev:
cam_unregister_subdev(&(o_ctrl->v4l2_dev_str));
@@ -313,18 +315,20 @@ free_o_ctrl:
return rc;
}
static int cam_ois_platform_driver_remove(struct platform_device *pdev)
static void cam_ois_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
int i;
struct cam_ois_ctrl_t *o_ctrl;
struct cam_ois_soc_private *soc_private;
struct cam_sensor_power_ctrl_t *power_info;
struct cam_hw_soc_info *soc_info;
struct platform_device *pdev = to_platform_device(dev);
o_ctrl = platform_get_drvdata(pdev);
if (!o_ctrl) {
CAM_ERR(CAM_OIS, "ois device is NULL");
return -EINVAL;
return;
}
CAM_INFO(CAM_OIS, "platform driver remove invoked");
@@ -346,7 +350,29 @@ static int cam_ois_platform_driver_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&o_ctrl->v4l2_dev_str.sd, NULL);
kfree(o_ctrl);
}
const static struct component_ops cam_ois_component_ops = {
.bind = cam_ois_component_bind,
.unbind = cam_ois_component_unbind,
};
static int32_t cam_ois_platform_driver_probe(
struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_OIS, "Adding OIS Sensor component");
rc = component_add(&pdev->dev, &cam_ois_component_ops);
if (rc)
CAM_ERR(CAM_OIS, "failed to add component rc: %d", rc);
return rc;
}
static int cam_ois_platform_driver_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_ois_component_ops);
return 0;
}
@@ -358,7 +384,7 @@ static const struct of_device_id cam_ois_dt_match[] = {
MODULE_DEVICE_TABLE(of, cam_ois_dt_match);
static struct platform_driver cam_ois_platform_driver = {
struct platform_driver cam_ois_platform_driver = {
.driver = {
.name = "qcom,ois",
.owner = THIS_MODULE,

View File

@@ -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/init.h>
@@ -12,6 +12,7 @@
#include "cam_debug_util.h"
#include "cam_res_mgr_api.h"
#include "cam_res_mgr_private.h"
#include "camera_main.h"
static struct cam_res_mgr *cam_res;
@@ -664,9 +665,11 @@ static int cam_res_mgr_parse_dt(struct device *dev)
return rc;
}
static int cam_res_mgr_probe(struct platform_device *pdev)
static int cam_res_mgr_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
int rc = 0;
struct platform_device *pdev = to_platform_device(dev);
cam_res = kzalloc(sizeof(*cam_res), GFP_KERNEL);
if (!cam_res)
@@ -692,17 +695,40 @@ static int cam_res_mgr_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&cam_res->gpio_res_list);
INIT_LIST_HEAD(&cam_res->flash_res_list);
CAM_DBG(CAM_RES, "Component bound successfully");
return 0;
}
static int cam_res_mgr_remove(struct platform_device *pdev)
static void cam_res_mgr_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
if (cam_res) {
cam_res_mgr_free_res();
kfree(cam_res);
cam_res = NULL;
}
}
const static struct component_ops cam_res_mgr_component_ops = {
.bind = cam_res_mgr_component_bind,
.unbind = cam_res_mgr_component_unbind,
};
static int cam_res_mgr_probe(struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_RES, "Adding Res mgr component");
rc = component_add(&pdev->dev, &cam_res_mgr_component_ops);
if (rc)
CAM_ERR(CAM_RES, "failed to add component rc: %d", rc);
return rc;
}
static int cam_res_mgr_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_res_mgr_component_ops);
return 0;
}
@@ -712,7 +738,7 @@ static const struct of_device_id cam_res_mgr_dt_match[] = {
};
MODULE_DEVICE_TABLE(of, cam_res_mgr_dt_match);
static struct platform_driver cam_res_mgr_driver = {
struct platform_driver cam_res_mgr_driver = {
.probe = cam_res_mgr_probe,
.remove = cam_res_mgr_remove,
.driver = {

View File

@@ -1,12 +1,13 @@
// 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 "cam_sensor_dev.h"
#include "cam_req_mgr_dev.h"
#include "cam_sensor_soc.h"
#include "cam_sensor_core.h"
#include "camera_main.h"
static long cam_sensor_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
@@ -201,73 +202,13 @@ free_s_ctrl:
return rc;
}
static int cam_sensor_platform_remove(struct platform_device *pdev)
{
int i;
struct cam_sensor_ctrl_t *s_ctrl;
struct cam_hw_soc_info *soc_info;
s_ctrl = platform_get_drvdata(pdev);
if (!s_ctrl) {
CAM_ERR(CAM_SENSOR, "sensor device is NULL");
return 0;
}
CAM_INFO(CAM_SENSOR, "platform remove invoked");
mutex_lock(&(s_ctrl->cam_sensor_mutex));
cam_sensor_shutdown(s_ctrl);
mutex_unlock(&(s_ctrl->cam_sensor_mutex));
cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
soc_info = &s_ctrl->soc_info;
for (i = 0; i < soc_info->num_clk; i++)
devm_clk_put(soc_info->dev, soc_info->clk[i]);
kfree(s_ctrl->i2c_data.per_frame);
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), NULL);
devm_kfree(&pdev->dev, s_ctrl);
return 0;
}
static int cam_sensor_driver_i2c_remove(struct i2c_client *client)
{
int i;
struct cam_sensor_ctrl_t *s_ctrl = i2c_get_clientdata(client);
struct cam_hw_soc_info *soc_info;
if (!s_ctrl) {
CAM_ERR(CAM_SENSOR, "sensor device is NULL");
return 0;
}
CAM_INFO(CAM_SENSOR, "i2c remove invoked");
mutex_lock(&(s_ctrl->cam_sensor_mutex));
cam_sensor_shutdown(s_ctrl);
mutex_unlock(&(s_ctrl->cam_sensor_mutex));
cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
soc_info = &s_ctrl->soc_info;
for (i = 0; i < soc_info->num_clk; i++)
devm_clk_put(soc_info->dev, soc_info->clk[i]);
kfree(s_ctrl->i2c_data.per_frame);
v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), NULL);
kfree(s_ctrl);
return 0;
}
static const struct of_device_id cam_sensor_driver_dt_match[] = {
{.compatible = "qcom,cam-sensor"},
{}
};
static int32_t cam_sensor_driver_platform_probe(
struct platform_device *pdev)
static int cam_sensor_component_bind(struct device *dev,
struct device *master_dev, void *data)
{
int32_t rc = 0, i = 0;
struct cam_sensor_ctrl_t *s_ctrl = NULL;
struct cam_hw_soc_info *soc_info = NULL;
struct platform_device *pdev = to_platform_device(dev);
/* Create sensor control structure */
s_ctrl = devm_kzalloc(&pdev->dev,
@@ -330,6 +271,7 @@ static int32_t cam_sensor_driver_platform_probe(
s_ctrl->sensordata->power_info.dev = &pdev->dev;
platform_set_drvdata(pdev, s_ctrl);
s_ctrl->sensor_state = CAM_SENSOR_INIT;
CAM_DBG(CAM_SENSOR, "Component bound successfully");
return rc;
unreg_subdev:
@@ -339,9 +281,94 @@ free_s_ctrl:
return rc;
}
static void cam_sensor_component_unbind(struct device *dev,
struct device *master_dev, void *data)
{
int i;
struct cam_sensor_ctrl_t *s_ctrl;
struct cam_hw_soc_info *soc_info;
struct platform_device *pdev = to_platform_device(dev);
s_ctrl = platform_get_drvdata(pdev);
if (!s_ctrl) {
CAM_ERR(CAM_SENSOR, "sensor device is NULL");
return;
}
CAM_INFO(CAM_SENSOR, "platform remove invoked");
mutex_lock(&(s_ctrl->cam_sensor_mutex));
cam_sensor_shutdown(s_ctrl);
mutex_unlock(&(s_ctrl->cam_sensor_mutex));
cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
soc_info = &s_ctrl->soc_info;
for (i = 0; i < soc_info->num_clk; i++)
devm_clk_put(soc_info->dev, soc_info->clk[i]);
kfree(s_ctrl->i2c_data.per_frame);
platform_set_drvdata(pdev, NULL);
v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), NULL);
devm_kfree(&pdev->dev, s_ctrl);
}
const static struct component_ops cam_sensor_component_ops = {
.bind = cam_sensor_component_bind,
.unbind = cam_sensor_component_unbind,
};
static int cam_sensor_platform_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &cam_sensor_component_ops);
return 0;
}
static int cam_sensor_driver_i2c_remove(struct i2c_client *client)
{
int i;
struct cam_sensor_ctrl_t *s_ctrl = i2c_get_clientdata(client);
struct cam_hw_soc_info *soc_info;
if (!s_ctrl) {
CAM_ERR(CAM_SENSOR, "sensor device is NULL");
return 0;
}
CAM_DBG(CAM_SENSOR, "i2c remove invoked");
mutex_lock(&(s_ctrl->cam_sensor_mutex));
cam_sensor_shutdown(s_ctrl);
mutex_unlock(&(s_ctrl->cam_sensor_mutex));
cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
soc_info = &s_ctrl->soc_info;
for (i = 0; i < soc_info->num_clk; i++)
devm_clk_put(soc_info->dev, soc_info->clk[i]);
kfree(s_ctrl->i2c_data.per_frame);
v4l2_set_subdevdata(&(s_ctrl->v4l2_dev_str.sd), NULL);
kfree(s_ctrl);
return 0;
}
static const struct of_device_id cam_sensor_driver_dt_match[] = {
{.compatible = "qcom,cam-sensor"},
{}
};
static int32_t cam_sensor_driver_platform_probe(
struct platform_device *pdev)
{
int rc = 0;
CAM_DBG(CAM_SENSOR, "Adding Sensor component");
rc = component_add(&pdev->dev, &cam_sensor_component_ops);
if (rc)
CAM_ERR(CAM_SENSOR, "failed to add component rc: %d", rc);
return rc;
}
MODULE_DEVICE_TABLE(of, cam_sensor_driver_dt_match);
static struct platform_driver cam_sensor_platform_driver = {
struct platform_driver cam_sensor_platform_driver = {
.probe = cam_sensor_driver_platform_probe,
.driver = {
.name = "qcom,camera",