Josh Kirsch | 1c23f24 | 2020-10-19 14:53:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Ajender Reddy | 202bc1c | 2022-08-14 23:11:37 +0530 | [diff] [blame] | 28 | * |
| 29 | * Changes from Qualcomm Innovation Center are provided under the following license: |
| 30 | * |
| 31 | * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| 32 | * SPDX-License-Identifier: BSD-3-Clause-Clear |
Josh Kirsch | 1c23f24 | 2020-10-19 14:53:15 -0700 | [diff] [blame] | 33 | */ |
| 34 | |
| 35 | #include <stdlib.h> |
| 36 | #include <string.h> |
| 37 | #include <stdio.h> |
| 38 | #include <log/log.h> |
| 39 | |
| 40 | #define AHAL_LOG_ERR (0x1) /**< error message, represents code bugs that should be debugged and fixed.*/ |
Ajender Reddy | 202bc1c | 2022-08-14 23:11:37 +0530 | [diff] [blame] | 41 | #define AHAL_LOG_WARN (0x2) /**< warning message, represents "may not be the best case scenario". */ |
| 42 | #define AHAL_LOG_INFO (0x4) /**< info message, additional info to support debug */ |
| 43 | #define AHAL_LOG_DBG (0x8) /**< debug message, required at minimum for debug.*/ |
| 44 | #define AHAL_LOG_VERBOSE (0x10)/**< verbose message, useful primarily to help developers debug low-level code */ |
Josh Kirsch | 1c23f24 | 2020-10-19 14:53:15 -0700 | [diff] [blame] | 45 | |
Ajender Reddy | 202bc1c | 2022-08-14 23:11:37 +0530 | [diff] [blame] | 46 | static uint32_t ahal_log_lvl = AHAL_LOG_ERR|AHAL_LOG_WARN|AHAL_LOG_INFO|AHAL_LOG_DBG; /*TODO make this dynamic*/ |
Josh Kirsch | 1c23f24 | 2020-10-19 14:53:15 -0700 | [diff] [blame] | 47 | |
| 48 | |
| 49 | #define AHAL_ERR(arg,...) \ |
| 50 | if (ahal_log_lvl & AHAL_LOG_ERR) { \ |
| 51 | ALOGE("%s: %d: " arg, __func__, __LINE__, ##__VA_ARGS__);\ |
| 52 | } |
Ajender Reddy | 202bc1c | 2022-08-14 23:11:37 +0530 | [diff] [blame] | 53 | #define AHAL_WARN(arg,...) \ |
| 54 | if (ahal_log_lvl & AHAL_LOG_WARN) { \ |
| 55 | ALOGW("%s: %d: " arg, __func__, __LINE__, ##__VA_ARGS__);\ |
| 56 | } |
Josh Kirsch | 1c23f24 | 2020-10-19 14:53:15 -0700 | [diff] [blame] | 57 | #define AHAL_DBG(arg,...) \ |
| 58 | if (ahal_log_lvl & AHAL_LOG_DBG) { \ |
| 59 | ALOGD("%s: %d: " arg, __func__, __LINE__, ##__VA_ARGS__); \ |
| 60 | } |
| 61 | #define AHAL_INFO(arg,...) \ |
| 62 | if (ahal_log_lvl & AHAL_LOG_INFO) { \ |
| 63 | ALOGI("%s: %d: " arg, __func__, __LINE__, ##__VA_ARGS__);\ |
| 64 | } |
| 65 | #define AHAL_VERBOSE(arg,...) \ |
| 66 | if (ahal_log_lvl & AHAL_LOG_VERBOSE) { \ |
| 67 | ALOGV("%s: %d: " arg, __func__, __LINE__, ##__VA_ARGS__);\ |
| 68 | } |