/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * uvc log * * Copyright (C) 2020 Rockchip Electronics Co., Ltd. * * Author: Bin Yang */ #ifndef __UVC_LOG_H__ #define __UVC_LOG_H__ #include #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "UVC-Gadget" #define UVCCTRL_LOG 0x01 #define ENCODE_LOG 0x02 #define BUFFER_LOG 0x04 #define UVCRGA_LOG 0x08 #define DUMP_IN 0x10 #define DUMP_OUT 0x20 #ifdef ANDROID_PLATFORM #include #define uvc_info(format, ...) ALOGI(format, ##__VA_ARGS__) #define uvc_warn(format, ...) ALOGW(format, ##__VA_ARGS__) #define uvc_err(format, ...) ALOGE(format, ##__VA_ARGS__) #define uvc_dbg(format, ...) ALOGD(format, ##__VA_ARGS__) #define uvc_dbg_if(cond, format, ...) ALOGD_IF(cond, format, ##__VA_ARGS__) #else #define LOG_ERROR_FLAG (4) #define LOG_WARING_FLAG (3) #define LOG_INFO_FLAG (2) #define LOG_DEBUG_FLAG (1) #define LOG_DEBUG_LEVEL (1) #define LOG_PRINTF(level, format, ...) \ do { \ if (level > LOG_DEBUG_LEVEL) { \ printf("[%s] "format, LOG_TAG, ##__VA_ARGS__); \ } \ } while(0) #define uvc_info(format, ...) LOG_PRINTF(LOG_INFO_FLAG, format, ##__VA_ARGS__) #define uvc_dbg(format, ...) LOG_PRINTF(LOG_DEBUG_FLAG, format, ##__VA_ARGS__) #define uvc_warn(format, ...) LOG_PRINTF(LOG_WARING_FLAG, format, ##__VA_ARGS__) #define uvc_err(format, ...) LOG_PRINTF(LOG_ERROR_FLAG, format, ##__VA_ARGS__) #define uvc_dbg_if(cond, format, ...) \ do { \ if (cond) { \ LOG_PRINTF(LOG_INFO_FLAG, format, ##__VA_ARGS__); \ } \ } while(0) #endif #endif /* __UVC_LOG_H__ */