| Dileep Marchya | f9ba485 | 2014-10-24 19:56:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without modification, are permitted |
| 5 | * provided that the following conditions are met: |
| 6 | * * Redistributions of source code must retain the above copyright notice, this list of |
| 7 | * conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above copyright notice, this list of |
| 9 | * conditions and the following disclaimer in the documentation and/or other materials provided |
| 10 | * with the distribution. |
| 11 | * * Neither the name of The Linux Foundation nor the names of its contributors may be used to |
| 12 | * endorse or promote products derived from this software without specific prior written |
| 13 | * permission. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 17 | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 19 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 20 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 21 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __DEBUG_H__ |
| 26 | #define __DEBUG_H__ |
| 27 | |
| Manoj Kumar AVM | 4746f24 | 2015-01-06 20:25:22 -0800 | [diff] [blame] | 28 | #include <stdint.h> |
| Dileep Marchya | 3ffb470 | 2014-12-04 16:31:37 -0800 | [diff] [blame] | 29 | #include <core/sde_types.h> |
| Dileep Marchya | b61346f | 2014-11-06 14:36:19 -0800 | [diff] [blame] | 30 | |
| Dileep Marchya | 3ffb470 | 2014-12-04 16:31:37 -0800 | [diff] [blame] | 31 | #define DLOG(tag, method, format, ...) Debug::GetLogHandler()->method(tag, \ |
| 32 | __CLASS__ "::%s: " format, __FUNCTION__, ##__VA_ARGS__) |
| Dileep Marchya | b61346f | 2014-11-06 14:36:19 -0800 | [diff] [blame] | 33 | |
| Dileep Marchya | 3ffb470 | 2014-12-04 16:31:37 -0800 | [diff] [blame] | 34 | #define DLOGE_IF(tag, format, ...) DLOG(tag, Error, format, ##__VA_ARGS__) |
| 35 | #define DLOGW_IF(tag, format, ...) DLOG(tag, Warning, format, ##__VA_ARGS__) |
| 36 | #define DLOGI_IF(tag, format, ...) DLOG(tag, Info, format, ##__VA_ARGS__) |
| 37 | #define DLOGV_IF(tag, format, ...) DLOG(tag, Verbose, format, ##__VA_ARGS__) |
| Dileep Marchya | b61346f | 2014-11-06 14:36:19 -0800 | [diff] [blame] | 38 | |
| Dileep Marchya | 3ffb470 | 2014-12-04 16:31:37 -0800 | [diff] [blame] | 39 | #define DLOGE(format, ...) DLOGE_IF(kTagNone, format, ##__VA_ARGS__) |
| 40 | #define DLOGW(format, ...) DLOGW_IF(kTagNone, format, ##__VA_ARGS__) |
| 41 | #define DLOGI(format, ...) DLOGI_IF(kTagNone, format, ##__VA_ARGS__) |
| 42 | #define DLOGV(format, ...) DLOGV_IF(kTagNone, format, ##__VA_ARGS__) |
| Dileep Marchya | b61346f | 2014-11-06 14:36:19 -0800 | [diff] [blame] | 43 | |
| Dileep Marchya | f9ba485 | 2014-10-24 19:56:57 -0700 | [diff] [blame] | 44 | namespace sde { |
| 45 | |
| Dileep Marchya | f9ba485 | 2014-10-24 19:56:57 -0700 | [diff] [blame] | 46 | class Debug { |
| 47 | public: |
| Dileep Marchya | 3ffb470 | 2014-12-04 16:31:37 -0800 | [diff] [blame] | 48 | static inline void SetLogHandler(LogHandler *log_handler) { debug_.log_handler_ = log_handler; } |
| 49 | static inline LogHandler* GetLogHandler() { return debug_.log_handler_; } |
| 50 | static inline bool IsVirtualDriver() { return debug_.virtual_driver_; } |
| Manoj Kumar AVM | 4746f24 | 2015-01-06 20:25:22 -0800 | [diff] [blame] | 51 | static uint32_t GetSimulationFlag(); |
| Arun Kumar K.R | ecae9b2 | 2015-01-07 20:59:16 -0800 | [diff] [blame^] | 52 | static uint32_t GetHDMIResolution(); |
| Dileep Marchya | f9ba485 | 2014-10-24 19:56:57 -0700 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | Debug(); |
| Dileep Marchya | 3ffb470 | 2014-12-04 16:31:37 -0800 | [diff] [blame] | 56 | |
| 57 | // By default, drop any log messages coming from Display Engine. It will be overriden by Display |
| 58 | // Engine client when core is successfully initialized. |
| 59 | class DefaultLogHandler : public LogHandler { |
| 60 | public: |
| 61 | virtual void Error(LogTag /*tag*/, const char */*format*/, ...) { } |
| 62 | virtual void Warning(LogTag /*tag*/, const char */*format*/, ...) { } |
| 63 | virtual void Info(LogTag /*tag*/, const char */*format*/, ...) { } |
| 64 | virtual void Verbose(LogTag /*tag*/, const char */*format*/, ...) { } |
| 65 | }; |
| 66 | |
| 67 | DefaultLogHandler default_log_handler_; |
| 68 | LogHandler *log_handler_; |
| Dileep Marchya | f9ba485 | 2014-10-24 19:56:57 -0700 | [diff] [blame] | 69 | bool virtual_driver_; |
| 70 | static Debug debug_; |
| 71 | }; |
| 72 | |
| 73 | } // namespace sde |
| 74 | |
| 75 | #endif // __DEBUG_H__ |
| 76 | |