msm: camera: common: Add sysfs support for bw override
To simulate bus overflow recovery in camera, cpas needs sysfs to take input from shell and vote the final value as given, instead of consolidated values from cpas clients. Add initial support for sysfs to add nodes for all drivers. Add sysfs based debug node to maintain and update all settings. Add cpas settings to override final bw voted to camnoc and mnoc ports. Usage: adb shell "echo <driver_name>#<setting_name>=<value> > /sys/devices/platform/soc/soc:qcom,cam-req-mgr/debug_node" Example:i adb shell "echo cpas#camnoc_bw=100 > /sys/devices/platform/soc/soc:qcom,cam-req-mgr/debug_node" Input format for updating settings is strict. CRs-Fixed: 2646825 Change-Id: I8d6063240f9685474bf4b2899e8dfb3f74cbdb75 Signed-off-by: Mukund Madhusudan Atre <matre@codeaurora.org>
This commit is contained in:
@@ -4,12 +4,115 @@
|
||||
*/
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include "cam_debug_util.h"
|
||||
|
||||
static uint debug_mdl;
|
||||
module_param(debug_mdl, uint, 0644);
|
||||
struct camera_debug_settings cam_debug;
|
||||
|
||||
const struct camera_debug_settings *cam_debug_get_settings()
|
||||
{
|
||||
return &cam_debug;
|
||||
}
|
||||
|
||||
static int cam_debug_parse_cpas_settings(const char *setting, u64 value)
|
||||
{
|
||||
if (!strcmp(setting, "camnoc_bw")) {
|
||||
cam_debug.cpas_settings.camnoc_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_hf_0_ab_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_hf_0_ab_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_hf_0_ib_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_hf_0_ib_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_hf_1_ab_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_hf_1_ab_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_hf_1_ib_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_hf_1_ib_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_sf_0_ab_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_sf_0_ab_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_sf_0_ib_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_sf_0_ib_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_sf_1_ab_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_sf_1_ab_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_sf_1_ib_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_sf_1_ib_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_sf_icp_ab_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_sf_icp_ab_bw = value;
|
||||
} else if (!strcmp(setting, "mnoc_sf_icp_ib_bw")) {
|
||||
cam_debug.cpas_settings.mnoc_sf_icp_ib_bw = value;
|
||||
} else {
|
||||
CAM_ERR(CAM_UTIL, "Unsupported cpas sysfs entry");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t cam_debug_sysfs_node_store(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int rc = 0;
|
||||
char *local_buf = NULL, *local_buf_temp = NULL;
|
||||
char *driver;
|
||||
char *setting = NULL;
|
||||
char *value_str = NULL;
|
||||
u64 value;
|
||||
|
||||
CAM_INFO(CAM_UTIL, "Sysfs debug attr name:[%s] buf:[%s] bytes:[%d]",
|
||||
attr->attr.name, buf, count);
|
||||
local_buf = kmemdup(buf, (count + sizeof(char)), GFP_KERNEL);
|
||||
local_buf_temp = local_buf;
|
||||
driver = strsep(&local_buf, "#");
|
||||
if (!driver) {
|
||||
CAM_ERR(CAM_UTIL,
|
||||
"Invalid input driver name buf:[%s], count:%d",
|
||||
buf, count);
|
||||
goto error;
|
||||
}
|
||||
|
||||
setting = strsep(&local_buf, "=");
|
||||
if (!setting) {
|
||||
CAM_ERR(CAM_UTIL, "Invalid input setting buf:[%s], count:%d",
|
||||
buf, count);
|
||||
goto error;
|
||||
}
|
||||
|
||||
value_str = strsep(&local_buf, "=");
|
||||
if (!value_str) {
|
||||
CAM_ERR(CAM_UTIL, "Invalid input value buf:[%s], count:%d",
|
||||
buf, count);
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = kstrtou64(value_str, 0, &value);
|
||||
if (rc < 0) {
|
||||
CAM_ERR(CAM_UTIL, "Error converting value:[%s], buf:[%s]",
|
||||
value_str, buf);
|
||||
goto error;
|
||||
}
|
||||
|
||||
CAM_INFO(CAM_UTIL,
|
||||
"Processing sysfs store for driver:[%s], setting:[%s], value:[%llu]",
|
||||
driver, setting, value);
|
||||
|
||||
if (!strcmp(driver, "cpas")) {
|
||||
rc = cam_debug_parse_cpas_settings(setting, value);
|
||||
if (rc)
|
||||
goto error;
|
||||
} else {
|
||||
CAM_ERR(CAM_UTIL, "Unsupported driver in camera debug node");
|
||||
goto error;
|
||||
}
|
||||
|
||||
kfree(local_buf_temp);
|
||||
return count;
|
||||
|
||||
error:
|
||||
kfree(local_buf_temp);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
const char *cam_get_module_name(unsigned int module_id)
|
||||
{
|
||||
|
Reference in New Issue
Block a user