mdss_samsung_dsi_panel.c 139 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883
  1. /* Copyright (c) 2012, Samsung Electronics. 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. #include <linux/module.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/of.h>
  15. #include <linux/of_gpio.h>
  16. #include <linux/gpio.h>
  17. #include <linux/qpnp/pin.h>
  18. #include <linux/delay.h>
  19. #include <linux/slab.h>
  20. #include <linux/leds.h>
  21. #include <linux/pwm.h>
  22. #include <linux/err.h>
  23. #include <linux/lcd.h>
  24. #ifdef CONFIG_HAS_EARLYSUSPEND
  25. #include <linux/earlysuspend.h>
  26. #endif
  27. #include "mdss_dsi.h"
  28. #include "mdss_samsung_dsi_panel.h"
  29. #include "mdss_fb.h"
  30. #if defined(CONFIG_MDNIE_LITE_TUNING)
  31. #include "mdnie_lite_tuning.h"
  32. #endif
  33. #define DDI_VIDEO_ENHANCE_TUNING
  34. #if defined(DDI_VIDEO_ENHANCE_TUNING)
  35. #include <linux/syscalls.h>
  36. #include <asm/uaccess.h>
  37. #endif
  38. #include <asm/system_info.h>
  39. #if defined(CONFIG_MIPI_LCD_S6E3FA0_FORCE_VIDEO_MODE)
  40. #define CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL 1
  41. #endif
  42. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL) \
  43. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL)
  44. #define SMART_ACL
  45. #define HBM_RE
  46. #define TEMPERATURE_ELVSS_S6E3FA0
  47. #define PARTIAL_UPDATE
  48. #endif
  49. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  50. #define LDI_FPS_CHANGE
  51. #define LDI_ADJ_VDDM_OFFSET
  52. #define FORCE_500CD
  53. #endif
  54. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  55. #define TEMPERATURE_ELVSS_S6E8AA4
  56. #define SMART_ACL
  57. #define HBM_RE
  58. #define NOT_USING_ACL_CONT
  59. #endif
  60. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  61. //#define TEMPERATURE_ELVSS
  62. #define HBM_RE
  63. #endif
  64. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  65. #define NOT_USING_ACL_CONT
  66. #endif
  67. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  68. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061)
  69. #define VIRTUAL_GAMMA
  70. #endif
  71. #if defined(CONFIG_MACH_KS01SKT) || defined(CONFIG_MACH_KS01KTT) || defined(CONFIG_MACH_KS01LGT) \
  72. || defined(CONFIG_MACH_HLTESKT) || defined(CONFIG_MACH_HLTELGT) || defined(CONFIG_MACH_HLTEKTT)
  73. #define octa_manufacture_date
  74. #endif
  75. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)
  76. #define SMART_ACL
  77. #define NOT_USING_ACL_CONT
  78. #endif
  79. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  80. #define SMART_ACL
  81. #define NOT_USING_ACL_CONT
  82. #define HBM_RE
  83. #endif
  84. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  85. #define TEMPERATURE_ELVSS
  86. #define SMART_ACL
  87. #define NOT_USING_ACL_CONT
  88. #define HBM_RE
  89. #define octa_manufacture_date
  90. #endif
  91. #define DT_CMD_HDR 6
  92. #if defined(octa_manufacture_date)
  93. static struct dsi_cmd nv_date_read_cmds;
  94. char mdate_buffer[10];
  95. #endif
  96. static struct dsi_buf dsi_panel_tx_buf;
  97. static struct dsi_buf dsi_panel_rx_buf;
  98. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)
  99. static struct dsi_cmd magna_read_pos_cmds;
  100. static struct dsi_cmd magna_read_run_cmds;
  101. #endif
  102. static struct dsi_cmd nv_mdnie_read_cmds;
  103. static struct dsi_cmd nv_mtp_read_cmds;
  104. static struct dsi_cmd nv_mtp_read_register_set_cmds;
  105. #if defined(HBM_RE)
  106. static struct dsi_cmd nv_mtp_hbm_read_cmds;
  107. static struct dsi_cmd nv_mtp_hbm2_read_cmds;
  108. static struct dsi_cmd hbm_gamma_cmds_list;
  109. static struct dsi_cmd hbm_etc_cmds_evt0_second_list;
  110. static struct dsi_cmd hbm_etc_cmds_evt1_list;
  111. static struct dsi_cmd hbm_etc_cmds_evt1_second_list;
  112. static struct dsi_cmd hbm_etc_cmds_evt1_H_revI_list;
  113. static struct dsi_cmd hbm_etc_cmds_evt1_H_revJ_list;
  114. static struct dsi_cmd hbm_etc_cmds_list;
  115. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)\
  116. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  117. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  118. static struct dsi_cmd nv_mtp_hbm3_read_cmds;
  119. static struct dsi_cmd hbm_hbm_off_elvss_cmds;
  120. #endif
  121. #elif defined(CONFIG_HBM_PSRE)
  122. static struct dsi_cmd nv_mtp_hbm_read_cmds;
  123. static struct dsi_cmd nv_mtp_hbm2_read_cmds;
  124. static struct dsi_cmd nv_mtp_hbm3_read_cmds;
  125. static struct dsi_cmd nv_hbm_elvss_offset_cmds;
  126. static struct dsi_cmd nv_production_day_cmds;
  127. static struct dsi_cmd hbm_gamma_cmds_list;
  128. static struct dsi_cmd hbm_etc_cmds_list;
  129. #endif
  130. static struct dsi_cmd nv_enable_cmds;
  131. static struct dsi_cmd nv_disable_cmds;
  132. #ifdef DEBUG_LDI_STATUS
  133. static struct dsi_cmd ldi_debug_cmds;
  134. #endif
  135. #ifdef LDI_FPS_CHANGE
  136. static struct dsi_cmd read_ldi_fps_cmds;
  137. static struct dsi_cmd write_ldi_fps_cmds;
  138. #endif
  139. #ifdef LDI_ADJ_VDDM_OFFSET
  140. static struct dsi_cmd read_vddm_ref_cmds;
  141. static struct dsi_cmd write_vddm_offset_cmds;
  142. #endif
  143. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  144. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  145. static struct dsi_cmd test_key_enable_cmds;
  146. static struct dsi_cmd test_key_disable_cmds;
  147. #endif
  148. static struct dsi_cmd manufacture_id_cmds;
  149. static struct dsi_cmd display_qcom_on_cmds;
  150. static struct dsi_cmd display_qcom_off_cmds;
  151. static struct dsi_cmd display_on_cmd;
  152. static struct dsi_cmd display_off_cmd;
  153. static struct dsi_cmd display_blank_cmd;
  154. static struct dsi_cmd display_unblank_cmd;
  155. static struct dsi_cmd acl_off_cmd;
  156. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  157. static struct dsi_cmd touchsensing_on_cmd;
  158. static struct dsi_cmd touchsensing_off_cmd;
  159. #endif
  160. #if defined(PARTIAL_UPDATE)
  161. static struct dsi_cmd partialdisp_on_cmd;
  162. static struct dsi_cmd partialdisp_off_cmd;
  163. #endif
  164. #if defined(FORCE_500CD)
  165. static struct dsi_cmd force_500;
  166. #endif
  167. /*
  168. contains the list of acl commands
  169. available for different brightness levels
  170. */
  171. static struct dsi_cmd acl_cmds_list;
  172. static struct dsi_cmd elvss_cmds_list;
  173. static struct dsi_cmd aid_cmds_list;
  174. static struct dsi_cmd aid_cmds_list_350;
  175. static struct dsi_cmd gamma_cmds_list;
  176. #if !defined(NOT_USING_ACL_CONT)
  177. static struct dsi_cmd aclcont_cmds_list;
  178. #endif
  179. #if defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  180. static struct dsi_cmd elvss_lowtemp_cmds_list;
  181. #endif
  182. #if defined(TEMPERATURE_ELVSS)
  183. static struct dsi_cmd elvss_lowtemp_cmds_list;
  184. static struct dsi_cmd elvss_tempcompen_cmds_list;
  185. #endif
  186. #if defined(SMART_ACL)
  187. static struct dsi_cmd smart_acl_elvss_cmds_list;
  188. #endif
  189. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  190. static struct dsi_cmd lcd_crack_rec_cmd_list;
  191. #endif
  192. /*
  193. contains mapping between bl_level and
  194. index number of corresponding acl command
  195. in acl command list
  196. */
  197. static struct cmd_map acl_map_table;
  198. static struct cmd_map elvss_map_table;
  199. static struct cmd_map aid_map_table;
  200. static struct candella_lux_map candela_map_table;
  201. static struct candella_lux_map candela_map_table_350;
  202. #if defined(SMART_ACL)
  203. static struct cmd_map smart_acl_elvss_map_table;
  204. #endif
  205. static struct mipi_samsung_driver_data msd;
  206. /*List of supported Panels with HW revision detail
  207. * (one structure per project)
  208. * {hw_rev,"label string given in panel dtsi file"}
  209. * */
  210. static struct panel_hrev panel_supp_cdp[]= {
  211. {"samsung amoled 720p video mode dsi S6E8AA3X01 panel", PANEL_720P_AMOLED_S6E8AA3X01},
  212. {"samsung amoled 1080p video mode dsi S6E8FA0 panel", PANEL_1080P_OCTA_S6E8FA0},
  213. {"samsung amoled 1080p video mode dsi S6E3FA0 panel", PANEL_1080P_OCTA_S6E3FA0},
  214. {"samsung amoled 1080p command mode dsi S6E3FA0 panel", PANEL_1080P_OCTA_S6E3FA0_CMD},
  215. {"samsung amoled 1080p command mode dsi S6E3FA1 panel", PANEL_1080P_YOUM_S6E3FA1_CMD},
  216. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  217. {"samsung amoled WVGA video mode dsi S6E88A0 panel", PANEL_WVGA_OCTA_S6E88A0},
  218. #endif
  219. {"magna amoled 720p video mode dsi D53D6EA8061V panel", PANEL_720P_OCTA_D53D6EA8061V},
  220. {"samsung amoled 720p video mode dsi S6E8AA0A01 panel", PANEL_720P_OCTA_S6E8AA0},
  221. {"samsung amoled 720p video mode dsi EA8061 panel", PANEL_720P_OCTA_EA8061_VIDEO},
  222. {"samsung amoled 720p video mode dsi S6E8AA4 panel", PANEL_720P_OCTA_S6E8AA4_VIDEO},
  223. {"samsung amoled 720p video mode dsi D53D6EA8061V panel", PANEL_720P_OCTA_D53D6EA8061V_VIDEO},
  224. {"samsung amoled qhd video mode dsi S6E88A0 panel",PANEL_QHD_OCTA_S6E88A0_VIDEO},
  225. {"samsung octa hd video mode dsi EA8061 panel",PANEL_HD_OCTA_D53D6EA8061_VIDEO},
  226. {NULL}
  227. };
  228. static struct dsi_cmd_desc brightness_packet[] = {
  229. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  230. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  231. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  232. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  233. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  234. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  235. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  236. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  237. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  238. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  239. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  240. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0, 0}, NULL},
  241. };
  242. #ifdef LDI_ADJ_VDDM_OFFSET
  243. unsigned int ldi_vddm_lut[128][2] = {
  244. {0, 13}, {1, 13}, {2, 14}, {3, 15}, {4, 16}, {5, 17}, {6, 18}, {7, 19}, {8, 20}, {9, 21},
  245. {10, 22}, {11, 23}, {12, 24}, {13, 25}, {14, 26}, {15, 27}, {16, 28}, {17, 29}, {18, 30}, {19, 31},
  246. {20, 32}, {21, 33}, {22, 34}, {23, 35}, {24, 36}, {25, 37}, {26, 38}, {27, 39}, {28, 40}, {29, 41},
  247. {30, 42}, {31, 43}, {32, 44}, {33, 45}, {34, 46}, {35, 47}, {36, 48}, {37, 49}, {38, 50}, {39, 51},
  248. {40, 52}, {41, 53}, {42, 54}, {43, 55}, {44, 56}, {45, 57}, {46, 58}, {47, 59}, {48, 60}, {49, 61},
  249. {50, 62}, {51, 63}, {52, 63}, {53, 63}, {54, 63}, {55, 63}, {56, 63}, {57, 63}, {58, 63}, {59, 63},
  250. {60, 63}, {61, 63}, {62, 63}, {63, 63}, {64, 12}, {65, 11}, {66, 10}, {67, 9}, {68, 8}, {69, 7},
  251. {70, 6}, {71, 5}, {72, 4}, {73, 3}, {74, 2}, {75, 1}, {76, 64}, {77, 65}, {78, 66}, {79, 67},
  252. {80, 68}, {81, 69}, {82, 70}, {83, 71}, {84, 72}, {85, 73}, {86, 74}, {87, 75}, {88, 76}, {89, 77},
  253. {90, 78}, {91, 79}, {92, 80}, {93, 81}, {94, 82}, {95, 83}, {96, 84}, {97, 85}, {98, 86}, {99, 87},
  254. {100, 88}, {101, 89}, {102, 90}, {103, 91}, {104, 92}, {105, 93}, {106, 94}, {107, 95}, {108, 96}, {109, 97},
  255. {110, 98}, {111, 99}, {112, 100}, {113, 101}, {114, 102}, {115, 103}, {116, 104}, {117, 105}, {118, 106}, {119, 107},
  256. {120, 108}, {121, 109}, {122, 110}, {123, 111}, {124, 112}, {125, 113}, {126, 114}, {127, 115},
  257. };
  258. #endif
  259. #define MAX_BR_PACKET_SIZE sizeof(brightness_packet)/sizeof(struct dsi_cmd_desc)
  260. DEFINE_LED_TRIGGER(bl_led_trigger);
  261. static struct mdss_dsi_phy_ctrl phy_params;
  262. static int lcd_attached = 1;
  263. static int lcd_id = 0;
  264. static char board_rev;
  265. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  266. #define ESD_DEBUG 1
  267. struct work_struct err_fg_work;
  268. static int err_fg_gpio = 0; /* PM_GPIO4 */
  269. static int esd_count = 0;
  270. static int err_fg_working = 0;
  271. static int err_fg_enable = 0;
  272. #endif
  273. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  274. struct work_struct lcd_crack_rec_work;
  275. static int lcd_crack_gpio = 0;
  276. static int lcd_crack_rec_working = 0;
  277. static int lcd_crack_rec_enable = 0;
  278. #endif
  279. static int mipi_samsung_disp_send_cmd(
  280. enum mipi_samsung_cmd_list cmd,
  281. unsigned char lock);
  282. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  283. extern void mdss_dsi_panel_touchsensing(int enable);
  284. #endif
  285. int get_lcd_attached(void);
  286. #if (defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  287. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061))\
  288. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  289. /* fresco ldi id3 */
  290. #define EVT0_REV_A 0x80
  291. #define EVT1_REV_B_C 0xA1
  292. #define EVT1_REV_D 0xA2
  293. /*
  294. oled id : msm gpio 91
  295. 1: s.lsi
  296. 0: magna
  297. */
  298. static int fresco_oled_id = 1;
  299. int get_oled_id(void);
  300. #endif
  301. int set_panel_rev(unsigned int id)
  302. {
  303. switch (id & 0xFF) {
  304. /* H OCTA panel */
  305. case 0x00:
  306. pr_info("%s : 0x00 EVT0_ID \n",__func__);
  307. msd.id3 = EVT0_ID;
  308. break;
  309. case 0x01:
  310. pr_info("%s : 0x01 EVT0_SECOND_ID \n",__func__);
  311. msd.id3 = EVT0_SECOND_ID;
  312. break;
  313. case 0x21:
  314. pr_info("%s : 0x21 EVT1_ID \n",__func__);
  315. msd.id3 = EVT1_ID;
  316. break;
  317. case 0x22:
  318. pr_info("%s : 0x22 EVT1_SECOND_ID \n",__func__);
  319. msd.id3 = EVT1_SECOND_ID;
  320. break;
  321. case 0x23:
  322. pr_info("%s : 0x23 EVT1_H_REV_I \n",__func__);
  323. msd.id3 = EVT1_H_REV_I;
  324. msd.panel_350cd = 1;
  325. break;
  326. case 0x24:
  327. pr_info("%s : 0x24 EVT1_H_REV_J \n",__func__);
  328. msd.id3 = EVT1_H_REV_J;
  329. msd.panel_350cd = 1;
  330. break;
  331. /* F YOUM panel */
  332. case 0x10:
  333. pr_info("%s : 0x10 EVT0_F_REV_A \n",__func__);
  334. msd.id3 = EVT0_F_REV_A;
  335. break;
  336. case 0x11:
  337. pr_info("%s : 0x11 EVT0_F_REV_E \n",__func__);
  338. msd.id3 = EVT0_F_REV_E;
  339. msd.panel_350cd = 1;
  340. break;
  341. case 0x12:
  342. pr_info("%s : 0x12 EVT0_F_REV_F \n",__func__);
  343. msd.id3 = EVT0_F_REV_F;
  344. msd.panel_350cd = 1;
  345. break;
  346. case 0x32:
  347. pr_info("%s : 0x32 EVT2_F_REV_G \n",__func__);
  348. msd.id3 = EVT2_F_REV_G;
  349. msd.panel_350cd = 1;
  350. break;
  351. case 0x43:
  352. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  353. pr_info("%s : 0x43 Fresco_kor_magna panel \n",__func__);
  354. msd.panel_350cd = 0;
  355. #else
  356. pr_info("%s : 0x43 EVT2_Fresco_REV_G \n",__func__);
  357. msd.id3 = EVT2_FRESCO_REV_G;
  358. msd.panel_350cd = 1;
  359. #endif
  360. break;
  361. case 0x82:
  362. pr_info("%s : 0x82 EVT0_EA8061V_REV_A \n",__func__);
  363. msd.id3 = EVT0_EA8061V_REV_A;
  364. msd.panel_350cd = 1;
  365. break;
  366. case 0x84:
  367. pr_info("%s : 0x84 EVT0_EA8061V_KMINI_REV_A \n",__func__);
  368. msd.id3 = EVT0_EA8061V_KMINI_REV_A;
  369. msd.panel_350cd = 1;
  370. break;
  371. case 0x40:
  372. pr_info("%s : 0x40 EVT2_EA8061_Hestia_REV_A \n",__func__);
  373. msd.id3 = EVT2_EA8061_HESTIA_REV_A;
  374. msd.panel_350cd = 1;
  375. break;
  376. case 0x47:
  377. #if defined(CONFIG_SEC_HESTIA_PROJECT)
  378. pr_info("%s : 0x47 used for HESTIA EVT2_EA8061_Hestia_REV_I \n",__func__);
  379. msd.id3 = EVT2_EA8061_HESTIA_REV_I;
  380. msd.panel_350cd = 1;
  381. #else
  382. pr_info("%s : 0x47 need to check \n",__func__);
  383. msd.id3 = 0;
  384. msd.panel_350cd = 0;
  385. #endif
  386. break;
  387. case 0x48:
  388. pr_info("%s : 0x48 EVT2_EA8061_Hestia_REV_J \n",__func__);
  389. msd.id3 = EVT2_EA8061_HESTIA_REV_J;
  390. msd.panel_350cd = 1;
  391. break;
  392. case 0x95:
  393. pr_info("%s : 0x82 EVT2_EA8061V_REV_C \n",__func__);
  394. msd.id3 = EVT2_EA8061V_REV_C;
  395. msd.panel_350cd = 1;
  396. break;
  397. case 0x96:
  398. pr_info("%s : 0x96 EVT2_EA8061V_REV_D \n",__func__);
  399. msd.id3 = EVT2_EA8061V_REV_D;
  400. msd.panel_350cd = 1;
  401. break;
  402. case 0x97:
  403. pr_info("%s : 0x96 EVT2_EA8061V_REV_E \n",__func__);
  404. msd.id3 = EVT2_EA8061V_REV_E;
  405. msd.panel_350cd = 1;
  406. break;
  407. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  408. /*FRESCO LSI panel*/
  409. case 0x80: /*evt 0 rev A*/
  410. pr_info("%s : 0x80 EVT0_REV_A \n",__func__);
  411. msd.id3 = EVT0_REV_A;
  412. msd.panel_350cd = 1;
  413. break;
  414. case 0xA1: /*evt 1 rev B, rev C*/
  415. pr_info("%s : 0xA1 EVT1_REV_B or EVT1_REV_C\n",__func__);
  416. msd.id3 = EVT1_REV_B_C;
  417. msd.panel_350cd = 1;
  418. break;
  419. case 0xA2:/*evt 1 rev D*/
  420. pr_info("%s : 0xA2 EVT1_REV_D \n",__func__);
  421. msd.id3 = EVT1_REV_D;
  422. msd.panel_350cd = 1;
  423. break;
  424. #endif
  425. default:
  426. pr_err("%s : can't find panel id.. \n", __func__);
  427. return -EINVAL;
  428. break;
  429. }
  430. return 1;
  431. }
  432. void mdss_dsi_panel_pwm_cfg(struct mdss_dsi_ctrl_pdata *ctrl)
  433. {
  434. int ret;
  435. if (!gpio_is_valid(ctrl->pwm_pmic_gpio)) {
  436. pr_err("%s: pwm_pmic_gpio=%d Invalid\n", __func__,
  437. ctrl->pwm_pmic_gpio);
  438. return;
  439. }
  440. ret = gpio_request(ctrl->pwm_pmic_gpio, "disp_pwm");
  441. if (ret) {
  442. pr_err("%s: pwm_pmic_gpio=%d request failed\n", __func__,
  443. ctrl->pwm_pmic_gpio);
  444. return;
  445. }
  446. ctrl->pwm_bl = pwm_request(ctrl->pwm_lpg_chan, "lcd-bklt");
  447. if (ctrl->pwm_bl == NULL || IS_ERR(ctrl->pwm_bl)) {
  448. pr_err("%s: lpg_chan=%d pwm request failed", __func__,
  449. ctrl->pwm_lpg_chan);
  450. gpio_free(ctrl->pwm_pmic_gpio);
  451. ctrl->pwm_pmic_gpio = -1;
  452. }
  453. }
  454. static void mdss_dsi_panel_bklt_pwm(struct mdss_dsi_ctrl_pdata *ctrl, int level)
  455. {
  456. int ret;
  457. u32 duty;
  458. if (ctrl->pwm_bl == NULL) {
  459. pr_err("%s: no PWM\n", __func__);
  460. return;
  461. }
  462. duty = level * ctrl->pwm_period;
  463. duty /= ctrl->bklt_max;
  464. pr_debug("%s: bklt_ctrl=%d pwm_period=%d pwm_pmic_gpio=%d pwm_lpg_chan=%d\n",
  465. __func__, ctrl->bklt_ctrl, ctrl->pwm_period,
  466. ctrl->pwm_pmic_gpio, ctrl->pwm_lpg_chan);
  467. pr_debug("%s: ndx=%d level=%d duty=%d\n", __func__,
  468. ctrl->ndx, level, duty);
  469. ret = pwm_config(ctrl->pwm_bl, duty, ctrl->pwm_period);
  470. if (ret) {
  471. pr_err("%s: pwm_config() failed err=%d.\n", __func__, ret);
  472. return;
  473. }
  474. ret = pwm_enable(ctrl->pwm_bl);
  475. if (ret)
  476. pr_err("%s: pwm_enable() failed err=%d\n", __func__, ret);
  477. }
  478. static char dcs_cmd[2] = {0x54, 0x00}; /* DTYPE_DCS_READ */
  479. static struct dsi_cmd_desc dcs_read_cmd = {
  480. {DTYPE_DCS_READ, 1, 0, 1, 5, sizeof(dcs_cmd)},
  481. dcs_cmd
  482. };
  483. static void dcs_read_cb(int data)
  484. {
  485. pr_info("%s: bklt_ctrl=%x\n", __func__, data);
  486. }
  487. u32 mdss_dsi_dcs_read(struct mdss_dsi_ctrl_pdata *ctrl,
  488. char cmd0, char cmd1)
  489. {
  490. struct dcs_cmd_req cmdreq;
  491. dcs_cmd[0] = cmd0;
  492. dcs_cmd[1] = cmd1;
  493. memset(&cmdreq, 0, sizeof(cmdreq));
  494. cmdreq.cmds = &dcs_read_cmd;
  495. cmdreq.cmds_cnt = 1;
  496. cmdreq.flags = CMD_REQ_RX | CMD_REQ_COMMIT;
  497. cmdreq.rlen = 1;
  498. cmdreq.cb = dcs_read_cb; /* call back */
  499. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  500. /*
  501. * blocked here, untill call back called
  502. */
  503. return 0;
  504. }
  505. void mdss_dsi_samsung_panel_reset(struct mdss_panel_data *pdata, int enable)
  506. {
  507. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  508. int rc =0;
  509. #endif
  510. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  511. if (pdata == NULL) {
  512. pr_err("%s: Invalid input data\n", __func__);
  513. return;
  514. }
  515. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  516. panel_data);
  517. if (!gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  518. pr_debug("%s:%d, enable line not configured\n",
  519. __func__, __LINE__);
  520. }
  521. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)
  522. if (!gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  523. pr_debug("%s:%d, enable line2 not configured\n",
  524. __func__, __LINE__);
  525. }
  526. #endif
  527. if (!gpio_is_valid(ctrl_pdata->rst_gpio)) {
  528. pr_debug("%s:%d, reset line not configured\n",
  529. __func__, __LINE__);
  530. }
  531. pr_debug("%s: enable = %d\n", __func__, enable);
  532. if (enable) {
  533. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  534. if (gpio_is_valid(ctrl_pdata->expander_enble_gpio)) {
  535. gpio_set_value((ctrl_pdata->expander_enble_gpio), 1);
  536. mdelay(5);
  537. }
  538. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  539. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->rst_gpio, 0,
  540. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  541. GPIO_CFG_ENABLE);
  542. if (rc)
  543. pr_err("request rst_gpio failed, rc=%d\n",rc);
  544. }
  545. #endif
  546. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)||\
  547. defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  548. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  549. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio, 0,
  550. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  551. GPIO_CFG_ENABLE);
  552. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  553. wmb();
  554. }
  555. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  556. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  557. mdelay(3);
  558. wmb();
  559. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  560. mdelay(10);
  561. wmb();
  562. }
  563. #elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  564. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  565. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  566. wmb();
  567. }
  568. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  569. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  570. msleep(20);
  571. wmb();
  572. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  573. udelay(200);
  574. wmb();
  575. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  576. msleep(20);
  577. wmb();
  578. }
  579. #else
  580. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  581. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  582. msleep(20);
  583. wmb();
  584. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  585. udelay(200);
  586. wmb();
  587. gpio_set_value((ctrl_pdata->rst_gpio), 1);
  588. msleep(20);
  589. wmb();
  590. }
  591. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  592. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  593. wmb();
  594. }
  595. #endif
  596. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)
  597. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  598. gpio_set_value((ctrl_pdata->disp_en_gpio2), 1);
  599. wmb();
  600. }
  601. #endif
  602. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  603. if(gpio_is_valid(lcd_crack_gpio))
  604. {
  605. rc = gpio_tlmm_config(GPIO_CFG(lcd_crack_gpio, 0,
  606. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  607. GPIO_CFG_ENABLE);
  608. if (rc)
  609. {
  610. pr_err("request lcd_crack_gpio failed, rc=%d\n",rc);
  611. }
  612. }
  613. #endif
  614. if (ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT) {
  615. pr_debug("%s: Panel Not properly turned OFF\n",
  616. __func__);
  617. ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
  618. pr_debug("%s: Reset panel done\n", __func__);
  619. }
  620. } else {
  621. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  622. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  623. if (gpio_is_valid(ctrl_pdata->rst_gpio)) {
  624. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->rst_gpio, 0,
  625. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  626. GPIO_CFG_DISABLE);
  627. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  628. }
  629. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  630. if(ctrl_pdata->disp_en_gpio == 115)
  631. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio, 0,
  632. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  633. GPIO_CFG_DISABLE);
  634. else
  635. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio, 0,
  636. GPIO_CFG_OUTPUT,GPIO_CFG_PULL_DOWN,GPIO_CFG_2MA),
  637. GPIO_CFG_DISABLE);
  638. gpio_set_value((ctrl_pdata->disp_en_gpio), 0);
  639. }
  640. #else
  641. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  642. gpio_set_value((ctrl_pdata->disp_en_gpio), 0);
  643. }
  644. #endif
  645. if (gpio_is_valid(ctrl_pdata->rst_gpio))
  646. gpio_set_value((ctrl_pdata->rst_gpio), 0);
  647. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)
  648. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  649. gpio_set_value((ctrl_pdata->disp_en_gpio2), 0);
  650. }
  651. #endif
  652. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  653. if (gpio_is_valid(ctrl_pdata->expander_enble_gpio))
  654. gpio_set_value((ctrl_pdata->expander_enble_gpio), 0);
  655. #endif
  656. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  657. if(gpio_is_valid(lcd_crack_gpio))
  658. {
  659. rc = gpio_tlmm_config(GPIO_CFG(lcd_crack_gpio, 0,
  660. GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN,GPIO_CFG_2MA),
  661. GPIO_CFG_DISABLE);
  662. if (rc)
  663. pr_err("request lcd_crack_gpio failed, rc=%d\n",rc);
  664. else
  665. gpio_set_value(lcd_crack_gpio, 0);
  666. }
  667. #endif
  668. }
  669. }
  670. static int get_candela_value(int bl_level)
  671. {
  672. if (msd.panel_350cd)
  673. return candela_map_table_350.lux_tab[candela_map_table_350.bkl[bl_level]];
  674. else
  675. return candela_map_table.lux_tab[candela_map_table.bkl[bl_level]];
  676. }
  677. static int get_cmd_idx(int bl_level)
  678. {
  679. if (msd.panel_350cd)
  680. return candela_map_table_350.cmd_idx[candela_map_table_350.bkl[bl_level]];
  681. else
  682. return candela_map_table.cmd_idx[candela_map_table.bkl[bl_level]];
  683. }
  684. #if defined(CONFIG_LCD_CLASS_DEVICE)
  685. static ssize_t mipi_samsung_disp_get_power(struct device *dev,
  686. struct device_attribute *attr, char *buf)
  687. {
  688. struct msm_fb_data_type *mfd = msd.mfd;
  689. int rc;
  690. if (unlikely(!mfd))
  691. return -ENODEV;
  692. if (unlikely(mfd->key != MFD_KEY))
  693. return -EINVAL;
  694. rc = snprintf((char *)buf, PAGE_SIZE, "%d\n", mfd->panel_power_on);
  695. pr_info("mipi_samsung_disp_get_power(%d)\n", mfd->panel_power_on);
  696. return rc;
  697. }
  698. static ssize_t mipi_samsung_disp_set_power(struct device *dev,
  699. struct device_attribute *attr, const char *buf, size_t size)
  700. {
  701. unsigned int power;
  702. struct msm_fb_data_type *mfd = msd.mfd;
  703. if (sscanf(buf, "%u", &power) != 1)
  704. return -EINVAL;
  705. if (power == mfd->panel_power_on)
  706. return 0;
  707. if (power) {
  708. mfd->fbi->fbops->fb_blank(FB_BLANK_UNBLANK, mfd->fbi);
  709. mfd->fbi->fbops->fb_pan_display(&mfd->fbi->var, mfd->fbi);
  710. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  711. } else {
  712. mfd->fbi->fbops->fb_blank(FB_BLANK_POWERDOWN, mfd->fbi);
  713. }
  714. pr_info("mipi_samsung_disp_set_power\n");
  715. return size;
  716. }
  717. static ssize_t mipi_samsung_disp_lcdtype_show(struct device *dev,
  718. struct device_attribute *attr, char *buf)
  719. {
  720. char temp[100];
  721. switch (msd.panel) {
  722. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  723. case PANEL_WVGA_OCTA_S6E88A0:
  724. snprintf(temp, 20, "SMD_AMS367AV01");
  725. break;
  726. #endif
  727. case PANEL_1080P_OCTA_S6E8FA0:
  728. snprintf(temp, 20, "SDC_AMS499QP01");
  729. break;
  730. case PANEL_1080P_OCTA_S6E3FA0:
  731. case PANEL_1080P_OCTA_S6E3FA0_CMD:
  732. snprintf(temp, 20, "SDC_AMS568AT01");
  733. break;
  734. case PANEL_1080P_YOUM_S6E3FA1_CMD:
  735. snprintf(temp, 20, "SDC_AMB568AU01");
  736. break;
  737. case PANEL_720P_OCTA_D53D6EA8061V:
  738. snprintf(temp, 20, "SDC_D53D6EA8061V");
  739. break;
  740. case PANEL_720P_OCTA_S6E8AA0:
  741. snprintf(temp, 20, "SDC_AMS480GY01");
  742. break;
  743. case PANEL_720P_OCTA_D53D6EA8061V_VIDEO:
  744. snprintf(temp, 20, "SDC_200283");
  745. break;
  746. case PANEL_HD_OCTA_D53D6EA8061_VIDEO:
  747. if (msd.manufacture_id)
  748. snprintf(temp, 20, "SDC_%x\n",msd.manufacture_id);
  749. break;
  750. case PANEL_720P_OCTA_S6E8AA4_VIDEO:
  751. snprintf(temp, 20, "SDC_AMS549BU05");
  752. break;
  753. case PANEL_QHD_OCTA_S6E88A0_VIDEO:
  754. snprintf(temp, 20, "SDC_AMS517CY01");
  755. break;
  756. default :
  757. snprintf(temp, strnlen(msd.panel_name, 100),
  758. msd.panel_name);
  759. break;
  760. }
  761. strlcat(buf, temp, 100);
  762. return strnlen(buf, 100);
  763. }
  764. static ssize_t mipi_samsung_disp_windowtype_show(struct device *dev,
  765. struct device_attribute *attr, char *buf)
  766. {
  767. char temp[15];
  768. int id1, id2, id3;
  769. id1 = (msd.manufacture_id & 0x00FF0000) >> 16;
  770. id2 = (msd.manufacture_id & 0x0000FF00) >> 8;
  771. id3 = msd.manufacture_id & 0xFF;
  772. snprintf(temp, PAGE_SIZE, "%x %x %x\n", id1, id2, id3);
  773. strlcat(buf, temp, 15);
  774. return strnlen(buf, 15);
  775. }
  776. static ssize_t mipi_samsung_disp_acl_show(struct device *dev,
  777. struct device_attribute *attr, char *buf)
  778. {
  779. int rc;
  780. rc = snprintf((char *)buf, PAGE_SIZE, "%d\n", msd.dstat.acl_on);
  781. pr_info("acl status: %d\n", *buf);
  782. return rc;
  783. }
  784. /*
  785. This function takes aid_map_table and uses cd_idx,
  786. to get the index of the command in aid command list.
  787. */
  788. static struct dsi_cmd get_aid_aor_control_set(int cd_idx)
  789. {
  790. struct dsi_cmd aid_control = {0,};
  791. int cmd_idx = 0, payload_size = 0;
  792. char *p_payload, *c_payload;
  793. int p_idx = msd.dstat.curr_aid_idx;
  794. if (!aid_map_table.size || !(cd_idx < aid_map_table.size))
  795. goto end;
  796. /* Get index in the aid command list*/
  797. cmd_idx = aid_map_table.cmd_idx[cd_idx];
  798. if(msd.id3 == EVT1_H_REV_I\
  799. || msd.id3 == EVT1_H_REV_J\
  800. || msd.id3 == EVT0_EA8061V_REV_A\
  801. || msd.id3 == EVT2_EA8061V_REV_C\
  802. || msd.id3 == EVT2_EA8061V_REV_D\
  803. || msd.id3 == EVT2_EA8061V_REV_E\
  804. || msd.id3 == EVT2_FRESCO_REV_G\
  805. || msd.id3 == EVT0_EA8061V_KMINI_REV_A\
  806. || msd.id3 == EVT2_EA8061_HESTIA_REV_I\
  807. ||msd.id3 == EVT2_EA8061_HESTIA_REV_J\
  808. || msd.id3 == EVT2_EA8061_HESTIA_REV_A)
  809. c_payload = aid_cmds_list_350.cmd_desc[cmd_idx].payload;
  810. else
  811. c_payload = aid_cmds_list.cmd_desc[cmd_idx].payload;
  812. /* Check if current & previous commands are same */
  813. if (p_idx >= 0) {
  814. if (msd.id3 == EVT1_H_REV_I\
  815. || msd.id3 == EVT1_H_REV_J\
  816. || msd.id3 == EVT0_EA8061V_REV_A\
  817. || msd.id3 == EVT2_EA8061V_REV_C\
  818. || msd.id3 == EVT2_EA8061V_REV_D\
  819. || msd.id3 == EVT2_EA8061V_REV_E\
  820. || msd.id3 == EVT2_FRESCO_REV_G\
  821. || msd.id3 == EVT0_EA8061V_KMINI_REV_A\
  822. || msd.id3 == EVT2_EA8061_HESTIA_REV_I\
  823. ||msd.id3 == EVT2_EA8061_HESTIA_REV_J\
  824. || msd.id3 == EVT2_EA8061_HESTIA_REV_A){
  825. p_payload = aid_cmds_list_350.cmd_desc[p_idx].payload;
  826. payload_size = aid_cmds_list_350.cmd_desc[p_idx].dchdr.dlen;
  827. } else {
  828. p_payload = aid_cmds_list.cmd_desc[p_idx].payload;
  829. payload_size = aid_cmds_list.cmd_desc[p_idx].dchdr.dlen;
  830. }
  831. if (!memcmp(p_payload, c_payload, payload_size))
  832. goto end;
  833. }
  834. /* Get the command desc */
  835. if(msd.id3 == EVT1_H_REV_I\
  836. || msd.id3 == EVT1_H_REV_J\
  837. || msd.id3 == EVT0_EA8061V_REV_A\
  838. || msd.id3 == EVT2_EA8061V_REV_C\
  839. || msd.id3 == EVT2_EA8061V_REV_D\
  840. || msd.id3 == EVT2_EA8061V_REV_E\
  841. || msd.id3 == EVT2_FRESCO_REV_G\
  842. || msd.id3 == EVT0_EA8061V_KMINI_REV_A\
  843. || msd.id3 == EVT2_EA8061_HESTIA_REV_I\
  844. ||msd.id3 == EVT2_EA8061_HESTIA_REV_J\
  845. || msd.id3 == EVT2_EA8061_HESTIA_REV_A)
  846. aid_control.cmd_desc = &(aid_cmds_list_350.cmd_desc[cmd_idx]);
  847. else
  848. aid_control.cmd_desc = &(aid_cmds_list.cmd_desc[cmd_idx]);
  849. aid_control.num_of_cmds = 1;
  850. msd.dstat.curr_aid_idx = cmd_idx;
  851. switch (msd.panel) {
  852. case PANEL_720P_AMOLED_S6E8AA3X01:
  853. /* Do any panel specfific customization here */
  854. break;
  855. }
  856. end:
  857. return aid_control;
  858. }
  859. /*
  860. This function takes acl_map_table and uses cd_idx,
  861. to get the index of the command in elvss command list.
  862. */
  863. #if !defined(NOT_USING_ACL_CONT)
  864. static struct dsi_cmd get_aclcont_control_set(void)
  865. {
  866. struct dsi_cmd aclcont_control = {0,};
  867. int cmd_idx = 0;
  868. int acl_cond = msd.dstat.curr_acl_cond;
  869. if (acl_cond) /* already acl condition setted */
  870. goto end;
  871. /* Get the command desc */
  872. aclcont_control.cmd_desc = &(aclcont_cmds_list.cmd_desc[cmd_idx]);
  873. aclcont_control.num_of_cmds = 1;
  874. msd.dstat.curr_acl_cond = 1;
  875. end:
  876. return aclcont_control;
  877. }
  878. #endif
  879. /*
  880. This function takes acl_map_table and uses cd_idx,
  881. to get the index of the command in elvss command list.
  882. */
  883. static struct dsi_cmd get_acl_control_set(int cd_idx)
  884. {
  885. struct dsi_cmd acl_control = {0,};
  886. int cmd_idx = 0, payload_size = 0;
  887. char *p_payload, *c_payload;
  888. int p_idx = msd.dstat.curr_acl_idx;
  889. if (!acl_map_table.size || !(cd_idx < acl_map_table.size))
  890. goto end;
  891. /* Get index in the acl command list*/
  892. cmd_idx = acl_map_table.cmd_idx[cd_idx];
  893. c_payload = acl_cmds_list.cmd_desc[cmd_idx].payload;
  894. /* Check if current & previous commands are same */
  895. if (p_idx >= 0) {
  896. p_payload = acl_cmds_list.cmd_desc[p_idx].payload;
  897. payload_size = acl_cmds_list.cmd_desc[p_idx].dchdr.dlen;
  898. if (!memcmp(p_payload, c_payload, payload_size))
  899. goto end;
  900. }
  901. /* Get the command desc */
  902. acl_control.cmd_desc = &(acl_cmds_list.cmd_desc[cmd_idx]);
  903. acl_control.num_of_cmds = 1;
  904. msd.dstat.curr_acl_idx = cmd_idx;
  905. switch (msd.panel) {
  906. case PANEL_720P_AMOLED_S6E8AA3X01:
  907. /* Do any panel specfific customization here */
  908. break;
  909. }
  910. end:
  911. return acl_control;
  912. }
  913. static struct dsi_cmd get_acl_control_off_set(void)
  914. {
  915. struct dsi_cmd acl_control = {0,};
  916. int p_idx = msd.dstat.curr_acl_idx;
  917. /* Check if current & previous commands are same */
  918. if (p_idx == 0) {
  919. /* already acl off */
  920. goto end;
  921. }
  922. /* Get the command desc */
  923. acl_control.cmd_desc = &(acl_cmds_list.cmd_desc[0]); /* idx 0 : ACL OFF */
  924. acl_control.num_of_cmds = 1;
  925. msd.dstat.curr_acl_idx = 0;
  926. msd.dstat.curr_acl_cond = 0;
  927. end:
  928. return acl_control;
  929. }
  930. #if defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  931. // ELVSS TEMPERATURE COMPENSATION for S6E3FA0
  932. static struct dsi_cmd get_elvss_tempcompen_control_set(void)
  933. {
  934. struct dsi_cmd elvss_tempcompen_control = {0,};
  935. /* Get the command desc */
  936. if (msd.dstat.temperature >= 0) {
  937. pr_debug("%s temp >= 0 \n",__func__);
  938. elvss_lowtemp_cmds_list.cmd_desc[1].payload[1] = 0x19;
  939. elvss_lowtemp_cmds_list.cmd_desc[2].payload[1] = 0x88;
  940. } else if (msd.dstat.temperature > -20) {
  941. pr_debug("%s 0 > temp > -20 \n",__func__);
  942. elvss_lowtemp_cmds_list.cmd_desc[1].payload[1] = 0x00;
  943. elvss_lowtemp_cmds_list.cmd_desc[2].payload[1] = 0x8C;
  944. } else {
  945. pr_debug("%s temp <= -20 \n",__func__);
  946. elvss_lowtemp_cmds_list.cmd_desc[1].payload[1] = 0x94;
  947. elvss_lowtemp_cmds_list.cmd_desc[2].payload[1] = 0x8C;
  948. }
  949. elvss_tempcompen_control.cmd_desc = elvss_lowtemp_cmds_list.cmd_desc;
  950. elvss_tempcompen_control.num_of_cmds = elvss_lowtemp_cmds_list.num_of_cmds;
  951. return elvss_tempcompen_control;
  952. }
  953. #endif
  954. #if defined(TEMPERATURE_ELVSS)
  955. // ELVSS TEMPERATURE COMPENSATION
  956. static struct dsi_cmd get_elvss_tempcompen_control_set(void)
  957. {
  958. struct dsi_cmd elvss_tempcompen_control = {0,};
  959. int cmd_idx = 0;
  960. /* Get the command desc */
  961. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  962. if(msd.dstat.temperature_value <= 0)
  963. elvss_tempcompen_cmds_list.cmd_desc[cmd_idx].payload[1] = msd.dstat.temperature_value + 0x80;
  964. else
  965. elvss_tempcompen_cmds_list.cmd_desc[cmd_idx].payload[1] = msd.dstat.temperature_value;
  966. #else
  967. elvss_tempcompen_cmds_list.cmd_desc[cmd_idx].payload[6] = msd.dstat.temperature_value;
  968. #endif
  969. elvss_tempcompen_control.cmd_desc = &(elvss_tempcompen_cmds_list.cmd_desc[cmd_idx]);
  970. elvss_tempcompen_control.num_of_cmds = 1;
  971. return elvss_tempcompen_control;
  972. }
  973. #endif
  974. /*
  975. This function takes acl_map_table and uses cd_idx,
  976. to get the index of the command in elvss command list.
  977. */
  978. #ifdef SMART_ACL
  979. static struct dsi_cmd get_elvss_control_set(int cd_idx)
  980. {
  981. struct dsi_cmd elvss_control = {0,};
  982. int cmd_idx = 0;
  983. char *payload;
  984. pr_info("%s for SMART_ACL\n",__func__);
  985. if (!elvss_map_table.size || !(cd_idx < elvss_map_table.size) ||
  986. !smart_acl_elvss_map_table.size ||
  987. !(cd_idx < smart_acl_elvss_map_table.size)) {
  988. pr_err("%s failed mapping elvss table\n",__func__);
  989. goto end;
  990. }
  991. /* Get the command desc */
  992. if(msd.dstat.acl_on || msd.dstat.siop_status) {
  993. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  994. if ((msd.id3 == EVT2_EA8061V_REV_D) || (msd.id3 == EVT2_EA8061V_REV_E) )
  995. smart_acl_elvss_cmds_list.cmd_desc[cmd_idx].payload[1] = 0x4C;
  996. #endif
  997. cmd_idx = smart_acl_elvss_map_table.cmd_idx[cd_idx];
  998. payload = smart_acl_elvss_cmds_list.cmd_desc[cmd_idx].payload;
  999. #if defined(TEMPERATURE_ELVSS_S6E8AA4)
  1000. elvss_lowtemp_cmds_list.cmd_desc[2].payload[2] = smart_acl_elvss_cmds_list.cmd_desc[cmd_idx].payload[2];
  1001. #endif
  1002. elvss_control.cmd_desc = &(smart_acl_elvss_cmds_list.cmd_desc[cmd_idx]);
  1003. pr_info("ELVSS for SMART_ACL cd_idx=%d, cmd_idx=%d\n", cd_idx, cmd_idx);
  1004. } else {
  1005. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1006. if ((msd.id3 == EVT2_EA8061V_REV_D) || (msd.id3 == EVT2_EA8061V_REV_E) )
  1007. elvss_cmds_list.cmd_desc[cmd_idx].payload[1] = 0x5C;
  1008. #endif
  1009. cmd_idx = elvss_map_table.cmd_idx[cd_idx];
  1010. payload = elvss_cmds_list.cmd_desc[cmd_idx].payload;
  1011. #if defined(TEMPERATURE_ELVSS_S6E8AA4)
  1012. elvss_lowtemp_cmds_list.cmd_desc[2].payload[2] = elvss_cmds_list.cmd_desc[cmd_idx].payload[2];
  1013. #endif
  1014. elvss_control.cmd_desc = &(elvss_cmds_list.cmd_desc[cmd_idx]);
  1015. pr_info("ELVSS for normal cd_idx=%d, cmd_idx=%d\n", cd_idx, cmd_idx);
  1016. }
  1017. /*HBM off : B6H(ELVSS SET) 21st para <- default set : Get value in mdss_dsi_panel_dimming_init() */
  1018. #if defined(HBM_RE) && defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1019. if(msd.dstat.hbm_mode) {
  1020. elvss_control.cmd_desc = hbm_hbm_off_elvss_cmds.cmd_desc;
  1021. elvss_control.num_of_cmds = hbm_hbm_off_elvss_cmds.num_of_cmds;
  1022. }
  1023. #endif
  1024. #if defined(TEMPERATURE_ELVSS)
  1025. #if !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1026. // ELVSS lOW TEMPERATURE
  1027. if (msd.dstat.auto_brightness != 6) // if HBM is not set
  1028. {
  1029. if (msd.dstat.temperature <= -20)
  1030. {
  1031. elvss_control.cmd_desc = &(elvss_lowtemp_cmds_list.cmd_desc[cmd_idx]);
  1032. }else {
  1033. }
  1034. }
  1035. #endif
  1036. #endif
  1037. elvss_control.num_of_cmds = 1;
  1038. msd.dstat.curr_elvss_idx = cmd_idx;
  1039. end:
  1040. return elvss_control;
  1041. }
  1042. #else
  1043. static struct dsi_cmd get_elvss_control_set(int cd_idx)
  1044. {
  1045. struct dsi_cmd elvss_control = {0,};
  1046. int cmd_idx = 0, payload_size = 0;
  1047. char *p_payload, *c_payload;
  1048. int p_idx = msd.dstat.curr_elvss_idx;
  1049. if (!elvss_map_table.size || !(cd_idx < elvss_map_table.size))
  1050. {
  1051. pr_err("%s invalid elvss mapping \n",__func__);
  1052. goto end;
  1053. }
  1054. /* Get index in the acl command list*/
  1055. cmd_idx = elvss_map_table.cmd_idx[cd_idx];
  1056. c_payload = elvss_cmds_list.cmd_desc[cmd_idx].payload;
  1057. /* Check if current & previous commands are same */
  1058. if (p_idx >= 0) {
  1059. p_payload = elvss_cmds_list.cmd_desc[p_idx].payload;
  1060. payload_size = elvss_cmds_list.cmd_desc[p_idx].dchdr.dlen;
  1061. if (msd.dstat.curr_elvss_idx == cmd_idx ||
  1062. !memcmp(p_payload, c_payload, payload_size))
  1063. goto end;
  1064. }
  1065. /* Get the command desc */
  1066. #if defined(TEMPERATURE_ELVSS)
  1067. // ELVSS lOW TEMPERATURE
  1068. if (msd.dstat.auto_brightness != 6) // will be changed to 7
  1069. {
  1070. if (msd.dstat.temperature <= -20)
  1071. {
  1072. elvss_control.cmd_desc = &(elvss_lowtemp_cmds_list.cmd_desc[cmd_idx]);
  1073. }else {
  1074. #endif
  1075. elvss_control.cmd_desc = &(elvss_cmds_list.cmd_desc[cmd_idx]);
  1076. #if defined(TEMPERATURE_ELVSS)
  1077. }
  1078. }
  1079. #endif
  1080. elvss_control.num_of_cmds = 1;
  1081. msd.dstat.curr_elvss_idx = cmd_idx;
  1082. switch (msd.panel) {
  1083. case PANEL_720P_AMOLED_S6E8AA3X01:
  1084. /* Do any panel specfific customization here */
  1085. break;
  1086. }
  1087. end:
  1088. return elvss_control;
  1089. }
  1090. #endif
  1091. static struct dsi_cmd get_gamma_control_set(int candella)
  1092. {
  1093. struct dsi_cmd gamma_control = {0,};
  1094. /* Just a safety check to ensure smart dimming data is initialised well */
  1095. BUG_ON(msd.sdimconf->generate_gamma == NULL);
  1096. msd.sdimconf->generate_gamma(candella, &gamma_cmds_list.cmd_desc[0].payload[1]);
  1097. gamma_control.cmd_desc = &(gamma_cmds_list.cmd_desc[0]);
  1098. gamma_control.num_of_cmds = gamma_cmds_list.num_of_cmds;
  1099. return gamma_control;
  1100. }
  1101. static int update_bright_packet(int cmd_count, struct dsi_cmd *cmd_set)
  1102. {
  1103. int i = 0;
  1104. if (cmd_count > (MAX_BR_PACKET_SIZE - 1)) /*cmd_count is index, if cmd_count >12 then panic*/
  1105. panic("over max brightness_packet size(%d).. !!", MAX_BR_PACKET_SIZE);
  1106. for (i = 0; i < cmd_set->num_of_cmds; i++) {
  1107. brightness_packet[cmd_count].payload = \
  1108. cmd_set->cmd_desc[i].payload;
  1109. brightness_packet[cmd_count].dchdr.dlen = \
  1110. cmd_set->cmd_desc[i].dchdr.dlen;
  1111. brightness_packet[cmd_count].dchdr.dtype = \
  1112. cmd_set->cmd_desc[i].dchdr.dtype;
  1113. brightness_packet[cmd_count].dchdr.wait = \
  1114. cmd_set->cmd_desc[i].dchdr.wait;
  1115. cmd_count++;
  1116. }
  1117. return cmd_count;
  1118. }
  1119. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1120. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1121. static struct dsi_cmd get_testKey_set(int enable)/*F0 or F0 F1*/
  1122. {
  1123. struct dsi_cmd testKey = {0,};
  1124. if (enable)
  1125. testKey.cmd_desc = &(test_key_enable_cmds.cmd_desc[0]);
  1126. else
  1127. testKey.cmd_desc = &(test_key_disable_cmds.cmd_desc[0]);
  1128. testKey.num_of_cmds = test_key_disable_cmds.num_of_cmds;
  1129. return testKey;
  1130. }
  1131. #endif
  1132. #if defined(HBM_RE) || defined(CONFIG_HBM_PSRE)
  1133. static struct dsi_cmd get_hbm_etc_control_set(void)
  1134. {
  1135. struct dsi_cmd etc_hbm_control = {0,};
  1136. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  1137. /* Get the command desc */
  1138. if (msd.id3 == EVT0_ID) {
  1139. pr_info("%s for EVT0_FIRST\n",__func__);
  1140. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_list.cmd_desc[0]);
  1141. etc_hbm_control.num_of_cmds = hbm_etc_cmds_list.num_of_cmds;
  1142. } else if (msd.id3 == EVT0_SECOND_ID) {
  1143. pr_info("%s for EVT0_SECOND\n",__func__);
  1144. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_evt0_second_list.cmd_desc[0]);
  1145. etc_hbm_control.num_of_cmds = hbm_etc_cmds_evt0_second_list.num_of_cmds;
  1146. } else if (msd.id3 == EVT1_ID) {
  1147. pr_info("%s for EVT1_FIRST\n",__func__);
  1148. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_evt1_list.cmd_desc[0]);
  1149. etc_hbm_control.num_of_cmds = hbm_etc_cmds_evt1_list.num_of_cmds;
  1150. } else if (msd.id3 == EVT1_SECOND_ID) {
  1151. pr_info("%s for EVT1_SECOND\n",__func__);
  1152. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_evt1_second_list.cmd_desc[0]);
  1153. etc_hbm_control.num_of_cmds = hbm_etc_cmds_evt1_second_list.num_of_cmds;
  1154. } else if (msd.id3 == EVT1_H_REV_I) {
  1155. pr_info("%s for EVT1_revI\n",__func__);
  1156. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_evt1_H_revI_list.cmd_desc[0]);
  1157. etc_hbm_control.num_of_cmds = hbm_etc_cmds_evt1_H_revI_list.num_of_cmds;
  1158. } else if (msd.id3 == EVT1_H_REV_J) {
  1159. pr_info("%s for EVT1_revI\n",__func__);
  1160. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_evt1_H_revJ_list.cmd_desc[0]);
  1161. etc_hbm_control.num_of_cmds = hbm_etc_cmds_evt1_H_revJ_list.num_of_cmds;
  1162. }
  1163. #elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL)
  1164. if ((msd.id3 == EVT0_F_REV_A) || (msd.id3 == EVT0_F_REV_E) ||
  1165. (msd.id3 == EVT0_F_REV_F) || (msd.id3 == EVT2_F_REV_G)) {
  1166. pr_info("%s for F\n",__func__);
  1167. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_evt0_second_list.cmd_desc[0]);
  1168. etc_hbm_control.num_of_cmds = hbm_etc_cmds_evt0_second_list.num_of_cmds;
  1169. }
  1170. #else
  1171. #if defined(TEMPERATURE_ELVSS_S6E8AA4)
  1172. if (msd.dstat.temperature > 0) {
  1173. pr_debug("%s temp > 0 \n",__func__);
  1174. hbm_etc_cmds_list.cmd_desc[0].payload[1] = 0x88;
  1175. } else {
  1176. pr_debug("%s temp <= 0 \n",__func__);
  1177. hbm_etc_cmds_list.cmd_desc[0].payload[1] = 0x8C;
  1178. }
  1179. #endif
  1180. etc_hbm_control.cmd_desc = &(hbm_etc_cmds_list.cmd_desc[0]);
  1181. etc_hbm_control.num_of_cmds = hbm_etc_cmds_list.num_of_cmds;
  1182. #endif
  1183. return etc_hbm_control;
  1184. }
  1185. static struct dsi_cmd get_hbm_gamma_control_set(void)
  1186. {
  1187. struct dsi_cmd gamma_hbm_control = {0,};
  1188. /* Get the command desc */
  1189. gamma_hbm_control.cmd_desc = &(hbm_gamma_cmds_list.cmd_desc[0]);
  1190. gamma_hbm_control.num_of_cmds = hbm_gamma_cmds_list.num_of_cmds;
  1191. return gamma_hbm_control;
  1192. }
  1193. static int make_brightcontrol_hbm_set(int bl_level)
  1194. {
  1195. struct dsi_cmd hbm_etc_control = {0,};
  1196. struct dsi_cmd gamma_control = {0,};
  1197. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1198. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1199. struct dsi_cmd testKey = {0,};
  1200. #endif
  1201. int cmd_count = 0;
  1202. if (msd.dstat.hbm_mode) {
  1203. pr_err("%s : already hbm mode! return .. \n", __func__);
  1204. return 0;
  1205. }
  1206. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1207. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1208. testKey = get_testKey_set(1);
  1209. cmd_count = update_bright_packet(cmd_count, &testKey);
  1210. #endif
  1211. /*gamma*/
  1212. gamma_control = get_hbm_gamma_control_set();
  1213. cmd_count = update_bright_packet(cmd_count, &gamma_control);
  1214. hbm_etc_control = get_hbm_etc_control_set();
  1215. cmd_count = update_bright_packet(cmd_count, &hbm_etc_control);
  1216. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1217. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1218. testKey = get_testKey_set(0);
  1219. cmd_count = update_bright_packet(cmd_count, &testKey);
  1220. #endif
  1221. /* for non hbm mode : reset */
  1222. msd.dstat.curr_elvss_idx = -1;
  1223. msd.dstat.curr_acl_idx = -1;
  1224. msd.dstat.curr_aid_idx = -1;
  1225. msd.dstat.curr_acl_cond = 0;
  1226. LCD_DEBUG("bright_level: HBM %d\n", cmd_count);
  1227. return cmd_count;
  1228. }
  1229. #if defined(FORCE_500CD)
  1230. static struct dsi_cmd get_force_500cd_control_set(void)
  1231. {
  1232. struct dsi_cmd force_500cd_etc_control = {0,};
  1233. force_500cd_etc_control.cmd_desc = &(force_500.cmd_desc[0]);
  1234. force_500cd_etc_control.num_of_cmds = force_500.num_of_cmds;
  1235. return force_500cd_etc_control;
  1236. }
  1237. static int make_force_500cd_set(int bl_level)
  1238. {
  1239. struct dsi_cmd force500_etc_control = {0,};
  1240. struct dsi_cmd gamma_control = {0,};
  1241. int cmd_count = 0;
  1242. if (msd.dstat.hbm_mode) {
  1243. pr_err("%s : already hbm mode! return .. \n", __func__);
  1244. return 0;
  1245. }
  1246. /*gamma*/
  1247. gamma_control = get_hbm_gamma_control_set();
  1248. cmd_count = update_bright_packet(cmd_count, &gamma_control);
  1249. force500_etc_control = get_force_500cd_control_set();
  1250. cmd_count = update_bright_packet(cmd_count, &force500_etc_control);
  1251. /* for non hbm mode : reset */
  1252. msd.dstat.curr_elvss_idx = -1;
  1253. msd.dstat.curr_acl_idx = -1;
  1254. msd.dstat.curr_aid_idx = -1;
  1255. msd.dstat.curr_acl_cond = 0;
  1256. LCD_DEBUG("bright_level: Force 500Cd %d\n", cmd_count);
  1257. return cmd_count;
  1258. }
  1259. #endif
  1260. #endif
  1261. static int make_brightcontrol_set(int bl_level)
  1262. {
  1263. struct dsi_cmd elvss_control = {0, 0, 0, 0, 0};
  1264. struct dsi_cmd acl_control = {0, 0, 0, 0, 0};
  1265. struct dsi_cmd aid_control = {0, 0, 0, 0, 0};
  1266. struct dsi_cmd gamma_control = {0, 0, 0, 0, 0};
  1267. #if !defined(NOT_USING_ACL_CONT)
  1268. struct dsi_cmd aclcont_control = {0, 0, 0, 0, 0};
  1269. #endif
  1270. #if defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  1271. struct dsi_cmd temperature_elvss_control = {0, 0, 0, 0, 0};
  1272. #endif
  1273. #if defined(TEMPERATURE_ELVSS)
  1274. struct dsi_cmd elvss_compen_control = {0, 0, 0, 0, 0};
  1275. #endif
  1276. int cmd_count = 0, cd_idx = 0, cd_level =0;
  1277. /* level2 enable */
  1278. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1279. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1280. struct dsi_cmd testKey = get_testKey_set(1);
  1281. cmd_count = update_bright_packet(cmd_count, &testKey);
  1282. #endif
  1283. cd_idx = get_cmd_idx(bl_level);
  1284. cd_level = get_candela_value(bl_level);
  1285. /* aid/aor */
  1286. aid_control = get_aid_aor_control_set(cd_idx);
  1287. cmd_count = update_bright_packet(cmd_count, &aid_control);
  1288. /* acl */
  1289. if (msd.dstat.acl_on||msd.dstat.siop_status) {
  1290. #if !defined(NOT_USING_ACL_CONT)
  1291. aclcont_control = get_aclcont_control_set();
  1292. cmd_count = update_bright_packet(cmd_count, &aclcont_control);
  1293. #endif
  1294. acl_control = get_acl_control_set(cd_idx);
  1295. cmd_count = update_bright_packet(cmd_count, &acl_control);
  1296. } else {
  1297. /* acl off (hbm off) */
  1298. acl_control = get_acl_control_off_set();
  1299. cmd_count = update_bright_packet(cmd_count, &acl_control);
  1300. }
  1301. /*elvss*/
  1302. elvss_control = get_elvss_control_set(cd_idx);
  1303. cmd_count = update_bright_packet(cmd_count, &elvss_control);
  1304. #if defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  1305. // ELVSS TEMPERATURE COMPENSATION
  1306. // ELVSS for Temperature set cmd should be sent after normal elvss set cmd
  1307. temperature_elvss_control = get_elvss_tempcompen_control_set();
  1308. cmd_count = update_bright_packet(cmd_count, &temperature_elvss_control);
  1309. #endif
  1310. #if defined(TEMPERATURE_ELVSS)
  1311. // ELVSS TEMPERATURE COMPENSATION
  1312. if (msd.dstat.temper_need_update) {
  1313. elvss_compen_control = get_elvss_tempcompen_control_set();
  1314. cmd_count = update_bright_packet(cmd_count, &elvss_compen_control);
  1315. msd.dstat.temper_need_update = 0;
  1316. }
  1317. #endif
  1318. /*gamma*/
  1319. #if (defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL) \
  1320. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061))\
  1321. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1322. // kyNam_131228_
  1323. if( get_oled_id() == 0)
  1324. {
  1325. int i,j;
  1326. cmd_count = 0;
  1327. /* If you cannot use AID-dimming, you can use temporary-gamma */
  1328. for( i = 1; i<=30; i++ )
  1329. {
  1330. // kyNam_140117_ sample for Fresco_KOR
  1331. /* calculator : 5<x<160 -> 92<gamma<113 */
  1332. if( bl_level < 160 ) j = (113-92)*(bl_level-5)/(160-5) +92;
  1333. /* calculator : 160<x<255 -> 113<gamma<130 */
  1334. else j = (130-113)*(bl_level-160)/(255-160) +113;
  1335. if( i==1 || i==3 || i==5 ) j = ((j*2)>>8);
  1336. if( i==2 || i==4 || i==6 ) j*=2;
  1337. gamma_cmds_list.cmd_desc[1].payload[i] = (j & 0xFF);
  1338. }
  1339. gamma_control.cmd_desc = &(gamma_cmds_list.cmd_desc[0]);
  1340. gamma_control.num_of_cmds = gamma_cmds_list.num_of_cmds;
  1341. cmd_count = update_bright_packet(cmd_count, &gamma_control);
  1342. }
  1343. else
  1344. {
  1345. gamma_control = get_gamma_control_set(cd_level);
  1346. cmd_count = update_bright_packet(cmd_count, &gamma_control);
  1347. }
  1348. #else
  1349. gamma_control = get_gamma_control_set(cd_level);
  1350. cmd_count = update_bright_packet(cmd_count, &gamma_control);
  1351. #endif
  1352. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1353. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1354. testKey = get_testKey_set(0);
  1355. cmd_count = update_bright_packet(cmd_count, &testKey);
  1356. #endif
  1357. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL) || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1358. LCD_DEBUG("bright_level: %d, candela_idx: %d( %d cd ), "\
  1359. "cmd_count(aid,acl,elvss,gamma)::(%d,%d,%d,%d)%d\n",
  1360. #elif defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  1361. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1362. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1363. LCD_DEBUG("bright_level: %d, candela_idx: %d( %d cd ), "\
  1364. "cmd_count(aid,acl,elvss,temperature,gamma)::(%d,%d,%d,%d)%d\n",
  1365. #elif defined(TEMPERATURE_ELVSS_S6E3FA0)
  1366. LCD_DEBUG("bright_level: %d, candela_idx: %d( %d cd ), "\
  1367. "cmd_count(aid,acl,acl_ctrl,elvss,temperature,gamma)::(%d,%d,%d,%d,%d,%d)%d\n",
  1368. #else
  1369. LCD_DEBUG("bright_level: %d, candela_idx: %d( %d cd ), "\
  1370. "cmd_count(aid,acl,acl_ctrl,elvss,temperature,gamma)::(%d,%d,%d,%d,%d)%d\n",
  1371. #endif
  1372. msd.dstat.bright_level, cd_idx, cd_level,
  1373. aid_control.num_of_cmds,
  1374. acl_control.num_of_cmds,
  1375. #if !defined(NOT_USING_ACL_CONT)
  1376. aclcont_control.num_of_cmds,
  1377. #endif
  1378. elvss_control.num_of_cmds,
  1379. #if defined(TEMPERATURE_ELVSS_S6E3FA0)
  1380. temperature_elvss_control.num_of_cmds,
  1381. #endif
  1382. gamma_control.num_of_cmds,
  1383. cmd_count);
  1384. return cmd_count;
  1385. }
  1386. static ssize_t mipi_samsung_disp_acl_store(struct device *dev,
  1387. struct device_attribute *attr, const char *buf, size_t size)
  1388. {
  1389. struct msm_fb_data_type *mfd = msd.mfd;
  1390. int acl_set;
  1391. acl_set = msd.dstat.acl_on;
  1392. if (sysfs_streq(buf, "1"))
  1393. acl_set = true;
  1394. else if (sysfs_streq(buf, "0"))
  1395. acl_set = false;
  1396. else
  1397. pr_info("%s: Invalid argument!!", __func__);
  1398. if (mfd->panel_power_on) {
  1399. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  1400. if (acl_set) {
  1401. msd.dstat.acl_on = true;
  1402. } else {
  1403. msd.dstat.acl_on = false;
  1404. msd.dstat.curr_acl_idx = -1;
  1405. }
  1406. pr_info("%s: acl on : acl %d", __func__, msd.dstat.acl_on);
  1407. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1408. #else
  1409. if (acl_set && !(msd.dstat.acl_on||msd.dstat.siop_status)) {
  1410. msd.dstat.acl_on = true;
  1411. pr_info("%s: acl on : acl %d, siop %d", __func__,
  1412. msd.dstat.acl_on, msd.dstat.siop_status);
  1413. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1414. } else if (!acl_set && msd.dstat.acl_on && !msd.dstat.siop_status) {
  1415. msd.dstat.acl_on = false;
  1416. msd.dstat.curr_acl_idx = -1;
  1417. pr_info("%s: acl off : acl %d, siop %d", __func__,
  1418. msd.dstat.acl_on, msd.dstat.siop_status);
  1419. if(msd.dstat.auto_brightness == 6)
  1420. pr_info("%s: HBM mode No ACL off!!", __func__);
  1421. #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL
  1422. else
  1423. mipi_samsung_disp_send_cmd(PANEL_ACL_OFF, true);
  1424. #endif
  1425. #ifdef SMART_ACL
  1426. /* If SMART_ACL enabled, elvss table shoud be set again */
  1427. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1428. #endif
  1429. } else {
  1430. msd.dstat.acl_on = acl_set;
  1431. pr_info("%s: skip but acl update!! acl %d, siop %d", __func__,
  1432. msd.dstat.acl_on, msd.dstat.siop_status);
  1433. }
  1434. #endif
  1435. }else {
  1436. pr_info("%s: panel is off state. updating state value.\n",
  1437. __func__);
  1438. msd.dstat.acl_on = acl_set;
  1439. }
  1440. return size;
  1441. }
  1442. #if defined(octa_manufacture_date)
  1443. static ssize_t manufacture_date_show(struct device *dev,
  1444. struct device_attribute *attr, char *buf)
  1445. {
  1446. u16 year;
  1447. u8 month;
  1448. u8 day;
  1449. pr_info("C8 41th : %02x\n", mdate_buffer[0]);
  1450. pr_info("C8 42th : %02x\n", mdate_buffer[1]);
  1451. year = ((mdate_buffer[0] & 0xF0)>>4) + 2011;
  1452. month = mdate_buffer[0] & 0x0F;
  1453. day = mdate_buffer[1] & 0x1F;
  1454. sprintf(buf, "%d, %d, %d\n", year, month, day);
  1455. return strlen(buf);
  1456. }
  1457. #endif
  1458. static ssize_t mipi_samsung_disp_siop_show(struct device *dev,
  1459. struct device_attribute *attr, char *buf)
  1460. {
  1461. int rc;
  1462. rc = snprintf((char *)buf, PAGE_SIZE, "%d\n", msd.dstat.siop_status);
  1463. pr_info("siop status: %d\n", *buf);
  1464. return rc;
  1465. }
  1466. static ssize_t mipi_samsung_disp_siop_store(struct device *dev,
  1467. struct device_attribute *attr, const char *buf, size_t size)
  1468. {
  1469. struct msm_fb_data_type *mfd = msd.mfd;
  1470. int siop_set;
  1471. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  1472. msd.dstat.siop_status = false;
  1473. return size;
  1474. #endif
  1475. siop_set = msd.dstat.siop_status;
  1476. if (sysfs_streq(buf, "1"))
  1477. siop_set = true;
  1478. else if (sysfs_streq(buf, "0"))
  1479. siop_set = false;
  1480. else
  1481. pr_info("%s: Invalid argument!!", __func__);
  1482. if (mfd->panel_power_on) {
  1483. if (siop_set && !(msd.dstat.acl_on||msd.dstat.siop_status)) {
  1484. msd.dstat.siop_status = true;
  1485. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1486. pr_info("%s: acl on : acl %d, siop %d", __func__,
  1487. msd.dstat.acl_on, msd.dstat.siop_status);
  1488. } else if (!siop_set && !msd.dstat.acl_on && msd.dstat.siop_status) {
  1489. mutex_lock(&msd.lock);
  1490. msd.dstat.siop_status = false;
  1491. msd.dstat.curr_acl_idx = -1;
  1492. if(msd.dstat.auto_brightness == 6)
  1493. pr_info("%s: HBM mode No ACL off!!", __func__);
  1494. #ifdef CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL
  1495. else
  1496. mipi_samsung_disp_send_cmd(PANEL_ACL_OFF, false);
  1497. #endif
  1498. #ifdef SMART_ACL
  1499. /* If SMART_ACL enabled, elvss table shoud be set again */
  1500. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, false);
  1501. #endif
  1502. mutex_unlock(&msd.lock);
  1503. pr_info("%s: acl off : acl %d, siop %d", __func__,
  1504. msd.dstat.acl_on, msd.dstat.siop_status);
  1505. } else {
  1506. msd.dstat.siop_status = siop_set;
  1507. pr_info("%s: skip but siop update!! acl %d, siop %d", __func__,
  1508. msd.dstat.acl_on, msd.dstat.siop_status);
  1509. }
  1510. }else {
  1511. msd.dstat.siop_status = siop_set;
  1512. pr_info("%s: panel is off state. updating state value.\n",
  1513. __func__);
  1514. }
  1515. return size;
  1516. }
  1517. #ifdef LDI_FPS_CHANGE
  1518. static unsigned int current_ldi_fps=0;
  1519. static unsigned int current_ldi_fps_otp=0;
  1520. unsigned int current_change_ldi_fps=0;
  1521. static int mipi_samsung_read_nv_mem(struct mdss_panel_data *pdata, struct dsi_cmd *nv_read_cmds, char *buffer);
  1522. int ldi_fps(unsigned int input_fps)
  1523. {
  1524. int dest_fps_delta;
  1525. const int proper_fps = 60300;
  1526. pr_info("%s: input_fps=%d\n", __func__, input_fps);
  1527. if((msd.manufacture_id & 0xFF) <= 0x01) {
  1528. pr_err("%s:LDI EVT0 Not Support. Skip!! \n",__func__);
  1529. return 0;
  1530. }
  1531. if(input_fps < 57000 || input_fps > 63000) {
  1532. pr_err("%s:Invalid input_fps : %d\n",__func__,input_fps);
  1533. return 0;
  1534. }
  1535. if(msd.mfd->resume_state == MIPI_RESUME_STATE) {
  1536. dest_fps_delta = (proper_fps - (int)input_fps)/200;
  1537. if(dest_fps_delta == 0) {
  1538. pr_info("%s::No FPS Delta, Skip!! \n",__func__);
  1539. return 1;
  1540. }
  1541. dest_fps_delta *= -1;
  1542. pr_info("%s:dest_fps_delta = %d \n", __func__, dest_fps_delta);
  1543. pr_info("%s:current_ldi_fps_register_value=0x%x\n",__func__,current_ldi_fps);
  1544. pr_info("%s:dest_ldi_fps_register_value=0x%x\n",__func__,current_ldi_fps+dest_fps_delta);
  1545. current_ldi_fps = current_ldi_fps + dest_fps_delta;
  1546. if(current_ldi_fps < 0x35 || current_ldi_fps > 0x55)
  1547. panic("LDI FPS Check input_fps");
  1548. write_ldi_fps_cmds.cmd_desc[1].payload[1] = current_ldi_fps;
  1549. mipi_samsung_disp_send_cmd(PANEL_MTP_ENABLE, true);
  1550. mipi_samsung_disp_send_cmd(PANEL_LDI_FPS_CHANGE, true);
  1551. mipi_samsung_disp_send_cmd(PANEL_MTP_DISABLE, true);
  1552. } else {
  1553. pr_err("%s:Panel is off state!!\n",__func__);
  1554. return 0;
  1555. }
  1556. return 1;
  1557. }
  1558. EXPORT_SYMBOL(ldi_fps);
  1559. #endif
  1560. static int atoi(const char *name)
  1561. {
  1562. int val = 0;
  1563. for (;; name++) {
  1564. switch (*name) {
  1565. case '0' ... '9':
  1566. val = 10*val+(*name-'0');
  1567. break;
  1568. default:
  1569. return val;
  1570. }
  1571. }
  1572. }
  1573. static ssize_t mipi_samsung_backlight_show(struct device *dev,
  1574. struct device_attribute *attr, char *buf)
  1575. {
  1576. int rc;
  1577. rc = snprintf((char *)buf, PAGE_SIZE, "%d\n",
  1578. msd.dstat.bright_level );
  1579. pr_info("backlight : %d\n", *buf);
  1580. return rc;
  1581. }
  1582. static ssize_t mipi_samsung_backlight_store(struct device *dev,
  1583. struct device_attribute *attr, const char *buf, size_t size)
  1584. {
  1585. int bl_level = atoi(buf);
  1586. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  1587. if (!msd.dstat.is_smart_dim_loaded)
  1588. return size;
  1589. #endif
  1590. pr_info("%s : level (%d)\n",__func__,bl_level);
  1591. msd.dstat.bright_level = bl_level;
  1592. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1593. return size;
  1594. }
  1595. static ssize_t mipi_samsung_auto_brightness_show(struct device *dev,
  1596. struct device_attribute *attr, char *buf)
  1597. {
  1598. int rc;
  1599. rc = snprintf((char *)buf, PAGE_SIZE, "%d\n",
  1600. msd.dstat.auto_brightness);
  1601. pr_info("auto_brightness: %d\n", *buf);
  1602. return rc;
  1603. }
  1604. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  1605. static unsigned int mipi_samsung_manufacture_id(struct mdss_panel_data *pdata);
  1606. static int mdss_dsi_panel_dimming_init(struct mdss_panel_data *pdata);
  1607. #endif
  1608. static ssize_t mipi_samsung_auto_brightness_store(struct device *dev,
  1609. struct device_attribute *attr, const char *buf, size_t size)
  1610. {
  1611. static int first_auto_br = 0;
  1612. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  1613. if (!msd.manufacture_id) {
  1614. msd.manufacture_id = mipi_samsung_manufacture_id(msd.pdata);
  1615. mdss_dsi_panel_dimming_init(msd.pdata);
  1616. }
  1617. #endif
  1618. if (sysfs_streq(buf, "0"))
  1619. msd.dstat.auto_brightness = 0;
  1620. else if (sysfs_streq(buf, "1"))
  1621. msd.dstat.auto_brightness = 1;
  1622. else if (sysfs_streq(buf, "2"))
  1623. msd.dstat.auto_brightness = 2;
  1624. else if (sysfs_streq(buf, "3"))
  1625. msd.dstat.auto_brightness = 3;
  1626. else if (sysfs_streq(buf, "4"))
  1627. msd.dstat.auto_brightness = 4;
  1628. else if (sysfs_streq(buf, "5"))
  1629. msd.dstat.auto_brightness = 5;
  1630. else if (sysfs_streq(buf, "6")) // HBM mode
  1631. msd.dstat.auto_brightness = 6;
  1632. else if (sysfs_streq(buf, "7"))
  1633. msd.dstat.auto_brightness = 7;
  1634. else
  1635. pr_info("%s: Invalid argument!!", __func__);
  1636. if (!first_auto_br) {
  1637. pr_info("%s : skip first auto brightness store (%d) (%d)!!\n",
  1638. __func__, msd.dstat.auto_brightness, msd.dstat.bright_level);
  1639. first_auto_br++;
  1640. return size;
  1641. }
  1642. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  1643. if (msd.dstat.on == 1 && msd.mfd->resume_state == MIPI_RESUME_STATE) {
  1644. pr_info("%s %d %d\n", __func__, msd.dstat.auto_brightness, msd.dstat.bright_level);
  1645. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1646. } else {
  1647. pr_info("%s : panel is off state!! on=%d, state=%d\n", __func__, msd.dstat.on, msd.mfd->resume_state);
  1648. }
  1649. #elif defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1650. if (msd.mfd->resume_state == MIPI_RESUME_STATE) {
  1651. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1652. #if defined(CONFIG_MDNIE_LITE_TUNING)
  1653. mDNIe_Set_Mode(); // LOCAL CE tuning
  1654. #endif
  1655. pr_info("%s %d %d\n", __func__, msd.dstat.auto_brightness, msd.dstat.bright_level);
  1656. } else {
  1657. pr_info("%s : panel is off state!!\n", __func__);
  1658. }
  1659. #else
  1660. if (msd.mfd->resume_state == MIPI_RESUME_STATE) {
  1661. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1662. pr_info("%s %d %d\n", __func__, msd.dstat.auto_brightness, msd.dstat.bright_level);
  1663. } else {
  1664. pr_info("%s : panel is off state!!\n", __func__);
  1665. }
  1666. #endif
  1667. return size;
  1668. }
  1669. #if defined(TEMPERATURE_ELVSS) || defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  1670. static ssize_t mipi_samsung_temperature_show(struct device *dev,
  1671. struct device_attribute *attr, char *buf)
  1672. {
  1673. int rc;
  1674. rc = snprintf((char *)buf, 40,"-20, -19, 0, 1, 30, 40\n");
  1675. pr_info("%s msd.mpd->temperature : %d msd.mpd->temperature_value : 0x%x", __func__,
  1676. msd.dstat.temperature, msd.dstat.temperature_value);
  1677. return rc;
  1678. }
  1679. static ssize_t mipi_samsung_temperature_store(struct device *dev,
  1680. struct device_attribute *attr, const char *buf, size_t size)
  1681. {
  1682. int temp;
  1683. sscanf(buf, "%d" , &msd.dstat.temperature);
  1684. temp = msd.dstat.temperature;
  1685. if (temp > 0)
  1686. msd.dstat.temperature_value = (char)temp;
  1687. else {
  1688. temp *= -1;
  1689. msd.dstat.temperature_value = (char)temp;
  1690. msd.dstat.temperature_value |=0x80;
  1691. }
  1692. msd.dstat.temper_need_update = 1;
  1693. if(msd.mfd->resume_state == MIPI_RESUME_STATE) {
  1694. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1695. pr_info("mipi_samsung_temperature_store %d\n", msd.dstat.bright_level);
  1696. pr_info("%s msd.dstat.temperature : %d msd.dstat.temperature_value : 0x%x", __func__,
  1697. msd.dstat.temperature, msd.dstat.temperature_value);
  1698. } else {
  1699. pr_info("%s: skip but temperature update!! temperature %d, temperature_value %d", __func__,
  1700. msd.dstat.temperature, msd.dstat.temperature_value);
  1701. }
  1702. return size;
  1703. }
  1704. #endif
  1705. #if defined(PARTIAL_UPDATE)
  1706. static int partial_disp_range[2];
  1707. static ssize_t mipi_samsung_disp_partial_disp_show(struct device *dev,
  1708. struct device_attribute *attr, char *buf)
  1709. {
  1710. int rc;
  1711. rc = snprintf((char *)buf, 40,"partial display range %d to %d \n", partial_disp_range[0], partial_disp_range[1]);
  1712. pr_info("partial display range %d to %d \n", partial_disp_range[0], partial_disp_range[1]);
  1713. return rc;
  1714. }
  1715. static ssize_t mipi_samsung_disp_partial_disp_store(struct device *dev,
  1716. struct device_attribute *attr, const char *buf, size_t size)
  1717. {
  1718. sscanf(buf, "%d %d" , &partial_disp_range[0], &partial_disp_range[1]);
  1719. pr_info("%s: partial_disp range[0] = 0x%x, range[1] = 0x%x\n", __func__, partial_disp_range[0], partial_disp_range[1]);
  1720. if(partial_disp_range[0] > 1919 || partial_disp_range[1] > 1919)
  1721. {
  1722. pr_err("%s:Invalid Input\n",__func__);
  1723. return -EINVAL;
  1724. }
  1725. partialdisp_on_cmd.cmd_desc[0].payload[1] = (partial_disp_range[0] >> 8) & 0xFF;/*select msb 1byte*/
  1726. partialdisp_on_cmd.cmd_desc[0].payload[2] = partial_disp_range[0] & 0xFF;
  1727. partialdisp_on_cmd.cmd_desc[0].payload[3] = (partial_disp_range[1] >> 8) & 0xFF;/*select msb 1byte*/
  1728. partialdisp_on_cmd.cmd_desc[0].payload[4] = partial_disp_range[1] & 0xFF;
  1729. if (msd.dstat.on) {
  1730. if (partial_disp_range[0] || partial_disp_range[1])
  1731. mipi_samsung_disp_send_cmd(PANEL_PARTIAL_ON, true);
  1732. else
  1733. mipi_samsung_disp_send_cmd(PANEL_PARTIAL_OFF, true);
  1734. } else {
  1735. pr_info("%s : LCD is off state\n", __func__);
  1736. return -EINVAL;
  1737. }
  1738. pr_info("%s: partialdisp_on_cmd = 0x%x\n", __func__, partialdisp_on_cmd.cmd_desc[0].payload[1]);
  1739. pr_info("%s: partialdisp_on_cmd = 0x%x\n", __func__, partialdisp_on_cmd.cmd_desc[0].payload[2]);
  1740. pr_info("%s: partialdisp_on_cmd = 0x%x\n", __func__, partialdisp_on_cmd.cmd_desc[0].payload[3]);
  1741. pr_info("%s: partialdisp_on_cmd = 0x%x\n", __func__, partialdisp_on_cmd.cmd_desc[0].payload[4]);
  1742. return size;
  1743. }
  1744. #endif
  1745. #if defined(FORCE_500CD)
  1746. static ssize_t mipi_samsung_force_500cd_show(struct device *dev,
  1747. struct device_attribute *attr, char *buf)
  1748. {
  1749. pr_info("Node for make brightness as 500Cd \n");
  1750. return 0;
  1751. }
  1752. static ssize_t mipi_samsung_force_500cd_store(struct device *dev,
  1753. struct device_attribute *attr, const char *buf, size_t size)
  1754. {
  1755. int input;
  1756. sscanf(buf, "%d " , &input);
  1757. pr_info("%s: input = %d\n", __func__, input);
  1758. if (msd.dstat.on) {
  1759. if(input) {
  1760. pr_info("Force 500Cd Enable\n");
  1761. mipi_samsung_disp_send_cmd(PANEl_FORCE_500CD, true);
  1762. pr_info("Finish to make 500Cd \n");
  1763. } else {
  1764. pr_info("Force 500Cd Disable\n");
  1765. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  1766. pr_info("Finish to Disable 500Cd \n");
  1767. }
  1768. } else {
  1769. pr_info("%s : LCD is off state\n", __func__);
  1770. return -EINVAL;
  1771. }
  1772. return size;
  1773. }
  1774. #endif
  1775. static struct lcd_ops mipi_samsung_disp_props = {
  1776. .get_power = NULL,
  1777. .set_power = NULL,
  1778. };
  1779. static DEVICE_ATTR(lcd_power, S_IRUGO | S_IWUSR,
  1780. mipi_samsung_disp_get_power,
  1781. mipi_samsung_disp_set_power);
  1782. static DEVICE_ATTR(lcd_type, S_IRUGO, mipi_samsung_disp_lcdtype_show, NULL);
  1783. static DEVICE_ATTR(window_type, S_IRUGO,
  1784. mipi_samsung_disp_windowtype_show, NULL);
  1785. static DEVICE_ATTR(power_reduce, S_IRUGO | S_IWUSR | S_IWGRP,
  1786. mipi_samsung_disp_acl_show,
  1787. mipi_samsung_disp_acl_store);
  1788. static DEVICE_ATTR(auto_brightness, S_IRUGO | S_IWUSR | S_IWGRP,
  1789. mipi_samsung_auto_brightness_show,
  1790. mipi_samsung_auto_brightness_store);
  1791. static DEVICE_ATTR(backlight, S_IRUGO | S_IWUSR | S_IWGRP,
  1792. mipi_samsung_backlight_show,
  1793. mipi_samsung_backlight_store);
  1794. #if defined(TEMPERATURE_ELVSS) || defined( TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  1795. static DEVICE_ATTR(temperature, S_IRUGO | S_IWUSR | S_IWGRP,
  1796. mipi_samsung_temperature_show,
  1797. mipi_samsung_temperature_store);
  1798. #endif
  1799. static DEVICE_ATTR(siop_enable, S_IRUGO | S_IWUSR | S_IWGRP,
  1800. mipi_samsung_disp_siop_show,
  1801. mipi_samsung_disp_siop_store);
  1802. #if defined(PARTIAL_UPDATE)
  1803. static DEVICE_ATTR(partial_disp, S_IRUGO | S_IWUSR | S_IWGRP,
  1804. mipi_samsung_disp_partial_disp_show,
  1805. mipi_samsung_disp_partial_disp_store);
  1806. #endif
  1807. #if defined(octa_manufacture_date)
  1808. static DEVICE_ATTR(manufacture_date, S_IRUGO,
  1809. manufacture_date_show, NULL);
  1810. #endif
  1811. #if defined(FORCE_500CD)
  1812. static DEVICE_ATTR(force_500cd, S_IRUGO | S_IWUSR | S_IWGRP,
  1813. mipi_samsung_force_500cd_show,
  1814. mipi_samsung_force_500cd_store);
  1815. #endif
  1816. #endif
  1817. #if !defined(CONFIG_FB_MSM_EDP_SAMSUNG)
  1818. static int __init current_boot_mode(char *mode)
  1819. {
  1820. /*
  1821. * 1,2 is recovery booting
  1822. * 0 is normal booting
  1823. */
  1824. if ((strncmp(mode, "1", 1) == 0)||(strncmp(mode, "2", 1) == 0))
  1825. msd.dstat.recovery_boot_mode = 1;
  1826. else
  1827. msd.dstat.recovery_boot_mode = 0;
  1828. pr_debug("%s %s", __func__, msd.dstat.recovery_boot_mode == 1 ?
  1829. "recovery" : "normal");
  1830. return 1;
  1831. }
  1832. __setup("androidboot.boot_recovery=", current_boot_mode);
  1833. #endif
  1834. void mdss_dsi_cmds_send(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmds, int cnt,int flag)
  1835. {
  1836. struct dcs_cmd_req cmdreq;
  1837. if (get_lcd_attached() == 0)
  1838. {
  1839. printk("%s: get_lcd_attached(0)!\n",__func__);
  1840. return;
  1841. }
  1842. memset(&cmdreq, 0, sizeof(cmdreq));
  1843. if (flag & CMD_REQ_SINGLE_TX) {
  1844. cmdreq.flags = CMD_REQ_SINGLE_TX | CMD_CLK_CTRL | CMD_REQ_COMMIT;
  1845. }else
  1846. cmdreq.flags = CMD_REQ_COMMIT | CMD_CLK_CTRL;
  1847. cmdreq.cmds = cmds;
  1848. cmdreq.cmds_cnt = cnt;
  1849. cmdreq.rlen = 0;
  1850. cmdreq.cb = NULL;
  1851. /*
  1852. * This mutex is to sync up with dynamic FPS changes
  1853. * so that DSI lockups shall not happen
  1854. */
  1855. BUG_ON(msd.ctrl_pdata == NULL);
  1856. mutex_lock(&msd.ctrl_pdata->dfps_mutex);
  1857. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  1858. mutex_unlock(&msd.ctrl_pdata->dfps_mutex);
  1859. }
  1860. u32 mdss_dsi_cmd_receive(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmd, int rlen)
  1861. {
  1862. struct dcs_cmd_req cmdreq;
  1863. char *buf;
  1864. buf = kmalloc(sizeof(rlen), GFP_KERNEL);
  1865. memset(&cmdreq, 0, sizeof(cmdreq));
  1866. cmdreq.cmds = cmd;
  1867. cmdreq.cmds_cnt = 1;
  1868. cmdreq.flags = CMD_REQ_RX | CMD_REQ_COMMIT;
  1869. cmdreq.rbuf = buf;
  1870. cmdreq.rlen = rlen;
  1871. cmdreq.cb = NULL; /* call back */
  1872. /*
  1873. * This mutex is to sync up with dynamic FPS changes
  1874. * so that DSI lockups shall not happen
  1875. */
  1876. BUG_ON(msd.ctrl_pdata == NULL);
  1877. mutex_lock(&msd.ctrl_pdata->dfps_mutex);
  1878. mdss_dsi_cmdlist_put(ctrl, &cmdreq);
  1879. mutex_unlock(&msd.ctrl_pdata->dfps_mutex);
  1880. /*
  1881. * blocked here, untill call back called
  1882. */
  1883. kfree(buf);
  1884. return ctrl->rx_buf.len;
  1885. }
  1886. static int samsung_nv_read(struct dsi_cmd_desc *desc, char *destBuffer,
  1887. int srcLength, struct mdss_panel_data *pdata, int startoffset)
  1888. {
  1889. int loop_limit = 0;
  1890. /* first byte is size of Register */
  1891. static char packet_size[] = { 0x07, 0 };
  1892. static struct dsi_cmd_desc s6e8aa0_packet_size_cmd = {
  1893. {DTYPE_MAX_PKTSIZE, 1, 0, 0, 0, sizeof(packet_size)},
  1894. packet_size };
  1895. /* second byte is Read-position */
  1896. static char reg_read_pos[] = { 0xB0, 0x00 };
  1897. static struct dsi_cmd_desc s6e8aa0_read_pos_cmd = {
  1898. {DTYPE_DCS_WRITE1, 1, 0, 0, 0, sizeof(reg_read_pos)},
  1899. reg_read_pos };
  1900. int read_pos = startoffset;
  1901. int read_count = 0;
  1902. int show_cnt;
  1903. int i, j;
  1904. char show_buffer[256];
  1905. int show_buffer_pos = 0;
  1906. int read_size = 0;
  1907. show_buffer_pos +=
  1908. snprintf(show_buffer, 256, "read_reg : %X[%d] : ",
  1909. desc[0].payload[0], srcLength);
  1910. loop_limit = (srcLength + packet_size[0] - 1)
  1911. / packet_size[0];
  1912. mdss_dsi_cmds_send(msd.ctrl_pdata, &(s6e8aa0_packet_size_cmd), 1, 0);
  1913. show_cnt = 0;
  1914. for (j = 0; j < loop_limit; j++) {
  1915. reg_read_pos[1] = read_pos;
  1916. read_size = ((srcLength - read_pos + startoffset) < packet_size[0]) ?
  1917. (srcLength - read_pos + startoffset) : packet_size[0];
  1918. mdss_dsi_cmds_send(msd.ctrl_pdata, &(s6e8aa0_read_pos_cmd), 1, 0);
  1919. read_count = mdss_dsi_cmd_receive(msd.ctrl_pdata, desc, read_size);
  1920. for (i = 0; i < read_count; i++, show_cnt++) {
  1921. show_buffer_pos += snprintf(show_buffer +
  1922. show_buffer_pos, 256, "%02x ",
  1923. msd.ctrl_pdata->rx_buf.data[i]);
  1924. if (destBuffer != NULL && show_cnt < srcLength) {
  1925. destBuffer[show_cnt] =
  1926. msd.ctrl_pdata->rx_buf.data[i];
  1927. }
  1928. }
  1929. show_buffer_pos += snprintf(show_buffer +
  1930. show_buffer_pos, 256, ".");
  1931. read_pos += read_count;
  1932. if (read_pos-startoffset >= srcLength)
  1933. break;
  1934. }
  1935. pr_info("%s\n", show_buffer);
  1936. return read_pos-startoffset;
  1937. }
  1938. static int mipi_samsung_read_nv_mem(struct mdss_panel_data *pdata, struct dsi_cmd *nv_read_cmds, char *buffer)
  1939. {
  1940. int nv_size = 0;
  1941. int nv_read_cnt = 0;
  1942. int i = 0, j = 0;
  1943. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL) \
  1944. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL) \
  1945. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  1946. j = 5; // do not repeat
  1947. #elif defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  1948. ||defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1949. j = 3;
  1950. #endif
  1951. #if !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1952. mipi_samsung_disp_send_cmd(PANEL_NV_MTP_READ_REGISTER_SET_CMDS, true);
  1953. mipi_samsung_disp_send_cmd(PANEL_MTP_ENABLE, true);
  1954. #endif
  1955. for (i = 0; i < nv_read_cmds->num_of_cmds; i++)
  1956. nv_size += nv_read_cmds->read_size[i];
  1957. pr_info("nv_size= %d, nv_read_cmds->num_of_cmds = %d", nv_size, nv_read_cmds->num_of_cmds);
  1958. for (i = 0; i < nv_read_cmds->num_of_cmds; i++) {
  1959. int count = 0;
  1960. int read_size = nv_read_cmds->read_size[i];
  1961. int read_startoffset = nv_read_cmds->read_startoffset[i];
  1962. do {
  1963. count = samsung_nv_read(&(nv_read_cmds->cmd_desc[i]),
  1964. &buffer[nv_read_cnt], read_size, pdata, read_startoffset);
  1965. if (j++ == 5)
  1966. break;
  1967. } while(buffer[0] != 0x0 && buffer[0] != 0x1);
  1968. nv_read_cnt += count;
  1969. if (count != read_size)
  1970. pr_err("Error reading LCD NV data !!!!\n");
  1971. }
  1972. #if !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1973. mipi_samsung_disp_send_cmd(PANEL_MTP_DISABLE, true);
  1974. #endif
  1975. return nv_read_cnt;
  1976. }
  1977. #ifdef DEBUG_LDI_STATUS
  1978. int read_ldi_status(void)
  1979. {
  1980. struct dsi_buf *rp, *tp;
  1981. int i;
  1982. if (!ldi_debug_cmds.num_of_cmds)
  1983. return 1;
  1984. if(!msd.dstat.on) {
  1985. pr_err("%s can not read because of panel off \n", __func__);
  1986. return 1;
  1987. }
  1988. tp = &dsi_panel_tx_buf;
  1989. rp = &dsi_panel_rx_buf;
  1990. mdss_dsi_cmd_receive(msd.ctrl_pdata,
  1991. &ldi_debug_cmds.cmd_desc[0],
  1992. ldi_debug_cmds.read_size[0]);
  1993. pr_info("%s: LDI 0Ah Register Value = 0x%x (Normal Case:0x9C)\n", __func__, *msd.ctrl_pdata->rx_buf.data);
  1994. mdss_dsi_cmd_receive(msd.ctrl_pdata,
  1995. &ldi_debug_cmds.cmd_desc[1],
  1996. ldi_debug_cmds.read_size[1]);
  1997. pr_info("%s: LDI 0Eh Register Value = 0x%x (Normal Case:0x80)\n", __func__, *msd.ctrl_pdata->rx_buf.data);
  1998. mdss_dsi_cmd_receive(msd.ctrl_pdata,
  1999. &ldi_debug_cmds.cmd_desc[2],
  2000. ldi_debug_cmds.read_size[2]);
  2001. for(i=0 ; i<8 ; i++) {
  2002. pr_info("%s: LDI EAh Register Value[%d] = 0x%x \n", __func__,i, msd.ctrl_pdata->rx_buf.data[i]);
  2003. }
  2004. return 0;
  2005. }
  2006. EXPORT_SYMBOL(read_ldi_status);
  2007. #endif
  2008. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL)
  2009. int reading_id = 0;
  2010. #endif
  2011. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2012. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061)
  2013. static int mipi_magna_ea8061_read(struct dsi_cmd_desc *cmd, int rlen)
  2014. {
  2015. magna_read_pos_cmds.cmd_desc[0].payload[1] = cmd->payload[0];
  2016. mdss_dsi_cmds_send(msd.ctrl_pdata, magna_read_pos_cmds.cmd_desc, 1, 0);
  2017. return mdss_dsi_cmd_receive(msd.ctrl_pdata, &magna_read_run_cmds.cmd_desc[0], rlen);
  2018. }
  2019. static unsigned int mipi_samsung_manufacture_id(struct mdss_panel_data *pdata)
  2020. {
  2021. struct dsi_buf *rp, *tp;
  2022. unsigned int id = 0 ;
  2023. return 0xFF1043; // kyNam_140116_ after Read in kernel, LCD is Over-brightness.
  2024. if (get_lcd_attached() == 0)
  2025. {
  2026. printk("%s: get_lcd_attached(0)!\n",__func__);
  2027. return id;
  2028. }
  2029. if (!manufacture_id_cmds.num_of_cmds)
  2030. return 0;
  2031. tp = &dsi_panel_tx_buf;
  2032. rp = &dsi_panel_rx_buf;
  2033. mipi_magna_ea8061_read( &manufacture_id_cmds.cmd_desc[0], manufacture_id_cmds.read_size[0] );
  2034. id = *((unsigned int *)msd.ctrl_pdata->rx_buf.data);
  2035. gv_manufacture_id = id;
  2036. pr_info("%s: manufacture_id=%x\n", __func__, id);
  2037. return id;
  2038. }
  2039. #else
  2040. static unsigned int mipi_samsung_manufacture_id(struct mdss_panel_data *pdata)
  2041. {
  2042. struct dsi_buf *rp, *tp;
  2043. unsigned int id = 0 ;
  2044. if (get_lcd_attached() == 0)
  2045. {
  2046. printk("%s: get_lcd_attached(0)!\n",__func__);
  2047. return id;
  2048. }
  2049. if (!manufacture_id_cmds.num_of_cmds)
  2050. return 0;
  2051. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL)
  2052. reading_id = 1;
  2053. #endif
  2054. tp = &dsi_panel_tx_buf;
  2055. rp = &dsi_panel_rx_buf;
  2056. mdss_dsi_cmd_receive(msd.ctrl_pdata,
  2057. &manufacture_id_cmds.cmd_desc[0],
  2058. manufacture_id_cmds.read_size[0]);
  2059. pr_info("%s: manufacture_id1=%x\n", __func__, *msd.ctrl_pdata->rx_buf.data);
  2060. id = (*((unsigned int *)msd.ctrl_pdata->rx_buf.data) & 0xFF);
  2061. id <<= 8;
  2062. mdss_dsi_cmd_receive(msd.ctrl_pdata,
  2063. &manufacture_id_cmds.cmd_desc[1],
  2064. manufacture_id_cmds.read_size[1]);
  2065. pr_info("%s: manufacture_id2=%x\n", __func__, *msd.ctrl_pdata->rx_buf.data);
  2066. id |= (*((unsigned int *)msd.ctrl_pdata->rx_buf.data) & 0xFF);
  2067. id <<= 8;
  2068. mdss_dsi_cmd_receive(msd.ctrl_pdata,
  2069. &manufacture_id_cmds.cmd_desc[2],
  2070. manufacture_id_cmds.read_size[2]);
  2071. pr_info("%s: manufacture_id3=%x\n", __func__, *msd.ctrl_pdata->rx_buf.data);
  2072. id |= (*((unsigned int *)msd.ctrl_pdata->rx_buf.data) & 0xFF);
  2073. gv_manufacture_id = id;
  2074. pr_info("%s: manufacture_id=%x\n", __func__, id);
  2075. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL)
  2076. reading_id = 0;
  2077. #endif
  2078. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2079. if(id != lcd_id)
  2080. {
  2081. pr_err("%s : manufacture id %x->%x\n", __func__, id, lcd_id);
  2082. id = lcd_id;
  2083. }
  2084. #endif
  2085. if (set_panel_rev(id) < 0)
  2086. pr_err("%s : can't find panel id.. \n", __func__);
  2087. return id;
  2088. }
  2089. #endif
  2090. static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata,
  2091. u32 bl_level)
  2092. {
  2093. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  2094. #if !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL) \
  2095. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL) \
  2096. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL) \
  2097. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)\
  2098. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  2099. mipi_samsung_disp_send_cmd(PANEL_MTP_ENABLE, true);
  2100. #endif
  2101. /*Dont need to send backlight command if display off*/
  2102. if (msd.mfd->resume_state != MIPI_RESUME_STATE)
  2103. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2104. {
  2105. msd.dstat.bright_level = bl_level;
  2106. return;
  2107. }
  2108. #else
  2109. return;
  2110. #endif
  2111. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  2112. panel_data);
  2113. if (!ctrl_pdata) {
  2114. pr_err("%s: Invalid input data\n", __func__);
  2115. return;
  2116. }
  2117. switch (ctrl_pdata->bklt_ctrl) {
  2118. case BL_WLED:
  2119. led_trigger_event(bl_led_trigger, bl_level);
  2120. break;
  2121. case BL_PWM:
  2122. mdss_dsi_panel_bklt_pwm(ctrl_pdata, bl_level);
  2123. break;
  2124. case BL_DCS_CMD:
  2125. msd.dstat.bright_level = bl_level;
  2126. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  2127. break;
  2128. default:
  2129. pr_err("%s: Unknown bl_ctrl configuration\n",
  2130. __func__);
  2131. break;
  2132. }
  2133. #if !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL) \
  2134. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL) \
  2135. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL) \
  2136. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)\
  2137. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  2138. mipi_samsung_disp_send_cmd(PANEL_MTP_DISABLE, true);
  2139. #endif
  2140. }
  2141. static int mipi_samsung_disp_send_cmd(
  2142. enum mipi_samsung_cmd_list cmd,
  2143. unsigned char lock)
  2144. {
  2145. /* fix build error temporary */
  2146. /* struct msm_fb_data_type *mfd = msd.mfd;*/
  2147. struct dsi_cmd_desc *cmd_desc;
  2148. int cmd_size = 0;
  2149. int flag = 0;
  2150. #ifdef CMD_DEBUG
  2151. int i,j;
  2152. #endif
  2153. if (get_lcd_attached() == 0)
  2154. {
  2155. printk("%s: get_lcd_attached(0)!\n",__func__);
  2156. return -ENODEV;
  2157. }
  2158. if (lock)
  2159. mutex_lock(&msd.lock);
  2160. switch (cmd) {
  2161. case PANEL_NV_MTP_READ_REGISTER_SET_CMDS:
  2162. cmd_desc = nv_mtp_read_register_set_cmds.cmd_desc;
  2163. cmd_size = nv_mtp_read_register_set_cmds.num_of_cmds;
  2164. break;
  2165. case PANEL_READY_TO_ON:
  2166. cmd_desc = display_qcom_on_cmds.cmd_desc;
  2167. cmd_size = display_qcom_on_cmds.num_of_cmds;
  2168. break;
  2169. case PANEL_DISP_OFF:
  2170. cmd_desc = display_qcom_off_cmds.cmd_desc;
  2171. cmd_size = display_qcom_off_cmds.num_of_cmds;
  2172. break;
  2173. case PANEL_DISPLAY_ON:
  2174. cmd_desc = display_on_cmd.cmd_desc;
  2175. cmd_size = display_on_cmd.num_of_cmds;
  2176. break;
  2177. case PANEL_DISPLAY_OFF:
  2178. cmd_desc = display_off_cmd.cmd_desc;
  2179. cmd_size = display_off_cmd.num_of_cmds;
  2180. break;
  2181. case PANEL_DISPLAY_UNBLANK:
  2182. cmd_desc = display_unblank_cmd.cmd_desc;
  2183. cmd_size = display_unblank_cmd.num_of_cmds;
  2184. break;
  2185. case PANEL_DISPLAY_BLANK:
  2186. cmd_desc = display_blank_cmd.cmd_desc;
  2187. cmd_size = display_blank_cmd.num_of_cmds;
  2188. break;
  2189. case PANEL_BRIGHT_CTRL:
  2190. cmd_desc = brightness_packet;
  2191. /* Single Tx use for DSI_VIDEO_MODE Only */
  2192. if(msd.pdata->panel_info.mipi.mode == DSI_VIDEO_MODE)
  2193. flag = CMD_REQ_SINGLE_TX;
  2194. else
  2195. flag = 0;
  2196. msd.dstat.recent_bright_level = msd.dstat.bright_level;
  2197. #if defined(HBM_RE) || defined(CONFIG_HBM_PSRE)
  2198. if(msd.dstat.auto_brightness >= 6 && msd.dstat.bright_level == 255) {
  2199. cmd_size = make_brightcontrol_hbm_set(msd.dstat.bright_level);
  2200. msd.dstat.hbm_mode = 1;
  2201. } else {
  2202. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  2203. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  2204. if(msd.dstat.hbm_mode)
  2205. mdss_dsi_cmds_send(msd.ctrl_pdata, hbm_hbm_off_elvss_cmds.cmd_desc, hbm_hbm_off_elvss_cmds.num_of_cmds, flag);
  2206. #endif
  2207. cmd_size = make_brightcontrol_set(msd.dstat.bright_level);
  2208. msd.dstat.hbm_mode = 0;
  2209. }
  2210. #else
  2211. cmd_size = make_brightcontrol_set(msd.dstat.bright_level);
  2212. #endif
  2213. if (msd.mfd->resume_state != MIPI_RESUME_STATE) {
  2214. pr_info("%s : panel is off state!!\n", __func__);
  2215. goto unknown_command;
  2216. }
  2217. udelay(300);
  2218. break;
  2219. case PANEL_MTP_ENABLE:
  2220. cmd_desc = nv_enable_cmds.cmd_desc;
  2221. cmd_size = nv_enable_cmds.num_of_cmds;
  2222. break;
  2223. case PANEL_MTP_DISABLE:
  2224. cmd_desc = nv_disable_cmds.cmd_desc;
  2225. cmd_size = nv_disable_cmds.num_of_cmds;
  2226. break;
  2227. case PANEL_NEED_FLIP:
  2228. /*
  2229. May be required by Panel Like Fusion3
  2230. */
  2231. break;
  2232. case PANEL_ACL_ON:
  2233. /*
  2234. May be required by panel like D2,Commanche
  2235. */
  2236. break;
  2237. case PANEL_ACL_OFF:
  2238. cmd_desc = acl_off_cmd.cmd_desc;
  2239. cmd_size = acl_off_cmd.num_of_cmds;
  2240. break;
  2241. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2242. case PANEL_TOUCHSENSING_ON:
  2243. cmd_desc = touchsensing_on_cmd.cmd_desc;
  2244. cmd_size = touchsensing_on_cmd.num_of_cmds;
  2245. break;
  2246. case PANEL_TOUCHSENSING_OFF:
  2247. cmd_desc = touchsensing_off_cmd.cmd_desc;
  2248. cmd_size = touchsensing_off_cmd.num_of_cmds;
  2249. break;
  2250. #endif
  2251. #ifdef LDI_FPS_CHANGE
  2252. case PANEL_LDI_FPS_CHANGE:
  2253. cmd_desc = write_ldi_fps_cmds.cmd_desc;
  2254. cmd_size = write_ldi_fps_cmds.num_of_cmds;
  2255. break;
  2256. #endif
  2257. #ifdef LDI_ADJ_VDDM_OFFSET
  2258. case PANEL_LDI_SET_VDDM_OFFSET:
  2259. cmd_desc = write_vddm_offset_cmds.cmd_desc;
  2260. cmd_size = write_vddm_offset_cmds.num_of_cmds;
  2261. break;
  2262. #endif
  2263. #if defined(PARTIAL_UPDATE)
  2264. case PANEL_PARTIAL_ON:
  2265. cmd_desc = partialdisp_on_cmd.cmd_desc;
  2266. cmd_size = partialdisp_on_cmd.num_of_cmds;
  2267. break;
  2268. case PANEL_PARTIAL_OFF:
  2269. cmd_desc = partialdisp_off_cmd.cmd_desc;
  2270. cmd_size = partialdisp_off_cmd.num_of_cmds;
  2271. break;
  2272. #endif
  2273. #if defined(FORCE_500CD)
  2274. case PANEl_FORCE_500CD:
  2275. cmd_desc = brightness_packet;
  2276. msd.dstat.recent_bright_level = msd.dstat.bright_level;
  2277. cmd_size = make_force_500cd_set(msd.dstat.bright_level);
  2278. break;
  2279. #endif
  2280. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  2281. case PANEL_CRACK_RECOVERY:
  2282. cmd_desc = lcd_crack_rec_cmd_list.cmd_desc;
  2283. cmd_size = lcd_crack_rec_cmd_list.num_of_cmds;
  2284. #endif
  2285. default:
  2286. pr_err("%s : unknown_command.. \n", __func__);
  2287. goto unknown_command;
  2288. ;
  2289. }
  2290. if (!cmd_size) {
  2291. pr_err("%s : cmd_size is zero!.. \n", __func__);
  2292. goto unknown_command;
  2293. }
  2294. #ifdef CMD_DEBUG
  2295. for (i = 0; i < cmd_size; i++)
  2296. {
  2297. for (j = 0; j < cmd_desc[i].dchdr.dlen; j++)
  2298. printk("%x ",cmd_desc[i].payload[j]);
  2299. printk("\n");
  2300. }
  2301. #endif
  2302. #ifdef MDP_RECOVERY
  2303. if (!mdss_recovery_start)
  2304. mdss_dsi_cmds_send(msd.ctrl_pdata, cmd_desc, cmd_size, flag);
  2305. else
  2306. pr_err ("%s : Can't send command during mdss_recovery_start\n", __func__);
  2307. #else
  2308. mdss_dsi_cmds_send(msd.ctrl_pdata, cmd_desc, cmd_size, flag);
  2309. #endif
  2310. if (lock)
  2311. mutex_unlock(&msd.lock);
  2312. return 0;
  2313. unknown_command:
  2314. LCD_DEBUG("Undefined command\n");
  2315. if (lock)
  2316. mutex_unlock(&msd.lock);
  2317. return -EINVAL;
  2318. }
  2319. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2320. void mdss_dsi_panel_touchsensing(int enable)
  2321. {
  2322. if(!msd.dstat.on)
  2323. {
  2324. pr_err("%s: No panel on! %d\n", __func__, enable);
  2325. return;
  2326. }
  2327. #if defined(CONFIG_MACH_KS01SKT) || defined(CONFIG_MACH_KS01KTT)\
  2328. || defined(CONFIG_MACH_KS01LGT) || defined(CONFIG_MACH_JACTIVESKT)\
  2329. || defined(CONFIG_MACH_JS01LTEDCM) || defined(CONFIG_MACH_JS01LTESBM)
  2330. if(enable)
  2331. mipi_samsung_disp_send_cmd(PANEL_TOUCHSENSING_ON, true);
  2332. #else
  2333. if(enable)
  2334. mipi_samsung_disp_send_cmd(PANEL_TOUCHSENSING_ON, true);
  2335. else
  2336. mipi_samsung_disp_send_cmd(PANEL_TOUCHSENSING_OFF, true);
  2337. #endif
  2338. }
  2339. #endif
  2340. static int mdss_dsi_panel_registered(struct mdss_panel_data *pdata)
  2341. {
  2342. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  2343. if (pdata == NULL) {
  2344. pr_err("%s: Invalid input data\n", __func__);
  2345. return -EINVAL;
  2346. }
  2347. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  2348. panel_data);
  2349. msd.mfd = (struct msm_fb_data_type *)registered_fb[0]->par;
  2350. msd.pdata = pdata;
  2351. msd.ctrl_pdata = ctrl_pdata;
  2352. #if defined(CONFIG_MDNIE_LITE_TUNING)
  2353. pr_info("[%s] CONFIG_MDNIE_LITE_TUNING ok ! init class called!\n",
  2354. __func__);
  2355. mdnie_lite_tuning_init(&msd);
  2356. #endif
  2357. /* Set the initial state to Suspend until it is switched on */
  2358. msd.mfd->resume_state = MIPI_SUSPEND_STATE;
  2359. pr_info("%s:%d, Panel registered succesfully\n", __func__, __LINE__);
  2360. return 0;
  2361. }
  2362. static int mdss_dsi_panel_dimming_init(struct mdss_panel_data *pdata)
  2363. {
  2364. #if defined(CONFIG_MDNIE_LITE_TUNING)
  2365. char temp[4];
  2366. int x, y;
  2367. #endif
  2368. #if defined(HBM_RE) || defined(CONFIG_HBM_PSRE)
  2369. char hbm_buffer[21];
  2370. #endif
  2371. #ifdef LDI_FPS_CHANGE
  2372. char ldi_fps_buffer;
  2373. #endif
  2374. #ifdef LDI_ADJ_VDDM_OFFSET
  2375. unsigned int vddm_offset;
  2376. char vol_ref_buffer;
  2377. #endif
  2378. if (get_lcd_attached() == 0)
  2379. {
  2380. printk("%s: get_lcd_attached(0)!\n",__func__);
  2381. return 0;
  2382. }
  2383. /* If the ID is not read yet, then read it*/
  2384. if (!msd.manufacture_id)
  2385. msd.manufacture_id = mipi_samsung_manufacture_id(pdata);
  2386. if (!msd.dstat.is_smart_dim_loaded) {
  2387. switch (msd.panel) {
  2388. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2389. case PANEL_WVGA_OCTA_S6E88A0:
  2390. msd.sdimconf = smart_S6E88A0_get_conf();
  2391. break;
  2392. #elif defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2393. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2394. case PANEL_720P_OCTA_S6E8AA4_VIDEO:
  2395. msd.sdimconf = smart_S6E8AA4_get_conf();
  2396. break;
  2397. case PANEL_720P_OCTA_EA8061_VIDEO:
  2398. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2399. msd.sdimconf = smart_S6E8AA4_get_conf();
  2400. break;
  2401. #else
  2402. msd.sdimconf = smart_S6E8FA0_get_conf();
  2403. break;
  2404. #endif
  2405. #else
  2406. case PANEL_1080P_OCTA_S6E8FA0:
  2407. case PANEL_720P_OCTA_D53D6EA8061V:
  2408. case PANEL_720P_OCTA_S6E8AA0:
  2409. case PANEL_720P_OCTA_D53D6EA8061V_VIDEO:
  2410. case PANEL_QHD_OCTA_S6E88A0_VIDEO:
  2411. case PANEL_HD_OCTA_D53D6EA8061_VIDEO:
  2412. msd.sdimconf = smart_S6E8FA0_get_conf();
  2413. break;
  2414. case PANEL_1080P_OCTA_S6E3FA0:
  2415. case PANEL_1080P_OCTA_S6E3FA0_CMD:
  2416. case PANEL_1080P_YOUM_S6E3FA1_CMD:
  2417. msd.sdimconf = smart_S6E3FA0_get_conf();
  2418. break;
  2419. #endif
  2420. }
  2421. /* Just a safety check to ensure smart dimming data is initialised well */
  2422. BUG_ON(msd.sdimconf == NULL);
  2423. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  2424. mipi_samsung_disp_send_cmd(PANEL_MTP_ENABLE, true);
  2425. #endif
  2426. /* Set the mtp read buffer pointer and read the NVM value*/
  2427. mipi_samsung_read_nv_mem(pdata, &nv_mtp_read_cmds, msd.sdimconf->mtp_buffer);
  2428. #if defined(octa_manufacture_date)
  2429. mipi_samsung_read_nv_mem(pdata, &nv_date_read_cmds, mdate_buffer);
  2430. #endif
  2431. #if (defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL) \
  2432. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061))\
  2433. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2434. // kyNam_131228_
  2435. //#if defined(VIRTUAL_GAMMA) // kyNam_131228_
  2436. if (get_oled_id() == 0)
  2437. {
  2438. memset( msd.sdimconf->mtp_buffer, 0, sizeof( struct MTP_OFFSET ) );
  2439. msd.mfd->resume_state = MIPI_RESUME_STATE;
  2440. return 0;
  2441. }
  2442. //#endif
  2443. #endif
  2444. #ifdef LDI_FPS_CHANGE
  2445. if(msd.id3 >= 0x21) {
  2446. mipi_samsung_read_nv_mem(msd.pdata, &read_ldi_fps_cmds, &ldi_fps_buffer);
  2447. current_ldi_fps_otp = (unsigned int)(ldi_fps_buffer & 0x7F);
  2448. if(current_ldi_fps_otp < 0x35 || current_ldi_fps_otp > 0x55) {
  2449. pr_err("%s:ldi_fps register otp value read fail = 0x%x\n", __func__, current_ldi_fps_otp);
  2450. panic("LDI FPS Register OTP Value Read Fail");
  2451. } else
  2452. pr_info("%s:ldi_fps register otp value = 0x%x\n", __func__, current_ldi_fps_otp);
  2453. } else
  2454. pr_err("%s:LDI EVT0 Not Support\n",__func__);
  2455. #endif
  2456. #ifdef LDI_ADJ_VDDM_OFFSET
  2457. mipi_samsung_read_nv_mem(msd.pdata, &read_vddm_ref_cmds, &vol_ref_buffer);
  2458. vddm_offset=(unsigned int)(vol_ref_buffer & 0x7F);
  2459. pr_info("%s:vddm_offset = %d , ldi_vddm_lut[%d][1] = %d \n", __func__, vddm_offset, vddm_offset, ldi_vddm_lut[vddm_offset][1]);
  2460. write_vddm_offset_cmds.cmd_desc[3].payload[1] = ldi_vddm_lut[vddm_offset][1];
  2461. #endif
  2462. /* Initialize smart dimming related things here */
  2463. /* lux_tab setting for 350cd */
  2464. if (msd.panel_350cd) {
  2465. msd.sdimconf->lux_tab = &candela_map_table_350.lux_tab[0];
  2466. msd.sdimconf->lux_tabsize = candela_map_table_350.lux_tab_size;
  2467. } else { /* lux_tab setting for 300cd */
  2468. msd.sdimconf->lux_tab = &candela_map_table.lux_tab[0];
  2469. msd.sdimconf->lux_tabsize = candela_map_table.lux_tab_size;
  2470. }
  2471. if (msd.id3 == EVT1_H_REV_I) {
  2472. display_qcom_on_cmds.cmd_desc[4].payload[2] = 0x08;
  2473. display_qcom_on_cmds.cmd_desc[4].payload[4] = 0x08;
  2474. } else if (msd.id3 == EVT1_H_REV_J) {
  2475. display_qcom_on_cmds.cmd_desc[4].payload[2] = 0x06;
  2476. display_qcom_on_cmds.cmd_desc[4].payload[4] = 0x06;
  2477. }
  2478. msd.sdimconf->man_id = msd.manufacture_id;
  2479. /* Just a safety check to ensure smart dimming data is initialised well */
  2480. BUG_ON(msd.sdimconf->init == NULL);
  2481. msd.sdimconf->init();
  2482. msd.dstat.is_smart_dim_loaded = true;
  2483. #if defined(HBM_RE)
  2484. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  2485. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm_read_cmds, hbm_buffer);
  2486. memcpy(&hbm_gamma_cmds_list.cmd_desc[1].payload[1], hbm_buffer, 21);
  2487. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm2_read_cmds, hbm_buffer);
  2488. memcpy(&hbm_etc_cmds_list.cmd_desc[3].payload[18], hbm_buffer, 1);
  2489. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm3_read_cmds, hbm_buffer);
  2490. memcpy(&hbm_hbm_off_elvss_cmds.cmd_desc[5].payload[18], hbm_buffer, 1);
  2491. #else
  2492. /* Read mtp (C8h 34th ~ 40th) for HBM */
  2493. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm_read_cmds, hbm_buffer);
  2494. memcpy(&hbm_gamma_cmds_list.cmd_desc[0].payload[1], hbm_buffer, 6);
  2495. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  2496. /* octa panel Read C8h 40th -> write B6h 17th */
  2497. if((msd.id3 == EVT0_SECOND_ID) && hbm_etc_cmds_evt0_second_list.cmd_desc)
  2498. memcpy(&hbm_etc_cmds_evt0_second_list.cmd_desc[2].payload[17], hbm_buffer+6, 1);
  2499. if((msd.id3 == EVT1_ID) && hbm_etc_cmds_evt1_list.cmd_desc)
  2500. memcpy(&hbm_etc_cmds_evt1_list.cmd_desc[2].payload[17], hbm_buffer+6, 1);
  2501. if((msd.id3 == EVT1_SECOND_ID) && hbm_etc_cmds_evt1_second_list.cmd_desc)
  2502. memcpy(&hbm_etc_cmds_evt1_second_list.cmd_desc[1].payload[17], hbm_buffer+6, 1);
  2503. if((msd.id3 == EVT1_H_REV_I) && hbm_etc_cmds_evt1_H_revI_list.cmd_desc)
  2504. memcpy(&hbm_etc_cmds_evt1_H_revI_list.cmd_desc[1].payload[17], hbm_buffer+6, 1);
  2505. if((msd.id3 == EVT1_H_REV_J) && hbm_etc_cmds_evt1_H_revJ_list.cmd_desc)
  2506. memcpy(&hbm_etc_cmds_evt1_H_revJ_list.cmd_desc[1].payload[17], hbm_buffer+6, 1);
  2507. #elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL)
  2508. /* youm panel */
  2509. if(((msd.id3 == EVT0_F_REV_A) || (msd.id3 == EVT0_F_REV_E) ||
  2510. (msd.id3 == EVT0_F_REV_F) || (msd.id3 == EVT2_F_REV_G))
  2511. && hbm_etc_cmds_evt0_second_list.cmd_desc)
  2512. memcpy(&hbm_etc_cmds_evt0_second_list.cmd_desc[2].payload[17], hbm_buffer+6, 1);
  2513. #elif defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2514. memcpy(&hbm_etc_cmds_list.cmd_desc[0].payload[21], hbm_buffer+6, 1);
  2515. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm3_read_cmds, hbm_buffer);
  2516. memcpy(&hbm_hbm_off_elvss_cmds.cmd_desc[0].payload[21], hbm_buffer, 1);
  2517. /* LSI panel EVT1_rev C : set RVdd*/
  2518. if((msd.id3 == EVT1_REV_D) && (get_oled_id()))
  2519. display_qcom_on_cmds.cmd_desc[3].payload[3] = 0x00;
  2520. #elif defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  2521. memcpy(&hbm_etc_cmds_list.cmd_desc[4].payload[1], hbm_buffer+6, 1);
  2522. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm3_read_cmds, hbm_buffer);
  2523. memcpy(&hbm_hbm_off_elvss_cmds.cmd_desc[2].payload[1], hbm_buffer, 1);
  2524. #endif
  2525. /* for rev I panel */
  2526. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm2_read_cmds, hbm_buffer);
  2527. memcpy(&hbm_gamma_cmds_list.cmd_desc[0].payload[7], hbm_buffer, 15);
  2528. #endif
  2529. #elif defined(CONFIG_HBM_PSRE)
  2530. /* Read mtp (B5h 13th ~ 18th) for HBM Write Gamma ( CAh 1st ~ 6th )*/
  2531. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm_read_cmds, hbm_buffer);
  2532. memcpy(&hbm_gamma_cmds_list.cmd_desc[0].payload[1], hbm_buffer, 6);
  2533. /* Read mtp (B5h 26th ~ 28th) for HBM Write Gamma ( CAh 7th ~ 9th )*/
  2534. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm2_read_cmds, hbm_buffer);
  2535. memcpy(&hbm_gamma_cmds_list.cmd_desc[0].payload[7], hbm_buffer, 3);
  2536. /* Read mtp (B6h 3rd ~ 14th) for HBM Write Gamma ( CAh 10th ~ 21th )*/
  2537. mipi_samsung_read_nv_mem(pdata, &nv_mtp_hbm3_read_cmds, hbm_buffer);
  2538. memcpy(&hbm_gamma_cmds_list.cmd_desc[0].payload[10], hbm_buffer, 12);
  2539. /* Read mtp (B5h 19th) for HBM ELVSS OFFSET */
  2540. mipi_samsung_read_nv_mem(pdata, &nv_hbm_elvss_offset_cmds, hbm_buffer);
  2541. memcpy(&hbm_etc_cmds_list.cmd_desc[2].payload[1], hbm_buffer, 1);
  2542. #if defined(CMD_DEBUG)
  2543. {
  2544. int i,j;
  2545. for (i = 0; i < hbm_gamma_cmds_list.num_of_cmds; i++)
  2546. {
  2547. printk("[HBM] hbm_gamma_cmds_list : ");
  2548. for (j = 0; j < hbm_gamma_cmds_list.cmd_desc[i].dchdr.dlen; j++)
  2549. printk("%02x ",hbm_gamma_cmds_list.cmd_desc[i].payload[j]);
  2550. printk("\n");
  2551. }
  2552. for (i = 0; i < hbm_etc_cmds_list.num_of_cmds; i++)
  2553. {
  2554. printk("[HBM] hbm_etc_cmds_list : ");
  2555. for (j = 0; j < hbm_etc_cmds_list.cmd_desc[i].dchdr.dlen; j++)
  2556. printk("%02x ",hbm_etc_cmds_list.cmd_desc[i].payload[j]);
  2557. printk("\n");
  2558. }
  2559. }
  2560. #endif
  2561. /* Read mtp (B5h 24th ~ 25th) for Panel Production Day */
  2562. mipi_samsung_read_nv_mem(pdata, &nv_production_day_cmds, hbm_buffer);
  2563. #endif
  2564. /*
  2565. * Since dimming is loaded, we can assume that device is out of suspend state
  2566. * and can accept backlight commands.
  2567. */
  2568. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2569. if(!msd.dstat.recovery_boot_mode)
  2570. msd.mfd->resume_state = MIPI_RESUME_STATE;
  2571. #else
  2572. msd.mfd->resume_state = MIPI_RESUME_STATE;
  2573. #endif
  2574. }
  2575. #if defined(CONFIG_MDNIE_LITE_TUNING)
  2576. /* MDNIe tuning initialisation*/
  2577. if (!msd.dstat.is_mdnie_loaded) {
  2578. mipi_samsung_read_nv_mem(pdata, &nv_mdnie_read_cmds, temp);
  2579. x = temp[0] << 8 | temp[1]; /* X */
  2580. y = temp[2] << 8 | temp[3]; /* Y */
  2581. coordinate_tunning(x, y);
  2582. msd.dstat.is_mdnie_loaded = true;
  2583. }
  2584. #endif
  2585. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  2586. mipi_samsung_disp_send_cmd(PANEL_MTP_DISABLE, true);
  2587. #endif
  2588. return 0;
  2589. }
  2590. #if defined(CONFIG_MIPI_LCD_S6E3FA0_FORCE_VIDEO_MODE)
  2591. void force_dsi_video_mode(struct mdss_panel_common_pdata *panel_data){
  2592. int i = 0;
  2593. struct mipi_panel_info *mipi;
  2594. mipi = &pinfo->mipi;
  2595. /* Configure Panel for VIDEO mode (F2 Command) */
  2596. for(;i < display_qcom_on_cmds.num_of_cmds; i++){
  2597. if (display_qcom_on_cmds.cmd_desc[i].payload[0] == 0xF2) {
  2598. display_qcom_on_cmds.cmd_desc[i].payload[1] = 0x02;
  2599. break;
  2600. }
  2601. }
  2602. pinfo->mipi.mode = DSI_VIDEO_MODE;
  2603. mipi->dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
  2604. LCD_DEBUG("<<<<<<<<<<<VIDEO MODE Enforced for S6E8FA0>>>>>>>>\n");
  2605. }
  2606. #endif
  2607. #if defined(CONFIG_DUAL_LCD)
  2608. struct mdss_panel_data *mdss_dsi_switching = NULL;
  2609. #endif
  2610. #if defined(CONFIG_MDNIE_LITE_TUNING) \
  2611. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL) \
  2612. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  2613. static bool dsi_first_init = true;
  2614. #endif
  2615. static int mdss_dsi_panel_on(struct mdss_panel_data *pdata)
  2616. {
  2617. struct mipi_panel_info *mipi;
  2618. struct mdss_dsi_ctrl_pdata *ctrl = NULL;
  2619. #if defined(CONFIG_DUAL_LCD)
  2620. msd.lcd_panel_cmds = 1;
  2621. #endif
  2622. if (pdata == NULL) {
  2623. pr_err("%s: Invalid input data\n", __func__);
  2624. return -EINVAL;
  2625. }
  2626. ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  2627. panel_data);
  2628. mipi = &pdata->panel_info.mipi;
  2629. #if defined(CONFIG_DUAL_LCD)
  2630. {
  2631. int ret;
  2632. if(mdss_dsi_switching == NULL) {
  2633. msd.dstat.bright_level = RECOVERY_BRIGHTNESS;
  2634. mdss_dsi_switching = pdata;
  2635. }
  2636. LCD_DEBUG("lcd_sel [%s]\n", msd.dstat.lcd_sel ? "CLOSE" : "OPEN");
  2637. ret = gpio_direction_output(msd.ctrl_pdata->lcd_sel_gpio, msd.dstat.lcd_sel);
  2638. if (ret) {
  2639. pr_err("%s : lcd_sel_gpio [%d]\n", __func__, msd.ctrl_pdata->lcd_sel_gpio);
  2640. }
  2641. }
  2642. #endif
  2643. pr_info("mdss_dsi_panel_on DSI_MODE = %d ++\n",mipi->mode);
  2644. pr_debug("%s: ctrl=%pK ndx=%d\n", __func__, ctrl, ctrl->ndx);
  2645. if (!msd.manufacture_id)
  2646. msd.manufacture_id = mipi_samsung_manufacture_id(pdata);
  2647. if (!msd.dstat.is_smart_dim_loaded)
  2648. mdss_dsi_panel_dimming_init(pdata);
  2649. #ifdef LDI_FPS_CHANGE
  2650. /* Restore current ldi_fps register value to OTP value because of ldi reset */
  2651. current_ldi_fps = current_ldi_fps_otp;
  2652. pr_info("%s:ldi_fps register value = 0x%x\n", __func__, current_ldi_fps);
  2653. #endif
  2654. mipi_samsung_disp_send_cmd(PANEL_READY_TO_ON, true);
  2655. /* Recovery Mode : Set some default brightness */
  2656. if (msd.dstat.recovery_boot_mode) {
  2657. msd.dstat.bright_level = RECOVERY_BRIGHTNESS;
  2658. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  2659. }
  2660. /* Init Index Values */
  2661. msd.dstat.curr_elvss_idx = -1;
  2662. msd.dstat.curr_acl_idx = -1;
  2663. msd.dstat.curr_aid_idx = -1;
  2664. msd.dstat.hbm_mode = 0;
  2665. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2666. msd.dstat.on = 1;
  2667. #endif
  2668. msd.dstat.wait_disp_on = 1;
  2669. msd.mfd->resume_state = MIPI_RESUME_STATE;
  2670. #ifdef LDI_ADJ_VDDM_OFFSET
  2671. mipi_samsung_disp_send_cmd(PANEL_LDI_SET_VDDM_OFFSET, true);
  2672. #endif
  2673. #if defined(CONFIG_MDNIE_LITE_TUNING)
  2674. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL) \
  2675. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  2676. is_negative_on();
  2677. #else
  2678. if (!dsi_first_init)
  2679. is_negative_on();
  2680. else
  2681. dsi_first_init = false;
  2682. #endif
  2683. #endif
  2684. #if defined(PARTIAL_UPDATE)
  2685. if (partial_disp_range[0] || partial_disp_range[1])
  2686. mipi_samsung_disp_send_cmd(PANEL_PARTIAL_ON, true);
  2687. #endif
  2688. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2689. mipi_samsung_disp_send_cmd(PANEL_DISPLAY_ON, true);
  2690. #endif
  2691. pr_info("mdss_dsi_panel_on--\n");
  2692. #if defined(CONFIG_DUAL_LCD)
  2693. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  2694. #else
  2695. msd.dstat.bright_level = msd.dstat.recent_bright_level;
  2696. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  2697. #endif
  2698. #if defined(CONFIG_DUAL_LCD)
  2699. msd.lcd_panel_cmds = 0;
  2700. #endif
  2701. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  2702. msd.dstat.on = 1;
  2703. #endif
  2704. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  2705. if(err_fg_enable)
  2706. {
  2707. pr_info("[lcd] mdss_dsi_panel_on end %d\n", gpio_get_value(err_fg_gpio));
  2708. enable_irq(gpio_to_irq(err_fg_gpio));
  2709. }
  2710. #endif
  2711. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  2712. if(lcd_crack_rec_enable)
  2713. {
  2714. pr_info("[lcd] mdss_dsi_panel_on end %d\n", gpio_get_value(lcd_crack_gpio));
  2715. enable_irq(gpio_to_irq(lcd_crack_gpio));
  2716. }
  2717. #endif
  2718. return 0;
  2719. }
  2720. static int mdss_dsi_panel_off(struct mdss_panel_data *pdata)
  2721. {
  2722. struct mipi_panel_info *mipi;
  2723. struct mdss_dsi_ctrl_pdata *ctrl = NULL;
  2724. #if defined(CONFIG_DUAL_LCD)
  2725. LCD_DEBUG("lcd_sel [%s]\n", msd.dstat.lcd_sel ? "CLOSE" : "OPEN");
  2726. msd.lcd_panel_cmds = 1;
  2727. #endif
  2728. if (pdata == NULL) {
  2729. pr_err("%s: Invalid input data\n", __func__);
  2730. return -EINVAL;
  2731. }
  2732. pr_info("mdss_dsi_panel_off ++\n");
  2733. ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  2734. panel_data);
  2735. pr_debug("%s: ctrl=%pK ndx=%d\n", __func__, ctrl, ctrl->ndx);
  2736. mipi = &pdata->panel_info.mipi;
  2737. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  2738. if (err_fg_enable && !err_fg_working && msd.dstat.on) {
  2739. disable_irq_nosync(gpio_to_irq(err_fg_gpio));
  2740. cancel_work_sync(&err_fg_work);
  2741. }
  2742. #endif
  2743. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  2744. if (lcd_crack_rec_enable && !lcd_crack_rec_working && msd.dstat.on) {
  2745. disable_irq_nosync(gpio_to_irq(lcd_crack_gpio));
  2746. cancel_work_sync(&lcd_crack_rec_work);
  2747. }
  2748. #endif
  2749. msd.dstat.on = 0;
  2750. msd.mfd->resume_state = MIPI_SUSPEND_STATE;
  2751. ctrl->dsi_err_cnt = 0;
  2752. mipi_samsung_disp_send_cmd(PANEL_DISP_OFF, true);
  2753. pr_info("mdss_dsi_panel_off --\n");
  2754. #if defined(CONFIG_DUAL_LCD)
  2755. msd.lcd_panel_cmds = 0;
  2756. #endif
  2757. return 0;
  2758. }
  2759. #if defined(CONFIG_DUAL_LCD)
  2760. DEFINE_MUTEX(mdss_switching_mutex);
  2761. int samsung_switching_lcd(int flip)
  2762. {
  2763. int ret = 0;
  2764. int before_lcd_sel = 0;
  2765. if(msd.lcd_panel_cmds) {
  2766. LCD_DEBUG("Waiting for complete about panel_on or panel_off!\n");
  2767. msleep(500);
  2768. }
  2769. before_lcd_sel = msd.dstat.lcd_sel;
  2770. msd.dstat.lcd_sel=!flip; //Change LCD SEL
  2771. if(mdss_dsi_switching == NULL){
  2772. pr_err("%s: mdss_dsi_switching NULL!\n",__func__);
  2773. return 0;
  2774. }
  2775. if (get_lcd_attached() == 0)
  2776. {
  2777. pr_err("%s: get_lcd_attached(0)!\n",__func__);
  2778. return 0;
  2779. }
  2780. LCD_DEBUG("msd.dstat.on=%d, before=%s, after=%s +\n",
  2781. msd.dstat.on,
  2782. before_lcd_sel ? "CLOSE" : "OPEN",
  2783. flip ? "OPEN" : "CLOSE"
  2784. );
  2785. mutex_lock(&mdss_switching_mutex);
  2786. if(msd.dstat.on && (before_lcd_sel == flip)) {
  2787. ret = mdss_dsi_panel_off(msd.pdata);
  2788. if(ret)
  2789. pr_err("%s: mdss_dsi_panel_off error\n",__func__);
  2790. /* Init Index Values */
  2791. msd.dstat.curr_elvss_idx = -1;
  2792. msd.dstat.curr_acl_idx = -1;
  2793. msd.dstat.curr_aid_idx = -1;
  2794. msd.dstat.hbm_mode = 0;
  2795. ret = mdss_dsi_panel_on(msd.pdata);
  2796. if(ret)
  2797. pr_err("%s: mdss_dsi_panel_on error\n",__func__);
  2798. }
  2799. mutex_unlock(&mdss_switching_mutex);
  2800. LCD_DEBUG(" -\n");
  2801. return ret;
  2802. }
  2803. EXPORT_SYMBOL(samsung_switching_lcd);
  2804. #endif
  2805. static int mdss_samsung_parse_candella_lux_mapping_table(struct device_node *np,
  2806. struct candella_lux_map *table, char *keystring)
  2807. {
  2808. const __be32 *data;
  2809. int data_offset, len = 0 , i = 0;
  2810. int cdmap_start=0, cdmap_end=0;
  2811. data = of_get_property(np, keystring, &len);
  2812. if (!data) {
  2813. pr_err("%s:%d, Unable to read table %s ",
  2814. __func__, __LINE__, keystring);
  2815. return -EINVAL;
  2816. }
  2817. if ((len % 4) != 0) {
  2818. pr_err("%s:%d, Incorrect table entries for %s",
  2819. __func__, __LINE__, keystring);
  2820. return -EINVAL;
  2821. }
  2822. table->lux_tab_size = len / (sizeof(int)*4);
  2823. table->lux_tab = kzalloc((sizeof(int) * table->lux_tab_size), GFP_KERNEL);
  2824. if (!table->lux_tab)
  2825. return -ENOMEM;
  2826. table->cmd_idx = kzalloc((sizeof(int) * table->lux_tab_size), GFP_KERNEL);
  2827. if (!table->cmd_idx)
  2828. goto error;
  2829. data_offset = 0;
  2830. for (i = 0 ; i < table->lux_tab_size; i++) {
  2831. table->cmd_idx[i]= be32_to_cpup(&data[data_offset++]); /* 1rst field => <idx> */
  2832. cdmap_start = be32_to_cpup(&data[data_offset++]); /* 2nd field => <from> */
  2833. cdmap_end = be32_to_cpup(&data[data_offset++]); /* 3rd field => <till> */
  2834. table->lux_tab[i] = be32_to_cpup(&data[data_offset++]); /* 4th field => <candella> */
  2835. /* Fill the backlight level to lux mapping array */
  2836. do{
  2837. table->bkl[cdmap_start++] = i;
  2838. }while(cdmap_start <= cdmap_end);
  2839. }
  2840. return 0;
  2841. error:
  2842. kfree(table->lux_tab);
  2843. return -ENOMEM;
  2844. }
  2845. static int mdss_samsung_parse_panel_table(struct device_node *np,
  2846. struct cmd_map *table, char *keystring)
  2847. {
  2848. const __be32 *data;
  2849. int data_offset, len = 0 , i = 0;
  2850. data = of_get_property(np, keystring, &len);
  2851. if (!data) {
  2852. pr_err("%s:%d, Unable to read table %s ",
  2853. __func__, __LINE__, keystring);
  2854. return -EINVAL;
  2855. }
  2856. if ((len % 2) != 0) {
  2857. pr_err("%s:%d, Incorrect table entries for %s",
  2858. __func__, __LINE__, keystring);
  2859. return -EINVAL;
  2860. }
  2861. table->size = len / (sizeof(int)*2);
  2862. table->bl_level = kzalloc((sizeof(int) * table->size), GFP_KERNEL);
  2863. if (!table->bl_level)
  2864. return -ENOMEM;
  2865. table->cmd_idx = kzalloc((sizeof(int) * table->size), GFP_KERNEL);
  2866. if (!table->cmd_idx)
  2867. goto error;
  2868. data_offset = 0;
  2869. for (i = 0 ; i < table->size; i++) {
  2870. table->bl_level[i] = be32_to_cpup(&data[data_offset++]);
  2871. table->cmd_idx[i] = be32_to_cpup(&data[data_offset++]);
  2872. }
  2873. return 0;
  2874. error:
  2875. kfree(table->cmd_idx);
  2876. return -ENOMEM;
  2877. }
  2878. static int mdss_samsung_parse_panel_cmd(struct device_node *np,
  2879. struct dsi_cmd *commands, char *keystring)
  2880. {
  2881. const char *data;
  2882. int type, len = 0, i = 0;
  2883. char *bp;
  2884. struct dsi_ctrl_hdr *dchdr;
  2885. int is_read = 0;
  2886. data = of_get_property(np, keystring, &len);
  2887. if (!data) {
  2888. pr_err("%s:%d, Unable to read %s",
  2889. __func__, __LINE__, keystring);
  2890. return -ENOMEM;
  2891. }
  2892. commands->cmds_buff = kzalloc(sizeof(char) * len, GFP_KERNEL);
  2893. if (!commands->cmds_buff)
  2894. return -ENOMEM;
  2895. memcpy(commands->cmds_buff, data, len);
  2896. commands->cmds_len = len;
  2897. /* scan dcs commands */
  2898. bp = commands->cmds_buff;
  2899. while (len > sizeof(*dchdr)) {
  2900. dchdr = (struct dsi_ctrl_hdr *)bp;
  2901. dchdr->dlen = ntohs(dchdr->dlen);
  2902. if (dchdr->dlen >200)
  2903. goto error2;
  2904. bp += sizeof(*dchdr);
  2905. len -= sizeof(*dchdr);
  2906. bp += dchdr->dlen;
  2907. len -= dchdr->dlen;
  2908. commands->num_of_cmds++;
  2909. type = dchdr->dtype;
  2910. if (type == DTYPE_GEN_READ ||
  2911. type == DTYPE_GEN_READ1 ||
  2912. type == DTYPE_GEN_READ2 ||
  2913. type == DTYPE_DCS_READ) {
  2914. /* Read command :last byte contain read size, read start */
  2915. bp += 2;
  2916. len -= 2;
  2917. is_read = 1;
  2918. }
  2919. }
  2920. if (len != 0) {
  2921. pr_err("%s: dcs OFF command byte Error, len=%d", __func__, len);
  2922. commands->cmds_len = 0;
  2923. commands->num_of_cmds = 0;
  2924. goto error2;
  2925. }
  2926. if (is_read) {
  2927. /*
  2928. Allocate an array which will store the number
  2929. for bytes to read for each read command
  2930. */
  2931. commands->read_size = kzalloc(sizeof(char) * \
  2932. commands->num_of_cmds, GFP_KERNEL);
  2933. if (!commands->read_size) {
  2934. pr_err("%s:%d, Unable to read NV cmds",
  2935. __func__, __LINE__);
  2936. goto error2;
  2937. }
  2938. commands->read_startoffset = kzalloc(sizeof(char) * \
  2939. commands->num_of_cmds, GFP_KERNEL);
  2940. if (!commands->read_startoffset) {
  2941. pr_err("%s:%d, Unable to read NV cmds",
  2942. __func__, __LINE__);
  2943. goto error1;
  2944. }
  2945. }
  2946. commands->cmd_desc = kzalloc(commands->num_of_cmds
  2947. * sizeof(struct dsi_cmd_desc),
  2948. GFP_KERNEL);
  2949. if (!commands->cmd_desc)
  2950. goto error1;
  2951. bp = commands->cmds_buff;
  2952. len = commands->cmds_len;
  2953. for (i = 0; i < commands->num_of_cmds; i++) {
  2954. dchdr = (struct dsi_ctrl_hdr *)bp;
  2955. len -= sizeof(*dchdr);
  2956. bp += sizeof(*dchdr);
  2957. commands->cmd_desc[i].dchdr = *dchdr;
  2958. commands->cmd_desc[i].payload = bp;
  2959. bp += dchdr->dlen;
  2960. len -= dchdr->dlen;
  2961. if (is_read)
  2962. {
  2963. commands->read_size[i] = *bp++;
  2964. commands->read_startoffset[i] = *bp++;
  2965. len -= 2;
  2966. }
  2967. }
  2968. return 0;
  2969. error1:
  2970. kfree(commands->read_size);
  2971. error2:
  2972. kfree(commands->cmds_buff);
  2973. return -EINVAL;
  2974. }
  2975. int mdss_panel_dt_get_dst_fmt(u32 bpp, char mipi_mode, u32 pixel_packing,
  2976. char *dst_format)
  2977. {
  2978. int rc = 0;
  2979. switch (bpp) {
  2980. case 3:
  2981. *dst_format = DSI_CMD_DST_FORMAT_RGB111;
  2982. break;
  2983. case 8:
  2984. *dst_format = DSI_CMD_DST_FORMAT_RGB332;
  2985. break;
  2986. case 12:
  2987. *dst_format = DSI_CMD_DST_FORMAT_RGB444;
  2988. break;
  2989. case 16:
  2990. switch (mipi_mode) {
  2991. case DSI_VIDEO_MODE:
  2992. *dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
  2993. break;
  2994. case DSI_CMD_MODE:
  2995. *dst_format = DSI_CMD_DST_FORMAT_RGB565;
  2996. break;
  2997. default:
  2998. *dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
  2999. break;
  3000. }
  3001. break;
  3002. case 18:
  3003. switch (mipi_mode) {
  3004. case DSI_VIDEO_MODE:
  3005. if (pixel_packing == 0)
  3006. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666;
  3007. else
  3008. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
  3009. break;
  3010. case DSI_CMD_MODE:
  3011. *dst_format = DSI_CMD_DST_FORMAT_RGB666;
  3012. break;
  3013. default:
  3014. if (pixel_packing == 0)
  3015. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666;
  3016. else
  3017. *dst_format = DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
  3018. break;
  3019. }
  3020. break;
  3021. case 24:
  3022. switch (mipi_mode) {
  3023. case DSI_VIDEO_MODE:
  3024. *dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
  3025. break;
  3026. case DSI_CMD_MODE:
  3027. *dst_format = DSI_CMD_DST_FORMAT_RGB888;
  3028. break;
  3029. default:
  3030. *dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
  3031. break;
  3032. }
  3033. break;
  3034. default:
  3035. rc = -EINVAL;
  3036. break;
  3037. }
  3038. return rc;
  3039. }
  3040. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  3041. static void mdss_panel_parse_te_params(struct device_node *np,
  3042. struct mdss_panel_info *panel_info)
  3043. {
  3044. u32 tmp;
  3045. int rc = 0;
  3046. /*
  3047. * TE default: dsi byte clock calculated base on 70 fps;
  3048. * around 14 ms to complete a kickoff cycle if te disabled;
  3049. * vclk_line base on 60 fps; write is faster than read;
  3050. * init == start == rdptr;
  3051. */
  3052. panel_info->te.tear_check_en =
  3053. !of_property_read_bool(np, "qcom,mdss-tear-check-disable");
  3054. rc = of_property_read_u32
  3055. (np, "qcom,mdss-tear-check-sync-cfg-height", &tmp);
  3056. panel_info->te.sync_cfg_height = (!rc ? tmp : 0xfff0);
  3057. rc = of_property_read_u32
  3058. (np, "qcom,mdss-tear-check-sync-init-val", &tmp);
  3059. panel_info->te.vsync_init_val = (!rc ? tmp : panel_info->yres);
  3060. rc = of_property_read_u32
  3061. (np, "qcom,mdss-tear-check-sync-threshold-start", &tmp);
  3062. panel_info->te.sync_threshold_start = (!rc ? tmp : 4);
  3063. rc = of_property_read_u32
  3064. (np, "qcom,mdss-tear-check-sync-threshold-continue", &tmp);
  3065. panel_info->te.sync_threshold_continue = (!rc ? tmp : 4);
  3066. rc = of_property_read_u32(np, "qcom,mdss-tear-check-start-pos", &tmp);
  3067. panel_info->te.start_pos = (!rc ? tmp : panel_info->yres);
  3068. rc = of_property_read_u32
  3069. (np, "qcom,mdss-tear-check-rd-ptr-trigger-intr", &tmp);
  3070. panel_info->te.rd_ptr_irq = (!rc ? tmp : panel_info->yres + 1);
  3071. rc = of_property_read_u32(np, "qcom,mdss-tear-check-frame-rate", &tmp);
  3072. panel_info->te.refx100 = (!rc ? tmp : 6000);
  3073. }
  3074. #endif
  3075. static int mdss_dsi_parse_dcs_cmds(struct device_node *np,
  3076. struct dsi_panel_cmds *pcmds, char *cmd_key, char *link_key)
  3077. {
  3078. const char *data;
  3079. int blen = 0, len;
  3080. char *buf, *bp;
  3081. struct dsi_ctrl_hdr *dchdr;
  3082. int i, cnt;
  3083. data = of_get_property(np, cmd_key, &blen);
  3084. if (!data) {
  3085. pr_err("%s: failed, key=%s\n", __func__, cmd_key);
  3086. return -ENOMEM;
  3087. }
  3088. buf = kzalloc(sizeof(char) * blen, GFP_KERNEL);
  3089. if (!buf)
  3090. return -ENOMEM;
  3091. memcpy(buf, data, blen);
  3092. /* scan dcs commands */
  3093. bp = buf;
  3094. len = blen;
  3095. cnt = 0;
  3096. while (len > sizeof(*dchdr)) {
  3097. dchdr = (struct dsi_ctrl_hdr *)bp;
  3098. dchdr->dlen = ntohs(dchdr->dlen);
  3099. if (dchdr->dlen > len) {
  3100. pr_err("%s: dtsi cmd=%x error, len=%d",
  3101. __func__, dchdr->dtype, dchdr->dlen);
  3102. goto exit_free;
  3103. }
  3104. bp += sizeof(*dchdr);
  3105. len -= sizeof(*dchdr);
  3106. bp += dchdr->dlen;
  3107. len -= dchdr->dlen;
  3108. cnt++;
  3109. }
  3110. if (len != 0) {
  3111. pr_err("%s: dcs_cmd=%x len=%d error!",
  3112. __func__, buf[0], blen);
  3113. goto exit_free;
  3114. }
  3115. pcmds->cmds = kzalloc(cnt * sizeof(struct dsi_cmd_desc),
  3116. GFP_KERNEL);
  3117. if (!pcmds->cmds)
  3118. goto exit_free;
  3119. pcmds->cmd_cnt = cnt;
  3120. pcmds->buf = buf;
  3121. pcmds->blen = blen;
  3122. bp = buf;
  3123. len = blen;
  3124. for (i = 0; i < cnt; i++) {
  3125. dchdr = (struct dsi_ctrl_hdr *)bp;
  3126. len -= sizeof(*dchdr);
  3127. bp += sizeof(*dchdr);
  3128. pcmds->cmds[i].dchdr = *dchdr;
  3129. pcmds->cmds[i].payload = bp;
  3130. bp += dchdr->dlen;
  3131. len -= dchdr->dlen;
  3132. }
  3133. /*Set default link state to LP Mode*/
  3134. pcmds->link_state = DSI_LP_MODE;
  3135. if (link_key) {
  3136. data = of_get_property(np, link_key, NULL);
  3137. if (data && !strcmp(data, "dsi_hs_mode"))
  3138. pcmds->link_state = DSI_HS_MODE;
  3139. else
  3140. pcmds->link_state = DSI_LP_MODE;
  3141. }
  3142. pr_info("%s: dcs_cmd=%x len=%d, cmd_cnt=%d link_state=%d\n", __func__,
  3143. pcmds->buf[0], pcmds->blen, pcmds->cmd_cnt, pcmds->link_state);
  3144. return 0;
  3145. exit_free:
  3146. kfree(buf);
  3147. return -ENOMEM;
  3148. }
  3149. static int mdss_panel_parse_dt(struct device_node *np,
  3150. struct mdss_dsi_ctrl_pdata *ctrl_pdata)
  3151. {
  3152. u32 res[6], tmp;
  3153. u32 fbc_res[7];
  3154. int rc, i, len;
  3155. const char *data;
  3156. static const char *bl_ctrl_type, *pdest;
  3157. struct mdss_panel_info *pinfo = &(ctrl_pdata->panel_data.panel_info);
  3158. bool fbc_enabled = false;
  3159. rc = of_property_read_u32_array(np, "qcom,mdss-pan-res", res, 2);
  3160. if (rc) {
  3161. pr_err("%s:%d, panel resolution not specified\n",
  3162. __func__, __LINE__);
  3163. return -EINVAL;
  3164. }
  3165. pinfo->xres = (!rc ? res[0] : 640);
  3166. pinfo->yres= (!rc ? res[1] : 480);
  3167. rc = of_property_read_u32_array(np, "qcom,mdss-pan-size", res, 2);
  3168. if (rc == 0) {
  3169. pinfo->width = res[0];
  3170. pinfo->height = res[1];
  3171. }
  3172. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  3173. err_fg_gpio = of_get_named_gpio(np, "qcom,esd-irq-gpio", 0);
  3174. if (!gpio_is_valid(err_fg_gpio)) {
  3175. pr_err("%s:%d, esd gpio not specified\n",
  3176. __func__, __LINE__);
  3177. } else {
  3178. rc = gpio_request(err_fg_gpio, "esd_enable");
  3179. if (rc) {
  3180. pr_err("request esd gpio failed, rc=%d\n",
  3181. rc);
  3182. gpio_free(err_fg_gpio);
  3183. return -ENODEV;
  3184. }
  3185. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  3186. if(get_oled_id()) err_fg_enable = 1; // s.lsi only
  3187. #elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  3188. err_fg_enable = 1;
  3189. #endif
  3190. }
  3191. #endif
  3192. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  3193. lcd_crack_gpio= of_get_named_gpio(np,"qcom,lcd-crack-det-gpio", 0);
  3194. if (!gpio_is_valid(lcd_crack_gpio)) {
  3195. pr_err("%s:%d, lcd_crack_gpio not specified\n",
  3196. __func__, __LINE__);
  3197. } else {
  3198. rc = gpio_tlmm_config(GPIO_CFG(lcd_crack_gpio, 0,
  3199. GPIO_CFG_INPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  3200. GPIO_CFG_ENABLE);
  3201. if (rc) {
  3202. pr_err("request lcd_crack_gpio failed, rc=%d\n",rc);
  3203. }
  3204. }
  3205. #endif
  3206. rc = of_property_read_u32_array(np, "qcom,mdss-pan-active-res", res, 2);
  3207. if (rc == 0) {
  3208. pinfo->lcdc.xres_pad =
  3209. pinfo->xres - res[0];
  3210. pinfo->lcdc.yres_pad =
  3211. pinfo->yres - res[1];
  3212. }
  3213. rc = of_property_read_u32(np, "qcom,mdss-pan-bpp", &tmp);
  3214. if (rc) {
  3215. pr_err("%s:%d, panel bpp not specified\n",
  3216. __func__, __LINE__);
  3217. return -EINVAL;
  3218. }
  3219. pinfo->bpp = (!rc ? tmp : 24);
  3220. pdest = of_get_property(np,
  3221. "qcom,mdss-pan-dest", NULL);
  3222. if (strlen(pdest) != 9) {
  3223. pr_err("%s: Unknown pdest specified\n", __func__);
  3224. return -EINVAL;
  3225. }
  3226. if (!strncmp(pdest, "display_1", 9))
  3227. pinfo->pdest = DISPLAY_1;
  3228. else if (!strncmp(pdest, "display_2", 9))
  3229. pinfo->pdest = DISPLAY_2;
  3230. else {
  3231. pr_debug("%s: pdest not specified. Set Default\n",
  3232. __func__);
  3233. pinfo->pdest = DISPLAY_1;
  3234. }
  3235. rc = of_property_read_u32_array(np,
  3236. "qcom,mdss-pan-porch-values", res, 6);
  3237. pinfo->lcdc.h_back_porch = (!rc ? res[0] : 6);
  3238. pinfo->lcdc.h_pulse_width = (!rc ? res[1] : 2);
  3239. pinfo->lcdc.h_front_porch = (!rc ? res[2] : 6);
  3240. pinfo->lcdc.v_back_porch = (!rc ? res[3] : 6);
  3241. pinfo->lcdc.v_pulse_width = (!rc ? res[4] : 2);
  3242. pinfo->lcdc.v_front_porch = (!rc ? res[5] : 6);
  3243. rc = of_property_read_u32(np,
  3244. "qcom,mdss-pan-underflow-clr", &tmp);
  3245. pinfo->lcdc.underflow_clr = (!rc ? tmp : 0xff);
  3246. bl_ctrl_type = of_get_property(np,
  3247. "qcom,mdss-pan-bl-ctrl", NULL);
  3248. if ((bl_ctrl_type) && (!strncmp(bl_ctrl_type, "bl_ctrl_wled", 12))) {
  3249. led_trigger_register_simple("bkl-trigger", &bl_led_trigger);
  3250. pr_debug("%s: SUCCESS-> WLED TRIGGER register\n", __func__);
  3251. pinfo->bklt_ctrl = BL_WLED;
  3252. } else if (!strncmp(bl_ctrl_type, "bl_ctrl_pwm", 11)) {
  3253. ctrl_pdata->bklt_ctrl = BL_PWM;
  3254. rc = of_property_read_u32(np, "qcom,dsi-pwm-period", &tmp);
  3255. if (rc) {
  3256. pr_err("%s:%d, Error, dsi pwm_period\n",
  3257. __func__, __LINE__);
  3258. return -EINVAL;
  3259. }
  3260. ctrl_pdata->pwm_period = tmp;
  3261. rc = of_property_read_u32(np, "qcom,dsi-lpg-channel", &tmp);
  3262. if (rc) {
  3263. pr_err("%s:%d, Error, dsi lpg channel\n",
  3264. __func__, __LINE__);
  3265. return -EINVAL;
  3266. }
  3267. ctrl_pdata->pwm_lpg_chan = tmp;
  3268. tmp = of_get_named_gpio(np, "qcom,dsi-pwm-gpio", 0);
  3269. ctrl_pdata->pwm_pmic_gpio = tmp;
  3270. } else if (!strncmp(bl_ctrl_type, "bl_ctrl_dcs_cmds", 12)) {
  3271. pr_debug("%s: SUCCESS-> DCS CMD BACKLIGHT register\n",
  3272. __func__);
  3273. ctrl_pdata->bklt_ctrl = BL_DCS_CMD;
  3274. } else {
  3275. pr_debug("%s: Unknown backlight control\n", __func__);
  3276. ctrl_pdata->bklt_ctrl = UNKNOWN_CTRL;
  3277. }
  3278. rc = of_property_read_u32(np, "qcom,mdss-brightness-max-level", &tmp);
  3279. pinfo->brightness_max = (!rc ? tmp : MDSS_MAX_BL_BRIGHTNESS);
  3280. rc = of_property_read_u32_array(np,
  3281. "qcom,mdss-pan-bl-levels", res, 2);
  3282. pinfo->bl_min = (!rc ? res[0] : 0);
  3283. pinfo->bl_max = (!rc ? res[1] : 255);
  3284. ctrl_pdata->bklt_max = pinfo->bl_max;
  3285. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-mode", &tmp);
  3286. pinfo->mipi.mode = (!rc ? tmp : DSI_VIDEO_MODE);
  3287. rc = of_property_read_u32(np, "qcom,mdss-vsync-enable", &tmp);
  3288. pinfo->mipi.vsync_enable = (!rc ? tmp : 0);
  3289. rc = of_property_read_u32(np, "qcom,mdss-hw-vsync-mode", &tmp);
  3290. pinfo->mipi.hw_vsync_mode = (!rc ? tmp : 0);
  3291. rc = of_property_read_u32(np,
  3292. "qcom,mdss-pan-dsi-h-pulse-mode", &tmp);
  3293. pinfo->mipi.pulse_mode_hsa_he = (!rc ? tmp : false);
  3294. rc = of_property_read_u32_array(np,
  3295. "qcom,mdss-pan-dsi-h-power-stop", res, 3);
  3296. pinfo->mipi.hbp_power_stop = (!rc ? res[0] : false);
  3297. pinfo->mipi.hsa_power_stop = (!rc ? res[1] : false);
  3298. pinfo->mipi.hfp_power_stop = (!rc ? res[2] : false);
  3299. rc = of_property_read_u32_array(np,
  3300. "qcom,mdss-pan-dsi-bllp-power-stop", res, 2);
  3301. pinfo->mipi.bllp_power_stop =
  3302. (!rc ? res[0] : false);
  3303. pinfo->mipi.eof_bllp_power_stop =
  3304. (!rc ? res[1] : false);
  3305. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-traffic-mode", &tmp);
  3306. pinfo->mipi.traffic_mode = (!rc ? tmp : DSI_NON_BURST_SYNCH_PULSE);
  3307. rc = of_property_read_u32(np, "qcom,mdss-pan-insert-dcs-cmd", &tmp);
  3308. pinfo->mipi.insert_dcs_cmd = (!rc ? tmp : 1);
  3309. rc = of_property_read_u32(np, "qcom,mdss-pan-wr-mem-continue", &tmp);
  3310. pinfo->mipi.wr_mem_continue = (!rc ? tmp : 0x3c);
  3311. rc = of_property_read_u32(np, "qcom,mdss-pan-wr-mem-start", &tmp);
  3312. pinfo->mipi.wr_mem_start = (!rc ? tmp : 0x2c);
  3313. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  3314. rc = of_property_read_u32(np, "qcom,mdss-pan-te-sel", &tmp);
  3315. pinfo->mipi.te_sel = (!rc ? tmp : 1);
  3316. #endif
  3317. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-dst-format", &tmp);
  3318. pinfo->mipi.dst_format = (!rc ? tmp : DSI_VIDEO_DST_FORMAT_RGB888);
  3319. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-vc", &tmp);
  3320. pinfo->mipi.vc = (!rc ? tmp : 0);
  3321. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-rgb-swap", &tmp);
  3322. pinfo->mipi.rgb_swap = (!rc ? tmp : DSI_RGB_SWAP_RGB);
  3323. rc = of_property_read_u32(np, "qcom,mdss-force-clk-lane-hs", &tmp);
  3324. pinfo->mipi.force_clk_lane_hs = (!rc ? tmp : 0);
  3325. rc = of_property_read_u32(np, "samsung,mdss-early-lcd-on", &tmp);
  3326. pinfo->early_lcd_on = (!rc ? tmp : 0);
  3327. rc = of_property_read_u32_array(np,
  3328. "qcom,mdss-pan-dsi-data-lanes", res, 4);
  3329. pinfo->mipi.data_lane0 = (!rc ? res[0] : true);
  3330. pinfo->mipi.data_lane1 = (!rc ? res[1] : false);
  3331. pinfo->mipi.data_lane2 = (!rc ? res[2] : false);
  3332. pinfo->mipi.data_lane3 = (!rc ? res[3] : false);
  3333. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-dlane-swap", &tmp);
  3334. pinfo->mipi.dlane_swap = (!rc ? tmp : 0);
  3335. rc = of_property_read_u32_array(np, "qcom,mdss-pan-dsi-t-clk", res, 2);
  3336. pinfo->mipi.t_clk_pre = (!rc ? res[0] : 0x24);
  3337. pinfo->mipi.t_clk_post = (!rc ? res[1] : 0x03);
  3338. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-stream", &tmp);
  3339. pinfo->mipi.stream = (!rc ? tmp : 0);
  3340. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-tx-eot-append", &tmp);
  3341. pinfo->mipi.tx_eot_append = (!rc ? tmp : 0);
  3342. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-mdp-tr", &tmp);
  3343. pinfo->mipi.mdp_trigger =
  3344. (!rc ? tmp : DSI_CMD_TRIGGER_SW);
  3345. if (pinfo->mipi.mdp_trigger > 6) {
  3346. pr_err("%s:%d, Invalid mdp trigger. Forcing to sw trigger",
  3347. __func__, __LINE__);
  3348. pinfo->mipi.mdp_trigger = DSI_CMD_TRIGGER_SW;
  3349. }
  3350. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-dma-tr", &tmp);
  3351. pinfo->mipi.dma_trigger = (!rc ? tmp : DSI_CMD_TRIGGER_SW);
  3352. if (pinfo->mipi.dma_trigger > 6) {
  3353. pr_err("%s:%d, Invalid dma trigger. Forcing to sw trigger",
  3354. __func__, __LINE__);
  3355. pinfo->mipi.dma_trigger = DSI_CMD_TRIGGER_SW;
  3356. }
  3357. rc = of_property_read_u32(np, "qcom,mdss-pan-dsi-frame-rate", &tmp);
  3358. pinfo->mipi.frame_rate = (!rc ? tmp : 60);
  3359. rc = of_property_read_u32(np, "qcom,mdss-pan-clk-rate", &tmp);
  3360. pinfo->clk_rate = (!rc ? tmp : 0);
  3361. data = of_get_property(np, "qcom,panel-phy-regulatorSettings", &len);
  3362. if ((!data) || (len != 7)) {
  3363. pr_err("%s:%d, Unable to read Phy regulator settings",
  3364. __func__, __LINE__);
  3365. return -EINVAL;
  3366. }
  3367. for (i = 0; i < len; i++)
  3368. phy_params.regulator[i] = data[i];
  3369. data = of_get_property(np, "qcom,panel-phy-timingSettings", &len);
  3370. if ((!data) || (len != 12)) {
  3371. pr_err("%s:%d, Unable to read Phy timing settings",
  3372. __func__, __LINE__);
  3373. return -EINVAL;
  3374. }
  3375. for (i = 0; i < len; i++)
  3376. phy_params.timing[i] = data[i];
  3377. data = of_get_property(np, "qcom,panel-phy-strengthCtrl", &len);
  3378. if ((!data) || (len != 2)) {
  3379. pr_err("%s:%d, Unable to read Phy Strength ctrl settings",
  3380. __func__, __LINE__);
  3381. return -EINVAL;
  3382. }
  3383. phy_params.strength[0] = data[0];
  3384. phy_params.strength[1] = data[1];
  3385. data = of_get_property(np, "qcom,panel-phy-bistCtrl", &len);
  3386. if ((!data) || (len != 6)) {
  3387. pr_err("%s:%d, Unable to read Phy Bist Ctrl settings",
  3388. __func__, __LINE__);
  3389. return -EINVAL;
  3390. }
  3391. for (i = 0; i < len; i++)
  3392. phy_params.bistctrl[i] = data[i];
  3393. data = of_get_property(np, "qcom,panel-phy-laneConfig", &len);
  3394. if ((!data) || (len != 45)) {
  3395. pr_err("%s:%d, Unable to read Phy lane configure settings",
  3396. __func__, __LINE__);
  3397. return -EINVAL;
  3398. }
  3399. for (i = 0; i < len; i++)
  3400. phy_params.lanecfg[i] = data[i];
  3401. pinfo->mipi.dsi_phy_db = phy_params;
  3402. fbc_enabled = of_property_read_bool(np,
  3403. "qcom,fbc-enabled");
  3404. if (fbc_enabled) {
  3405. pr_debug("%s:%d FBC panel enabled.\n", __func__, __LINE__);
  3406. pinfo->fbc.enabled = 1;
  3407. rc = of_property_read_u32_array(np,
  3408. "qcom,fbc-mode", fbc_res, 7);
  3409. pinfo->fbc.target_bpp =
  3410. (!rc ? fbc_res[0] : pinfo->bpp);
  3411. pinfo->fbc.comp_mode = (!rc ? fbc_res[1] : 0);
  3412. pinfo->fbc.qerr_enable =
  3413. (!rc ? fbc_res[2] : 0);
  3414. pinfo->fbc.cd_bias = (!rc ? fbc_res[3] : 0);
  3415. pinfo->fbc.pat_enable = (!rc ? fbc_res[4] : 0);
  3416. pinfo->fbc.vlc_enable = (!rc ? fbc_res[5] : 0);
  3417. pinfo->fbc.bflc_enable =
  3418. (!rc ? fbc_res[6] : 0);
  3419. rc = of_property_read_u32_array(np,
  3420. "qcom,fbc-budget-ctl", fbc_res, 3);
  3421. pinfo->fbc.line_x_budget =
  3422. (!rc ? fbc_res[0] : 0);
  3423. pinfo->fbc.block_x_budget =
  3424. (!rc ? fbc_res[1] : 0);
  3425. pinfo->fbc.block_budget =
  3426. (!rc ? fbc_res[2] : 0);
  3427. rc = of_property_read_u32_array(np,
  3428. "qcom,fbc-lossy-mode", fbc_res, 4);
  3429. pinfo->fbc.lossless_mode_thd =
  3430. (!rc ? fbc_res[0] : 0);
  3431. pinfo->fbc.lossy_mode_thd =
  3432. (!rc ? fbc_res[1] : 0);
  3433. pinfo->fbc.lossy_rgb_thd =
  3434. (!rc ? fbc_res[2] : 0);
  3435. pinfo->fbc.lossy_mode_idx =
  3436. (!rc ? fbc_res[3] : 0);
  3437. } else {
  3438. pr_debug("%s:%d Panel does not support FBC.\n",
  3439. __func__, __LINE__);
  3440. pinfo->fbc.enabled = 0;
  3441. pinfo->fbc.target_bpp =
  3442. pinfo->bpp;
  3443. }
  3444. mdss_dsi_parse_dcs_cmds(np, &ctrl_pdata->on_cmds,
  3445. "qcom,panel-on-cmds", "qcom,on-cmds-dsi-state");
  3446. mdss_dsi_parse_dcs_cmds(np, &ctrl_pdata->off_cmds,
  3447. "qcom,panel-off-cmds", "qcom,off-cmds-dsi-state");
  3448. #if 1
  3449. mdss_samsung_parse_panel_cmd(np, &display_qcom_on_cmds,
  3450. "qcom,panel-on-cmds");
  3451. mdss_samsung_parse_panel_cmd(np, &display_qcom_off_cmds,
  3452. "qcom,panel-off-cmds");
  3453. #endif
  3454. #if defined(octa_manufacture_date)
  3455. mdss_samsung_parse_panel_cmd(np, &nv_date_read_cmds,
  3456. "samsung,panel-nv-mdate-read-cmds");
  3457. #endif
  3458. mdss_samsung_parse_panel_cmd(np, &nv_mtp_read_cmds,
  3459. "samsung,panel-nv-mtp-read-cmds");
  3460. mdss_samsung_parse_panel_cmd(np, &nv_mtp_read_register_set_cmds,
  3461. "samsung,panel-mtp-read-cmds");
  3462. #if defined(HBM_RE)
  3463. mdss_samsung_parse_panel_cmd(np, &nv_mtp_hbm_read_cmds,
  3464. "samsung,panel-nv-mtp-read-hbm-cmds");
  3465. mdss_samsung_parse_panel_cmd(np, &nv_mtp_hbm2_read_cmds,
  3466. "samsung,panel-nv-mtp-read-hbm2-cmds");
  3467. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_list,
  3468. "samsung,panel-etc-hbm-cmds");
  3469. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)\
  3470. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  3471. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  3472. mdss_samsung_parse_panel_cmd(np, &nv_mtp_hbm3_read_cmds,
  3473. "samsung,panel-nv-mtp-read-hbm3-cmds");
  3474. mdss_samsung_parse_panel_cmd(np, &hbm_hbm_off_elvss_cmds,
  3475. "samsung,panel-hbm-off-elvss-cmds");
  3476. #endif
  3477. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_evt0_second_list,
  3478. "samsung,panel-etc-hbm-evt0-second-cmds");
  3479. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_evt1_list,
  3480. "samsung,panel-etc-hbm-evt1-cmds");
  3481. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_evt1_second_list,
  3482. "samsung,panel-etc-hbm-evt1-second-cmds");
  3483. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_evt1_H_revI_list,
  3484. "samsung,panel-etc-hbm-evt1-revI-cmds");
  3485. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_evt1_H_revJ_list,
  3486. "samsung,panel-etc-hbm-evt1-revJ-cmds");
  3487. mdss_samsung_parse_panel_cmd(np, &hbm_gamma_cmds_list,
  3488. "samsung,panel-gamma-hbm-cmds-list");
  3489. #elif defined(CONFIG_HBM_PSRE)
  3490. mdss_samsung_parse_panel_cmd(np, &nv_mtp_hbm_read_cmds,
  3491. "samsung,panel-nv-mtp-read-hbm-cmds");
  3492. mdss_samsung_parse_panel_cmd(np, &nv_mtp_hbm2_read_cmds,
  3493. "samsung,panel-nv-mtp-read-hbm2-cmds");
  3494. mdss_samsung_parse_panel_cmd(np, &nv_mtp_hbm3_read_cmds,
  3495. "samsung,panel-nv-mtp-read-hbm3-cmds");
  3496. mdss_samsung_parse_panel_cmd(np, &nv_hbm_elvss_offset_cmds,
  3497. "samsung,panel-nv-hbm-elvss-offset-cmds");
  3498. mdss_samsung_parse_panel_cmd(np, &nv_production_day_cmds,
  3499. "samsung,panel-nv-production-day-cmds");
  3500. mdss_samsung_parse_panel_cmd(np, &hbm_gamma_cmds_list,
  3501. "samsung,panel-gamma-hbm-cmds-list");
  3502. mdss_samsung_parse_panel_cmd(np, &hbm_etc_cmds_list,
  3503. "samsung,panel-etc-hbm-cmds");
  3504. #endif
  3505. mdss_samsung_parse_panel_cmd(np, &nv_mdnie_read_cmds,
  3506. "samsung,panel-nv-mdnie-read-cmds");
  3507. mdss_samsung_parse_panel_cmd(np, &nv_enable_cmds,
  3508. "samsung,panel-nv-read-enable-cmds");
  3509. mdss_samsung_parse_panel_cmd(np, &nv_disable_cmds,
  3510. "samsung,panel-nv-read-disable-cmds");
  3511. mdss_samsung_parse_panel_cmd(np, &manufacture_id_cmds,
  3512. "samsung,panel-manufacture-id-read-cmds");
  3513. #ifdef DEBUG_LDI_STATUS
  3514. mdss_samsung_parse_panel_cmd(np, &ldi_debug_cmds,
  3515. "samsung,panel-ldi-debug-read-cmds");
  3516. #endif
  3517. #ifdef LDI_FPS_CHANGE
  3518. mdss_samsung_parse_panel_cmd(np, &read_ldi_fps_cmds,
  3519. "samsung,panel-ldi-fps-read-cmds");
  3520. mdss_samsung_parse_panel_cmd(np, &write_ldi_fps_cmds,
  3521. "samsung,panel-ldi-fps-write-cmds");
  3522. #endif
  3523. #ifdef LDI_ADJ_VDDM_OFFSET
  3524. mdss_samsung_parse_panel_cmd(np, &read_vddm_ref_cmds,
  3525. "samsung,panel-ldi-vddm-read-cmds");
  3526. mdss_samsung_parse_panel_cmd(np, &write_vddm_offset_cmds,
  3527. "samsung,panel-ldi-vddm-offset-write-cmds");
  3528. #endif
  3529. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)
  3530. mdss_samsung_parse_panel_cmd(np, &magna_read_pos_cmds,
  3531. "magna,panel-read-pos-cmds");
  3532. mdss_samsung_parse_panel_cmd(np, &magna_read_run_cmds,
  3533. "magna,panel-read-run-cmds");
  3534. #endif
  3535. mdss_samsung_parse_panel_cmd(np, &display_on_cmd,
  3536. "qcom,panel-display-on-cmds");
  3537. mdss_samsung_parse_panel_cmd(np, &display_off_cmd,
  3538. "qcom,panel-display-off-cmds");
  3539. mdss_samsung_parse_panel_cmd(np, &display_unblank_cmd,
  3540. "qcom,panel-display-unblank-cmds");
  3541. mdss_samsung_parse_panel_cmd(np, &display_blank_cmd,
  3542. "qcom,panel-display-blank-cmds");
  3543. mdss_samsung_parse_panel_cmd(np, &acl_off_cmd,
  3544. "samsung,panel-acl-off-cmds");
  3545. mdss_samsung_parse_panel_cmd(np, &acl_cmds_list,
  3546. "samsung,panel-acl-cmds-list");
  3547. #if !defined(NOT_USING_ACL_CONT)
  3548. mdss_samsung_parse_panel_cmd(np, &aclcont_cmds_list,
  3549. "samsung,panel-aclcont-cmds-list");
  3550. #endif
  3551. #if defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  3552. mdss_samsung_parse_panel_cmd(np, &elvss_lowtemp_cmds_list,
  3553. "samsung,panel-elvss-lowtemp-cmds-list");
  3554. #endif
  3555. #if defined(TEMPERATURE_ELVSS)
  3556. mdss_samsung_parse_panel_cmd(np, &elvss_lowtemp_cmds_list,
  3557. "samsung,panel-elvss-lowtemp-cmds-list");
  3558. mdss_samsung_parse_panel_cmd(np, &elvss_tempcompen_cmds_list,
  3559. "samsung,panel-elvss-cmds-tempcompen-list");
  3560. #endif
  3561. mdss_samsung_parse_panel_cmd(np, &gamma_cmds_list,
  3562. "samsung,panel-gamma-cmds-list");
  3563. mdss_samsung_parse_panel_cmd(np, &elvss_cmds_list,
  3564. "samsung,panel-elvss-cmds-list");
  3565. mdss_samsung_parse_panel_cmd(np, &aid_cmds_list,
  3566. "samsung,panel-aid-cmds-list");
  3567. mdss_samsung_parse_panel_cmd(np, &aid_cmds_list_350,
  3568. "samsung,panel-aid-cmds-list-350");
  3569. #if defined(SMART_ACL)
  3570. mdss_samsung_parse_panel_cmd(np, &smart_acl_elvss_cmds_list,
  3571. "samsung,panel-smart-acl-elvss-cmds-list");
  3572. #endif
  3573. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  3574. mdss_samsung_parse_panel_cmd(np, &lcd_crack_rec_cmd_list,
  3575. "samsung,panel-crack-rec-cmds-list");
  3576. #endif
  3577. /* Process the mapping tables */
  3578. mdss_samsung_parse_panel_table(np, &aid_map_table,
  3579. "samsung,panel-aid-map-table");
  3580. mdss_samsung_parse_panel_table(np, &acl_map_table,
  3581. "samsung,panel-acl-map-table");
  3582. mdss_samsung_parse_panel_table(np, &elvss_map_table,
  3583. "samsung,panel-elvss-map-table");
  3584. #if defined(SMART_ACL)
  3585. mdss_samsung_parse_panel_table(np, &smart_acl_elvss_map_table,
  3586. "samsung,panel-smart-acl-elvss-map-table");
  3587. #endif
  3588. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  3589. mdss_panel_parse_te_params(np, pinfo);
  3590. #endif
  3591. /* Process the lux value table */
  3592. mdss_samsung_parse_candella_lux_mapping_table(np, &candela_map_table,
  3593. "samsung,panel-candella-mapping-table");
  3594. mdss_samsung_parse_candella_lux_mapping_table(np, &candela_map_table_350,
  3595. "samsung,panel-candella-mapping-table-350");
  3596. /* Process touch sensing */
  3597. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  3598. mdss_samsung_parse_panel_cmd(np, &touchsensing_on_cmd,
  3599. "qcom,panel-touchsensing-on-cmds");
  3600. mdss_samsung_parse_panel_cmd(np, &touchsensing_off_cmd,
  3601. "qcom,panel-touchsensing-off-cmds");
  3602. #endif
  3603. #if defined(PARTIAL_UPDATE)
  3604. mdss_samsung_parse_panel_cmd(np, &partialdisp_on_cmd,
  3605. "samsung,panel-ldi-partial-disp-on");
  3606. mdss_samsung_parse_panel_cmd(np, &partialdisp_off_cmd,
  3607. "samsung,panel-ldi-partial-disp-off");
  3608. #endif
  3609. #if defined(FORCE_500CD)
  3610. mdss_samsung_parse_panel_cmd(np, &force_500,
  3611. "samsung,panel-force-500cd-cmds");
  3612. #endif
  3613. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  3614. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  3615. mdss_samsung_parse_panel_cmd(np, &test_key_enable_cmds,
  3616. "samsung,panel-test-key-enable-cmds");
  3617. mdss_samsung_parse_panel_cmd(np, &test_key_disable_cmds,
  3618. "samsung,panel-test-key-disable-cmds");
  3619. #endif
  3620. return 0;
  3621. return -EINVAL;
  3622. }
  3623. #if defined(CONFIG_HAS_EARLYSUSPEND)
  3624. static void mipi_samsung_disp_early_suspend(struct early_suspend *h)
  3625. {
  3626. msd.mfd->resume_state = MIPI_SUSPEND_STATE;
  3627. LCD_DEBUG("------");
  3628. }
  3629. static void mipi_samsung_disp_late_resume(struct early_suspend *h)
  3630. {
  3631. msd.mfd->resume_state = MIPI_RESUME_STATE;
  3632. LCD_DEBUG("------");
  3633. }
  3634. #endif
  3635. static int is_panel_supported(const char *panel_name)
  3636. {
  3637. int i = 0;
  3638. if (panel_name == NULL)
  3639. return -EINVAL;
  3640. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  3641. || defined(CONFIG_FB_MSM_MIPI_S6E8AA0A_720P_PT_PANEL)\
  3642. || defined(CONFIG_FB_MSM_MDSS_MSM8X26)
  3643. if(!of_machine_is_compatible("qcom,msm8226-mtp"))
  3644. return -EINVAL;
  3645. #else
  3646. if(!of_machine_is_compatible("qcom,msm8974-cdp"))
  3647. return -EINVAL;
  3648. #endif
  3649. while(panel_supp_cdp[i].name != NULL) {
  3650. if(!strcmp(panel_name,panel_supp_cdp[i].name))
  3651. break;
  3652. i++;
  3653. }
  3654. if( i < ARRAY_SIZE(panel_supp_cdp)) {
  3655. memcpy(msd.panel_name, panel_name, MAX_PANEL_NAME_SIZE);
  3656. msd.panel = panel_supp_cdp[i].panel_code;
  3657. return 0;
  3658. }
  3659. return -EINVAL;
  3660. }
  3661. #ifdef DDI_VIDEO_ENHANCE_TUNING
  3662. #define MAX_FILE_NAME 128
  3663. #define TUNING_FILE_PATH "/sdcard/"
  3664. #define TUNE_FIRST_SIZE 5
  3665. #define TUNE_SECOND_SIZE 108
  3666. static char tuning_file[MAX_FILE_NAME];
  3667. static char mdni_tuning1[TUNE_FIRST_SIZE];
  3668. static char mdni_tuning2[TUNE_SECOND_SIZE];
  3669. static struct dsi_cmd_desc mdni_tune_cmd[] = {
  3670. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0,
  3671. sizeof(mdni_tuning2)}, mdni_tuning2},
  3672. {{DTYPE_DCS_LWRITE, 1, 0, 0, 0,
  3673. sizeof(mdni_tuning1)}, mdni_tuning1},
  3674. };
  3675. static char char_to_dec(char data1, char data2)
  3676. {
  3677. char dec;
  3678. dec = 0;
  3679. if (data1 >= 'a') {
  3680. data1 -= 'a';
  3681. data1 += 10;
  3682. } else if (data1 >= 'A') {
  3683. data1 -= 'A';
  3684. data1 += 10;
  3685. } else
  3686. data1 -= '0';
  3687. dec = data1 << 4;
  3688. if (data2 >= 'a') {
  3689. data2 -= 'a';
  3690. data2 += 10;
  3691. } else if (data2 >= 'A') {
  3692. data2 -= 'A';
  3693. data2 += 10;
  3694. } else
  3695. data2 -= '0';
  3696. dec |= data2;
  3697. return dec;
  3698. }
  3699. static void sending_tune_cmd(char *src, int len)
  3700. {
  3701. int data_pos;
  3702. int cmd_step;
  3703. int cmd_pos;
  3704. cmd_step = 0;
  3705. cmd_pos = 0;
  3706. for (data_pos = 0; data_pos < len;) {
  3707. if (*(src + data_pos) == '0') {
  3708. if (*(src + data_pos + 1) == 'x') {
  3709. if (!cmd_step) {
  3710. mdni_tuning1[cmd_pos] =
  3711. char_to_dec(*(src + data_pos + 2),
  3712. *(src + data_pos + 3));
  3713. } else {
  3714. mdni_tuning2[cmd_pos] =
  3715. char_to_dec(*(src + data_pos + 2),
  3716. *(src + data_pos + 3));
  3717. }
  3718. data_pos += 3;
  3719. cmd_pos++;
  3720. if (cmd_pos == TUNE_FIRST_SIZE && !cmd_step) {
  3721. cmd_pos = 0;
  3722. cmd_step = 1;
  3723. }
  3724. } else
  3725. data_pos++;
  3726. } else {
  3727. data_pos++;
  3728. }
  3729. }
  3730. printk(KERN_INFO "\n");
  3731. for (data_pos = 0; data_pos < TUNE_FIRST_SIZE ; data_pos++)
  3732. printk(KERN_INFO "0x%x ", mdni_tuning1[data_pos]);
  3733. printk(KERN_INFO "\n");
  3734. for (data_pos = 0; data_pos < TUNE_SECOND_SIZE ; data_pos++)
  3735. printk(KERN_INFO"0x%x ", mdni_tuning2[data_pos]);
  3736. printk(KERN_INFO "\n");
  3737. mutex_lock(&msd.lock);
  3738. mdss_dsi_cmds_send(msd.ctrl_pdata, mdni_tune_cmd, ARRAY_SIZE(mdni_tune_cmd), 0);
  3739. mutex_unlock(&msd.lock);
  3740. }
  3741. static void load_tuning_file(char *filename)
  3742. {
  3743. struct file *filp;
  3744. char *dp;
  3745. long l;
  3746. loff_t pos;
  3747. int ret;
  3748. mm_segment_t fs;
  3749. pr_info("%s called loading file name : [%s]\n", __func__,
  3750. filename);
  3751. fs = get_fs();
  3752. set_fs(get_ds());
  3753. filp = filp_open(filename, O_RDONLY, 0);
  3754. if (IS_ERR(filp)) {
  3755. printk(KERN_ERR "%s File open failed\n", __func__);
  3756. goto err;
  3757. }
  3758. l = filp->f_path.dentry->d_inode->i_size;
  3759. pr_info("%s Loading File Size : %ld(bytes)", __func__, l);
  3760. dp = kmalloc(l + 10, GFP_KERNEL);
  3761. if (dp == NULL) {
  3762. pr_info("Can't not alloc memory for tuning file load\n");
  3763. filp_close(filp, current->files);
  3764. goto err;
  3765. }
  3766. pos = 0;
  3767. memset(dp, 0, l);
  3768. pr_info("%s before vfs_read()\n", __func__);
  3769. ret = vfs_read(filp, (char __user *)dp, l, &pos);
  3770. pr_info("%s after vfs_read()\n", __func__);
  3771. if (ret != l) {
  3772. pr_info("vfs_read() filed ret : %d\n", ret);
  3773. kfree(dp);
  3774. filp_close(filp, current->files);
  3775. goto err;
  3776. }
  3777. filp_close(filp, current->files);
  3778. set_fs(fs);
  3779. sending_tune_cmd(dp, l);
  3780. kfree(dp);
  3781. return;
  3782. err:
  3783. set_fs(fs);
  3784. }
  3785. static ssize_t tuning_show(struct device *dev,
  3786. struct device_attribute *attr, char *buf)
  3787. {
  3788. int ret = 0;
  3789. ret = snprintf(buf, MAX_FILE_NAME, "Tunned File Name : %s\n",
  3790. tuning_file);
  3791. return ret;
  3792. }
  3793. static ssize_t tuning_store(struct device *dev,
  3794. struct device_attribute *attr, const char *buf,
  3795. size_t size)
  3796. {
  3797. char *pt;
  3798. memset(tuning_file, 0, sizeof(tuning_file));
  3799. snprintf(tuning_file, MAX_FILE_NAME, "%s%s", TUNING_FILE_PATH, buf);
  3800. pt = tuning_file;
  3801. while (*pt) {
  3802. if (*pt == '\r' || *pt == '\n') {
  3803. *pt = 0;
  3804. break;
  3805. }
  3806. pt++;
  3807. }
  3808. pr_info("%s:%s\n", __func__, tuning_file);
  3809. load_tuning_file(tuning_file);
  3810. return size;
  3811. }
  3812. static DEVICE_ATTR(tuning, 0664, tuning_show, tuning_store);
  3813. #endif
  3814. static int samsung_dsi_panel_event_handler(int event)
  3815. {
  3816. pr_debug("SS DSI Event Handler");
  3817. switch (event) {
  3818. case MDSS_EVENT_FRAME_UPDATE:
  3819. if(msd.dstat.wait_disp_on) {
  3820. mipi_samsung_disp_send_cmd(PANEL_DISPLAY_ON, true);
  3821. msd.dstat.wait_disp_on = 0;
  3822. }
  3823. break;
  3824. #if defined(CONFIG_MDNIE_LITE_TUNING) \
  3825. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL)
  3826. case MDSS_EVENT_MDNIE_DEFAULT_UPDATE:
  3827. is_negative_on();
  3828. break;
  3829. #endif
  3830. default:
  3831. pr_err("%s : unknown event \n", __func__);
  3832. break;
  3833. }
  3834. return 0;
  3835. }
  3836. static int mdss_dsi_panel_blank(struct mdss_panel_data *pdata, int blank)
  3837. {
  3838. if(blank) {
  3839. pr_debug("%s:%d, blanking panel\n", __func__, __LINE__);
  3840. mipi_samsung_disp_send_cmd(PANEL_DISPLAY_BLANK, false);
  3841. }
  3842. else {
  3843. pr_debug("%s:%d, unblanking panel\n", __func__, __LINE__);
  3844. mipi_samsung_disp_send_cmd(PANEL_DISPLAY_UNBLANK, false);
  3845. }
  3846. return 0;
  3847. }
  3848. #if defined(CONFIG_LCD_CLASS_DEVICE)
  3849. static struct attribute *panel_sysfs_attributes[] = {
  3850. &dev_attr_lcd_power.attr,
  3851. &dev_attr_lcd_type.attr,
  3852. &dev_attr_window_type.attr,
  3853. &dev_attr_power_reduce.attr,
  3854. &dev_attr_siop_enable.attr,
  3855. #if defined(TEMPERATURE_ELVSS) || defined(TEMPERATURE_ELVSS_S6E3FA0) || defined(TEMPERATURE_ELVSS_S6E8AA4)
  3856. &dev_attr_temperature.attr,
  3857. #endif
  3858. #if defined(PARTIAL_UPDATE)
  3859. &dev_attr_partial_disp.attr,
  3860. #endif
  3861. #if defined(FORCE_500CD)
  3862. &dev_attr_force_500cd.attr,
  3863. #endif
  3864. #if defined(octa_manufacture_date)
  3865. &dev_attr_manufacture_date.attr,
  3866. #endif
  3867. NULL
  3868. };
  3869. static const struct attribute_group panel_sysfs_group = {
  3870. .attrs = panel_sysfs_attributes,
  3871. };
  3872. #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
  3873. static struct attribute *bl_sysfs_attributes[] = {
  3874. &dev_attr_auto_brightness.attr,
  3875. &dev_attr_backlight.attr,
  3876. NULL
  3877. };
  3878. static const struct attribute_group bl_sysfs_group = {
  3879. .attrs = bl_sysfs_attributes,
  3880. };
  3881. #endif
  3882. #endif
  3883. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  3884. static irqreturn_t err_fg_irq_handler(int irq, void *handle)
  3885. {
  3886. pr_info("%s handler start irq=%d", __func__, irq);
  3887. if(err_fg_working) return IRQ_HANDLED;
  3888. err_fg_working = 1;
  3889. disable_irq_nosync(gpio_to_irq(err_fg_gpio));
  3890. schedule_work(&err_fg_work);
  3891. pr_info("%s : handler end", __func__);
  3892. return IRQ_HANDLED;
  3893. }
  3894. static void err_fg_work_func(struct work_struct *work)
  3895. {
  3896. struct msm_fb_data_type *mfd = msd.mfd;
  3897. pr_info("%s : start", __func__);
  3898. if (mfd->panel_power_on) {
  3899. int bl_backup = msd.dstat.bright_level;
  3900. mutex_lock(&mfd->power_state);
  3901. mutex_lock(&mfd->ctx_lock);
  3902. msd.pdata->event_handler(msd.pdata, MDSS_EVENT_BLANK, NULL);
  3903. msd.pdata->event_handler(msd.pdata, MDSS_EVENT_PANEL_OFF, NULL);
  3904. mdelay(20);
  3905. msd.pdata->event_handler(msd.pdata, MDSS_EVENT_UNBLANK, NULL);
  3906. msd.pdata->event_handler(msd.pdata, MDSS_EVENT_PANEL_ON, NULL);
  3907. mutex_unlock(&mfd->ctx_lock);
  3908. mutex_unlock(&mfd->power_state);
  3909. /* Restore brightness */
  3910. msd.dstat.bright_level = bl_backup;
  3911. mipi_samsung_disp_send_cmd(PANEL_BRIGHT_CTRL, true);
  3912. }
  3913. esd_count++;
  3914. err_fg_working = 0;
  3915. pr_info("%s end", __func__);
  3916. return;
  3917. }
  3918. #ifdef ESD_DEBUG
  3919. static ssize_t mipi_samsung_esd_check_show(struct device *dev,
  3920. struct device_attribute *attr, char *buf)
  3921. {
  3922. int rc;
  3923. rc = snprintf((char *)buf, 20, "esd count %d\n", esd_count);
  3924. return rc;
  3925. }
  3926. static ssize_t mipi_samsung_esd_check_store(struct device *dev,
  3927. struct device_attribute *attr, const char *buf, size_t size)
  3928. {
  3929. struct msm_fb_data_type *mfd = msd.mfd;
  3930. err_fg_irq_handler(0, mfd);
  3931. return 1;
  3932. }
  3933. static DEVICE_ATTR(esd_check, S_IRUGO , mipi_samsung_esd_check_show,\
  3934. mipi_samsung_esd_check_store);
  3935. #endif
  3936. #endif
  3937. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  3938. static irqreturn_t lcd_crack_irq_handler(int irq, void *handle)
  3939. {
  3940. pr_info("%s handler start irq=%d", __func__, irq);
  3941. if(lcd_crack_rec_working) return IRQ_HANDLED;
  3942. lcd_crack_rec_working = 1;
  3943. disable_irq_nosync(gpio_to_irq(lcd_crack_gpio));
  3944. schedule_work(&lcd_crack_rec_work);
  3945. pr_info("%s : handler end", __func__);
  3946. return IRQ_HANDLED;
  3947. }
  3948. static void lcd_crack_rec_work_func(struct work_struct *work)
  3949. {
  3950. pr_info("%s : start", __func__);
  3951. mipi_samsung_disp_send_cmd(PANEL_CRACK_RECOVERY, true);
  3952. lcd_crack_rec_working = 0;
  3953. pr_info("%s end", __func__);
  3954. return;
  3955. }
  3956. static ssize_t mipi_samsung_lcd_crack_det_show(struct device *dev,
  3957. struct device_attribute *attr, char *buf)
  3958. {
  3959. int rc;
  3960. rc = snprintf((char *)buf, 20, " lcd_crack_detect_show \n");
  3961. return rc;
  3962. }
  3963. static ssize_t mipi_samsung_lcd_crack_det_store(struct device *dev,
  3964. struct device_attribute *attr, const char *buf, size_t size)
  3965. {
  3966. struct msm_fb_data_type *mfd = msd.mfd;
  3967. lcd_crack_irq_handler(0, mfd);
  3968. printk("%s: ********** inside ********\n",__func__);
  3969. return size;
  3970. }
  3971. static DEVICE_ATTR(lcd_crack_check, S_IRUGO , mipi_samsung_lcd_crack_det_show,\
  3972. mipi_samsung_lcd_crack_det_store);
  3973. #endif
  3974. int mdss_dsi_panel_init(struct device_node *node, struct mdss_dsi_ctrl_pdata *ctrl_pdata,
  3975. bool cmd_cfg_conf_splash)
  3976. {
  3977. int rc = 0;
  3978. static const char *panel_name;
  3979. bool cont_splash_enabled = false;
  3980. #if defined(CONFIG_LCD_CLASS_DEVICE)
  3981. struct lcd_device *lcd_device;
  3982. #endif
  3983. #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
  3984. struct backlight_device *bd = NULL;
  3985. #endif
  3986. pr_debug("%s:%d", __func__, __LINE__);
  3987. if (!node)
  3988. return -ENODEV;
  3989. panel_name = of_get_property(node, "label", NULL);
  3990. if (!panel_name)
  3991. pr_info("%s:%d, panel name not specified\n",
  3992. __func__, __LINE__);
  3993. else
  3994. pr_info("%s: Panel Name = %s\n", __func__, panel_name);
  3995. if(is_panel_supported(panel_name)) {
  3996. LCD_DEBUG("Panel : %s is not supported:",panel_name);
  3997. return -1;
  3998. }
  3999. rc = mdss_panel_parse_dt(node, ctrl_pdata);
  4000. if (rc)
  4001. return rc;
  4002. ctrl_pdata->on = mdss_dsi_panel_on;
  4003. ctrl_pdata->off = mdss_dsi_panel_off;
  4004. ctrl_pdata->bl_fnc = mdss_dsi_panel_bl_ctrl;
  4005. ctrl_pdata->panel_reset = mdss_dsi_samsung_panel_reset;
  4006. ctrl_pdata->registered = mdss_dsi_panel_registered;
  4007. ctrl_pdata->dimming_init = mdss_dsi_panel_dimming_init;
  4008. ctrl_pdata->event_handler = samsung_dsi_panel_event_handler;
  4009. ctrl_pdata->panel_blank = mdss_dsi_panel_blank;
  4010. ctrl_pdata->panel_data.set_backlight = mdss_dsi_panel_bl_ctrl;
  4011. /* Init driver specific data */
  4012. mutex_init(&msd.lock);
  4013. msd.dstat.on = 0;
  4014. msd.dstat.recent_bright_level = 255;
  4015. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)\
  4016. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  4017. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  4018. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  4019. if (cmd_cfg_conf_splash)
  4020. cont_splash_enabled = of_property_read_bool(node,
  4021. "qcom,cont-splash-enabled");
  4022. else
  4023. cont_splash_enabled = false;
  4024. #else
  4025. cont_splash_enabled = of_property_read_bool(node,
  4026. "qcom,cont-splash-enabled");
  4027. #endif
  4028. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL) \
  4029. || defined(CONFIG_FB_MSM_MIPI_S6E8AA0A_720P_PT_PANEL) \
  4030. || defined(CONFIG_FB_MSM_MIPI_S6E88A0_QHD_VIDEO_PT_PANEL) \
  4031. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  4032. cont_splash_enabled = of_property_read_bool(node,
  4033. "qcom,cont-splash-enabled");
  4034. #endif
  4035. if (get_lcd_attached() == 0)
  4036. cont_splash_enabled = 0;
  4037. if (!cont_splash_enabled) {
  4038. pr_info("%s:%d Continuous splash flag not found.\n",
  4039. __func__, __LINE__);
  4040. ctrl_pdata->panel_data.panel_info.cont_splash_enabled = 0;
  4041. } else {
  4042. pr_info("%s:%d Continuous splash flag enabled.\n",
  4043. __func__, __LINE__);
  4044. ctrl_pdata->panel_data.panel_info.cont_splash_enabled = 1;
  4045. }
  4046. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  4047. if(err_fg_enable)
  4048. {
  4049. INIT_WORK(&err_fg_work, err_fg_work_func);
  4050. rc = request_threaded_irq(gpio_to_irq(err_fg_gpio),
  4051. NULL, err_fg_irq_handler, IRQF_TRIGGER_RISING | IRQF_ONESHOT, "esd_detect", NULL);
  4052. if (rc) {
  4053. pr_err("%s : Failed to request_irq.:ret=%d", __func__, rc);
  4054. }
  4055. disable_irq(gpio_to_irq(err_fg_gpio));
  4056. }
  4057. #endif
  4058. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  4059. if(lcd_crack_rec_enable)
  4060. {
  4061. INIT_WORK(&lcd_crack_rec_work, lcd_crack_rec_work_func);
  4062. rc = request_threaded_irq(gpio_to_irq(lcd_crack_gpio),
  4063. NULL, lcd_crack_irq_handler, IRQF_TRIGGER_RISING | IRQF_ONESHOT, "lcd_crack_detect", NULL);
  4064. if (rc) {
  4065. pr_err("%s : Failed to request_irq.:ret=%d", __func__, rc);
  4066. }
  4067. disable_irq(gpio_to_irq(lcd_crack_gpio));
  4068. }
  4069. #endif
  4070. #if defined(CONFIG_LCD_CLASS_DEVICE)
  4071. lcd_device = lcd_device_register("panel", NULL, NULL,
  4072. &mipi_samsung_disp_props);
  4073. if (IS_ERR(lcd_device)) {
  4074. rc = PTR_ERR(lcd_device);
  4075. printk(KERN_ERR "lcd : failed to register device\n");
  4076. return rc;
  4077. }
  4078. sysfs_remove_file(&lcd_device->dev.kobj,
  4079. &dev_attr_lcd_power.attr);
  4080. rc = sysfs_create_group(&lcd_device->dev.kobj, &panel_sysfs_group);
  4081. if (rc) {
  4082. pr_err("Failed to create panel sysfs group..\n");
  4083. sysfs_remove_group(&lcd_device->dev.kobj, &panel_sysfs_group);
  4084. }
  4085. #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
  4086. bd = backlight_device_register("panel", &lcd_device->dev,
  4087. NULL, NULL, NULL);
  4088. if (IS_ERR(bd)) {
  4089. rc = PTR_ERR(bd);
  4090. pr_info("backlight : failed to register device\n");
  4091. return rc;
  4092. }
  4093. rc = sysfs_create_group(&bd->dev.kobj, &bl_sysfs_group);
  4094. if (rc) {
  4095. pr_err("Failed to create backlight sysfs group..\n");
  4096. sysfs_remove_group(&bd->dev.kobj, &bl_sysfs_group);
  4097. }
  4098. #endif
  4099. #endif
  4100. #if defined(CONFIG_ESD_ERR_FG_RECOVERY)
  4101. #ifdef ESD_DEBUG
  4102. rc= sysfs_create_file(&lcd_device->dev.kobj,
  4103. &dev_attr_esd_check.attr);
  4104. if (rc) {
  4105. pr_info("sysfs create fail-%s\n",
  4106. dev_attr_esd_check.attr.name);
  4107. }
  4108. #endif
  4109. #endif
  4110. #if defined(CONFIG_LCD_CRACK_RECOVERY)
  4111. rc= sysfs_create_file(&lcd_device->dev.kobj,
  4112. &dev_attr_lcd_crack_check.attr);
  4113. if (rc) {
  4114. pr_info("sysfs create fail-%s\n",
  4115. dev_attr_lcd_crack_check.attr.name);
  4116. }
  4117. #endif
  4118. #if defined(CONFIG_MDNIE_LITE_TUNING)
  4119. pr_info("[%s] CONFIG_MDNIE_LITE_TUNING ok ! init class called!\n",
  4120. __func__);
  4121. init_mdnie_class();
  4122. #endif
  4123. #if defined(DDI_VIDEO_ENHANCE_TUNING)
  4124. rc = sysfs_create_file(&lcd_device->dev.kobj,
  4125. &dev_attr_tuning.attr);
  4126. if (rc) {
  4127. pr_info("sysfs create fail-%s\n",
  4128. dev_attr_tuning.attr.name);
  4129. }
  4130. #endif
  4131. #if defined(CONFIG_HAS_EARLYSUSPEND)
  4132. msd.early_suspend.suspend = mipi_samsung_disp_early_suspend;
  4133. msd.early_suspend.resume = mipi_samsung_disp_late_resume;
  4134. msd.early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN-1;
  4135. register_early_suspend(&msd.early_suspend);
  4136. #endif
  4137. /*
  4138. * unless panel is powered on don't set the state to true
  4139. * This is to handle cases like cont splash or lpm in which panel
  4140. * will be powered on later on.
  4141. */
  4142. msd.dstat.on = 0;
  4143. return 0;
  4144. }
  4145. int get_samsung_lcd_attached(void)
  4146. {
  4147. return lcd_attached;
  4148. }
  4149. EXPORT_SYMBOL(get_samsung_lcd_attached);
  4150. static int __init get_lcd_id_cmdline(char *mode)
  4151. {
  4152. char *pt;
  4153. lcd_id = 0;
  4154. if( mode == NULL ) return 1;
  4155. for( pt = mode; *pt != 0; pt++ )
  4156. {
  4157. lcd_id <<= 4;
  4158. switch(*pt)
  4159. {
  4160. case '0' ... '9' :
  4161. lcd_id += *pt -'0';
  4162. break;
  4163. case 'a' ... 'f' :
  4164. lcd_id += 10 + *pt -'a';
  4165. break;
  4166. case 'A' ... 'F' :
  4167. lcd_id += 10 + *pt -'A';
  4168. break;
  4169. }
  4170. }
  4171. lcd_attached = ((lcd_id&0xFFFFFF)!=0x000000);
  4172. #if defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  4173. if(get_oled_id()==0) // magna only
  4174. msd.manufacture_id = lcd_id;
  4175. #endif
  4176. pr_info( "%s: LCD_ID = 0x%X, lcd_attached =%d", __func__,lcd_id, lcd_attached);
  4177. return 0;
  4178. }
  4179. __setup( "lcd_id=0x", get_lcd_id_cmdline );
  4180. #if defined(CONFIG_DUAL_LCD)
  4181. static int __init lcd_sel_status(char *mode)
  4182. {
  4183. msd.dstat.lcd_sel = simple_strtol(mode, NULL, 10);
  4184. LCD_DEBUG("lcd_sel=%d", msd.dstat.lcd_sel);
  4185. return 1;
  4186. }
  4187. __setup("lcd_sel=", lcd_sel_status);
  4188. #endif
  4189. #if (defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  4190. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061))\
  4191. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  4192. int get_oled_id(void)
  4193. {
  4194. /*
  4195. id3 7bit : 0 -> magna(EA8061), 1-> lsi(S6EAA4)
  4196. */
  4197. if(lcd_id&0x00080) return 1;
  4198. return 0;
  4199. }
  4200. EXPORT_SYMBOL(get_oled_id);
  4201. static int __init get_oled_id_cmdline(char *mode)
  4202. {
  4203. /*
  4204. oled id : msm gpio 91
  4205. 1: s.lsi
  4206. 0: magna
  4207. */
  4208. fresco_oled_id = simple_strtol(mode, NULL, 10);
  4209. LCD_DEBUG("oled_id=%d", fresco_oled_id);
  4210. return 1;
  4211. }
  4212. __setup("oled_id=", get_oled_id_cmdline);
  4213. #endif
  4214. static int __init mdss_panel_current_hw_rev(char *rev)
  4215. {
  4216. /*
  4217. * 1 is recovery booting
  4218. * 0 is normal booting
  4219. */
  4220. board_rev = atoi(rev);
  4221. pr_info("%s : %d", __func__, board_rev);
  4222. return 1;
  4223. }
  4224. __setup("samsung.board_rev=", mdss_panel_current_hw_rev);
  4225. MODULE_DESCRIPTION("Samsung DSI panel driver");
  4226. MODULE_AUTHOR("Krishna Kishor Jha <krishna.jha@samsung.com>");
  4227. MODULE_LICENSE("GPL");