gfx: hdmi: Enabling EDID prints during run-time
authorAnand Gandhimathi <gandhimathi.anand@intel.com>
Tue, 13 Mar 2012 00:28:44 +0000 (17:28 -0700)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:30:32 +0000 (12:30 +0300)
Handle to hdmi_context function added in a opaque manner
Cleaned up print pointers being passed to different functions
PD_LOG macros and typedefs replaced to LOG_ macros and typedefs
New module to generate run-time EDID print logs

Signed-off-by: Chen Hu <hu.tiger.chen@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/staging/mrst/drv/otm_hdmi/pil/common/edid.c
drivers/staging/mrst/drv/otm_hdmi/pil/common/edid.h
drivers/staging/mrst/drv/otm_hdmi/pil/common/edid_print.c
drivers/staging/mrst/drv/otm_hdmi/pil/common/otm_hdmi.c
drivers/staging/mrst/drv/otm_hdmi/pil/include/otm_hdmi.h

index 97a0ecf..1e23136 100644 (file)
 #define EDID_SIGNATURE 0x00FFFFFFFFFFFF00ull
 
 /*
- * Debug printing setup
- */
-/* TODO: All printing should use one method,either PD_LOG_PRINT,
- * EDID_PRINT, DRM printing, pr_debug. The solution should be run-time
- * instead of compile-time switches. Will need some work to get
- * that done. Deferring for the time-being. Keep EDID prints
- * disabled as they are invoked on every DRM get_mode query
- * and prove costly and add problems like slow, jittery playback */
-#ifndef OTM_HDMI_FIXME
-static int EDID_PRINT(const char *fmt, ...)
-{
-       return 0;
-}
-#else
-static int EDID_PRINT(const char *fmt, ...)
-{
-       va_list arg_list;
-
-       va_start(arg_list, fmt);
-       vprintk(fmt, arg_list);
-       va_end(arg_list);
-       return 0;
-}
-#endif
-
-/*
  * Structure to keep state of read operation
  */
 typedef struct {
@@ -121,10 +95,6 @@ typedef struct {
        int position;
 } read_context_t;
 
-static void fetch_generic_descriptor(generic_descriptor_t *gd,
-                               read_context_t *rctx)
-                               __attribute__((unused));
-
 static void fetch_timing_descriptor(timing_descriptor_t *td,
                                read_context_t *rctx)
                                __attribute__((unused));
@@ -473,7 +443,7 @@ static otm_hdmi_ret_t add_timings(edid_info_t *edid,
                                OTM_HDMI_ERR_INVAL, exit);
 
        /* Print info about it */
-       print_pd_timing(pdt, order, EDID_PRINT);
+       print_pd_timing(pdt, order);
 
        /* Do not add modes that we dont support */
        i = find_timing_tp(edid->ref_timings, edid->num_ref_timings, pdt);
@@ -523,12 +493,12 @@ static void decode_speaker_allocation_data_block(unsigned char *e, int n,
 {
        int ne = n / 3;
 
-       EDID_PRINT("[speaker block]\n");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "[speaker block]\n");
 
        while (ne-- > 0) {
                edid->speaker_map =
                    (unsigned)*e | (unsigned)(*(e + 1) & 0x7) << 8;
-               print_speaker_layout(edid->speaker_map, EDID_PRINT);
+               print_speaker_layout(edid->speaker_map);
                e++;
                e++;             /* skip the rest of the block */
        }
@@ -541,11 +511,12 @@ static void decode_video_data_block(unsigned char *e, int n, edid_info_t *edid)
 {
        int vic, j, i = 0;
 
-       EDID_PRINT("[video data block]\n");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "[video data block]\n");
 
        while (n-- > 0) {
                vic = *e & 0x7F;
-               EDID_PRINT("- mode #%d %s\n", vic, (*e & 0x80) ? "native" : "");
+               LOG_PRINT(LOG_LEVEL_DETAIL,
+                        "- mode #%d %s\n", vic, (*e & 0x80) ? "native" : "");
 
                if ((j =
                     find_timing_by_vic_tp(edid->ref_timings,
@@ -572,7 +543,7 @@ static void decode_audio_data_block(unsigned char *e, int n, edid_info_t *edid)
        int ne = n / 3;
        otm_hdmi_audio_cap_t *adb = (otm_hdmi_audio_cap_t *) &edid->audio_caps;
 
-       EDID_PRINT("[audio data block... %d entries]\n", ne);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "[audio data block... %d entries]\n", ne);
 
        while (ne-- > 0) {
                /* Do we have room for another capability? */
@@ -581,8 +552,7 @@ static void decode_audio_data_block(unsigned char *e, int n, edid_info_t *edid)
                        adb[edid->num_caps].max_channels = (*e & 0x07) + 1;
                        adb[edid->num_caps].fs = *(e + 1) & 0x7F;
                        adb[edid->num_caps].ss_bitrate = *(e + 2);
-                       print_audio_capability(&adb[edid->num_caps],
-                                              EDID_PRINT);
+                       print_audio_capability(&adb[edid->num_caps]);
                        edid->num_caps++;
                }
                /* Go to the next entry of the block */
@@ -718,7 +688,7 @@ void decode_3D_modes(unsigned char *e, int n, int layout, edid_info_t *edid)
 {
        unsigned int offset;
 
-       EDID_PRINT("- 3D modes supported:\n");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "- 3D modes supported:\n");
 
        /* Declare mandatory modes */
        declare_mandatory_3d(edid);
@@ -766,13 +736,14 @@ static void decode_vendor_data_block(unsigned char *e,
        unsigned int len_3d, len_hdmi;
 #endif
 
-       EDID_PRINT("[vendor specific data block.. length %d]\n", n);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               "[vendor specific data block.. length %d]\n", n);
 
        /* Look for HDMI signature [0x030C00] */
        if (n >= 3) {
                if ((e[0] == 0x03) && (e[1] == 0x0C) && (e[2] == 0x00)) {
                        edid->hdmi = true;
-                       EDID_PRINT("- HDMI signature found\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL, "- HDMI signature found\n");
                }
        }
        /* Parse Source Physical Address */
@@ -847,32 +818,34 @@ static void decode_vendor_data_block(unsigned char *e,
 static void decode_extended_data_block(unsigned char *e,
                                int n, edid_info_t *edid)
 {
-       EDID_PRINT("[extended data block.. length %d]\n", n);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "[extended data block.. length %d]\n", n);
 
        switch (*(e + 0)) {
        case 0x00:               /* Video Capability Block */
-               EDID_PRINT("Video Capability Block\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "Video Capability Block\n");
                edid->rgb_quant_selectable = *(e + 1) & 0x40;
                edid->ycc_quant_selectable = *(e + 1) & 0x80;
                break;
        case 0x01:               /* Vendor Specific Video Data Block */
-               EDID_PRINT("Vendor Specific Video Data Block\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL,
+                       "Vendor Specific Video Data Block\n");
                break;
        case 0x05:               /* Colorimetry Block */
-               EDID_PRINT("Colorimetry Block\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "Colorimetry Block\n");
                if (n == 3) {
                        edid->xvycc601 = (*(e + 1) & 0x01) != 0;
                        edid->xvycc709 = (*(e + 1) & 0x02) != 0;
                }
                break;
        case 0x11:               /* CEA Misc Audio Block */
-               EDID_PRINT("CEA Misc Audio Block\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "CEA Misc Audio Block\n");
                break;
        case 0x12:               /* Vendor specific audio data block */
-               EDID_PRINT("Vendor specific audio data Block\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL,
+                       "Vendor specific audio data Block\n");
                break;
        default:                 /* reserved blocks */
-               EDID_PRINT("Reserved Block\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "Reserved Block\n");
                break;
        }
 
@@ -929,14 +902,16 @@ static void decode_block_collection(extention_block_cea_t *eb,
                                                                  payload_size,
                                                                  edid);
                        } else {
-                               EDID_PRINT("[block 0x%x.. TBA]\n", block_type);
+                               LOG_PRINT(LOG_LEVEL_DETAIL,
+                                        "[block 0x%x.. TBA]\n", block_type);
                        }
                }
                /* Unknown */
                else
-                       EDID_PRINT("[unknown block 0x%x]\n", (int)*c);
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                                       "[unknown block 0x%x]\n", (int)*c);
 
-               EDID_PRINT("\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "\n");
                c += (*c & 0x1F) + 1;
        }
 }
@@ -976,7 +951,7 @@ static void decode_standard_timings(unsigned short st, edid_info_t *edid)
                /* Indicate no stereo support */
                pdt.stereo_type = OTM_HDMI_STEREO_NONE;
 
-               EDID_PRINT("[Standart timing]\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "[Standart timing]\n");
                add_timings(edid, &pdt, 0);
        }
 }
@@ -1011,20 +986,27 @@ static bool decode_detailed_timings(timing_descriptor_t *td,
        int h_img_size = ((td->hv_image_size & 0xF0) << 4) | td->h_image_size;
        int v_img_size = ((td->hv_image_size & 0x0F) << 8) | td->v_image_size;
 
-       EDID_PRINT("[detailed timing descriptor]\n");
-
-#ifndef PRINT_DETAILED_TIMINGS
-       EDID_PRINT(" - pixel_clock     : %d KHz\n", pixel_clock);
-       EDID_PRINT(" - horz_active     : %d pixels\n", h_active);
-       EDID_PRINT(" - horz_blanking   : %d pixels\n", h_blanking);
-       EDID_PRINT(" - vert_active     : %d lines\n", v_active);
-       EDID_PRINT(" - vert_blanking   : %d lines\n", v_blanking);
-       EDID_PRINT(" - horz_sync_off   : %d pixels\n", h_sync_off);
-       EDID_PRINT(" - horz_sync_pw    : %d pixels\n", h_sync_pw);
-       EDID_PRINT(" - vert_sync_off   : %d lines\n", v_sync_off);
-       EDID_PRINT(" - vert_sync_pw    : %d lines\n", v_sync_pw);
-       EDID_PRINT(" - image ratio     : %d : %d\n", h_img_size, v_img_size);
-#endif
+       LOG_PRINT(LOG_LEVEL_DETAIL, "[detailed timing descriptor]\n");
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - pixel_clock     : %d KHz\n", pixel_clock);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - horz_active     : %d pixels\n", h_active);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - horz_blanking   : %d pixels\n", h_blanking);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - vert_active     : %d lines\n", v_active);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - vert_blanking   : %d lines\n", v_blanking);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - horz_sync_off   : %d pixels\n", h_sync_off);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - horz_sync_pw    : %d pixels\n", h_sync_pw);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - vert_sync_off   : %d lines\n", v_sync_off);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - vert_sync_pw    : %d lines\n", v_sync_pw);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               " - image ratio     : %d : %d\n", h_img_size, v_img_size);
 
        pdt->width = h_active;
        pdt->htotal = h_active + h_blanking;
@@ -1083,20 +1065,24 @@ static void decode_generic_descriptor(generic_descriptor_t *gd,
            && (gd->flag == 0)) {
                switch (gd->data_type_tag) {
                case 0xFF:
-                       EDID_PRINT("[Monitor Serial Number ]\n");
-                       EDID_PRINT(" - %s\n", gd->payload);
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[Monitor Serial Number ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL, " - %s\n", gd->payload);
                        break;
                case 0xFE:
-                       EDID_PRINT("[ASCII String          ]\n");
-                       EDID_PRINT(" - %s\n", gd->payload);
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[ASCII String          ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL, " - %s\n", gd->payload);
                        break;
                case 0xFD:
-                       EDID_PRINT("[Monitor Range Limits  ]\n");
-                       EDID_PRINT(" - ...\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[Monitor Range Limits  ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL, " - ...\n");
                        break;
                case 0xFC:
-                       EDID_PRINT("[Monitor Name          ]\n");
-                       EDID_PRINT(" - %s\n", gd->payload);
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[Monitor Name          ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL, " - %s\n", gd->payload);
                        for (i = 0; i < 13; i++) {
                                if (gd->payload[i] == '\n')
                                        break;
@@ -1105,10 +1091,12 @@ static void decode_generic_descriptor(generic_descriptor_t *gd,
                        }
                        break;
                case 0xFB:
-                       EDID_PRINT("[Color Data            ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[Color Data            ]\n");
                        break;
                case 0xFA:
-                       EDID_PRINT("[More Standard Timings ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[More Standard Timings ]\n");
                        for (i = 0; i < 12; i += 2) {
                                /* TODO: Need more info on proper byte order */
                                decode_standard_timings
@@ -1117,10 +1105,12 @@ static void decode_generic_descriptor(generic_descriptor_t *gd,
                        }
                        break;
                case 0x10:
-                       EDID_PRINT("[Dummy                 ]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[Dummy                 ]\n");
                        break;
                default:
-                       EDID_PRINT("[Manufacturer/Undefined]\n");
+                       LOG_PRINT(LOG_LEVEL_DETAIL,
+                               "[Manufacturer/Undefined]\n");
                        break;
                }
        }
@@ -1254,7 +1244,7 @@ static otm_hdmi_ret_t block_decode(edid_info_t *edid_info, unsigned int type,
        otm_hdmi_ret_t rc = OTM_HDMI_SUCCESS;
        extention_block_cea_t eb;
 
-       EDID_PRINT("Decoding extension 0x%x\n", type);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "Decoding extension 0x%x\n", type);
 
        switch (type) {
        case 0x02:
@@ -1265,7 +1255,8 @@ static otm_hdmi_ret_t block_decode(edid_info_t *edid_info, unsigned int type,
                break;
 
        default:
-               EDID_PRINT("Extension 0x%x is not supported; Bypassing\n",
+               LOG_PRINT(LOG_LEVEL_DETAIL,
+                       "Extension 0x%x is not supported; Bypassing\n",
                           type);
                break;
        }
@@ -1302,8 +1293,7 @@ int edid_parse_pd_timing_from_cea_block(edid_info_t *edid_info,
  * edid_parse()
  */
 otm_hdmi_ret_t edid_parse(edid_info_t *edid_info,
-                       i2c_read_t data_read, void *cd,
-                       bool hex_dump)
+                       i2c_read_t data_read, void *cd)
 {
        unsigned char buffer[SEGMENT_SIZE];
        edid_block_zero_t ebz;
@@ -1315,7 +1305,7 @@ otm_hdmi_ret_t edid_parse(edid_info_t *edid_info,
        /* Read block zero */
        rc = data_read(cd, 0, 0, buffer, SEGMENT_SIZE);
        VERIFY_QUICK(rc == OTM_HDMI_SUCCESS, exit);
-       print_raw_block(buffer, SEGMENT_SIZE, (bool) hex_dump);
+       print_raw_block(buffer, SEGMENT_SIZE);
        VERIFY(checksum_valid(buffer, SEGMENT_SIZE), rc,
                                OTM_HDMI_ERR_FAILED, exit);
 
@@ -1354,7 +1344,7 @@ otm_hdmi_ret_t edid_parse(edid_info_t *edid_info,
        /* Read next block */
        rc = data_read(cd, 0, SEGMENT_SIZE, buffer, SEGMENT_SIZE);
        VERIFY_QUICK(rc == OTM_HDMI_SUCCESS, exit);
-       print_raw_block(buffer, SEGMENT_SIZE, (bool) hex_dump);
+       print_raw_block(buffer, SEGMENT_SIZE);
        VERIFY(checksum_valid(buffer, SEGMENT_SIZE), rc,
                                OTM_HDMI_ERR_FAILED, exit);
 
@@ -1384,7 +1374,7 @@ otm_hdmi_ret_t edid_parse(edid_info_t *edid_info,
                        /* Read extension block */
                        rc = data_read(cd, sp, offset, buffer, SEGMENT_SIZE);
                        VERIFY_QUICK(rc == OTM_HDMI_SUCCESS, exit);
-                       print_raw_block(buffer, SEGMENT_SIZE, (bool) hex_dump);
+                       print_raw_block(buffer, SEGMENT_SIZE);
                        VERIFY(checksum_valid(buffer, SEGMENT_SIZE), rc,
                               OTM_HDMI_ERR_FAILED, exit);
 
index 45e671a..5517dcb 100644 (file)
@@ -134,13 +134,12 @@ typedef struct {
 } edid_info_t;
 
 otm_hdmi_ret_t edid_parse(edid_info_t *edid_info, i2c_read_t data_read,
-                         void *cd, bool hex_dump);
+                         void *cd);
 
-void print_pd_timing(const otm_hdmi_timing_t *pdt, unsigned int order,
-                    printf_t print);
-void print_audio_capability(otm_hdmi_audio_cap_t *adb, printf_t print);
-void print_speaker_layout(unsigned int layout, printf_t print);
-void print_raw_block(unsigned char *buffer, int size, bool print);
+void print_pd_timing(const otm_hdmi_timing_t *pdt, unsigned int order);
+void print_audio_capability(otm_hdmi_audio_cap_t *adb);
+void print_speaker_layout(unsigned int layout);
+void print_raw_block(unsigned char *buffer, int size);
 
 int find_timing(const otm_hdmi_timing_t *set, int size,
                const otm_hdmi_timing_t *e);
index 523cf1f..6061c26 100644 (file)
 #include <linux/kernel.h>
 #include "edid_internal.h"
 
-/* __fake_printf */
-static int __fake_printf(const char *fmt, ...)
-{
-       return 0;
-}
-
 /* Convert the refresh rate enum to a string for printing */
 static char *_refresh_string(otm_hdmi_refresh_t r)
 {
@@ -151,29 +145,37 @@ static char *_stereo_string(otm_hdmi_stereo_t stereo_type)
 
 /* print_pd_timing */
 void print_pd_timing(const otm_hdmi_timing_t *t,
-                    unsigned int order, printf_t print)
+                    unsigned int order)
 {
-       printf_t p = print ? print : __fake_printf;
-
-       p(" - %dx%d @ %s", t->width, t->height, _refresh_string(t->refresh));
-       p("%s", (t->mode_info_flags & PD_SCAN_INTERLACE) ? "i" : "p");
-       p(" [%s]", (t->mode_info_flags & PD_AR_16_BY_9) ? "16:9" : "4:3");
-       p(" [%d]", order);
-       p(" [%s]\n", _stereo_string(t->stereo_type));
-
-#ifdef PRINT_DETAILED_TIMINGS
-       p(" - htotal      : %d\n", t->htotal);
-       p(" - hblank_start: %d\n", t->hblank_start);
-       p(" - hblank_end  : %d\n", t->hblank_end);
-       p(" - hsync_start : %d\n", t->hsync_start);
-       p(" - hsync_end   : %d\n", t->hsync_end);
-       p(" - vtotal      : %d\n", t->vtotal);
-       p(" - vblank_start: %d\n", t->vblank_start);
-       p(" - vblank_end  : %d\n", t->vblank_end);
-       p(" - vsync_start : %d\n", t->vsync_start);
-       p(" - vsync_end   : %d\n", t->vsync_end);
-       p(" - clock       : %dMhz\n", (int)(t->dclk / 1000));
-#endif
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               "%dx%d @ %s %s [%s] [%d] [%s]\n",
+               t->width, t->height, _refresh_string(t->refresh),
+               ((t->mode_info_flags & PD_SCAN_INTERLACE) ? "i" : "p"),
+               ((t->mode_info_flags & PD_AR_16_BY_9) ? "16:9" : "4:3"),
+               order, _stereo_string(t->stereo_type));
+
+       LOG_PRINT(LOG_LEVEL_DETAIL, "htotal      : %d\n",
+                               t->htotal);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               "hblank_start: %d\n", t->hblank_start);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               "hblank_end  : %d\n", t->hblank_end);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "hsync_start : %d\n",
+                       t->hsync_start);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "hsync_end   : %d\n",
+                       t->hsync_end);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "vtotal      : %d\n",
+                       t->vtotal);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "vblank_start: %d\n",
+               t->vblank_start);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "vblank_end  : %d\n",
+               t->vblank_end);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "vsync_start : %d\n",
+               t->vsync_start);
+       LOG_PRINT(LOG_LEVEL_DETAIL, "vsync_end   : %d\n",
+               t->vsync_end);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               "clock       : %dMhz\n", (int)(t->dclk / 1000));
 }
 
 /* Convert audio format enum to a string for printing */
@@ -269,17 +271,18 @@ static char *_sampling_rate(otm_hdmi_audio_fs_t fs)
 }
 
 /* print_audio_capability() */
-void print_audio_capability(otm_hdmi_audio_cap_t *cap, printf_t print)
+void print_audio_capability(otm_hdmi_audio_cap_t *cap)
 {
-       printf_t p = print ? print : __fake_printf;
        int i;
 
-       p(" - Format: %s; Max channels: %d; Sampling rates, KHz:",
-         _audio_format(cap->format), cap->max_channels);
+       LOG_PRINT(LOG_LEVEL_DETAIL,
+               "Format: %s; Max channels: %d; Sampling rates, KHz:",
+                 _audio_format(cap->format), cap->max_channels);
 
        for (i = 0; i < 7; i++)
-               p(" %s", (cap->fs & (1 << i)) ? _sampling_rate(1 << i) : "");
-       p("\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL,
+               " %s", (cap->fs & (1 << i)) ? _sampling_rate(1 << i) : "");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "\n");
 }
 
 /* Convert a speaker map enum to a string for printing */
@@ -331,28 +334,26 @@ static char *_speaker_map(otm_hdmi_audio_speaker_map_t map)
 }
 
 /* print_speaker_layout() */
-void print_speaker_layout(unsigned int layout, printf_t print)
+void print_speaker_layout(unsigned int layout)
 {
-       printf_t p = print ? print : __fake_printf;
        int i;
 
-       p(" - Speaker layout map:");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "Speaker layout map:");
        for (i = 0; i < 11; i++)
-               p(" %s", (layout & (1 << i)) ? _speaker_map(1 << i) : "");
-       p("\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL,
+               " %s", (layout & (1 << i)) ? _speaker_map(1 << i) : "");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "\n");
 }
 
 /* print_raw_block() */
-void print_raw_block(unsigned char *buffer, int size, bool print)
+void print_raw_block(unsigned char *buffer, int size)
 {
        int i;
 
-       if (!print)
-               return;
-
        for (i = 0; i < size; i++) {
-               pr_debug("%s", (i % 0x10) ? "" : "\n");
-               pr_debug("%02X ", buffer[i]);
+               if (i != 0 && ((i % 0x10) == 0))
+                       LOG_PRINT(LOG_LEVEL_DETAIL, "\n");
+               LOG_PRINT(LOG_LEVEL_DETAIL, "%02X\n", buffer[i]);
        }
-       pr_debug("\n");
+       LOG_PRINT(LOG_LEVEL_DETAIL, "\n");
 }
index f178f26..6582579 100644 (file)
@@ -159,82 +159,64 @@ static otm_hdmi_ret_t __program_clocks(hdmi_context_t *ctx, unsigned int dclk)
        return rc;
 }
 
-/*
- * Wrapper over printing to both console and SVEN. Note that Both underlying
- * routines accept frame stack pointer
- */
-static int __vprintf(const char *fmt, ...)
-{
-       int rc = 0;
-       va_list argp;
-
-       /* Log on console only if debug is on */
-       if (PD_ATTR_UINT(ATTRS[OTM_HDMI_ATTR_ID_DEBUG]) >= PD_LOG_LEVEL_ERROR) {
-               va_start(argp, fmt);
-               rc = vprintk(fmt, argp);
-               va_end(argp);
-       }
-       return rc;
-}
-
 static void __hdmi_report_edid(hdmi_context_t *ctx, edid_info_t *edid)
 {
        int i = 0;
 
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "----------------------\n");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Name     : %s\n", edid->product_name);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Year     : %d\n", edid->product_year);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "SN       : %d\n", edid->product_sn);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Type     : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "----------------------\n");
+       LOG_PRINT(LOG_LEVEL_HIGH, "Name     : %s\n", edid->product_name);
+       LOG_PRINT(LOG_LEVEL_HIGH, "Year     : %d\n", edid->product_year);
+       LOG_PRINT(LOG_LEVEL_HIGH, "SN       : %d\n", edid->product_sn);
+       LOG_PRINT(LOG_LEVEL_HIGH, "Type     : %s\n",
                        edid->hdmi ? "HDMI" : "DVI");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "YCbCr444 : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "YCbCr444 : %s\n",
                        edid->ycbcr444 ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "YCbCr422 : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "YCbCr422 : %s\n",
                        edid->ycbcr422 ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "30 bpp   : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "30 bpp   : %s\n",
                        edid->dc_30 ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "36 bpp   : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "36 bpp   : %s\n",
                        edid->dc_36 ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "48 bpp   : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "48 bpp   : %s\n",
                        edid->dc_48 ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "DC_YUV   : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "DC_YUV   : %s\n",
                        edid->dc_y444 ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Max CLK  : %d\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "Max CLK  : %d\n",
                        edid->max_tmds_clock);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Lip sync : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "Lip sync : %s\n",
                        edid->latency_present ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "ILip sync: %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "ILip sync: %s\n",
                        edid->latency_int_present ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Vid lat  : %d\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "Vid lat  : %d\n",
                        edid->latency_video);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Aud lat  : %d\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "Aud lat  : %d\n",
                        edid->latency_audio);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "IVid lat : %d\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "IVid lat : %d\n",
                        edid->latency_video_interlaced);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "IAud lat : %d\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "IAud lat : %d\n",
                        edid->latency_audio_interlaced);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "HDMI VID : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "HDMI VID : %s\n",
                        edid->hdmi_video_present ? "Y" : "N");
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "HDMI 3D  : %s\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "HDMI 3D  : %s\n",
                        edid->enabled_3d ? "Y" : "N");
 
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "SPA      : %d.%d.%d.%d\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "SPA      : %d.%d.%d.%d\n",
                  (edid->spa & 0xF000) >> 12,
                  (edid->spa & 0x0F00) >> 8,
                  (edid->spa & 0x00F0) >> 4, (edid->spa & 0x000F) >> 0);
 
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Supported timings [%d]:\n",
+       LOG_PRINT(LOG_LEVEL_HIGH, "Supported timings [%d]:\n",
                  edid->num_timings);
 
        for (i = 0; i < edid->num_timings; i++)
-               print_pd_timing(&edid->timings[i], edid->order[i], __vprintf);
+               print_pd_timing(&edid->timings[i], edid->order[i]);
 
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "Audio capabilities:\n");
+       LOG_PRINT(LOG_LEVEL_HIGH, "Audio capabilities:\n");
        for (i = 0; i < edid->num_caps; i++)
-               print_audio_capability(&edid->audio_caps[i], __vprintf);
+               print_audio_capability(&edid->audio_caps[i]);
 
-       print_speaker_layout(edid->speaker_map, __vprintf);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "----------------------\n");
+       print_speaker_layout(edid->speaker_map);
+       LOG_PRINT(LOG_LEVEL_HIGH, "----------------------\n");
 }
 
 static otm_hdmi_ret_t __hdmi_edid_override(hdmi_context_t *ctx,
@@ -353,7 +335,7 @@ otm_hdmi_ret_t otm_hdmi_edid_parse(void *context, otm_hdmi_use_edid_t use_edid)
                /* Try reading EDID. If reading failed pick overriding strategy
                 * based on cable status
                */
-               rc = edid_parse(edid, edid_foo, ctx, false);
+               rc = edid_parse(edid, edid_foo, ctx);
                if (rc != OTM_HDMI_SUCCESS) {
                        pr_debug("Failed to read EDID info\n");
                        use_edid = cable ? OTM_HDMI_USE_EDID_SAFE :
@@ -362,7 +344,7 @@ otm_hdmi_ret_t otm_hdmi_edid_parse(void *context, otm_hdmi_use_edid_t use_edid)
                break;
        case OTM_HDMI_USE_EDID_SAFE:
                /* In safe mode we still need real EDID */
-               edid_parse(edid, edid_foo, ctx, false);
+               edid_parse(edid, edid_foo, ctx);
                break;
        case OTM_HDMI_USE_EDID_NONE:
                /* In full override mode we dont care of real EDID
@@ -410,11 +392,11 @@ twin_caps:
 
        /* Print warning message in case there are no timings */
        if (ctx->edid_int.num_timings == 0) {
-               PD_LOG_ERROR
+               LOG_ERROR
                    ("----------------- WARNING -----------------------\n");
-               PD_LOG_ERROR
+               LOG_ERROR
                    ("-- TV timings are not available           --\n");
-               PD_LOG_ERROR
+               LOG_ERROR
                    ("-- To resolve this switch to static TV timings --\n");
        }
        /* Update EDID availability indicator */
@@ -619,7 +601,7 @@ static otm_hdmi_ret_t __hdmi_phy_enable(void *context, bool status)
        ctx->phy_status = status;
 
        /* Debug print */
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "PHY -> %s\n", status ? "on" : "off");
+       LOG_PRINT(LOG_LEVEL_HIGH, "PHY -> %s\n", status ? "on" : "off");
 
 exit:
        return rc;
@@ -699,7 +681,7 @@ static otm_hdmi_ret_t __hdmi_context_init(void *context, struct pci_dev *pdev)
        hdmi_context_t *ctx = NULL;
        unsigned int isr_address;
 
-       PD_LOG_ENTRY(PD_LOG_LEVEL_HIGH);
+       LOG_ENTRY(LOG_LEVEL_HIGH);
 
        /* Verify pointers */
        if (context == NULL) {
@@ -756,7 +738,7 @@ static otm_hdmi_ret_t __hdmi_context_init(void *context, struct pci_dev *pdev)
        mutex_init (&ctx->mute_sema);
 
 exit:
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return rc;
 }
 
@@ -765,7 +747,7 @@ void otm_hdmi_deinit(void *context)
        otm_hdmi_ret_t rc = OTM_HDMI_SUCCESS;
        hdmi_context_t *ctx = NULL;
 
-       PD_LOG_ENTRY(PD_LOG_LEVEL_HIGH);
+       LOG_ENTRY(LOG_LEVEL_HIGH);
 
        /* Verify pointers */
        if (context == NULL) {
@@ -821,7 +803,7 @@ void otm_hdmi_deinit(void *context)
 
        pr_debug("Exiting deinit with error code %d\n", rc);
 exit:
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return;
 }
 
@@ -945,7 +927,7 @@ otm_hdmi_ret_t otm_hdmi_device_init(void **context, struct pci_dev *pdev)
        hdmi_context_t *ctx = NULL;
        int n;
 
-       PD_LOG_ENTRY(PD_LOG_LEVEL_HIGH);
+       LOG_ENTRY(LOG_LEVEL_HIGH);
 
        /* Verify pointers */
        if (context == NULL) {
@@ -1040,7 +1022,7 @@ exit:
        if ((rc != OTM_HDMI_SUCCESS) && (ctx != NULL))
                otm_hdmi_deinit((void *)ctx);
 
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return rc;
 }
 
@@ -1198,7 +1180,7 @@ static otm_hdmi_ret_t __set_attr_csc(hdmi_context_t *ctx)
        int in, out;
 
        if (NULL == ctx) {
-               PD_LOG_ERROR("Invalid argument passed (ctx)\n");
+               LOG_ERROR("Invalid argument passed (ctx)\n");
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
@@ -1236,18 +1218,18 @@ static otm_hdmi_ret_t otm_hdmi_attr_set_validate(otm_hdmi_attribute_id_t id,
        int str_len = 0;
 
        if (id < 0 || id >= OTM_HDMI_MAX_SUPPORTED_ATTRIBUTES) {
-               PD_LOG_ERROR("Invalid argument passed (id): %d\n", id);
+               LOG_ERROR("Invalid argument passed (id): %d\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
        if (NULL == value) {
-               PD_LOG_ERROR("Invalid argument passed (value): %d\n", id);
+               LOG_ERROR("Invalid argument passed (value): %d\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
 
-       if (OTM_HDMI_ATTR_FLAG_WRITE != ATTRS[id].flags) {
-               PD_LOG_ERROR("Attribute id: %d is read-only\n", id);
+       if ((OTM_HDMI_ATTR_FLAG_WRITE & ATTRS[id].flags) != 1) {
+               LOG_ERROR("Attribute id: %d is read-only\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
@@ -1279,13 +1261,13 @@ static otm_hdmi_ret_t otm_hdmi_attr_set_validate(otm_hdmi_attribute_id_t id,
                }
                break;
        default:
-               PD_LOG_ERROR("Invalid attribute id (%d)\n", id);
+               LOG_ERROR("Invalid attribute id (%d)\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                break;
        }
 
 exit:
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return rc;
 }
 
@@ -1320,10 +1302,10 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
        bool abool;
        unsigned int auint, out, depth;
        otm_hdmi_attribute_flag_t flags;
-       PD_LOG_ENTRY(PD_LOG_LEVEL_HIGH);
+       LOG_ENTRY(LOG_LEVEL_HIGH);
 
        if (NULL == ctx) {
-               PD_LOG_ERROR("Invalid argument passed (context): %d\n", id);
+               LOG_ERROR("Invalid argument passed (context): %d\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
@@ -1336,7 +1318,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
                goto exit;
        abool = *(bool *) (data);
        auint = *(unsigned int *) (data);
-       PD_LOG_PRINT(PD_LOG_LEVEL_HIGH, "ATTR[%d] -> %d\n", id, auint);
+       LOG_PRINT(LOG_LEVEL_HIGH, "ATTR[%d] -> %d\n", id, auint);
 
 #ifdef OTM_HDMI_FIXME
        /*
@@ -1351,7 +1333,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 
        rc = __update_edid(ctx);
        if (rc != OTM_HDMI_SUCCESS) {
-               PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+               LOG_ERROR("ERR: %s at %d code = %d\n",
                                __func__, __LINE__, rc);
                goto exit;
        }
@@ -1374,7 +1356,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = ctx->support->pd_setmode_required(pipe);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1401,7 +1383,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = ctx->support->pd_setmode_required(pipe);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1425,7 +1407,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
        case OTM_HDMI_ATTR_ID_BG_COLOR:
                rc  = hdmi_video_set_pixel_color(&ctx->dev, auint);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1443,7 +1425,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc  = ctx->support->pd_setmode_required(pipe);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1463,7 +1445,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
                                rc = service_hdcp_set(ctx, false,
                                                        true);
                                if (rc != OTM_HDMI_SUCCESS) {
-                                       PD_LOG_ERROR("ERR: %s at %d code :%d\n",
+                                       LOG_ERROR("ERR: %s at %d code :%d\n",
                                                 __func__, __LINE__, rc);
                                        goto exit;
                                }
@@ -1483,7 +1465,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = hdmi_i2c_set_ddc_speed(&ctx->dev, abool);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1531,7 +1513,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
                        goto exit;
                rc = __switch_pipe(ctx);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1551,7 +1533,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = hdmi_video_set_video_indicator(&ctx->dev, abool);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1562,7 +1544,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = ctx->support->pd_setmode_required(pipe);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1573,7 +1555,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = hdmi_hdcp_set_enc(ctx, abool && HDCP_OFF != hdcp_status);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1584,7 +1566,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
                rc = ctx->support->pd_setmode_required(pipe);
                if (rc != OTM_HDMI_SUCCESS) {
-                       PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+                       LOG_ERROR("ERR: %s at %d code = %d\n",
                                        __func__, __LINE__, rc);
                        goto exit;
                }
@@ -1598,7 +1580,9 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
                        goto exit;
                }
                break;
-
+       case OTM_HDMI_ATTR_ID_DEBUG:
+               ATTRS[id].content._uint.value = auint;
+               break;
        default:
                break;
        }
@@ -1606,7 +1590,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
 #ifdef OTM_HDMI_FIXME
        rc = ctx->support->pd_attr_set(ATTRS, id, data, flags);
        if (rc != OTM_HDMI_SUCCESS) {
-               PD_LOG_ERROR("ERR: %s at %d code = %d\n",
+               LOG_ERROR("ERR: %s at %d code = %d\n",
                                __func__, __LINE__, rc);
                goto exit;
        }
@@ -1640,7 +1624,7 @@ otm_hdmi_ret_t otm_hdmi_set_attribute(void *context,
        }
 
 exit:
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return rc;
 }
 EXPORT_SYMBOL(otm_hdmi_set_attribute);
@@ -1660,34 +1644,30 @@ static otm_hdmi_ret_t otm_hdmi_attr_get_validate(otm_hdmi_attribute_id_t id)
 {
        otm_hdmi_ret_t rc = OTM_HDMI_SUCCESS;
        if (id < 0 || id >= OTM_HDMI_MAX_SUPPORTED_ATTRIBUTES) {
-               PD_LOG_ERROR("Invalid argument passed (id): %d\n", id);
+               LOG_ERROR("Invalid argument passed (id): %d\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
        /*
         * Based on attribute type perform appropriate check
        */
-       switch (ATTRS[id].flags) {
-       case OTM_HDMI_ATTR_FLAG_WRITE:
-               break;
-
-       case OTM_HDMI_ATTR_FLAG_SUPPORTED:
+       if (OTM_HDMI_ATTR_FLAG_WRITE & ATTRS[id].flags) {
+               return rc;
+       } else if (OTM_HDMI_ATTR_FLAG_SUPPORTED & ATTRS[id].flags) {
                /*
                 * Needs a Fix.
                 */
-               rc = OTM_HDMI_SUCCESS;
-               break;
-
-       case OTM_HDMI_ATTR_FLAG_INTERNAL:
+               return rc;
+       } else if (OTM_HDMI_ATTR_FLAG_INTERNAL & ATTRS[id].flags) {
                rc = OTM_HDMI_ERR_INTERNAL;
-               break;
-       default:
-               PD_LOG_ERROR("Invalid attribute accessed: (%d)\n", id);
+               return rc;
+       } else {
+               LOG_ERROR("Invalid attribute accessed: (%d)\n", id);
                rc = OTM_HDMI_ERR_FAILED;
-               break;
+               return rc;
        }
 exit:
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return rc;
 }
 
@@ -1703,20 +1683,20 @@ otm_hdmi_ret_t otm_hdmi_get_attribute(void *context,
                                        bool log)
 {
        otm_hdmi_ret_t rc = OTM_HDMI_SUCCESS;
-       PD_LOG_ENTRY((log) ? PD_LOG_LEVEL_HIGH : PD_LOG_LEVEL_VBLANK);
+       LOG_ENTRY((log) ? LOG_LEVEL_HIGH : LOG_LEVEL_VBLANK);
 
        rc = otm_hdmi_attr_get_validate(id);
        if (OTM_HDMI_SUCCESS != rc)
                goto exit;
        if (NULL == attribute || NULL == context) {
-               PD_LOG_ERROR("Invalid argument passed (attribute): %d\n", id);
+               LOG_ERROR("Invalid argument passed (attribute): %d\n", id);
                rc = OTM_HDMI_ERR_FAILED;
                goto exit;
        }
 
        *attribute = ATTRS[id];
 exit:
-       PD_LOG_EXIT((log) ? PD_LOG_LEVEL_HIGH : PD_LOG_LEVEL_VBLANK, rc);
+       LOG_EXIT((log) ? LOG_LEVEL_HIGH : LOG_LEVEL_VBLANK, rc);
        return rc;
 }
 EXPORT_SYMBOL(otm_hdmi_get_attribute);
@@ -1755,7 +1735,7 @@ static otm_hdmi_ret_t __pd_attr_declare(otm_hdmi_attribute_t *table,
        if ((name != NULL) && (strlen(name) < OTM_HDMI_MAX_STRING_LENGTH))
                strncpy(table[id].name, name, strlen(table[id].name));
        else if (strlen(table[id].name) == 0)
-               PD_LOG_ERROR("set default name\n");
+               LOG_ERROR("set default name\n");
                /* TODO: set default name */
 
        table[id].flags = flags;
@@ -1798,7 +1778,7 @@ otm_hdmi_ret_t otm_hdmi_declare_attributes(pd_attr_declare_t declare,
 
        otm_hdmi_attribute_t *table = otm_hdmi_attributes_table;
 
-       PD_LOG_ENTRY(PD_LOG_LEVEL_HIGH);
+       LOG_ENTRY(LOG_LEVEL_HIGH);
 
        /*
         * declare(table, OTM_HDMI_ATTR_ID_NAME,
@@ -1874,8 +1854,8 @@ otm_hdmi_ret_t otm_hdmi_declare_attributes(pd_attr_declare_t declare,
                OTM_HDMI_ATTR_ID_DEBUG,
                PD_ATTR_FLAGS_RWS,
                get_name,
-               PD_LOG_LEVEL_ERROR,
-               __PD_LOG_LEVEL_MIN, __PD_LOG_LEVEL_MAX);
+               LOG_LEVEL_ERROR,
+               __LOG_LEVEL_MIN, __LOG_LEVEL_MAX);
 
        PD_DECLARE_ATTRIBUTE_UINT(declare, table,
                OTM_HDMI_ATTR_ID_VERSION_MAJOR,
@@ -1980,7 +1960,7 @@ otm_hdmi_ret_t otm_hdmi_declare_attributes(pd_attr_declare_t declare,
                OTM_HDMI_ATTR_ID_HDCP_RI_RETRY,
                PD_ATTR_FLAGS_RWS, get_name, 40, 0, 50);
 
-       PD_LOG_EXIT(PD_LOG_LEVEL_HIGH, rc);
+       LOG_EXIT(LOG_LEVEL_HIGH, rc);
        return rc;
 }
 EXPORT_SYMBOL(otm_hdmi_declare_attributes);
@@ -2224,13 +2204,13 @@ void test_otm_hdmi_report_edid(void)
 {
        edid_info_t *edid = NULL;
        if (NULL == g_context) {
-               PD_LOG_PRINT(PD_LOG_LEVEL_HIGH,
+               LOG_PRINT(LOG_LEVEL_HIGH,
                             "Cant print EDID, Initialize otm_hdmi first!\n");
                return;
        }
        edid = &g_context->edid_int;
        if (NULL == edid) {
-               PD_LOG_PRINT(PD_LOG_LEVEL_HIGH,
+               LOG_PRINT(LOG_LEVEL_HIGH,
                             "EDID not initialized in driver.\n");
                return;
        }
@@ -2238,3 +2218,22 @@ void test_otm_hdmi_report_edid(void)
 }
 EXPORT_SYMBOL_GPL(test_otm_hdmi_report_edid);
 #endif
+
+#ifdef OTM_HDMI_UNIT_TEST
+
+/**
+ *     get_hdmi_context() - Getting hdmi_context
+ *
+ *     This routine gives a handle to hdmi_context
+ *     to be used with other function calls like
+ *     set_attribute which requires hdmi_context
+ *     as one of the params
+ *
+ *     Returns - hdmi_context
+ */
+void *otm_hdmi_get_context(void)
+{
+       return (void *)g_context;
+}
+EXPORT_SYMBOL_GPL(otm_hdmi_get_context);
+#endif
index 1fbab29..bf69507 100644 (file)
@@ -304,42 +304,42 @@ void otm_hdmi_restore_and_enable_display(void *context, bool connected);
 /*
  * Logging macros
  */
-#define ATTRIBUTES otm_hdmi_attributes_table
+
+/*
+ * Table of attributes
+ */
+extern otm_hdmi_attribute_t otm_hdmi_attributes_table[];
+
+#define ATTR otm_hdmi_attributes_table
 
 typedef enum {
-       PD_LOG_LEVEL_ERROR = 0, /* Error messages; Will always be printed */
-       __PD_LOG_LEVEL_MIN = PD_LOG_LEVEL_ERROR,
+       LOG_LEVEL_ERROR = 0,    /* Error messages; Will always be printed */
+       __LOG_LEVEL_MIN = LOG_LEVEL_ERROR,
        /* Add log levels below this line */
-       PD_LOG_LEVEL_HIGH = 1,  /* Printed if 'debug' is set to 1 or higher */
-       PD_LOG_LEVEL_LOW,       /* Printed if 'debug' is set to 2 or higher */
-       PD_LOG_LEVEL_VBLANK,    /* Printed if 'debug' at highest level */
+       LOG_LEVEL_HIGH = 1,     /* Printed if 'debug' is set to 1 or higher */
+       LOG_LEVEL_LOW,  /* Printed if 'debug' is set to 2 or higher */
+       LOG_LEVEL_VBLANK,       /* Printed if 'debug' at highest level */
+       LOG_LEVEL_DETAIL, /* Print detailed info */
        /* Add log levels above this line */
-       __PD_LOG_LEVEL_TEMP_UPPER__,    /* DO NOT USE */
-       __PD_LOG_LEVEL_MAX = __PD_LOG_LEVEL_TEMP_UPPER__ - 1,
-} pd_log_level_t;
+       __LOG_LEVEL_TEMP_UPPER__,       /* DO NOT USE */
+       __LOG_LEVEL_MAX = __LOG_LEVEL_TEMP_UPPER__ - 1,
+} log_level_t;
 
 /* Used to log entry in to a function */
-#define PD_LOG_ENTRY(log_level) \
-       if ((log_level) <= (int) PD_ATTR_UINT( \
-                                       ATTRIBUTES[OTM_HDMI_ATTR_ID_DEBUG])) \
+#define LOG_ENTRY(log_level) \
+       if ((log_level) <= (int) PD_ATTR_UINT(ATTR[OTM_HDMI_ATTR_ID_DEBUG])) \
                printk("OTM_HDMI: Entering %s\n", __func__)
 
 /* Used to log exit from a function */
-#define PD_LOG_EXIT(log_level, rc) \
-       if ((log_level) <= (int) PD_ATTR_UINT( \
-                                       ATTRIBUTES[OTM_HDMI_ATTR_ID_DEBUG])) \
+#define LOG_EXIT(log_level, rc) \
+       if ((log_level) <= (int) PD_ATTR_UINT(ATTR[OTM_HDMI_ATTR_ID_DEBUG])) \
                printk("OTM_HDMI: Exiting %s with %d\n", __func__, rc)
 
-#ifdef OTM_HDMI_FIXME
-#define PD_LOG_PRINT(log_level, args...) \
-       if ((log_level) <= (int) PD_ATTR_UINT( \
-                                       ATTRIBUTES[OTM_HDMI_ATTR_ID_DEBUG])) \
-               printk(args)
-#else
-#define PD_LOG_PRINT(log_level, args...) printk("OTM_HDMI: " args)
-#endif
+#define LOG_PRINT(log_level, args...) \
+       if ((log_level) <= (int) PD_ATTR_UINT(ATTR[OTM_HDMI_ATTR_ID_DEBUG])) \
+               printk("OTM_HDMI:" args)
 
-#define PD_LOG_ERROR(msg, args...) PD_LOG_PRINT(PD_LOG_LEVEL_ERROR, msg, ##args)
+#define LOG_ERROR(msg, args...) LOG_PRINT(LOG_LEVEL_ERROR, msg, ##args)
 
 /*
  * Bits in 'mode_info_flags' field
@@ -367,4 +367,12 @@ typedef enum {
 void test_otm_hdmi_report_edid(void);
 #endif
 
+/*
+ * Description: function to get hdmi_context
+ *             handle
+ *
+ * Returns:    hdmi_context
+ */
+extern void *otm_hdmi_get_context(void);
+
 #endif /* _OTM_HDMI_H */