external_common.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  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. #ifndef __EXTERNAL_COMMON_H__
  14. #define __EXTERNAL_COMMON_H__
  15. #include <linux/switch.h>
  16. #ifdef DEBUG
  17. #ifndef DEV_DBG_PREFIX
  18. #define DEV_DBG_PREFIX "EXT_INTERFACE: "
  19. #endif
  20. #define DEV_DBG(args...) pr_debug(DEV_DBG_PREFIX args)
  21. #else
  22. #define DEV_DBG(args...) (void)0
  23. #endif /* DEBUG */
  24. #define DEV_INFO(args...) dev_info(external_common_state->dev, args)
  25. #define DEV_WARN(args...) dev_warn(external_common_state->dev, args)
  26. #define DEV_ERR(args...) dev_err(external_common_state->dev, args)
  27. #ifdef CONFIG_FB_MSM_TVOUT
  28. #define TVOUT_VFRMT_NTSC_M_720x480i 0
  29. #define TVOUT_VFRMT_NTSC_J_720x480i 1
  30. #define TVOUT_VFRMT_PAL_BDGHIN_720x576i 2
  31. #define TVOUT_VFRMT_PAL_M_720x480i 3
  32. #define TVOUT_VFRMT_PAL_N_720x480i 4
  33. #elif defined(CONFIG_FB_MSM_HDMI_COMMON)
  34. /* all video formats defined by EIA CEA 861D */
  35. #define HDMI_VFRMT_640x480p60_4_3 0
  36. #define HDMI_VFRMT_720x480p60_4_3 1
  37. #define HDMI_VFRMT_720x480p60_16_9 2
  38. #define HDMI_VFRMT_1280x720p60_16_9 3
  39. #define HDMI_VFRMT_1920x1080i60_16_9 4
  40. #define HDMI_VFRMT_720x480i60_4_3 5
  41. #define HDMI_VFRMT_1440x480i60_4_3 HDMI_VFRMT_720x480i60_4_3
  42. #define HDMI_VFRMT_720x480i60_16_9 6
  43. #define HDMI_VFRMT_1440x480i60_16_9 HDMI_VFRMT_720x480i60_16_9
  44. #define HDMI_VFRMT_720x240p60_4_3 7
  45. #define HDMI_VFRMT_1440x240p60_4_3 HDMI_VFRMT_720x240p60_4_3
  46. #define HDMI_VFRMT_720x240p60_16_9 8
  47. #define HDMI_VFRMT_1440x240p60_16_9 HDMI_VFRMT_720x240p60_16_9
  48. #define HDMI_VFRMT_2880x480i60_4_3 9
  49. #define HDMI_VFRMT_2880x480i60_16_9 10
  50. #define HDMI_VFRMT_2880x240p60_4_3 11
  51. #define HDMI_VFRMT_2880x240p60_16_9 12
  52. #define HDMI_VFRMT_1440x480p60_4_3 13
  53. #define HDMI_VFRMT_1440x480p60_16_9 14
  54. #define HDMI_VFRMT_1920x1080p60_16_9 15
  55. #define HDMI_VFRMT_720x576p50_4_3 16
  56. #define HDMI_VFRMT_720x576p50_16_9 17
  57. #define HDMI_VFRMT_1280x720p50_16_9 18
  58. #define HDMI_VFRMT_1920x1080i50_16_9 19
  59. #define HDMI_VFRMT_720x576i50_4_3 20
  60. #define HDMI_VFRMT_1440x576i50_4_3 HDMI_VFRMT_720x576i50_4_3
  61. #define HDMI_VFRMT_720x576i50_16_9 21
  62. #define HDMI_VFRMT_1440x576i50_16_9 HDMI_VFRMT_720x576i50_16_9
  63. #define HDMI_VFRMT_720x288p50_4_3 22
  64. #define HDMI_VFRMT_1440x288p50_4_3 HDMI_VFRMT_720x288p50_4_3
  65. #define HDMI_VFRMT_720x288p50_16_9 23
  66. #define HDMI_VFRMT_1440x288p50_16_9 HDMI_VFRMT_720x288p50_16_9
  67. #define HDMI_VFRMT_2880x576i50_4_3 24
  68. #define HDMI_VFRMT_2880x576i50_16_9 25
  69. #define HDMI_VFRMT_2880x288p50_4_3 26
  70. #define HDMI_VFRMT_2880x288p50_16_9 27
  71. #define HDMI_VFRMT_1440x576p50_4_3 28
  72. #define HDMI_VFRMT_1440x576p50_16_9 29
  73. #define HDMI_VFRMT_1920x1080p50_16_9 30
  74. #define HDMI_VFRMT_1920x1080p24_16_9 31
  75. #define HDMI_VFRMT_1920x1080p25_16_9 32
  76. #define HDMI_VFRMT_1920x1080p30_16_9 33
  77. #define HDMI_VFRMT_2880x480p60_4_3 34
  78. #define HDMI_VFRMT_2880x480p60_16_9 35
  79. #define HDMI_VFRMT_2880x576p50_4_3 36
  80. #define HDMI_VFRMT_2880x576p50_16_9 37
  81. #define HDMI_VFRMT_1920x1250i50_16_9 38
  82. #define HDMI_VFRMT_1920x1080i100_16_9 39
  83. #define HDMI_VFRMT_1280x720p100_16_9 40
  84. #define HDMI_VFRMT_720x576p100_4_3 41
  85. #define HDMI_VFRMT_720x576p100_16_9 42
  86. #define HDMI_VFRMT_720x576i100_4_3 43
  87. #define HDMI_VFRMT_1440x576i100_4_3 HDMI_VFRMT_720x576i100_4_3
  88. #define HDMI_VFRMT_720x576i100_16_9 44
  89. #define HDMI_VFRMT_1440x576i100_16_9 HDMI_VFRMT_720x576i100_16_9
  90. #define HDMI_VFRMT_1920x1080i120_16_9 45
  91. #define HDMI_VFRMT_1280x720p120_16_9 46
  92. #define HDMI_VFRMT_720x480p120_4_3 47
  93. #define HDMI_VFRMT_720x480p120_16_9 48
  94. #define HDMI_VFRMT_720x480i120_4_3 49
  95. #define HDMI_VFRMT_1440x480i120_4_3 HDMI_VFRMT_720x480i120_4_3
  96. #define HDMI_VFRMT_720x480i120_16_9 50
  97. #define HDMI_VFRMT_1440x480i120_16_9 HDMI_VFRMT_720x480i120_16_9
  98. #define HDMI_VFRMT_720x576p200_4_3 51
  99. #define HDMI_VFRMT_720x576p200_16_9 52
  100. #define HDMI_VFRMT_720x576i200_4_3 53
  101. #define HDMI_VFRMT_1440x576i200_4_3 HDMI_VFRMT_720x576i200_4_3
  102. #define HDMI_VFRMT_720x576i200_16_9 54
  103. #define HDMI_VFRMT_1440x576i200_16_9 HDMI_VFRMT_720x576i200_16_9
  104. #define HDMI_VFRMT_720x480p240_4_3 55
  105. #define HDMI_VFRMT_720x480p240_16_9 56
  106. #define HDMI_VFRMT_720x480i240_4_3 57
  107. #define HDMI_VFRMT_1440x480i240_4_3 HDMI_VFRMT_720x480i240_4_3
  108. #define HDMI_VFRMT_720x480i240_16_9 58
  109. #define HDMI_VFRMT_1440x480i240_16_9 HDMI_VFRMT_720x480i240_16_9
  110. #define HDMI_VFRMT_FORCE_32BIT 0x7FFFFFFF
  111. /* Video Identification Codes from 65-127 are reserved for the future */
  112. #define HDMI_VFRMT_END 127
  113. /* VESA DMT TIMINGS */
  114. /* DMT ID: 23h, STD code: (81h, 80h), also a part of Established Timing III */
  115. #define HDMI_VFRMT_1280x1024p60_5_4 (HDMI_VFRMT_END + 1)
  116. #define DMT_VFRMT_END HDMI_VFRMT_1280x1024p60_5_4
  117. #define HDMI_VFRMT_MAX (DMT_VFRMT_END + 1)
  118. extern int ext_resolution;
  119. struct hdmi_disp_mode_timing_type {
  120. uint32 video_format;
  121. uint32 active_h;
  122. uint32 front_porch_h;
  123. uint32 pulse_width_h;
  124. uint32 back_porch_h;
  125. boolean active_low_h;
  126. uint32 active_v;
  127. uint32 front_porch_v;
  128. uint32 pulse_width_v;
  129. uint32 back_porch_v;
  130. boolean active_low_v;
  131. /* Must divide by 1000 to get the actual frequency in MHZ */
  132. uint32 pixel_freq;
  133. /* Must divide by 1000 to get the actual frequency in HZ */
  134. uint32 refresh_rate;
  135. boolean interlaced;
  136. boolean supported;
  137. };
  138. #define HDMI_SETTINGS_640x480p60_4_3 \
  139. {HDMI_VFRMT_640x480p60_4_3, 640, 16, 96, 48, TRUE, \
  140. 480, 10, 2, 33, TRUE, 25200, 60000, FALSE, TRUE}
  141. #define HDMI_SETTINGS_720x480p60_4_3 \
  142. {HDMI_VFRMT_720x480p60_4_3, 720, 16, 62, 60, TRUE, \
  143. 480, 9, 6, 30, TRUE, 27030, 60000, FALSE, TRUE}
  144. #define HDMI_SETTINGS_720x480p60_16_9 \
  145. {HDMI_VFRMT_720x480p60_16_9, 720, 16, 62, 60, TRUE, \
  146. 480, 9, 6, 30, TRUE, 27030, 60000, FALSE, TRUE}
  147. #define HDMI_SETTINGS_1280x720p60_16_9 \
  148. {HDMI_VFRMT_1280x720p60_16_9, 1280, 110, 40, 220, FALSE, \
  149. 720, 5, 5, 20, FALSE, 74250, 60000, FALSE, TRUE}
  150. #define HDMI_SETTINGS_1920x1080i60_16_9 \
  151. {HDMI_VFRMT_1920x1080i60_16_9, 1920, 88, 44, 148, FALSE, \
  152. 540, 2, 5, 5, FALSE, 74250, 60000, FALSE, TRUE}
  153. #define HDMI_SETTINGS_1440x480i60_4_3 \
  154. {HDMI_VFRMT_1440x480i60_4_3, 1440, 38, 124, 114, TRUE, \
  155. 240, 4, 3, 15, TRUE, 27000, 60000, TRUE, TRUE}
  156. #define HDMI_SETTINGS_1440x480i60_16_9 \
  157. {HDMI_VFRMT_1440x480i60_16_9, 1440, 38, 124, 114, TRUE, \
  158. 240, 4, 3, 15, TRUE, 27000, 60000, TRUE, TRUE}
  159. #define HDMI_SETTINGS_1920x1080p60_16_9 \
  160. {HDMI_VFRMT_1920x1080p60_16_9, 1920, 88, 44, 148, FALSE, \
  161. 1080, 4, 5, 36, FALSE, 148500, 60000, FALSE, TRUE}
  162. #define HDMI_SETTINGS_720x576p50_4_3 \
  163. {HDMI_VFRMT_720x576p50_4_3, 720, 12, 64, 68, TRUE, \
  164. 576, 5, 5, 39, TRUE, 27000, 50000, FALSE, TRUE}
  165. #define HDMI_SETTINGS_720x576p50_16_9 \
  166. {HDMI_VFRMT_720x576p50_16_9, 720, 12, 64, 68, TRUE, \
  167. 576, 5, 5, 39, TRUE, 27000, 50000, FALSE, TRUE}
  168. #define HDMI_SETTINGS_1280x720p50_16_9 \
  169. {HDMI_VFRMT_1280x720p50_16_9, 1280, 440, 40, 220, FALSE, \
  170. 720, 5, 5, 20, FALSE, 74250, 50000, FALSE, TRUE}
  171. #define HDMI_SETTINGS_1440x576i50_4_3 \
  172. {HDMI_VFRMT_1440x576i50_4_3, 1440, 24, 126, 138, TRUE, \
  173. 288, 2, 3, 19, TRUE, 27000, 50000, TRUE, TRUE}
  174. #define HDMI_SETTINGS_1440x576i50_16_9 \
  175. {HDMI_VFRMT_1440x576i50_16_9, 1440, 24, 126, 138, TRUE, \
  176. 288, 2, 3, 19, TRUE, 27000, 50000, TRUE, TRUE}
  177. #define HDMI_SETTINGS_1920x1080p50_16_9 \
  178. {HDMI_VFRMT_1920x1080p50_16_9, 1920, 528, 44, 148, FALSE, \
  179. 1080, 4, 5, 36, FALSE, 148500, 50000, FALSE, TRUE}
  180. #define HDMI_SETTINGS_1920x1080p24_16_9 \
  181. {HDMI_VFRMT_1920x1080p24_16_9, 1920, 638, 44, 148, FALSE, \
  182. 1080, 4, 5, 36, FALSE, 74250, 24000, FALSE, TRUE}
  183. #define HDMI_SETTINGS_1920x1080p25_16_9 \
  184. {HDMI_VFRMT_1920x1080p25_16_9, 1920, 528, 44, 148, FALSE, \
  185. 1080, 4, 5, 36, FALSE, 74250, 25000, FALSE, TRUE}
  186. #define HDMI_SETTINGS_1920x1080p30_16_9 \
  187. {HDMI_VFRMT_1920x1080p30_16_9, 1920, 88, 44, 148, FALSE, \
  188. 1080, 4, 5, 36, FALSE, 74250, 30000, FALSE, TRUE}
  189. #define HDMI_SETTINGS_1280x1024p60_5_4 \
  190. {HDMI_VFRMT_1280x1024p60_5_4, 1280, 48, 112, 248, FALSE, \
  191. 1024, 1, 3, 38, FALSE, 108000, 60000, FALSE, TRUE}
  192. /* A lookup table for all the supported display modes by the HDMI
  193. * hardware and driver. Use HDMI_SETUP_LUT in the module init to
  194. * setup the LUT with the supported modes. */
  195. extern struct hdmi_disp_mode_timing_type
  196. hdmi_common_supported_video_mode_lut[HDMI_VFRMT_MAX];
  197. /* Structure that encapsulates all the supported display modes by the HDMI sink
  198. * device */
  199. struct hdmi_disp_mode_list_type {
  200. uint32 disp_mode_list[HDMI_VFRMT_MAX];
  201. #define TOP_AND_BOTTOM 0x10
  202. #define FRAME_PACKING 0x20
  203. #define SIDE_BY_SIDE_HALF 0x40
  204. uint32 disp_3d_mode_list[HDMI_VFRMT_MAX];
  205. uint32 disp_multi_3d_mode_list[16];
  206. uint32 disp_multi_3d_mode_list_cnt;
  207. uint32 num_of_elements;
  208. };
  209. #endif
  210. /*
  211. * As per the CEA-861E spec, there can be a total of 10 short audio
  212. * descriptors with each SAD being 3 bytes long.
  213. * Thus, the maximum length of the audio data block would be 30 bytes
  214. */
  215. #define MAX_AUDIO_DATA_BLOCK_SIZE 30
  216. #define MAX_SPKR_ALLOC_DATA_BLOCK_SIZE 3
  217. struct external_common_state_type {
  218. boolean hpd_state;
  219. struct kobject *uevent_kobj;
  220. uint32 video_resolution;
  221. boolean default_res_supported;
  222. struct device *dev;
  223. struct switch_dev sdev;
  224. struct switch_dev audio_sdev;
  225. #ifdef CONFIG_FB_MSM_HDMI_3D
  226. boolean format_3d;
  227. void (*switch_3d)(boolean on);
  228. #endif
  229. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  230. boolean hdcp_active;
  231. boolean hpd_feature_on;
  232. boolean hdmi_sink;
  233. struct hdmi_disp_mode_list_type disp_mode_list;
  234. uint16 video_latency, audio_latency;
  235. uint16 physical_address;
  236. uint32 preferred_video_format;
  237. uint8 pt_scan_info;
  238. uint8 it_scan_info;
  239. uint8 ce_scan_info;
  240. uint8 spd_vendor_name[8];
  241. uint8 spd_product_description[16];
  242. boolean present_3d;
  243. boolean present_hdcp;
  244. uint8 audio_data_block[MAX_AUDIO_DATA_BLOCK_SIZE];
  245. int adb_size;
  246. uint8 spkr_alloc_data_block[MAX_SPKR_ALLOC_DATA_BLOCK_SIZE];
  247. int sadb_size;
  248. int (*read_edid_block)(int block, uint8 *edid_buf);
  249. int (*hpd_feature)(int on);
  250. #endif
  251. };
  252. /* The external interface driver needs to initialize the common state. */
  253. extern struct external_common_state_type *external_common_state;
  254. extern struct mutex external_common_state_hpd_mutex;
  255. extern struct mutex hdmi_msm_state_mutex;
  256. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  257. #define VFRMT_NOT_SUPPORTED(VFRMT) \
  258. {VFRMT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FALSE}
  259. #define HDMI_SETUP_LUT(MODE) do { \
  260. struct hdmi_disp_mode_timing_type mode \
  261. = HDMI_SETTINGS_ ## MODE; \
  262. hdmi_common_supported_video_mode_lut[mode.video_format] \
  263. = mode; \
  264. } while (0)
  265. int hdmi_common_read_edid(void);
  266. const char *video_format_2string(uint32 format);
  267. bool hdmi_common_get_video_format_from_drv_data(struct msm_fb_data_type *mfd);
  268. const struct hdmi_disp_mode_timing_type *hdmi_common_get_mode(uint32 mode);
  269. const struct hdmi_disp_mode_timing_type *hdmi_common_get_supported_mode(
  270. uint32 mode);
  271. const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_mode(uint32 mode);
  272. const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_supported_mode(
  273. uint32 mode);
  274. void hdmi_common_init_panel_info(struct msm_panel_info *pinfo);
  275. ssize_t video_3d_format_2string(uint32 format, char *buf);
  276. #endif
  277. int external_common_state_create(struct platform_device *pdev);
  278. void external_common_state_remove(void);
  279. #endif /* __EXTERNAL_COMMON_H__ */