diff --git a/msm/vidc/msm_vidc_debug.c b/msm/vidc/msm_vidc_debug.c index 6be7fd301782..e5a1bc0deee3 100644 --- a/msm/vidc/msm_vidc_debug.c +++ b/msm/vidc/msm_vidc_debug.c @@ -600,7 +600,7 @@ int msm_vidc_check_ratelimit(void) /** * get_sid() must be called under "&core->lock" - * to avoid race condition in occurring empty slot. + * to avoid race condition at occupying empty slot. */ int get_sid(u32 *sid, u32 session_type) { @@ -633,6 +633,7 @@ inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) { const char *codec; char type; + u32 s_type = 0; if (!sid || sid > MAX_SUPPORTED_INSTANCES) { d_vpr_e("%s: invalid sid %#x\n", @@ -676,28 +677,54 @@ inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) switch (session_type) { case MSM_VIDC_ENCODER: type = 'e'; + s_type = VIDC_ENCODER; break; case MSM_VIDC_DECODER: type = 'd'; + s_type = VIDC_DECODER; break; case MSM_VIDC_CVP: type = 'c'; + s_type = VIDC_CVP; default: type = '.'; break; } - ctxt[sid-1].session_type = session_type; + ctxt[sid-1].session_type = s_type; ctxt[sid-1].codec_type = fourcc; memcpy(&ctxt[sid-1].name, codec, 4); ctxt[sid-1].name[4] = type; ctxt[sid-1].name[5] = '\0'; } -char *get_codec_name(u32 sid) +inline char *get_codec_name(u32 sid) { if (!sid || sid > MAX_SUPPORTED_INSTANCES) return "....."; return ctxt[sid-1].name; } + +/** + * 0xx -> allow prints for all sessions + * 1xx -> allow only encoder prints + * 2xx -> allow only decoder prints + * 4xx -> allow only cvp prints + */ +inline bool is_print_allowed(u32 sid, u32 level) +{ + if (!(msm_vidc_debug & level)) + return false; + + if (!((msm_vidc_debug >> 8) & 0xF)) + return true; + + if (!sid || sid > MAX_SUPPORTED_INSTANCES) + return true; + + if (ctxt[sid-1].session_type & msm_vidc_debug) + return true; + + return false; +} diff --git a/msm/vidc/msm_vidc_debug.h b/msm/vidc/msm_vidc_debug.h index a3b2c99b0471..89a0f8df0663 100644 --- a/msm/vidc/msm_vidc_debug.h +++ b/msm/vidc/msm_vidc_debug.h @@ -40,6 +40,9 @@ enum vidc_msg_prio { VIDC_PERF = 0x00000008, VIDC_PKT = 0x00000010, VIDC_BUS = 0x00000020, + VIDC_ENCODER = 0x00000100, + VIDC_DECODER = 0x00000200, + VIDC_CVP = 0x00000400, VIDC_PRINTK = 0x00001000, VIDC_FTRACE = 0x00002000, FW_LOW = 0x00010000, @@ -79,7 +82,7 @@ struct log_cookie { #define dprintk(__level, sid, __fmt, ...) \ do { \ - if (msm_vidc_debug & __level) { \ + if (is_print_allowed(sid, __level)) { \ if (msm_vidc_debug & VIDC_FTRACE) { \ char trace_logbuf[MAX_TRACER_LOG_LENGTH]; \ int log_length = snprintf(trace_logbuf, \ @@ -167,8 +170,9 @@ void msm_vidc_debugfs_update(struct msm_vidc_inst *inst, int msm_vidc_check_ratelimit(void); int get_sid(u32 *sid, u32 session_type); void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc); -char *get_codec_name(u32 sid); -void put_sid(u32 sid); +inline char *get_codec_name(u32 sid); +inline void put_sid(u32 sid); +inline bool is_print_allowed(u32 sid, u32 level); static inline char *get_debug_level_str(int level) {