CamX中如何控制KMD的Debug Log和Trace打印

CamX中如何控制KMD的Debug Log和Trace打印

在CamX中,如何控制KMD的debug log和trace打印呢?

设置要打开哪些模块的Log

首先,确定要打开哪些模块的Log,然后将这些模块的值与在一起,转换成十六进制。

然后,通过echo命令写到/sys/module/camera/parameters/debug_mdl,比如:

adb shell "echo 0x‭1001030‬ > /sys/module/camera/parameters/debug_mdl"

具体的模块定义在:techpack/camera/drivers/cam_utils/cam_debug_util.h

/* Module IDs used for debug logging */
#define CAM_CDM        (1 << 0)
#define CAM_CORE       (1 << 1)
#define CAM_CPAS       (1 << 2)
#define CAM_ISP        (1 << 3)
#define CAM_CRM        (1 << 4)
#define CAM_SENSOR     (1 << 5)
#define CAM_SMMU       (1 << 6)
#define CAM_SYNC       (1 << 7)
#define CAM_ICP        (1 << 8)
#define CAM_JPEG       (1 << 9)
#define CAM_FD         (1 << 10)
#define CAM_LRME       (1 << 11)
#define CAM_FLASH      (1 << 12)
#define CAM_ACTUATOR   (1 << 13)
#define CAM_CCI        (1 << 14)
#define CAM_CSIPHY     (1 << 15)
#define CAM_EEPROM     (1 << 16)
#define CAM_UTIL       (1 << 17)
#define CAM_HFI        (1 << 18)
#define CAM_CTXT       (1 << 19)
#define CAM_OIS        (1 << 20)
#define CAM_RES        (1 << 21)
#define CAM_MEM        (1 << 22)
#define CAM_IRQ_CTRL   (1 << 23)
#define CAM_REQ        (1 << 24)
#define CAM_PERF       (1 << 25)
#define CAM_CUSTOM     (1 << 26)
#define CAM_PRESIL     (1 << 27)
#define CAM_OPE        (1 << 28)
#define CAM_IO_ACCESS  (1 << 29)
#define CAM_SFE        (1 << 30)

设置debug type

debug type是表示日志是打印在log里面,还是打印在trace里面,具体定义:

- 0x0 - only logs 
- 0x1 - only trace
- 0x2 - logs + trace

也是通过echo命令来控制:

"echo 0x‭2‬ > /sys/module/camera/parameters/debug_type"

代码流程

设置完debug_mdl和debug_type后,在cam_debug_log函数中会对debug_mdl和debug_type进行解析,具体代码如下:

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

 va_start(args, fmt);

 if (debug_mdl & module_id) {
  vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);

  if ((debug_type == 0) || (debug_type == 2)) {
   pr_info("CAM_DBG: %s: %s: %d: %s\n",
    cam_get_module_name(module_id),
    func, line, str_buffer);
  }

  if ((debug_type == 1) || (debug_type == 2)) {
   char trace_buffer[STR_BUFFER_MAX_LENGTH];

   snprintf(trace_buffer, sizeof(trace_buffer),
    "%s: %s: %s: %d: %s",
    cam_get_tag_name(CAM_TYPE_DBG),
    cam_get_module_name(module_id),
    func, line, str_buffer);
   trace_cam_log_debug(trace_buffer);
  }
 }

 va_end(args);
}

注意:通过echo命令修改debug_mdl或debug_type后立即生效,无需重启Camera HAL进程

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程