Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ddcb9d34 authored by Jigarkumar Zala's avatar Jigarkumar Zala
Browse files

msm: camera: add/update string log macros in debug header file



Add string log macro in debug header file for any
modules when developer needs to turn on the debugging
for specific module/modules. Also, update other log
macros independent from module specific condition in
order to print logs.

CRs-Fixed: 2056624
Change-Id: Icdc15f6ff4a4f6bb9b6c82bfc7f4ccf910f93924
Signed-off-by: default avatarJigarkumar Zala <jzala@codeaurora.org>
parent 26abf776
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr/

obj-$(CONFIG_SPECTRA_CAMERA) += cam_soc_util.o cam_io_util.o cam_packet_util.o
obj-$(CONFIG_SPECTRA_CAMERA) += cam_soc_util.o cam_io_util.o cam_packet_util.o cam_debug_util.o
+101 −0
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundataion. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/io.h>
#include "cam_debug_util.h"

static const char *cam_debug_module_id_to_name(unsigned int module_id)
{
	const char *name = NULL;

	switch (module_id) {
	case CAM_CDM:
		name = "CAM-CDM";
		break;
	case CAM_CORE:
		name = "CAM-CORE";
		break;
	case CAM_CRM:
		name = "CAM_CRM";
		break;
	case CAM_CPAS:
		name = "CAM-CPAS";
		break;
	case CAM_ISP:
		name = "CAM-ISP";
		break;
	case CAM_SENSOR:
		name = "CAM-SENSOR";
		break;
	case CAM_SMMU:
		name = "CAM-SMMU";
		break;
	case CAM_SYNC:
		name = "CAM-SYNC";
		break;
	case CAM_ICP:
		name = "CAM-ICP";
		break;
	case CAM_JPEG:
		name = "CAM-JPEG";
		break;
	case CAM_FD:
		name = "CAM-FD";
		break;
	case CAM_LRME:
		name = "CAM-LRME";
		break;
	case CAM_FLASH:
		name = "CAM-FLASH";
		break;
	default:
		name = "CAM";
		break;
	}

	return name;
}

void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
	const char *func, const int line, const char *fmt, ...)
{
	char str_buffer[STR_BUFFER_MAX_LENGTH];
	const char *module_name;
	va_list args;

	va_start(args, fmt);
	vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
	va_end(args);

	module_name = cam_debug_module_id_to_name(module_id);

	switch (dbg_level) {
	case CAM_LEVEL_INFO:
		pr_info("CAM_INFO: %s: %s: %d: %s\n",
			module_name, func, line, str_buffer);
		break;
	case CAM_LEVEL_WARN:
		pr_warn("CAM_WARN: %s: %s: %d: %s\n",
			module_name, func, line, str_buffer);
		break;
	case CAM_LEVEL_ERR:
		pr_err("CAM_ERR: %s: %s: %d: %s\n",
			module_name, func, line, str_buffer);
		break;
	case CAM_LEVEL_DBG:
		pr_info("CAM_DBG: %s: %s: %d: %s\n",
			module_name, func, line, str_buffer);
		break;
	default:
		break;
	}
}
+85 −27
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
#ifndef _CAM_DEBUG_UTIL_H_
#define _CAM_DEBUG_UTIL_H_

#define DEFAULT     0xFFFF
#define CAM_CDM    (1 << 0)
#define CAM_CORE   (1 << 1)
#define CAM_CPAS   (1 << 2)
@@ -26,32 +25,91 @@
#define CAM_JPEG   (1 << 9)
#define CAM_FD     (1 << 10)
#define CAM_LRME   (1 << 11)
#define CAM_FLASH  (1 << 12)

#define GROUP      DEFAULT
#define TRACE_ON   0
#define STR_BUFFER_MAX_LENGTH  1024
#define GROUP                  0x0000

enum cam_debug_level {
	CAM_LEVEL_INFO,
	CAM_LEVEL_WARN,
	CAM_LEVEL_ERR,
	CAM_LEVEL_DBG,
};

/*
 *  cam_debug_log()
 *
 * @brief:        Get the Module name form module ID and print
 *                respective debug logs
 *
 * @module_id :  Respective Module ID which is calling this function
 * @dbg_level :  Debug level from cam_module_debug_level enum entries
 * @func :       Function which is calling to print logs
 * @line :       Line number associated with the function which is calling
 *               to print log
 * @fmt  :       Formatted string which needs to be print in the log
 *
 */
void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
	const char *func, const int line, const char *fmt, ...);

/*
 * CAM_ERR
 * @brief :     This Macro will print error logs
 *
 * @__module :  Respective module id which is been calling this Macro
 * @fmt :       Formatted string which needs to be print in log
 * @args:       Arguments which needs to be print in log
 */
#define CAM_ERR(__module, fmt, args...)                            \
	do { if (GROUP & __module) {                                         \
		if (TRACE_ON)                                                \
			trace_printk(fmt, ##args);                           \
		else                                                         \
			pr_err(fmt, ##args);                                 \
	} } while (0)
	{                                                          \
		cam_debug_log(__module, CAM_LEVEL_ERR,             \
			__func__, __LINE__, fmt, ##args);          \
	}

/*
 * CAM_WARN
 * @brief :     This Macro will print warning logs
 *
 * @__module :  Respective module id which is been calling this Macro
 * @fmt      :  Formatted string which needs to be print in log
 * @args     :  Arguments which needs to be print in log
 */
#define CAM_WARN(__module, fmt, args...)                           \
	do { if (GROUP & __module) {                                         \
		if (TRACE_ON)                                                \
			trace_printk(fmt, ##args);                           \
		else                                                         \
			pr_warn(fmt, ##args);                                \
	} } while (0)
	{                                                          \
		cam_debug_log(__module, CAM_LEVEL_WARN,            \
			__func__, __LINE__, fmt, ##args);          \
	}

/*
 * CAM_INFO
 * @brief :     This Macro will print Information logs
 *
 * @__module :  Respective module id which is been calling this Macro
 * @fmt      :  Formatted string which needs to be print in log
 * @args     :  Arguments which needs to be print in log
 */
#define CAM_INFO(__module, fmt, args...)                           \
	do { if (GROUP & __module) {                                         \
		if (TRACE_ON)                                                \
			trace_printk(fmt, ##args);                           \
		else                                                         \
			pr_info(fmt, ##args);                                \
	} } while (0)
	{                                                          \
		cam_debug_log(__module, CAM_LEVEL_INFO,            \
			__func__, __LINE__, fmt, ##args);          \
	}

/*
 * CAM_DBG
 * @brief :     This Macro will print debug logs when enabled using GROUP
 *
 * @__module :  Respective module id which is been calling this Macro
 * @fmt      :  Formatted string which needs to be print in log
 * @args     :  Arguments which needs to be print in log
 */
#define CAM_DBG(__module, fmt, args...)                            \
	do {                                                       \
		if (GROUP & __module) {                            \
			cam_debug_log(__module, CAM_LEVEL_DBG,     \
				__func__, __LINE__, fmt, ##args);  \
		}                                                  \
	} while (0)

#endif /* _CAM_DEBUG_UTIL_H_ */