Kiran Kandi | 94f25dc | 2012-01-31 00:18:33 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/bitops.h> |
| 16 | #include <linux/mutex.h> |
| 17 | |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 18 | /* #define DEBUG */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | #define DEV_DBG_PREFIX "EXT_COMMON: " |
| 20 | |
| 21 | #include "msm_fb.h" |
Manoj Rao | a2c2767 | 2011-08-30 17:19:39 -0700 | [diff] [blame] | 22 | #include "hdmi_msm.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | #include "external_common.h" |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 24 | #include "mhl_api.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | |
| 26 | struct external_common_state_type *external_common_state; |
| 27 | EXPORT_SYMBOL(external_common_state); |
| 28 | DEFINE_MUTEX(external_common_state_hpd_mutex); |
| 29 | EXPORT_SYMBOL(external_common_state_hpd_mutex); |
| 30 | |
Manoj Rao | a2c2767 | 2011-08-30 17:19:39 -0700 | [diff] [blame] | 31 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 32 | static int atoi(const char *name) |
| 33 | { |
| 34 | int val = 0; |
| 35 | |
| 36 | for (;; name++) { |
| 37 | switch (*name) { |
| 38 | case '0' ... '9': |
| 39 | val = 10*val+(*name-'0'); |
| 40 | break; |
| 41 | default: |
| 42 | return val; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 47 | #ifdef DEBUG_EDID |
| 48 | /* |
| 49 | * Block 0 - 1920x1080p, 1360x768p |
| 50 | * Block 1 - 1280x720p, 1920x540i, 720x480p |
| 51 | */ |
| 52 | const char edid_blk0[0x100] = { |
| 53 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x4C, 0x2D, 0x03, 0x05, 0x00, |
| 54 | 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78, 0x0A, 0xEE, |
| 55 | 0x91, 0xA3, 0x54, 0x4C, 0x99, 0x26, 0x0F, 0x50, 0x54, 0xBD, 0xEF, 0x80, 0x71, |
| 56 | 0x4F, 0x81, 0x00, 0x81, 0x40, 0x81, 0x80, 0x95, 0x00, 0x95, 0x0F, 0xB3, 0x00, |
| 57 | 0xA9, 0x40, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C, 0x45, |
| 58 | 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x66, 0x21, 0x50, 0xB0, 0x51, 0x00, |
| 59 | 0x1B, 0x30, 0x40, 0x70, 0x36, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x00, |
| 60 | 0x00, 0x00, 0xFD, 0x00, 0x18, 0x4B, 0x1A, 0x51, 0x17, 0x00, 0x0A, 0x20, 0x20, |
| 61 | 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x53, 0x41, 0x4D, 0x53, |
| 62 | 0x55, 0x4E, 0x47, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x8F}; |
| 63 | |
| 64 | const char edid_blk1[0x100] = { |
| 65 | 0x02, 0x03, 0x1E, 0xF1, 0x46, 0x90, 0x04, 0x05, 0x03, 0x20, 0x22, 0x23, 0x09, |
| 66 | 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0xE2, 0x00, 0x0F, 0x67, 0x03, 0x0C, 0x00, |
| 67 | 0x10, 0x00, 0xB8, 0x2D, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20, 0x6E, |
| 68 | 0x28, 0x55, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x80, 0x18, |
| 69 | 0x71, 0x1C, 0x16, 0x20, 0x58, 0x2C, 0x25, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, |
| 70 | 0x9E, 0x8C, 0x0A, 0xD0, 0x8A, 0x20, 0xE0, 0x2D, 0x10, 0x10, 0x3E, 0x96, 0x00, |
| 71 | 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 72 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 74 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF}; |
| 75 | #endif /* DEBUG_EDID */ |
| 76 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 77 | const char *video_format_2string(uint32 format) |
| 78 | { |
| 79 | switch (format) { |
| 80 | default: |
| 81 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 82 | case HDMI_VFRMT_640x480p60_4_3: return " 640x 480 p60 4/3"; |
| 83 | case HDMI_VFRMT_720x480p60_4_3: return " 720x 480 p60 4/3"; |
| 84 | case HDMI_VFRMT_720x480p60_16_9: return " 720x 480 p60 16/9"; |
| 85 | case HDMI_VFRMT_1280x720p60_16_9: return "1280x 720 p60 16/9"; |
| 86 | case HDMI_VFRMT_1920x1080i60_16_9: return "1920x1080 i60 16/9"; |
| 87 | case HDMI_VFRMT_1440x480i60_4_3: return "1440x 480 i60 4/3"; |
| 88 | case HDMI_VFRMT_1440x480i60_16_9: return "1440x 480 i60 16/9"; |
| 89 | case HDMI_VFRMT_1440x240p60_4_3: return "1440x 240 p60 4/3"; |
| 90 | case HDMI_VFRMT_1440x240p60_16_9: return "1440x 240 p60 16/9"; |
| 91 | case HDMI_VFRMT_2880x480i60_4_3: return "2880x 480 i60 4/3"; |
| 92 | case HDMI_VFRMT_2880x480i60_16_9: return "2880x 480 i60 16/9"; |
| 93 | case HDMI_VFRMT_2880x240p60_4_3: return "2880x 240 p60 4/3"; |
| 94 | case HDMI_VFRMT_2880x240p60_16_9: return "2880x 240 p60 16/9"; |
| 95 | case HDMI_VFRMT_1440x480p60_4_3: return "1440x 480 p60 4/3"; |
| 96 | case HDMI_VFRMT_1440x480p60_16_9: return "1440x 480 p60 16/9"; |
| 97 | case HDMI_VFRMT_1920x1080p60_16_9: return "1920x1080 p60 16/9"; |
| 98 | case HDMI_VFRMT_720x576p50_4_3: return " 720x 576 p50 4/3"; |
| 99 | case HDMI_VFRMT_720x576p50_16_9: return " 720x 576 p50 16/9"; |
| 100 | case HDMI_VFRMT_1280x720p50_16_9: return "1280x 720 p50 16/9"; |
| 101 | case HDMI_VFRMT_1920x1080i50_16_9: return "1920x1080 i50 16/9"; |
| 102 | case HDMI_VFRMT_1440x576i50_4_3: return "1440x 576 i50 4/3"; |
| 103 | case HDMI_VFRMT_1440x576i50_16_9: return "1440x 576 i50 16/9"; |
| 104 | case HDMI_VFRMT_1440x288p50_4_3: return "1440x 288 p50 4/3"; |
| 105 | case HDMI_VFRMT_1440x288p50_16_9: return "1440x 288 p50 16/9"; |
| 106 | case HDMI_VFRMT_2880x576i50_4_3: return "2880x 576 i50 4/3"; |
| 107 | case HDMI_VFRMT_2880x576i50_16_9: return "2880x 576 i50 16/9"; |
| 108 | case HDMI_VFRMT_2880x288p50_4_3: return "2880x 288 p50 4/3"; |
| 109 | case HDMI_VFRMT_2880x288p50_16_9: return "2880x 288 p50 16/9"; |
| 110 | case HDMI_VFRMT_1440x576p50_4_3: return "1440x 576 p50 4/3"; |
| 111 | case HDMI_VFRMT_1440x576p50_16_9: return "1440x 576 p50 16/9"; |
| 112 | case HDMI_VFRMT_1920x1080p50_16_9: return "1920x1080 p50 16/9"; |
| 113 | case HDMI_VFRMT_1920x1080p24_16_9: return "1920x1080 p24 16/9"; |
| 114 | case HDMI_VFRMT_1920x1080p25_16_9: return "1920x1080 p25 16/9"; |
| 115 | case HDMI_VFRMT_1920x1080p30_16_9: return "1920x1080 p30 16/9"; |
| 116 | case HDMI_VFRMT_2880x480p60_4_3: return "2880x 480 p60 4/3"; |
| 117 | case HDMI_VFRMT_2880x480p60_16_9: return "2880x 480 p60 16/9"; |
| 118 | case HDMI_VFRMT_2880x576p50_4_3: return "2880x 576 p50 4/3"; |
| 119 | case HDMI_VFRMT_2880x576p50_16_9: return "2880x 576 p50 16/9"; |
| 120 | case HDMI_VFRMT_1920x1250i50_16_9: return "1920x1250 i50 16/9"; |
| 121 | case HDMI_VFRMT_1920x1080i100_16_9:return "1920x1080 i100 16/9"; |
| 122 | case HDMI_VFRMT_1280x720p100_16_9: return "1280x 720 p100 16/9"; |
| 123 | case HDMI_VFRMT_720x576p100_4_3: return " 720x 576 p100 4/3"; |
| 124 | case HDMI_VFRMT_720x576p100_16_9: return " 720x 576 p100 16/9"; |
| 125 | case HDMI_VFRMT_1440x576i100_4_3: return "1440x 576 i100 4/3"; |
| 126 | case HDMI_VFRMT_1440x576i100_16_9: return "1440x 576 i100 16/9"; |
| 127 | case HDMI_VFRMT_1920x1080i120_16_9:return "1920x1080 i120 16/9"; |
| 128 | case HDMI_VFRMT_1280x720p120_16_9: return "1280x 720 p120 16/9"; |
| 129 | case HDMI_VFRMT_720x480p120_4_3: return " 720x 480 p120 4/3"; |
| 130 | case HDMI_VFRMT_720x480p120_16_9: return " 720x 480 p120 16/9"; |
| 131 | case HDMI_VFRMT_1440x480i120_4_3: return "1440x 480 i120 4/3"; |
| 132 | case HDMI_VFRMT_1440x480i120_16_9: return "1440x 480 i120 16/9"; |
| 133 | case HDMI_VFRMT_720x576p200_4_3: return " 720x 576 p200 4/3"; |
| 134 | case HDMI_VFRMT_720x576p200_16_9: return " 720x 576 p200 16/9"; |
| 135 | case HDMI_VFRMT_1440x576i200_4_3: return "1440x 576 i200 4/3"; |
| 136 | case HDMI_VFRMT_1440x576i200_16_9: return "1440x 576 i200 16/9"; |
| 137 | case HDMI_VFRMT_720x480p240_4_3: return " 720x 480 p240 4/3"; |
| 138 | case HDMI_VFRMT_720x480p240_16_9: return " 720x 480 p240 16/9"; |
| 139 | case HDMI_VFRMT_1440x480i240_4_3: return "1440x 480 i240 4/3"; |
| 140 | case HDMI_VFRMT_1440x480i240_16_9: return "1440x 480 i240 16/9"; |
| 141 | #elif defined(CONFIG_FB_MSM_TVOUT) |
| 142 | case TVOUT_VFRMT_NTSC_M_720x480i: return "NTSC_M_720x480i"; |
| 143 | case TVOUT_VFRMT_NTSC_J_720x480i: return "NTSC_J_720x480i"; |
| 144 | case TVOUT_VFRMT_PAL_BDGHIN_720x576i: return "PAL_BDGHIN_720x576i"; |
| 145 | case TVOUT_VFRMT_PAL_M_720x480i: return "PAL_M_720x480i"; |
| 146 | case TVOUT_VFRMT_PAL_N_720x480i: return "PAL_N_720x480i"; |
| 147 | #endif |
| 148 | |
| 149 | } |
| 150 | } |
| 151 | EXPORT_SYMBOL(video_format_2string); |
| 152 | |
| 153 | static ssize_t external_common_rda_video_mode_str(struct device *dev, |
| 154 | struct device_attribute *attr, char *buf) |
| 155 | { |
| 156 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n", |
| 157 | video_format_2string(external_common_state->video_resolution)); |
| 158 | DEV_DBG("%s: '%s'\n", __func__, |
| 159 | video_format_2string(external_common_state->video_resolution)); |
| 160 | return ret; |
| 161 | } |
| 162 | |
| 163 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 164 | struct hdmi_disp_mode_timing_type |
| 165 | hdmi_common_supported_video_mode_lut[HDMI_VFRMT_MAX] = { |
| 166 | HDMI_SETTINGS_640x480p60_4_3, |
| 167 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_4_3), |
| 168 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_16_9), |
| 169 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p60_16_9), |
| 170 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i60_16_9), |
| 171 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_4_3), |
| 172 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_16_9), |
| 173 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_4_3), |
| 174 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_16_9), |
| 175 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_4_3), |
| 176 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_16_9), |
| 177 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_4_3), |
| 178 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_16_9), |
| 179 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_4_3), |
| 180 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_16_9), |
| 181 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p60_16_9), |
| 182 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_4_3), |
| 183 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_16_9), |
| 184 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p50_16_9), |
| 185 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i50_16_9), |
| 186 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_4_3), |
| 187 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_16_9), |
| 188 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_4_3), |
| 189 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_16_9), |
| 190 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_4_3), |
| 191 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_16_9), |
| 192 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_4_3), |
| 193 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_16_9), |
| 194 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_4_3), |
| 195 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_16_9), |
| 196 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p50_16_9), |
| 197 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p24_16_9), |
| 198 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p25_16_9), |
| 199 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p30_16_9), |
| 200 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_4_3), |
| 201 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_16_9), |
| 202 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_4_3), |
| 203 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_16_9), |
| 204 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1250i50_16_9), |
| 205 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i100_16_9), |
| 206 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p100_16_9), |
| 207 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_4_3), |
| 208 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_16_9), |
| 209 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_4_3), |
| 210 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_16_9), |
| 211 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i120_16_9), |
| 212 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p120_16_9), |
| 213 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_4_3), |
| 214 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_16_9), |
| 215 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_4_3), |
| 216 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_16_9), |
| 217 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_4_3), |
| 218 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_16_9), |
| 219 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_4_3), |
| 220 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_16_9), |
| 221 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_4_3), |
| 222 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_16_9), |
| 223 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_4_3), |
| 224 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_16_9), |
| 225 | }; |
| 226 | EXPORT_SYMBOL(hdmi_common_supported_video_mode_lut); |
| 227 | |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 228 | struct hdmi_disp_mode_timing_type |
| 229 | hdmi_mhl_supported_video_mode_lut[HDMI_VFRMT_MAX] = { |
| 230 | HDMI_SETTINGS_640x480p60_4_3, |
| 231 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_4_3), |
| 232 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_16_9), |
| 233 | HDMI_SETTINGS_1280x720p60_16_9, |
| 234 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i60_16_9), |
| 235 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_4_3), |
| 236 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_16_9), |
| 237 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_4_3), |
| 238 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_16_9), |
| 239 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_4_3), |
| 240 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_16_9), |
| 241 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_4_3), |
| 242 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_16_9), |
| 243 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_4_3), |
| 244 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_16_9), |
| 245 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p60_16_9), |
| 246 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_4_3), |
| 247 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_16_9), |
| 248 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p50_16_9), |
| 249 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i50_16_9), |
| 250 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_4_3), |
| 251 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_16_9), |
| 252 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_4_3), |
| 253 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_16_9), |
| 254 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_4_3), |
| 255 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_16_9), |
| 256 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_4_3), |
| 257 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_16_9), |
| 258 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_4_3), |
| 259 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_16_9), |
| 260 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p50_16_9), |
| 261 | HDMI_SETTINGS_1920x1080p24_16_9, |
| 262 | HDMI_SETTINGS_1920x1080p25_16_9, |
| 263 | HDMI_SETTINGS_1920x1080p30_16_9, |
| 264 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_4_3), |
| 265 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_16_9), |
| 266 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_4_3), |
| 267 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_16_9), |
| 268 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1250i50_16_9), |
| 269 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i100_16_9), |
| 270 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p100_16_9), |
| 271 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_4_3), |
| 272 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_16_9), |
| 273 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_4_3), |
| 274 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_16_9), |
| 275 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i120_16_9), |
| 276 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p120_16_9), |
| 277 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_4_3), |
| 278 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_16_9), |
| 279 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_4_3), |
| 280 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_16_9), |
| 281 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_4_3), |
| 282 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_16_9), |
| 283 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_4_3), |
| 284 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_16_9), |
| 285 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_4_3), |
| 286 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_16_9), |
| 287 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_4_3), |
| 288 | VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_16_9), |
| 289 | }; |
| 290 | EXPORT_SYMBOL(hdmi_mhl_supported_video_mode_lut); |
| 291 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 292 | static ssize_t hdmi_common_rda_edid_modes(struct device *dev, |
| 293 | struct device_attribute *attr, char *buf) |
| 294 | { |
| 295 | ssize_t ret = 0; |
| 296 | int i; |
| 297 | |
| 298 | buf[0] = 0; |
| 299 | if (external_common_state->disp_mode_list.num_of_elements) { |
| 300 | uint32 *video_mode = external_common_state->disp_mode_list |
| 301 | .disp_mode_list; |
| 302 | for (i = 0; i < external_common_state->disp_mode_list |
| 303 | .num_of_elements; ++i) { |
| 304 | if (ret > 0) |
| 305 | ret += snprintf(buf+ret, PAGE_SIZE-ret, ",%d", |
| 306 | *video_mode++ + 1); |
| 307 | else |
| 308 | ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d", |
| 309 | *video_mode++ + 1); |
| 310 | } |
| 311 | } else |
| 312 | ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d", |
| 313 | external_common_state->video_resolution+1); |
| 314 | |
| 315 | DEV_DBG("%s: '%s'\n", __func__, buf); |
| 316 | ret += snprintf(buf+ret, PAGE_SIZE-ret, "\n"); |
| 317 | return ret; |
| 318 | } |
| 319 | |
| 320 | static ssize_t hdmi_common_rda_hdcp(struct device *dev, |
| 321 | struct device_attribute *attr, char *buf) |
| 322 | { |
| 323 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 324 | external_common_state->hdcp_active); |
| 325 | DEV_DBG("%s: '%d'\n", __func__, |
| 326 | external_common_state->hdcp_active); |
| 327 | return ret; |
| 328 | } |
| 329 | |
| 330 | static ssize_t hdmi_common_rda_hpd(struct device *dev, |
| 331 | struct device_attribute *attr, char *buf) |
| 332 | { |
| 333 | ssize_t ret; |
| 334 | if (external_common_state->hpd_feature) { |
| 335 | ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 336 | external_common_state->hpd_feature_on); |
| 337 | DEV_DBG("%s: '%d'\n", __func__, |
| 338 | external_common_state->hpd_feature_on); |
| 339 | } else { |
| 340 | ret = snprintf(buf, PAGE_SIZE, "-1\n"); |
| 341 | DEV_DBG("%s: 'not supported'\n", __func__); |
| 342 | } |
| 343 | return ret; |
| 344 | } |
| 345 | |
| 346 | static ssize_t hdmi_common_wta_hpd(struct device *dev, |
| 347 | struct device_attribute *attr, const char *buf, size_t count) |
| 348 | { |
| 349 | ssize_t ret = strnlen(buf, PAGE_SIZE); |
Ravishangar Kalyanam | 898f4bd | 2011-07-15 18:25:47 -0700 | [diff] [blame] | 350 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 351 | int hpd = 1; |
| 352 | #else |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 353 | int hpd = atoi(buf); |
Ravishangar Kalyanam | 898f4bd | 2011-07-15 18:25:47 -0700 | [diff] [blame] | 354 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 355 | if (external_common_state->hpd_feature) { |
| 356 | if (hpd == 0 && external_common_state->hpd_feature_on) { |
| 357 | external_common_state->hpd_feature(0); |
| 358 | external_common_state->hpd_feature_on = 0; |
| 359 | DEV_DBG("%s: '%d'\n", __func__, |
| 360 | external_common_state->hpd_feature_on); |
| 361 | } else if (hpd == 1 && !external_common_state->hpd_feature_on) { |
| 362 | external_common_state->hpd_feature(1); |
| 363 | external_common_state->hpd_feature_on = 1; |
| 364 | DEV_DBG("%s: '%d'\n", __func__, |
| 365 | external_common_state->hpd_feature_on); |
| 366 | } else { |
| 367 | DEV_DBG("%s: '%d' (unchanged)\n", __func__, |
| 368 | external_common_state->hpd_feature_on); |
| 369 | } |
| 370 | } else { |
| 371 | DEV_DBG("%s: 'not supported'\n", __func__); |
| 372 | } |
| 373 | |
| 374 | return ret; |
| 375 | } |
| 376 | |
Manoj Rao | a2c2767 | 2011-08-30 17:19:39 -0700 | [diff] [blame] | 377 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT |
| 378 | /* |
| 379 | * This interface for CEC feature is defined to suit |
| 380 | * the current requirements. However, the actual functionality is |
| 381 | * added to accommodate different interfaces |
| 382 | */ |
| 383 | static ssize_t hdmi_msm_rda_cec(struct device *dev, |
| 384 | struct device_attribute *attr, char *buf) |
| 385 | { |
| 386 | /* 0x028C CEC_CTRL */ |
| 387 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 388 | (HDMI_INP(0x028C) & BIT(0))); |
| 389 | return ret; |
| 390 | } |
| 391 | |
| 392 | static ssize_t hdmi_msm_wta_cec(struct device *dev, |
| 393 | struct device_attribute *attr, const char *buf, size_t count) |
| 394 | { |
| 395 | ssize_t ret = strnlen(buf, PAGE_SIZE); |
| 396 | int cec = atoi(buf); |
| 397 | |
| 398 | if (cec != 0) { |
| 399 | mutex_lock(&hdmi_msm_state_mutex); |
| 400 | hdmi_msm_state->cec_enabled = true; |
| 401 | hdmi_msm_state->cec_logical_addr = 4; |
| 402 | mutex_unlock(&hdmi_msm_state_mutex); |
| 403 | hdmi_msm_cec_init(); |
| 404 | hdmi_msm_cec_write_logical_addr( |
| 405 | hdmi_msm_state->cec_logical_addr); |
| 406 | DEV_DBG("CEC enabled\n"); |
| 407 | } else { |
| 408 | mutex_lock(&hdmi_msm_state_mutex); |
| 409 | hdmi_msm_state->cec_enabled = false; |
| 410 | hdmi_msm_state->cec_logical_addr = 15; |
| 411 | mutex_unlock(&hdmi_msm_state_mutex); |
| 412 | hdmi_msm_cec_write_logical_addr( |
| 413 | hdmi_msm_state->cec_logical_addr); |
| 414 | /* 0x028C CEC_CTRL */ |
| 415 | HDMI_OUTP(0x028C, 0); |
| 416 | DEV_DBG("CEC disabled\n"); |
| 417 | } |
| 418 | return ret; |
| 419 | } |
| 420 | |
| 421 | static ssize_t hdmi_msm_rda_cec_logical_addr(struct device *dev, |
| 422 | struct device_attribute *attr, char *buf) |
| 423 | { |
| 424 | ssize_t ret; |
| 425 | |
| 426 | mutex_lock(&hdmi_msm_state_mutex); |
| 427 | ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 428 | hdmi_msm_state->cec_logical_addr); |
| 429 | mutex_unlock(&hdmi_msm_state_mutex); |
| 430 | return ret; |
| 431 | } |
| 432 | |
| 433 | static ssize_t hdmi_msm_wta_cec_logical_addr(struct device *dev, |
| 434 | struct device_attribute *attr, const char *buf, size_t count) |
| 435 | { |
| 436 | |
Manoj Rao | 0f0ab64 | 2011-11-01 12:28:24 -0700 | [diff] [blame] | 437 | #ifdef DRVR_ONLY_CECT_NO_DAEMON |
Manoj Rao | a2c2767 | 2011-08-30 17:19:39 -0700 | [diff] [blame] | 438 | /* |
| 439 | * Only for testing |
| 440 | */ |
| 441 | hdmi_msm_cec_one_touch_play(); |
| 442 | return 0; |
| 443 | #else |
| 444 | ssize_t ret = strnlen(buf, PAGE_SIZE); |
| 445 | int logical_addr = atoi(buf); |
| 446 | |
| 447 | if (logical_addr < 0 || logical_addr > 15) |
| 448 | return -EINVAL; |
| 449 | |
| 450 | mutex_lock(&hdmi_msm_state_mutex); |
| 451 | hdmi_msm_state->cec_logical_addr = logical_addr; |
| 452 | mutex_unlock(&hdmi_msm_state_mutex); |
| 453 | |
| 454 | hdmi_msm_cec_write_logical_addr(logical_addr); |
| 455 | |
| 456 | return ret; |
| 457 | #endif |
| 458 | } |
| 459 | |
| 460 | static ssize_t hdmi_msm_rda_cec_frame(struct device *dev, |
| 461 | struct device_attribute *attr, char *buf) |
| 462 | { |
| 463 | mutex_lock(&hdmi_msm_state_mutex); |
| 464 | if (hdmi_msm_state->cec_queue_rd == hdmi_msm_state->cec_queue_wr |
| 465 | && !hdmi_msm_state->cec_queue_full) { |
| 466 | mutex_unlock(&hdmi_msm_state_mutex); |
| 467 | DEV_ERR("CEC message queue is empty\n"); |
| 468 | return -EBUSY; |
| 469 | } |
| 470 | memcpy(buf, hdmi_msm_state->cec_queue_rd++, |
| 471 | sizeof(struct hdmi_msm_cec_msg)); |
| 472 | hdmi_msm_state->cec_queue_full = false; |
| 473 | if (hdmi_msm_state->cec_queue_rd == CEC_QUEUE_END) |
| 474 | hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start; |
| 475 | mutex_unlock(&hdmi_msm_state_mutex); |
| 476 | |
| 477 | return sizeof(struct hdmi_msm_cec_msg); |
| 478 | } |
| 479 | |
| 480 | static ssize_t hdmi_msm_wta_cec_frame(struct device *dev, |
| 481 | struct device_attribute *attr, const char *buf, size_t count) |
| 482 | { |
| 483 | int retry = ((struct hdmi_msm_cec_msg *) buf)->retransmit; |
| 484 | |
| 485 | if (retry > 15) |
| 486 | retry = 15; |
| 487 | while (1) { |
| 488 | hdmi_msm_cec_msg_send((struct hdmi_msm_cec_msg *) buf); |
| 489 | if (hdmi_msm_state->cec_frame_wr_status |
| 490 | & CEC_STATUS_WR_ERROR && retry--) |
| 491 | msleep(360); |
| 492 | else |
| 493 | break; |
| 494 | } |
| 495 | |
| 496 | if (hdmi_msm_state->cec_frame_wr_status & CEC_STATUS_WR_DONE) |
| 497 | return sizeof(struct hdmi_msm_cec_msg); |
| 498 | else |
| 499 | return -EINVAL; |
| 500 | } |
| 501 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ |
| 502 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 503 | static ssize_t hdmi_common_rda_3d_present(struct device *dev, |
| 504 | struct device_attribute *attr, char *buf) |
| 505 | { |
| 506 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 507 | external_common_state->present_3d); |
| 508 | DEV_DBG("%s: '%d'\n", __func__, |
| 509 | external_common_state->present_3d); |
| 510 | return ret; |
| 511 | } |
| 512 | |
| 513 | static ssize_t hdmi_common_rda_hdcp_present(struct device *dev, |
| 514 | struct device_attribute *attr, char *buf) |
| 515 | { |
| 516 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 517 | external_common_state->present_hdcp); |
| 518 | DEV_DBG("%s: '%d'\n", __func__, |
| 519 | external_common_state->present_hdcp); |
| 520 | return ret; |
| 521 | } |
| 522 | #endif |
| 523 | |
| 524 | #ifdef CONFIG_FB_MSM_HDMI_3D |
| 525 | static ssize_t hdmi_3d_rda_format_3d(struct device *dev, |
| 526 | struct device_attribute *attr, char *buf) |
| 527 | { |
| 528 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 529 | external_common_state->format_3d); |
| 530 | DEV_DBG("%s: '%d'\n", __func__, |
| 531 | external_common_state->format_3d); |
| 532 | return ret; |
| 533 | } |
| 534 | |
| 535 | static ssize_t hdmi_3d_wta_format_3d(struct device *dev, |
| 536 | struct device_attribute *attr, const char *buf, size_t count) |
| 537 | { |
| 538 | ssize_t ret = strnlen(buf, PAGE_SIZE); |
| 539 | int format_3d = atoi(buf); |
| 540 | |
| 541 | if (format_3d >= 0 && format_3d <= 2) { |
| 542 | if (format_3d != external_common_state->format_3d) { |
| 543 | external_common_state->format_3d = format_3d; |
| 544 | if (external_common_state->switch_3d) |
| 545 | external_common_state->switch_3d(format_3d); |
| 546 | DEV_DBG("%s: '%d'\n", __func__, |
| 547 | external_common_state->format_3d); |
| 548 | } else { |
| 549 | DEV_DBG("%s: '%d' (unchanged)\n", __func__, |
| 550 | external_common_state->format_3d); |
| 551 | } |
| 552 | } else { |
| 553 | DEV_DBG("%s: '%d' (unknown)\n", __func__, format_3d); |
| 554 | } |
| 555 | |
| 556 | return ret; |
| 557 | } |
| 558 | #endif |
| 559 | |
Manoj Rao | a2c2767 | 2011-08-30 17:19:39 -0700 | [diff] [blame] | 560 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT |
| 561 | static DEVICE_ATTR(cec, S_IRUGO | S_IWUSR, |
| 562 | hdmi_msm_rda_cec, |
| 563 | hdmi_msm_wta_cec); |
| 564 | |
| 565 | static DEVICE_ATTR(cec_logical_addr, S_IRUGO | S_IWUSR, |
| 566 | hdmi_msm_rda_cec_logical_addr, |
| 567 | hdmi_msm_wta_cec_logical_addr); |
| 568 | |
| 569 | static DEVICE_ATTR(cec_rd_frame, S_IRUGO, |
| 570 | hdmi_msm_rda_cec_frame, NULL); |
| 571 | |
| 572 | static DEVICE_ATTR(cec_wr_frame, S_IWUSR, |
| 573 | NULL, hdmi_msm_wta_cec_frame); |
| 574 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ |
| 575 | |
| 576 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 577 | static ssize_t external_common_rda_video_mode(struct device *dev, |
| 578 | struct device_attribute *attr, char *buf) |
| 579 | { |
| 580 | ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 581 | external_common_state->video_resolution+1); |
| 582 | DEV_DBG("%s: '%d'\n", __func__, |
| 583 | external_common_state->video_resolution+1); |
| 584 | return ret; |
| 585 | } |
| 586 | |
| 587 | static ssize_t external_common_wta_video_mode(struct device *dev, |
| 588 | struct device_attribute *attr, const char *buf, size_t count) |
| 589 | { |
| 590 | ssize_t ret = strnlen(buf, PAGE_SIZE); |
| 591 | uint32 video_mode; |
| 592 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 593 | const struct hdmi_disp_mode_timing_type *disp_mode; |
| 594 | #endif |
| 595 | mutex_lock(&external_common_state_hpd_mutex); |
| 596 | if (!external_common_state->hpd_state) { |
| 597 | mutex_unlock(&external_common_state_hpd_mutex); |
| 598 | DEV_INFO("%s: FAILED: display off or cable disconnected\n", |
| 599 | __func__); |
| 600 | return ret; |
| 601 | } |
| 602 | mutex_unlock(&external_common_state_hpd_mutex); |
| 603 | |
| 604 | video_mode = atoi(buf)-1; |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 605 | DEV_INFO("%s: video_mode is %d\n", __func__, video_mode); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 606 | kobject_uevent(external_common_state->uevent_kobj, KOBJ_OFFLINE); |
| 607 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 608 | disp_mode = hdmi_common_get_supported_mode(video_mode); |
| 609 | if (!disp_mode) { |
| 610 | DEV_INFO("%s: FAILED: mode not supported (%d)\n", |
| 611 | __func__, video_mode); |
| 612 | return ret; |
| 613 | } |
| 614 | external_common_state->disp_mode_list.num_of_elements = 1; |
| 615 | external_common_state->disp_mode_list.disp_mode_list[0] = video_mode; |
| 616 | #elif defined(CONFIG_FB_MSM_TVOUT) |
| 617 | external_common_state->video_resolution = video_mode; |
| 618 | #endif |
| 619 | DEV_DBG("%s: 'mode=%d %s' successful (sending OFF/ONLINE)\n", __func__, |
| 620 | video_mode, video_format_2string(video_mode)); |
| 621 | kobject_uevent(external_common_state->uevent_kobj, KOBJ_ONLINE); |
| 622 | return ret; |
| 623 | } |
| 624 | |
| 625 | static ssize_t external_common_rda_connected(struct device *dev, |
| 626 | struct device_attribute *attr, char *buf) |
| 627 | { |
| 628 | ssize_t ret; |
| 629 | mutex_lock(&external_common_state_hpd_mutex); |
| 630 | ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 631 | external_common_state->hpd_state); |
| 632 | DEV_DBG("%s: '%d'\n", __func__, |
| 633 | external_common_state->hpd_state); |
| 634 | mutex_unlock(&external_common_state_hpd_mutex); |
| 635 | return ret; |
| 636 | } |
| 637 | |
Ajay Singh Parmar | db7007f | 2011-12-14 02:17:58 +0530 | [diff] [blame] | 638 | static ssize_t external_common_rda_hdmi_mode(struct device *dev, |
| 639 | struct device_attribute *attr, char *buf) |
| 640 | { |
| 641 | ssize_t ret; |
| 642 | |
| 643 | ret = snprintf(buf, PAGE_SIZE, "%d\n", |
| 644 | external_common_state->hdmi_sink); |
| 645 | |
| 646 | DEV_DBG("%s: '%d'\n", __func__, |
| 647 | external_common_state->hdmi_sink); |
| 648 | |
| 649 | return ret; |
| 650 | } |
| 651 | |
| 652 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 653 | static DEVICE_ATTR(video_mode, S_IRUGO | S_IWUGO, |
| 654 | external_common_rda_video_mode, external_common_wta_video_mode); |
| 655 | static DEVICE_ATTR(video_mode_str, S_IRUGO, external_common_rda_video_mode_str, |
| 656 | NULL); |
| 657 | static DEVICE_ATTR(connected, S_IRUGO, external_common_rda_connected, NULL); |
Ajay Singh Parmar | db7007f | 2011-12-14 02:17:58 +0530 | [diff] [blame] | 658 | static DEVICE_ATTR(hdmi_mode, S_IRUGO, external_common_rda_hdmi_mode, NULL); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 659 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 660 | static DEVICE_ATTR(edid_modes, S_IRUGO, hdmi_common_rda_edid_modes, NULL); |
| 661 | static DEVICE_ATTR(hpd, S_IRUGO | S_IWUGO, hdmi_common_rda_hpd, |
| 662 | hdmi_common_wta_hpd); |
| 663 | static DEVICE_ATTR(hdcp, S_IRUGO, hdmi_common_rda_hdcp, NULL); |
| 664 | static DEVICE_ATTR(3d_present, S_IRUGO, hdmi_common_rda_3d_present, NULL); |
| 665 | static DEVICE_ATTR(hdcp_present, S_IRUGO, hdmi_common_rda_hdcp_present, NULL); |
| 666 | #endif |
| 667 | #ifdef CONFIG_FB_MSM_HDMI_3D |
| 668 | static DEVICE_ATTR(format_3d, S_IRUGO | S_IWUGO, hdmi_3d_rda_format_3d, |
| 669 | hdmi_3d_wta_format_3d); |
| 670 | #endif |
| 671 | |
| 672 | static struct attribute *external_common_fs_attrs[] = { |
| 673 | &dev_attr_video_mode.attr, |
| 674 | &dev_attr_video_mode_str.attr, |
| 675 | &dev_attr_connected.attr, |
Ajay Singh Parmar | db7007f | 2011-12-14 02:17:58 +0530 | [diff] [blame] | 676 | &dev_attr_hdmi_mode.attr, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 677 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 678 | &dev_attr_edid_modes.attr, |
| 679 | &dev_attr_hdcp.attr, |
| 680 | &dev_attr_hpd.attr, |
| 681 | &dev_attr_3d_present.attr, |
| 682 | &dev_attr_hdcp_present.attr, |
| 683 | #endif |
| 684 | #ifdef CONFIG_FB_MSM_HDMI_3D |
| 685 | &dev_attr_format_3d.attr, |
| 686 | #endif |
Manoj Rao | a2c2767 | 2011-08-30 17:19:39 -0700 | [diff] [blame] | 687 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT |
| 688 | &dev_attr_cec.attr, |
| 689 | &dev_attr_cec_logical_addr.attr, |
| 690 | &dev_attr_cec_rd_frame.attr, |
| 691 | &dev_attr_cec_wr_frame.attr, |
| 692 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 693 | NULL, |
| 694 | }; |
| 695 | static struct attribute_group external_common_fs_attr_group = { |
| 696 | .attrs = external_common_fs_attrs, |
| 697 | }; |
| 698 | |
| 699 | /* create external interface kobject and initialize */ |
| 700 | int external_common_state_create(struct platform_device *pdev) |
| 701 | { |
| 702 | int rc; |
| 703 | struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); |
| 704 | if (!mfd) { |
| 705 | DEV_ERR("%s: mfd not found\n", __func__); |
| 706 | return -ENODEV; |
| 707 | } |
| 708 | if (!mfd->fbi) { |
| 709 | DEV_ERR("%s: mfd->fbi not found\n", __func__); |
| 710 | return -ENODEV; |
| 711 | } |
| 712 | if (!mfd->fbi->dev) { |
| 713 | DEV_ERR("%s: mfd->fbi->dev not found\n", __func__); |
| 714 | return -ENODEV; |
| 715 | } |
| 716 | rc = sysfs_create_group(&mfd->fbi->dev->kobj, |
| 717 | &external_common_fs_attr_group); |
| 718 | if (rc) { |
| 719 | DEV_ERR("%s: sysfs group creation failed, rc=%d\n", __func__, |
| 720 | rc); |
| 721 | return rc; |
| 722 | } |
| 723 | external_common_state->uevent_kobj = &mfd->fbi->dev->kobj; |
| 724 | DEV_ERR("%s: sysfs group %p\n", __func__, |
| 725 | external_common_state->uevent_kobj); |
| 726 | |
| 727 | kobject_uevent(external_common_state->uevent_kobj, KOBJ_ADD); |
| 728 | DEV_DBG("%s: kobject_uevent(KOBJ_ADD)\n", __func__); |
| 729 | return 0; |
| 730 | } |
| 731 | EXPORT_SYMBOL(external_common_state_create); |
| 732 | |
| 733 | void external_common_state_remove(void) |
| 734 | { |
| 735 | if (external_common_state->uevent_kobj) |
| 736 | sysfs_remove_group(external_common_state->uevent_kobj, |
| 737 | &external_common_fs_attr_group); |
| 738 | external_common_state->uevent_kobj = NULL; |
| 739 | } |
| 740 | EXPORT_SYMBOL(external_common_state_remove); |
| 741 | |
| 742 | #ifdef CONFIG_FB_MSM_HDMI_COMMON |
| 743 | /* The Logic ID for HDMI TX Core. Currently only support 1 HDMI TX Core. */ |
| 744 | struct hdmi_edid_video_mode_property_type { |
| 745 | uint32 video_code; |
| 746 | uint32 active_h; |
| 747 | uint32 active_v; |
| 748 | boolean interlaced; |
| 749 | uint32 total_h; |
| 750 | uint32 total_blank_h; |
| 751 | uint32 total_v; |
| 752 | uint32 total_blank_v; |
| 753 | /* Must divide by 1000 to get the frequency */ |
| 754 | uint32 freq_h; |
| 755 | /* Must divide by 1000 to get the frequency */ |
| 756 | uint32 freq_v; |
| 757 | /* Must divide by 1000 to get the frequency */ |
| 758 | uint32 pixel_freq; |
| 759 | /* Must divide by 1000 to get the frequency */ |
| 760 | uint32 refresh_rate; |
| 761 | boolean aspect_ratio_4_3; |
| 762 | }; |
| 763 | |
| 764 | /* LUT is sorted from lowest Active H to highest Active H - ease searching */ |
| 765 | static struct hdmi_edid_video_mode_property_type |
| 766 | hdmi_edid_disp_mode_lut[] = { |
| 767 | |
| 768 | /* All 640 H Active */ |
| 769 | {HDMI_VFRMT_640x480p60_4_3, 640, 480, FALSE, 800, 160, 525, 45, |
| 770 | 31465, 59940, 25175, 59940, TRUE}, |
| 771 | {HDMI_VFRMT_640x480p60_4_3, 640, 480, FALSE, 800, 160, 525, 45, |
| 772 | 31500, 60000, 25200, 60000, TRUE}, |
| 773 | |
| 774 | /* All 720 H Active */ |
| 775 | {HDMI_VFRMT_720x576p50_4_3, 720, 576, FALSE, 864, 144, 625, 49, |
| 776 | 31250, 50000, 27000, 50000, TRUE}, |
| 777 | {HDMI_VFRMT_720x480p60_4_3, 720, 480, FALSE, 858, 138, 525, 45, |
| 778 | 31465, 59940, 27000, 59940, TRUE}, |
| 779 | {HDMI_VFRMT_720x480p60_4_3, 720, 480, FALSE, 858, 138, 525, 45, |
| 780 | 31500, 60000, 27030, 60000, TRUE}, |
| 781 | {HDMI_VFRMT_720x576p100_4_3, 720, 576, FALSE, 864, 144, 625, 49, |
| 782 | 62500, 100000, 54000, 100000, TRUE}, |
| 783 | {HDMI_VFRMT_720x480p120_4_3, 720, 480, FALSE, 858, 138, 525, 45, |
| 784 | 62937, 119880, 54000, 119880, TRUE}, |
| 785 | {HDMI_VFRMT_720x480p120_4_3, 720, 480, FALSE, 858, 138, 525, 45, |
| 786 | 63000, 120000, 54054, 120000, TRUE}, |
| 787 | {HDMI_VFRMT_720x576p200_4_3, 720, 576, FALSE, 864, 144, 625, 49, |
| 788 | 125000, 200000, 108000, 200000, TRUE}, |
| 789 | {HDMI_VFRMT_720x480p240_4_3, 720, 480, FALSE, 858, 138, 525, 45, |
| 790 | 125874, 239760, 108000, 239000, TRUE}, |
| 791 | {HDMI_VFRMT_720x480p240_4_3, 720, 480, FALSE, 858, 138, 525, 45, |
| 792 | 126000, 240000, 108108, 240000, TRUE}, |
| 793 | |
| 794 | /* All 1280 H Active */ |
| 795 | {HDMI_VFRMT_1280x720p50_16_9, 1280, 720, FALSE, 1980, 700, 750, 30, |
| 796 | 37500, 50000, 74250, 50000, FALSE}, |
| 797 | {HDMI_VFRMT_1280x720p60_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, |
| 798 | 44955, 59940, 74176, 59940, FALSE}, |
| 799 | {HDMI_VFRMT_1280x720p60_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, |
| 800 | 45000, 60000, 74250, 60000, FALSE}, |
| 801 | {HDMI_VFRMT_1280x720p100_16_9, 1280, 720, FALSE, 1980, 700, 750, 30, |
| 802 | 75000, 100000, 148500, 100000, FALSE}, |
| 803 | {HDMI_VFRMT_1280x720p120_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, |
| 804 | 89909, 119880, 148352, 119880, FALSE}, |
| 805 | {HDMI_VFRMT_1280x720p120_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, |
| 806 | 90000, 120000, 148500, 120000, FALSE}, |
| 807 | |
| 808 | /* All 1440 H Active */ |
| 809 | {HDMI_VFRMT_1440x576i50_4_3, 1440, 576, TRUE, 1728, 288, 625, 24, |
| 810 | 15625, 50000, 27000, 50000, TRUE}, |
| 811 | {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 312, 24, |
| 812 | 15625, 50080, 27000, 50000, TRUE}, |
| 813 | {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 313, 25, |
| 814 | 15625, 49920, 27000, 50000, TRUE}, |
| 815 | {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 314, 26, |
| 816 | 15625, 49761, 27000, 50000, TRUE}, |
| 817 | {HDMI_VFRMT_1440x576p50_4_3, 1440, 576, FALSE, 1728, 288, 625, 49, |
| 818 | 31250, 50000, 54000, 50000, TRUE}, |
| 819 | {HDMI_VFRMT_1440x480i60_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, |
| 820 | 15734, 59940, 27000, 59940, TRUE}, |
| 821 | {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 262, 22, |
| 822 | 15734, 60054, 27000, 59940, TRUE}, |
| 823 | {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 263, 23, |
| 824 | 15734, 59826, 27000, 59940, TRUE}, |
| 825 | {HDMI_VFRMT_1440x480p60_4_3, 1440, 480, FALSE, 1716, 276, 525, 45, |
| 826 | 31469, 59940, 54000, 59940, TRUE}, |
| 827 | {HDMI_VFRMT_1440x480i60_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, |
| 828 | 15750, 60000, 27027, 60000, TRUE}, |
| 829 | {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 262, 22, |
| 830 | 15750, 60115, 27027, 60000, TRUE}, |
| 831 | {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 263, 23, |
| 832 | 15750, 59886, 27027, 60000, TRUE}, |
| 833 | {HDMI_VFRMT_1440x480p60_4_3, 1440, 480, FALSE, 1716, 276, 525, 45, |
| 834 | 31500, 60000, 54054, 60000, TRUE}, |
| 835 | {HDMI_VFRMT_1440x576i100_4_3, 1440, 576, TRUE, 1728, 288, 625, 24, |
| 836 | 31250, 100000, 54000, 100000, TRUE}, |
| 837 | {HDMI_VFRMT_1440x480i120_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, |
| 838 | 31469, 119880, 54000, 119880, TRUE}, |
| 839 | {HDMI_VFRMT_1440x480i120_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, |
| 840 | 31500, 120000, 54054, 120000, TRUE}, |
| 841 | {HDMI_VFRMT_1440x576i200_4_3, 1440, 576, TRUE, 1728, 288, 625, 24, |
| 842 | 62500, 200000, 108000, 200000, TRUE}, |
| 843 | {HDMI_VFRMT_1440x480i240_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, |
| 844 | 62937, 239760, 108000, 239000, TRUE}, |
| 845 | {HDMI_VFRMT_1440x480i240_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, |
| 846 | 63000, 240000, 108108, 240000, TRUE}, |
| 847 | |
| 848 | /* All 1920 H Active */ |
| 849 | {HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, FALSE, 2200, 280, 1125, |
| 850 | 45, 67433, 59940, 148352, 59940, FALSE}, |
| 851 | {HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, TRUE, 2200, 280, 1125, |
| 852 | 45, 67500, 60000, 148500, 60000, FALSE}, |
| 853 | {HDMI_VFRMT_1920x1080p50_16_9, 1920, 1080, FALSE, 2640, 720, 1125, |
| 854 | 45, 56250, 50000, 148500, 50000, FALSE}, |
| 855 | {HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, FALSE, 2750, 830, 1125, |
| 856 | 45, 26973, 23976, 74176, 24000, FALSE}, |
| 857 | {HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, FALSE, 2750, 830, 1125, |
| 858 | 45, 27000, 24000, 74250, 24000, FALSE}, |
| 859 | {HDMI_VFRMT_1920x1080p25_16_9, 1920, 1080, FALSE, 2640, 720, 1125, |
| 860 | 45, 28125, 25000, 74250, 25000, FALSE}, |
| 861 | {HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, FALSE, 2200, 280, 1125, |
| 862 | 45, 33716, 29970, 74176, 30000, FALSE}, |
| 863 | {HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, FALSE, 2200, 280, 1125, |
| 864 | 45, 33750, 30000, 74250, 30000, FALSE}, |
| 865 | {HDMI_VFRMT_1920x1080i50_16_9, 1920, 1080, TRUE, 2304, 384, 1250, |
| 866 | 85, 31250, 50000, 72000, 50000, FALSE}, |
| 867 | {HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, TRUE, 2200, 280, 1125, |
| 868 | 22, 33716, 59940, 74176, 59940, FALSE}, |
| 869 | {HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, TRUE, 2200, 280, 1125, |
| 870 | 22, 33750, 60000, 74250, 60000, FALSE}, |
| 871 | {HDMI_VFRMT_1920x1080i100_16_9, 1920, 1080, TRUE, 2640, 720, 1125, |
| 872 | 22, 56250, 100000, 148500, 100000, FALSE}, |
| 873 | {HDMI_VFRMT_1920x1080i120_16_9, 1920, 1080, TRUE, 2200, 280, 1125, |
| 874 | 22, 67432, 119880, 148352, 119980, FALSE}, |
| 875 | {HDMI_VFRMT_1920x1080i120_16_9, 1920, 1080, TRUE, 2200, 280, 1125, |
| 876 | 22, 67500, 120000, 148500, 120000, FALSE}, |
| 877 | |
| 878 | /* All 2880 H Active */ |
| 879 | {HDMI_VFRMT_2880x576i50_4_3, 2880, 576, TRUE, 3456, 576, 625, 24, |
| 880 | 15625, 50000, 54000, 50000, TRUE}, |
| 881 | {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 312, 24, |
| 882 | 15625, 50080, 54000, 50000, TRUE}, |
| 883 | {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 313, 25, |
| 884 | 15625, 49920, 54000, 50000, TRUE}, |
| 885 | {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 314, 26, |
| 886 | 15625, 49761, 54000, 50000, TRUE}, |
| 887 | {HDMI_VFRMT_2880x576p50_4_3, 2880, 576, FALSE, 3456, 576, 625, 49, |
| 888 | 31250, 50000, 108000, 50000, TRUE}, |
| 889 | {HDMI_VFRMT_2880x480i60_4_3, 2880, 480, TRUE, 3432, 552, 525, 22, |
| 890 | 15734, 59940, 54000, 59940, TRUE}, |
| 891 | {HDMI_VFRMT_2880x240p60_4_3, 2880, 480, FALSE, 3432, 552, 262, 22, |
| 892 | 15734, 60054, 54000, 59940, TRUE}, |
| 893 | {HDMI_VFRMT_2880x240p60_4_3, 2880, 480, FALSE, 3432, 552, 263, 23, |
| 894 | 15734, 59940, 54000, 59940, TRUE}, |
| 895 | {HDMI_VFRMT_2880x480p60_4_3, 2880, 480, FALSE, 3432, 552, 525, 45, |
| 896 | 31469, 59940, 108000, 59940, TRUE}, |
| 897 | {HDMI_VFRMT_2880x480i60_4_3, 2880, 480, TRUE, 3432, 552, 525, 22, |
| 898 | 15750, 60000, 54054, 60000, TRUE}, |
| 899 | {HDMI_VFRMT_2880x240p60_4_3, 2880, 240, FALSE, 3432, 552, 262, 22, |
| 900 | 15750, 60115, 54054, 60000, TRUE}, |
| 901 | {HDMI_VFRMT_2880x240p60_4_3, 2880, 240, FALSE, 3432, 552, 262, 23, |
| 902 | 15750, 59886, 54054, 60000, TRUE}, |
| 903 | {HDMI_VFRMT_2880x480p60_4_3, 2880, 480, FALSE, 3432, 552, 525, 45, |
| 904 | 31500, 60000, 108108, 60000, TRUE}, |
| 905 | }; |
| 906 | |
| 907 | static const uint8 *hdmi_edid_find_block(const uint8 *in_buf, uint8 type, |
| 908 | uint8 *len) |
| 909 | { |
| 910 | /* the start of data block collection, start of Video Data Block */ |
| 911 | uint32 offset = 4; |
| 912 | |
| 913 | *len = 0; |
Ajay Singh Parmar | 3b9595f | 2012-02-08 16:36:03 +0530 | [diff] [blame^] | 914 | |
| 915 | /*edid buffer 1, byte 2 being 4 means no non-DTD/Data block collection |
| 916 | present. |
| 917 | edid buffer 1, byte 2 being 0 menas no non-DTD/DATA block collection |
| 918 | present and no DTD data present.*/ |
| 919 | if ((in_buf[2] == 0) || (in_buf[2] == 4)) { |
| 920 | DEV_WARN("EDID: no DTD or non-DTD data present\n"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 921 | return NULL; |
| 922 | } |
| 923 | while (offset < 0x80) { |
| 924 | uint8 block_len = in_buf[offset] & 0x1F; |
| 925 | if ((in_buf[offset] >> 5) == type) { |
| 926 | *len = block_len; |
| 927 | DEV_DBG("EDID: block=%d found @ %d with length=%d\n", |
| 928 | type, offset, block_len); |
| 929 | return in_buf+offset; |
| 930 | } |
| 931 | offset += 1 + block_len; |
| 932 | } |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 933 | DEV_WARN("EDID: type=%d block not found in EDID block\n", type); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 934 | return NULL; |
| 935 | } |
| 936 | |
| 937 | static void hdmi_edid_extract_vendor_id(const uint8 *in_buf, |
| 938 | char *vendor_id) |
| 939 | { |
| 940 | uint32 id_codes = ((uint32)in_buf[8] << 8) + in_buf[9]; |
| 941 | |
| 942 | vendor_id[0] = 'A' - 1 + ((id_codes >> 10) & 0x1F); |
| 943 | vendor_id[1] = 'A' - 1 + ((id_codes >> 5) & 0x1F); |
| 944 | vendor_id[2] = 'A' - 1 + (id_codes & 0x1F); |
| 945 | vendor_id[3] = 0; |
| 946 | } |
| 947 | |
| 948 | static uint32 hdmi_edid_extract_ieee_reg_id(const uint8 *in_buf) |
| 949 | { |
| 950 | uint8 len; |
| 951 | const uint8 *vsd = hdmi_edid_find_block(in_buf, 3, &len); |
| 952 | |
| 953 | if (vsd == NULL) |
| 954 | return 0; |
| 955 | |
| 956 | DEV_DBG("EDID: VSD PhyAddr=%04x, MaxTMDS=%dMHz\n", |
| 957 | ((uint32)vsd[6] << 8) + (uint32)vsd[5], (uint32)vsd[7] * 5); |
| 958 | return ((uint32)vsd[3] << 16) + ((uint32)vsd[2] << 8) + (uint32)vsd[1]; |
| 959 | } |
| 960 | |
| 961 | static void hdmi_edid_extract_3d_present(const uint8 *in_buf) |
| 962 | { |
| 963 | uint8 len, offset; |
| 964 | const uint8 *vsd = hdmi_edid_find_block(in_buf, 3, &len); |
| 965 | |
| 966 | external_common_state->present_3d = 0; |
| 967 | if (vsd == NULL || len < 9) { |
| 968 | DEV_DBG("EDID[3D]: block-id 3 not found or not long enough\n"); |
| 969 | return; |
| 970 | } |
| 971 | |
| 972 | offset = !(vsd[8] & BIT(7)) ? 9 : 13; |
| 973 | DEV_DBG("EDID: 3D present @ %d = %02x\n", offset, vsd[offset]); |
| 974 | if (vsd[offset] >> 7) { /* 3D format indication present */ |
| 975 | DEV_INFO("EDID: 3D present, 3D-len=%d\n", vsd[offset+1] & 0x1F); |
| 976 | external_common_state->present_3d = 1; |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | |
| 981 | static void hdmi_edid_extract_latency_fields(const uint8 *in_buf) |
| 982 | { |
| 983 | uint8 len; |
| 984 | const uint8 *vsd = hdmi_edid_find_block(in_buf, 3, &len); |
| 985 | |
| 986 | if (vsd == NULL || len < 12 || !(vsd[8] & BIT(7))) { |
| 987 | external_common_state->video_latency = (uint16)-1; |
| 988 | external_common_state->audio_latency = (uint16)-1; |
| 989 | DEV_DBG("EDID: No audio/video latency present\n"); |
| 990 | } else { |
| 991 | external_common_state->video_latency = vsd[9]; |
| 992 | external_common_state->audio_latency = vsd[10]; |
| 993 | DEV_DBG("EDID: video-latency=%04x, audio-latency=%04x\n", |
| 994 | external_common_state->video_latency, |
| 995 | external_common_state->audio_latency); |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | static void hdmi_edid_extract_speaker_allocation_data(const uint8 *in_buf) |
| 1000 | { |
| 1001 | uint8 len; |
| 1002 | const uint8 *sad = hdmi_edid_find_block(in_buf, 4, &len); |
| 1003 | |
| 1004 | if (sad == NULL) |
| 1005 | return; |
| 1006 | |
| 1007 | external_common_state->speaker_allocation_block = sad[1]; |
Kiran Kandi | 94f25dc | 2012-01-31 00:18:33 -0800 | [diff] [blame] | 1008 | DEV_DBG("EDID: speaker allocation data SP byte = %08x %s%s%s%s%s%s%s\n", |
| 1009 | sad[1], |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1010 | (sad[1] & BIT(0)) ? "FL/FR," : "", |
| 1011 | (sad[1] & BIT(1)) ? "LFE," : "", |
| 1012 | (sad[1] & BIT(2)) ? "FC," : "", |
| 1013 | (sad[1] & BIT(3)) ? "RL/RR," : "", |
| 1014 | (sad[1] & BIT(4)) ? "RC," : "", |
| 1015 | (sad[1] & BIT(5)) ? "FLC/FRC," : "", |
Kiran Kandi | 94f25dc | 2012-01-31 00:18:33 -0800 | [diff] [blame] | 1016 | (sad[1] & BIT(6)) ? "RLC/RRC," : ""); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | static void hdmi_edid_extract_audio_data_blocks(const uint8 *in_buf) |
| 1020 | { |
| 1021 | uint8 len; |
| 1022 | const uint8 *sad = hdmi_edid_find_block(in_buf, 1, &len); |
| 1023 | uint32 *adb = external_common_state->audio_data_blocks; |
| 1024 | |
| 1025 | if (sad == NULL) |
| 1026 | return; |
| 1027 | |
| 1028 | external_common_state->audio_data_block_cnt = 0; |
| 1029 | while (len >= 3 && external_common_state->audio_data_block_cnt < 16) { |
| 1030 | DEV_DBG("EDID: Audio Data Block=<ch=%d, format=%d " |
| 1031 | "sampling=0x%02x bit-depth=0x%02x>\n", |
| 1032 | (sad[1] & 0x7)+1, sad[1] >> 3, sad[2], sad[3]); |
| 1033 | *adb++ = (uint32)sad[1] + ((uint32)sad[2] << 8) |
| 1034 | + ((uint32)sad[2] << 16); |
| 1035 | ++external_common_state->audio_data_block_cnt; |
| 1036 | len -= 3; |
| 1037 | sad += 3; |
| 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | |
| 1042 | static void hdmi_edid_detail_desc(const uint8 *data_buf, uint32 *disp_mode) |
| 1043 | { |
| 1044 | boolean aspect_ratio_4_3 = FALSE; |
| 1045 | boolean interlaced = FALSE; |
| 1046 | uint32 active_h = 0; |
| 1047 | uint32 active_v = 0; |
| 1048 | uint32 blank_h = 0; |
| 1049 | uint32 blank_v = 0; |
| 1050 | uint32 ndx = 0; |
| 1051 | uint32 max_num_of_elements = 0; |
| 1052 | uint32 img_size_h = 0; |
| 1053 | uint32 img_size_v = 0; |
| 1054 | |
| 1055 | /* See VESA Spec */ |
| 1056 | /* EDID_TIMING_DESC_UPPER_H_NIBBLE[0x4]: Relative Offset to the EDID |
| 1057 | * detailed timing descriptors - Upper 4 bit for each H active/blank |
| 1058 | * field */ |
| 1059 | /* EDID_TIMING_DESC_H_ACTIVE[0x2]: Relative Offset to the EDID detailed |
| 1060 | * timing descriptors - H active */ |
| 1061 | active_h = ((((uint32)data_buf[0x4] >> 0x4) & 0xF) << 8) |
| 1062 | | data_buf[0x2]; |
| 1063 | |
| 1064 | /* EDID_TIMING_DESC_H_BLANK[0x3]: Relative Offset to the EDID detailed |
| 1065 | * timing descriptors - H blank */ |
| 1066 | blank_h = (((uint32)data_buf[0x4] & 0xF) << 8) |
| 1067 | | data_buf[0x3]; |
| 1068 | |
| 1069 | /* EDID_TIMING_DESC_UPPER_V_NIBBLE[0x7]: Relative Offset to the EDID |
| 1070 | * detailed timing descriptors - Upper 4 bit for each V active/blank |
| 1071 | * field */ |
| 1072 | /* EDID_TIMING_DESC_V_ACTIVE[0x5]: Relative Offset to the EDID detailed |
| 1073 | * timing descriptors - V active */ |
| 1074 | active_v = ((((uint32)data_buf[0x7] >> 0x4) & 0xF) << 8) |
| 1075 | | data_buf[0x5]; |
| 1076 | |
| 1077 | /* EDID_TIMING_DESC_V_BLANK[0x6]: Relative Offset to the EDID detailed |
| 1078 | * timing descriptors - V blank */ |
| 1079 | blank_v = (((uint32)data_buf[0x7] & 0xF) << 8) |
| 1080 | | data_buf[0x6]; |
| 1081 | |
| 1082 | /* EDID_TIMING_DESC_IMAGE_SIZE_UPPER_NIBBLE[0xE]: Relative Offset to the |
| 1083 | * EDID detailed timing descriptors - Image Size upper nibble |
| 1084 | * V and H */ |
| 1085 | /* EDID_TIMING_DESC_H_IMAGE_SIZE[0xC]: Relative Offset to the EDID |
| 1086 | * detailed timing descriptors - H image size */ |
| 1087 | /* EDID_TIMING_DESC_V_IMAGE_SIZE[0xD]: Relative Offset to the EDID |
| 1088 | * detailed timing descriptors - V image size */ |
| 1089 | img_size_h = ((((uint32)data_buf[0xE] >> 0x4) & 0xF) << 8) |
| 1090 | | data_buf[0xC]; |
| 1091 | img_size_v = (((uint32)data_buf[0xE] & 0xF) << 8) |
| 1092 | | data_buf[0xD]; |
| 1093 | |
Abhishek Kharbanda | 402adc6 | 2011-12-15 12:21:29 -0800 | [diff] [blame] | 1094 | /* |
| 1095 | * aspect ratio as 4:3 if within specificed range , rathaer than being |
| 1096 | * absolute value |
| 1097 | */ |
| 1098 | aspect_ratio_4_3 = (abs(img_size_h * 3 - img_size_v * 4) < 5) ? 1 : 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1099 | |
| 1100 | max_num_of_elements = sizeof(hdmi_edid_disp_mode_lut) |
| 1101 | / sizeof(*hdmi_edid_disp_mode_lut); |
| 1102 | |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1103 | /* EDID_TIMING_DESC_INTERLACE[0x11:7]: Relative Offset to the EDID |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1104 | * detailed timing descriptors - Interlace flag */ |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1105 | DEV_DBG("Interlaced mode byte data_buf[0x11]=[%x]\n", data_buf[0x11]); |
| 1106 | /* |
| 1107 | * CEA 861-D: interlaced bit is bit[7] of byte[0x11] |
| 1108 | */ |
| 1109 | interlaced = (data_buf[0x11] & 0x80) >> 7; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1110 | |
| 1111 | DEV_DBG("%s: A[%ux%u] B[%ux%u] V[%ux%u] %s\n", __func__, |
| 1112 | active_h, active_v, blank_h, blank_v, img_size_h, img_size_v, |
| 1113 | interlaced ? "i" : "p"); |
| 1114 | |
| 1115 | *disp_mode = HDMI_VFRMT_FORCE_32BIT; |
| 1116 | while (ndx < max_num_of_elements) { |
| 1117 | const struct hdmi_edid_video_mode_property_type *edid = |
| 1118 | hdmi_edid_disp_mode_lut+ndx; |
| 1119 | |
| 1120 | if ((interlaced == edid->interlaced) && |
| 1121 | (active_h == edid->active_h) && |
| 1122 | (blank_h == edid->total_blank_h) && |
| 1123 | (blank_v == edid->total_blank_v) && |
| 1124 | ((active_v == edid->active_v) || |
| 1125 | (active_v == (edid->active_v + 1))) |
| 1126 | ) { |
| 1127 | if (edid->aspect_ratio_4_3 && !aspect_ratio_4_3) |
| 1128 | /* Aspect ratio 16:9 */ |
| 1129 | *disp_mode = edid->video_code + 1; |
| 1130 | else |
| 1131 | /* Aspect ratio 4:3 */ |
| 1132 | *disp_mode = edid->video_code; |
| 1133 | |
| 1134 | DEV_DBG("%s: mode found:%d\n", __func__, *disp_mode); |
| 1135 | break; |
| 1136 | } |
| 1137 | ++ndx; |
| 1138 | } |
| 1139 | if (ndx == max_num_of_elements) |
| 1140 | DEV_INFO("%s: *no mode* found\n", __func__); |
| 1141 | } |
| 1142 | |
| 1143 | static void add_supported_video_format( |
| 1144 | struct hdmi_disp_mode_list_type *disp_mode_list, |
| 1145 | uint32 video_format) |
| 1146 | { |
| 1147 | const struct hdmi_disp_mode_timing_type *timing = |
| 1148 | hdmi_common_get_supported_mode(video_format); |
| 1149 | boolean supported = timing != NULL; |
| 1150 | |
| 1151 | if (video_format >= HDMI_VFRMT_MAX) |
| 1152 | return; |
| 1153 | |
| 1154 | DEV_DBG("EDID: format: %d [%s], %s\n", |
| 1155 | video_format, video_format_2string(video_format), |
| 1156 | supported ? "Supported" : "Not-Supported"); |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 1157 | if (supported) { |
| 1158 | if (mhl_is_connected()) { |
| 1159 | const struct hdmi_disp_mode_timing_type *mhl_timing = |
| 1160 | hdmi_mhl_get_supported_mode(video_format); |
| 1161 | boolean mhl_supported = mhl_timing != NULL; |
| 1162 | DEV_DBG("EDID: format: %d [%s], %s by MHL\n", |
| 1163 | video_format, video_format_2string(video_format), |
| 1164 | mhl_supported ? "Supported" : "Not-Supported"); |
| 1165 | if (mhl_supported) |
| 1166 | disp_mode_list->disp_mode_list[ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1167 | disp_mode_list->num_of_elements++] = video_format; |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 1168 | } else |
| 1169 | disp_mode_list->disp_mode_list[ |
| 1170 | disp_mode_list->num_of_elements++] = video_format; |
| 1171 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | static void hdmi_edid_get_display_mode(const uint8 *data_buf, |
| 1175 | struct hdmi_disp_mode_list_type *disp_mode_list, |
| 1176 | uint32 num_og_cea_blocks) |
| 1177 | { |
| 1178 | uint8 i = 0; |
| 1179 | uint32 video_format = HDMI_VFRMT_640x480p60_4_3; |
| 1180 | boolean has480p = FALSE; |
| 1181 | uint8 len; |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1182 | const uint8 *edid_blk0 = &data_buf[0x0]; |
| 1183 | const uint8 *edid_blk1 = &data_buf[0x80]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1184 | const uint8 *svd = num_og_cea_blocks ? |
| 1185 | hdmi_edid_find_block(data_buf+0x80, 2, &len) : NULL; |
| 1186 | |
| 1187 | disp_mode_list->num_of_elements = 0; |
| 1188 | if (svd != NULL) { |
| 1189 | ++svd; |
| 1190 | for (i = 0; i < len; ++i, ++svd) { |
| 1191 | /* Subtract 1 because it is zero based in the driver, |
| 1192 | * while the Video identification code is 1 based in the |
| 1193 | * CEA_861D spec */ |
| 1194 | video_format = (*svd & 0x7F) - 1; |
| 1195 | add_supported_video_format(disp_mode_list, |
| 1196 | video_format); |
| 1197 | if (video_format == HDMI_VFRMT_640x480p60_4_3) |
| 1198 | has480p = TRUE; |
| 1199 | } |
| 1200 | } else if (!num_og_cea_blocks) { |
| 1201 | /* Detailed timing descriptors */ |
| 1202 | uint32 desc_offset = 0; |
| 1203 | /* Maximum 4 timing descriptor in block 0 - No CEA |
| 1204 | * extension in this case */ |
| 1205 | /* EDID_FIRST_TIMING_DESC[0x36] - 1st detailed timing |
| 1206 | * descriptor */ |
| 1207 | /* EDID_DETAIL_TIMING_DESC_BLCK_SZ[0x12] - Each detailed timing |
| 1208 | * descriptor has block size of 18 */ |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1209 | while (4 > i && 0 != edid_blk0[0x36+desc_offset]) { |
| 1210 | hdmi_edid_detail_desc(edid_blk0+0x36+desc_offset, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1211 | &video_format); |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1212 | DEV_DBG("[%s:%d] Block-0 Adding vid fmt = [%s]\n", |
| 1213 | __func__, __LINE__, |
| 1214 | video_format_2string(video_format)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1215 | add_supported_video_format(disp_mode_list, |
| 1216 | video_format); |
| 1217 | if (video_format == HDMI_VFRMT_640x480p60_4_3) |
| 1218 | has480p = TRUE; |
| 1219 | desc_offset += 0x12; |
| 1220 | ++i; |
| 1221 | } |
| 1222 | } else if (1 == num_og_cea_blocks) { |
| 1223 | uint32 desc_offset = 0; |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1224 | |
| 1225 | /* |
| 1226 | * Read from both block 0 and block 1 |
| 1227 | * Read EDID block[0] as above |
| 1228 | */ |
| 1229 | while (4 > i && 0 != edid_blk0[0x36+desc_offset]) { |
| 1230 | hdmi_edid_detail_desc(edid_blk0+0x36+desc_offset, |
| 1231 | &video_format); |
| 1232 | DEV_DBG("[%s:%d] Block-0 Adding vid fmt = [%s]\n", |
| 1233 | __func__, __LINE__, |
| 1234 | video_format_2string(video_format)); |
| 1235 | add_supported_video_format(disp_mode_list, |
| 1236 | video_format); |
| 1237 | if (video_format == HDMI_VFRMT_640x480p60_4_3) |
| 1238 | has480p = TRUE; |
| 1239 | desc_offset += 0x12; |
| 1240 | ++i; |
| 1241 | } |
| 1242 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1243 | /* Parse block 1 - CEA extension byte offset of first |
| 1244 | * detailed timing generation - offset is relevant to |
| 1245 | * the offset of block 1 */ |
| 1246 | |
| 1247 | /* EDID_CEA_EXTENSION_FIRST_DESC[0x82]: Offset to CEA |
| 1248 | * extension first timing desc - indicate the offset of |
| 1249 | * the first detailed timing descriptor */ |
| 1250 | /* EDID_BLOCK_SIZE = 0x80 Each page size in the EDID ROM */ |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1251 | desc_offset = edid_blk1[0x02]; |
| 1252 | while (0 != edid_blk1[desc_offset]) { |
| 1253 | hdmi_edid_detail_desc(edid_blk1+desc_offset, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1254 | &video_format); |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1255 | DEV_DBG("[%s:%d] Block-1 Adding vid fmt = [%s]\n", |
| 1256 | __func__, __LINE__, |
| 1257 | video_format_2string(video_format)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1258 | add_supported_video_format(disp_mode_list, |
| 1259 | video_format); |
| 1260 | if (video_format == HDMI_VFRMT_640x480p60_4_3) |
| 1261 | has480p = TRUE; |
| 1262 | desc_offset += 0x12; |
| 1263 | ++i; |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | if (!has480p) |
| 1268 | /* Need to add default 640 by 480 timings, in case not described |
| 1269 | * in the EDID structure. |
| 1270 | * All DTV sink devices should support this mode */ |
| 1271 | add_supported_video_format(disp_mode_list, |
| 1272 | HDMI_VFRMT_640x480p60_4_3); |
| 1273 | } |
| 1274 | |
| 1275 | static int hdmi_common_read_edid_block(int block, uint8 *edid_buf) |
| 1276 | { |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1277 | uint32 ndx, check_sum, print_len; |
| 1278 | #ifdef DEBUG |
| 1279 | const u8 *b = edid_buf; |
| 1280 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1281 | int status = external_common_state->read_edid_block(block, edid_buf); |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1282 | if (status) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1283 | goto error; |
| 1284 | |
| 1285 | /* Calculate checksum */ |
| 1286 | check_sum = 0; |
| 1287 | for (ndx = 0; ndx < 0x80; ++ndx) |
| 1288 | check_sum += edid_buf[ndx]; |
| 1289 | |
| 1290 | if (check_sum & 0xFF) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1291 | DEV_ERR("%s: failed CHECKSUM (read:%x, expected:%x)\n", |
| 1292 | __func__, (uint8)edid_buf[0x7F], (uint8)check_sum); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1293 | #ifdef DEBUG |
| 1294 | for (ndx = 0; ndx < 0x100; ndx += 16) |
| 1295 | DEV_DBG("EDID[%02x-%02x] %02x %02x %02x %02x " |
| 1296 | "%02x %02x %02x %02x %02x %02x %02x %02x " |
| 1297 | "%02x %02x %02x %02x\n", ndx, ndx+15, |
| 1298 | b[ndx+0], b[ndx+1], b[ndx+2], b[ndx+3], |
| 1299 | b[ndx+4], b[ndx+5], b[ndx+6], b[ndx+7], |
| 1300 | b[ndx+8], b[ndx+9], b[ndx+10], b[ndx+11], |
| 1301 | b[ndx+12], b[ndx+13], b[ndx+14], b[ndx+15]); |
| 1302 | #endif |
| 1303 | status = -EPROTO; |
| 1304 | goto error; |
| 1305 | } |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1306 | print_len = 0x80; |
| 1307 | for (ndx = 0; ndx < print_len; ndx += 16) |
| 1308 | DEV_DBG("EDID[%02x-%02x] %02x %02x %02x %02x " |
| 1309 | "%02x %02x %02x %02x %02x %02x %02x %02x " |
| 1310 | "%02x %02x %02x %02x\n", ndx, ndx+15, |
| 1311 | b[ndx+0], b[ndx+1], b[ndx+2], b[ndx+3], |
| 1312 | b[ndx+4], b[ndx+5], b[ndx+6], b[ndx+7], |
| 1313 | b[ndx+8], b[ndx+9], b[ndx+10], b[ndx+11], |
| 1314 | b[ndx+12], b[ndx+13], b[ndx+14], b[ndx+15]); |
| 1315 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1316 | |
| 1317 | error: |
| 1318 | return status; |
| 1319 | } |
| 1320 | |
| 1321 | static boolean check_edid_header(const uint8 *edid_buf) |
| 1322 | { |
| 1323 | return (edid_buf[0] == 0x00) && (edid_buf[1] == 0xff) |
| 1324 | && (edid_buf[2] == 0xff) && (edid_buf[3] == 0xff) |
| 1325 | && (edid_buf[4] == 0xff) && (edid_buf[5] == 0xff) |
| 1326 | && (edid_buf[6] == 0xff) && (edid_buf[7] == 0x00); |
| 1327 | } |
| 1328 | |
| 1329 | int hdmi_common_read_edid(void) |
| 1330 | { |
| 1331 | int status = 0; |
| 1332 | uint32 cea_extension_ver = 0; |
| 1333 | uint32 num_og_cea_blocks = 0; |
| 1334 | uint32 ieee_reg_id = 0; |
| 1335 | uint32 i = 1; |
| 1336 | char vendor_id[5]; |
| 1337 | /* EDID_BLOCK_SIZE[0x80] Each page size in the EDID ROM */ |
| 1338 | uint8 edid_buf[0x80 * 4]; |
| 1339 | |
| 1340 | external_common_state->present_3d = 0; |
| 1341 | memset(&external_common_state->disp_mode_list, 0, |
| 1342 | sizeof(external_common_state->disp_mode_list)); |
| 1343 | memset(edid_buf, 0, sizeof(edid_buf)); |
| 1344 | |
| 1345 | status = hdmi_common_read_edid_block(0, edid_buf); |
| 1346 | if (status || !check_edid_header(edid_buf)) { |
| 1347 | if (!status) |
| 1348 | status = -EPROTO; |
| 1349 | DEV_ERR("%s: edid read block(0) failed: %d " |
| 1350 | "[%02x%02x%02x%02x%02x%02x%02x%02x]\n", __func__, |
| 1351 | status, |
| 1352 | edid_buf[0], edid_buf[1], edid_buf[2], edid_buf[3], |
| 1353 | edid_buf[4], edid_buf[5], edid_buf[6], edid_buf[7]); |
| 1354 | goto error; |
| 1355 | } |
| 1356 | hdmi_edid_extract_vendor_id(edid_buf, vendor_id); |
| 1357 | |
| 1358 | /* EDID_CEA_EXTENSION_FLAG[0x7E] - CEC extension byte */ |
| 1359 | num_og_cea_blocks = edid_buf[0x7E]; |
| 1360 | |
| 1361 | DEV_DBG("[JSR] (%s): No. of CEA blocks is [%u]\n", __func__, |
| 1362 | num_og_cea_blocks); |
| 1363 | /* Find out any CEA extension blocks following block 0 */ |
| 1364 | switch (num_og_cea_blocks) { |
| 1365 | case 0: /* No CEA extension */ |
| 1366 | external_common_state->hdmi_sink = false; |
| 1367 | DEV_DBG("HDMI DVI mode: %s\n", |
| 1368 | external_common_state->hdmi_sink ? "no" : "yes"); |
| 1369 | break; |
| 1370 | case 1: /* Read block 1 */ |
Manoj Rao | 668d6d5 | 2011-08-16 19:12:31 -0700 | [diff] [blame] | 1371 | status = hdmi_common_read_edid_block(1, &edid_buf[0x80]); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1372 | if (status) { |
| 1373 | DEV_ERR("%s: ddc read block(1) failed: %d\n", __func__, |
| 1374 | status); |
| 1375 | goto error; |
| 1376 | } |
| 1377 | if (edid_buf[0x80] != 2) |
| 1378 | num_og_cea_blocks = 0; |
| 1379 | if (num_og_cea_blocks) { |
| 1380 | ieee_reg_id = |
| 1381 | hdmi_edid_extract_ieee_reg_id(edid_buf+0x80); |
| 1382 | if (ieee_reg_id == 0x0c03) |
| 1383 | external_common_state->hdmi_sink = TRUE ; |
| 1384 | else |
| 1385 | external_common_state->hdmi_sink = FALSE ; |
| 1386 | hdmi_edid_extract_latency_fields(edid_buf+0x80); |
| 1387 | hdmi_edid_extract_speaker_allocation_data( |
| 1388 | edid_buf+0x80); |
| 1389 | hdmi_edid_extract_audio_data_blocks(edid_buf+0x80); |
| 1390 | hdmi_edid_extract_3d_present(edid_buf+0x80); |
| 1391 | } |
| 1392 | break; |
| 1393 | case 2: |
| 1394 | case 3: |
| 1395 | case 4: |
| 1396 | for (i = 1; i <= num_og_cea_blocks; i++) { |
| 1397 | if (!(i % 2)) { |
| 1398 | status = hdmi_common_read_edid_block(i, |
| 1399 | edid_buf+0x00); |
| 1400 | if (status) { |
| 1401 | DEV_ERR("%s: ddc read block(%d)" |
| 1402 | "failed: %d\n", __func__, i, |
| 1403 | status); |
| 1404 | goto error; |
| 1405 | } |
| 1406 | } else { |
| 1407 | status = hdmi_common_read_edid_block(i, |
| 1408 | edid_buf+0x80); |
| 1409 | if (status) { |
| 1410 | DEV_ERR("%s: ddc read block(%d)" |
| 1411 | "failed:%d\n", __func__, i, |
| 1412 | status); |
| 1413 | goto error; |
| 1414 | } |
| 1415 | } |
| 1416 | } |
| 1417 | break; |
| 1418 | default: |
| 1419 | DEV_ERR("%s: ddc read failed, not supported multi-blocks: %d\n", |
| 1420 | __func__, num_og_cea_blocks); |
| 1421 | status = -EPROTO; |
| 1422 | goto error; |
| 1423 | } |
| 1424 | |
| 1425 | if (num_og_cea_blocks) { |
| 1426 | /* EDID_CEA_EXTENSION_VERSION[0x81]: Offset to CEA extension |
| 1427 | * version number - v1,v2,v3 (v1 is seldom, v2 is obsolete, |
| 1428 | * v3 most common) */ |
| 1429 | cea_extension_ver = edid_buf[0x81]; |
| 1430 | } |
| 1431 | |
| 1432 | /* EDID_VERSION[0x12] - EDID Version */ |
| 1433 | /* EDID_REVISION[0x13] - EDID Revision */ |
| 1434 | DEV_INFO("EDID (V=%d.%d, #CEABlocks=%d[V%d], ID=%s, IEEE=%04x, " |
| 1435 | "EDID-Ext=0x%02x)\n", edid_buf[0x12], edid_buf[0x13], |
| 1436 | num_og_cea_blocks, cea_extension_ver, vendor_id, ieee_reg_id, |
| 1437 | edid_buf[0x80]); |
| 1438 | |
| 1439 | hdmi_edid_get_display_mode(edid_buf, |
| 1440 | &external_common_state->disp_mode_list, num_og_cea_blocks); |
| 1441 | |
| 1442 | return 0; |
| 1443 | |
| 1444 | error: |
| 1445 | external_common_state->disp_mode_list.num_of_elements = 1; |
| 1446 | external_common_state->disp_mode_list.disp_mode_list[0] = |
| 1447 | external_common_state->video_resolution; |
| 1448 | return status; |
| 1449 | } |
| 1450 | EXPORT_SYMBOL(hdmi_common_read_edid); |
| 1451 | |
| 1452 | bool hdmi_common_get_video_format_from_drv_data(struct msm_fb_data_type *mfd) |
| 1453 | { |
| 1454 | uint32 format; |
| 1455 | struct fb_var_screeninfo *var = &mfd->fbi->var; |
| 1456 | bool changed = TRUE; |
| 1457 | |
| 1458 | if (var->reserved[3]) { |
| 1459 | format = var->reserved[3]-1; |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 1460 | DEV_DBG("reserved format is %d\n", format); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1461 | } else { |
| 1462 | DEV_DBG("detecting resolution from %dx%d use var->reserved[3]" |
| 1463 | " to specify mode", mfd->var_xres, mfd->var_yres); |
| 1464 | switch (mfd->var_xres) { |
| 1465 | default: |
| 1466 | case 640: |
| 1467 | format = HDMI_VFRMT_640x480p60_4_3; |
| 1468 | break; |
| 1469 | case 720: |
| 1470 | format = (mfd->var_yres == 480) |
| 1471 | ? HDMI_VFRMT_720x480p60_16_9 |
| 1472 | : HDMI_VFRMT_720x576p50_16_9; |
| 1473 | break; |
| 1474 | case 1280: |
| 1475 | format = HDMI_VFRMT_1280x720p60_16_9; |
| 1476 | break; |
| 1477 | case 1440: |
| 1478 | format = (mfd->var_yres == 480) |
| 1479 | ? HDMI_VFRMT_1440x480i60_16_9 |
| 1480 | : HDMI_VFRMT_1440x576i50_16_9; |
| 1481 | break; |
| 1482 | case 1920: |
| 1483 | format = HDMI_VFRMT_1920x1080p60_16_9; |
| 1484 | break; |
| 1485 | } |
| 1486 | } |
| 1487 | |
| 1488 | changed = external_common_state->video_resolution != format; |
| 1489 | if (external_common_state->video_resolution != format) |
| 1490 | DEV_DBG("switching %s => %s", video_format_2string( |
| 1491 | external_common_state->video_resolution), |
| 1492 | video_format_2string(format)); |
| 1493 | else |
| 1494 | DEV_DBG("resolution %s", video_format_2string( |
| 1495 | external_common_state->video_resolution)); |
| 1496 | external_common_state->video_resolution = format; |
| 1497 | return changed; |
| 1498 | } |
| 1499 | EXPORT_SYMBOL(hdmi_common_get_video_format_from_drv_data); |
| 1500 | |
| 1501 | const struct hdmi_disp_mode_timing_type *hdmi_common_get_mode(uint32 mode) |
| 1502 | { |
| 1503 | if (mode >= HDMI_VFRMT_MAX) |
| 1504 | return NULL; |
| 1505 | |
| 1506 | return &hdmi_common_supported_video_mode_lut[mode]; |
| 1507 | } |
| 1508 | EXPORT_SYMBOL(hdmi_common_get_mode); |
| 1509 | |
| 1510 | const struct hdmi_disp_mode_timing_type *hdmi_common_get_supported_mode( |
| 1511 | uint32 mode) |
| 1512 | { |
| 1513 | const struct hdmi_disp_mode_timing_type *ret |
| 1514 | = hdmi_common_get_mode(mode); |
| 1515 | |
| 1516 | if (ret == NULL || !ret->supported) |
| 1517 | return NULL; |
| 1518 | return ret; |
| 1519 | } |
| 1520 | EXPORT_SYMBOL(hdmi_common_get_supported_mode); |
| 1521 | |
Eugene Yasman | d0de5f9 | 2011-12-20 13:57:28 +0200 | [diff] [blame] | 1522 | const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_mode(uint32 mode) |
| 1523 | { |
| 1524 | if (mode >= HDMI_VFRMT_MAX) |
| 1525 | return NULL; |
| 1526 | |
| 1527 | return &hdmi_mhl_supported_video_mode_lut[mode]; |
| 1528 | } |
| 1529 | EXPORT_SYMBOL(hdmi_mhl_get_mode); |
| 1530 | |
| 1531 | const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_supported_mode( |
| 1532 | uint32 mode) |
| 1533 | { |
| 1534 | const struct hdmi_disp_mode_timing_type *ret |
| 1535 | = hdmi_mhl_get_mode(mode); |
| 1536 | |
| 1537 | if (ret == NULL || !ret->supported) |
| 1538 | return NULL; |
| 1539 | return ret; |
| 1540 | } |
| 1541 | EXPORT_SYMBOL(hdmi_mhl_get_supported_mode); |
| 1542 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1543 | void hdmi_common_init_panel_info(struct msm_panel_info *pinfo) |
| 1544 | { |
| 1545 | const struct hdmi_disp_mode_timing_type *timing = |
| 1546 | hdmi_common_get_supported_mode( |
| 1547 | external_common_state->video_resolution); |
| 1548 | |
| 1549 | if (timing == NULL) |
| 1550 | return; |
| 1551 | |
| 1552 | pinfo->xres = timing->active_h; |
| 1553 | pinfo->yres = timing->active_v; |
| 1554 | pinfo->clk_rate = timing->pixel_freq*1000; |
| 1555 | |
| 1556 | pinfo->lcdc.h_back_porch = timing->back_porch_h; |
| 1557 | pinfo->lcdc.h_front_porch = timing->front_porch_h; |
| 1558 | pinfo->lcdc.h_pulse_width = timing->pulse_width_h; |
| 1559 | pinfo->lcdc.v_back_porch = timing->back_porch_v; |
| 1560 | pinfo->lcdc.v_front_porch = timing->front_porch_v; |
| 1561 | pinfo->lcdc.v_pulse_width = timing->pulse_width_v; |
| 1562 | |
| 1563 | pinfo->type = DTV_PANEL; |
| 1564 | pinfo->pdest = DISPLAY_2; |
| 1565 | pinfo->wait_cycle = 0; |
| 1566 | pinfo->bpp = 24; |
Ravishangar Kalyanam | 898f4bd | 2011-07-15 18:25:47 -0700 | [diff] [blame] | 1567 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 1568 | pinfo->fb_num = 2; |
| 1569 | #else |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1570 | pinfo->fb_num = 1; |
Ravishangar Kalyanam | 898f4bd | 2011-07-15 18:25:47 -0700 | [diff] [blame] | 1571 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1572 | |
| 1573 | /* blk */ |
| 1574 | pinfo->lcdc.border_clr = 0; |
| 1575 | /* blue */ |
| 1576 | pinfo->lcdc.underflow_clr = 0xff; |
| 1577 | pinfo->lcdc.hsync_skew = 0; |
| 1578 | } |
| 1579 | EXPORT_SYMBOL(hdmi_common_init_panel_info); |
| 1580 | #endif |