Home | History | Annotate | Download | only in core
      1 /*
      2 * Copyright (c) 2015 - 2016, 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.
     28 */
     29 
     30 /*! @file debug_interface.h
     31   @brief This file provides the debug interface for display manager.
     32 */
     33 #ifndef __DEBUG_INTERFACE_H__
     34 #define __DEBUG_INTERFACE_H__
     35 
     36 namespace sdm {
     37 
     38 /*! @brief This enum represents different modules/logical unit tags that a log message may
     39   be associated with. Client may use this to filter messages for dynamic logging.
     40 
     41   @sa DebugHandler
     42 */
     43 enum DebugTag {
     44   kTagNone,             //!< Debug log is not tagged. This type of logs should always be printed.
     45   kTagResources,        //!< Debug log is tagged for resource management.
     46   kTagStrategy,         //!< Debug log is tagged for strategy decisions.
     47   kTagCompManager,      //!< Debug log is tagged for composition manager.
     48   kTagDriverConfig,     //!< Debug log is tagged for driver config.
     49   kTagRotator,          //!< Debug log is tagged for rotator.
     50   kTagScalar,           //!< Debug log is tagged for Scalar Helper.
     51   kTagQDCM,             //!< Debug log is tagged for display QDCM color managing.
     52 };
     53 
     54 /*! @brief Display debug handler class.
     55 
     56   @details This class defines display debug handler. The handle contains methods which client
     57   should implement to get different levels of logging/tracing from display manager. Display manager
     58    will call into these methods at appropriate times to send logging/tracing information.
     59 
     60   @sa CoreInterface::CreateCore
     61 */
     62 class DebugHandler {
     63  public:
     64   /*! @brief Method to handle error messages.
     65 
     66     @param[in] tag \link DebugTag \endlink
     67     @param[in] format \link message format with variable argument list \endlink
     68   */
     69   virtual void Error(DebugTag tag, const char *format, ...) = 0;
     70 
     71   /*! @brief Method to handle warning messages.
     72 
     73     @param[in] tag \link DebugTag \endlink
     74     @param[in] format \link message format with variable argument list \endlink
     75   */
     76   virtual void Warning(DebugTag tag, const char *format, ...) = 0;
     77 
     78   /*! @brief Method to handle informative messages.
     79 
     80     @param[in] tag \link DebugTag \endlink
     81     @param[in] format \link message format with variable argument list \endlink
     82   */
     83   virtual void Info(DebugTag tag, const char *format, ...) = 0;
     84 
     85   /*! @brief Method to handle debug messages.
     86 
     87     @param[in] tag \link DebugTag \endlink
     88     @param[in] format \link message format with variable argument list \endlink
     89   */
     90   virtual void Debug(DebugTag tag, const char *format, ...) = 0;
     91 
     92   /*! @brief Method to handle verbose messages.
     93 
     94     @param[in] tag \link DebugTag \endlink
     95     @param[in] format \link message format with variable argument list \endlink
     96   */
     97   virtual void Verbose(DebugTag tag, const char *format, ...) = 0;
     98 
     99   /*! @brief Method to begin trace for a module/logical unit.
    100 
    101     @param[in] class_name \link name of the class that the function belongs to \endlink
    102     @param[in] function_name \link name of the function to be traced \endlink
    103     @param[in] custom_string \link custom string for multiple traces within a function \endlink
    104   */
    105   virtual void BeginTrace(const char *class_name, const char *function_name,
    106                           const char *custom_string) = 0;
    107 
    108   /*! @brief Method to end trace for a module/logical unit.
    109   */
    110   virtual void EndTrace() = 0;
    111 
    112   /*! @brief Method to get property value corresponding to give string.
    113 
    114     @param[in] property_name name of the property
    115     @param[out] integer converted value corresponding to the property name
    116 
    117     @return \link DisplayError \endlink
    118   */
    119   virtual DisplayError GetProperty(const char *property_name, int *value) = 0;
    120 
    121   /*! @brief Method to get property value corresponding to give string.
    122 
    123    @param[in] property_name name of the property
    124    @param[out] string value corresponding to the property name
    125 
    126    @return \link DisplayError \endlink
    127   */
    128   virtual DisplayError GetProperty(const char *property_name, char *value) = 0;
    129 
    130   /*! @brief Method to set a property to a given string value.
    131 
    132    @param[in] property_name name of the property
    133    @param[in] value new value of the property name
    134 
    135    @return \link DisplayError \endlink
    136   */
    137   virtual DisplayError SetProperty(const char *property_name, const char *value) = 0;
    138 
    139  protected:
    140   virtual ~DebugHandler() { }
    141 };
    142 
    143 /*! @brief Scope tracer template class.
    144 
    145   @details This class template implements the funtionality to capture the trace for function/
    146   module. It starts the trace upon object creation and ends the trace upon object destruction.
    147 */
    148 template <class T>
    149 class ScopeTracer {
    150  public:
    151   ScopeTracer(const char *class_name, const char *function_name) {
    152     T::Get()->BeginTrace(class_name, function_name, "");
    153   }
    154 
    155   ~ScopeTracer() { T::Get()->EndTrace(); }
    156 };
    157 
    158 }  // namespace sdm
    159 
    160 #endif  // __DEBUG_INTERFACE_H__
    161 
    162 
    163 
    164