external_common.c 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270
  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. #include <linux/types.h>
  14. #include <linux/bitops.h>
  15. #include <linux/mutex.h>
  16. /* #define DEBUG */
  17. #define DEV_DBG_PREFIX "EXT_COMMON: "
  18. /* The start of the data block collection within the CEA Extension Version 3 */
  19. #define DBC_START_OFFSET 4
  20. #include "msm_fb.h"
  21. #include "hdmi_msm.h"
  22. #include "external_common.h"
  23. #include "mhl_api.h"
  24. #include "mdp.h"
  25. struct external_common_state_type *external_common_state;
  26. EXPORT_SYMBOL(external_common_state);
  27. DEFINE_MUTEX(external_common_state_hpd_mutex);
  28. EXPORT_SYMBOL(external_common_state_hpd_mutex);
  29. static int atoi(const char *name)
  30. {
  31. int val = 0;
  32. for (;; name++) {
  33. switch (*name) {
  34. case '0' ... '9':
  35. val = 10*val+(*name-'0');
  36. break;
  37. default:
  38. return val;
  39. }
  40. }
  41. }
  42. #ifdef DEBUG_EDID
  43. /*
  44. * Block 0 - 1920x1080p, 1360x768p
  45. * Block 1 - 1280x720p, 1920x540i, 720x480p
  46. */
  47. const char edid_blk0[0x100] = {
  48. 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x4C, 0x2D, 0x03, 0x05, 0x00,
  49. 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78, 0x0A, 0xEE,
  50. 0x91, 0xA3, 0x54, 0x4C, 0x99, 0x26, 0x0F, 0x50, 0x54, 0xBD, 0xEF, 0x80, 0x71,
  51. 0x4F, 0x81, 0x00, 0x81, 0x40, 0x81, 0x80, 0x95, 0x00, 0x95, 0x0F, 0xB3, 0x00,
  52. 0xA9, 0x40, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C, 0x45,
  53. 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x66, 0x21, 0x50, 0xB0, 0x51, 0x00,
  54. 0x1B, 0x30, 0x40, 0x70, 0x36, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x00,
  55. 0x00, 0x00, 0xFD, 0x00, 0x18, 0x4B, 0x1A, 0x51, 0x17, 0x00, 0x0A, 0x20, 0x20,
  56. 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x53, 0x41, 0x4D, 0x53,
  57. 0x55, 0x4E, 0x47, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x8F};
  58. const char edid_blk1[0x100] = {
  59. 0x02, 0x03, 0x1E, 0xF1, 0x46, 0x90, 0x04, 0x05, 0x03, 0x20, 0x22, 0x23, 0x09,
  60. 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0xE2, 0x00, 0x0F, 0x67, 0x03, 0x0C, 0x00,
  61. 0x10, 0x00, 0xB8, 0x2D, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20, 0x6E,
  62. 0x28, 0x55, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x80, 0x18,
  63. 0x71, 0x1C, 0x16, 0x20, 0x58, 0x2C, 0x25, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00,
  64. 0x9E, 0x8C, 0x0A, 0xD0, 0x8A, 0x20, 0xE0, 0x2D, 0x10, 0x10, 0x3E, 0x96, 0x00,
  65. 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  66. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  67. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF};
  69. #endif /* DEBUG_EDID */
  70. #define DMA_E_BASE 0xB0000
  71. void mdp_vid_quant_set(void)
  72. {
  73. if ((external_common_state->video_resolution == \
  74. HDMI_VFRMT_720x480p60_4_3) || \
  75. (external_common_state->video_resolution == \
  76. HDMI_VFRMT_720x480p60_16_9)) {
  77. MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x70, 0x00EB0010);
  78. MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x74, 0x00EB0010);
  79. MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x78, 0x00EB0010);
  80. } else {
  81. MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x70, 0x00FF0000);
  82. MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x74, 0x00FF0000);
  83. MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x78, 0x00FF0000);
  84. }
  85. }
  86. const char *video_format_2string(uint32 format)
  87. {
  88. switch (format) {
  89. default:
  90. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  91. case HDMI_VFRMT_640x480p60_4_3: return " 640x 480 p60 4/3";
  92. case HDMI_VFRMT_720x480p60_4_3: return " 720x 480 p60 4/3";
  93. case HDMI_VFRMT_720x480p60_16_9: return " 720x 480 p60 16/9";
  94. case HDMI_VFRMT_1280x720p60_16_9: return "1280x 720 p60 16/9";
  95. case HDMI_VFRMT_1920x1080i60_16_9: return "1920x1080 i60 16/9";
  96. case HDMI_VFRMT_1440x480i60_4_3: return "1440x 480 i60 4/3";
  97. case HDMI_VFRMT_1440x480i60_16_9: return "1440x 480 i60 16/9";
  98. case HDMI_VFRMT_1440x240p60_4_3: return "1440x 240 p60 4/3";
  99. case HDMI_VFRMT_1440x240p60_16_9: return "1440x 240 p60 16/9";
  100. case HDMI_VFRMT_2880x480i60_4_3: return "2880x 480 i60 4/3";
  101. case HDMI_VFRMT_2880x480i60_16_9: return "2880x 480 i60 16/9";
  102. case HDMI_VFRMT_2880x240p60_4_3: return "2880x 240 p60 4/3";
  103. case HDMI_VFRMT_2880x240p60_16_9: return "2880x 240 p60 16/9";
  104. case HDMI_VFRMT_1440x480p60_4_3: return "1440x 480 p60 4/3";
  105. case HDMI_VFRMT_1440x480p60_16_9: return "1440x 480 p60 16/9";
  106. case HDMI_VFRMT_1920x1080p60_16_9: return "1920x1080 p60 16/9";
  107. case HDMI_VFRMT_720x576p50_4_3: return " 720x 576 p50 4/3";
  108. case HDMI_VFRMT_720x576p50_16_9: return " 720x 576 p50 16/9";
  109. case HDMI_VFRMT_1280x720p50_16_9: return "1280x 720 p50 16/9";
  110. case HDMI_VFRMT_1920x1080i50_16_9: return "1920x1080 i50 16/9";
  111. case HDMI_VFRMT_1440x576i50_4_3: return "1440x 576 i50 4/3";
  112. case HDMI_VFRMT_1440x576i50_16_9: return "1440x 576 i50 16/9";
  113. case HDMI_VFRMT_1440x288p50_4_3: return "1440x 288 p50 4/3";
  114. case HDMI_VFRMT_1440x288p50_16_9: return "1440x 288 p50 16/9";
  115. case HDMI_VFRMT_2880x576i50_4_3: return "2880x 576 i50 4/3";
  116. case HDMI_VFRMT_2880x576i50_16_9: return "2880x 576 i50 16/9";
  117. case HDMI_VFRMT_2880x288p50_4_3: return "2880x 288 p50 4/3";
  118. case HDMI_VFRMT_2880x288p50_16_9: return "2880x 288 p50 16/9";
  119. case HDMI_VFRMT_1440x576p50_4_3: return "1440x 576 p50 4/3";
  120. case HDMI_VFRMT_1440x576p50_16_9: return "1440x 576 p50 16/9";
  121. case HDMI_VFRMT_1920x1080p50_16_9: return "1920x1080 p50 16/9";
  122. case HDMI_VFRMT_1920x1080p24_16_9: return "1920x1080 p24 16/9";
  123. case HDMI_VFRMT_1920x1080p25_16_9: return "1920x1080 p25 16/9";
  124. case HDMI_VFRMT_1920x1080p30_16_9: return "1920x1080 p30 16/9";
  125. case HDMI_VFRMT_2880x480p60_4_3: return "2880x 480 p60 4/3";
  126. case HDMI_VFRMT_2880x480p60_16_9: return "2880x 480 p60 16/9";
  127. case HDMI_VFRMT_2880x576p50_4_3: return "2880x 576 p50 4/3";
  128. case HDMI_VFRMT_2880x576p50_16_9: return "2880x 576 p50 16/9";
  129. case HDMI_VFRMT_1920x1250i50_16_9: return "1920x1250 i50 16/9";
  130. case HDMI_VFRMT_1920x1080i100_16_9:return "1920x1080 i100 16/9";
  131. case HDMI_VFRMT_1280x720p100_16_9: return "1280x 720 p100 16/9";
  132. case HDMI_VFRMT_720x576p100_4_3: return " 720x 576 p100 4/3";
  133. case HDMI_VFRMT_720x576p100_16_9: return " 720x 576 p100 16/9";
  134. case HDMI_VFRMT_1440x576i100_4_3: return "1440x 576 i100 4/3";
  135. case HDMI_VFRMT_1440x576i100_16_9: return "1440x 576 i100 16/9";
  136. case HDMI_VFRMT_1920x1080i120_16_9:return "1920x1080 i120 16/9";
  137. case HDMI_VFRMT_1280x720p120_16_9: return "1280x 720 p120 16/9";
  138. case HDMI_VFRMT_720x480p120_4_3: return " 720x 480 p120 4/3";
  139. case HDMI_VFRMT_720x480p120_16_9: return " 720x 480 p120 16/9";
  140. case HDMI_VFRMT_1440x480i120_4_3: return "1440x 480 i120 4/3";
  141. case HDMI_VFRMT_1440x480i120_16_9: return "1440x 480 i120 16/9";
  142. case HDMI_VFRMT_720x576p200_4_3: return " 720x 576 p200 4/3";
  143. case HDMI_VFRMT_720x576p200_16_9: return " 720x 576 p200 16/9";
  144. case HDMI_VFRMT_1440x576i200_4_3: return "1440x 576 i200 4/3";
  145. case HDMI_VFRMT_1440x576i200_16_9: return "1440x 576 i200 16/9";
  146. case HDMI_VFRMT_720x480p240_4_3: return " 720x 480 p240 4/3";
  147. case HDMI_VFRMT_720x480p240_16_9: return " 720x 480 p240 16/9";
  148. case HDMI_VFRMT_1440x480i240_4_3: return "1440x 480 i240 4/3";
  149. case HDMI_VFRMT_1440x480i240_16_9: return "1440x 480 i240 16/9";
  150. #elif defined(CONFIG_FB_MSM_TVOUT)
  151. case TVOUT_VFRMT_NTSC_M_720x480i: return "NTSC_M_720x480i";
  152. case TVOUT_VFRMT_NTSC_J_720x480i: return "NTSC_J_720x480i";
  153. case TVOUT_VFRMT_PAL_BDGHIN_720x576i: return "PAL_BDGHIN_720x576i";
  154. case TVOUT_VFRMT_PAL_M_720x480i: return "PAL_M_720x480i";
  155. case TVOUT_VFRMT_PAL_N_720x480i: return "PAL_N_720x480i";
  156. #endif
  157. }
  158. }
  159. EXPORT_SYMBOL(video_format_2string);
  160. static ssize_t external_common_rda_video_mode_str(struct device *dev,
  161. struct device_attribute *attr, char *buf)
  162. {
  163. ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n",
  164. video_format_2string(external_common_state->video_resolution));
  165. DEV_DBG("%s: '%s'\n", __func__,
  166. video_format_2string(external_common_state->video_resolution));
  167. return ret;
  168. }
  169. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  170. struct hdmi_disp_mode_timing_type
  171. hdmi_common_supported_video_mode_lut[HDMI_VFRMT_MAX] = {
  172. HDMI_SETTINGS_640x480p60_4_3,
  173. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_4_3),
  174. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_16_9),
  175. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p60_16_9),
  176. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i60_16_9),
  177. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_4_3),
  178. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_16_9),
  179. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_4_3),
  180. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_16_9),
  181. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_4_3),
  182. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_16_9),
  183. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_4_3),
  184. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_16_9),
  185. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_4_3),
  186. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_16_9),
  187. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p60_16_9),
  188. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_4_3),
  189. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_16_9),
  190. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p50_16_9),
  191. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i50_16_9),
  192. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_4_3),
  193. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_16_9),
  194. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_4_3),
  195. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_16_9),
  196. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_4_3),
  197. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_16_9),
  198. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_4_3),
  199. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_16_9),
  200. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_4_3),
  201. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_16_9),
  202. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p50_16_9),
  203. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p24_16_9),
  204. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p25_16_9),
  205. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p30_16_9),
  206. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_4_3),
  207. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_16_9),
  208. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_4_3),
  209. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_16_9),
  210. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1250i50_16_9),
  211. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i100_16_9),
  212. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p100_16_9),
  213. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_4_3),
  214. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_16_9),
  215. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_4_3),
  216. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_16_9),
  217. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i120_16_9),
  218. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p120_16_9),
  219. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_4_3),
  220. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_16_9),
  221. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_4_3),
  222. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_16_9),
  223. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_4_3),
  224. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_16_9),
  225. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_4_3),
  226. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_16_9),
  227. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_4_3),
  228. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_16_9),
  229. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_4_3),
  230. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_16_9),
  231. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x1024p60_5_4)
  232. };
  233. EXPORT_SYMBOL(hdmi_common_supported_video_mode_lut);
  234. struct hdmi_disp_mode_timing_type
  235. hdmi_mhl_supported_video_mode_lut[HDMI_VFRMT_MAX] = {
  236. HDMI_SETTINGS_640x480p60_4_3,
  237. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_4_3),
  238. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_16_9),
  239. HDMI_SETTINGS_1280x720p60_16_9,
  240. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i60_16_9),
  241. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_4_3),
  242. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_16_9),
  243. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_4_3),
  244. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_16_9),
  245. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_4_3),
  246. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_16_9),
  247. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_4_3),
  248. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_16_9),
  249. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_4_3),
  250. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_16_9),
  251. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p60_16_9),
  252. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_4_3),
  253. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_16_9),
  254. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p50_16_9),
  255. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i50_16_9),
  256. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_4_3),
  257. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_16_9),
  258. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_4_3),
  259. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_16_9),
  260. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_4_3),
  261. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_16_9),
  262. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_4_3),
  263. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_16_9),
  264. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_4_3),
  265. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_16_9),
  266. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p50_16_9),
  267. HDMI_SETTINGS_1920x1080p24_16_9,
  268. HDMI_SETTINGS_1920x1080p25_16_9,
  269. HDMI_SETTINGS_1920x1080p30_16_9,
  270. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_4_3),
  271. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_16_9),
  272. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_4_3),
  273. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_16_9),
  274. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1250i50_16_9),
  275. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i100_16_9),
  276. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p100_16_9),
  277. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_4_3),
  278. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_16_9),
  279. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_4_3),
  280. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_16_9),
  281. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i120_16_9),
  282. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p120_16_9),
  283. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_4_3),
  284. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_16_9),
  285. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_4_3),
  286. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_16_9),
  287. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_4_3),
  288. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_16_9),
  289. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_4_3),
  290. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_16_9),
  291. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_4_3),
  292. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_16_9),
  293. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_4_3),
  294. VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_16_9),
  295. HDMI_SETTINGS_1280x1024p60_5_4
  296. };
  297. EXPORT_SYMBOL(hdmi_mhl_supported_video_mode_lut);
  298. static ssize_t hdmi_common_rda_edid_modes(struct device *dev,
  299. struct device_attribute *attr, char *buf)
  300. {
  301. ssize_t ret = 0;
  302. int i;
  303. buf[0] = 0;
  304. if (external_common_state->disp_mode_list.num_of_elements) {
  305. uint32 *video_mode = external_common_state->disp_mode_list
  306. .disp_mode_list;
  307. for (i = 0; i < external_common_state->disp_mode_list
  308. .num_of_elements; ++i) {
  309. if (ret > 0)
  310. ret += snprintf(buf+ret, PAGE_SIZE-ret, ",%d",
  311. *video_mode++ + 1);
  312. else
  313. ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d",
  314. *video_mode++ + 1);
  315. }
  316. } else
  317. ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d",
  318. external_common_state->video_resolution+1);
  319. DEV_DBG("%s: '%s'\n", __func__, buf);
  320. ret += snprintf(buf+ret, PAGE_SIZE-ret, "\n");
  321. return ret;
  322. }
  323. static ssize_t hdmi_common_rda_edid_physical_address(struct device *dev,
  324. struct device_attribute *attr, char *buf)
  325. {
  326. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  327. external_common_state->physical_address);
  328. DEV_DBG("%s: '%d'\n", __func__,
  329. external_common_state->physical_address);
  330. return ret;
  331. }
  332. static ssize_t hdmi_common_rda_edid_scan_info(struct device *dev,
  333. struct device_attribute *attr, char *buf)
  334. {
  335. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d, %d, %d\n",
  336. external_common_state->pt_scan_info,
  337. external_common_state->it_scan_info,
  338. external_common_state->ce_scan_info);
  339. DEV_DBG("%s: '%s'\n", __func__, buf);
  340. return ret;
  341. }
  342. static ssize_t hdmi_common_wta_vendor_name(struct device *dev,
  343. struct device_attribute *attr, const char *buf, size_t count)
  344. {
  345. uint8 *s = (uint8 *) buf;
  346. uint8 *d = external_common_state->spd_vendor_name;
  347. ssize_t ret = strnlen(buf, PAGE_SIZE);
  348. ret = (ret > 8) ? 8 : ret;
  349. memset(external_common_state->spd_vendor_name, 0, 8);
  350. while (*s) {
  351. if (*s & 0x60 && *s ^ 0x7f) {
  352. *d = *s;
  353. } else {
  354. /* stop copying if control character found */
  355. break;
  356. }
  357. if (++s > (uint8 *) (buf + ret))
  358. break;
  359. d++;
  360. }
  361. DEV_DBG("%s: '%s'\n", __func__,
  362. external_common_state->spd_vendor_name);
  363. return ret;
  364. }
  365. static ssize_t hdmi_common_rda_vendor_name(struct device *dev,
  366. struct device_attribute *attr, char *buf)
  367. {
  368. ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n",
  369. external_common_state->spd_vendor_name);
  370. DEV_DBG("%s: '%s'\n", __func__,
  371. external_common_state->spd_vendor_name);
  372. return ret;
  373. }
  374. static ssize_t hdmi_common_wta_product_description(struct device *dev,
  375. struct device_attribute *attr, const char *buf, size_t count)
  376. {
  377. uint8 *s = (uint8 *) buf;
  378. uint8 *d = external_common_state->spd_product_description;
  379. ssize_t ret = strnlen(buf, PAGE_SIZE);
  380. ret = (ret > 16) ? 16 : ret;
  381. memset(external_common_state->spd_product_description, 0, 16);
  382. while (*s) {
  383. if (*s & 0x60 && *s ^ 0x7f) {
  384. *d = *s;
  385. } else {
  386. /* stop copying if control character found */
  387. break;
  388. }
  389. if (++s > (uint8 *) (buf + ret))
  390. break;
  391. d++;
  392. }
  393. DEV_DBG("%s: '%s'\n", __func__,
  394. external_common_state->spd_product_description);
  395. return ret;
  396. }
  397. static ssize_t hdmi_common_rda_product_description(struct device *dev,
  398. struct device_attribute *attr, char *buf)
  399. {
  400. ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n",
  401. external_common_state->spd_product_description);
  402. DEV_DBG("%s: '%s'\n", __func__,
  403. external_common_state->spd_product_description);
  404. return ret;
  405. }
  406. static ssize_t hdmi_common_rda_edid_3d_modes(struct device *dev,
  407. struct device_attribute *attr, char *buf)
  408. {
  409. ssize_t ret = 0;
  410. int i;
  411. char buff_3d[128];
  412. buf[0] = 0;
  413. if (external_common_state->disp_mode_list.num_of_elements) {
  414. uint32 *video_mode = external_common_state->disp_mode_list
  415. .disp_mode_list;
  416. uint32 *video_3d_mode = external_common_state->disp_mode_list
  417. .disp_3d_mode_list;
  418. for (i = 0; i < external_common_state->disp_mode_list
  419. .num_of_elements; ++i) {
  420. video_3d_format_2string(*video_3d_mode++, buff_3d);
  421. if (ret > 0)
  422. ret += snprintf(buf+ret, PAGE_SIZE-ret,
  423. ",%d=%s",
  424. *video_mode++ + 1, buff_3d);
  425. else
  426. ret += snprintf(buf+ret, PAGE_SIZE-ret,
  427. "%d=%s",
  428. *video_mode++ + 1, buff_3d);
  429. }
  430. } else
  431. ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d",
  432. external_common_state->video_resolution+1);
  433. DEV_DBG("%s: '%s'\n", __func__, buf);
  434. ret += snprintf(buf+ret, PAGE_SIZE-ret, "\n");
  435. return ret;
  436. }
  437. static ssize_t hdmi_common_rda_hdcp(struct device *dev,
  438. struct device_attribute *attr, char *buf)
  439. {
  440. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  441. external_common_state->hdcp_active);
  442. DEV_DBG("%s: '%d'\n", __func__,
  443. external_common_state->hdcp_active);
  444. return ret;
  445. }
  446. static ssize_t hdmi_common_rda_hpd(struct device *dev,
  447. struct device_attribute *attr, char *buf)
  448. {
  449. ssize_t ret;
  450. if (external_common_state->hpd_feature) {
  451. ret = snprintf(buf, PAGE_SIZE, "%d\n",
  452. external_common_state->hpd_feature_on);
  453. DEV_DBG("%s: '%d'\n", __func__,
  454. external_common_state->hpd_feature_on);
  455. } else {
  456. ret = snprintf(buf, PAGE_SIZE, "-1\n");
  457. DEV_DBG("%s: 'not supported'\n", __func__);
  458. }
  459. return ret;
  460. }
  461. static ssize_t hdmi_common_wta_hpd(struct device *dev,
  462. struct device_attribute *attr, const char *buf, size_t count)
  463. {
  464. ssize_t ret = strnlen(buf, PAGE_SIZE);
  465. int hpd;
  466. if (hdmi_prim_display)
  467. hpd = 1;
  468. else
  469. hpd = atoi(buf);
  470. if (external_common_state->hpd_feature) {
  471. if (hpd == 0 && external_common_state->hpd_feature_on) {
  472. external_common_state->hpd_feature(0);
  473. external_common_state->hpd_feature_on = 0;
  474. DEV_DBG("%s: '%d'\n", __func__,
  475. external_common_state->hpd_feature_on);
  476. } else if (hpd == 1 && !external_common_state->hpd_feature_on) {
  477. external_common_state->hpd_feature(1);
  478. external_common_state->hpd_feature_on = 1;
  479. DEV_DBG("%s: '%d'\n", __func__,
  480. external_common_state->hpd_feature_on);
  481. } else {
  482. DEV_DBG("%s: '%d' (unchanged)\n", __func__,
  483. external_common_state->hpd_feature_on);
  484. }
  485. } else {
  486. DEV_DBG("%s: 'not supported'\n", __func__);
  487. }
  488. return ret;
  489. }
  490. #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
  491. /*
  492. * This interface for CEC feature is defined to suit
  493. * the current requirements. However, the actual functionality is
  494. * added to accommodate different interfaces
  495. */
  496. static ssize_t hdmi_msm_rda_cec(struct device *dev,
  497. struct device_attribute *attr, char *buf)
  498. {
  499. /* 0x028C CEC_CTRL */
  500. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  501. (HDMI_INP(0x028C) & BIT(0)));
  502. return ret;
  503. }
  504. static ssize_t hdmi_msm_wta_cec(struct device *dev,
  505. struct device_attribute *attr, const char *buf, size_t count)
  506. {
  507. ssize_t ret = strnlen(buf, PAGE_SIZE);
  508. int cec = atoi(buf);
  509. if (cec != 0) {
  510. mutex_lock(&hdmi_msm_state_mutex);
  511. hdmi_msm_state->cec_enabled = true;
  512. hdmi_msm_state->cec_logical_addr = 4;
  513. /* flush CEC queue */
  514. hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start;
  515. hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start;
  516. hdmi_msm_state->cec_queue_full = false;
  517. memset(hdmi_msm_state->cec_queue_rd, 0,
  518. sizeof(struct hdmi_msm_cec_msg)*CEC_QUEUE_SIZE);
  519. mutex_unlock(&hdmi_msm_state_mutex);
  520. hdmi_msm_cec_init();
  521. hdmi_msm_cec_write_logical_addr(
  522. hdmi_msm_state->cec_logical_addr);
  523. DEV_DBG("CEC enabled\n");
  524. } else {
  525. mutex_lock(&hdmi_msm_state_mutex);
  526. hdmi_msm_state->cec_enabled = false;
  527. hdmi_msm_state->cec_logical_addr = 15;
  528. mutex_unlock(&hdmi_msm_state_mutex);
  529. hdmi_msm_cec_write_logical_addr(
  530. hdmi_msm_state->cec_logical_addr);
  531. /* 0x028C CEC_CTRL */
  532. HDMI_OUTP(0x028C, 0);
  533. DEV_DBG("CEC disabled\n");
  534. }
  535. return ret;
  536. }
  537. static ssize_t hdmi_msm_rda_cec_logical_addr(struct device *dev,
  538. struct device_attribute *attr, char *buf)
  539. {
  540. ssize_t ret;
  541. mutex_lock(&hdmi_msm_state_mutex);
  542. ret = snprintf(buf, PAGE_SIZE, "%d\n",
  543. hdmi_msm_state->cec_logical_addr);
  544. mutex_unlock(&hdmi_msm_state_mutex);
  545. return ret;
  546. }
  547. static ssize_t hdmi_msm_wta_cec_logical_addr(struct device *dev,
  548. struct device_attribute *attr, const char *buf, size_t count)
  549. {
  550. #ifdef DRVR_ONLY_CECT_NO_DAEMON
  551. /*
  552. * Only for testing
  553. */
  554. hdmi_msm_cec_one_touch_play();
  555. return 0;
  556. #else
  557. ssize_t ret = strnlen(buf, PAGE_SIZE);
  558. int logical_addr = atoi(buf);
  559. if (logical_addr < 0 || logical_addr > 15)
  560. return -EINVAL;
  561. mutex_lock(&hdmi_msm_state_mutex);
  562. hdmi_msm_state->cec_logical_addr = logical_addr;
  563. mutex_unlock(&hdmi_msm_state_mutex);
  564. hdmi_msm_cec_write_logical_addr(logical_addr);
  565. return ret;
  566. #endif
  567. }
  568. static ssize_t hdmi_msm_rda_cec_frame(struct device *dev,
  569. struct device_attribute *attr, char *buf)
  570. {
  571. mutex_lock(&hdmi_msm_state_mutex);
  572. if (hdmi_msm_state->cec_queue_rd == hdmi_msm_state->cec_queue_wr
  573. && !hdmi_msm_state->cec_queue_full) {
  574. mutex_unlock(&hdmi_msm_state_mutex);
  575. DEV_ERR("CEC message queue is empty\n");
  576. return -EBUSY;
  577. }
  578. memcpy(buf, hdmi_msm_state->cec_queue_rd++,
  579. sizeof(struct hdmi_msm_cec_msg));
  580. hdmi_msm_state->cec_queue_full = false;
  581. if (hdmi_msm_state->cec_queue_rd == CEC_QUEUE_END)
  582. hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start;
  583. mutex_unlock(&hdmi_msm_state_mutex);
  584. return sizeof(struct hdmi_msm_cec_msg);
  585. }
  586. static ssize_t hdmi_msm_wta_cec_frame(struct device *dev,
  587. struct device_attribute *attr, const char *buf, size_t count)
  588. {
  589. int i;
  590. int retry = ((struct hdmi_msm_cec_msg *) buf)->retransmit;
  591. for (i = 0; i < RETRANSMIT_MAX_NUM; i++) {
  592. hdmi_msm_cec_msg_send((struct hdmi_msm_cec_msg *) buf);
  593. if (hdmi_msm_state->cec_frame_wr_status
  594. & CEC_STATUS_WR_ERROR && retry--) {
  595. mutex_lock(&hdmi_msm_state_mutex);
  596. if (hdmi_msm_state->fsm_reset_done)
  597. retry++;
  598. mutex_unlock(&hdmi_msm_state_mutex);
  599. msleep(20);
  600. } else
  601. break;
  602. }
  603. if (hdmi_msm_state->cec_frame_wr_status & CEC_STATUS_WR_DONE)
  604. return sizeof(struct hdmi_msm_cec_msg);
  605. else
  606. return -EINVAL;
  607. }
  608. #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
  609. static ssize_t hdmi_common_rda_3d_present(struct device *dev,
  610. struct device_attribute *attr, char *buf)
  611. {
  612. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  613. external_common_state->present_3d);
  614. DEV_DBG("%s: '%d'\n", __func__,
  615. external_common_state->present_3d);
  616. return ret;
  617. }
  618. static ssize_t hdmi_common_rda_hdcp_present(struct device *dev,
  619. struct device_attribute *attr, char *buf)
  620. {
  621. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  622. external_common_state->present_hdcp);
  623. DEV_DBG("%s: '%d'\n", __func__,
  624. external_common_state->present_hdcp);
  625. return ret;
  626. }
  627. #endif
  628. #ifdef CONFIG_FB_MSM_HDMI_3D
  629. static ssize_t hdmi_3d_rda_format_3d(struct device *dev,
  630. struct device_attribute *attr, char *buf)
  631. {
  632. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  633. external_common_state->format_3d);
  634. DEV_DBG("%s: '%d'\n", __func__,
  635. external_common_state->format_3d);
  636. return ret;
  637. }
  638. static ssize_t hdmi_3d_wta_format_3d(struct device *dev,
  639. struct device_attribute *attr, const char *buf, size_t count)
  640. {
  641. ssize_t ret = strnlen(buf, PAGE_SIZE);
  642. int format_3d = atoi(buf);
  643. if (format_3d >= 0 && format_3d <= 2) {
  644. if (format_3d != external_common_state->format_3d) {
  645. external_common_state->format_3d = format_3d;
  646. if (external_common_state->switch_3d)
  647. external_common_state->switch_3d(format_3d);
  648. DEV_DBG("%s: '%d'\n", __func__,
  649. external_common_state->format_3d);
  650. } else {
  651. DEV_DBG("%s: '%d' (unchanged)\n", __func__,
  652. external_common_state->format_3d);
  653. }
  654. } else {
  655. DEV_DBG("%s: '%d' (unknown)\n", __func__, format_3d);
  656. }
  657. return ret;
  658. }
  659. #endif
  660. #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
  661. static DEVICE_ATTR(cec, S_IRUGO | S_IWUSR,
  662. hdmi_msm_rda_cec,
  663. hdmi_msm_wta_cec);
  664. static DEVICE_ATTR(cec_logical_addr, S_IRUGO | S_IWUSR,
  665. hdmi_msm_rda_cec_logical_addr,
  666. hdmi_msm_wta_cec_logical_addr);
  667. static DEVICE_ATTR(cec_rd_frame, S_IRUGO,
  668. hdmi_msm_rda_cec_frame, NULL);
  669. static DEVICE_ATTR(cec_wr_frame, S_IWUSR,
  670. NULL, hdmi_msm_wta_cec_frame);
  671. #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
  672. static ssize_t external_common_rda_video_mode(struct device *dev,
  673. struct device_attribute *attr, char *buf)
  674. {
  675. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  676. external_common_state->video_resolution+1);
  677. DEV_DBG("%s: '%d'\n", __func__,
  678. external_common_state->video_resolution+1);
  679. return ret;
  680. }
  681. static ssize_t external_common_wta_video_mode(struct device *dev,
  682. struct device_attribute *attr, const char *buf, size_t count)
  683. {
  684. ssize_t ret = strnlen(buf, PAGE_SIZE);
  685. uint32 video_mode;
  686. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  687. const struct hdmi_disp_mode_timing_type *disp_mode;
  688. #endif
  689. mutex_lock(&external_common_state_hpd_mutex);
  690. if (!external_common_state->hpd_state) {
  691. mutex_unlock(&external_common_state_hpd_mutex);
  692. DEV_INFO("%s: FAILED: display off or cable disconnected\n",
  693. __func__);
  694. return ret;
  695. }
  696. mutex_unlock(&external_common_state_hpd_mutex);
  697. video_mode = atoi(buf)-1;
  698. DEV_INFO("%s: video_mode is %d\n", __func__, video_mode);
  699. kobject_uevent(external_common_state->uevent_kobj, KOBJ_OFFLINE);
  700. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  701. disp_mode = hdmi_common_get_supported_mode(video_mode);
  702. if (!disp_mode) {
  703. DEV_INFO("%s: FAILED: mode not supported (%d)\n",
  704. __func__, video_mode);
  705. return ret;
  706. }
  707. external_common_state->disp_mode_list.num_of_elements = 1;
  708. external_common_state->disp_mode_list.disp_mode_list[0] = video_mode;
  709. #elif defined(CONFIG_FB_MSM_TVOUT)
  710. external_common_state->video_resolution = video_mode;
  711. #endif
  712. DEV_DBG("%s: 'mode=%d %s' successful (sending OFF/ONLINE)\n", __func__,
  713. video_mode, video_format_2string(video_mode));
  714. kobject_uevent(external_common_state->uevent_kobj, KOBJ_ONLINE);
  715. return ret;
  716. }
  717. static ssize_t external_common_rda_connected(struct device *dev,
  718. struct device_attribute *attr, char *buf)
  719. {
  720. ssize_t ret;
  721. mutex_lock(&external_common_state_hpd_mutex);
  722. ret = snprintf(buf, PAGE_SIZE, "%d\n",
  723. external_common_state->hpd_state);
  724. DEV_DBG("%s: '%d'\n", __func__,
  725. external_common_state->hpd_state);
  726. mutex_unlock(&external_common_state_hpd_mutex);
  727. return ret;
  728. }
  729. static ssize_t external_common_rda_hdmi_mode(struct device *dev,
  730. struct device_attribute *attr, char *buf)
  731. {
  732. ssize_t ret;
  733. ret = snprintf(buf, PAGE_SIZE, "%d\n",
  734. external_common_state->hdmi_sink);
  735. DEV_DBG("%s: '%d'\n", __func__,
  736. external_common_state->hdmi_sink);
  737. return ret;
  738. }
  739. static ssize_t hdmi_common_rda_hdmi_primary(struct device *dev,
  740. struct device_attribute *attr, char *buf)
  741. {
  742. ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n",
  743. hdmi_prim_display);
  744. DEV_DBG("%s: '%d'\n", __func__, hdmi_prim_display);
  745. return ret;
  746. }
  747. static ssize_t hdmi_common_rda_audio_data_block(struct device *dev,
  748. struct device_attribute *attr, char *buf)
  749. {
  750. int adb_size = 0;
  751. int adb_count = 0;
  752. ssize_t ret = 0;
  753. char *data = buf;
  754. if (!external_common_state)
  755. return 0;
  756. adb_count = 1;
  757. adb_size = external_common_state->adb_size;
  758. ret = sizeof(adb_count) + sizeof(adb_size) + adb_size;
  759. if (ret > PAGE_SIZE) {
  760. DEV_DBG("%s: Insufficient buffer size\n", __func__);
  761. return 0;
  762. }
  763. /* Currently only extracting one audio data block */
  764. memcpy(data, &adb_count, sizeof(adb_count));
  765. data += sizeof(adb_count);
  766. memcpy(data, &adb_size, sizeof(adb_size));
  767. data += sizeof(adb_size);
  768. memcpy(data, external_common_state->audio_data_block,
  769. external_common_state->adb_size);
  770. print_hex_dump(KERN_DEBUG, "AUDIO DATA BLOCK: ", DUMP_PREFIX_NONE,
  771. 32, 8, buf, ret, false);
  772. return ret;
  773. }
  774. static ssize_t hdmi_common_rda_spkr_alloc_data_block(struct device *dev,
  775. struct device_attribute *attr, char *buf)
  776. {
  777. int sadb_size = 0;
  778. int sadb_count = 0;
  779. ssize_t ret = 0;
  780. char *data = buf;
  781. if (!external_common_state)
  782. return 0;
  783. sadb_count = 1;
  784. sadb_size = external_common_state->sadb_size;
  785. ret = sizeof(sadb_count) + sizeof(sadb_size) + sadb_size;
  786. if (ret > PAGE_SIZE) {
  787. DEV_DBG("%s: Insufficient buffer size\n", __func__);
  788. return 0;
  789. }
  790. /* Currently only extracting one speaker allocation data block */
  791. memcpy(data, &sadb_count, sizeof(sadb_count));
  792. data += sizeof(sadb_count);
  793. memcpy(data, &sadb_size, sizeof(sadb_size));
  794. data += sizeof(sadb_size);
  795. memcpy(data, external_common_state->spkr_alloc_data_block,
  796. external_common_state->sadb_size);
  797. print_hex_dump(KERN_DEBUG, "SPKR ALLOC DATA BLOCK: ", DUMP_PREFIX_NONE,
  798. 32, 8, buf, ret, false);
  799. return ret;
  800. }
  801. static DEVICE_ATTR(video_mode, S_IRUGO | S_IWUGO,
  802. external_common_rda_video_mode, external_common_wta_video_mode);
  803. static DEVICE_ATTR(video_mode_str, S_IRUGO, external_common_rda_video_mode_str,
  804. NULL);
  805. static DEVICE_ATTR(connected, S_IRUGO, external_common_rda_connected, NULL);
  806. static DEVICE_ATTR(hdmi_mode, S_IRUGO, external_common_rda_hdmi_mode, NULL);
  807. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  808. static DEVICE_ATTR(edid_modes, S_IRUGO, hdmi_common_rda_edid_modes, NULL);
  809. static DEVICE_ATTR(hpd, S_IRUGO | S_IWUGO, hdmi_common_rda_hpd,
  810. hdmi_common_wta_hpd);
  811. static DEVICE_ATTR(hdcp, S_IRUGO, hdmi_common_rda_hdcp, NULL);
  812. static DEVICE_ATTR(pa, S_IRUGO,
  813. hdmi_common_rda_edid_physical_address, NULL);
  814. static DEVICE_ATTR(scan_info, S_IRUGO,
  815. hdmi_common_rda_edid_scan_info, NULL);
  816. static DEVICE_ATTR(vendor_name, S_IRUGO | S_IWUSR, hdmi_common_rda_vendor_name,
  817. hdmi_common_wta_vendor_name);
  818. static DEVICE_ATTR(product_description, S_IRUGO | S_IWUSR,
  819. hdmi_common_rda_product_description,
  820. hdmi_common_wta_product_description);
  821. static DEVICE_ATTR(edid_3d_modes, S_IRUGO,
  822. hdmi_common_rda_edid_3d_modes, NULL);
  823. static DEVICE_ATTR(3d_present, S_IRUGO, hdmi_common_rda_3d_present, NULL);
  824. static DEVICE_ATTR(hdcp_present, S_IRUGO, hdmi_common_rda_hdcp_present, NULL);
  825. #endif
  826. #ifdef CONFIG_FB_MSM_HDMI_3D
  827. static DEVICE_ATTR(format_3d, S_IRUGO | S_IWUGO, hdmi_3d_rda_format_3d,
  828. hdmi_3d_wta_format_3d);
  829. #endif
  830. static DEVICE_ATTR(hdmi_primary, S_IRUGO, hdmi_common_rda_hdmi_primary, NULL);
  831. static DEVICE_ATTR(audio_data_block, S_IRUGO, hdmi_common_rda_audio_data_block,
  832. NULL);
  833. static DEVICE_ATTR(spkr_alloc_data_block, S_IRUGO,
  834. hdmi_common_rda_spkr_alloc_data_block, NULL);
  835. static struct attribute *external_common_fs_attrs[] = {
  836. &dev_attr_video_mode.attr,
  837. &dev_attr_video_mode_str.attr,
  838. &dev_attr_connected.attr,
  839. &dev_attr_hdmi_mode.attr,
  840. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  841. &dev_attr_edid_modes.attr,
  842. &dev_attr_hdcp.attr,
  843. &dev_attr_hpd.attr,
  844. &dev_attr_pa.attr,
  845. &dev_attr_scan_info.attr,
  846. &dev_attr_vendor_name.attr,
  847. &dev_attr_product_description.attr,
  848. &dev_attr_edid_3d_modes.attr,
  849. &dev_attr_3d_present.attr,
  850. &dev_attr_hdcp_present.attr,
  851. #endif
  852. #ifdef CONFIG_FB_MSM_HDMI_3D
  853. &dev_attr_format_3d.attr,
  854. #endif
  855. #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
  856. &dev_attr_cec.attr,
  857. &dev_attr_cec_logical_addr.attr,
  858. &dev_attr_cec_rd_frame.attr,
  859. &dev_attr_cec_wr_frame.attr,
  860. #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
  861. &dev_attr_hdmi_primary.attr,
  862. &dev_attr_audio_data_block.attr,
  863. &dev_attr_spkr_alloc_data_block.attr,
  864. NULL,
  865. };
  866. static struct attribute_group external_common_fs_attr_group = {
  867. .attrs = external_common_fs_attrs,
  868. };
  869. /* create external interface kobject and initialize */
  870. int external_common_state_create(struct platform_device *pdev)
  871. {
  872. int rc;
  873. struct msm_fb_data_type *mfd = platform_get_drvdata(pdev);
  874. if (!mfd) {
  875. DEV_ERR("%s: mfd not found\n", __func__);
  876. return -ENODEV;
  877. }
  878. if (!mfd->fbi) {
  879. DEV_ERR("%s: mfd->fbi not found\n", __func__);
  880. return -ENODEV;
  881. }
  882. if (!mfd->fbi->dev) {
  883. DEV_ERR("%s: mfd->fbi->dev not found\n", __func__);
  884. return -ENODEV;
  885. }
  886. rc = sysfs_create_group(&mfd->fbi->dev->kobj,
  887. &external_common_fs_attr_group);
  888. if (rc) {
  889. DEV_ERR("%s: sysfs group creation failed, rc=%d\n", __func__,
  890. rc);
  891. return rc;
  892. }
  893. external_common_state->uevent_kobj = &mfd->fbi->dev->kobj;
  894. DEV_ERR("%s: sysfs group %pK\n", __func__,
  895. external_common_state->uevent_kobj);
  896. kobject_uevent(external_common_state->uevent_kobj, KOBJ_ADD);
  897. DEV_DBG("%s: kobject_uevent(KOBJ_ADD)\n", __func__);
  898. return 0;
  899. }
  900. EXPORT_SYMBOL(external_common_state_create);
  901. void external_common_state_remove(void)
  902. {
  903. if (external_common_state->uevent_kobj)
  904. sysfs_remove_group(external_common_state->uevent_kobj,
  905. &external_common_fs_attr_group);
  906. external_common_state->uevent_kobj = NULL;
  907. }
  908. EXPORT_SYMBOL(external_common_state_remove);
  909. #ifdef CONFIG_FB_MSM_HDMI_COMMON
  910. /* The Logic ID for HDMI TX Core. Currently only support 1 HDMI TX Core. */
  911. struct hdmi_edid_video_mode_property_type {
  912. uint32 video_code;
  913. uint32 active_h;
  914. uint32 active_v;
  915. boolean interlaced;
  916. uint32 total_h;
  917. uint32 total_blank_h;
  918. uint32 total_v;
  919. uint32 total_blank_v;
  920. /* Must divide by 1000 to get the frequency */
  921. uint32 freq_h;
  922. /* Must divide by 1000 to get the frequency */
  923. uint32 freq_v;
  924. /* Must divide by 1000 to get the frequency */
  925. uint32 pixel_freq;
  926. /* Must divide by 1000 to get the frequency */
  927. uint32 refresh_rate;
  928. boolean aspect_ratio_4_3;
  929. };
  930. /* LUT is sorted from lowest Active H to highest Active H - ease searching */
  931. static struct hdmi_edid_video_mode_property_type
  932. hdmi_edid_disp_mode_lut[] = {
  933. /* All 640 H Active */
  934. {HDMI_VFRMT_640x480p60_4_3, 640, 480, FALSE, 800, 160, 525, 45,
  935. 31465, 59940, 25175, 59940, TRUE},
  936. {HDMI_VFRMT_640x480p60_4_3, 640, 480, FALSE, 800, 160, 525, 45,
  937. 31500, 60000, 25200, 60000, TRUE},
  938. /* All 720 H Active */
  939. {HDMI_VFRMT_720x576p50_4_3, 720, 576, FALSE, 864, 144, 625, 49,
  940. 31250, 50000, 27000, 50000, TRUE},
  941. {HDMI_VFRMT_720x480p60_4_3, 720, 480, FALSE, 858, 138, 525, 45,
  942. 31465, 59940, 27000, 59940, TRUE},
  943. {HDMI_VFRMT_720x480p60_4_3, 720, 480, FALSE, 858, 138, 525, 45,
  944. 31500, 60000, 27030, 60000, TRUE},
  945. {HDMI_VFRMT_720x576p100_4_3, 720, 576, FALSE, 864, 144, 625, 49,
  946. 62500, 100000, 54000, 100000, TRUE},
  947. {HDMI_VFRMT_720x480p120_4_3, 720, 480, FALSE, 858, 138, 525, 45,
  948. 62937, 119880, 54000, 119880, TRUE},
  949. {HDMI_VFRMT_720x480p120_4_3, 720, 480, FALSE, 858, 138, 525, 45,
  950. 63000, 120000, 54054, 120000, TRUE},
  951. {HDMI_VFRMT_720x576p200_4_3, 720, 576, FALSE, 864, 144, 625, 49,
  952. 125000, 200000, 108000, 200000, TRUE},
  953. {HDMI_VFRMT_720x480p240_4_3, 720, 480, FALSE, 858, 138, 525, 45,
  954. 125874, 239760, 108000, 239000, TRUE},
  955. {HDMI_VFRMT_720x480p240_4_3, 720, 480, FALSE, 858, 138, 525, 45,
  956. 126000, 240000, 108108, 240000, TRUE},
  957. /* All 1280 H Active */
  958. {HDMI_VFRMT_1280x720p50_16_9, 1280, 720, FALSE, 1980, 700, 750, 30,
  959. 37500, 50000, 74250, 50000, FALSE},
  960. {HDMI_VFRMT_1280x720p60_16_9, 1280, 720, FALSE, 1650, 370, 750, 30,
  961. 44955, 59940, 74176, 59940, FALSE},
  962. {HDMI_VFRMT_1280x720p60_16_9, 1280, 720, FALSE, 1650, 370, 750, 30,
  963. 45000, 60000, 74250, 60000, FALSE},
  964. {HDMI_VFRMT_1280x720p100_16_9, 1280, 720, FALSE, 1980, 700, 750, 30,
  965. 75000, 100000, 148500, 100000, FALSE},
  966. {HDMI_VFRMT_1280x720p120_16_9, 1280, 720, FALSE, 1650, 370, 750, 30,
  967. 89909, 119880, 148352, 119880, FALSE},
  968. {HDMI_VFRMT_1280x720p120_16_9, 1280, 720, FALSE, 1650, 370, 750, 30,
  969. 90000, 120000, 148500, 120000, FALSE},
  970. {HDMI_VFRMT_1280x1024p60_5_4, 1280, 1024, FALSE, 1688, 408, 1066, 42,
  971. 63981, 60020, 108000, 60000, FALSE},
  972. /* All 1440 H Active */
  973. {HDMI_VFRMT_1440x576i50_4_3, 1440, 576, TRUE, 1728, 288, 625, 24,
  974. 15625, 50000, 27000, 50000, TRUE},
  975. {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 312, 24,
  976. 15625, 50080, 27000, 50000, TRUE},
  977. {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 313, 25,
  978. 15625, 49920, 27000, 50000, TRUE},
  979. {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 314, 26,
  980. 15625, 49761, 27000, 50000, TRUE},
  981. {HDMI_VFRMT_1440x576p50_4_3, 1440, 576, FALSE, 1728, 288, 625, 49,
  982. 31250, 50000, 54000, 50000, TRUE},
  983. {HDMI_VFRMT_1440x480i60_4_3, 1440, 480, TRUE, 1716, 276, 525, 22,
  984. 15734, 59940, 27000, 59940, TRUE},
  985. {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 262, 22,
  986. 15734, 60054, 27000, 59940, TRUE},
  987. {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 263, 23,
  988. 15734, 59826, 27000, 59940, TRUE},
  989. {HDMI_VFRMT_1440x480p60_4_3, 1440, 480, FALSE, 1716, 276, 525, 45,
  990. 31469, 59940, 54000, 59940, TRUE},
  991. {HDMI_VFRMT_1440x480i60_4_3, 1440, 480, TRUE, 1716, 276, 525, 22,
  992. 15750, 60000, 27027, 60000, TRUE},
  993. {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 262, 22,
  994. 15750, 60115, 27027, 60000, TRUE},
  995. {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 263, 23,
  996. 15750, 59886, 27027, 60000, TRUE},
  997. {HDMI_VFRMT_1440x480p60_4_3, 1440, 480, FALSE, 1716, 276, 525, 45,
  998. 31500, 60000, 54054, 60000, TRUE},
  999. {HDMI_VFRMT_1440x576i100_4_3, 1440, 576, TRUE, 1728, 288, 625, 24,
  1000. 31250, 100000, 54000, 100000, TRUE},
  1001. {HDMI_VFRMT_1440x480i120_4_3, 1440, 480, TRUE, 1716, 276, 525, 22,
  1002. 31469, 119880, 54000, 119880, TRUE},
  1003. {HDMI_VFRMT_1440x480i120_4_3, 1440, 480, TRUE, 1716, 276, 525, 22,
  1004. 31500, 120000, 54054, 120000, TRUE},
  1005. {HDMI_VFRMT_1440x576i200_4_3, 1440, 576, TRUE, 1728, 288, 625, 24,
  1006. 62500, 200000, 108000, 200000, TRUE},
  1007. {HDMI_VFRMT_1440x480i240_4_3, 1440, 480, TRUE, 1716, 276, 525, 22,
  1008. 62937, 239760, 108000, 239000, TRUE},
  1009. {HDMI_VFRMT_1440x480i240_4_3, 1440, 480, TRUE, 1716, 276, 525, 22,
  1010. 63000, 240000, 108108, 240000, TRUE},
  1011. /* All 1920 H Active */
  1012. {HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, FALSE, 2200, 280, 1125,
  1013. 45, 67433, 59940, 148352, 59940, FALSE},
  1014. {HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, TRUE, 2200, 280, 1125,
  1015. 45, 67500, 60000, 148500, 60000, FALSE},
  1016. {HDMI_VFRMT_1920x1080p50_16_9, 1920, 1080, FALSE, 2640, 720, 1125,
  1017. 45, 56250, 50000, 148500, 50000, FALSE},
  1018. {HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, FALSE, 2750, 830, 1125,
  1019. 45, 26973, 23976, 74176, 24000, FALSE},
  1020. {HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, FALSE, 2750, 830, 1125,
  1021. 45, 27000, 24000, 74250, 24000, FALSE},
  1022. {HDMI_VFRMT_1920x1080p25_16_9, 1920, 1080, FALSE, 2640, 720, 1125,
  1023. 45, 28125, 25000, 74250, 25000, FALSE},
  1024. {HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, FALSE, 2200, 280, 1125,
  1025. 45, 33716, 29970, 74176, 30000, FALSE},
  1026. {HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, FALSE, 2200, 280, 1125,
  1027. 45, 33750, 30000, 74250, 30000, FALSE},
  1028. {HDMI_VFRMT_1920x1080i50_16_9, 1920, 1080, TRUE, 2304, 384, 1250,
  1029. 85, 31250, 50000, 72000, 50000, FALSE},
  1030. {HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, TRUE, 2200, 280, 1125,
  1031. 22, 33716, 59940, 74176, 59940, FALSE},
  1032. {HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, TRUE, 2200, 280, 1125,
  1033. 22, 33750, 60000, 74250, 60000, FALSE},
  1034. {HDMI_VFRMT_1920x1080i100_16_9, 1920, 1080, TRUE, 2640, 720, 1125,
  1035. 22, 56250, 100000, 148500, 100000, FALSE},
  1036. {HDMI_VFRMT_1920x1080i120_16_9, 1920, 1080, TRUE, 2200, 280, 1125,
  1037. 22, 67432, 119880, 148352, 119980, FALSE},
  1038. {HDMI_VFRMT_1920x1080i120_16_9, 1920, 1080, TRUE, 2200, 280, 1125,
  1039. 22, 67500, 120000, 148500, 120000, FALSE},
  1040. /* All 2880 H Active */
  1041. {HDMI_VFRMT_2880x576i50_4_3, 2880, 576, TRUE, 3456, 576, 625, 24,
  1042. 15625, 50000, 54000, 50000, TRUE},
  1043. {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 312, 24,
  1044. 15625, 50080, 54000, 50000, TRUE},
  1045. {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 313, 25,
  1046. 15625, 49920, 54000, 50000, TRUE},
  1047. {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 314, 26,
  1048. 15625, 49761, 54000, 50000, TRUE},
  1049. {HDMI_VFRMT_2880x576p50_4_3, 2880, 576, FALSE, 3456, 576, 625, 49,
  1050. 31250, 50000, 108000, 50000, TRUE},
  1051. {HDMI_VFRMT_2880x480i60_4_3, 2880, 480, TRUE, 3432, 552, 525, 22,
  1052. 15734, 59940, 54000, 59940, TRUE},
  1053. {HDMI_VFRMT_2880x240p60_4_3, 2880, 480, FALSE, 3432, 552, 262, 22,
  1054. 15734, 60054, 54000, 59940, TRUE},
  1055. {HDMI_VFRMT_2880x240p60_4_3, 2880, 480, FALSE, 3432, 552, 263, 23,
  1056. 15734, 59940, 54000, 59940, TRUE},
  1057. {HDMI_VFRMT_2880x480p60_4_3, 2880, 480, FALSE, 3432, 552, 525, 45,
  1058. 31469, 59940, 108000, 59940, TRUE},
  1059. {HDMI_VFRMT_2880x480i60_4_3, 2880, 480, TRUE, 3432, 552, 525, 22,
  1060. 15750, 60000, 54054, 60000, TRUE},
  1061. {HDMI_VFRMT_2880x240p60_4_3, 2880, 240, FALSE, 3432, 552, 262, 22,
  1062. 15750, 60115, 54054, 60000, TRUE},
  1063. {HDMI_VFRMT_2880x240p60_4_3, 2880, 240, FALSE, 3432, 552, 262, 23,
  1064. 15750, 59886, 54054, 60000, TRUE},
  1065. {HDMI_VFRMT_2880x480p60_4_3, 2880, 480, FALSE, 3432, 552, 525, 45,
  1066. 31500, 60000, 108108, 60000, TRUE},
  1067. };
  1068. static const uint8 *hdmi_edid_find_block(const uint8 *in_buf,
  1069. uint32 start_offset, uint8 type, uint8 *len)
  1070. {
  1071. /* the start of data block collection, start of Video Data Block */
  1072. uint32 offset = start_offset;
  1073. uint32 end_dbc_offset = in_buf[2];
  1074. *len = 0;
  1075. /*edid buffer 1, byte 2 being 4 means no non-DTD/Data block collection
  1076. present.
  1077. edid buffer 1, byte 2 being 0 menas no non-DTD/DATA block collection
  1078. present and no DTD data present.*/
  1079. if ((end_dbc_offset == 0) || (end_dbc_offset == 4)) {
  1080. DEV_WARN("EDID: no DTD or non-DTD data present\n");
  1081. return NULL;
  1082. }
  1083. while (offset < end_dbc_offset) {
  1084. uint8 block_len = in_buf[offset] & 0x1F;
  1085. if ((in_buf[offset] >> 5) == type) {
  1086. *len = block_len;
  1087. DEV_DBG("EDID: block=%d found @ %d with length=%d\n",
  1088. type, offset, block_len);
  1089. return in_buf+offset;
  1090. }
  1091. offset += 1 + block_len;
  1092. }
  1093. DEV_WARN("EDID: type=%d block not found in EDID block\n", type);
  1094. return NULL;
  1095. }
  1096. static void hdmi_edid_extract_vendor_id(const uint8 *in_buf,
  1097. char *vendor_id)
  1098. {
  1099. uint32 id_codes = ((uint32)in_buf[8] << 8) + in_buf[9];
  1100. vendor_id[0] = 'A' - 1 + ((id_codes >> 10) & 0x1F);
  1101. vendor_id[1] = 'A' - 1 + ((id_codes >> 5) & 0x1F);
  1102. vendor_id[2] = 'A' - 1 + (id_codes & 0x1F);
  1103. vendor_id[3] = 0;
  1104. }
  1105. static uint32 hdmi_edid_extract_ieee_reg_id(const uint8 *in_buf)
  1106. {
  1107. uint8 len;
  1108. const uint8 *vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3,
  1109. &len);
  1110. if (vsd == NULL)
  1111. return 0;
  1112. DEV_DBG("EDID: VSD PhyAddr=%04x, MaxTMDS=%dMHz\n",
  1113. ((uint32)vsd[4] << 8) + (uint32)vsd[5], (uint32)vsd[7] * 5);
  1114. external_common_state->physical_address =
  1115. ((uint16)vsd[4] << 8) + (uint16)vsd[5];
  1116. return ((uint32)vsd[3] << 16) + ((uint32)vsd[2] << 8) + (uint32)vsd[1];
  1117. }
  1118. #define HDMI_VSDB_3D_DATA_OFFSET(vsd) \
  1119. (!((vsd)[8] & BIT(7)) ? 9 : (!((vsd)[8] & BIT(6)) ? 11 : 13))
  1120. static void hdmi_edid_extract_3d_present(const uint8 *in_buf)
  1121. {
  1122. uint8 len, offset;
  1123. const uint8 *vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3,
  1124. &len);
  1125. external_common_state->present_3d = 0;
  1126. if (vsd == NULL || len < 9) {
  1127. DEV_DBG("EDID[3D]: block-id 3 not found or not long enough\n");
  1128. return;
  1129. }
  1130. offset = HDMI_VSDB_3D_DATA_OFFSET(vsd);
  1131. DEV_DBG("EDID: 3D present @ %d = %02x\n", offset, vsd[offset]);
  1132. if (vsd[offset] >> 7) { /* 3D format indication present */
  1133. DEV_INFO("EDID: 3D present, 3D-len=%d\n", vsd[offset+1] & 0x1F);
  1134. external_common_state->present_3d = 1;
  1135. }
  1136. }
  1137. static void hdmi_edid_extract_latency_fields(const uint8 *in_buf)
  1138. {
  1139. uint8 len;
  1140. const uint8 *vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3,
  1141. &len);
  1142. if (vsd == NULL || len < 12 || !(vsd[8] & BIT(7))) {
  1143. external_common_state->video_latency = (uint16)-1;
  1144. external_common_state->audio_latency = (uint16)-1;
  1145. DEV_DBG("EDID: No audio/video latency present\n");
  1146. } else {
  1147. external_common_state->video_latency = vsd[9];
  1148. external_common_state->audio_latency = vsd[10];
  1149. DEV_DBG("EDID: video-latency=%04x, audio-latency=%04x\n",
  1150. external_common_state->video_latency,
  1151. external_common_state->audio_latency);
  1152. }
  1153. }
  1154. static void hdmi_edid_extract_speaker_allocation_data(const uint8 *in_buf)
  1155. {
  1156. uint8 len;
  1157. const uint8 *sadb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 4,
  1158. &len);
  1159. if (sadb == NULL)
  1160. return;
  1161. if (len != MAX_SPKR_ALLOC_DATA_BLOCK_SIZE)
  1162. return;
  1163. memcpy(external_common_state->spkr_alloc_data_block, sadb + 1, len);
  1164. external_common_state->sadb_size = len;
  1165. }
  1166. static void hdmi_edid_extract_audio_data_blocks(const uint8 *in_buf)
  1167. {
  1168. uint8 len;
  1169. const uint8 *adb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 1,
  1170. &len);
  1171. if (external_common_state->audio_data_block == NULL)
  1172. return;
  1173. if (len > MAX_AUDIO_DATA_BLOCK_SIZE)
  1174. return;
  1175. memcpy(external_common_state->audio_data_block, adb + 1, len);
  1176. external_common_state->adb_size = len;
  1177. }
  1178. static void hdmi_edid_extract_extended_data_blocks(const uint8 *in_buf)
  1179. {
  1180. uint8 len = 0;
  1181. uint32 start_offset = DBC_START_OFFSET;
  1182. /* A Tage code of 7 identifies extended data blocks */
  1183. uint8 const *etag = hdmi_edid_find_block(in_buf, start_offset, 7, &len);
  1184. while (etag != NULL) {
  1185. /* The extended data block should at least be 2 bytes long */
  1186. if (len < 2) {
  1187. DEV_DBG("EDID: Found an extended data block of length"
  1188. "less than 2 bytes. Ignoring ...\n");
  1189. } else {
  1190. /*
  1191. * The second byte of the extended data block has the
  1192. * extended tag code
  1193. */
  1194. switch (etag[1]) {
  1195. case 0:
  1196. /* Video Capability Data Block */
  1197. DEV_DBG("EDID: VCDB=%02X %02X\n", etag[1],
  1198. etag[2]);
  1199. /*
  1200. * Check if the sink specifies underscan
  1201. * support for:
  1202. * BIT 5: preferred video format
  1203. * BIT 3: IT video format
  1204. * BIT 1: CE video format
  1205. */
  1206. external_common_state->pt_scan_info = (etag[2] &
  1207. (BIT(4) | BIT(5))) >> 4;
  1208. external_common_state->it_scan_info = (etag[2] &
  1209. (BIT(3) | BIT(2))) >> 2;
  1210. external_common_state->ce_scan_info = etag[2] &
  1211. (BIT(1) | BIT(0));
  1212. DEV_DBG("EDID: Scan Information (pt|it|ce): "
  1213. "(%d|%d|%d)",
  1214. external_common_state->pt_scan_info,
  1215. external_common_state->it_scan_info,
  1216. external_common_state->ce_scan_info);
  1217. break;
  1218. default:
  1219. DEV_DBG("EDID: Extend Tag Code %d not"
  1220. "supported\n", etag[1]);
  1221. break;
  1222. }
  1223. }
  1224. /* There could be more that one extended data block */
  1225. start_offset = etag - in_buf + len + 1;
  1226. etag = hdmi_edid_find_block(in_buf, start_offset, 7, &len);
  1227. }
  1228. }
  1229. static void hdmi_edid_detail_desc(const uint8 *data_buf, uint32 *disp_mode)
  1230. {
  1231. boolean aspect_ratio_4_3 = FALSE;
  1232. boolean interlaced = FALSE;
  1233. uint32 active_h = 0;
  1234. uint32 active_v = 0;
  1235. uint32 blank_h = 0;
  1236. uint32 blank_v = 0;
  1237. uint32 ndx = 0;
  1238. uint32 max_num_of_elements = 0;
  1239. uint32 img_size_h = 0;
  1240. uint32 img_size_v = 0;
  1241. /* See VESA Spec */
  1242. /* EDID_TIMING_DESC_UPPER_H_NIBBLE[0x4]: Relative Offset to the EDID
  1243. * detailed timing descriptors - Upper 4 bit for each H active/blank
  1244. * field */
  1245. /* EDID_TIMING_DESC_H_ACTIVE[0x2]: Relative Offset to the EDID detailed
  1246. * timing descriptors - H active */
  1247. active_h = ((((uint32)data_buf[0x4] >> 0x4) & 0xF) << 8)
  1248. | data_buf[0x2];
  1249. /* EDID_TIMING_DESC_H_BLANK[0x3]: Relative Offset to the EDID detailed
  1250. * timing descriptors - H blank */
  1251. blank_h = (((uint32)data_buf[0x4] & 0xF) << 8)
  1252. | data_buf[0x3];
  1253. /* EDID_TIMING_DESC_UPPER_V_NIBBLE[0x7]: Relative Offset to the EDID
  1254. * detailed timing descriptors - Upper 4 bit for each V active/blank
  1255. * field */
  1256. /* EDID_TIMING_DESC_V_ACTIVE[0x5]: Relative Offset to the EDID detailed
  1257. * timing descriptors - V active */
  1258. active_v = ((((uint32)data_buf[0x7] >> 0x4) & 0xF) << 8)
  1259. | data_buf[0x5];
  1260. /* EDID_TIMING_DESC_V_BLANK[0x6]: Relative Offset to the EDID detailed
  1261. * timing descriptors - V blank */
  1262. blank_v = (((uint32)data_buf[0x7] & 0xF) << 8)
  1263. | data_buf[0x6];
  1264. /* EDID_TIMING_DESC_IMAGE_SIZE_UPPER_NIBBLE[0xE]: Relative Offset to the
  1265. * EDID detailed timing descriptors - Image Size upper nibble
  1266. * V and H */
  1267. /* EDID_TIMING_DESC_H_IMAGE_SIZE[0xC]: Relative Offset to the EDID
  1268. * detailed timing descriptors - H image size */
  1269. /* EDID_TIMING_DESC_V_IMAGE_SIZE[0xD]: Relative Offset to the EDID
  1270. * detailed timing descriptors - V image size */
  1271. img_size_h = ((((uint32)data_buf[0xE] >> 0x4) & 0xF) << 8)
  1272. | data_buf[0xC];
  1273. img_size_v = (((uint32)data_buf[0xE] & 0xF) << 8)
  1274. | data_buf[0xD];
  1275. /*
  1276. * aspect ratio as 4:3 if within specificed range , rathaer than being
  1277. * absolute value
  1278. */
  1279. aspect_ratio_4_3 = (abs(img_size_h * 3 - img_size_v * 4) < 5) ? 1 : 0;
  1280. max_num_of_elements = sizeof(hdmi_edid_disp_mode_lut)
  1281. / sizeof(*hdmi_edid_disp_mode_lut);
  1282. /* EDID_TIMING_DESC_INTERLACE[0x11:7]: Relative Offset to the EDID
  1283. * detailed timing descriptors - Interlace flag */
  1284. DEV_DBG("Interlaced mode byte data_buf[0x11]=[%x]\n", data_buf[0x11]);
  1285. /*
  1286. * CEA 861-D: interlaced bit is bit[7] of byte[0x11]
  1287. */
  1288. interlaced = (data_buf[0x11] & 0x80) >> 7;
  1289. DEV_DBG("%s: A[%ux%u] B[%ux%u] V[%ux%u] %s\n", __func__,
  1290. active_h, active_v, blank_h, blank_v, img_size_h, img_size_v,
  1291. interlaced ? "i" : "p");
  1292. *disp_mode = HDMI_VFRMT_FORCE_32BIT;
  1293. while (ndx < max_num_of_elements) {
  1294. const struct hdmi_edid_video_mode_property_type *edid =
  1295. hdmi_edid_disp_mode_lut+ndx;
  1296. if ((interlaced == edid->interlaced) &&
  1297. (active_h == edid->active_h) &&
  1298. (blank_h == edid->total_blank_h) &&
  1299. (blank_v == edid->total_blank_v) &&
  1300. ((active_v == edid->active_v) ||
  1301. (active_v == (edid->active_v + 1)))
  1302. ) {
  1303. if (edid->aspect_ratio_4_3 && !aspect_ratio_4_3)
  1304. /* Aspect ratio 16:9 */
  1305. *disp_mode = edid->video_code + 1;
  1306. else
  1307. /* Aspect ratio 4:3 */
  1308. *disp_mode = edid->video_code;
  1309. DEV_DBG("%s: mode found:%d\n", __func__, *disp_mode);
  1310. break;
  1311. }
  1312. ++ndx;
  1313. }
  1314. if (ndx == max_num_of_elements)
  1315. DEV_INFO("%s: *no mode* found\n", __func__);
  1316. }
  1317. static void add_supported_video_format(
  1318. struct hdmi_disp_mode_list_type *disp_mode_list,
  1319. uint32 video_format)
  1320. {
  1321. const struct hdmi_disp_mode_timing_type *timing;
  1322. boolean supported = false;
  1323. boolean mhl_supported = true;
  1324. if (video_format >= HDMI_VFRMT_MAX)
  1325. return;
  1326. timing = hdmi_common_get_supported_mode(video_format);
  1327. supported = timing != NULL;
  1328. DEV_DBG("EDID: format: %d [%s], %s\n",
  1329. video_format, video_format_2string(video_format),
  1330. supported ? "Supported" : "Not-Supported");
  1331. if (mhl_is_enabled()) {
  1332. const struct hdmi_disp_mode_timing_type *mhl_timing =
  1333. hdmi_mhl_get_supported_mode(video_format);
  1334. mhl_supported = mhl_timing != NULL;
  1335. DEV_DBG("EDID: format: %d [%s], %s by MHL\n",
  1336. video_format, video_format_2string(video_format),
  1337. mhl_supported ? "Supported" : "Not-Supported");
  1338. }
  1339. if (supported && mhl_supported) {
  1340. disp_mode_list->disp_mode_list[
  1341. disp_mode_list->num_of_elements++] = video_format;
  1342. if (video_format == external_common_state->video_resolution) {
  1343. DEV_DBG("%s: Default resolution %d [%s] supported\n",
  1344. __func__, video_format,
  1345. video_format_2string(video_format));
  1346. external_common_state->default_res_supported = true;
  1347. }
  1348. }
  1349. }
  1350. const char *single_video_3d_format_2string(uint32 format)
  1351. {
  1352. switch (format) {
  1353. case TOP_AND_BOTTOM: return "TAB";
  1354. case FRAME_PACKING: return "FP";
  1355. case SIDE_BY_SIDE_HALF: return "SSH";
  1356. }
  1357. return "";
  1358. }
  1359. ssize_t video_3d_format_2string(uint32 format, char *buf)
  1360. {
  1361. ssize_t ret, len = 0;
  1362. ret = snprintf(buf, PAGE_SIZE, "%s",
  1363. single_video_3d_format_2string(format & FRAME_PACKING));
  1364. len += ret;
  1365. if (len && (format & TOP_AND_BOTTOM))
  1366. ret = snprintf(buf + len, PAGE_SIZE - len, ":%s",
  1367. single_video_3d_format_2string(
  1368. format & TOP_AND_BOTTOM));
  1369. else
  1370. ret = snprintf(buf + len, PAGE_SIZE - len, "%s",
  1371. single_video_3d_format_2string(
  1372. format & TOP_AND_BOTTOM));
  1373. len += ret;
  1374. if (len && (format & SIDE_BY_SIDE_HALF))
  1375. ret = snprintf(buf + len, PAGE_SIZE - len, ":%s",
  1376. single_video_3d_format_2string(
  1377. format & SIDE_BY_SIDE_HALF));
  1378. else
  1379. ret = snprintf(buf + len, PAGE_SIZE - len, "%s",
  1380. single_video_3d_format_2string(
  1381. format & SIDE_BY_SIDE_HALF));
  1382. len += ret;
  1383. return len;
  1384. }
  1385. static void add_supported_3d_format(
  1386. struct hdmi_disp_mode_list_type *disp_mode_list,
  1387. uint32 video_format,
  1388. uint32 video_3d_format)
  1389. {
  1390. char string[128];
  1391. boolean added = FALSE;
  1392. int i;
  1393. for (i = 0; i < disp_mode_list->num_of_elements; ++i) {
  1394. if (disp_mode_list->disp_mode_list[i] == video_format) {
  1395. disp_mode_list->disp_3d_mode_list[i] |=
  1396. video_3d_format;
  1397. added = TRUE;
  1398. break;
  1399. }
  1400. }
  1401. video_3d_format_2string(video_3d_format, string);
  1402. DEV_DBG("EDID[3D]: format: %d [%s], %s %s\n",
  1403. video_format, video_format_2string(video_format),
  1404. string, added ? "added" : "NOT added");
  1405. }
  1406. static void hdmi_edid_get_display_vsd_3d_mode(const uint8 *data_buf,
  1407. struct hdmi_disp_mode_list_type *disp_mode_list,
  1408. uint32 num_og_cea_blocks)
  1409. {
  1410. uint8 len, offset, present_multi_3d, hdmi_vic_len;
  1411. int hdmi_3d_len;
  1412. uint16 structure_all, structure_mask;
  1413. const uint8 *vsd = num_og_cea_blocks ?
  1414. hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET,
  1415. 3, &len) : NULL;
  1416. int i;
  1417. offset = HDMI_VSDB_3D_DATA_OFFSET(vsd);
  1418. present_multi_3d = (vsd[offset] & 0x60) >> 5;
  1419. offset += 1;
  1420. hdmi_vic_len = (vsd[offset] >> 5) & 0x7;
  1421. hdmi_3d_len = vsd[offset] & 0x1F;
  1422. DEV_DBG("EDID[3D]: HDMI_VIC_LEN = %d, HDMI_3D_LEN = %d\n",
  1423. hdmi_vic_len, hdmi_3d_len);
  1424. offset += (hdmi_vic_len + 1);
  1425. if (present_multi_3d == 1 || present_multi_3d == 2) {
  1426. DEV_DBG("EDID[3D]: multi 3D present (%d)\n", present_multi_3d);
  1427. /* 3d_structure_all */
  1428. structure_all = (vsd[offset] << 8) | vsd[offset + 1];
  1429. offset += 2;
  1430. hdmi_3d_len -= 2;
  1431. if (present_multi_3d == 2) {
  1432. /* 3d_structure_mask */
  1433. structure_mask = (vsd[offset] << 8) | vsd[offset + 1];
  1434. offset += 2;
  1435. hdmi_3d_len -= 2;
  1436. } else
  1437. structure_mask = 0xffff;
  1438. i = 0;
  1439. while (i < 16) {
  1440. if (i >= disp_mode_list->disp_multi_3d_mode_list_cnt)
  1441. break;
  1442. if (!(structure_mask & BIT(i))) {
  1443. ++i;
  1444. continue;
  1445. }
  1446. /* BIT0: FRAME PACKING */
  1447. if (structure_all & BIT(0))
  1448. add_supported_3d_format(disp_mode_list,
  1449. disp_mode_list->
  1450. disp_multi_3d_mode_list[i],
  1451. FRAME_PACKING);
  1452. /* BIT6: TOP AND BOTTOM */
  1453. if (structure_all & BIT(6))
  1454. add_supported_3d_format(disp_mode_list,
  1455. disp_mode_list->
  1456. disp_multi_3d_mode_list[i],
  1457. TOP_AND_BOTTOM);
  1458. /* BIT8: SIDE BY SIDE HALF */
  1459. if (structure_all & BIT(8))
  1460. add_supported_3d_format(disp_mode_list,
  1461. disp_mode_list->
  1462. disp_multi_3d_mode_list[i],
  1463. SIDE_BY_SIDE_HALF);
  1464. ++i;
  1465. }
  1466. }
  1467. i = 0;
  1468. while (hdmi_3d_len > 0) {
  1469. DEV_DBG("EDID[3D]: 3D_Structure_%d @ %d: %02x\n",
  1470. i + 1, offset, vsd[offset]);
  1471. if ((vsd[offset] >> 4) >=
  1472. disp_mode_list->disp_multi_3d_mode_list_cnt) {
  1473. if ((vsd[offset] & 0x0F) >= 8) {
  1474. offset += 1;
  1475. hdmi_3d_len -= 1;
  1476. DEV_DBG("EDID[3D]: 3D_Detail_%d @ %d: %02x\n",
  1477. i + 1, offset, vsd[offset]);
  1478. }
  1479. i += 1;
  1480. offset += 1;
  1481. hdmi_3d_len -= 1;
  1482. continue;
  1483. }
  1484. switch (vsd[offset] & 0x0F) {
  1485. case 0:
  1486. /* 0000b: FRAME PACKING */
  1487. add_supported_3d_format(disp_mode_list,
  1488. disp_mode_list->disp_multi_3d_mode_list
  1489. [vsd[offset] >> 4],
  1490. FRAME_PACKING);
  1491. break;
  1492. case 6:
  1493. /* 0110b: TOP AND BOTTOM */
  1494. add_supported_3d_format(disp_mode_list,
  1495. disp_mode_list->disp_multi_3d_mode_list
  1496. [vsd[offset] >> 4],
  1497. TOP_AND_BOTTOM);
  1498. break;
  1499. case 8:
  1500. /* 1000b: SIDE BY SIDE HALF */
  1501. add_supported_3d_format(disp_mode_list,
  1502. disp_mode_list->disp_multi_3d_mode_list
  1503. [vsd[offset] >> 4],
  1504. SIDE_BY_SIDE_HALF);
  1505. break;
  1506. }
  1507. if ((vsd[offset] & 0x0F) >= 8) {
  1508. offset += 1;
  1509. hdmi_3d_len -= 1;
  1510. DEV_DBG("EDID[3D]: 3D_Detail_%d @ %d: %02x\n",
  1511. i + 1, offset, vsd[offset]);
  1512. }
  1513. i += 1;
  1514. offset += 1;
  1515. hdmi_3d_len -= 1;
  1516. }
  1517. }
  1518. static void hdmi_edid_get_display_mode(const uint8 *data_buf,
  1519. struct hdmi_disp_mode_list_type *disp_mode_list,
  1520. uint32 num_og_cea_blocks)
  1521. {
  1522. uint8 i = 0, offset = 0, std_blk = 0;
  1523. uint32 video_format = HDMI_VFRMT_640x480p60_4_3;
  1524. boolean has480p = FALSE;
  1525. uint8 len;
  1526. const uint8 *edid_blk0 = &data_buf[0x0];
  1527. const uint8 *edid_blk1 = &data_buf[0x80];
  1528. const uint8 *svd = num_og_cea_blocks ?
  1529. hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET,
  1530. 2, &len) : NULL;
  1531. boolean has60hz_mode = FALSE;
  1532. boolean has50hz_mode = FALSE;
  1533. disp_mode_list->num_of_elements = 0;
  1534. disp_mode_list->disp_multi_3d_mode_list_cnt = 0;
  1535. if (svd != NULL) {
  1536. ++svd;
  1537. for (i = 0; i < len; ++i, ++svd) {
  1538. /* Subtract 1 because it is zero based in the driver,
  1539. * while the Video identification code is 1 based in the
  1540. * CEA_861D spec */
  1541. video_format = (*svd & 0x7F) - 1;
  1542. add_supported_video_format(disp_mode_list,
  1543. video_format);
  1544. /* Make a note of the preferred video format */
  1545. if (i == 0) {
  1546. external_common_state->preferred_video_format =
  1547. video_format;
  1548. }
  1549. if (i < 16) {
  1550. disp_mode_list->disp_multi_3d_mode_list[i]
  1551. = video_format;
  1552. disp_mode_list->disp_multi_3d_mode_list_cnt++;
  1553. }
  1554. if (video_format <= HDMI_VFRMT_1920x1080p60_16_9 ||
  1555. video_format == HDMI_VFRMT_2880x480p60_4_3 ||
  1556. video_format == HDMI_VFRMT_2880x480p60_16_9)
  1557. has60hz_mode = TRUE;
  1558. if ((video_format >= HDMI_VFRMT_720x576p50_4_3 &&
  1559. video_format <= HDMI_VFRMT_1920x1080p50_16_9) ||
  1560. video_format == HDMI_VFRMT_2880x576p50_4_3 ||
  1561. video_format == HDMI_VFRMT_2880x576p50_16_9 ||
  1562. video_format == HDMI_VFRMT_1920x1250i50_16_9)
  1563. has50hz_mode = TRUE;
  1564. if (video_format == HDMI_VFRMT_640x480p60_4_3)
  1565. has480p = TRUE;
  1566. }
  1567. } else if (!num_og_cea_blocks) {
  1568. /* Detailed timing descriptors */
  1569. uint32 desc_offset = 0;
  1570. /* Maximum 4 timing descriptor in block 0 - No CEA
  1571. * extension in this case */
  1572. /* EDID_FIRST_TIMING_DESC[0x36] - 1st detailed timing
  1573. * descriptor */
  1574. /* EDID_DETAIL_TIMING_DESC_BLCK_SZ[0x12] - Each detailed timing
  1575. * descriptor has block size of 18 */
  1576. while (4 > i && 0 != edid_blk0[0x36+desc_offset]) {
  1577. hdmi_edid_detail_desc(edid_blk0+0x36+desc_offset,
  1578. &video_format);
  1579. DEV_DBG("[%s:%d] Block-0 Adding vid fmt = [%s]\n",
  1580. __func__, __LINE__,
  1581. video_format_2string(video_format));
  1582. add_supported_video_format(disp_mode_list,
  1583. video_format);
  1584. if (video_format == HDMI_VFRMT_640x480p60_4_3)
  1585. has480p = TRUE;
  1586. /* Make a note of the preferred video format */
  1587. if (i == 0) {
  1588. external_common_state->preferred_video_format =
  1589. video_format;
  1590. }
  1591. desc_offset += 0x12;
  1592. ++i;
  1593. }
  1594. } else if (1 == num_og_cea_blocks) {
  1595. uint32 desc_offset = 0;
  1596. /*
  1597. * Read from both block 0 and block 1
  1598. * Read EDID block[0] as above
  1599. */
  1600. while (4 > i && 0 != edid_blk0[0x36+desc_offset]) {
  1601. hdmi_edid_detail_desc(edid_blk0+0x36+desc_offset,
  1602. &video_format);
  1603. DEV_DBG("[%s:%d] Block-0 Adding vid fmt = [%s]\n",
  1604. __func__, __LINE__,
  1605. video_format_2string(video_format));
  1606. add_supported_video_format(disp_mode_list,
  1607. video_format);
  1608. if (video_format == HDMI_VFRMT_640x480p60_4_3)
  1609. has480p = TRUE;
  1610. /* Make a note of the preferred video format */
  1611. if (i == 0) {
  1612. external_common_state->preferred_video_format =
  1613. video_format;
  1614. }
  1615. desc_offset += 0x12;
  1616. ++i;
  1617. }
  1618. /* Parse block 1 - CEA extension byte offset of first
  1619. * detailed timing generation - offset is relevant to
  1620. * the offset of block 1 */
  1621. /* EDID_CEA_EXTENSION_FIRST_DESC[0x82]: Offset to CEA
  1622. * extension first timing desc - indicate the offset of
  1623. * the first detailed timing descriptor */
  1624. /* EDID_BLOCK_SIZE = 0x80 Each page size in the EDID ROM */
  1625. desc_offset = edid_blk1[0x02];
  1626. while (0 != edid_blk1[desc_offset]) {
  1627. hdmi_edid_detail_desc(edid_blk1+desc_offset,
  1628. &video_format);
  1629. DEV_DBG("[%s:%d] Block-1 Adding vid fmt = [%s]\n",
  1630. __func__, __LINE__,
  1631. video_format_2string(video_format));
  1632. add_supported_video_format(disp_mode_list,
  1633. video_format);
  1634. if (video_format == HDMI_VFRMT_640x480p60_4_3)
  1635. has480p = TRUE;
  1636. /* Make a note of the preferred video format */
  1637. if (i == 0) {
  1638. external_common_state->preferred_video_format =
  1639. video_format;
  1640. }
  1641. desc_offset += 0x12;
  1642. ++i;
  1643. }
  1644. }
  1645. /*
  1646. * Check SD Timings if it contains 1280x1024@60Hz.
  1647. * SD Timing can be max 8 with 2 byte in size.
  1648. */
  1649. std_blk = 0;
  1650. offset = 0;
  1651. while (std_blk < 8) {
  1652. if ((edid_blk0[0x26 + offset] == 0x81) &&
  1653. (edid_blk0[0x26 + offset + 1] == 0x80)) {
  1654. add_supported_video_format(disp_mode_list,
  1655. HDMI_VFRMT_1280x1024p60_5_4);
  1656. break;
  1657. } else {
  1658. offset += 2;
  1659. }
  1660. std_blk++;
  1661. }
  1662. /* check if the EDID revision is 4 (version 1.4) */
  1663. if (edid_blk0[0x13] == 4) {
  1664. uint8 start = 0x36;
  1665. i = 0;
  1666. /* Check each of 4 - 18 bytes descriptors */
  1667. while (i < 4) {
  1668. uint8 itrate = start;
  1669. uint32 header_1 = 0;
  1670. uint8 header_2 = 0;
  1671. /*
  1672. * First 5 bytes are header.
  1673. * If they match 0x000000F700, it means its an
  1674. * established Timing III descriptor.
  1675. */
  1676. header_1 = edid_blk0[itrate++];
  1677. header_1 = header_1 << 8 | edid_blk0[itrate++];
  1678. header_1 = header_1 << 8 | edid_blk0[itrate++];
  1679. header_1 = header_1 << 8 | edid_blk0[itrate++];
  1680. header_2 = edid_blk0[itrate];
  1681. if (header_1 == 0x000000F7 &&
  1682. header_2 == 0x00) {
  1683. itrate++; /* VESA DMT Standard Version (0x0A)*/
  1684. itrate++; /* First set of supported formats */
  1685. itrate++; /* Second set of supported formats */
  1686. /* BIT(1) indicates 1280x1024@60Hz */
  1687. if (edid_blk0[itrate] & 0x02) {
  1688. add_supported_video_format(
  1689. disp_mode_list,
  1690. HDMI_VFRMT_1280x1024p60_5_4);
  1691. break;
  1692. }
  1693. }
  1694. i++;
  1695. start += 0x12;
  1696. }
  1697. }
  1698. /* mandaroty 3d format */
  1699. if (external_common_state->present_3d) {
  1700. if (has60hz_mode) {
  1701. add_supported_3d_format(disp_mode_list,
  1702. HDMI_VFRMT_1920x1080p24_16_9,
  1703. FRAME_PACKING | TOP_AND_BOTTOM);
  1704. add_supported_3d_format(disp_mode_list,
  1705. HDMI_VFRMT_1280x720p60_16_9,
  1706. FRAME_PACKING | TOP_AND_BOTTOM);
  1707. add_supported_3d_format(disp_mode_list,
  1708. HDMI_VFRMT_1920x1080i60_16_9,
  1709. SIDE_BY_SIDE_HALF);
  1710. }
  1711. if (has50hz_mode) {
  1712. add_supported_3d_format(disp_mode_list,
  1713. HDMI_VFRMT_1920x1080p24_16_9,
  1714. FRAME_PACKING | TOP_AND_BOTTOM);
  1715. add_supported_3d_format(disp_mode_list,
  1716. HDMI_VFRMT_1280x720p50_16_9,
  1717. FRAME_PACKING | TOP_AND_BOTTOM);
  1718. add_supported_3d_format(disp_mode_list,
  1719. HDMI_VFRMT_1920x1080i50_16_9,
  1720. SIDE_BY_SIDE_HALF);
  1721. }
  1722. /* 3d format described in Vendor Specific Data */
  1723. hdmi_edid_get_display_vsd_3d_mode(data_buf, disp_mode_list,
  1724. num_og_cea_blocks);
  1725. }
  1726. if (!has480p)
  1727. /* Need to add default 640 by 480 timings, in case not described
  1728. * in the EDID structure.
  1729. * All DTV sink devices should support this mode */
  1730. add_supported_video_format(disp_mode_list,
  1731. HDMI_VFRMT_640x480p60_4_3);
  1732. }
  1733. static int hdmi_common_read_edid_block(int block, uint8 *edid_buf)
  1734. {
  1735. uint32 ndx, check_sum, print_len;
  1736. #ifdef DEBUG
  1737. const u8 *b = edid_buf;
  1738. #endif
  1739. int status = external_common_state->read_edid_block(block, edid_buf);
  1740. if (status)
  1741. goto error;
  1742. /* Calculate checksum */
  1743. check_sum = 0;
  1744. for (ndx = 0; ndx < 0x80; ++ndx)
  1745. check_sum += edid_buf[ndx];
  1746. if (check_sum & 0xFF) {
  1747. DEV_ERR("%s: failed CHECKSUM (read:%x, expected:%x)\n",
  1748. __func__, (uint8)edid_buf[0x7F], (uint8)check_sum);
  1749. #ifdef DEBUG
  1750. for (ndx = 0; ndx < 0x100; ndx += 16)
  1751. DEV_DBG("EDID[%02x-%02x] %02x %02x %02x %02x "
  1752. "%02x %02x %02x %02x %02x %02x %02x %02x "
  1753. "%02x %02x %02x %02x\n", ndx, ndx+15,
  1754. b[ndx+0], b[ndx+1], b[ndx+2], b[ndx+3],
  1755. b[ndx+4], b[ndx+5], b[ndx+6], b[ndx+7],
  1756. b[ndx+8], b[ndx+9], b[ndx+10], b[ndx+11],
  1757. b[ndx+12], b[ndx+13], b[ndx+14], b[ndx+15]);
  1758. #endif
  1759. status = -EPROTO;
  1760. goto error;
  1761. }
  1762. print_len = 0x80;
  1763. for (ndx = 0; ndx < print_len; ndx += 16)
  1764. DEV_DBG("EDID[%02x-%02x] %02x %02x %02x %02x "
  1765. "%02x %02x %02x %02x %02x %02x %02x %02x "
  1766. "%02x %02x %02x %02x\n", ndx, ndx+15,
  1767. b[ndx+0], b[ndx+1], b[ndx+2], b[ndx+3],
  1768. b[ndx+4], b[ndx+5], b[ndx+6], b[ndx+7],
  1769. b[ndx+8], b[ndx+9], b[ndx+10], b[ndx+11],
  1770. b[ndx+12], b[ndx+13], b[ndx+14], b[ndx+15]);
  1771. error:
  1772. return status;
  1773. }
  1774. static boolean check_edid_header(const uint8 *edid_buf)
  1775. {
  1776. return (edid_buf[0] == 0x00) && (edid_buf[1] == 0xff)
  1777. && (edid_buf[2] == 0xff) && (edid_buf[3] == 0xff)
  1778. && (edid_buf[4] == 0xff) && (edid_buf[5] == 0xff)
  1779. && (edid_buf[6] == 0xff) && (edid_buf[7] == 0x00);
  1780. }
  1781. int hdmi_common_read_edid(void)
  1782. {
  1783. int status = 0;
  1784. uint32 cea_extension_ver = 0;
  1785. uint32 num_og_cea_blocks = 0;
  1786. uint32 ieee_reg_id = 0;
  1787. uint32 i = 1;
  1788. char vendor_id[5];
  1789. /* EDID_BLOCK_SIZE[0x80] Each page size in the EDID ROM */
  1790. uint8 edid_buf[0x80 * 4];
  1791. external_common_state->pt_scan_info = 0;
  1792. external_common_state->it_scan_info = 0;
  1793. external_common_state->ce_scan_info = 0;
  1794. external_common_state->preferred_video_format = 0;
  1795. external_common_state->present_3d = 0;
  1796. memset(&external_common_state->disp_mode_list, 0,
  1797. sizeof(external_common_state->disp_mode_list));
  1798. memset(edid_buf, 0, sizeof(edid_buf));
  1799. external_common_state->default_res_supported = false;
  1800. memset(external_common_state->audio_data_block, 0,
  1801. sizeof(external_common_state->audio_data_block));
  1802. memset(external_common_state->spkr_alloc_data_block, 0,
  1803. sizeof(external_common_state->spkr_alloc_data_block));
  1804. external_common_state->adb_size = 0;
  1805. external_common_state->sadb_size = 0;
  1806. status = hdmi_common_read_edid_block(0, edid_buf);
  1807. if (status || !check_edid_header(edid_buf)) {
  1808. if (!status)
  1809. status = -EPROTO;
  1810. DEV_ERR("%s: edid read block(0) failed: %d "
  1811. "[%02x%02x%02x%02x%02x%02x%02x%02x]\n", __func__,
  1812. status,
  1813. edid_buf[0], edid_buf[1], edid_buf[2], edid_buf[3],
  1814. edid_buf[4], edid_buf[5], edid_buf[6], edid_buf[7]);
  1815. goto error;
  1816. }
  1817. hdmi_edid_extract_vendor_id(edid_buf, vendor_id);
  1818. /* EDID_CEA_EXTENSION_FLAG[0x7E] - CEC extension byte */
  1819. num_og_cea_blocks = edid_buf[0x7E];
  1820. DEV_DBG("[JSR] (%s): No. of CEA blocks is [%u]\n", __func__,
  1821. num_og_cea_blocks);
  1822. /* Find out any CEA extension blocks following block 0 */
  1823. switch (num_og_cea_blocks) {
  1824. case 0: /* No CEA extension */
  1825. external_common_state->hdmi_sink = false;
  1826. DEV_DBG("HDMI DVI mode: %s\n",
  1827. external_common_state->hdmi_sink ? "no" : "yes");
  1828. break;
  1829. case 1: /* Read block 1 */
  1830. status = hdmi_common_read_edid_block(1, &edid_buf[0x80]);
  1831. if (status) {
  1832. DEV_ERR("%s: ddc read block(1) failed: %d\n", __func__,
  1833. status);
  1834. goto error;
  1835. }
  1836. if (edid_buf[0x80] != 2)
  1837. num_og_cea_blocks = 0;
  1838. if (num_og_cea_blocks) {
  1839. ieee_reg_id =
  1840. hdmi_edid_extract_ieee_reg_id(edid_buf+0x80);
  1841. if (ieee_reg_id == 0x0c03)
  1842. external_common_state->hdmi_sink = TRUE ;
  1843. else
  1844. external_common_state->hdmi_sink = FALSE ;
  1845. hdmi_edid_extract_latency_fields(edid_buf+0x80);
  1846. hdmi_edid_extract_speaker_allocation_data(
  1847. edid_buf+0x80);
  1848. hdmi_edid_extract_audio_data_blocks(edid_buf+0x80);
  1849. hdmi_edid_extract_3d_present(edid_buf+0x80);
  1850. hdmi_edid_extract_extended_data_blocks(edid_buf+0x80);
  1851. }
  1852. break;
  1853. case 2:
  1854. case 3:
  1855. case 4:
  1856. for (i = 1; i <= num_og_cea_blocks; i++) {
  1857. if (!(i % 2)) {
  1858. status = hdmi_common_read_edid_block(i,
  1859. edid_buf+0x00);
  1860. if (status) {
  1861. DEV_ERR("%s: ddc read block(%d)"
  1862. "failed: %d\n", __func__, i,
  1863. status);
  1864. goto error;
  1865. }
  1866. } else {
  1867. status = hdmi_common_read_edid_block(i,
  1868. edid_buf+0x80);
  1869. if (status) {
  1870. DEV_ERR("%s: ddc read block(%d)"
  1871. "failed:%d\n", __func__, i,
  1872. status);
  1873. goto error;
  1874. }
  1875. }
  1876. }
  1877. break;
  1878. default:
  1879. DEV_ERR("%s: ddc read failed, not supported multi-blocks: %d\n",
  1880. __func__, num_og_cea_blocks);
  1881. status = -EPROTO;
  1882. goto error;
  1883. }
  1884. if (num_og_cea_blocks) {
  1885. /* EDID_CEA_EXTENSION_VERSION[0x81]: Offset to CEA extension
  1886. * version number - v1,v2,v3 (v1 is seldom, v2 is obsolete,
  1887. * v3 most common) */
  1888. cea_extension_ver = edid_buf[0x81];
  1889. }
  1890. /* EDID_VERSION[0x12] - EDID Version */
  1891. /* EDID_REVISION[0x13] - EDID Revision */
  1892. DEV_INFO("EDID (V=%d.%d, #CEABlocks=%d[V%d], ID=%s, IEEE=%04x, "
  1893. "EDID-Ext=0x%02x)\n", edid_buf[0x12], edid_buf[0x13],
  1894. num_og_cea_blocks, cea_extension_ver, vendor_id, ieee_reg_id,
  1895. edid_buf[0x80]);
  1896. hdmi_edid_get_display_mode(edid_buf,
  1897. &external_common_state->disp_mode_list, num_og_cea_blocks);
  1898. return 0;
  1899. error:
  1900. external_common_state->disp_mode_list.num_of_elements = 1;
  1901. external_common_state->disp_mode_list.disp_mode_list[0] =
  1902. external_common_state->video_resolution;
  1903. return status;
  1904. }
  1905. EXPORT_SYMBOL(hdmi_common_read_edid);
  1906. bool hdmi_common_get_video_format_from_drv_data(struct msm_fb_data_type *mfd)
  1907. {
  1908. uint32 format = external_common_state->video_resolution;
  1909. struct fb_var_screeninfo *var = &mfd->fbi->var;
  1910. bool changed = TRUE;
  1911. if (var->reserved[3]) {
  1912. format = var->reserved[3]-1;
  1913. DEV_DBG("reserved format is %d\n", format);
  1914. } else if (hdmi_prim_resolution) {
  1915. format = hdmi_prim_resolution - 1;
  1916. } else {
  1917. DEV_DBG("detecting resolution from %dx%d use var->reserved[3]"
  1918. " to specify mode", mfd->var_xres, mfd->var_yres);
  1919. switch (mfd->var_xres) {
  1920. default:
  1921. case 640:
  1922. format = HDMI_VFRMT_640x480p60_4_3;
  1923. break;
  1924. case 720:
  1925. format = (mfd->var_yres == 480)
  1926. ? HDMI_VFRMT_720x480p60_16_9
  1927. : HDMI_VFRMT_720x576p50_16_9;
  1928. break;
  1929. case 1280:
  1930. if (mfd->var_yres == 1024)
  1931. format = HDMI_VFRMT_1280x1024p60_5_4;
  1932. else if (mfd->var_frame_rate == 50000)
  1933. format = HDMI_VFRMT_1280x720p50_16_9;
  1934. else
  1935. format = HDMI_VFRMT_1280x720p60_16_9;
  1936. break;
  1937. case 1440:
  1938. format = (mfd->var_yres == 240) /* interlaced has half
  1939. of y res.
  1940. */
  1941. ? HDMI_VFRMT_1440x480i60_16_9
  1942. : HDMI_VFRMT_1440x576i50_16_9;
  1943. break;
  1944. case 1920:
  1945. if (mfd->var_yres == 540) {/* interlaced */
  1946. format = HDMI_VFRMT_1920x1080i60_16_9;
  1947. } else if (mfd->var_yres == 1080) {
  1948. if (mfd->var_frame_rate == 50000)
  1949. format = HDMI_VFRMT_1920x1080p50_16_9;
  1950. else if (mfd->var_frame_rate == 24000)
  1951. format = HDMI_VFRMT_1920x1080p24_16_9;
  1952. else if (mfd->var_frame_rate == 25000)
  1953. format = HDMI_VFRMT_1920x1080p25_16_9;
  1954. else if (mfd->var_frame_rate == 30000)
  1955. format = HDMI_VFRMT_1920x1080p30_16_9;
  1956. else
  1957. format = HDMI_VFRMT_1920x1080p60_16_9;
  1958. }
  1959. break;
  1960. }
  1961. }
  1962. changed = external_common_state->video_resolution != format;
  1963. if (external_common_state->video_resolution != format)
  1964. DEV_DBG("switching %s => %s", video_format_2string(
  1965. external_common_state->video_resolution),
  1966. video_format_2string(format));
  1967. else
  1968. DEV_DBG("resolution %s", video_format_2string(
  1969. external_common_state->video_resolution));
  1970. external_common_state->video_resolution = format;
  1971. return changed;
  1972. }
  1973. EXPORT_SYMBOL(hdmi_common_get_video_format_from_drv_data);
  1974. const struct hdmi_disp_mode_timing_type *hdmi_common_get_mode(uint32 mode)
  1975. {
  1976. if (mode >= HDMI_VFRMT_MAX)
  1977. return NULL;
  1978. return &hdmi_common_supported_video_mode_lut[mode];
  1979. }
  1980. EXPORT_SYMBOL(hdmi_common_get_mode);
  1981. const struct hdmi_disp_mode_timing_type *hdmi_common_get_supported_mode(
  1982. uint32 mode)
  1983. {
  1984. const struct hdmi_disp_mode_timing_type *ret
  1985. = hdmi_common_get_mode(mode);
  1986. if (ret == NULL || !ret->supported)
  1987. return NULL;
  1988. return ret;
  1989. }
  1990. EXPORT_SYMBOL(hdmi_common_get_supported_mode);
  1991. const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_mode(uint32 mode)
  1992. {
  1993. if (mode >= HDMI_VFRMT_MAX)
  1994. return NULL;
  1995. return &hdmi_mhl_supported_video_mode_lut[mode];
  1996. }
  1997. EXPORT_SYMBOL(hdmi_mhl_get_mode);
  1998. const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_supported_mode(
  1999. uint32 mode)
  2000. {
  2001. const struct hdmi_disp_mode_timing_type *ret
  2002. = hdmi_mhl_get_mode(mode);
  2003. if (ret == NULL || !ret->supported)
  2004. return NULL;
  2005. return ret;
  2006. }
  2007. EXPORT_SYMBOL(hdmi_mhl_get_supported_mode);
  2008. void hdmi_common_init_panel_info(struct msm_panel_info *pinfo)
  2009. {
  2010. const struct hdmi_disp_mode_timing_type *timing =
  2011. hdmi_common_get_supported_mode(
  2012. external_common_state->video_resolution);
  2013. if (timing == NULL)
  2014. return;
  2015. pinfo->xres = timing->active_h;
  2016. pinfo->yres = timing->active_v;
  2017. pinfo->clk_rate = timing->pixel_freq*1000;
  2018. pinfo->frame_rate = 60;
  2019. pinfo->lcdc.h_back_porch = timing->back_porch_h;
  2020. pinfo->lcdc.h_front_porch = timing->front_porch_h;
  2021. pinfo->lcdc.h_pulse_width = timing->pulse_width_h;
  2022. pinfo->lcdc.v_back_porch = timing->back_porch_v;
  2023. pinfo->lcdc.v_front_porch = timing->front_porch_v;
  2024. pinfo->lcdc.v_pulse_width = timing->pulse_width_v;
  2025. pinfo->type = DTV_PANEL;
  2026. pinfo->pdest = DISPLAY_2;
  2027. pinfo->wait_cycle = 0;
  2028. pinfo->bpp = 24;
  2029. if (hdmi_prim_display)
  2030. pinfo->fb_num = 2;
  2031. else
  2032. pinfo->fb_num = 1;
  2033. /* blk */
  2034. pinfo->lcdc.border_clr = 0;
  2035. /* blue */
  2036. pinfo->lcdc.underflow_clr = 0xff;
  2037. pinfo->lcdc.hsync_skew = 0;
  2038. }
  2039. EXPORT_SYMBOL(hdmi_common_init_panel_info);
  2040. #endif