// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
/*
 * Copyright (c) 2020 MediaTek Inc.
 */

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/timer.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/types.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <media/v4l2-mem2mem.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-vmalloc.h>
#include <media/v4l2-ctrls.h>
#ifndef __KERNEL__
#include <stdbool.h>
#endif
//#include <linux/vmalloc.h>

#include "mtk_srccap.h"
#include "mtk_srccap_debugcmd.h"
#include "hwreg_srccap_timingdetect.h"


//-----------------------------------------------------------------------------
//  Local Defines
//-----------------------------------------------------------------------------
#define DEBUGCMD_LOG_ERROR		BIT(0)
#define DEBUGCMD_LOG_INFO		BIT(1)
#define DEBUGCMD_LOG_FLOW		BIT(2)

#define DEBUGCMD_LOG_DEFAULT		(7)
static unsigned char debug = DEBUGCMD_LOG_DEFAULT;
#define DEBUGCMD_LOG(_level, _fmt, _args...) { \
	if ((_level & debug) != 0) { \
		if (_level & DEBUGCMD_LOG_ERROR) \
			pr_err("[DEBUGCMD ERROR]  [%s,%5d]"_fmt, \
			__func__, __LINE__, ##_args); \
		else if (_level & DEBUGCMD_LOG_INFO) { \
			pr_err("[DEBUGCMD INFO]  [%s,%5d]"_fmt, \
			__func__, __LINE__, ##_args); \
		} \
		else if (_level & DEBUGCMD_LOG_FLOW) { \
			pr_err("[DEGCMD FLOW]  [%s,%5d]"_fmt, \
			__func__, __LINE__, ##_args); \
		} \
	} \
}

#define ENTER()		{DEBUGCMD_LOG(DEBUGCMD_LOG_FLOW, ">>>>>ENTER>>>>>\n")}
#define EXIT()		{DEBUGCMD_LOG(DEBUGCMD_LOG_FLOW, "<<<<<EXIT <<<<<\n")}


//-----------------------------------------------------------------------------
//  Local Variables
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//  Local Functions
//-----------------------------------------------------------------------------


static bool _mtk_srccap_debugcmd_get_value_from_string(char *buf, char *name,
	unsigned int len, int *value)
{
	bool find = false;
	char *string, *tmp_name, *cmd, *tmp_value;

	ENTER();

	if ((buf == NULL) || (name == NULL) || (value == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "Pointer is NULL!\n");
		return false;
	}

	*value = 0;
	cmd = buf;

	for (string = buf; string < (buf + len); ) {
		strsep(&cmd, " =\n\r");
		for (string += strlen(string); string < (buf + len) && !*string;)
			string++;
	}

	for (string = buf; string < (buf + len); ) {
		tmp_name = string;
		for (string += strlen(string); string < (buf + len) && !*string;)
			string++;

		tmp_value = string;
		for (string += strlen(string); string < (buf + len) && !*string;)
			string++;

		if (strncmp(tmp_name, name, strlen(name) + 1) == 0) {
			if (kstrtoint(tmp_value, 0, value)) {
				DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
					"kstrtoint fail!\n");
				return find;
			}
			find = true;
			DEBUGCMD_LOG(DEBUGCMD_LOG_INFO,
				"name = %s, value = %d\n", name, *value);
			return find;
		}
	}

	DEBUGCMD_LOG(DEBUGCMD_LOG_INFO,
		"name(%s) was not found!\n", name);

	EXIT();
	return find;
}

static int _mtk_srccap_debugcmd_map_detblock_reg(
	enum v4l2_srccap_input_source src,
	struct srccap_port_map map[V4L2_SRCCAP_INPUT_SOURCE_NUM],
	enum reg_srccap_timingdetect_source *detblock)
{
	if (detblock == NULL) {
		SRCCAP_MSG_POINTER_CHECK();
		return -ENXIO;
	}

	if ((src <= V4L2_SRCCAP_INPUT_SOURCE_NONE) || (src >= V4L2_SRCCAP_INPUT_SOURCE_NUM)) {
		SRCCAP_MSG_ERROR("invalid source:%d\n", src);
		return -EINVAL;
	}

	switch (src) {
	case V4L2_SRCCAP_INPUT_SOURCE_HDMI:
	case V4L2_SRCCAP_INPUT_SOURCE_HDMI2:
	case V4L2_SRCCAP_INPUT_SOURCE_HDMI3:
	case V4L2_SRCCAP_INPUT_SOURCE_HDMI4:
	case V4L2_SRCCAP_INPUT_SOURCE_DVI:
	case V4L2_SRCCAP_INPUT_SOURCE_DVI2:
	case V4L2_SRCCAP_INPUT_SOURCE_DVI3:
	case V4L2_SRCCAP_INPUT_SOURCE_DVI4:
	case V4L2_SRCCAP_INPUT_SOURCE_DPRX:
	case V4L2_SRCCAP_INPUT_SOURCE_DPRX2:
		switch (map[src].data_port) {
		case SRCCAP_INPUT_PORT_DVI0:
		case SRCCAP_INPUT_PORT_HDMI0:
			*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_HDMI;
			break;
		case SRCCAP_INPUT_PORT_DVI1:
		case SRCCAP_INPUT_PORT_HDMI1:
			*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_HDMI2;
			break;
		case SRCCAP_INPUT_PORT_DVI2:
		case SRCCAP_INPUT_PORT_HDMI2:
			*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_HDMI3;
			break;
		case SRCCAP_INPUT_PORT_DVI3:
		case SRCCAP_INPUT_PORT_HDMI3:
			*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_HDMI4;
			break;
		case SRCCAP_INPUT_PORT_DPRX0:
			*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_DP;
			break;
		case SRCCAP_INPUT_PORT_DPRX1:
			*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_DP2;
			break;
		default:
			SRCCAP_MSG_FATAL("invalid port:%d\n", map[src].data_port);
			break;
		}
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS2:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS3:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS4:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS5:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS6:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS7:
	case V4L2_SRCCAP_INPUT_SOURCE_CVBS8:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_VD;
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_SVIDEO:
	case V4L2_SRCCAP_INPUT_SOURCE_SVIDEO2:
	case V4L2_SRCCAP_INPUT_SOURCE_SVIDEO3:
	case V4L2_SRCCAP_INPUT_SOURCE_SVIDEO4:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_VD;
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_YPBPR:
	case V4L2_SRCCAP_INPUT_SOURCE_YPBPR2:
	case V4L2_SRCCAP_INPUT_SOURCE_YPBPR3:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_ADCA;
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_VGA:
	case V4L2_SRCCAP_INPUT_SOURCE_VGA2:
	case V4L2_SRCCAP_INPUT_SOURCE_VGA3:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_ADCA;
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_ATV:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_VD;
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_SCART:
	case V4L2_SRCCAP_INPUT_SOURCE_SCART2:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_VD;
		break;
	case V4L2_SRCCAP_INPUT_SOURCE_DSC_HDMI:
	case V4L2_SRCCAP_INPUT_SOURCE_DSC_HDMI2:
	case V4L2_SRCCAP_INPUT_SOURCE_DSC_HDMI3:
	case V4L2_SRCCAP_INPUT_SOURCE_DSC_HDMI4:
	case V4L2_SRCCAP_INPUT_SOURCE_DSC_DP:
	case V4L2_SRCCAP_INPUT_SOURCE_DSC_DP2:
		*detblock = REG_SRCCAP_TIMINGDETECT_SOURCE_DSC;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}


static int _mtk_srccap_debugcmd_set_auto_no_signal_mute(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	int ret = 0;
	bool find = 0;
	int enable = 0;
	int src_num = 0;

	enum reg_srccap_timingdetect_source detsrc = REG_SRCCAP_TIMINGDETECT_SOURCE_ADCA;

	if ((srccap_dev == NULL) || (cmd == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or cmd is NULL!\n");
		return -EINVAL;
	}

	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "src", len, &src_num);
	if (!find) {
		src_num = srccap_dev->srccap_info.src;
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"cant fine src_num in cmdlinem! use online src(%d)\n", src_num);
	} else if ((src_num < V4L2_SRCCAP_INPUT_SOURCE_NONE) ||
		(src_num >= V4L2_SRCCAP_INPUT_SOURCE_NUM)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"src_num(%d) not match, use online src(%d)\n",
			src_num, srccap_dev->srccap_info.src);
		src_num = srccap_dev->srccap_info.src;
	}

	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "enable", len, &enable);
	if (!find) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "cant fine min in cmdline!\n");
		return -EINVAL;
	}

	ret = _mtk_srccap_debugcmd_map_detblock_reg(
		(enum v4l2_srccap_input_source)src_num, srccap_dev->srccap_info.map, &detsrc);

	if (ret) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "map detblock reg fail ret=%d\n", ret);
		return ret;
	}

	ret = drv_hwreg_srccap_timingdetect_set_ans_mute(detsrc, enable, TRUE, NULL, NULL);

	if ((!ret) && (srccap_dev->memout_info.buf_ctrl_mode == V4L2_MEMOUT_BYPASSMODE))
		DEBUGCMD_LOG(DEBUGCMD_LOG_INFO, "%d Auto no signal.\n", enable);

	if (ret)
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "set ans mute fail ret=%d\n", ret);

	return ret;
}


static int _mtk_srccap_debugcmd_adc_table_redo(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "TBD\n");
	return 0;
}

static int _mtk_srccap_debugcmd_reset_ip1(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	int ret = 0;
	bool find = 0;
	int src_num = 0;
	enum reg_srccap_timingdetect_source detsrc = REG_SRCCAP_TIMINGDETECT_SOURCE_ADCA;

	if ((srccap_dev == NULL) || (cmd == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or cmd is NULL!\n");
		return -EINVAL;
	}

	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "src", len, &src_num);
	if (!find) {
		src_num = srccap_dev->srccap_info.src;
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"cant fine src_num in cmdlinem! use online src(%d)\n", src_num);
	} else if ((src_num < V4L2_SRCCAP_INPUT_SOURCE_NONE) ||
		(src_num >= V4L2_SRCCAP_INPUT_SOURCE_NUM)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"src_num(%d) not match, use online src(%d)\n",
			src_num, srccap_dev->srccap_info.src);
		src_num = srccap_dev->srccap_info.src;
	}

	ret = _mtk_srccap_debugcmd_map_detblock_reg(
		(enum v4l2_srccap_input_source)src_num, srccap_dev->srccap_info.map, &detsrc);

	if (ret) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "map detblock reg fail ret=%d\n", ret);
		return ret;
	}

	ret = drv_hwreg_srccap_timingdetect_reset(detsrc, TRUE, TRUE, NULL, NULL);
	if (ret < 0) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "ip1 reset to TRUE fail ret=%d\n", ret);
		return ret;
	}

	usleep_range(SRCCAP_DEBUGCMD_IP1_RESET_DELAY_1000, SRCCAP_DEBUGCMD_IP1_RESET_DELAY_1100);

	ret = drv_hwreg_srccap_timingdetect_reset(detsrc, FALSE, TRUE, NULL, NULL);
	if (ret < 0) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "ip1 reset to FALSE fail ret=%d\n", ret);
		return ret;
	}

	usleep_range(SRCCAP_DEBUGCMD_IP1_RESET_DELAY_1000, SRCCAP_DEBUGCMD_IP1_RESET_DELAY_1100);

	return ret;
}



static int _mtk_srccap_debugcmd_pre_signal_polling_time_upd(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	int ret = 0;
	bool find = 0;
	int min_time = 0;
	int max_time = 0;

	ENTER();

	if ((srccap_dev == NULL) || (cmd == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or cmd is NULL!\n");
		return -EINVAL;
	}


	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "min", len, &min_time);
	if (!find) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"cant fine min in cmdline!\n");
		return -EINVAL;
	}

	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "max", len, &max_time);
	if (!find) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"cant fine max in cmdline!\n");
		return -EINVAL;
	}


	srccap_dev->srccap_info.cap.polling_time_min_pre_signal_task = min_time;
	srccap_dev->srccap_info.cap.polling_time_max_pre_signal_task = max_time;

	EXIT();
	return ret;

}


static int _mtk_srccap_debugcmd_pre_signal_stable_cnt_upd(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	int ret = 0;
	bool find = 0;
	int stable_cnt = 0;

	ENTER();

	if ((srccap_dev == NULL) || (cmd == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or cmd is NULL!\n");
		return -EINVAL;
	}

	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "cnt", len, &stable_cnt);
	if (!find) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"cant fine min in cmdline!\n");
		return -EINVAL;
	}

	srccap_dev->srccap_info.cap.stable_count = stable_cnt;

	EXIT();
	return ret;

}


static int _mtk_srccap_debugcmd_sync_monitor_polling_time_upd(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	int ret = 0;
	bool find = 0;
	int time = 0;

	ENTER();

	if ((srccap_dev == NULL) || (cmd == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or cmd is NULL!\n");
		return -EINVAL;
	}

	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "time", len, &time);
	if (!find) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"cant fine time in cmdline!\n");
		return -EINVAL;
	}

	srccap_dev->srccap_info.cap.polling_time_sync_monitor_task = time;

	EXIT();
	return ret;

}

static int _mtk_srccap_debugcmd_parser_info(
	struct mtk_srccap_dev *srccap_dev, char *cmd, int len)
{
	int ret = 0;
	bool find = 0;
	int type = 0;

	ENTER();

	if ((srccap_dev == NULL) || (cmd == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or cmd is NULL!\n");
		return -EINVAL;
	}


	find = _mtk_srccap_debugcmd_get_value_from_string(cmd, "type", len, &type);
	if (!find) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"Cmdline format error, type should be set!\n");
		return -EINVAL;
	}

	switch (type) {
	case SRCCAP_DEBUG_CMD_AUTO_MUTE_CLR:
		ret =  _mtk_srccap_debugcmd_set_auto_no_signal_mute(srccap_dev, cmd, len);
		break;
	case SRCCAP_DEBUG_CMD_ADC_TABLE_REDO:
		ret = _mtk_srccap_debugcmd_adc_table_redo(srccap_dev, cmd, len);
		break;
	case SRCCAP_DEBUG_CMD_IP1_RESET:
		ret = _mtk_srccap_debugcmd_reset_ip1(srccap_dev, cmd, len);
		break;
	case SRCCAP_DEBUG_CMD_PRE_SIGNAL_POLLING_TIME_UPD:
		ret = _mtk_srccap_debugcmd_pre_signal_polling_time_upd(srccap_dev, cmd, len);
		break;
	case SRCCAP_DEBUG_CMD_PRE_SIGNAL_STABLE_CNT_UPD:
		ret = _mtk_srccap_debugcmd_pre_signal_stable_cnt_upd(srccap_dev, cmd, len);
		break;
	case SRCCAP_DEBUG_CMD_SYNC_MONITOR_POLLING_TIME_UPD:
		ret = _mtk_srccap_debugcmd_sync_monitor_polling_time_upd(srccap_dev, cmd, len);
		break;
	default:
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
			"Cmdline format error, type(%d) not match!\n", type);
		ret = -EINVAL;
		break;
	}

	EXIT();
	return ret;
}

int mtk_srccap_debugcmd_store(struct device *dev, const char *buf)
{
	int ret = 0;
	int len = 0;
	char *cmd = NULL;
	int char_num = 0;
	struct mtk_srccap_dev *srccap_dev = NULL;

	ENTER();

	if ((dev == NULL) || (buf == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or buf is NULL!\n");
		return -EINVAL;
	}

	srccap_dev = dev_get_drvdata(dev);

	if (!srccap_dev) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "srccap_dev is NULL!\n");
		return -EINVAL;
	}

	len = strlen(buf);
	if (len >= SRCCAP_DEBUGCMD_STRING_SIZE_MAX) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "Over max size:%d\n", len);
		return -EINVAL;
	}

	cmd = MALLOC(SRCCAP_DEBUGCMD_STRING_SIZE_MAX);
	if (cmd == NULL) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "MALLOC cmd fail!\n");
		return -EINVAL;
	}

	memset(cmd, 0, SRCCAP_DEBUGCMD_STRING_SIZE_MAX);

	char_num = snprintf(cmd, SRCCAP_DEBUGCMD_STRING_SIZE_MAX, "%s", buf);
	if (char_num < 0) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "invalid string size\n");
		FREE_MEM(cmd, SRCCAP_DEBUGCMD_STRING_SIZE_MAX);
		return -EPERM;
	}

	ret = _mtk_srccap_debugcmd_parser_info(srccap_dev, cmd, len);

	FREE_MEM(cmd, SRCCAP_DEBUGCMD_STRING_SIZE_MAX);

	EXIT();
	return ret;
}


ssize_t mtk_srccap_debugcmd_show(struct device *dev, char *buf)
{
	struct mtk_srccap_dev *srccap_dev = NULL;
	u16 max_size = SRCCAP_STRING_SIZE_65535;
	int string_size = 0;
	int total_string_size = 0;
	int pre_polling_time_min = 0;
	int pre_polling_time_max = 0;
	int sync_polling_time = 0;
	int stable_cnt = 0;

	ENTER();

	if ((dev == NULL) || (buf == NULL)) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "dev or buf is NULL!\n");
		return -EINVAL;
	}

	srccap_dev = dev_get_drvdata(dev);

	if (!srccap_dev) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR, "srccap_dev is NULL!\n");
		return -EINVAL;
	}

	pre_polling_time_min = srccap_dev->srccap_info.cap.polling_time_min_pre_signal_task;
	pre_polling_time_max = srccap_dev->srccap_info.cap.polling_time_max_pre_signal_task;
	sync_polling_time = srccap_dev->srccap_info.cap.polling_time_sync_monitor_task;
	stable_cnt = srccap_dev->srccap_info.cap.stable_count;

	/* Show support module list */
	string_size = snprintf(buf, max_size,
	"Debug cmd Info:\n"
	"SRCCAP_DEBUG_CMD_AUTO_MUTE_CLR: type=%d src=%d enable=1 or 0\n"
	"SRCCAP_DEBUG_CMD_ADC_TABLE_REDO: type=%d\n"
	"SRCCAP_DEBUG_CMD_IP1_RESET: type=%d src=%d\n"
	"SRCCAP_DEBUG_CMD_PRE_SIGNAL_POLLING_TIME_UPD (us): type=%d min=%d max=%d\n"
	"SRCCAP_DEBUG_CMD_PRE_SIGNAL_STABLE_CNT_UPD: type=%d cnt=%d\n"
	"SRCCAP_DEBUG_CMD_SYNC_MONITOR_POLLING_TIME_UPD (us): type=%d time=%d\n"
	"\n",
	SRCCAP_DEBUG_CMD_AUTO_MUTE_CLR, srccap_dev->srccap_info.src,
	SRCCAP_DEBUG_CMD_ADC_TABLE_REDO,
	SRCCAP_DEBUG_CMD_IP1_RESET, srccap_dev->srccap_info.src,
	SRCCAP_DEBUG_CMD_PRE_SIGNAL_POLLING_TIME_UPD, pre_polling_time_min, pre_polling_time_max,
	SRCCAP_DEBUG_CMD_PRE_SIGNAL_STABLE_CNT_UPD, stable_cnt,
	SRCCAP_DEBUG_CMD_SYNC_MONITOR_POLLING_TIME_UPD, sync_polling_time);

	if (string_size < 0) {
		DEBUGCMD_LOG(DEBUGCMD_LOG_ERROR,
					"invalid string size of RCCAP_DEBUG_CMD INFO\n");
		return -EPERM;
	}

	total_string_size += string_size;

	EXIT();
	return total_string_size;

}

