smart_mtp_ea8064.c 170 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886
  1. /*
  2. * =================================================================
  3. *
  4. * Filename: smart_mtp_s6e3.c
  5. *
  6. * Description: Smart dimming algorithm implementation
  7. *
  8. * Company: Samsung Electronics
  9. *
  10. * model: K LTE
  11. * ================================================================
  12. */
  13. /*
  14. <one line to give the program's name and a brief idea of what it does.>
  15. Copyright (C) 2012, Samsung Electronics. All rights reserved.
  16. *
  17. * This program is free software; you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License version 2 and
  19. * only version 2 as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  29. * 02110-1301, USA.
  30. *
  31. */
  32. #include "smart_mtp_ea8064.h"
  33. #include "smart_mtp_2p2_gamma.h"
  34. #include "smart_dimming.h"
  35. static struct SMART_DIM smart_S6E3;
  36. static struct smartdim_conf __S6E3__ ;
  37. #if defined(CONFIG_LCD_HMT)
  38. static struct SMART_DIM smart_S6E3_hmt;
  39. static struct smartdim_conf_hmt __S6E3_HMT__;
  40. static struct SMART_DIM smart_S6E3_hmt_single;
  41. static struct smartdim_conf_hmt __S6E3_HMT_S__;
  42. #endif
  43. /*#define SMART_DIMMING_DEBUG*/
  44. static char max_lux_table[GAMMA_SET_MAX];
  45. static char min_lux_table[GAMMA_SET_MAX];
  46. static int *temp_candela_coeff;
  47. /*
  48. * To support different center cell gamma setting
  49. */
  50. static char V255_300CD_R_MSB;
  51. static char V255_300CD_R_LSB;
  52. static char V255_300CD_G_MSB;
  53. static char V255_300CD_G_LSB;
  54. static char V255_300CD_B_MSB;
  55. static char V255_300CD_B_LSB;
  56. static char V203_300CD_R;
  57. static char V203_300CD_G;
  58. static char V203_300CD_B;
  59. static char V151_300CD_R;
  60. static char V151_300CD_G;
  61. static char V151_300CD_B;
  62. static char V87_300CD_R;
  63. static char V87_300CD_G;
  64. static char V87_300CD_B;
  65. static char V51_300CD_R;
  66. static char V51_300CD_G;
  67. static char V51_300CD_B;
  68. static char V35_300CD_R;
  69. static char V35_300CD_G;
  70. static char V35_300CD_B;
  71. static char V23_300CD_R;
  72. static char V23_300CD_G;
  73. static char V23_300CD_B;
  74. static char V11_300CD_R;
  75. static char V11_300CD_G;
  76. static char V11_300CD_B;
  77. static char V3_300CD_R;
  78. static char V3_300CD_G;
  79. static char V3_300CD_B;
  80. static char VT_300CD_R;
  81. static char VT_300CD_G;
  82. static char VT_300CD_B;
  83. static int char_to_int(char data1)
  84. {
  85. int cal_data;
  86. if (data1 & 0x80) {
  87. cal_data = data1 & 0x7F;
  88. cal_data *= -1;
  89. } else
  90. cal_data = data1;
  91. return cal_data;
  92. }
  93. static int char_to_int_v255(char data1, char data2)
  94. {
  95. int cal_data;
  96. if (data1)
  97. cal_data = data2 * -1;
  98. else
  99. cal_data = data2;
  100. return cal_data;
  101. }
  102. void print_RGB_offset(struct SMART_DIM *pSmart)
  103. {
  104. pr_info("%s MTP Offset VT R:%d G:%d B:%d\n", __func__,
  105. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1),
  106. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1),
  107. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1));
  108. pr_info("%s MTP Offset V3 R:%d G:%d B:%d\n", __func__,
  109. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3),
  110. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3),
  111. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3));
  112. pr_info("%s MTP Offset V11 R:%d G:%d B:%d\n", __func__,
  113. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11),
  114. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11),
  115. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11));
  116. pr_info("%s MTP Offset V23 R:%d G:%d B:%d\n", __func__,
  117. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23),
  118. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23),
  119. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23));
  120. pr_info("%s MTP Offset V35 R:%d G:%d B:%d\n", __func__,
  121. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35),
  122. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35),
  123. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35));
  124. pr_info("%s MTP Offset V51 R:%d G:%d B:%d\n", __func__,
  125. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51),
  126. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51),
  127. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51));
  128. pr_info("%s MTP Offset V87 R:%d G:%d B:%d\n", __func__,
  129. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87),
  130. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87),
  131. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87));
  132. pr_info("%s MTP Offset V151 R:%d G:%d B:%d\n", __func__,
  133. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151),
  134. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151),
  135. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151));
  136. pr_info("%s MTP Offset V203 R:%d G:%d B:%d\n", __func__,
  137. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203),
  138. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203),
  139. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203));
  140. pr_info("%s MTP Offset V255 R:%d G:%d B:%d\n", __func__,
  141. char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  142. pSmart->MTP.R_OFFSET.OFFSET_255_LSB),
  143. char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  144. pSmart->MTP.G_OFFSET.OFFSET_255_LSB),
  145. char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  146. pSmart->MTP.B_OFFSET.OFFSET_255_LSB));
  147. }
  148. void print_lux_table(struct SMART_DIM *psmart)
  149. {
  150. int lux_loop;
  151. int cnt;
  152. char pBuffer[256];
  153. memset(pBuffer, 0x00, 256);
  154. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  155. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  156. snprintf(pBuffer + strnlen(pBuffer, 256), 256, " %d",
  157. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  158. pr_info("lux : %3d %s", psmart->plux_table[lux_loop], pBuffer);
  159. memset(pBuffer, 0x00, 256);
  160. }
  161. }
  162. void print_aid_log(void)
  163. {
  164. print_RGB_offset(&smart_S6E3);
  165. print_lux_table(&smart_S6E3);
  166. }
  167. #if defined(CONFIG_LCD_HMT)
  168. void print_aid_log_hmt(void)
  169. {
  170. pr_info("== DUAL SCAN ==\n");
  171. print_RGB_offset(&smart_S6E3_hmt);
  172. print_lux_table(&smart_S6E3_hmt);
  173. pr_info("\n");
  174. pr_info("== SINGLE SCAN ==\n");
  175. print_RGB_offset(&smart_S6E3_hmt_single);
  176. print_lux_table(&smart_S6E3_hmt_single);
  177. pr_info("\n");
  178. }
  179. #endif
  180. #define v255_coefficient 72
  181. #define v255_denominator 860
  182. static int v255_adjustment(struct SMART_DIM *pSmart)
  183. {
  184. unsigned long long result_1, result_2, result_3, result_4;
  185. int add_mtp;
  186. int LSB;
  187. int v255_value;
  188. v255_value = (V255_300CD_R_MSB << 8) | (V255_300CD_R_LSB);
  189. LSB = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  190. pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
  191. add_mtp = LSB + v255_value;
  192. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  193. do_div(result_2, v255_denominator);
  194. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  195. result_4 = pSmart->vregout_voltage - result_3;
  196. pSmart->RGB_OUTPUT.R_VOLTAGE.level_255 = result_4;
  197. pSmart->RGB_OUTPUT.R_VOLTAGE.level_0 = pSmart->vregout_voltage;
  198. v255_value = (V255_300CD_G_MSB << 8) | (V255_300CD_G_LSB);
  199. LSB = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  200. pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
  201. add_mtp = LSB + v255_value;
  202. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  203. do_div(result_2, v255_denominator);
  204. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  205. result_4 = pSmart->vregout_voltage - result_3;
  206. pSmart->RGB_OUTPUT.G_VOLTAGE.level_255 = result_4;
  207. pSmart->RGB_OUTPUT.G_VOLTAGE.level_0 = pSmart->vregout_voltage;
  208. v255_value = (V255_300CD_B_MSB << 8) | (V255_300CD_B_LSB);
  209. LSB = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  210. pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
  211. add_mtp = LSB + v255_value;
  212. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  213. do_div(result_2, v255_denominator);
  214. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  215. result_4 = pSmart->vregout_voltage - result_3;
  216. pSmart->RGB_OUTPUT.B_VOLTAGE.level_255 = result_4;
  217. pSmart->RGB_OUTPUT.B_VOLTAGE.level_0 = pSmart->vregout_voltage;
  218. #ifdef SMART_DIMMING_DEBUG
  219. pr_info("%s V255 RED:%d GREEN:%d BLUE:%d\n", __func__,
  220. pSmart->RGB_OUTPUT.R_VOLTAGE.level_255,
  221. pSmart->RGB_OUTPUT.G_VOLTAGE.level_255,
  222. pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
  223. #endif
  224. return 0;
  225. }
  226. static void v255_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  227. {
  228. unsigned long long result_1, result_2, result_3;
  229. result_1 = pSmart->vregout_voltage -
  230. (pSmart->GRAY.TABLE[index[V255_INDEX]].R_Gray);
  231. result_2 = result_1 * v255_denominator;
  232. do_div(result_2, pSmart->vregout_voltage);
  233. result_3 = result_2 - v255_coefficient;
  234. str[0] = (result_3 & 0xff00) >> 8;
  235. str[1] = result_3 & 0xff;
  236. result_1 = pSmart->vregout_voltage -
  237. (pSmart->GRAY.TABLE[index[V255_INDEX]].G_Gray);
  238. result_2 = result_1 * v255_denominator;
  239. do_div(result_2, pSmart->vregout_voltage);
  240. result_3 = result_2 - v255_coefficient;
  241. str[2] = (result_3 & 0xff00) >> 8;
  242. str[3] = result_3 & 0xff;
  243. result_1 = pSmart->vregout_voltage -
  244. (pSmart->GRAY.TABLE[index[V255_INDEX]].B_Gray);
  245. result_2 = result_1 * v255_denominator;
  246. do_div(result_2, pSmart->vregout_voltage);
  247. result_3 = result_2 - v255_coefficient;
  248. str[4] = (result_3 & 0xff00) >> 8;
  249. str[5] = result_3 & 0xff;
  250. }
  251. static int vt_coefficient[] = {
  252. 0, 12, 24, 36, 48,
  253. 60, 72, 84, 96, 108,
  254. 138, 148, 158, 168,
  255. 178, 186,
  256. };
  257. #define vt_denominator 860
  258. static int vt_adjustment(struct SMART_DIM *pSmart)
  259. {
  260. unsigned long long result_1, result_2, result_3, result_4;
  261. int add_mtp;
  262. int LSB;
  263. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1);
  264. add_mtp = LSB + VT_300CD_R;
  265. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  266. do_div(result_2, vt_denominator);
  267. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  268. result_4 = pSmart->vregout_voltage - result_3;
  269. pSmart->GRAY.VT_TABLE.R_Gray = result_4;
  270. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1);
  271. add_mtp = LSB + VT_300CD_G;
  272. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  273. do_div(result_2, vt_denominator);
  274. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  275. result_4 = pSmart->vregout_voltage - result_3;
  276. pSmart->GRAY.VT_TABLE.G_Gray = result_4;
  277. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1);
  278. add_mtp = LSB + VT_300CD_B;
  279. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  280. do_div(result_2, vt_denominator);
  281. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  282. result_4 = pSmart->vregout_voltage - result_3;
  283. pSmart->GRAY.VT_TABLE.B_Gray = result_4;
  284. #ifdef SMART_DIMMING_DEBUG
  285. pr_info("%s VT RED:%d GREEN:%d BLUE:%d\n", __func__,
  286. pSmart->GRAY.VT_TABLE.R_Gray,
  287. pSmart->GRAY.VT_TABLE.G_Gray,
  288. pSmart->GRAY.VT_TABLE.B_Gray);
  289. #endif
  290. return 0;
  291. }
  292. static void vt_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  293. {
  294. str[30] = VT_300CD_R;
  295. str[31] = VT_300CD_G;
  296. str[32] = VT_300CD_B;
  297. }
  298. #define v203_coefficient 64
  299. #define v203_denominator 320
  300. static int v203_adjustment(struct SMART_DIM *pSmart)
  301. {
  302. unsigned long long result_1, result_2, result_3, result_4;
  303. int add_mtp;
  304. int LSB;
  305. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203);
  306. add_mtp = LSB + V203_300CD_R;
  307. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  308. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_255);
  309. result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
  310. do_div(result_2, v203_denominator);
  311. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  312. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  313. pSmart->RGB_OUTPUT.R_VOLTAGE.level_203 = result_4;
  314. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203);
  315. add_mtp = LSB + V203_300CD_G;
  316. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  317. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_255);
  318. result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
  319. do_div(result_2, v203_denominator);
  320. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  321. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  322. pSmart->RGB_OUTPUT.G_VOLTAGE.level_203 = result_4;
  323. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203);
  324. add_mtp = LSB + V203_300CD_B;
  325. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  326. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
  327. result_2 = (v203_coefficient+add_mtp) << BIT_SHIFT;
  328. do_div(result_2, v203_denominator);
  329. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  330. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  331. pSmart->RGB_OUTPUT.B_VOLTAGE.level_203 = result_4;
  332. #ifdef SMART_DIMMING_DEBUG
  333. pr_info("%s V203 RED:%d GREEN:%d BLUE:%d\n", __func__,
  334. pSmart->RGB_OUTPUT.R_VOLTAGE.level_203,
  335. pSmart->RGB_OUTPUT.G_VOLTAGE.level_203,
  336. pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
  337. #endif
  338. return 0;
  339. }
  340. static void v203_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  341. {
  342. unsigned long long result_1, result_2, result_3;
  343. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  344. - (pSmart->GRAY.TABLE[index[V203_INDEX]].R_Gray);
  345. result_2 = result_1 * v203_denominator;
  346. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  347. - (pSmart->GRAY.TABLE[index[V255_INDEX]].R_Gray);
  348. do_div(result_2, result_3);
  349. str[6] = (result_2 - v203_coefficient) & 0xff;
  350. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  351. - (pSmart->GRAY.TABLE[index[V203_INDEX]].G_Gray);
  352. result_2 = result_1 * v203_denominator;
  353. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  354. - (pSmart->GRAY.TABLE[index[V255_INDEX]].G_Gray);
  355. do_div(result_2, result_3);
  356. str[7] = (result_2 - v203_coefficient) & 0xff;
  357. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  358. - (pSmart->GRAY.TABLE[index[V203_INDEX]].B_Gray);
  359. result_2 = result_1 * v203_denominator;
  360. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  361. - (pSmart->GRAY.TABLE[index[V255_INDEX]].B_Gray);
  362. do_div(result_2, result_3);
  363. str[8] = (result_2 - v203_coefficient) & 0xff;
  364. }
  365. #define v151_coefficient 64
  366. #define v151_denominator 320
  367. static int v151_adjustment(struct SMART_DIM *pSmart)
  368. {
  369. unsigned long long result_1, result_2, result_3, result_4;
  370. int add_mtp;
  371. int LSB;
  372. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151);
  373. add_mtp = LSB + V151_300CD_R;
  374. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  375. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_203);
  376. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  377. do_div(result_2, v151_denominator);
  378. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  379. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  380. pSmart->RGB_OUTPUT.R_VOLTAGE.level_151 = result_4;
  381. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151);
  382. add_mtp = LSB + V151_300CD_G;
  383. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  384. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_203);
  385. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  386. do_div(result_2, v151_denominator);
  387. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  388. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  389. pSmart->RGB_OUTPUT.G_VOLTAGE.level_151 = result_4;
  390. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151);
  391. add_mtp = LSB + V151_300CD_B;
  392. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  393. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
  394. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  395. do_div(result_2, v151_denominator);
  396. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  397. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  398. pSmart->RGB_OUTPUT.B_VOLTAGE.level_151 = result_4;
  399. #ifdef SMART_DIMMING_DEBUG
  400. pr_info("%s V151 RED:%d GREEN:%d BLUE:%d\n", __func__,
  401. pSmart->RGB_OUTPUT.R_VOLTAGE.level_151,
  402. pSmart->RGB_OUTPUT.G_VOLTAGE.level_151,
  403. pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
  404. #endif
  405. return 0;
  406. }
  407. static void v151_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  408. {
  409. unsigned long long result_1, result_2, result_3;
  410. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  411. - (pSmart->GRAY.TABLE[index[V151_INDEX]].R_Gray);
  412. result_2 = result_1 * v151_denominator;
  413. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  414. - (pSmart->GRAY.TABLE[index[V203_INDEX]].R_Gray);
  415. do_div(result_2, result_3);
  416. str[9] = (result_2 - v151_coefficient) & 0xff;
  417. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  418. - (pSmart->GRAY.TABLE[index[V151_INDEX]].G_Gray);
  419. result_2 = result_1 * v151_denominator;
  420. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  421. - (pSmart->GRAY.TABLE[index[V203_INDEX]].G_Gray);
  422. do_div(result_2, result_3);
  423. str[10] = (result_2 - v151_coefficient) & 0xff;
  424. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  425. - (pSmart->GRAY.TABLE[index[V151_INDEX]].B_Gray);
  426. result_2 = result_1 * v151_denominator;
  427. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  428. - (pSmart->GRAY.TABLE[index[V203_INDEX]].B_Gray);
  429. do_div(result_2, result_3);
  430. str[11] = (result_2 - v151_coefficient) & 0xff;
  431. }
  432. #define v87_coefficient 64
  433. #define v87_denominator 320
  434. static int v87_adjustment(struct SMART_DIM *pSmart)
  435. {
  436. unsigned long long result_1, result_2, result_3, result_4;
  437. int add_mtp;
  438. int LSB;
  439. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87);
  440. add_mtp = LSB + V87_300CD_R;
  441. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  442. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_151);
  443. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  444. do_div(result_2, v87_denominator);
  445. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  446. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  447. pSmart->RGB_OUTPUT.R_VOLTAGE.level_87 = result_4;
  448. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87);
  449. add_mtp = LSB + V87_300CD_G;
  450. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  451. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_151);
  452. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  453. do_div(result_2, v87_denominator);
  454. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  455. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  456. pSmart->RGB_OUTPUT.G_VOLTAGE.level_87 = result_4;
  457. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87);
  458. add_mtp = LSB + V87_300CD_B;
  459. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  460. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
  461. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  462. do_div(result_2, v87_denominator);
  463. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  464. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  465. pSmart->RGB_OUTPUT.B_VOLTAGE.level_87 = result_4;
  466. #ifdef SMART_DIMMING_DEBUG
  467. pr_info("%s V87 RED:%d GREEN:%d BLUE:%d\n", __func__,
  468. pSmart->RGB_OUTPUT.R_VOLTAGE.level_87,
  469. pSmart->RGB_OUTPUT.G_VOLTAGE.level_87,
  470. pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
  471. #endif
  472. return 0;
  473. }
  474. static void v87_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  475. {
  476. unsigned long long result_1, result_2, result_3;
  477. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  478. - (pSmart->GRAY.TABLE[index[V87_INDEX]].R_Gray);
  479. result_2 = result_1 * v87_denominator;
  480. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  481. - (pSmart->GRAY.TABLE[index[V151_INDEX]].R_Gray);
  482. do_div(result_2, result_3);
  483. str[12] = (result_2 - v87_coefficient) & 0xff;
  484. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  485. - (pSmart->GRAY.TABLE[index[V87_INDEX]].G_Gray);
  486. result_2 = result_1 * v87_denominator;
  487. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  488. - (pSmart->GRAY.TABLE[index[V151_INDEX]].G_Gray);
  489. do_div(result_2, result_3);
  490. str[13] = (result_2 - v87_coefficient) & 0xff;
  491. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  492. - (pSmart->GRAY.TABLE[index[V87_INDEX]].B_Gray);
  493. result_2 = result_1 * v87_denominator;
  494. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  495. - (pSmart->GRAY.TABLE[index[V151_INDEX]].B_Gray);
  496. do_div(result_2, result_3);
  497. str[14] = (result_2 - v87_coefficient) & 0xff;
  498. }
  499. #define v51_coefficient 64
  500. #define v51_denominator 320
  501. static int v51_adjustment(struct SMART_DIM *pSmart)
  502. {
  503. unsigned long long result_1, result_2, result_3, result_4;
  504. int add_mtp;
  505. int LSB;
  506. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51);
  507. add_mtp = LSB + V51_300CD_R;
  508. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  509. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_87);
  510. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  511. do_div(result_2, v51_denominator);
  512. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  513. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  514. pSmart->RGB_OUTPUT.R_VOLTAGE.level_51 = result_4;
  515. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51);
  516. add_mtp = LSB + V51_300CD_G;
  517. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  518. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_87);
  519. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  520. do_div(result_2, v51_denominator);
  521. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  522. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  523. pSmart->RGB_OUTPUT.G_VOLTAGE.level_51 = result_4;
  524. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51);
  525. add_mtp = LSB + V51_300CD_B;
  526. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  527. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
  528. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  529. do_div(result_2, v51_denominator);
  530. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  531. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  532. pSmart->RGB_OUTPUT.B_VOLTAGE.level_51 = result_4;
  533. #ifdef SMART_DIMMING_DEBUG
  534. pr_info("%s V51 RED:%d GREEN:%d BLUE:%d\n", __func__,
  535. pSmart->RGB_OUTPUT.R_VOLTAGE.level_51,
  536. pSmart->RGB_OUTPUT.G_VOLTAGE.level_51,
  537. pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
  538. #endif
  539. return 0;
  540. }
  541. static void v51_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  542. {
  543. unsigned long long result_1, result_2, result_3;
  544. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  545. - (pSmart->GRAY.TABLE[index[V51_INDEX]].R_Gray);
  546. result_2 = result_1 * v51_denominator;
  547. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  548. - (pSmart->GRAY.TABLE[index[V87_INDEX]].R_Gray);
  549. do_div(result_2, result_3);
  550. str[15] = (result_2 - v51_coefficient) & 0xff;
  551. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  552. - (pSmart->GRAY.TABLE[index[V51_INDEX]].G_Gray);
  553. result_2 = result_1 * v51_denominator;
  554. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  555. - (pSmart->GRAY.TABLE[index[V87_INDEX]].G_Gray);
  556. do_div(result_2, result_3);
  557. str[16] = (result_2 - v51_coefficient) & 0xff;
  558. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  559. - (pSmart->GRAY.TABLE[index[V51_INDEX]].B_Gray);
  560. result_2 = result_1 * v51_denominator;
  561. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  562. - (pSmart->GRAY.TABLE[index[V87_INDEX]].B_Gray);
  563. do_div(result_2, result_3);
  564. str[17] = (result_2 - v51_coefficient) & 0xff;
  565. }
  566. #define v35_coefficient 64
  567. #define v35_denominator 320
  568. static int v35_adjustment(struct SMART_DIM *pSmart)
  569. {
  570. unsigned long long result_1, result_2, result_3, result_4;
  571. int add_mtp;
  572. int LSB;
  573. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35);
  574. add_mtp = LSB + V35_300CD_R;
  575. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  576. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_51);
  577. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  578. do_div(result_2, v35_denominator);
  579. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  580. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  581. pSmart->RGB_OUTPUT.R_VOLTAGE.level_35 = result_4;
  582. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35);
  583. add_mtp = LSB + V35_300CD_G;
  584. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  585. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_51);
  586. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  587. do_div(result_2, v35_denominator);
  588. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  589. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  590. pSmart->RGB_OUTPUT.G_VOLTAGE.level_35 = result_4;
  591. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35);
  592. add_mtp = LSB + V35_300CD_B;
  593. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  594. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
  595. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  596. do_div(result_2, v35_denominator);
  597. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  598. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  599. pSmart->RGB_OUTPUT.B_VOLTAGE.level_35 = result_4;
  600. #ifdef SMART_DIMMING_DEBUG
  601. pr_info("%s V35 RED:%d GREEN:%d BLUE:%d\n", __func__,
  602. pSmart->RGB_OUTPUT.R_VOLTAGE.level_35,
  603. pSmart->RGB_OUTPUT.G_VOLTAGE.level_35,
  604. pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
  605. #endif
  606. return 0;
  607. }
  608. static void v35_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  609. {
  610. unsigned long long result_1, result_2, result_3;
  611. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  612. - (pSmart->GRAY.TABLE[index[V35_INDEX]].R_Gray);
  613. result_2 = result_1 * v35_denominator;
  614. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  615. - (pSmart->GRAY.TABLE[index[V51_INDEX]].R_Gray);
  616. do_div(result_2, result_3);
  617. str[18] = (result_2 - v35_coefficient) & 0xff;
  618. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  619. - (pSmart->GRAY.TABLE[index[V35_INDEX]].G_Gray);
  620. result_2 = result_1 * v35_denominator;
  621. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  622. - (pSmart->GRAY.TABLE[index[V51_INDEX]].G_Gray);
  623. do_div(result_2, result_3);
  624. str[19] = (result_2 - v35_coefficient) & 0xff;
  625. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  626. - (pSmart->GRAY.TABLE[index[V35_INDEX]].B_Gray);
  627. result_2 = result_1 * v35_denominator;
  628. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  629. - (pSmart->GRAY.TABLE[index[V51_INDEX]].B_Gray);
  630. do_div(result_2, result_3);
  631. str[20] = (result_2 - v35_coefficient) & 0xff;
  632. }
  633. #define v23_coefficient 64
  634. #define v23_denominator 320
  635. static int v23_adjustment(struct SMART_DIM *pSmart)
  636. {
  637. unsigned long long result_1, result_2, result_3, result_4;
  638. int add_mtp;
  639. int LSB;
  640. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23);
  641. add_mtp = LSB + V23_300CD_R;
  642. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  643. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_35);
  644. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  645. do_div(result_2, v23_denominator);
  646. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  647. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  648. pSmart->RGB_OUTPUT.R_VOLTAGE.level_23 = result_4;
  649. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23);
  650. add_mtp = LSB + V23_300CD_G;
  651. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  652. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_35);
  653. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  654. do_div(result_2, v23_denominator);
  655. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  656. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  657. pSmart->RGB_OUTPUT.G_VOLTAGE.level_23 = result_4;
  658. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23);
  659. add_mtp = LSB + V23_300CD_B;
  660. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  661. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
  662. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  663. do_div(result_2, v23_denominator);
  664. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  665. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  666. pSmart->RGB_OUTPUT.B_VOLTAGE.level_23 = result_4;
  667. #ifdef SMART_DIMMING_DEBUG
  668. pr_info("%s V23 RED:%d GREEN:%d BLUE:%d\n", __func__,
  669. pSmart->RGB_OUTPUT.R_VOLTAGE.level_23,
  670. pSmart->RGB_OUTPUT.G_VOLTAGE.level_23,
  671. pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
  672. #endif
  673. return 0;
  674. }
  675. static void v23_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  676. {
  677. unsigned long long result_1, result_2, result_3;
  678. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  679. - (pSmart->GRAY.TABLE[index[V23_INDEX]].R_Gray);
  680. result_2 = result_1 * v23_denominator;
  681. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  682. - (pSmart->GRAY.TABLE[index[V35_INDEX]].R_Gray);
  683. do_div(result_2, result_3);
  684. str[21] = (result_2 - v23_coefficient) & 0xff;
  685. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  686. - (pSmart->GRAY.TABLE[index[V23_INDEX]].G_Gray);
  687. result_2 = result_1 * v23_denominator;
  688. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  689. - (pSmart->GRAY.TABLE[index[V35_INDEX]].G_Gray);
  690. do_div(result_2, result_3);
  691. str[22] = (result_2 - v23_coefficient) & 0xff;
  692. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  693. - (pSmart->GRAY.TABLE[index[V23_INDEX]].B_Gray);
  694. result_2 = result_1 * v23_denominator;
  695. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  696. - (pSmart->GRAY.TABLE[index[V35_INDEX]].B_Gray);
  697. do_div(result_2, result_3);
  698. str[23] = (result_2 - v23_coefficient) & 0xff;
  699. }
  700. #define v11_coefficient 64
  701. #define v11_denominator 320
  702. static int v11_adjustment(struct SMART_DIM *pSmart)
  703. {
  704. unsigned long long result_1, result_2, result_3, result_4;
  705. int add_mtp;
  706. int LSB;
  707. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11);
  708. add_mtp = LSB + V11_300CD_R;
  709. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  710. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_23);
  711. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  712. do_div(result_2, v11_denominator);
  713. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  714. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  715. pSmart->RGB_OUTPUT.R_VOLTAGE.level_11 = result_4;
  716. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11);
  717. add_mtp = LSB + V11_300CD_G;
  718. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  719. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_23);
  720. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  721. do_div(result_2, v11_denominator);
  722. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  723. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  724. pSmart->RGB_OUTPUT.G_VOLTAGE.level_11 = result_4;
  725. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11);
  726. add_mtp = LSB + V11_300CD_B;
  727. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  728. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
  729. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  730. do_div(result_2, v11_denominator);
  731. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  732. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  733. pSmart->RGB_OUTPUT.B_VOLTAGE.level_11 = result_4;
  734. #ifdef SMART_DIMMING_DEBUG
  735. pr_info("%s V11 RED:%d GREEN:%d BLUE:%d\n", __func__,
  736. pSmart->RGB_OUTPUT.R_VOLTAGE.level_11,
  737. pSmart->RGB_OUTPUT.G_VOLTAGE.level_11,
  738. pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
  739. #endif
  740. return 0;
  741. }
  742. static void v11_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  743. {
  744. unsigned long long result_1, result_2, result_3;
  745. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  746. - (pSmart->GRAY.TABLE[index[V11_INDEX]].R_Gray);
  747. result_2 = result_1 * v11_denominator;
  748. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  749. - (pSmart->GRAY.TABLE[index[V23_INDEX]].R_Gray);
  750. do_div(result_2, result_3);
  751. str[24] = (result_2 - v11_coefficient) & 0xff;
  752. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  753. - (pSmart->GRAY.TABLE[index[V11_INDEX]].G_Gray);
  754. result_2 = result_1 * v11_denominator;
  755. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  756. - (pSmart->GRAY.TABLE[index[V23_INDEX]].G_Gray);
  757. do_div(result_2, result_3);
  758. str[25] = (result_2 - v11_coefficient) & 0xff;
  759. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  760. - (pSmart->GRAY.TABLE[index[V11_INDEX]].B_Gray);
  761. result_2 = result_1 * v11_denominator;
  762. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  763. - (pSmart->GRAY.TABLE[index[V23_INDEX]].B_Gray);
  764. do_div(result_2, result_3);
  765. str[26] = (result_2 - v11_coefficient) & 0xff;
  766. }
  767. #define v3_coefficient 64
  768. #define v3_denominator 320
  769. static int v3_adjustment(struct SMART_DIM *pSmart)
  770. {
  771. unsigned long long result_1, result_2, result_3, result_4;
  772. int add_mtp;
  773. int LSB;
  774. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3);
  775. add_mtp = LSB + V3_300CD_R;
  776. result_1 = (pSmart->vregout_voltage)
  777. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_11);
  778. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  779. do_div(result_2, v3_denominator);
  780. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  781. result_4 = (pSmart->vregout_voltage) - result_3;
  782. pSmart->RGB_OUTPUT.R_VOLTAGE.level_3 = result_4;
  783. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3);
  784. add_mtp = LSB + V3_300CD_G;
  785. result_1 = (pSmart->vregout_voltage)
  786. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_11);
  787. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  788. do_div(result_2, v3_denominator);
  789. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  790. result_4 = (pSmart->vregout_voltage) - result_3;
  791. pSmart->RGB_OUTPUT.G_VOLTAGE.level_3 = result_4;
  792. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3);
  793. add_mtp = LSB + V3_300CD_B;
  794. result_1 = (pSmart->vregout_voltage)
  795. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
  796. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  797. do_div(result_2, v3_denominator);
  798. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  799. result_4 = (pSmart->vregout_voltage) - result_3;
  800. pSmart->RGB_OUTPUT.B_VOLTAGE.level_3 = result_4;
  801. #ifdef SMART_DIMMING_DEBUG
  802. pr_info("%s V3 RED:%d GREEN:%d BLUE:%d\n", __func__,
  803. pSmart->RGB_OUTPUT.R_VOLTAGE.level_3,
  804. pSmart->RGB_OUTPUT.G_VOLTAGE.level_3,
  805. pSmart->RGB_OUTPUT.B_VOLTAGE.level_3);
  806. #endif
  807. return 0;
  808. }
  809. static void v3_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  810. {
  811. unsigned long long result_1, result_2, result_3;
  812. result_1 = (pSmart->vregout_voltage)
  813. - (pSmart->GRAY.TABLE[index[V3_INDEX]].R_Gray);
  814. result_2 = result_1 * v3_denominator;
  815. result_3 = (pSmart->vregout_voltage)
  816. - (pSmart->GRAY.TABLE[index[V11_INDEX]].R_Gray);
  817. do_div(result_2, result_3);
  818. str[27] = (result_2 - v3_coefficient) & 0xff;
  819. result_1 = (pSmart->vregout_voltage)
  820. - (pSmart->GRAY.TABLE[index[V3_INDEX]].G_Gray);
  821. result_2 = result_1 * v3_denominator;
  822. result_3 = (pSmart->vregout_voltage)
  823. - (pSmart->GRAY.TABLE[index[V11_INDEX]].G_Gray);
  824. do_div(result_2, result_3);
  825. str[28] = (result_2 - v3_coefficient) & 0xff;
  826. result_1 = (pSmart->vregout_voltage)
  827. - (pSmart->GRAY.TABLE[index[V3_INDEX]].B_Gray);
  828. result_2 = result_1 * v3_denominator;
  829. result_3 = (pSmart->vregout_voltage)
  830. - (pSmart->GRAY.TABLE[index[V11_INDEX]].B_Gray);
  831. do_div(result_2, result_3);
  832. str[29] = (result_2 - v3_coefficient) & 0xff;
  833. }
  834. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  835. static int S6E3_ARRAY[S6E3_MAX] = {0, 1, 3, 11, 23, 35, 51, 87, 151, 203, 255};
  836. #define V0toV3_Coefficient 2
  837. #define V0toV3_Multiple 1
  838. #define V0toV3_denominator 3
  839. #define V3toV11_Coefficient 7
  840. #define V3toV11_Multiple 1
  841. #define V3toV11_denominator 8
  842. #define V11toV23_Coefficient 11
  843. #define V11toV23_Multiple 1
  844. #define V11toV23_denominator 12
  845. #define V23toV35_Coefficient 11
  846. #define V23toV35_Multiple 1
  847. #define V23toV35_denominator 12
  848. #define V35toV51_Coefficient 15
  849. #define V35toV51_Multiple 1
  850. #define V35toV51_denominator 16
  851. #define V51toV87_Coefficient 35
  852. #define V51toV87_Multiple 1
  853. #define V51toV87_denominator 36
  854. #define V87toV151_Coefficient 63
  855. #define V87toV151_Multiple 1
  856. #define V87toV151_denominator 64
  857. #define V151toV203_Coefficient 51
  858. #define V151toV203_Multiple 1
  859. #define V151toV203_denominator 52
  860. #define V203toV255_Coefficient 51
  861. #define V203toV255_Multiple 1
  862. #define V203toV255_denominator 52
  863. static int cal_gray_scale_linear(int up, int low, int coeff,
  864. int mul, int deno, int cnt)
  865. {
  866. unsigned long long result_1, result_2, result_3, result_4;
  867. result_1 = up - low;
  868. result_2 = (result_1 * (coeff - (cnt * mul))) << BIT_SHIFT;
  869. do_div(result_2, deno);
  870. result_3 = result_2 >> BIT_SHIFT;
  871. result_4 = low + result_3;
  872. return (int)result_4;
  873. }
  874. static int generate_gray_scale(struct SMART_DIM *pSmart)
  875. {
  876. int cnt = 0, cal_cnt = 0;
  877. int array_index = 0;
  878. struct GRAY_VOLTAGE *ptable = (struct GRAY_VOLTAGE *)
  879. (&(pSmart->GRAY.TABLE));
  880. for (cnt = 0; cnt < S6E3_MAX; cnt++) {
  881. pSmart->GRAY.TABLE[S6E3_ARRAY[cnt]].R_Gray =
  882. ((int *)&(pSmart->RGB_OUTPUT.R_VOLTAGE))[cnt];
  883. pSmart->GRAY.TABLE[S6E3_ARRAY[cnt]].G_Gray =
  884. ((int *)&(pSmart->RGB_OUTPUT.G_VOLTAGE))[cnt];
  885. pSmart->GRAY.TABLE[S6E3_ARRAY[cnt]].B_Gray =
  886. ((int *)&(pSmart->RGB_OUTPUT.B_VOLTAGE))[cnt];
  887. }
  888. /*
  889. below codes use hard coded value.
  890. So it is possible to modify on each model.
  891. V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255
  892. */
  893. for (cnt = 0; cnt < S6E3_GRAY_SCALE_MAX; cnt++) {
  894. if (cnt == S6E3_ARRAY[0]) {
  895. /* 0 */
  896. array_index = 0;
  897. cal_cnt = 0;
  898. } else if ((cnt > S6E3_ARRAY[0]) &&
  899. (cnt < S6E3_ARRAY[2])) {
  900. /* 1 ~ 2 */
  901. array_index = 2;
  902. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  903. ptable[S6E3_ARRAY[array_index-2]].R_Gray,
  904. ptable[S6E3_ARRAY[array_index]].R_Gray,
  905. V0toV3_Coefficient, V0toV3_Multiple,
  906. V0toV3_denominator, cal_cnt);
  907. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  908. ptable[S6E3_ARRAY[array_index-2]].G_Gray,
  909. ptable[S6E3_ARRAY[array_index]].G_Gray,
  910. V0toV3_Coefficient, V0toV3_Multiple,
  911. V0toV3_denominator, cal_cnt);
  912. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  913. ptable[S6E3_ARRAY[array_index-2]].B_Gray,
  914. ptable[S6E3_ARRAY[array_index]].B_Gray,
  915. V0toV3_Coefficient, V0toV3_Multiple,
  916. V0toV3_denominator , cal_cnt);
  917. cal_cnt++;
  918. } else if (cnt == S6E3_ARRAY[2]) {
  919. /* 3 */
  920. cal_cnt = 0;
  921. } else if ((cnt > S6E3_ARRAY[2]) &&
  922. (cnt < S6E3_ARRAY[3])) {
  923. /* 4 ~ 10 */
  924. array_index = 3;
  925. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  926. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  927. ptable[S6E3_ARRAY[array_index]].R_Gray,
  928. V3toV11_Coefficient, V3toV11_Multiple,
  929. V3toV11_denominator, cal_cnt);
  930. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  931. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  932. ptable[S6E3_ARRAY[array_index]].G_Gray,
  933. V3toV11_Coefficient, V3toV11_Multiple,
  934. V3toV11_denominator, cal_cnt);
  935. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  936. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  937. ptable[S6E3_ARRAY[array_index]].B_Gray,
  938. V3toV11_Coefficient, V3toV11_Multiple,
  939. V3toV11_denominator , cal_cnt);
  940. cal_cnt++;
  941. } else if (cnt == S6E3_ARRAY[3]) {
  942. /* 11 */
  943. cal_cnt = 0;
  944. } else if ((cnt > S6E3_ARRAY[3]) &&
  945. (cnt < S6E3_ARRAY[4])) {
  946. /* 12 ~ 22 */
  947. array_index = 4;
  948. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  949. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  950. ptable[S6E3_ARRAY[array_index]].R_Gray,
  951. V11toV23_Coefficient, V11toV23_Multiple,
  952. V11toV23_denominator, cal_cnt);
  953. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  954. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  955. ptable[S6E3_ARRAY[array_index]].G_Gray,
  956. V11toV23_Coefficient, V11toV23_Multiple,
  957. V11toV23_denominator, cal_cnt);
  958. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  959. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  960. ptable[S6E3_ARRAY[array_index]].B_Gray,
  961. V11toV23_Coefficient, V11toV23_Multiple,
  962. V11toV23_denominator , cal_cnt);
  963. cal_cnt++;
  964. } else if (cnt == S6E3_ARRAY[4]) {
  965. /* 23 */
  966. cal_cnt = 0;
  967. } else if ((cnt > S6E3_ARRAY[4]) &&
  968. (cnt < S6E3_ARRAY[5])) {
  969. /* 24 ~ 34 */
  970. array_index = 5;
  971. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  972. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  973. ptable[S6E3_ARRAY[array_index]].R_Gray,
  974. V23toV35_Coefficient, V23toV35_Multiple,
  975. V23toV35_denominator, cal_cnt);
  976. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  977. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  978. ptable[S6E3_ARRAY[array_index]].G_Gray,
  979. V23toV35_Coefficient, V23toV35_Multiple,
  980. V23toV35_denominator, cal_cnt);
  981. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  982. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  983. ptable[S6E3_ARRAY[array_index]].B_Gray,
  984. V23toV35_Coefficient, V23toV35_Multiple,
  985. V23toV35_denominator , cal_cnt);
  986. cal_cnt++;
  987. } else if (cnt == S6E3_ARRAY[5]) {
  988. /* 35 */
  989. cal_cnt = 0;
  990. } else if ((cnt > S6E3_ARRAY[5]) &&
  991. (cnt < S6E3_ARRAY[6])) {
  992. /* 36 ~ 50 */
  993. array_index = 6;
  994. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  995. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  996. ptable[S6E3_ARRAY[array_index]].R_Gray,
  997. V35toV51_Coefficient, V35toV51_Multiple,
  998. V35toV51_denominator, cal_cnt);
  999. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1000. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  1001. ptable[S6E3_ARRAY[array_index]].G_Gray,
  1002. V35toV51_Coefficient, V35toV51_Multiple,
  1003. V35toV51_denominator, cal_cnt);
  1004. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1005. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  1006. ptable[S6E3_ARRAY[array_index]].B_Gray,
  1007. V35toV51_Coefficient, V35toV51_Multiple,
  1008. V35toV51_denominator, cal_cnt);
  1009. cal_cnt++;
  1010. } else if (cnt == S6E3_ARRAY[6]) {
  1011. /* 51 */
  1012. cal_cnt = 0;
  1013. } else if ((cnt > S6E3_ARRAY[6]) &&
  1014. (cnt < S6E3_ARRAY[7])) {
  1015. /* 52 ~ 86 */
  1016. array_index = 7;
  1017. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1018. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  1019. ptable[S6E3_ARRAY[array_index]].R_Gray,
  1020. V51toV87_Coefficient, V51toV87_Multiple,
  1021. V51toV87_denominator, cal_cnt);
  1022. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1023. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  1024. ptable[S6E3_ARRAY[array_index]].G_Gray,
  1025. V51toV87_Coefficient, V51toV87_Multiple,
  1026. V51toV87_denominator, cal_cnt);
  1027. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1028. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  1029. ptable[S6E3_ARRAY[array_index]].B_Gray,
  1030. V51toV87_Coefficient, V51toV87_Multiple,
  1031. V51toV87_denominator, cal_cnt);
  1032. cal_cnt++;
  1033. } else if (cnt == S6E3_ARRAY[7]) {
  1034. /* 87 */
  1035. cal_cnt = 0;
  1036. } else if ((cnt > S6E3_ARRAY[7]) &&
  1037. (cnt < S6E3_ARRAY[8])) {
  1038. /* 88 ~ 150 */
  1039. array_index = 8;
  1040. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1041. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  1042. ptable[S6E3_ARRAY[array_index]].R_Gray,
  1043. V87toV151_Coefficient, V87toV151_Multiple,
  1044. V87toV151_denominator, cal_cnt);
  1045. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1046. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  1047. ptable[S6E3_ARRAY[array_index]].G_Gray,
  1048. V87toV151_Coefficient, V87toV151_Multiple,
  1049. V87toV151_denominator, cal_cnt);
  1050. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1051. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  1052. ptable[S6E3_ARRAY[array_index]].B_Gray,
  1053. V87toV151_Coefficient, V87toV151_Multiple,
  1054. V87toV151_denominator, cal_cnt);
  1055. cal_cnt++;
  1056. } else if (cnt == S6E3_ARRAY[8]) {
  1057. /* 151 */
  1058. cal_cnt = 0;
  1059. } else if ((cnt > S6E3_ARRAY[8]) &&
  1060. (cnt < S6E3_ARRAY[9])) {
  1061. /* 152 ~ 202 */
  1062. array_index = 9;
  1063. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1064. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  1065. ptable[S6E3_ARRAY[array_index]].R_Gray,
  1066. V151toV203_Coefficient, V151toV203_Multiple,
  1067. V151toV203_denominator, cal_cnt);
  1068. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1069. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  1070. ptable[S6E3_ARRAY[array_index]].G_Gray,
  1071. V151toV203_Coefficient, V151toV203_Multiple,
  1072. V151toV203_denominator, cal_cnt);
  1073. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1074. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  1075. ptable[S6E3_ARRAY[array_index]].B_Gray,
  1076. V151toV203_Coefficient, V151toV203_Multiple,
  1077. V151toV203_denominator, cal_cnt);
  1078. cal_cnt++;
  1079. } else if (cnt == S6E3_ARRAY[9]) {
  1080. /* 203 */
  1081. cal_cnt = 0;
  1082. } else if ((cnt > S6E3_ARRAY[9]) &&
  1083. (cnt < S6E3_ARRAY[10])) {
  1084. /* 204 ~ 254 */
  1085. array_index = 10;
  1086. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1087. ptable[S6E3_ARRAY[array_index-1]].R_Gray,
  1088. ptable[S6E3_ARRAY[array_index]].R_Gray,
  1089. V203toV255_Coefficient, V203toV255_Multiple,
  1090. V203toV255_denominator, cal_cnt);
  1091. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1092. ptable[S6E3_ARRAY[array_index-1]].G_Gray,
  1093. ptable[S6E3_ARRAY[array_index]].G_Gray,
  1094. V203toV255_Coefficient, V203toV255_Multiple,
  1095. V203toV255_denominator, cal_cnt);
  1096. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1097. ptable[S6E3_ARRAY[array_index-1]].B_Gray,
  1098. ptable[S6E3_ARRAY[array_index]].B_Gray,
  1099. V203toV255_Coefficient, V203toV255_Multiple,
  1100. V203toV255_denominator, cal_cnt);
  1101. cal_cnt++;
  1102. } else {
  1103. if (cnt == S6E3_ARRAY[10]) {
  1104. pr_debug("%s end\n", __func__);
  1105. } else {
  1106. pr_err("%s fail cnt:%d\n", __func__, cnt);
  1107. return -EINVAL;
  1108. }
  1109. }
  1110. }
  1111. #ifdef SMART_DIMMING_DEBUG
  1112. for (cnt = 0; cnt < S6E3_GRAY_SCALE_MAX; cnt++) {
  1113. pr_info("%s %8d %8d %8d %d\n", __func__,
  1114. pSmart->GRAY.TABLE[cnt].R_Gray,
  1115. pSmart->GRAY.TABLE[cnt].G_Gray,
  1116. pSmart->GRAY.TABLE[cnt].B_Gray, cnt);
  1117. }
  1118. #endif
  1119. return 0;
  1120. }
  1121. char offset_cal(int offset, char value)
  1122. {
  1123. unsigned char real_value;
  1124. if (value < 0 )
  1125. real_value = value * -1;
  1126. else
  1127. real_value = value;
  1128. if (real_value - offset < 0)
  1129. return 0;
  1130. else if (real_value - offset > 255)
  1131. return 0xFF;
  1132. else
  1133. return real_value - offset;
  1134. }
  1135. static void mtp_offset_substraction(struct SMART_DIM *pSmart, char *str)
  1136. {
  1137. int level_255_temp = 0;
  1138. int level_255_temp_MSB = 0;
  1139. int MTP_V255;
  1140. /*subtration MTP_OFFSET value from generated gamma table*/
  1141. level_255_temp = (str[0] << 8) | str[1] ;
  1142. MTP_V255 = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  1143. pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
  1144. level_255_temp -= MTP_V255;
  1145. level_255_temp_MSB = level_255_temp / 256;
  1146. str[0] = level_255_temp_MSB & 0xff;
  1147. str[1] = level_255_temp & 0xff;
  1148. level_255_temp = (str[2] << 8) | str[3] ;
  1149. MTP_V255 = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  1150. pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
  1151. level_255_temp -= MTP_V255;
  1152. level_255_temp_MSB = level_255_temp / 256;
  1153. str[2] = level_255_temp_MSB & 0xff;
  1154. str[3] = level_255_temp & 0xff;
  1155. level_255_temp = (str[4] << 8) | str[5] ;
  1156. MTP_V255 = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  1157. pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
  1158. level_255_temp -= MTP_V255;
  1159. level_255_temp_MSB = level_255_temp / 256;
  1160. str[4] = level_255_temp_MSB & 0xff;
  1161. str[5] = level_255_temp & 0xff;
  1162. str[6] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203), str[6]);
  1163. str[7] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203), str[7]);
  1164. str[8] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203), str[8]);
  1165. str[9] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151), str[9]);
  1166. str[10] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151), str[10]);
  1167. str[11] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151), str[11]);
  1168. str[12] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87), str[12]);
  1169. str[13] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87), str[13]);
  1170. str[14] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87), str[14]);
  1171. str[15] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51), str[15]);
  1172. str[16] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51), str[16]);
  1173. str[17] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51), str[17]);
  1174. str[18] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35), str[18]);
  1175. str[19] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35), str[19]);
  1176. str[20] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35), str[20]);
  1177. str[21] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23), str[21]);
  1178. str[22] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23), str[22]);
  1179. str[23] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23), str[23]);
  1180. str[24] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11), str[24]);
  1181. str[25] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11), str[25]);
  1182. str[26] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11), str[26]);
  1183. str[27] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3), str[27]);
  1184. str[28] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3), str[28]);
  1185. str[29] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3), str[29]);
  1186. }
  1187. static int searching_function(long long candela, int *index, int gamma_curve)
  1188. {
  1189. long long delta_1 = 0, delta_2 = 0;
  1190. int cnt;
  1191. /*
  1192. * This searching_functin should be changed with improved
  1193. searcing algorithm to reduce searching time.
  1194. */
  1195. *index = -1;
  1196. for (cnt = 0; cnt < (S6E3_GRAY_SCALE_MAX-1); cnt++) {
  1197. if (gamma_curve == GAMMA_CURVE_1P9) {
  1198. delta_1 = candela - curve_1p9_350[cnt];
  1199. delta_2 = candela - curve_1p9_350[cnt+1];
  1200. } else if (gamma_curve == GAMMA_CURVE_2P15) {
  1201. delta_1 = candela - curve_2p15_350[cnt];
  1202. delta_2 = candela - curve_2p15_350[cnt+1];
  1203. } else if (gamma_curve == GAMMA_CURVE_2P2) {
  1204. delta_1 = candela - curve_2p2_350[cnt];
  1205. delta_2 = candela - curve_2p2_350[cnt+1];
  1206. } else
  1207. delta_1 = candela - curve_2p2_350[cnt];
  1208. delta_2 = candela - curve_2p2_350[cnt+1];
  1209. if (delta_2 < 0) {
  1210. *index = (delta_1 + delta_2) <= 0 ? cnt : cnt+1;
  1211. break;
  1212. }
  1213. if (delta_1 == 0) {
  1214. *index = cnt;
  1215. break;
  1216. }
  1217. if (delta_2 == 0) {
  1218. *index = cnt+1;
  1219. break;
  1220. }
  1221. }
  1222. if (*index == -1)
  1223. return -EINVAL;
  1224. else
  1225. return 0;
  1226. }
  1227. static int searching_function_360(long long candela, int *index, int gamma_curve)
  1228. {
  1229. long long delta_1 = 0, delta_2 = 0;
  1230. int cnt;
  1231. /*
  1232. * This searching_functin should be changed with improved
  1233. searcing algorithm to reduce searching time.
  1234. */
  1235. *index = -1;
  1236. for (cnt = 0; cnt < (S6E3_GRAY_SCALE_MAX-1); cnt++) {
  1237. if (gamma_curve == GAMMA_CURVE_1P9) {
  1238. delta_1 = candela - curve_1p9_360[cnt];
  1239. delta_2 = candela - curve_1p9_360[cnt+1];
  1240. } else if (gamma_curve == GAMMA_CURVE_2P15) {
  1241. delta_1 = candela - curve_2p15_360[cnt];
  1242. delta_2 = candela - curve_2p15_360[cnt+1];
  1243. } else if (gamma_curve == GAMMA_CURVE_2P2) {
  1244. delta_1 = candela - curve_2p2_360[cnt];
  1245. delta_2 = candela - curve_2p2_360[cnt+1];
  1246. } else
  1247. delta_1 = candela - curve_2p2_360[cnt];
  1248. delta_2 = candela - curve_2p2_360[cnt+1];
  1249. if (delta_2 < 0) {
  1250. *index = (delta_1 + delta_2) <= 0 ? cnt : cnt+1;
  1251. break;
  1252. }
  1253. if (delta_1 == 0) {
  1254. *index = cnt;
  1255. break;
  1256. }
  1257. if (delta_2 == 0) {
  1258. *index = cnt+1;
  1259. break;
  1260. }
  1261. }
  1262. if (*index == -1)
  1263. return -EINVAL;
  1264. else
  1265. return 0;
  1266. }
  1267. /* -1 means V1 */
  1268. #define S6E3_TABLE_MAX (S6E3_MAX-1)
  1269. static void(*Make_hexa[S6E3_TABLE_MAX])(int*, struct SMART_DIM*, char*) = {
  1270. v255_hexa,
  1271. v203_hexa,
  1272. v151_hexa,
  1273. v87_hexa,
  1274. v51_hexa,
  1275. v35_hexa,
  1276. v23_hexa,
  1277. v11_hexa,
  1278. v3_hexa,
  1279. vt_hexa,
  1280. };
  1281. #if defined(AID_OPERATION)
  1282. /*
  1283. * Because of AID operation & display quality.
  1284. *
  1285. * only smart dimmg range : 350CD ~ 183CD
  1286. * AOR fix range : 172CD ~ 111CD AOR 40%
  1287. * AOR adjust range : 105CD ~ 10CD
  1288. */
  1289. #define AOR_FIX_CD 172
  1290. #define AOR_ADJUST_CD 111
  1291. #define AOR_DIM_BASE_CD 110
  1292. #define CCG6_MAX_TABLE 64
  1293. static int ccg6_candela_table[][2] = {
  1294. {2, 0,},
  1295. {3, 1,},
  1296. {4, 2,},
  1297. {5, 3,},
  1298. {6, 4,},
  1299. {7, 5,},
  1300. {8, 6,},
  1301. {9, 7,},
  1302. {10, 8,},
  1303. {11, 9,},
  1304. {12, 10,},
  1305. {13, 11,},
  1306. {14, 12,},
  1307. {15, 13,},
  1308. {16, 14,},
  1309. {17, 15,},
  1310. {19, 16,},
  1311. {20, 17,},
  1312. {21, 18,},
  1313. {22, 19,},
  1314. {24, 20,},
  1315. {25, 21,},
  1316. {27, 22,},
  1317. {29, 23,},
  1318. {30, 24,},
  1319. {32, 25,},
  1320. {34, 26,},
  1321. {37, 27,},
  1322. {39, 28,},
  1323. {41, 29,},
  1324. {44, 30,},
  1325. {47, 31,},
  1326. {50, 32,},
  1327. {53, 33,},
  1328. {56, 34,},
  1329. {60, 35,},
  1330. {64, 36,},
  1331. {68, 37,},
  1332. {72, 38,},
  1333. {77, 39,},
  1334. {82, 40,},
  1335. {87, 41,},
  1336. {93, 42,},
  1337. {98, 43,},
  1338. {105, 44,},
  1339. {111, 45,},
  1340. {119, 46,},
  1341. {126, 47,},
  1342. {134, 48,},
  1343. {143, 49,},
  1344. {152, 50,},
  1345. {162, 51,},
  1346. {172, 52,},
  1347. {183, 53,},
  1348. {195, 54,},
  1349. {207, 55,},
  1350. {220, 56,},
  1351. {234, 57,},
  1352. {249, 58,},
  1353. {265, 59,},
  1354. {282, 60,},
  1355. {300, 61,},
  1356. {316, 62,},
  1357. {333, 63,},
  1358. {350, 64,},
  1359. };
  1360. static int find_cadela_table(int brightness)
  1361. {
  1362. int loop;
  1363. int err = -1;
  1364. for(loop = 0; loop <= CCG6_MAX_TABLE; loop++)
  1365. if (ccg6_candela_table[loop][0] == brightness)
  1366. return ccg6_candela_table[loop][1];
  1367. return err;
  1368. }
  1369. #define RGB_COMPENSATION 24
  1370. static int gradation_offset_S_hd_revA[][9] = {
  1371. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1372. {0, 10, 20, 31, 40, 45, 46, 47, 48},
  1373. {0, 8, 16, 27, 34, 38, 43, 44, 45},
  1374. {0, 7, 14, 23, 29, 33, 36, 37, 38},
  1375. {0, 7, 12, 19, 24, 27, 31, 34, 35},
  1376. {0, 6, 11, 19, 23, 26, 30, 31, 32},
  1377. {0, 6, 10, 17, 20, 24, 28, 29, 30},
  1378. {0, 5, 9, 15, 18, 21, 25, 26, 27},
  1379. {0, 5, 7, 13, 16, 19, 23, 24, 25},
  1380. {0, 4, 7, 11, 14, 16, 20, 23, 25},
  1381. {0, 3, 6, 11, 13, 16, 20, 22, 23},
  1382. {0, 3, 5, 10, 13, 16, 19, 20, 22},
  1383. {0, 3, 5, 9, 12, 14, 18, 19, 21},
  1384. {0, 3, 5, 9, 11, 13, 17, 18, 20},
  1385. {0, 3, 4, 8, 11, 13, 16, 17, 19},
  1386. {0, 2, 4, 8, 10, 12, 16, 17, 18},
  1387. {0, 2, 4, 8, 9, 12, 15, 16, 17},
  1388. {0, 2, 3, 7, 8, 10, 14, 15, 16},
  1389. {0, 3, 4, 6, 8, 9, 12, 15, 16},
  1390. {0, 2, 3, 6, 7, 9, 12, 13, 14},
  1391. {0, 2, 3, 6, 7, 9, 12, 13, 14},
  1392. {0, 2, 3, 5, 6, 9, 12, 13, 14},
  1393. {0, 2, 3, 5, 6, 8, 11, 12, 13},
  1394. {0, 2, 3, 5, 5, 7, 10, 11, 12},
  1395. {0, 2, 2, 5, 5, 7, 10, 11, 12},
  1396. {0, 2, 2, 4, 5, 7, 10, 11, 12},
  1397. {0, 2, 2, 4, 5, 6, 9, 10, 11},
  1398. {0, 2, 2, 4, 4, 6, 8, 9, 10},
  1399. {0, 2, 2, 3, 3, 5, 7, 8, 9},
  1400. {0, 2, 2, 3, 3, 5, 7, 8, 9},
  1401. {0, 2, 2, 3, 3, 5, 7, 8, 9},
  1402. {0, 2, 2, 3, 3, 4, 6, 7, 8},
  1403. {0, 2, 2, 3, 3, 4, 6, 7, 8},
  1404. {0, 2, 2, 3, 3, 4, 6, 7, 8},
  1405. {0, 2, 2, 3, 3, 4, 6, 7, 8},
  1406. {0, 2, 2, 3, 3, 4, 5, 6, 7},
  1407. {0, 1, 2, 3, 3, 3, 4, 6, 6},
  1408. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1409. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1410. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1411. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1412. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1413. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1414. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1415. {0, 1, 2, 3, 3, 3, 4, 5, 6},
  1416. {0, 1, 2, 2, 2, 3, 4, 5, 6},
  1417. {0, 1, 2, 2, 2, 2, 3, 4, 7},
  1418. {0, 1, 2, 2, 2, 2, 4, 5, 4},
  1419. {0, 1, 2, 2, 2, 1, 3, 4, 5},
  1420. {0, 1, 2, 3, 2, 2, 3, 5, 5},
  1421. {0, 1, 2, 2, 2, 2, 3, 4, 5},
  1422. {0, 1, 2, 2, 1, 2, 3, 4, 5},
  1423. {0, 1, 2, 2, 1, 1, 2, 4, 5},
  1424. {0, 1, 2, 2, 1, 1, 2, 3, 6},
  1425. {0, 1, 1, 2, 1, 1, 2, 3, 5},
  1426. {0, 1, 1, 2, 1, 1, 1, 3, 3},
  1427. {0, 1, 1, 1, 1, 0, 1, 2, 5},
  1428. {0, 1, 1, 1, 1, 0, 1, 2, 3},
  1429. {0, 1, 1, 1, 1, 0, 1, 1, 5},
  1430. {0, 1, 1, 1, 1, 0, 1, 1, 5},
  1431. {0, 0, 2, 1, 1, 0, 1, 2, 4},
  1432. {0, 0, 2, 1, 1, 0, 1, 2, 4},
  1433. {0, 0, 1, 0, 1, 0, 1, 1, 3},
  1434. {0, 0, 1, -1, 1, 0, 1, 1, 3},
  1435. {0, 0, 1, -1, 1, 0, 0, 0, 2},
  1436. {0, 0, 0, 0, 0, 0, 0, 0, 0},
  1437. };
  1438. static int rgb_offset_S_hd_revA[][RGB_COMPENSATION] = {
  1439. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  1440. R87 G87 B87 R51 G51 B51 R35 G35 B35
  1441. R23 G23 B23 R11 G11 B11
  1442. */
  1443. {-8, 0, -8, -3, 1, -6, -4, 1, -8, -7, 4, -11, -4, 5, -11, 0, 3, -3, -18, 3, -13, -6, 2, -15},
  1444. {-5, 1, -7, -3, 0, -4, -4, 1, -7, -4, 4, -9, -9, 5, -10, -7, 3, -12, -1, 3, -7, -6, 2, -15},
  1445. {-4, 1, -4, -2, 0, -4, -4, 1, -6, -3, 4, -9, -8, 5, -10, -7, 3, -11, -1, 3, -7, -6, 2, -15},
  1446. {-3, 0, -3, -3, 0, -3, -2, 1, -5, -6, 4, -9, -7, 4, -11, -2, 3, -6, -1, 3, -7, -6, 2, -15},
  1447. {-3, 0, -3, -2, 0, -3, -3, 0, -4, -5, 3, -8, -4, 4, -10, -3, 3, -7, -2, 3, -7, -6, 2, -15},
  1448. {-3, 0, -3, -1, 0, -2, -3, 0, -4, -4, 3, -8, -4, 4, -9, -4, 3, -7, -2, 3, -7, -6, 2, -15},
  1449. {-2, 0, -2, -1, 0, -2, -3, 0, -4, -3, 3, -7, -4, 4, -9, -4, 3, -8, -3, 3, -7, -6, 2, -15},
  1450. {-2, 0, -2, 0, 0, -2, -3, 0, -3, -3, 3, -7, -4, 3, -9, -5, 3, -9, -3, 3, -7, -6, 2, -15},
  1451. {-2, 0, 1, 0, 0, -2, -2, 0, -3, -3, 3, -6, -7, 4, -9, -5, 2, -9, -3, 2, -7, -6, 2, -15},
  1452. {-2, 0, 1, 0, 0, -2, -2, 0, -3, -3, 3, -6, -6, 3, -8, -5, 2, -8, -3, 2, -7, -4, 2, -13},
  1453. {-2, 0, 1, 0, 0, -1, -2, 0, -3, -3, 2, -6, -6, 3, -8, -5, 2, -8, -3, 2, -7, -4, 2, -13},
  1454. {-2, 0, 1, 0, 0, -1, -2, 0, -2, -3, 2, -6, -5, 3, -8, -4, 2, -7, -3, 2, -7, -4, 2, -13},
  1455. {-2, 0, 1, 0, 0, -1, -2, 0, -2, -2, 2, -5, -5, 3, -8, -4, 2, -7, -3, 2, -7, -4, 2, -13},
  1456. {-1, 0, 1, 0, 0, -1, -2, 0, -2, -3, 2, -5, -4, 3, -7, -4, 2, -6, -3, 2, -7, -4, 2, -13},
  1457. {-1, 0, 1, 0, 0, -1, -2, 0, -2, -3, 2, -5, -4, 3, -7, -3, 2, -6, -3, 2, -6, -4, 2, -13},
  1458. {-1, 0, 1, 0, 0, -1, -2, 0, -2, -2, 2, -4, -4, 3, -7, -2, 2, -5, -3, 2, -6, -4, 2, -13},
  1459. {-1, 0, 1, 0, 0, -1, -2, 0, -2, -1, 2, -4, -4, 3, -6, -5, 2, -6, -3, 2, -6, -4, 2, -13},
  1460. {-1, 0, 1, 0, 0, -1, 0, 0, -2, -2, 2, -3, -4, 3, -6, -4, 2, -4, -4, 2, -6, -4, 2, -13},
  1461. {-1, 0, 1, 0, 0, -1, 0, 0, -2, -1, 2, -4, -4, 3, -6, -3, 2, -4, -4, 2, -6, -4, 2, -13},
  1462. {-1, 0, 1, 0, 0, -1, 0, 0, -2, -2, 1, -4, -4, 3, -7, -2, 2, -4, -4, 2, -6, -4, 2, -13},
  1463. {-1, 0, 1, 0, 0, -1, 0, 0, -2, -2, 1, -4, -4, 2, -6, -2, 2, -4, -4, 2, -6, -4, 2, -13},
  1464. {-1, 0, 1, 0, 0, -1, 0, 0, -2, -2, 1, -4, -3, 2, -5, -2, 2, -4, -4, 2, -5, -4, 2, -13},
  1465. {-1, 0, 1, 0, 0, 0, 0, 0, -2, -2, 1, -4, -3, 2, -5, -2, 2, -4, -4, 2, -6, -4, 2, -13},
  1466. {-1, 0, 1, 0, 0, 0, 0, 0, -2, -2, 1, -4, -3, 2, -4, -2, 2, -4, -3, 2, -6, -4, 2, -13},
  1467. {-1, 0, 1, 0, 0, 0, 0, 0, -2, -2, 1, -4, -3, 2, -5, -2, 2, -4, -3, 2, -5, -4, 2, -13},
  1468. {-1, 0, 1, 0, 0, 0, 0, 0, -2, -1, 1, -3, -2, 2, -4, -2, 2, -4, -3, 2, -5, -3, 2, -12},
  1469. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 1, -3, -2, 2, -4, -2, 2, -4, -3, 2, -5, -3, 2, -12},
  1470. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 1, -2, -2, 1, -4, -2, 2, -4, -3, 2, -6, -3, 2, -12},
  1471. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 1, -2, -2, 1, -4, -2, 1, -4, -3, 1, -4, -3, 2, -12},
  1472. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 1, -2, -2, 1, -4, -2, 1, -4, -3, 1, -4, -3, 2, -12},
  1473. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 1, -2, -2, 1, -4, -2, 1, -3, -2, 1, -4, -3, 2, -12},
  1474. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -2, -3, 1, -4, -2, 1, -3, -2, 1, -4, -3, 2, -12},
  1475. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -2, -1, 1, -4, -2, 1, -3, -2, 1, -4, -3, 2, -12},
  1476. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -2, -2, 1, -4, -2, 1, -3, -2, 1, -4, -3, 2, -12},
  1477. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, -3, -2, 0, -2, -2, 1, -3, -3, 2, -12},
  1478. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, -3, -2, 0, -2, -2, 1, -3, -3, 2, -12},
  1479. {-1, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, -3, -2, 0, -2, -2, 1, -2, -3, 2, -12},
  1480. {-1, 0, 1, 1, 0, 0, 0, 0, -1, -1, 0, -1, -3, 0, -4, -2, 0, -1, -2, 1, -2, -2, 4, -11},
  1481. {-1, 0, 0, 1, 0, 0, 0, 0, -1, -1, 0, -1, -3, 0, -3, -3, 0, -2, -2, 1, -2, -2, 3, -11},
  1482. {-1, 0, 0, 1, 0, 0, 0, 0, -1, -1, 0, -1, -3, 0, -3, -1, 0, -2, -2, 0, -2, -2, 3, -11},
  1483. {-1, 0, 0, 1, 0, 0, 0, 0, -1, -1, 0, -1, -2, 0, -3, -1, 0, -2, -1, 0, -2, -2, 3, -11},
  1484. {-1, 0, 0, 1, 0, 0, 1, 0, -1, -1, 0, -1, -2, 0, -3, -1, 0, -2, -2, 0, -2, -2, 3, -11},
  1485. {-1, 0, 0, 1, 0, 0, 1, 0, -1, -1, 0, -1, -2, 0, -3, -1, 0, -2, -2, 0, -2, -2, 3, -11},
  1486. {-1, 0, 0, 1, 0, 0, -1, 0, -2, -1, 0, -3, -2, 0, -1, -2, 0, -2, -2, 0, -2, -2, 3, -11},
  1487. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -2, 0, -2, -2, 0, -2, -2, 0, -2, -2, 3, -9},
  1488. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -2, 0, -2, -2, 0, -2, -2, 0, -2, -2, 3, -9},
  1489. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -2, 0, -2, -3, 0, -2, -2, 0, -2, -2, 2, -6},
  1490. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -2, 0, -2, -2, 0, -2, -2, 0, -2, -1, 2, -6},
  1491. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -1, 0, -2, -1, 0, -2, -2, 0, -2, -2, 2, -5},
  1492. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -1, 0, -2, -1, 0, -2, -2, 0, -2, -2, 1, -4},
  1493. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -1, 0, -2, -1, 0, -1, -2, 0, -2, -2, 1, -4},
  1494. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -1, 0, -1, 0, 0, -1, -2, 0, -2, -2, 1, -4},
  1495. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -1, 0, -1, -1, 0, -1, -2, 0, -2, -2, 2, -4},
  1496. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, -1, 0, -1, -1, 0, -1, -2, 0, -2, -2, 1, -2},
  1497. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, -1, -2, 0, -2, -2, 0, -2},
  1498. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, -1, -1, 0, -1, -2, 1, -2},
  1499. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, -1, 0, 0, -1, -2, 0, -2},
  1500. {-1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, -1, 0, 0, -1, -1, 0, -2},
  1501. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, -1},
  1502. {0, 0, 0, 0, 0, 0, -1, 0, -1, 1, 0, -1, 0, 0, 0, -1, 0, -1, 1, 0, 0, -1, 0, -1},
  1503. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 1, 0, 0, -1, 0, -1},
  1504. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, -1},
  1505. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0},
  1506. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0},
  1507. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1508. };
  1509. static int gradation_offset_S_hd_revD[][9] = {
  1510. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1511. {0, 9, 17, 27, 37, 38, 39, 40, 41},
  1512. {0, 9, 16, 25, 34, 36, 37, 39, 39},
  1513. {0, 7, 13, 20, 27, 30, 33, 36, 37},
  1514. {0, 6, 11, 17, 22, 26, 30, 33, 35},
  1515. {0, 5, 9, 16, 20, 25, 28, 32, 33},
  1516. {0, 4, 7, 14, 18, 22, 26, 29, 26},
  1517. {0, 4, 7, 12, 17, 21, 24, 28, 27},
  1518. {0, 4, 6, 11, 15, 18, 21, 26, 20},
  1519. {0, 3, 6, 10, 14, 17, 20, 24, 22},
  1520. {0, 3, 5, 10, 13, 16, 19, 23, 22},
  1521. {0, 3, 5, 9, 12, 15, 18, 22, 16},
  1522. {0, 3, 5, 8, 11, 14, 17, 21, 16},
  1523. {0, 3, 5, 8, 10, 13, 16, 20, 14},
  1524. {0, 3, 4, 7, 10, 13, 15, 19, 18},
  1525. {0, 3, 4, 7, 9, 12, 15, 18, 16},
  1526. {0, 3, 4, 7, 9, 11, 14, 17, 17},
  1527. {0, 3, 4, 6, 7, 10, 12, 16, 11},
  1528. {0, 3, 4, 6, 7, 10, 12, 15, 15},
  1529. {0, 3, 3, 6, 7, 9, 11, 15, 13},
  1530. {0, 3, 3, 5, 7, 9, 11, 15, 11},
  1531. {0, 3, 3, 5, 6, 8, 9, 13, 12},
  1532. {0, 3, 3, 5, 5, 8, 9, 13, 11},
  1533. {0, 3, 3, 5, 5, 7, 9, 12, 11},
  1534. {0, 2, 3, 4, 5, 7, 8, 11, 10},
  1535. {0, 2, 3, 4, 5, 6, 7, 11, 9},
  1536. {0, 2, 3, 4, 4, 6, 7, 10, 9},
  1537. {0, 2, 2, 4, 4, 5, 7, 10, 8},
  1538. {0, 2, 3, 3, 3, 5, 6, 9, 7},
  1539. {0, 2, 2, 3, 3, 5, 6, 9, 6},
  1540. {0, 2, 2, 3, 3, 4, 5, 8, 7},
  1541. {0, 2, 2, 3, 3, 4, 5, 8, 5},
  1542. {0, 2, 2, 3, 2, 4, 5, 7, 7},
  1543. {0, 2, 2, 3, 2, 3, 4, 7, 5},
  1544. {0, 2, 2, 3, 2, 3, 4, 6, 5},
  1545. {0, 2, 2, 2, 2, 2, 3, 5, 6},
  1546. {0, 2, 2, 2, 1, 2, 3, 5, 5},
  1547. {0, 2, 2, 2, 1, 2, 3, 4, 5},
  1548. {0, 2, 2, 2, 1, 2, 2, 4, 5},
  1549. {0, 2, 2, 2, 1, 2, 2, 4, 2},
  1550. {0, 2, 1, 1, 0, 0, 2, 4, 1},
  1551. {0, 2, 2, 2, 0, 1, 2, 3, 1},
  1552. {0, 2, 3, 2, 1, 2, 2, 3, 3},
  1553. {0, 1, 2, 2, 0, 1, 2, 3, 2},
  1554. {0, 1, 1, 2, 0, 1, 1, 3, 2},
  1555. {0, 1, 2, 2, 0, 1, 2, 3, 2},
  1556. {0, 0, 2, 2, 1, 1, 1, 2, 4},
  1557. {0, 0, 1, 2, 0, 0, 1, 2, 3},
  1558. {0, 0, 2, 2, 1, 2, 1, 3, 2},
  1559. {0, 0, 2, 2, 1, 1, 2, 3, 0},
  1560. {0, 0, 1, 2, 1, 1, 1, 2, 1},
  1561. {0, 0, 2, 2, 2, 1, 1, 2, 1},
  1562. {0, 1, 1, 1, 0, 0, 1, 2, 1},
  1563. {0, 1, 1, 1, 0, -1, 0, 2, 2},
  1564. {0, 1, 1, 1, 0, -1, 0, 2, 0},
  1565. {0, 1, 0, 1, 0, -1, 0, 1, 0},
  1566. {0, 0, 1, 1, 0, -1, 0, 0, 4},
  1567. {0, 0, 1, 1, 0, -1, 0, 0, 2},
  1568. {0, 0, 1, 1, -1, -1, 0, 0, 0},
  1569. {0, 0, 1, 1, 0, -1, 0, 0, 2},
  1570. {0, 0, 1, 1, 0, 0, -1, 0, 2},
  1571. {0, -1, 0, 0, 0, 0, -1, -1, 3},
  1572. {0, 0, 0, 0, 0, -1, -1, -1, 3},
  1573. {0, 0, -1, -1, -1, -1, -1, -1, 4},
  1574. {0, 0, -1, -1, -1, -1, -1, -2, 4},
  1575. {0, 0, 0, 0, 0, 0, 0, 0, 0},
  1576. };
  1577. static int rgb_offset_S_hd_revD[][RGB_COMPENSATION] = {
  1578. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  1579. R87 G87 B87 R51 G51 B51 R35 G35 B35
  1580. R23 G23 B23 R11 G11 B11
  1581. */
  1582. {-4, 1, -5, -3, 0, -4, -4, 1, -6, -7, 3, -10, -3, 5, -13, -1, 5, -15, -1, 6, -13, -3, 3, -14},
  1583. {-4, -1, -5, -3, 0, -3, -4, 1, -5, -6, 3, -9, -3, 3, -10, -2, 4, -13, -1, 6, -13, -3, 3, -14},
  1584. {-2, 0, -3, -2, 0, -2, -3, 0, -4, -6, 2, -8, -6, 3, -12, -4, 3, -11, -1, 5, -12, -3, 3, -14},
  1585. {-2, 0, -2, -2, 0, -2, -3, 0, -4, -5, 2, -8, -5, 3, -11, -4, 3, -10, -1, 3, -12, -3, 3, -14},
  1586. {0, 0, 0, -2, 0, -3, -3, 0, -4, -4, 2, -5, -4, 3, -8, -3, 2, -7, -4, 3, -13, -3, 3, -12},
  1587. {0, 0, 0, -2, 0, -2, -3, 0, -4, -4, 2, -5, -5, 3, -9, -3, 3, -8, -3, 3, -11, -2, 3, -12},
  1588. {0, 0, 0, -2, 0, -1, -3, 0, -4, -2, 2, -6, -5, 3, -7, -3, 2, -5, -3, 3, -13, -2, 2, -11},
  1589. {0, 0, 0, -2, 0, -1, -3, 0, -4, -2, 2, -4, -5, 3, -7, -3, 2, -8, -5, 3, -12, -1, 2, -11},
  1590. {0, 0, 0, -2, 0, -1, -3, 0, -3, -2, 2, -3, -4, 3, -8, -3, 2, -5, -5, 3, -14, -1, 3, -10},
  1591. {0, 0, 0, -2, 0, -1, -3, 0, -3, -2, 1, -3, -5, 3, -7, -2, 2, -5, -4, 3, -11, -1, 3, -10},
  1592. {0, 0, 0, -2, 0, -1, -3, 0, -3, -2, 1, -3, -4, 3, -7, -2, 2, -5, -4, 3, -12, -1, 3, -10},
  1593. {0, 0, 1, -2, 0, -1, -3, 0, -3, -2, 1, -3, -4, 2, -8, -3, 2, -6, -5, 3, -12, 0, 3, -9},
  1594. {0, 0, 1, -2, 0, -1, -2, 0, -2, -2, 1, -3, -4, 2, -8, -4, 2, -7, -5, 3, -14, -1, 4, -12},
  1595. {0, 0, 1, -2, 0, -1, -2, 0, -2, -2, 1, -3, -3, 2, -6, -3, 2, -5, -4, 3, -12, -1, 4, -12},
  1596. {0, 0, 1, -2, 0, -1, -2, 0, -2, -2, 1, -3, -3, 2, -6, -4, 2, -6, -5, 3, -12, -1, 4, -12},
  1597. {0, 0, 1, -2, 0, -1, -2, 0, -2, -2, 1, -2, -3, 2, -6, -3, 2, -6, -5, 3, -12, -1, 4, -12},
  1598. {0, 0, 1, -2, 0, -1, -2, 0, -2, -1, 1, -2, -4, 2, -7, -3, 2, -6, -5, 3, -13, -2, 3, -11},
  1599. {0, 0, 1, -2, 0, -1, -2, 0, -2, -1, 1, -2, -4, 1, -7, -3, 2, -6, -5, 3, -13, -3, 4, -15},
  1600. {0, 0, 1, -1, 0, 0, -2, 0, -2, -1, 1, -2, -3, 1, -6, -4, 2, -7, -5, 3, -13, -3, 3, -12},
  1601. {0, 0, 1, -1, 0, 0, -2, 0, -2, -1, 1, -2, -3, 1, -6, -3, 2, -6, -5, 2, -13, -3, 3, -10},
  1602. {0, 0, 1, 0, 0, 0, -2, 0, -2, -1, 1, -2, -4, 1, -6, -4, 2, -6, -5, 2, -13, -1, 4, -12},
  1603. {0, 0, 1, 0, 0, 0, -1, 0, -2, -1, 1, -2, -4, 1, -5, -4, 2, -6, -5, 2, -13, -2, 5, -12},
  1604. {0, 0, 1, 0, 0, 0, -1, 0, -2, -1, 0, -2, -4, 1, -5, -4, 2, -6, -6, 2, -12, -1, 5, -14},
  1605. {0, 0, 1, 0, 0, 0, 0, 0, -2, -1, 0, -2, -3, 1, -4, -4, 2, -6, -5, 2, -13, -2, 4, -14},
  1606. {0, 0, 1, 0, 0, 0, 0, 0, -2, -1, 0, -2, -3, 1, -4, -4, 2, -6, -4, 2, -13, -2, 4, -13},
  1607. {0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, -1, -4, 1, -4, -4, 1, -6, -4, 2, -12, -1, 5, -13},
  1608. {0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, -1, -4, 1, -4, -4, 1, -6, -5, 2, -11, -1, 5, -12},
  1609. {0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, -1, -3, 0, -4, -4, 1, -6, -5, 2, -11, -1, 4, -13},
  1610. {0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, -1, -4, 0, -4, -3, 1, -6, -6, 2, -10, -2, 4, -13},
  1611. {0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, -1, -3, 0, -3, -3, 1, -6, -5, 2, -11, -2, 5, -14},
  1612. {0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, -1, -3, 0, -2, -2, 1, -5, -5, 2, -10, -2, 4, -13},
  1613. {0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, -2, 0, -2, -3, 1, -4, -5, 1, -10, -2, 5, -14},
  1614. {0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, -2, 0, -2, -2, 1, -4, -5, 1, -9, -2, 5, -11},
  1615. {0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, -2, 0, -2, -1, 1, -4, -3, 1, -7, -4, 5, -14},
  1616. {0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, -2, 0, -2, -1, 1, -4, -3, 1, -7, -4, 5, -15},
  1617. {0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, -2, 0, -1, -1, 1, -4, -3, 1, -6, -4, 4, -14},
  1618. {0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, -1, -2, 1, -4, -3, 1, -6, -2, 5, -12},
  1619. {0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, -1, -1, 0, -4, -3, 1, -5, -2, 5, -11},
  1620. {0, 0, 1, 0, 0, -1, 0, 0, 0, -1, 0, -1, 0, 0, 0, -2, 0, -3, -3, 1, -3, -1, 4, -10},
  1621. {0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, -1, -2, 0, -4, -4, 1, -4, -2, 4, -10},
  1622. {0, 0, 1, 0, 0, 0, -1, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, -3, -3, 1, -5, -3, 4, -10},
  1623. {0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, -3, -3, 1, -4, -2, 4, -10},
  1624. {0, 0, 1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, -2, -3, 1, -4, -1, 5, -10},
  1625. {0, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, 0, -1, 0, -2, -3, 0, -5, -3, 4, -9},
  1626. {0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, -1, 0, -2, -3, 0, -4, -3, 4, -11},
  1627. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, 0, -3, -2, 4, -9},
  1628. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, -3, 0, -3, -2, 4, -9},
  1629. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, -3, 0, -4, -3, 3, -8},
  1630. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -3, 0, -3, -3, 3, -7},
  1631. {0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, -1, -3, 0, -4, -2, 3, -7},
  1632. {0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, -2, 0, 0, 0, -1, 0, -1, -3, 0, -3, -2, 3, -5},
  1633. {0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -1, 0, -1, -3, 0, -3, -2, 3, -6},
  1634. {0, 0, 1, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -2, -3, 0, -4, -3, 2, -5},
  1635. {0, 0, 1, 0, 0, 1, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, -1, -3, 0, -3, -1, 2, -4},
  1636. {0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, -2, 0, -2, -1, 2, -5},
  1637. {0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -1, 2, -4},
  1638. {0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 1, -3},
  1639. {0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, -1, -1, 1, -2},
  1640. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 1, -2},
  1641. {0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, -2},
  1642. {0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, -1, 0, 0, -1, 0, -2},
  1643. {0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, -1, 0, 0, -1, 0, -1},
  1644. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2},
  1645. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1646. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1647. };
  1648. static int gradation_offset_S_hd_revF[][9] = {
  1649. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1650. { 0, 9, 16, 24, 33, 37, 41, 42, 43 },
  1651. { 0, 7, 12, 21, 27, 31, 34, 39, 36 },
  1652. { 0, 6, 9, 17, 21, 26, 30, 34, 28 },
  1653. { 0, 5, 8, 15, 18, 22, 25, 28, 27 },
  1654. { 0, 5, 7, 13, 17, 20, 23, 27, 27 },
  1655. { 0, 3, 5, 11, 15, 18, 22, 26, 26 },
  1656. { 0, 3, 4, 10, 13, 17, 19, 24, 23 },
  1657. { 0, 3, 4, 9, 12, 15, 18, 23, 22 },
  1658. { 0, 3, 4, 8, 11, 14, 17, 22, 18 },
  1659. { 0, 3, 4, 8, 11, 14, 17, 21, 20 },
  1660. { 0, 3, 3, 7, 10, 13, 16, 20, 18 },
  1661. { 0, 3, 3, 7, 10, 12, 16, 20, 16 },
  1662. { 0, 3, 3, 7, 9, 11, 14, 18, 17 },
  1663. { 0, 3, 3, 7, 9, 12, 14, 18, 19 },
  1664. { 0, 3, 3, 7, 9, 11, 14, 18, 15 },
  1665. { 0, 3, 3, 6, 8, 11, 13, 17, 17 },
  1666. { 0, 3, 3, 6, 7, 10, 12, 16, 12 },
  1667. { 0, 3, 3, 5, 7, 10, 12, 16, 12 },
  1668. { 0, 3, 3, 5, 7, 9, 11, 15, 13 },
  1669. { 0, 3, 3, 5, 6, 9, 11, 15, 12 },
  1670. { 0, 3, 2, 5, 6, 8, 10, 14, 13 },
  1671. { 0, 3, 2, 5, 6, 8, 10, 14, 10 },
  1672. { 0, 3, 2, 4, 5, 7, 9, 13, 10 },
  1673. { 0, 3, 2, 4, 5, 7, 8, 12, 10 },
  1674. { 0, 3, 2, 4, 5, 7, 8, 12, 10 },
  1675. { 0, 3, 2, 4, 4, 6, 8, 11, 10 },
  1676. { 0, 3, 2, 3, 4, 6, 7, 11, 7 },
  1677. { 0, 3, 2, 3, 3, 5, 6, 10, 7 },
  1678. { 0, 3, 2, 3, 3, 5, 6, 9, 7 },
  1679. { 0, 3, 2, 3, 3, 4, 5, 9, 6 },
  1680. { 0, 3, 2, 3, 2, 4, 5, 8, 6 },
  1681. { 0, 3, 2, 3, 2, 4, 5, 8, 6 },
  1682. { 0, 3, 1, 2, 2, 3, 4, 7, 6 },
  1683. { 0, 2, 1, 2, 2, 3, 4, 7, 6 },
  1684. { 0, 2, 1, 2, 2, 3, 4, 6, 6 },
  1685. { 0, 2, 1, 2, 2, 3, 3, 5, 6 },
  1686. { 0, 3, 1, 2, 2, 2, 3, 5, 6 },
  1687. { 0, 2, 1, 2, 1, 2, 3, 4, 6 },
  1688. { 0, 2, 1, 1, 1, 1, 2, 4, 4 },
  1689. { 0, 2, 2, 2, 0, 1, 2, 4, 4 },
  1690. { 0, 2, 2, 2, 1, 1, 2, 3, 4 },
  1691. { 0, 2, 2, 1, 0, 1, 2, 3, 3 },
  1692. { 0, 2, 2, 2, 0, 1, 2, 3, 3 },
  1693. { 0, 1, 2, 2, 0, 1, 2, 3, 3 },
  1694. { 0, 1, 2, 1, 0, 1, 2, 3, 3 },
  1695. { 0, 1, 2, 2, 1, 1, 2, 3, 3 },
  1696. { 0, 2, 4, 3, 1, 1, 2, 3, 3 },
  1697. { 0, 1, 2, 2, 1, 1, 1, 3, 3 },
  1698. { 0, 2, 3, 2, 0, 1, 2, 3, 3 },
  1699. { 0, 1, 3, 2, 1, 1, 1, 2, 3 },
  1700. { 0, 1, 3, 2, 1, 1, 2, 2, 3 },
  1701. { 0, 1, 2, 1, 1, 1, 1, 2, 3 },
  1702. { 0, 1, 2, 1, 1, 1, 0, 2, 3 },
  1703. { 0, 1, 2, 1, 0, 1, 0, 1, 3 },
  1704. { 0, 1, 2, 1, 0, 0, 0, 1, 3 },
  1705. { 0, 1, 2, 0, 0, 0, 0, 1, 3 },
  1706. { 0, 1, 2, 0, 0, 0, 0, 1, 3 },
  1707. { 0, 1, 1, 1, 0, 0, 0, 1, 3 },
  1708. { 0, 1, 1, 1, 0, 0, 0, 1, 3 },
  1709. { 0, 0, 1, 0, 0, 0, 0, 1, 3 },
  1710. { 0, 0, 0, 0, -1, 0, 0, 1, 3 },
  1711. { 0, 1, 1, 0, 0, 0, 0, 1, 3 },
  1712. { 0, 0, 0, 0, 0, 0, 0, 1, 3 },
  1713. { 0, 1, 0, 1, 0, 0, 0, 0, 3 },
  1714. { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1715. };
  1716. static int rgb_offset_S_hd_revF[][RGB_COMPENSATION] = {
  1717. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  1718. R87 G87 B87 R51 G51 B51 R35 G35 B35
  1719. R23 G23 B23 R11 G11 B11
  1720. */
  1721. { -5, 0, -3, -4, 0, -4, -4, 0, -5, -9, 2, -10, -8, 3, -12, -4, 3, -11, -3, 3, -6, 0, 3, -5 },
  1722. { -3, 0, -1, -3, 0, -2, -3, 0, -4, -6, 2, -7, -6, 3, -7, -4, 2, -7, -3, 3, -8, -1, 3, -3 },
  1723. { -2, 0, 0, -3, 0, -2, -3, 0, -4, -6, 1, -8, -8, 3, -9, -5, 2, -8, -3, 3, -9, 1, 3, -6 },
  1724. { -2, 0, 0, -2, 0, -1, -2, 0, -3, -5, 1, -7, -8, 3, -8, -6, 2, -9, -4, 3, -10, -1, 3, -8 },
  1725. { -1, 0, 1, -2, 0, -2, -2, 0, -2, -5, 1, -7, -7, 3, -7, -3, 3, -6, -6, 3, -12, -1, 3, -6 },
  1726. { -1, 0, 1, -2, 0, -2, -2, 0, -2, -4, 1, -7, -6, 3, -7, -6, 2, -8, -3, 3, -6, 0, 3, -7 },
  1727. { -1, 0, 1, -1, 0, -1, -2, 0, -3, -5, 1, -6, -7, 3, -8, -3, 3, -5, -4, 4, -12, 0, 2, -6 },
  1728. { -1, 0, 1, -1, 0, -1, -1, 0, -2, -5, 1, -6, -5, 3, -6, -4, 3, -6, -3, 4, -8, -1, 2, -7 },
  1729. { -1, 0, 1, -1, 0, -1, -1, 0, -2, -4, 1, -6, -7, 2, -7, -4, 3, -7, -4, 4, -12, 2, 3, -3 },
  1730. { 0, 0, 2, -2, 0, -2, -1, 0, -2, -4, 1, -5, -4, 3, -5, -4, 3, -4, -3, 4, -9, 0, 3, -8 },
  1731. { 0, 0, 2, -2, 0, -2, -1, 0, -2, -3, 1, -5, -5, 2, -5, -3, 3, -4, -4, 3, -11, -1, 3, -8 },
  1732. { 0, 0, 2, -2, 0, -2, -1, 0, -2, -2, 1, -4, -5, 2, -5, -4, 3, -5, -4, 3, -8, -1, 3, -7 },
  1733. { 0, 0, 2, -2, 0, -2, -1, 0, -2, -2, 1, -4, -6, 2, -6, -2, 3, -5, -4, 4, -12, 0, 3, -9 },
  1734. { 0, 0, 2, -2, 0, -2, 0, 0, -1, -3, 1, -4, -5, 2, -6, -4, 2, -6, -5, 3, -14, 0, 4, -8 },
  1735. { 0, 0, 2, -2, 0, -2, 0, 0, -1, -2, 1, -4, -5, 2, -5, -4, 2, -6, -4, 3, -12, -1, 3, -7 },
  1736. { 0, 0, 2, -2, 0, -2, 0, 0, -1, -2, 1, -4, -4, 2, -4, -3, 2, -4, -6, 3, -14, 0, 3, -8 },
  1737. { 0, 0, 2, -2, 0, -2, 0, 0, -1, -2, 1, -3, -3, 2, -4, -3, 2, -6, -6, 3, -13, 0, 3, -7 },
  1738. { 0, 0, 2, -1, 0, -1, -1, 0, -2, -1, 1, -3, -5, 1, -6, -3, 2, -6, -5, 3, -12, -1, 3, -8 },
  1739. { 0, 0, 1, -1, 0, -1, 0, 0, -1, -1, 1, -3, -3, 2, -4, -3, 3, -6, -6, 3, -13, -1, 3, -8 },
  1740. { 0, 0, 1, -1, 0, -1, -1, 0, -1, -1, 1, -2, -3, 2, -4, -3, 2, -6, -6, 3, -13, -1, 3, -7 },
  1741. { 0, 0, 1, -1, 0, -1, -1, 0, -1, -1, 1, -2, -3, 2, -4, -4, 2, -6, -6, 3, -13, -1, 3, -7 },
  1742. { 0, 0, 1, -1, 0, -1, -1, 0, -1, -1, 1, -2, -3, 2, -4, -3, 2, -5, -5, 3, -12, -1, 3, -7 },
  1743. { 0, 0, 1, -1, 0, -1, -1, 0, -1, -1, 1, -2, -2, 2, -2, -2, 2, -5, -5, 3, -12, -1, 3, -7 },
  1744. { 0, 0, 1, -1, 0, -1, 0, 0, -1, -2, 1, -2, -2, 1, -2, -2, 2, -5, -4, 3, -12, -1, 3, -7 },
  1745. { 0, 0, 1, -1, 0, -1, 0, 0, -1, -2, 1, -2, -2, 0, -2, -3, 2, -6, -4, 3, -12, -1, 3, -7 },
  1746. { 0, 0, 1, -1, 0, -1, 0, 0, 0, -1, 1, -2, -2, 0, -2, -3, 2, -5, -4, 3, -12, -1, 3, -8 },
  1747. { 0, 0, 1, -1, 0, -1, 0, 0, 0, -1, 0, -2, -2, 0, -2, -3, 2, -5, -3, 3, -12, -1, 3, -8 },
  1748. { 0, 0, 1, -1, 0, -1, 0, 0, 0, 0, 0, -1, -2, 0, -2, -1, 2, -5, -3, 3, -12, -1, 3, -8 },
  1749. { 0, 0, 1, -1, 0, -1, 0, 0, 0, 0, 0, -1, -2, 0, -2, 0, 2, -5, -3, 3, -12, -1, 3, -8 },
  1750. { 0, 0, 1, -1, 0, -1, 0, 0, 0, -1, 0, -2, -2, 0, -2, -1, 2, -4, -3, 4, -12, 0, 3, -9 },
  1751. { 0, 0, 1, -1, 0, -1, 0, 0, 0, -1, 0, -2, -1, 0, -1, -1, 2, -4, -2, 3, -10, 1, 5, -9 },
  1752. { 0, 0, 1, -1, 0, -1, 0, 0, 0, -1, 0, -2, -1, 0, -1, -1, 1, -4, -2, 3, -10, 0, 4, -8 },
  1753. { 0, 0, 1, -1, 0, -1, 1, 0, 0, 0, 0, 0, -2, 0, -1, -2, 1, -5, -2, 3, -12, -1, 4, -10 },
  1754. { 0, 0, 1, -1, 0, 0, 0, 0, -1, 1, 0, 0, -1, 0, 0, -2, 1, -5, -2, 3, -11, 0, 4, -7 },
  1755. { 0, 0, 1, -1, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, -2, 1, -4, -1, 3, -10, 1, 5, -10 },
  1756. { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, -1, 1, -2, 0, 3, -13, -1, 5, -12 },
  1757. { 0, 0, 1, -1, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, -4, -1, 3, -10, -1, 4, -10 },
  1758. { 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, -3, -1, 2, -10, 0, 6, -11 },
  1759. { -1, 0, 0, -1, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 1, -4, -1, 2, -9, -2, 6, -11 },
  1760. { 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, 0, 0, 0, 2, 0, 0, -4, -1, 2, -10, -2, 6, -10 },
  1761. { 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, 0, -1, 0, 2, 0, 0, -4, -1, 2, -9, -1, 6, -10 },
  1762. { -1, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -3, -1, 2, -9, -2, 6, -11 },
  1763. { 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, -3, -2, 2, -7, 1, 6, -12 },
  1764. { 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, -4, -2, 2, -5, 3, 6, -9 },
  1765. { 1, 0, 1, -1, 0, 1, 0, 0, -2, 0, 0, 0, 0, 0, 2, 0, 0, -2, -2, 2, -6, 2, 6, -9 },
  1766. { 0, 0, 1, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, 1, -1, 0, -2, -2, 2, -6, 1, 6, -9 },
  1767. { 0, 0, 0, -1, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, 0, 0, 0, -1, -2, 1, -8, -4, 3, -11 },
  1768. { 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 1, -7, -4, 3, -10 },
  1769. { 1, 0, 2, -1, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 1, -1, 1, -2, -1, 0, -5, -3, 3, -9 },
  1770. { 1, 0, 1, -1, 0, -1, -1, 0, 0, 1, 0, -1, 0, 0, 0, -1, 0, -2, -1, 0, -6, -5, 2, -11 },
  1771. { 1, 0, 2, -1, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 0, -1, 0, -4, -4, 2, -10 },
  1772. { 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 1, -3, -4, 3, -10 },
  1773. { 1, 0, 1, -1, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 1, -6, -3, 2, -6 },
  1774. { 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 1, 0, 2, 1, 0, 0, -1, 1, -5, -3, 2, -8 },
  1775. { 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, -1, -2, -1, -6, -4, 2, -7 },
  1776. { 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, 2, 0, 0, -1, -1, -1, -6, -3, 2, -5 },
  1777. { 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, 0, 0, 2, 1, -1, -1, -2, 0, -5, -3, 1, -4 },
  1778. { 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 1, 0, 2, 0, -1, -2, 0, -1, -4, -3, 2, -2 },
  1779. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -3, -3, 0, -3 },
  1780. { 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -2, -2, 0, -3 },
  1781. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1782. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1783. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1784. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1785. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1786. };
  1787. static int gradation_offset_S_hd_revG[][9] = {
  1788. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1789. { 0, 9, 15, 24, 31, 36, 38, 39, 40 },
  1790. { 0, 7, 11, 19, 23, 27, 31, 32, 33 },
  1791. { 0, 6, 9, 17, 21, 26, 29, 30, 31 },
  1792. { 0, 5, 6, 13, 17, 21, 25, 28, 29 },
  1793. { 0, 5, 6, 12, 16, 19, 23, 27, 28 },
  1794. { 0, 4, 6, 11, 14, 18, 21, 25, 26 },
  1795. { 0, 4, 5, 10, 14, 17, 20, 24, 25 },
  1796. { 0, 4, 4, 9, 12, 16, 18, 23, 24 },
  1797. { 0, 4, 4, 9, 11, 14, 17, 21, 22 },
  1798. { 0, 4, 4, 9, 11, 14, 17, 21, 22 },
  1799. { 0, 3, 3, 8, 10, 12, 15, 19, 20 },
  1800. { 0, 3, 3, 7, 10, 12, 15, 19, 20 },
  1801. { 0, 3, 3, 7, 10, 12, 15, 19, 20 },
  1802. { 0, 3, 3, 7, 9, 11, 14, 18, 19 },
  1803. { 0, 3, 3, 7, 9, 11, 14, 18, 19 },
  1804. { 0, 3, 3, 6, 9, 11, 14, 17, 18 },
  1805. { 0, 3, 3, 6, 8, 10, 12, 16, 17 },
  1806. { 0, 3, 3, 6, 8, 10, 12, 15, 16 },
  1807. { 0, 3, 3, 5, 7, 10, 12, 15, 16 },
  1808. { 0, 3, 3, 5, 7, 9, 11, 15, 16 },
  1809. { 0, 3, 3, 5, 6, 9, 11, 15, 16 },
  1810. { 0, 3, 3, 5, 6, 8, 10, 14, 15 },
  1811. { 0, 3, 3, 4, 6, 8, 9, 13, 14 },
  1812. { 0, 3, 3, 4, 5, 7, 9, 13, 14 },
  1813. { 0, 3, 3, 4, 4, 7, 8, 12, 13 },
  1814. { 0, 3, 3, 4, 4, 6, 8, 12, 13 },
  1815. { 0, 3, 3, 4, 4, 6, 7, 11, 12 },
  1816. { 0, 3, 3, 3, 4, 5, 7, 10, 11 },
  1817. { 0, 3, 3, 3, 3, 5, 6, 10, 11 },
  1818. { 0, 3, 3, 3, 3, 5, 6, 9, 10 },
  1819. { 0, 3, 3, 3, 3, 4, 5, 8, 9 },
  1820. { 0, 3, 3, 3, 3, 4, 5, 8, 9 },
  1821. { 0, 2, 3, 3, 2, 4, 5, 7, 8 },
  1822. { 0, 2, 3, 3, 2, 3, 5, 7, 8 },
  1823. { 0, 2, 3, 3, 2, 3, 4, 6, 7 },
  1824. { 0, 2, 3, 3, 2, 3, 4, 5, 6 },
  1825. { 0, 2, 3, 3, 2, 3, 3, 5, 6 },
  1826. { 0, 2, 2, 2, 1, 2, 3, 5, 6 },
  1827. { 0, 2, 3, 2, 1, 2, 3, 4, 5 },
  1828. { 0, 2, 3, 2, 1, 2, 3, 4, 5 },
  1829. { 0, 2, 3, 2, 1, 2, 3, 4, 5 },
  1830. { 0, 2, 3, 2, 1, 2, 3, 3, 4 },
  1831. { 0, 2, 3, 2, 1, 2, 3, 3, 4 },
  1832. { 0, 2, 3, 2, 1, 2, 3, 3, 4 },
  1833. { 0, 2, 3, 2, 1, 1, 3, 3, 4 },
  1834. { 0, 2, 3, 2, 1, 1, 2, 3, 4 },
  1835. { 0, 2, 3, 2, 1, 1, 2, 3, 4 },
  1836. { 0, 2, 3, 2, 1, 1, 2, 3, 4 },
  1837. { 0, 2, 3, 2, 1, 1, 2, 3, 4 },
  1838. { 0, 2, 3, 2, 1, 1, 2, 3, 4 },
  1839. { 0, 2, 3, 2, 1, 1, 2, 2, 3 },
  1840. { 0, 2, 3, 2, 1, 1, 1, 3, 4 },
  1841. { 0, 2, 3, 2, 1, 1, 1, 2, 3 },
  1842. { 0, 2, 3, 2, 1, 1, 1, 2, 3 },
  1843. { 0, 2, 3, 2, 0, 1, 0, 1, 2 },
  1844. { 0, 2, 2, 1, 0, 0, 0, 1, 2 },
  1845. { 0, 1, 2, 1, 0, 0, 0, 1, 2 },
  1846. { 0, 1, 2, 1, 0, 0, 0, 1, 2 },
  1847. { 0, 1, 1, 1, 0, 0, 0, 1, 2 },
  1848. { 0, 2, 2, 1, 0, 0, 0, 1, 2 },
  1849. { 0, 1, 1, 1, 0, 0, 0, 0, 0 },
  1850. { 0, 1, 1, 1, 0, 0, 0, 0, 0 },
  1851. { 0, 0, 1, 0, 0, 0, 0, 0, 0 },
  1852. { 0, 1, 0, 0, 0, 0, 0, 0, 0 },
  1853. { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1854. };
  1855. static int rgb_offset_S_hd_revG[][RGB_COMPENSATION] = {
  1856. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  1857. R87 G87 B87 R51 G51 B51 R35 G35 B35
  1858. R23 G23 B23 R11 G11 B11
  1859. */
  1860. { -3, 0, -3, -4, 0, -3, -3, 1, -3, -7, 3, -8, -8, 4, -12, -3, 4, -8, -3, 5, -6, -8, 6, -11 },
  1861. { -3, 0, -2, -4, 0, -3, -2, 1, -2, -7, 2, -7, -8, 4, -10, -4, 4, -8, -4, 4, -6, -6, 6, -10 },
  1862. { -3, 0, -1, -2, 0, -2, -3, 0, -2, -6, 2, -7, -7, 3, -8, -6, 3, -8, -3, 4, -7, -7, 6, -9 },
  1863. { -1, 0, 0, -2, 0, -1, -2, 0, -2, -4, 2, -6, -7, 3, -9, -8, 3, -10, -3, 3, -6, -5, 4, -10 },
  1864. { -2, 0, 0, -2, 0, -1, -2, 0, -3, -5, 1, -7, -9, 2, -8, -9, 3, -12, -3, 3, -6, -2, 3, -7 },
  1865. { -2, 0, 0, -2, 0, -1, -2, 0, -3, -5, 1, -7, -8, 2, -8, -7, 3, -9, -6, 3, -8, -1, 4, -8 },
  1866. { -1, 0, 0, -2, 0, 0, -2, 0, -3, -4, 1, -6, -6, 2, -6, -6, 3, -8, -6, 2, -8, -1, 4, -7 },
  1867. { -1, 0, 0, -2, 0, 0, -1, 0, -2, -4, 1, -7, -8, 2, -8, -4, 3, -5, -6, 3, -11, -1, 3, -5 },
  1868. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -4, 1, -6, -7, 2, -8, -6, 3, -7, -4, 3, -9, -1, 4, -7 },
  1869. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -3, 1, -5, -7, 2, -7, -5, 3, -6, -3, 3, -7, -3, 3, -7 },
  1870. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -3, 1, -5, -5, 2, -6, -6, 3, -8, -5, 3, -10, -2, 3, -10 },
  1871. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -3, 1, -5, -5, 2, -6, -5, 3, -7, -6, 3, -9, -1, 3, -6 },
  1872. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -3, 1, -5, -5, 2, -6, -4, 3, -6, -5, 3, -9, -2, 3, -6 },
  1873. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -2, 1, -4, -5, 2, -6, -4, 3, -6, -5, 3, -9, -2, 3, -6 },
  1874. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -2, 1, -4, -5, 1, -6, -5, 2, -8, -6, 3, -9, -2, 3, -8 },
  1875. { -1, 0, 0, -1, 0, 0, -1, 0, -2, -1, 1, -3, -5, 1, -5, -5, 2, -7, -6, 2, -9, -2, 3, -9 },
  1876. { -1, 0, 0, -1, 0, 0, -1, 0, -2, 0, 1, -2, -6, 1, -6, -6, 1, -7, -5, 3, -11, -1, 3, -6 },
  1877. { -1, 0, 0, -1, 0, 0, -1, 0, -1, 0, 1, -3, -5, 1, -5, -4, 1, -6, -4, 3, -9, -2, 4, -13 },
  1878. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -2, 0, -3, -5, 1, -6, -4, 2, -6, -3, 3, -8, -2, 4, -11 },
  1879. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -2, 0, -3, -4, 1, -5, -5, 2, -7, -3, 3, -9, -4, 3, -9 },
  1880. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -2, 0, -3, -4, 1, -4, -3, 2, -5, -4, 3, -7, -3, 2, -9 },
  1881. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -2, 0, -3, -4, 0, -4, -5, 2, -7, -4, 3, -8, -4, 2, -12 },
  1882. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -1, 0, -3, -4, 0, -4, -4, 2, -6, -6, 3, -10, -4, 3, -13 },
  1883. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -1, 0, -3, -4, 0, -4, -4, 2, -6, -4, 3, -6, -3, 3, -11 },
  1884. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -1, 0, -3, -4, 0, -4, -3, 2, -5, -3, 3, -6, -1, 3, -9 },
  1885. { -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -2, -5, 0, -4, -3, 2, -6, -3, 3, -6, -1, 2, -8 },
  1886. { -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -2, -4, 0, -3, -2, 2, -5, -3, 3, -6, -3, 3, -9 },
  1887. { -1, 0, 0, -1, 0, 0, 0, 0, -1, -1, 0, -1, -2, 0, -2, -2, 2, -5, -1, 2, -4, -4, 3, -11 },
  1888. { -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -2, 0, -2, -3, 2, -5, -2, 2, -6, -4, 3, -9 },
  1889. { -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, -1, -1, 0, -1, -4, 2, -5, -1, 2, -5, -4, 4, -13 },
  1890. { -1, 0, 0, -1, 0, 0, 0, 0, -1, 1, 0, 0, -2, 0, -2, -2, 2, -5, -1, 2, -5, -4, 4, -15 },
  1891. { -1, 0, 0, -1, 0, 0, 0, 0, -1, 1, 0, 0, -1, 0, -1, -2, 1, -5, -3, 2, -6, -3, 4, -13 },
  1892. { -1, 0, 0, -1, 0, 0, 1, 0, -1, 0, 0, 0, -2, 0, -1, -2, 1, -5, -1, 2, -4, -3, 4, -16 },
  1893. { -1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, -1, -2, 0, -1, -3, 1, -5, 0, 2, -6, -3, 3, -13 },
  1894. { -1, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, 0, -2, 0, -1, -3, 1, -4, 0, 2, -7, -4, 3, -13 },
  1895. { -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, -2, 0, -1, -2, 1, -4, 0, 2, -6, -5, 3, -15 },
  1896. { -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -2, 1, -3, 0, 2, -6, -5, 3, -13 },
  1897. { -1, 0, 0, -1, 0, 0, 0, 0, 0, 2, 0, 0, -1, 0, 0, -1, 1, -4, -1, 2, -8, -4, 2, -8 },
  1898. { 0, 0, 0, -2, 0, -1, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 1, -3, -1, 2, -7, -2, 4, -11 },
  1899. { 0, 0, 0, -2, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 1, -1, 1, -3, -1, 2, -7, -3, 3, -11 },
  1900. { 0, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, -1, -1, 0, 1, -1, 1, -3, 0, 1, -7, -4, 4, -13 },
  1901. { 0, 0, 0, -1, 0, 0, 0, 0, -1, 1, 0, -1, -2, 0, 0, -1, 1, -2, 0, 1, -6, -4, 4, -15 },
  1902. { 0, 0, 0, -2, 0, -1, 0, 0, 0, 1, 0, 0, -2, 0, 0, -1, 0, -3, 0, 1, -6, -6, 4, -17 },
  1903. { 0, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, 0, -2, 0, 0, -1, 0, -2, 0, 1, -7, -4, 4, -16 },
  1904. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -2, 0, -1, -1, 0, -3, 0, 1, -5, -5, 4, -13 },
  1905. { 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, -3, -1, 1, -5, -6, 2, -11 },
  1906. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, -1, -1, 1, -5, -4, 2, -9 },
  1907. { 0, 0, 0, 0, 0, 0, -1, 0, -2, 0, 0, 0, 0, 0, 0, -1, 0, -2, -2, 1, -4, -5, 3, -11 },
  1908. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, 1, -4, -4, 2, -9 },
  1909. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, -3, 1, -4, -4, 2, -9 },
  1910. { 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, -2, -4, 1, -4, -4, 2, -9 },
  1911. { 0, 0, 1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, 1, -4, -4, 1, -6 },
  1912. { 0, 0, 0, -1, 0, -1, 0, 0, 2, 1, 0, -2, -2, 0, 0, -1, 0, -2, -2, 1, -4, -4, 1, -6 },
  1913. { 0, 0, 0, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, 0, 0, 0, -1, -2, 1, -3, -3, 1, -5 },
  1914. { 0, 0, 0, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, 0, 0, 0, -1, -1, 1, -3, -2, 1, -5 },
  1915. { 0, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 1, 1, -5, -2, 0, -4 },
  1916. { 0, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 1, 1, -4, -2, 0, -2 },
  1917. { 0, 0, 0, 0, 0, -1, -1, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, -1, 1, 1, -2, 0, 0, -1 },
  1918. { 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, -1, -1, 0, -3, 0, 0, 0 },
  1919. { 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 2, 0, 0, 0, 1, 1, -2, 0, 0, 0 },
  1920. { 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 2, 0, 1, -1, 0, -1, -1, 0, -2, 0, 0, -1 },
  1921. { 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, -3, 0, 0, -1 },
  1922. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1923. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1924. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1925. };
  1926. static void gamma_init_S_hd_revA(struct SMART_DIM *pSmart, char *str, int size)
  1927. {
  1928. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  1929. int bl_index[S6E3_TABLE_MAX] = {-1, };
  1930. long long temp_cal_data = 0;
  1931. int bl_level;
  1932. int level_255_temp_MSB = 0;
  1933. int level_V255 = 0;
  1934. int point_index;
  1935. int cnt;
  1936. int table_index;
  1937. pr_info("%s : start !!\n",__func__);
  1938. /*calculate candela level */
  1939. if (pSmart->brightness_level == 350) {
  1940. bl_level = pSmart->brightness_level;
  1941. }else if (pSmart->brightness_level == 333)
  1942. bl_level = 337;
  1943. else if (pSmart->brightness_level == 316)
  1944. bl_level = 322;
  1945. else if (pSmart->brightness_level == 300)
  1946. bl_level = 303;
  1947. else if (pSmart->brightness_level == 282)
  1948. bl_level = 286;
  1949. else if (pSmart->brightness_level == 265)
  1950. bl_level = 269;
  1951. else if ((pSmart->brightness_level <= 249) &&
  1952. (pSmart->brightness_level >= 162)) {
  1953. bl_level = 256;
  1954. } else if ((pSmart->brightness_level <= 152) &&
  1955. (pSmart->brightness_level >= 72)) {
  1956. if (pSmart->brightness_level == 72)
  1957. bl_level = 118;
  1958. else if (pSmart->brightness_level == 77)
  1959. bl_level = 125;
  1960. else if (pSmart->brightness_level == 82)
  1961. bl_level = 134;
  1962. else if (pSmart->brightness_level == 87)
  1963. bl_level = 144;
  1964. else if (pSmart->brightness_level == 93)
  1965. bl_level = 152;
  1966. else if (pSmart->brightness_level == 98)
  1967. bl_level = 160;
  1968. else if (pSmart->brightness_level == 105)
  1969. bl_level = 170;
  1970. else if (pSmart->brightness_level == 111)
  1971. bl_level = 178;
  1972. else if (pSmart->brightness_level == 119)
  1973. bl_level = 191;
  1974. else if (pSmart->brightness_level == 126)
  1975. bl_level = 203;
  1976. else if (pSmart->brightness_level == 134)
  1977. bl_level = 217;
  1978. else if (pSmart->brightness_level == 143)
  1979. bl_level = 228;
  1980. else if (pSmart->brightness_level == 152)
  1981. bl_level = 243;
  1982. else
  1983. bl_level = 243;
  1984. } else {
  1985. bl_level = AOR_DIM_BASE_CD;
  1986. }
  1987. if (pSmart->brightness_level < 350) {
  1988. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  1989. point_index = S6E3_ARRAY[cnt+1];
  1990. temp_cal_data =
  1991. ((long long)(candela_coeff_2p15[point_index])) *
  1992. ((long long)(bl_level));
  1993. candela_level[cnt] = temp_cal_data;
  1994. }
  1995. } else {
  1996. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  1997. point_index = S6E3_ARRAY[cnt+1];
  1998. temp_cal_data =
  1999. ((long long)(candela_coeff_2p2[point_index])) *
  2000. ((long long)(bl_level));
  2001. candela_level[cnt] = temp_cal_data;
  2002. }
  2003. }
  2004. #ifdef SMART_DIMMING_DEBUG
  2005. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2006. candela_level[0], candela_level[1], candela_level[2]);
  2007. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2008. candela_level[3], candela_level[4], candela_level[5]);
  2009. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2010. candela_level[6], candela_level[7], candela_level[8]);
  2011. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  2012. #endif
  2013. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2014. if (searching_function(candela_level[cnt],
  2015. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2016. pr_info("%s searching functioin error cnt:%d\n",
  2017. __func__, cnt);
  2018. }
  2019. }
  2020. /*
  2021. * Candela compensation
  2022. */
  2023. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  2024. table_index = find_cadela_table(pSmart->brightness_level);
  2025. if (table_index == -1) {
  2026. table_index = CCG6_MAX_TABLE;
  2027. pr_info("%s fail candela table_index cnt : %d brightness %d",
  2028. __func__, cnt, pSmart->brightness_level);
  2029. }
  2030. bl_index[S6E3_TABLE_MAX - cnt] +=
  2031. gradation_offset_S_hd_revA[table_index][cnt - 1];
  2032. /* THERE IS M-GRAY0 target */
  2033. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  2034. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  2035. }
  2036. #ifdef SMART_DIMMING_DEBUG
  2037. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2038. bl_index[0], bl_index[1], bl_index[2]);
  2039. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2040. bl_index[3], bl_index[4], bl_index[5]);
  2041. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2042. bl_index[6], bl_index[7], bl_index[8]);
  2043. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2044. #endif
  2045. /*Generate Gamma table*/
  2046. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  2047. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2048. /*
  2049. * RGB compensation
  2050. */
  2051. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  2052. table_index = find_cadela_table(pSmart->brightness_level);
  2053. if (table_index == -1) {
  2054. table_index = CCG6_MAX_TABLE;
  2055. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  2056. __func__, cnt, pSmart->brightness_level);
  2057. }
  2058. if (cnt < 3) {
  2059. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  2060. level_V255 +=
  2061. rgb_offset_S_hd_revA[table_index][cnt];
  2062. level_255_temp_MSB = level_V255 / 256;
  2063. str[cnt * 2] = level_255_temp_MSB & 0xff;
  2064. str[(cnt * 2) + 1] = level_V255 & 0xff;
  2065. } else {
  2066. str[cnt+3] += rgb_offset_S_hd_revA[table_index][cnt];
  2067. }
  2068. }
  2069. /*subtration MTP_OFFSET value from generated gamma table*/
  2070. mtp_offset_substraction(pSmart, str);
  2071. }
  2072. static void gamma_init_S_hd_revD(struct SMART_DIM *pSmart, char *str, int size)
  2073. {
  2074. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  2075. int bl_index[S6E3_TABLE_MAX] = {-1, };
  2076. long long temp_cal_data = 0;
  2077. int bl_level;
  2078. int level_255_temp_MSB = 0;
  2079. int level_V255 = 0;
  2080. int point_index;
  2081. int cnt;
  2082. int table_index;
  2083. pr_info("%s : start !!\n",__func__);
  2084. /*calculate candela level */
  2085. if (pSmart->brightness_level == 350) {
  2086. bl_level = pSmart->brightness_level;
  2087. }else if (pSmart->brightness_level == 333)
  2088. bl_level = 335;
  2089. else if (pSmart->brightness_level == 316)
  2090. bl_level = 317;
  2091. else if (pSmart->brightness_level == 300)
  2092. bl_level = 300;
  2093. else if (pSmart->brightness_level == 282)
  2094. bl_level = 284;
  2095. else if (pSmart->brightness_level == 265)
  2096. bl_level = 268;
  2097. else if ((pSmart->brightness_level <= 249) &&
  2098. (pSmart->brightness_level >= 162)) {
  2099. bl_level = 253;
  2100. } else if ((pSmart->brightness_level <= 152) &&
  2101. (pSmart->brightness_level >= 72)) {
  2102. if (pSmart->brightness_level == 72)
  2103. bl_level = 115;
  2104. else if (pSmart->brightness_level == 77)
  2105. bl_level = 124;
  2106. else if (pSmart->brightness_level == 82)
  2107. bl_level = 130;
  2108. else if (pSmart->brightness_level == 87)
  2109. bl_level = 139;
  2110. else if (pSmart->brightness_level == 93)
  2111. bl_level = 148;
  2112. else if (pSmart->brightness_level == 98)
  2113. bl_level = 155;
  2114. else if (pSmart->brightness_level == 105)
  2115. bl_level = 166;
  2116. else if (pSmart->brightness_level == 111)
  2117. bl_level = 174;
  2118. else if (pSmart->brightness_level == 119)
  2119. bl_level = 188;
  2120. else if (pSmart->brightness_level == 126)
  2121. bl_level = 198;
  2122. else if (pSmart->brightness_level == 134)
  2123. bl_level = 210;
  2124. else if (pSmart->brightness_level == 143)
  2125. bl_level = 224;
  2126. else if (pSmart->brightness_level == 152)
  2127. bl_level = 239;
  2128. else
  2129. bl_level = 239;
  2130. } else {
  2131. bl_level = AOR_DIM_BASE_CD;
  2132. }
  2133. if (pSmart->brightness_level < 350) {
  2134. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2135. point_index = S6E3_ARRAY[cnt+1];
  2136. temp_cal_data =
  2137. ((long long)(candela_coeff_2p15[point_index])) *
  2138. ((long long)(bl_level));
  2139. candela_level[cnt] = temp_cal_data;
  2140. }
  2141. } else {
  2142. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2143. point_index = S6E3_ARRAY[cnt+1];
  2144. temp_cal_data =
  2145. ((long long)(candela_coeff_2p2[point_index])) *
  2146. ((long long)(bl_level));
  2147. candela_level[cnt] = temp_cal_data;
  2148. }
  2149. }
  2150. #ifdef SMART_DIMMING_DEBUG
  2151. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2152. candela_level[0], candela_level[1], candela_level[2]);
  2153. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2154. candela_level[3], candela_level[4], candela_level[5]);
  2155. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2156. candela_level[6], candela_level[7], candela_level[8]);
  2157. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  2158. #endif
  2159. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2160. if (searching_function(candela_level[cnt],
  2161. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2162. pr_info("%s searching functioin error cnt:%d\n",
  2163. __func__, cnt);
  2164. }
  2165. }
  2166. /*
  2167. * Candela compensation
  2168. */
  2169. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  2170. table_index = find_cadela_table(pSmart->brightness_level);
  2171. if (table_index == -1) {
  2172. table_index = CCG6_MAX_TABLE;
  2173. pr_info("%s fail candela table_index cnt : %d brightness %d",
  2174. __func__, cnt, pSmart->brightness_level);
  2175. }
  2176. bl_index[S6E3_TABLE_MAX - cnt] +=
  2177. gradation_offset_S_hd_revD[table_index][cnt - 1];
  2178. /* THERE IS M-GRAY0 target */
  2179. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  2180. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  2181. }
  2182. #ifdef SMART_DIMMING_DEBUG
  2183. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2184. bl_index[0], bl_index[1], bl_index[2]);
  2185. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2186. bl_index[3], bl_index[4], bl_index[5]);
  2187. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2188. bl_index[6], bl_index[7], bl_index[8]);
  2189. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2190. #endif
  2191. /*Generate Gamma table*/
  2192. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  2193. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2194. /*
  2195. * RGB compensation
  2196. */
  2197. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  2198. table_index = find_cadela_table(pSmart->brightness_level);
  2199. if (table_index == -1) {
  2200. table_index = CCG6_MAX_TABLE;
  2201. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  2202. __func__, cnt, pSmart->brightness_level);
  2203. }
  2204. if (cnt < 3) {
  2205. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  2206. level_V255 +=
  2207. rgb_offset_S_hd_revD[table_index][cnt];
  2208. level_255_temp_MSB = level_V255 / 256;
  2209. str[cnt * 2] = level_255_temp_MSB & 0xff;
  2210. str[(cnt * 2) + 1] = level_V255 & 0xff;
  2211. } else {
  2212. str[cnt+3] += rgb_offset_S_hd_revD[table_index][cnt];
  2213. }
  2214. }
  2215. /*subtration MTP_OFFSET value from generated gamma table*/
  2216. mtp_offset_substraction(pSmart, str);
  2217. }
  2218. static void gamma_init_S_hd_revF(struct SMART_DIM *pSmart, char *str, int size)
  2219. {
  2220. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  2221. int bl_index[S6E3_TABLE_MAX] = {-1, };
  2222. long long temp_cal_data = 0;
  2223. int bl_level;
  2224. int level_255_temp_MSB = 0;
  2225. int level_V255 = 0;
  2226. int point_index;
  2227. int cnt;
  2228. int table_index;
  2229. pr_info("%s : start !!\n",__func__);
  2230. /*calculate candela level */
  2231. if (pSmart->brightness_level == 350) {
  2232. bl_level = pSmart->brightness_level;
  2233. }else if (pSmart->brightness_level == 333)
  2234. bl_level = 334;
  2235. else if (pSmart->brightness_level == 316)
  2236. bl_level = 316;
  2237. else if (pSmart->brightness_level == 300)
  2238. bl_level = 300;
  2239. else if (pSmart->brightness_level == 282)
  2240. bl_level = 283;
  2241. else if (pSmart->brightness_level == 265)
  2242. bl_level = 268;
  2243. else if ((pSmart->brightness_level <= 249) &&
  2244. (pSmart->brightness_level >= 162)) {
  2245. bl_level = 250;
  2246. } else if ((pSmart->brightness_level <= 152) &&
  2247. (pSmart->brightness_level >= 72)) {
  2248. if (pSmart->brightness_level == 72)
  2249. bl_level = 117;
  2250. else if (pSmart->brightness_level == 77)
  2251. bl_level = 123;
  2252. else if (pSmart->brightness_level == 82)
  2253. bl_level = 133;
  2254. else if (pSmart->brightness_level == 87)
  2255. bl_level = 139;
  2256. else if (pSmart->brightness_level == 93)
  2257. bl_level = 150;
  2258. else if (pSmart->brightness_level == 98)
  2259. bl_level = 157;
  2260. else if (pSmart->brightness_level == 105)
  2261. bl_level = 167;
  2262. else if (pSmart->brightness_level == 111)
  2263. bl_level = 177;
  2264. else if (pSmart->brightness_level == 119)
  2265. bl_level = 189;
  2266. else if (pSmart->brightness_level == 126)
  2267. bl_level = 198;
  2268. else if (pSmart->brightness_level == 134)
  2269. bl_level = 210;
  2270. else if (pSmart->brightness_level == 143)
  2271. bl_level = 225;
  2272. else if (pSmart->brightness_level == 152)
  2273. bl_level = 239;
  2274. else
  2275. bl_level = 239;
  2276. } else {
  2277. bl_level = AOR_DIM_BASE_CD;
  2278. }
  2279. if (pSmart->brightness_level < 350) {
  2280. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2281. point_index = S6E3_ARRAY[cnt+1];
  2282. temp_cal_data =
  2283. ((long long)(candela_coeff_2p15[point_index])) *
  2284. ((long long)(bl_level));
  2285. candela_level[cnt] = temp_cal_data;
  2286. }
  2287. } else {
  2288. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2289. point_index = S6E3_ARRAY[cnt+1];
  2290. temp_cal_data =
  2291. ((long long)(candela_coeff_2p2[point_index])) *
  2292. ((long long)(bl_level));
  2293. candela_level[cnt] = temp_cal_data;
  2294. }
  2295. }
  2296. #ifdef SMART_DIMMING_DEBUG
  2297. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2298. candela_level[0], candela_level[1], candela_level[2]);
  2299. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2300. candela_level[3], candela_level[4], candela_level[5]);
  2301. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2302. candela_level[6], candela_level[7], candela_level[8]);
  2303. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  2304. #endif
  2305. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2306. if (searching_function(candela_level[cnt],
  2307. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2308. pr_info("%s searching functioin error cnt:%d\n",
  2309. __func__, cnt);
  2310. }
  2311. }
  2312. /*
  2313. * Candela compensation
  2314. */
  2315. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  2316. table_index = find_cadela_table(pSmart->brightness_level);
  2317. if (table_index == -1) {
  2318. table_index = CCG6_MAX_TABLE;
  2319. pr_info("%s fail candela table_index cnt : %d brightness %d",
  2320. __func__, cnt, pSmart->brightness_level);
  2321. }
  2322. bl_index[S6E3_TABLE_MAX - cnt] +=
  2323. gradation_offset_S_hd_revF[table_index][cnt - 1];
  2324. /* THERE IS M-GRAY0 target */
  2325. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  2326. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  2327. }
  2328. #ifdef SMART_DIMMING_DEBUG
  2329. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2330. bl_index[0], bl_index[1], bl_index[2]);
  2331. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2332. bl_index[3], bl_index[4], bl_index[5]);
  2333. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2334. bl_index[6], bl_index[7], bl_index[8]);
  2335. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2336. #endif
  2337. /*Generate Gamma table*/
  2338. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  2339. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2340. /*
  2341. * RGB compensation
  2342. */
  2343. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  2344. table_index = find_cadela_table(pSmart->brightness_level);
  2345. if (table_index == -1) {
  2346. table_index = CCG6_MAX_TABLE;
  2347. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  2348. __func__, cnt, pSmart->brightness_level);
  2349. }
  2350. if (cnt < 3) {
  2351. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  2352. level_V255 +=
  2353. rgb_offset_S_hd_revF[table_index][cnt];
  2354. level_255_temp_MSB = level_V255 / 256;
  2355. str[cnt * 2] = level_255_temp_MSB & 0xff;
  2356. str[(cnt * 2) + 1] = level_V255 & 0xff;
  2357. } else {
  2358. str[cnt+3] += rgb_offset_S_hd_revF[table_index][cnt];
  2359. }
  2360. }
  2361. /*subtration MTP_OFFSET value from generated gamma table*/
  2362. mtp_offset_substraction(pSmart, str);
  2363. }
  2364. static void gamma_init_S_hd_revG(struct SMART_DIM *pSmart, char *str, int size)
  2365. {
  2366. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  2367. int bl_index[S6E3_TABLE_MAX] = {-1, };
  2368. long long temp_cal_data = 0;
  2369. int bl_level;
  2370. int level_255_temp_MSB = 0;
  2371. int level_V255 = 0;
  2372. int point_index;
  2373. int cnt;
  2374. int table_index;
  2375. pr_info("%s : start !!\n",__func__);
  2376. /*calculate candela level */
  2377. if (pSmart->brightness_level == 350) {
  2378. bl_level = pSmart->brightness_level;/*360*/
  2379. }else if (pSmart->brightness_level == 333)
  2380. bl_level = 333;
  2381. else if (pSmart->brightness_level == 316)
  2382. bl_level = 318;
  2383. else if (pSmart->brightness_level == 300)
  2384. bl_level = 300;
  2385. else if (pSmart->brightness_level == 282)
  2386. bl_level = 283;
  2387. else if (pSmart->brightness_level == 265)
  2388. bl_level = 267;
  2389. else if ((pSmart->brightness_level <= 249) &&
  2390. (pSmart->brightness_level >= 162)) {
  2391. bl_level = 249;
  2392. } else if ((pSmart->brightness_level <= 152) &&
  2393. (pSmart->brightness_level >= 72)) {
  2394. if (pSmart->brightness_level == 72)
  2395. bl_level = 117;
  2396. else if (pSmart->brightness_level == 77)
  2397. bl_level = 123;
  2398. else if (pSmart->brightness_level == 82)
  2399. bl_level = 131;
  2400. else if (pSmart->brightness_level == 87)
  2401. bl_level = 140;
  2402. else if (pSmart->brightness_level == 93)
  2403. bl_level = 149;
  2404. else if (pSmart->brightness_level == 98)
  2405. bl_level = 156;
  2406. else if (pSmart->brightness_level == 105)
  2407. bl_level = 168;
  2408. else if (pSmart->brightness_level == 111)
  2409. bl_level = 176;
  2410. else if (pSmart->brightness_level == 119)
  2411. bl_level = 189;
  2412. else if (pSmart->brightness_level == 126)
  2413. bl_level = 199;
  2414. else if (pSmart->brightness_level == 134)
  2415. bl_level = 210;
  2416. else if (pSmart->brightness_level == 143)
  2417. bl_level = 223;
  2418. else if (pSmart->brightness_level == 152)
  2419. bl_level = 237;
  2420. else
  2421. bl_level = 237;
  2422. } else {
  2423. bl_level = AOR_DIM_BASE_CD;
  2424. }
  2425. if (pSmart->brightness_level < 350) {
  2426. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2427. point_index = S6E3_ARRAY[cnt+1];
  2428. temp_cal_data =
  2429. ((long long)(candela_coeff_2p15[point_index])) *
  2430. ((long long)(bl_level));
  2431. candela_level[cnt] = temp_cal_data;
  2432. }
  2433. } else {
  2434. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2435. point_index = S6E3_ARRAY[cnt+1];
  2436. temp_cal_data =
  2437. ((long long)(candela_coeff_2p2[point_index])) *
  2438. ((long long)(bl_level));
  2439. candela_level[cnt] = temp_cal_data;
  2440. }
  2441. }
  2442. #ifdef SMART_DIMMING_DEBUG
  2443. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2444. candela_level[0], candela_level[1], candela_level[2]);
  2445. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2446. candela_level[3], candela_level[4], candela_level[5]);
  2447. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2448. candela_level[6], candela_level[7], candela_level[8]);
  2449. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  2450. #endif
  2451. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2452. if (searching_function_360(candela_level[cnt],
  2453. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2454. pr_info("%s searching functioin error cnt:%d\n",
  2455. __func__, cnt);
  2456. }
  2457. }
  2458. /*
  2459. * Candela compensation
  2460. */
  2461. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  2462. table_index = find_cadela_table(pSmart->brightness_level);
  2463. if (table_index == -1) {
  2464. table_index = CCG6_MAX_TABLE;
  2465. pr_info("%s fail candela table_index cnt : %d brightness %d",
  2466. __func__, cnt, pSmart->brightness_level);
  2467. }
  2468. bl_index[S6E3_TABLE_MAX - cnt] +=
  2469. gradation_offset_S_hd_revG[table_index][cnt - 1];
  2470. /* THERE IS M-GRAY0 target */
  2471. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  2472. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  2473. }
  2474. #ifdef SMART_DIMMING_DEBUG
  2475. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2476. bl_index[0], bl_index[1], bl_index[2]);
  2477. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2478. bl_index[3], bl_index[4], bl_index[5]);
  2479. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2480. bl_index[6], bl_index[7], bl_index[8]);
  2481. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2482. #endif
  2483. /*Generate Gamma table*/
  2484. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  2485. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2486. /*
  2487. * RGB compensation
  2488. */
  2489. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  2490. table_index = find_cadela_table(pSmart->brightness_level);
  2491. if (table_index == -1) {
  2492. table_index = CCG6_MAX_TABLE;
  2493. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  2494. __func__, cnt, pSmart->brightness_level);
  2495. }
  2496. if (cnt < 3) {
  2497. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  2498. level_V255 +=
  2499. rgb_offset_S_hd_revG[table_index][cnt];
  2500. level_255_temp_MSB = level_V255 / 256;
  2501. str[cnt * 2] = level_255_temp_MSB & 0xff;
  2502. str[(cnt * 2) + 1] = level_V255 & 0xff;
  2503. } else {
  2504. str[cnt+3] += rgb_offset_S_hd_revG[table_index][cnt];
  2505. }
  2506. }
  2507. /*subtration MTP_OFFSET value from generated gamma table*/
  2508. mtp_offset_substraction(pSmart, str);
  2509. }
  2510. #if defined(CONFIG_LCD_HMT)
  2511. static int gradation_offset_K_wqhd_revB[][9] = {
  2512. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  2513. {0, 11, 20, 28, 34, 35, 38, 40, 40},
  2514. {0, 8, 15, 22, 26, 27, 30, 32, 32},
  2515. {0, 7, 14, 19, 23, 24, 27, 28, 28},
  2516. {0, 8, 14, 19, 22, 22, 24, 26, 27},
  2517. {0, 8, 13, 18, 20, 20, 22, 24, 25},
  2518. {0, 7, 12, 17, 18, 19, 21, 22, 23},
  2519. {0, 7, 12, 16, 17, 18, 20, 21, 22},
  2520. {0, 7, 11, 15, 16, 17, 18, 20, 21},
  2521. {0, 7, 11, 14, 16, 16, 17, 18, 19},
  2522. {0, 6, 11, 14, 15, 15, 17, 18, 19},
  2523. {0, 6, 11, 14, 14, 14, 16, 17, 18},
  2524. {0, 6, 10, 13, 13, 13, 15, 16, 18},
  2525. {0, 6, 10, 12, 13, 13, 15, 16, 17},
  2526. {0, 6, 10, 11, 13, 13, 14, 15, 17},
  2527. {0, 6, 10, 11, 12, 12, 14, 15, 16},
  2528. {0, 5, 9, 10, 11, 11, 13, 13, 15},
  2529. {0, 5, 9, 10, 11, 10, 12, 12, 13},
  2530. {0, 5, 8, 10, 11, 10, 12, 12, 13},
  2531. {0, 5, 8, 10, 11, 10, 12, 12, 13},
  2532. {0, 5, 8, 9, 10, 10, 11, 12, 13},
  2533. {0, 5, 8, 9, 10, 9, 10, 11, 12},
  2534. {0, 5, 8, 9, 9, 9, 9, 10, 12},
  2535. {0, 5, 7, 9, 9, 8, 8, 9, 10},
  2536. {0, 5, 7, 8, 8, 8, 8, 9, 10},
  2537. {0, 5, 7, 8, 8, 7, 8, 9, 10},
  2538. {0, 5, 7, 8, 8, 7, 8, 9, 10},
  2539. {0, 5, 7, 7, 7, 7, 7, 8, 9},
  2540. {0, 5, 7, 6, 7, 6, 7, 7, 8},
  2541. {0, 5, 7, 6, 6, 5, 7, 7, 8},
  2542. {0, 5, 7, 6, 6, 5, 7, 7, 8},
  2543. {0, 3, 6, 6, 6, 5, 6, 6, 7},
  2544. {0, 3, 5, 6, 6, 4, 5, 5, 6},
  2545. {0, 4, 5, 5, 5, 5, 5, 5, 6},
  2546. {0, 4, 5, 5, 5, 4, 5, 5, 6},
  2547. {0, 4, 5, 5, 5, 4, 5, 5, 6},
  2548. {0, 3, 4, 4, 4, 3, 4, 4, 5},
  2549. {0, 3, 4, 5, 5, 4, 4, 4, 5},
  2550. {0, 4, 5, 6, 5, 4, 4, 5, 5},
  2551. {0, 4, 6, 5, 4, 5, 5, 4, 5},
  2552. {0, 3, 5, 6, 5, 4, 4, 4, 5},
  2553. {0, 2, 5, 6, 5, 4, 4, 4, 5},
  2554. {0, 3, 6, 6, 5, 4, 4, 4, 5},
  2555. {0, 3, 6, 6, 5, 4, 4, 4, 5},
  2556. {0, 2, 5, 5, 5, 4, 4, 4, 5},
  2557. {0, 2, 5, 6, 5, 5, 4, 4, 5},
  2558. {0, 2, 6, 6, 5, 5, 4, 5, 6},
  2559. {0, 2, 5, 6, 4, 4, 4, 4, 5},
  2560. {0, 2, 6, 6, 4, 4, 3, 3, 4},
  2561. {0, 2, 6, 6, 5, 4, 4, 3, 4},
  2562. {0, 3, 5, 6, 4, 4, 4, 3, 4},
  2563. {0, 2, 5, 6, 4, 4, 3, 3, 4},
  2564. {0, 2, 5, 6, 4, 4, 2, 2, 3},
  2565. {0, 2, 4, 5, 4, 4, 2, 2, 3},
  2566. {0, 1, 4, 5, 3, 3, 2, 1, 2},
  2567. {0, 1, 4, 4, 3, 3, 1, 1, 2},
  2568. {0, 1, 4, 4, 3, 2, 1, 1, 2},
  2569. {0, 1, 3, 3, 2, 2, 1, 1, 2},
  2570. {0, 0, 2, 2, 1, 1, 1, 0, 1},
  2571. {3, 3, 3, 3, 1, 1, 1, 0, 1},
  2572. {2, 2, 2, 1, 1, 1, 1, 1, 2},
  2573. {2, 2, 2, 1, 1, 1, 0, 0, 1},
  2574. {2, 3, 3, 2, 1, 1, 0, 0, 1},
  2575. {2, 2, 2, 1, 1, 1, 0, 0, 1},
  2576. {1, 1, 1, 1, 0, 0, 0, 0, 0},
  2577. {0, 0, 0, 0, 0, 0, 0, 0, 0},
  2578. };
  2579. static int rgb_offset_K_wqhd_revB[][RGB_COMPENSATION] = {
  2580. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  2581. R87 G87 B87 R51 G51 B51 R35 G35 B35
  2582. R23 G23 B23 R11 G11 B11
  2583. */
  2584. {-5, 3, -8, -3, 1, -4, -4, 2, -4, -12, 5, -4, -20, 7, -13, -18, 4, -5, -21, 3, -8, -28, 4, -6},
  2585. {-4, 2, -7, -3, 1, -4, -2, 2, -3, -10, 4, -6, -21, 6, -10, -19, 4, -9, -21, 5, -8, -43, 6, -9},
  2586. {-1, 2, -5, -3, 0, -3, -2, 2, -4, -10, 4, -6, -18, 4, -8, -19, 5, -13, -19, 5, -9, -32, 7, -10},
  2587. {-3, 1, -5, -1, 1, -2, -2, 1, -4, -6, 4, -5, -15, 3, -5, -15, 7, -12, -16, 7, -8, -26, 5, -14},
  2588. {-3, 1, -5, -2, 0, -3, -2, 1, -3, -7, 2, -7, -14, 3, -4, -17, 7, -15, -19, 7, -9, -21, 5, -13},
  2589. {-2, 1, -4, -2, 0, -3, -2, 1, -3, -6, 2, -6, -13, 3, -4, -14, 5, -11, -19, 6, -12, -20, 8, -15},
  2590. {-2, 1, -4, -2, 0, -3, -2, 1, -2, -5, 2, -6, -12, 3, -4, -14, 5, -10, -19, 6, -14, -24, 8, -16},
  2591. {-2, 1, -4, -2, 0, -2, -1, 1, -2, -5, 2, -6, -11, 3, -5, -15, 3, -10, -21, 8, -16, -21, 6, -15},
  2592. {-2, 0, -4, -2, 0, -2, -3, 0, -4, -4, 2, -5, -8, 3, -4, -14, 3, -8, -18, 9, -16, -21, 8, -17},
  2593. {-2, 0, -4, -2, 0, -2, -3, 0, -4, -3, 2, -4, -8, 3, -4, -13, 3, -7, -21, 6, -18, -27, 7, -20},
  2594. {-2, 0, -4, -2, 0, -2, -1, 0, -3, -4, 2, -4, -6, 3, -4, -13, 2, -6, -23, 5, -21, -31, 6, -22},
  2595. {-2, 0, -4, -2, 0, -2, -1, 0, -2, -5, 2, -6, -4, 4, -2, -14, 2, -7, -24, 5, -21, -31, 5, -22},
  2596. {-2, 0, -4, -2, 0, -2, -1, 0, -2, -3, 2, -4, -7, 2, -5, -13, 1, -7, -21, 5, -19, -30, 5, -24},
  2597. {-2, 0, -4, -2, 0, -2, -1, 0, -2, -3, 2, -4, -7, 2, -5, -12, 1, -6, -22, 7, -19, -30, 6, -24},
  2598. {-2, 0, -4, -2, 0, -2, -1, 0, -2, -3, 2, -3, -6, 3, -5, -11, 1, -5, -23, 3, -21, -32, 6, -25},
  2599. {-2, 0, -3, -1, 0, -2, -1, 0, -2, -3, 2, -3, -5, 3, -5, -11, 1, -5, -20, 4, -19, -26, 14, -20},
  2600. {-2, 0, -3, -1, 0, -2, -1, 0, -2, -4, 1, -4, -4, 3, -4, -8, 3, -4, -21, 3, -18, -25, 16, -19},
  2601. {-2, 0, -3, -1, 0, -2, -1, 0, -2, -3, 1, -3, -5, 2, -5, -8, 3, -4, -22, 2, -19, -27, 15, -21},
  2602. {-2, 0, -3, -1, 0, -2, -1, 0, -2, -3, 1, -3, -5, 1, -5, -8, 3, -4, -20, 2, -17, -30, 13, -24},
  2603. {-2, 0, -3, -1, 0, -2, -1, 0, -1, -2, 1, -3, -5, 2, -5, -9, 1, -4, -17, 4, -16, -34, 9, -28},
  2604. {-2, 0, -3, 0, 0, -1, -2, 0, -2, -2, 1, -3, -4, 1, -4, -8, 3, -3, -17, 3, -15, -31, 10, -27},
  2605. {-2, 0, -3, 0, 0, -1, -2, 0, -2, -2, 1, -3, -2, 2, -3, -9, 1, -4, -15, 6, -14, -29, 13, -25},
  2606. {-1, -2, -4, -1, 0, -1, -2, 0, -3, -4, 1, -4, -3, 2, -3, -8, 0, -3, -11, 7, -11, -29, 13, -25},
  2607. {-1, 0, -3, -1, 0, -1, -2, 0, -3, -4, 0, -4, -2, 1, -3, -7, 0, -4, -12, 6, -12, -31, 11, -27},
  2608. {-1, 0, -3, -1, 0, -1, -2, 0, -3, -3, 0, -3, -2, 1, -3, -5, 2, -3, -14, 4, -12, -32, 10, -28},
  2609. {-1, 0, -3, -1, 0, -1, -2, 0, -3, -3, 0, -3, -2, 1, -3, -5, 1, -3, -13, 3, -11, -37, 7, -32},
  2610. {-1, 0, -3, -1, 0, -1, -2, 0, -3, -3, 0, -3, -2, 1, -3, -6, 1, -2, -11, 5, -10, -36, 8, -32},
  2611. {0, 0, -3, -1, 0, -1, -2, 0, -3, -3, 0, -2, -3, 0, -3, -5, 1, -1, -10, 3, -10, -34, 13, -30},
  2612. {0, 0, -3, -1, 0, -1, -2, 0, -3, -3, 0, -1, 0, 1, -3, -6, 1, -1, -11, 1, -10, -33, 11, -31},
  2613. {0, 0, -3, -1, 0, -1, -2, 0, -3, -3, 0, -1, -1, 1, -3, -4, 1, 0, -10, 1, -10, -37, 8, -33},
  2614. {1, 0, -2, -3, 0, -2, -1, 0, -1, -3, 0, -2, -1, 0, -3, -6, 0, -1, -8, 4, -8, -29, 11, -28},
  2615. {1, 0, -2, -2, 1, -1, -1, 0, -1, -2, 0, -2, -1, 0, -3, -5, 1, 0, -5, 4, -7, -30, 11, -28},
  2616. {1, 0, -2, -2, 0, -1, -1, 0, -1, -2, 0, -2, -1, 0, -2, -5, 0, -1, -6, 4, -7, -30, 10, -28},
  2617. {1, 0, -2, -2, 0, -1, -1, 0, -1, -2, 0, -2, -1, 0, -2, -5, 1, -1, -5, 2, -7, -29, 7, -30},
  2618. {0, 0, -2, -1, 0, -1, -1, 0, -1, -2, 0, -1, -1, 0, -3, -5, 0, -1, -6, 1, -8, -28, 6, -29},
  2619. {1, 0, -2, -2, 0, -1, -1, 0, -1, -2, 0, -1, 0, 1, -3, -4, 0, 0, -3, 4, -5, -29, 5, -31},
  2620. {-1, 0, -2, -1, 0, -1, 0, 0, -1, -1, 0, -1, 0, 0, -3, -3, 0, 1, -5, 2, -6, -29, 9, -28},
  2621. {-1, 0, -2, -1, 0, -1, 0, 0, 0, -1, 0, -2, -1, 0, -3, -4, 0, 1, -5, 2, -6, -24, 7, -24},
  2622. {-1, 0, -2, -1, 0, -1, 0, 0, -1, -1, 0, -2, 0, 0, -1, -3, 0, 0, -6, 1, -6, -24, 7, -24},
  2623. {0, 0, -1, -1, 0, -1, -1, 0, -1, -1, 0, -2, 0, 0, -3, -3, 0, 0, -5, 1, -6, -24, 7, -24},
  2624. {0, 0, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, -1, 0, -4, -2, 0, 2, -5, 1, -6, -24, 7, -24},
  2625. {0, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, -1, 0, -4, -2, 0, 2, -5, 1, -4, -25, 7, -25},
  2626. {0, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, -1, 0, -2, -1, 0, 1, -4, 1, -3, -24, 7, -24},
  2627. {0, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, -1, 0, -1, -2, 0, 0, -3, 1, -2, -18, 6, -21},
  2628. {0, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, -1, 0, -2, -2, 0, 0, -5, 1, -3, -22, 6, -22},
  2629. {0, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, 0, 0, -3, -2, 0, 0, -4, 1, -2, -16, 6, -18},
  2630. {0, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -1, -1, 0, -2, -2, 0, 0, -4, 0, -2, -18, 6, -20},
  2631. {1, 0, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, -1, 0, -2, 0, 1, -3, -4, 0, -1, -14, 6, -17},
  2632. {1, 0, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, 1, -3, -4, 0, -1, -13, 6, -15},
  2633. {1, 0, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, -2, -4, 0, -1, -14, 5, -14},
  2634. {1, 0, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, 0, 0, -1, -2, -4, 0, 0, -14, 4, -13},
  2635. {1, 0, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, 0, 0, -1, -2, -3, 0, 1, -12, 4, -12},
  2636. {1, 0, 0, -1, 0, -1, -1, 0, -1, -1, 0, -1, 0, 0, 0, 0, -1, -3, -3, 0, 1, -9, 3, -11},
  2637. {1, 0, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, 0, 0, -1, -1, -4, -3, 0, 2, -10, 3, -12},
  2638. {1, 0, 0, -2, 0, -1, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, -1, -3, -1, 0, 3, -9, 2, -11},
  2639. {1, 0, 0, -2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -4, -1, 0, 3, -8, 1, -11},
  2640. {1, 0, 0, -2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -3, -1, 0, 3, -5, 1, -9},
  2641. {0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 2, -1, -3, -1, 0, 3, -4, 1, -10},
  2642. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2643. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2644. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2645. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2646. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2647. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2648. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2649. };
  2650. static void gamma_init_K_wqhd_revB(struct SMART_DIM *pSmart, char *str, int size)
  2651. {
  2652. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  2653. int bl_index[S6E3_TABLE_MAX] = {-1, };
  2654. long long temp_cal_data = 0;
  2655. int bl_level;
  2656. int level_255_temp_MSB = 0;
  2657. int level_V255 = 0;
  2658. int point_index;
  2659. int cnt;
  2660. int table_index;
  2661. pr_debug("%s : start !!\n",__func__);
  2662. /*calculate candela level */
  2663. if (pSmart->brightness_level >= 249) {
  2664. /* 249CD ~ 350CD */
  2665. bl_level = pSmart->brightness_level;
  2666. } else if ((pSmart->brightness_level < 249) &&
  2667. (pSmart->brightness_level > 143)) {
  2668. /* 152CD ~ 234CD */
  2669. bl_level = 249;
  2670. } else if ((pSmart->brightness_level <= 143) &&
  2671. (pSmart->brightness_level >= 64)) {
  2672. /* 64CD ~ 143CD */
  2673. if (pSmart->brightness_level == 64)
  2674. bl_level = 117;
  2675. else if (pSmart->brightness_level == 68)
  2676. bl_level = 123;
  2677. else if (pSmart->brightness_level == 72)
  2678. bl_level = 130;
  2679. else if (pSmart->brightness_level == 77)
  2680. bl_level = 138;
  2681. else if (pSmart->brightness_level == 82)
  2682. bl_level = 147;
  2683. else if (pSmart->brightness_level == 87)
  2684. bl_level = 154;
  2685. else if (pSmart->brightness_level == 93)
  2686. bl_level = 164;
  2687. else if (pSmart->brightness_level == 98)
  2688. bl_level = 172;
  2689. else if (pSmart->brightness_level == 105)
  2690. bl_level = 186;
  2691. else if (pSmart->brightness_level == 111)
  2692. bl_level = 199;
  2693. else if (pSmart->brightness_level == 119)
  2694. bl_level = 208;
  2695. else if (pSmart->brightness_level == 126)
  2696. bl_level = 218;
  2697. else if (pSmart->brightness_level == 134)
  2698. bl_level = 230;
  2699. else if (pSmart->brightness_level == 143)
  2700. bl_level = 241;
  2701. else
  2702. bl_level = 241;
  2703. } else {
  2704. /* 60CD ~ 2CD */
  2705. bl_level = AOR_DIM_BASE_CD;
  2706. }
  2707. if (pSmart->brightness_level < 350) {
  2708. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2709. point_index = S6E3_ARRAY[cnt+1];
  2710. temp_cal_data =
  2711. ((long long)(candela_coeff_2p15[point_index])) *
  2712. ((long long)(bl_level));
  2713. candela_level[cnt] = temp_cal_data;
  2714. }
  2715. } else {
  2716. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2717. point_index = S6E3_ARRAY[cnt+1];
  2718. temp_cal_data =
  2719. ((long long)(candela_coeff_2p2[point_index])) *
  2720. ((long long)(bl_level));
  2721. candela_level[cnt] = temp_cal_data;
  2722. }
  2723. }
  2724. #ifdef SMART_DIMMING_DEBUG
  2725. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2726. candela_level[0], candela_level[1], candela_level[2]);
  2727. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2728. candela_level[3], candela_level[4], candela_level[5]);
  2729. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2730. candela_level[6], candela_level[7], candela_level[8]);
  2731. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  2732. #endif
  2733. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2734. if (searching_function(candela_level[cnt],
  2735. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2736. pr_info("%s searching functioin error cnt:%d\n",
  2737. __func__, cnt);
  2738. }
  2739. }
  2740. /*
  2741. * Candela compensation
  2742. */
  2743. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  2744. table_index = find_cadela_table(pSmart->brightness_level);
  2745. if (table_index == -1) {
  2746. table_index = CCG6_MAX_TABLE;
  2747. pr_info("%s fail candela table_index cnt : %d brightness %d",
  2748. __func__, cnt, pSmart->brightness_level);
  2749. }
  2750. bl_index[S6E3_TABLE_MAX - cnt] +=
  2751. gradation_offset_K_wqhd_revB[table_index][cnt - 1];
  2752. /* THERE IS M-GRAY0 target */
  2753. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  2754. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  2755. }
  2756. #ifdef SMART_DIMMING_DEBUG
  2757. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2758. bl_index[0], bl_index[1], bl_index[2]);
  2759. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2760. bl_index[3], bl_index[4], bl_index[5]);
  2761. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2762. bl_index[6], bl_index[7], bl_index[8]);
  2763. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2764. #endif
  2765. /*Generate Gamma table*/
  2766. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  2767. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2768. /*
  2769. * RGB compensation
  2770. */
  2771. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  2772. table_index = find_cadela_table(pSmart->brightness_level);
  2773. if (table_index == -1) {
  2774. table_index = CCG6_MAX_TABLE;
  2775. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  2776. __func__, cnt, pSmart->brightness_level);
  2777. }
  2778. if (cnt < 3) {
  2779. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  2780. level_V255 +=
  2781. rgb_offset_K_wqhd_revB[table_index][cnt];
  2782. level_255_temp_MSB = level_V255 / 256;
  2783. str[cnt * 2] = level_255_temp_MSB & 0xff;
  2784. str[(cnt * 2) + 1] = level_V255 & 0xff;
  2785. } else {
  2786. str[cnt+3] += rgb_offset_K_wqhd_revB[table_index][cnt];
  2787. }
  2788. }
  2789. /*subtration MTP_OFFSET value from generated gamma table*/
  2790. mtp_offset_substraction(pSmart, str);
  2791. }
  2792. static int gradation_offset_K_wqhd_revE[][9] = {
  2793. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  2794. {0, 5, 9, 12, 15, 16, 17, 18, 18},
  2795. {0, 9, 16, 21, 26, 28, 29, 30, 30},
  2796. {0, 8, 15, 19, 22, 24, 24, 26, 26},
  2797. {0, 8, 14, 18, 20, 21, 22, 24, 25},
  2798. {0, 7, 13, 16, 18, 19, 20, 22, 22},
  2799. {0, 7, 13, 15, 17, 18, 18, 20, 20},
  2800. {0, 6, 11, 13, 15, 16, 17, 19, 19},
  2801. {0, 5, 9, 12, 14, 14, 15, 16, 16},
  2802. {0, 6, 10, 12, 14, 14, 14, 15, 15},
  2803. {0, 5, 9, 11, 13, 13, 14, 15, 15},
  2804. {0, 5, 9, 10, 12, 12, 12, 13, 14},
  2805. {0, 5, 9, 10, 12, 12, 12, 13, 14},
  2806. {0, 5, 8, 9, 11, 11, 11, 13, 14},
  2807. {0, 5, 8, 9, 11, 11, 11, 12, 12},
  2808. {0, 5, 8, 8, 10, 10, 10, 12, 12},
  2809. {0, 4, 7, 7, 9, 9, 9, 11, 15},
  2810. {0, 5, 7, 7, 9, 9, 9, 10, 10},
  2811. {0, 4, 7, 7, 9, 9, 9, 10, 10},
  2812. {0, 5, 8, 10, 11, 10, 12, 12, 13},
  2813. {0, 5, 7, 7, 8, 8, 8, 9, 10},
  2814. {0, 4, 7, 7, 7, 7, 8, 9, 9},
  2815. {0, 4, 6, 5, 7, 7, 7, 8, 8},
  2816. {0, 4, 6, 5, 6, 6, 6, 7, 7},
  2817. {0, 4, 6, 5, 6, 6, 6, 7, 7},
  2818. {0, 4, 6, 5, 6, 6, 6,7, 7},
  2819. {0, 4, 5, 5, 5, 5, 6, 6, 7},
  2820. {0, 3, 5, 4, 5, 5, 5, 5, 6},
  2821. {0, 3, 5, 4, 5, 5, 5, 5, 6},
  2822. {0, 3, 5, 4, 4, 4, 5, 5, 6},
  2823. {0, 4, 5, 4, 4, 4, 5, 4, 6},
  2824. {0, 3, 5, 3, 4, 3, 4, 4, 6},
  2825. {0, 3, 4, 3, 4, 3, 4, 4, 6},
  2826. {0, 3, 4, 2, 3, 3, 4, 3, 6},
  2827. {0, 3, 4, 2, 3, 2, 3, 2, 4},
  2828. {0, 3, 3, 2, 2, 2, 3, 2, 4},
  2829. {0, 3, 3, 2, 2, 1, 2, 1, 4},
  2830. {0, 3, 3, 1, 2, 1, 2, 1, 4},
  2831. {0, 2, 2, 1, 1, 2, 2, 1, 3},
  2832. {0, 2, 4, 2, 1, 2, 2, 2, 4},
  2833. {0, 2, 3, 2, 1, 2, 2, 2, 3},
  2834. {0, 2, 4, 2, 2, 2, 2, 1, 3},
  2835. {0, 2, 4, 2, 1, 1, 2, 1, 3},
  2836. {0, 2, 4, 3, 2, 2, 1, 1, 3},
  2837. {0, 2, 4, 3, 2, 1, 1, 1, 3},
  2838. {0, 1, 4, 3, 2, 2, 1, 1, 4},
  2839. {0, 1, 4, 3, 2, 2, 1, 1, 4},
  2840. {0, 1, 4, 2, 2, 1, 1, 1, 3},
  2841. {0, 1, 3, 3, 2, 2, 1, 1, 2},
  2842. {0, 1, 3, 2, 2, 1, 1, 1, 2},
  2843. {0, 0, 3, 2, 2, 2, 1, 0, 2},
  2844. {0, 1, 4, 3, 1, 1, 1, 0, 2},
  2845. {0, 2, 4, 3, 2, 1, 0, 0, 2},
  2846. {0, 2, 3, 3, 2, 1, 0, 0, 1},
  2847. {0, 1, 3, 2, 1, 1, 0, 0, 1},
  2848. {0, 1, 3, 2, 1, 1, 0, 0, 1},
  2849. {0, 1, 2, 1, 0, 0, -1, -1, 0},
  2850. {0, 0, 1, 0, 0, 0, -1, -1, 0},
  2851. {0, -1, 1, 0, 0, 0, -1, -1, 0},
  2852. {2, 1, 2, 1, 0, 0, 0, 0, 0},
  2853. {0, 0, 1, -1, -1, 0, 0, 0, 0},
  2854. {1, 1, 1, 0, 0, 0, 0, -1, 0},
  2855. {0, 0, 0, -1, -1, -1, -1, -1, 0},
  2856. {0, -1, -1, -1, -1, -1, -1, 0, 0},
  2857. {1, 0, 0, -1, -1, -1, -1, -1, 0},
  2858. {0, 0, 0, 0, 0, 0, 0, 0, 0},
  2859. };
  2860. static int rgb_offset_K_wqhd_revE[][RGB_COMPENSATION] = {
  2861. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  2862. R87 G87 B87 R51 G51 B51 R35 G35 B35
  2863. R23 G23 B23 R11 G11 B11
  2864. */
  2865. {-3, 2, -6, -2, 0, -3, -3, 1, -2, -10, 2, -6, -17, 4, -19, -5, 4, -14, -5, -1, -10, -9, 3, -15},
  2866. {-2, 1, -5, -3, 1, -4, -3, 2, -4, -10, 3, -5, -18, 3, -15, -13, 1, -14, -11, 2, -9, -7, 5, -10},
  2867. {-1, 1, -3, -2, 1, -4, -4, 0, -5, -8, 2, -4, -16, 4, -10, -13, 2, -14, -8, 5, -7, -11, 3, -16},
  2868. {-1, 0, -3, -3, 0, -4, -3, 2, -4, -7, 1, -5, -15, 3, -9, -10, 4, -11, -11, 1, -12, -7, 3, -17},
  2869. {-1, 0, -3, -2, 0, -3, -4, 1, -5, -5, 1, -3, -13, 3, -6, -11, 3, -11, -12, 1, -15, -8, 3, -18},
  2870. {-1, 0, -3, -2, 0, -3, -4, 0, -5, -4, 2, -3, -12, 2, -6, -12, 1, -12, -8, 5, -12, -9, 3, -20},
  2871. {0, 0, -2, -1, 0, -2, -4, 1, -4, -4, 2, -3, -10, 2, -4, -12, 1, -11, -11, 2, -16, -12, 1, -23},
  2872. {0, 0, -2, 0, 1, -1, -3, 1, -4, -3, 1, -3, -9, 2, -4, -12, 2, -9, -10, 4, -16, -7, 6, -20},
  2873. {0, 0, -2, -2, 0, -2, -2, 1, -3, -3, 1, -4, -10, 0, -5, -9, 3, -6, -8, 6, -15, -6, 7, -21},
  2874. {0, 0, -1, -1, 1, -2, -2, 0, -3, -3, 0, -4, -8, 1, -4, -10, 1, -7, -11, 2, -17, -6, 6, -22},
  2875. {0, 0, -1, -1, 1, -2, -2, 0, -3, -1, 1, -2, -8, 1, -5, -10, 1, -7, -7, 6, -14, -1, 9, -21},
  2876. {0, 0, -1, -1, 0, -2, -2, 0, -3, -2, 0, -3, -8, 1, -5, -9, 1, -6, -7, 5, -14, -5, 8, -24},
  2877. {0, 0, -1, -1, 0, -2, -2, 0, -3, -2, 0, -2, -7, 1, -5, -9, 1, -6, -8, 5, -13, -8, 3, -26},
  2878. {0, 0, -1, -1, 0, -2, -2, 0, -3, -1, 0, -2, -8, 0, -7, -10, 0, -6, -11, 3, -11, -6, 8, -24},
  2879. {1, 0, 0, -2, 0, -2, -2, 0, -3, 1, 1, -1, -9, 0, -8, -9, 1, -6, -7, 4, -9, -13, 3, -28},
  2880. {1, 0, 0, -1, 1, -1, -2, 1, -2, 0, 1, -1, -7, 1, -6, -8, 1, -6, -9, 4, -9, -10, 4, -27},
  2881. {1, 0, 0, -2, 0, -2, -1, 1, -2, -1, 1, 0, -7, 0, -7, -9, 0, -6, -9, 2, -10, -4, 9, -24},
  2882. {1, 0, 0, 0, 0, -1, -4, 1, -3, 0, 0, 0, -7, 0, -7, -8, 0, -5, -11, 1, -12, -5, 8, -25},
  2883. {1, 0, 0, -1, 0, -2, -1, 0, -2, -3, 1, -3, -5, 1, -5, -8, 3, -4, -20, 2, -17, -30, 13, -24},
  2884. {1, 0, 0, -2, 0, -2, -1, 0, -2, -1, 0, -1, -4, 1, -3, -6, 1, -4, -6, 4, -12, -1, 7, -27},
  2885. {1, 0, 0, -1, 0, -1, -2, 0, -3, 0, 0, 0, -3, 1, -3, -7, 1, -5, -7, 0, -12, -6, 3, -31},
  2886. {1, 0, 0, -1, 0, -1, -1, 1, -2, 0, 0, 0, -4, 1, -3, -7, 0, -5, -4, 4, -11, -2, 5, -28},
  2887. {0, 0, 0, 0, 0, -1, -2, 0, -3, 0, 0, 1, -4, 1, -4, -3, 1, -4, -4, 3, -11, -1, 7, -28},
  2888. {0, 0, 0, 0, 0, -1, -2, 0, -2, 0, 0, 0, -3, 1, -3, -6, 0, -6, 0, 4, -8, -4, 5, -31},
  2889. {0, 0, 0, 0, 0, -1, -1, 0, -2, -1, 0, 0, -3, 1, -3, -4, 0, -5, -3, 3, -9, -6, 3, -33},
  2890. {0, 0, 0, 0, 0, -1, -2, 0, -2, 0, 0, 0, -2, 1, -2, -3, 1, -4, -5, 0, -11, 1, 8, -29},
  2891. {0, 0, 0, 1, 1, -1, -1, 0, -2, 0, 0, 1, -3, 1, -3, -4, 0, -5, 2, 4, -6, 4, 8, -28},
  2892. {0, 0, 0, 1, 1, -1, -2, 0, -2, 0, 0, 1, -2, 0, -3, -3, 0, -4, 0, 2, -7, 1, 6, -30},
  2893. {1, 0, 1, 0, 1, -2, -2, 0, -2, 1, 0, 2, -2, 1, -3, -3, 1, -3, 0, 1, -7, -1, 4, -31},
  2894. {1, 0, 1, -1, 0, -2, -1, 0, -1, 0, 0, 1, -2, 0, -3, -3, 1, -3, -1, 0, -7, 7, 10, -28},
  2895. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, 0, 2, -2, 0, -3, -1, 1, -3, 2, 2, -5, -1, 4, -32},
  2896. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, -1, 2, -3, 0, -3, 0, 1, -3, 1, 1, -6, -3, 1, -34},
  2897. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, 0, 2, -2, 0, -3, -2, 0, -4, 1, 0, -5, 17, 6, -23},
  2898. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, 0, 2, -2, 0, -3, -1, 2, -3, 6, 1, -3, 30, 6, -17},
  2899. {1, 0, 1, 0, 1, -1, 0, 0, 0, 0, 0, 2, -1, 1, -3, -3, 0, -3, 5, 1, -3, 29, 4, -19},
  2900. {1, 0, 1, 0, 1, -1, -1, 0, -1, 1, 0, 3, 0, 2, -2, 0, 1, -2, 8, 2, -2, 41, 3, -14},
  2901. {1, 0, 1, 0, 1, -1, -1, 0, 0, 2, 0, 3, -2, 0, -3, 0, 0, -2, 7, 1, -3, 44, 4, -10},
  2902. {1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 2, 0, 0, -3, -2, 0, -4, 5, 0, -2, 40, 6, -8},
  2903. {2, 0, 0, 0, 0, 0, -2, 0, -2, 2, 0, 3, -1, 0, -2, 0, 0, -3, 6, 0, -2, 20, 0, -19},
  2904. {1, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, 3, 0, 0, -2, 1, 1, -3, 5, 0, -2, 22, 0, -17},
  2905. {1, 0, 1, 0, 0, -1, -1, 0, -2, 2, 0, 3, -1, 0, -1, 0, 0, -3, 4, 0, -2, 23, 1, -16},
  2906. {1, 0, 0, -1, 0, -2, -1, 0, 0, 2, 0, 3, -2, 0, -2, 0, 0, -3, 4, 0, -2, 25, 3, -14},
  2907. {1, 0, 1, 0, 0, -1, -1, 0, 0, 2, 0, 2, -1, 0, -1, 0, 0, -3, 6, 1, 0, 25, 3, -13},
  2908. {1, 0, 1, -1, 0, -2, 0, 0, -1, 1, 0, 2, 0, 0, -1, 1, 1, -2, 6, 0, 0, 22, 1, -14},
  2909. {1, 0, 1, -1, 0, -1, 0, 0, -1, 2, 0, 2, -2, 0, -1, 0, 0, -3, 3, 0, -1, 12, 0, -18},
  2910. {2, 0, 2, -1, 0, -2, -1, 0, -1, 1, 0, 2, 0, 0, 0, 0, 0, -2, 4, 0, -1, 12, 1, -17},
  2911. {1, 0, 1, 0, 0, -1, -1, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, -2, 3, 0, -1, 12, 0, -16},
  2912. {1, 0, 2, 0, 0, -2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -3, 3, 0, -1, 15, 1, -14},
  2913. {1, 0, 2, 0, 0, -1, 0, 1, 0, 1, 0, 1, -1, 0, 0, 1, 0, -1, 4, 0, -1, 11, -1, -16},
  2914. {0, 0, 1, 1, 0, -1, -1, 0, -1, 1, 0, 2, 0, 0, 1, 1, 0, -1, 2, 1, -2, 18, 3, -9},
  2915. {0, 0, 1, 1, 0, -1, -1, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 5, 2, 0, 16, 3, -8},
  2916. {0, 0, 1, 0, 0, -1, 0, 0, -1, 1, 0, 1, 0, 0, 2, 2, 0, 0, 3, 1, -2, 17, 4, -7},
  2917. {0, 0, 1, 1, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 0, -1, 4, 1, -1, 14, 0, -9},
  2918. {0, 0, 1, 1, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 1, 0, -1, 4, 0, -1, 14, 0, -8},
  2919. {0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 1, 0, -1, 5, 0, 0, 14, 0, -7},
  2920. {0, 0, 1, 0, 0, -1, 0, 0, -1, 1, 0, 2, 0, 0, 1, 2, 0, -1, 7, 1, 0, 26, 0, -1},
  2921. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 0, -2, 7, 0, 0, 27, 0, 0},
  2922. {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2, 3, 0, -1, 6, 0, -1, 27, 0, 0},
  2923. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2924. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2925. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2926. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2927. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2928. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2929. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2930. };
  2931. static void gamma_init_K_wqhd_revE(struct SMART_DIM *pSmart, char *str, int size)
  2932. {
  2933. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  2934. int bl_index[S6E3_TABLE_MAX] = {-1, };
  2935. long long temp_cal_data = 0;
  2936. int bl_level;
  2937. int level_255_temp_MSB = 0;
  2938. int level_V255 = 0;
  2939. int point_index;
  2940. int cnt;
  2941. int table_index;
  2942. pr_debug("%s : start !!\n",__func__);
  2943. /*calculate candela level */
  2944. if (pSmart->brightness_level >= 249) {
  2945. /* 249CD ~ 350CD */
  2946. bl_level = pSmart->brightness_level;
  2947. } else if ((pSmart->brightness_level < 249) &&
  2948. (pSmart->brightness_level > 152)) {
  2949. /* 162CD ~ 234CD */
  2950. bl_level = 249;
  2951. } else if ((pSmart->brightness_level <= 152) &&
  2952. (pSmart->brightness_level >= 68)) {
  2953. /* 68CD ~ 143CD */
  2954. if (pSmart->brightness_level == 68)
  2955. bl_level = 114;
  2956. else if (pSmart->brightness_level == 72)
  2957. bl_level = 121;
  2958. else if (pSmart->brightness_level == 77)
  2959. bl_level = 129;
  2960. else if (pSmart->brightness_level == 82)
  2961. bl_level = 136;
  2962. else if (pSmart->brightness_level == 87)
  2963. bl_level = 146;
  2964. else if (pSmart->brightness_level == 93)
  2965. bl_level = 153;
  2966. else if (pSmart->brightness_level == 98)
  2967. bl_level = 159;
  2968. else if (pSmart->brightness_level == 105)
  2969. bl_level = 171;
  2970. else if (pSmart->brightness_level == 111)
  2971. bl_level = 180;
  2972. else if (pSmart->brightness_level == 119)
  2973. bl_level = 190;
  2974. else if (pSmart->brightness_level == 126)
  2975. bl_level = 201;
  2976. else if (pSmart->brightness_level == 134)
  2977. bl_level = 213;
  2978. else if (pSmart->brightness_level == 143)
  2979. bl_level = 227;
  2980. else if (pSmart->brightness_level == 152)
  2981. bl_level = 236;
  2982. else
  2983. bl_level = 236;
  2984. }
  2985. else if(pSmart->brightness_level == 2)
  2986. bl_level = 33;
  2987. else {
  2988. /* 60CD ~ 2CD */
  2989. bl_level = AOR_DIM_BASE_CD;
  2990. }
  2991. if (pSmart->brightness_level < 350) {
  2992. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  2993. point_index = S6E3_ARRAY[cnt+1];
  2994. temp_cal_data =
  2995. ((long long)(candela_coeff_2p15[point_index])) *
  2996. ((long long)(bl_level));
  2997. candela_level[cnt] = temp_cal_data;
  2998. }
  2999. } else {
  3000. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3001. point_index = S6E3_ARRAY[cnt+1];
  3002. temp_cal_data =
  3003. ((long long)(candela_coeff_2p2[point_index])) *
  3004. ((long long)(bl_level));
  3005. candela_level[cnt] = temp_cal_data;
  3006. }
  3007. }
  3008. #ifdef SMART_DIMMING_DEBUG
  3009. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3010. candela_level[0], candela_level[1], candela_level[2]);
  3011. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3012. candela_level[3], candela_level[4], candela_level[5]);
  3013. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3014. candela_level[6], candela_level[7], candela_level[8]);
  3015. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  3016. #endif
  3017. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3018. if (searching_function(candela_level[cnt],
  3019. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3020. pr_info("%s searching functioin error cnt:%d\n",
  3021. __func__, cnt);
  3022. }
  3023. }
  3024. /*
  3025. * Candela compensation
  3026. */
  3027. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  3028. table_index = find_cadela_table(pSmart->brightness_level);
  3029. if (table_index == -1) {
  3030. table_index = CCG6_MAX_TABLE;
  3031. pr_info("%s fail candela table_index cnt : %d brightness %d",
  3032. __func__, cnt, pSmart->brightness_level);
  3033. }
  3034. bl_index[S6E3_TABLE_MAX - cnt] +=
  3035. gradation_offset_K_wqhd_revE[table_index][cnt - 1];
  3036. /* THERE IS M-GRAY0 target */
  3037. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  3038. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  3039. }
  3040. #ifdef SMART_DIMMING_DEBUG
  3041. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3042. bl_index[0], bl_index[1], bl_index[2]);
  3043. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3044. bl_index[3], bl_index[4], bl_index[5]);
  3045. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3046. bl_index[6], bl_index[7], bl_index[8]);
  3047. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3048. #endif
  3049. /*Generate Gamma table*/
  3050. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3051. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3052. /*
  3053. * RGB compensation
  3054. */
  3055. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  3056. table_index = find_cadela_table(pSmart->brightness_level);
  3057. if (table_index == -1) {
  3058. table_index = CCG6_MAX_TABLE;
  3059. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  3060. __func__, cnt, pSmart->brightness_level);
  3061. }
  3062. if (cnt < 3) {
  3063. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  3064. level_V255 +=
  3065. rgb_offset_K_wqhd_revE[table_index][cnt];
  3066. level_255_temp_MSB = level_V255 / 256;
  3067. str[cnt * 2] = level_255_temp_MSB & 0xff;
  3068. str[(cnt * 2) + 1] = level_V255 & 0xff;
  3069. } else {
  3070. str[cnt+3] += rgb_offset_K_wqhd_revE[table_index][cnt];
  3071. }
  3072. }
  3073. /*subtration MTP_OFFSET value from generated gamma table*/
  3074. mtp_offset_substraction(pSmart, str);
  3075. }
  3076. static int gradation_offset_K_wqhd_revF[][9] = {
  3077. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  3078. {0, 5, 9, 12, 14, 15, 15, 16, 17},
  3079. {15, 15, 17, 16, 16, 17, 17, 17, 18},
  3080. {27, 25, 25, 21, 20, 19, 19, 19, 20},
  3081. {0, 8, 14, 18, 20, 21, 21, 23, 24},
  3082. {0, 7, 13, 16, 17, 18, 18, 20, 21},
  3083. {0, 7, 12, 14, 16, 16, 17, 19, 20},
  3084. {0, 6, 11, 13, 14, 14, 15, 16, 18},
  3085. {0, 6, 10, 12, 13, 13, 14, 15, 16},
  3086. {0, 6, 10, 12, 14, 14, 14, 15, 15},
  3087. {0, 5, 9, 11, 13, 13, 14, 15, 15},
  3088. {0, 5, 9, 10, 12, 12, 12, 13, 14},
  3089. {0, 5, 9, 10, 12, 12, 12, 13, 14},
  3090. {0, 5, 8, 9, 11, 11, 11, 13, 14},
  3091. {0, 5, 8, 9, 11, 11, 11, 12, 12},
  3092. {0, 5, 8, 8, 10, 10, 10, 12, 12},
  3093. {0, 4, 7, 7, 9, 9, 9, 11, 15},
  3094. {0, 5, 7, 7, 9, 9, 9, 10, 10},
  3095. {0, 4, 7, 7, 9, 9, 9, 10, 10},
  3096. {0, 5, 8, 10, 11, 10, 12, 12, 13},
  3097. {0, 5, 7, 7, 8, 8, 8, 9, 10},
  3098. {0, 4, 7, 7, 7, 7, 8, 9, 9},
  3099. {0, 4, 6, 5, 7, 7, 7, 8, 8},
  3100. {0, 4, 6, 5, 6, 6, 6, 7, 7},
  3101. {0, 4, 6, 5, 6, 6, 6, 7, 7},
  3102. {0, 4, 6, 5, 6, 6, 6, 7, 7},
  3103. {0, 4, 5, 5, 5, 5, 6, 6, 7},
  3104. {0, 3, 5, 4, 5, 5, 5, 5, 6},
  3105. {0, 3, 5, 4, 5, 5, 5, 5, 6},
  3106. {0, 3, 5, 4, 4, 4, 5, 5, 6},
  3107. {0, 4, 5, 4, 4, 4, 5, 4, 6},
  3108. {0, 3, 5, 3, 4, 3, 4, 4, 6},
  3109. {0, 3, 4, 3, 4, 3, 4, 4, 6},
  3110. {0, 3, 4, 2, 3, 3, 4, 3, 6},
  3111. {0, 3, 4, 2, 3, 2, 3, 2, 4},
  3112. {0, 3, 3, 2, 2, 2, 3, 2, 4},
  3113. {0, 3, 3, 2, 2, 1, 2, 1, 4},
  3114. {0, 3, 3, 1, 2, 1, 2, 1, 4},
  3115. {0, 2, 2, 1, 1, 2, 2, 1, 3},
  3116. {0, 2, 4, 2, 1, 2, 2, 2, 4},
  3117. {0, 2, 3, 2, 1, 2, 2, 2, 3},
  3118. {0, 2, 4, 2, 2, 2, 2, 1, 3},
  3119. {0, 2, 4, 2, 1, 1, 2, 1, 3},
  3120. {0, 2, 4, 3, 2, 2, 1, 1, 3},
  3121. {0, 2, 4, 3, 2, 1, 1, 1, 3},
  3122. {0, 1, 4, 3, 2, 2, 1, 1, 4},
  3123. {0, 1, 4, 3, 2, 2, 1, 1, 4},
  3124. {0, 1, 4, 2, 2, 1, 1, 1, 3},
  3125. {0, 1, 3, 3, 2, 2, 1, 1, 2},
  3126. {0, 1, 3, 2, 2, 1, 1, 1, 2},
  3127. {0, 0, 3, 2, 2, 2, 1, 0, 2},
  3128. {0, 1, 4, 3, 1, 1, 1, 0, 2},
  3129. {0, 2, 4, 3, 2, 1, 0, 0, 2},
  3130. {0, 2, 3, 3, 2, 1, 0, 0, 1},
  3131. {0, 1, 3, 2, 1, 1, 0, 0, 1},
  3132. {0, 1, 3, 2, 1, 1, 0, 0, 1},
  3133. {0, 1, 2, 1, 0, 0, -1, -1, 0},
  3134. {0, 0, 1, 0, 0, 0, -1, -1, 0},
  3135. {0, -1, 1, 0, 0, 0, -1, -1, 0},
  3136. {2, 1, 2, 1, 0, 0, 0, 0, 0},
  3137. {0, 0, 1, -1, -1, 0, 0, 0, 0},
  3138. {1, 1, 1, 0, 0, 0, 0, -1, 0},
  3139. {0, 0, 0, -1, -1, -1, -1, -1, 0},
  3140. {0, -1, -1, -1, -1, -1, -1, 0, 0},
  3141. {1, 0, 0, -1, -1, -1, -1, -1, 0},
  3142. {0, 0, 0, 0, 0, 0, 0, 0, 0},
  3143. };
  3144. static int rgb_offset_K_wqhd_revF[][RGB_COMPENSATION] = {
  3145. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  3146. R87 G87 B87 R51 G51 B51 R35 G35 B35
  3147. R23 G23 B23 R11 G11 B11
  3148. */
  3149. {-3, 2, -6, -2, 0, -3, -4, 0, -3, -10, 2, -6, -13, 7, -17, -5, 4, -12, -1, 4, -7, -10, 4, -12},
  3150. {-2, 1, -5, -2, 1, -3, -2, 1, -2, -6, 2, -3, -14, 5, -13, -11, 2, -17, -4, 1, -11, -5, 8, -11},
  3151. {-2, 1, -5, -2, 1, -2, -3, 0, -5, -6, 0, -3, -16, 3, -11, -10, 3, -15, -8, 1, -13, -10, 2, -16},
  3152. {-1, 0, -4, -3, 0, -4, -3, 1, -5, -5, 2, -4, -15, 2, -9, -11, 4, -10, -9, 3, -11, -10, 5, -16},
  3153. {-1, 0, -3, -2, 1, -3, -3, 1, -5, -4, 2, -3, -11, 5, -6, -12, 2, -11, -8, 6, -12, -9, 4, -17},
  3154. {-1, 0, -3, -2, 1, -3, -2, 1, -4, -3, 2, -3, -12, 2, -7, -9, 4, -8, -10, 3, -16, -9, 2, -19},
  3155. {0, 0, -2, -2, 1, -3, -3, 1, -3, -2, 2, -2, -8, 4, -4, -9, 4, -7, -9, 4, -15, -7, 5, -18},
  3156. {0, 0, -2, -2, 1, -3, -2, 2, -2, -1, 2, -3, -8, 4, -3, -9, 3, -7, -9, 3, -16, -4, 6, -19},
  3157. {0, 0, -2, -2, 0, -2, -2, 1, -3, -3, 1, -4, -10, 0, -5, -9, 3, -6, -8, 6, -15, -6, 7, -21},
  3158. {0, 0, -1, -1, 1, -2, -2, 0, -3, -3, 0, -4, -8, 1, -4, -10, 1, -7, -11, 2, -17, -6, 6, -22},
  3159. {0, 0, -1, -1, 1, -2, -2, 0, -3, -1, 1, -2, -8, 1, -5, -10, 1, -7, -7, 6, -14, -1, 9, -21},
  3160. {0, 0, -1, -1, 0, -2, -2, 0, -3, -2, 0, -3, -8, 1, -5, -9, 1, -6, -7, 5, -14, -5, 8, -24},
  3161. {0, 0, -1, -1, 0, -2, -2, 0, -3, -2, 0, -2, -7, 1, -5, -9, 1, -6, -8, 5, -13, -8, 3, -26},
  3162. {0, 0, -1, -1, 0, -2, -2, 0, -3, -1, 0, -2, -8, 0, -7, -10, 0, -6, -11, 3, -11, -6, 8, -24},
  3163. {1, 0, 0, -2, 0, -2, -2, 0, -3, 1, 1, -1, -9, 0, -8, -9, 1, -6, -7, 4, -9, -13, 3, -28},
  3164. {1, 0, 0, -1, 1, -1, -2, 1, -2, 0, 1, -1, -7, 1, -6, -8, 1, -6, -9, 4, -9, -10, 4, -27},
  3165. {1, 0, 0, -2, 0, -2, -1, 1, -2, -1, 1, 0, -7, 0, -7, -9, 0, -6, -9, 2, -10, -4, 9, -24},
  3166. {1, 0, 0, 0, 0, -1, -4, 1, -3, 0, 0, 0, -7, 0, -7, -8, 0, -5, -11, 1, -12, -5, 8, -25},
  3167. {1, 0, 0, -1, 0, -2, -1, 0, -2, -3, 1, -3, -5, 1, -5, -8, 3, -4, -20, 2, -17, -30, 13, -24},
  3168. {1, 0, 0, -2, 0, -2, -1, 0, -2, -1, 0, -1, -4, 1, -3, -6, 1, -4, -6, 4, -12, -1, 7, -27},
  3169. {1, 0, 0, -1, 0, -1, -2, 0, -3, 0, 0, 0, -3, 1, -3, -7, 1, -5, -7, 0, -12, -6, 3, -31},
  3170. {1, 0, 0, -1, 0, -1, -1, 1, -2, 0, 0, 0, -4, 1, -3, -7, 0, -5, -4, 4, -11, -2, 5, -28},
  3171. {0, 0, 0, 0, 0, -1, -2, 0, -3, 0, 0, 1, -4, 1, -4, -3, 1, -4, -4, 3, -11, -1, 7, -28},
  3172. {0, 0, 0, 0, 0, -1, -2, 0, -2, 0, 0, 0, -3, 1, -3, -6, 0, -6, 0, 4, -8, -4, 5, -31},
  3173. {0, 0, 0, 0, 0, -1, -1, 0, -2, -1, 0, 0, -3, 1, -3, -4, 0, -5, -3, 3, -9, -6, 3, -33},
  3174. {0, 0, 0, 0, 0, -1, -2, 0, -2, 0, 0, 0, -2, 1, -2, -3, 1, -4, -5, 0, -11, 1, 8, -29},
  3175. {0, 0, 0, 1, 1, -1, -1, 0, -2, 0, 0, 1, -3, 1, -3, -4, 0, -5, 2, 4, -6, 4, 8, -28},
  3176. {0, 0, 0, 1, 1, -1, -2, 0, -2, 0, 0, 1, -2, 0, -3, -3, 0, -4, 0, 2, -7, 1, 6, -30},
  3177. {1, 0, 1, 0, 1, -2, -2, 0, -2, 1, 0, 2, -2, 1, -3, -3, 1, -3, 0, 1, -7, -1, 4, -31},
  3178. {1, 0, 1, -1, 0, -2, -1, 0, -1, 0, 0, 1, -2, 0, -3, -3, 1, -3, -1, 0, -7, 7, 10, -28},
  3179. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, 0, 2, -2, 0, -3, -1, 1, -3, 2, 2, -5, -1, 4, -32},
  3180. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, -1, 2, -3, 0, -3, 0, 1, -3, 1, 1, -6, -3, 1, -34},
  3181. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, 0, 2, -2, 0, -3, -2, 0, -4, 1, 0, -5, 17, 6, -23},
  3182. {1, 0, 1, 0, 1, -1, -1, 0, -2, 1, 0, 2, -2, 0, -3, -1, 2, -3, 6, 1, -3, 30, 6, -17},
  3183. {1, 0, 1, 0, 1, -1, 0, 0, 0, 0, 0, 2, -1, 1, -3, -3, 0, -3, 5, 1, -3, 29, 4, -19},
  3184. {1, 0, 1, 0, 1, -1, -1, 0, -1, 1, 0, 3, 0, 2, -2, 0, 1, -2, 8, 2, -2, 41, 3, -14},
  3185. {1, 0, 1, 0, 1, -1, -1, 0, 0, 2, 0, 3, -2, 0, -3, 0, 0, -2, 7, 1, -3, 44, 4, -10},
  3186. {1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 2, 0, 0, -3, -2, 0, -4, 5, 0, -2, 40, 6, -8},
  3187. {2, 0, 0, 0, 0, 0, -2, 0, -2, 2, 0, 3, -1, 0, -2, 0, 0, -3, 6, 0, -2, 20, 0, -19},
  3188. {1, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, 3, 0, 0, -2, 1, 1, -3, 5, 0, -2, 22, 0, -17},
  3189. {1, 0, 1, 0, 0, -1, -1, 0, -2, 2, 0, 3, -1, 0, -1, 0, 0, -3, 4, 0, -2, 23, 1, -16},
  3190. {1, 0, 0, -1, 0, -2, -1, 0, 0, 2, 0, 3, -2, 0, -2, 0, 0, -3, 4, 0, -2, 25, 3, -14},
  3191. {1, 0, 1, 0, 0, -1, -1, 0, 0, 2, 0, 2, -1, 0, -1, 0, 0, -3, 6, 1, 0, 25, 3, -13},
  3192. {1, 0, 1, -1, 0, -2, 0, 0, -1, 1, 0, 2, 0, 0, -1, 1, 1, -2, 6, 0, 0, 22, 1, -14},
  3193. {1, 0, 1, -1, 0, -1, 0, 0, -1, 2, 0, 2, -2, 0, -1, 0, 0, -3, 3, 0, -1, 12, 0, -18},
  3194. {2, 0, 2, -1, 0, -2, -1, 0, -1, 1, 0, 2, 0, 0, 0, 0, 0, -2, 4, 0, -1, 12, 1, -17},
  3195. {1, 0, 1, 0, 0, -1, -1, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, -2, 3, 0, -1, 12, 0, -16},
  3196. {1, 0, 2, 0, 0, -2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -3, 3, 0, -1, 15, 1, -14},
  3197. {1, 0, 2, 0, 0, -1, 0, 1, 0, 1, 0, 1, -1, 0, 0, 1, 0, -1, 4, 0, -1, 11, -1, -16},
  3198. {0, 0, 1, 1, 0, -1, -1, 0, -1, 1, 0, 2, 0, 0, 1, 1, 0, -1, 2, 1, -2, 18, 3, -9},
  3199. {0, 0, 1, 1, 0, -1, -1, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 5, 2, 0, 16, 3, -8},
  3200. {0, 0, 1, 0, 0, -1, 0, 0, -1, 1, 0, 1, 0, 0, 2, 2, 0, 0, 3, 1, -2, 17, 4, -7},
  3201. {0, 0, 1, 1, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 0, -1, 4, 1, -1, 14, 0, -9},
  3202. {0, 0, 1, 1, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 1, 0, -1, 4, 0, -1, 14, 0, -8},
  3203. {0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 1, 0, -1, 5, 0, 0, 14, 0, -7},
  3204. {0, 0, 1, 0, 0, -1, 0, 0, -1, 1, 0, 2, 0, 0, 1, 2, 0, -1, 7, 1, 0, 26, 0, -1},
  3205. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 0, -2, 7, 0, 0, 27, 0, 0},
  3206. {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2, 3, 0, -1, 6, 0, -1, 27, 0, 0},
  3207. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3208. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3209. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3210. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3211. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3212. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3213. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  3214. };
  3215. static void gamma_init_K_wqhd_revF(struct SMART_DIM *pSmart, char *str, int size)
  3216. {
  3217. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  3218. int bl_index[S6E3_TABLE_MAX] = {-1, };
  3219. long long temp_cal_data = 0;
  3220. int bl_level;
  3221. int level_255_temp_MSB = 0;
  3222. int level_V255 = 0;
  3223. int point_index;
  3224. int cnt;
  3225. int table_index;
  3226. pr_debug("%s : start !!\n",__func__);
  3227. /*calculate candela level */
  3228. if (pSmart->brightness_level >= 249) {
  3229. /* 249CD ~ 350CD */
  3230. bl_level = pSmart->brightness_level;
  3231. } else if ((pSmart->brightness_level < 249) &&
  3232. (pSmart->brightness_level > 152)) {
  3233. /* 162CD ~ 234CD */
  3234. bl_level = 249;
  3235. } else if ((pSmart->brightness_level <= 152) &&
  3236. (pSmart->brightness_level >= 68)) {
  3237. /* 68CD ~ 143CD */
  3238. if (pSmart->brightness_level == 68)
  3239. bl_level = 114;
  3240. else if (pSmart->brightness_level == 72)
  3241. bl_level = 121;
  3242. else if (pSmart->brightness_level == 77)
  3243. bl_level = 129;
  3244. else if (pSmart->brightness_level == 82)
  3245. bl_level = 136;
  3246. else if (pSmart->brightness_level == 87)
  3247. bl_level = 146;
  3248. else if (pSmart->brightness_level == 93)
  3249. bl_level = 153;
  3250. else if (pSmart->brightness_level == 98)
  3251. bl_level = 159;
  3252. else if (pSmart->brightness_level == 105)
  3253. bl_level = 171;
  3254. else if (pSmart->brightness_level == 111)
  3255. bl_level = 180;
  3256. else if (pSmart->brightness_level == 119)
  3257. bl_level = 190;
  3258. else if (pSmart->brightness_level == 126)
  3259. bl_level = 201;
  3260. else if (pSmart->brightness_level == 134)
  3261. bl_level = 213;
  3262. else if (pSmart->brightness_level == 143)
  3263. bl_level = 227;
  3264. else if (pSmart->brightness_level == 152)
  3265. bl_level = 236;
  3266. else
  3267. bl_level = 236;
  3268. }
  3269. else if ((pSmart->brightness_level <= 4) &&
  3270. (pSmart->brightness_level >= 2)) {
  3271. bl_level = 33;
  3272. } else {
  3273. /* 60CD ~ 2CD */
  3274. bl_level = AOR_DIM_BASE_CD;
  3275. }
  3276. if (pSmart->brightness_level < 350) {
  3277. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3278. point_index = S6E3_ARRAY[cnt+1];
  3279. temp_cal_data =
  3280. ((long long)(candela_coeff_2p15[point_index])) *
  3281. ((long long)(bl_level));
  3282. candela_level[cnt] = temp_cal_data;
  3283. }
  3284. } else {
  3285. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3286. point_index = S6E3_ARRAY[cnt+1];
  3287. temp_cal_data =
  3288. ((long long)(candela_coeff_2p2[point_index])) *
  3289. ((long long)(bl_level));
  3290. candela_level[cnt] = temp_cal_data;
  3291. }
  3292. }
  3293. #ifdef SMART_DIMMING_DEBUG
  3294. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3295. candela_level[0], candela_level[1], candela_level[2]);
  3296. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3297. candela_level[3], candela_level[4], candela_level[5]);
  3298. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3299. candela_level[6], candela_level[7], candela_level[8]);
  3300. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  3301. #endif
  3302. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3303. if (searching_function(candela_level[cnt],
  3304. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3305. pr_info("%s searching functioin error cnt:%d\n",
  3306. __func__, cnt);
  3307. }
  3308. }
  3309. /*
  3310. * Candela compensation
  3311. */
  3312. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  3313. table_index = find_cadela_table(pSmart->brightness_level);
  3314. if (table_index == -1) {
  3315. table_index = CCG6_MAX_TABLE;
  3316. pr_info("%s fail candela table_index cnt : %d brightness %d",
  3317. __func__, cnt, pSmart->brightness_level);
  3318. }
  3319. bl_index[S6E3_TABLE_MAX - cnt] +=
  3320. gradation_offset_K_wqhd_revF[table_index][cnt - 1];
  3321. /* THERE IS M-GRAY0 target */
  3322. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  3323. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  3324. }
  3325. #ifdef SMART_DIMMING_DEBUG
  3326. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3327. bl_index[0], bl_index[1], bl_index[2]);
  3328. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3329. bl_index[3], bl_index[4], bl_index[5]);
  3330. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3331. bl_index[6], bl_index[7], bl_index[8]);
  3332. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3333. #endif
  3334. /*Generate Gamma table*/
  3335. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3336. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3337. /*
  3338. * RGB compensation
  3339. */
  3340. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  3341. table_index = find_cadela_table(pSmart->brightness_level);
  3342. if (table_index == -1) {
  3343. table_index = CCG6_MAX_TABLE;
  3344. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  3345. __func__, cnt, pSmart->brightness_level);
  3346. }
  3347. if (cnt < 3) {
  3348. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  3349. level_V255 +=
  3350. rgb_offset_K_wqhd_revF[table_index][cnt];
  3351. level_255_temp_MSB = level_V255 / 256;
  3352. str[cnt * 2] = level_255_temp_MSB & 0xff;
  3353. str[(cnt * 2) + 1] = level_V255 & 0xff;
  3354. } else {
  3355. str[cnt+3] += rgb_offset_K_wqhd_revF[table_index][cnt];
  3356. }
  3357. }
  3358. /*subtration MTP_OFFSET value from generated gamma table*/
  3359. mtp_offset_substraction(pSmart, str);
  3360. }
  3361. #define CCG6_MAX_TABLE_HMT 3
  3362. static int ccg6_candela_table_hmt[][2] = {
  3363. {80, 0,},
  3364. {95, 1,},
  3365. {115, 2,},
  3366. {130, 3,},
  3367. };
  3368. static int find_cadela_table_hmt(int brightness)
  3369. {
  3370. int loop;
  3371. int err = -1;
  3372. for(loop = 0; loop <= CCG6_MAX_TABLE_HMT; loop++)
  3373. if (ccg6_candela_table_hmt[loop][0] == brightness)
  3374. return ccg6_candela_table_hmt[loop][1];
  3375. return err;
  3376. }
  3377. static int gradation_offset_K_fhd_revE_hmt[][9] = {
  3378. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  3379. {0, 5, 11, 9, 13, 14, 16, 18, 14},
  3380. {0, 5, 9, 7, 11, 12, 11, 15, 13},
  3381. {0, 5, 9, 7, 9, 9, 11, 13, 12},
  3382. {0, 3, 5, 8, 10, 8, 11, 13, 13},
  3383. };
  3384. static int rgb_offset_K_fhd_revE_hmt[][RGB_COMPENSATION] = {
  3385. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  3386. R87 G87 B87 R51 G51 B51 R35 G35 B35
  3387. R23 G23 B23 R11 G11 B11
  3388. */
  3389. {-3, -2, -3, 0, 0, 0, 0, 1, -1, -1, 1, -1, -2, 0, -5, -2, 1, -6, -5, -3, 3, 3, 6, -11},
  3390. {0, 1, 2, 1, 0, 1, 0, 0, -1, 0, 3, 0, -2, 0, -4, -3, 0, -7, 2, 4, 7, 1, 5, -12},
  3391. {-1, -1, -1, 0, 0, 0, 0, 1, -1, 0, 2, 0, 0, 1, -2, -2, 1, -4, -2, 0, 4, 0, 4, -14},
  3392. {-3, -1, -2, 1, 0, 1, 1, 1, -1, -1, 0, -1, 1, 2, -1, 1, 3, -2, -3, -2, 3, -2, 3, -13},
  3393. };
  3394. static void gamma_init_K_fhd_revE_hmt(struct SMART_DIM *pSmart, char *str, int size)
  3395. {
  3396. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  3397. int bl_index[S6E3_TABLE_MAX] = {-1, };
  3398. long long temp_cal_data = 0;
  3399. int bl_level;
  3400. int level_255_temp_MSB = 0;
  3401. int level_V255 = 0;
  3402. int point_index;
  3403. int cnt;
  3404. int table_index;
  3405. pr_debug("%s : start !!\n",__func__);
  3406. /*calculate candela level */
  3407. if (pSmart->brightness_level == 80)
  3408. bl_level = 250;
  3409. else if (pSmart->brightness_level == 95)
  3410. bl_level = 270;
  3411. else if (pSmart->brightness_level == 115)
  3412. bl_level = 260;
  3413. else if (pSmart->brightness_level == 130)
  3414. bl_level = 288;
  3415. else
  3416. bl_level = 288;
  3417. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3418. point_index = S6E3_ARRAY[cnt+1];
  3419. temp_cal_data =
  3420. ((long long)(candela_coeff_2p15[point_index])) *
  3421. ((long long)(bl_level));
  3422. candela_level[cnt] = temp_cal_data;
  3423. }
  3424. #ifdef SMART_DIMMING_DEBUG
  3425. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3426. candela_level[0], candela_level[1], candela_level[2]);
  3427. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3428. candela_level[3], candela_level[4], candela_level[5]);
  3429. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3430. candela_level[6], candela_level[7], candela_level[8]);
  3431. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  3432. #endif
  3433. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3434. if (searching_function(candela_level[cnt],
  3435. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3436. pr_info("%s searching functioin error cnt:%d\n",
  3437. __func__, cnt);
  3438. }
  3439. }
  3440. /*
  3441. * Candela compensation
  3442. */
  3443. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  3444. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3445. if (table_index == -1) {
  3446. table_index = CCG6_MAX_TABLE_HMT;
  3447. pr_info("%s fail candela table_index cnt : %d brightness %d",
  3448. __func__, cnt, pSmart->brightness_level);
  3449. }
  3450. bl_index[S6E3_TABLE_MAX - cnt] +=
  3451. gradation_offset_K_fhd_revE_hmt[table_index][cnt - 1];
  3452. /* THERE IS M-GRAY0 target */
  3453. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  3454. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  3455. }
  3456. #ifdef SMART_DIMMING_DEBUG
  3457. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3458. bl_index[0], bl_index[1], bl_index[2]);
  3459. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3460. bl_index[3], bl_index[4], bl_index[5]);
  3461. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3462. bl_index[6], bl_index[7], bl_index[8]);
  3463. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3464. #endif
  3465. /*Generate Gamma table*/
  3466. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3467. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3468. /*
  3469. * RGB compensation
  3470. */
  3471. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  3472. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3473. if (table_index == -1) {
  3474. table_index = CCG6_MAX_TABLE_HMT;
  3475. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  3476. __func__, cnt, pSmart->brightness_level);
  3477. }
  3478. if (cnt < 3) {
  3479. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  3480. level_V255 +=
  3481. rgb_offset_K_fhd_revE_hmt[table_index][cnt];
  3482. level_255_temp_MSB = level_V255 / 256;
  3483. str[cnt * 2] = level_255_temp_MSB & 0xff;
  3484. str[(cnt * 2) + 1] = level_V255 & 0xff;
  3485. } else {
  3486. str[cnt+3] += rgb_offset_K_fhd_revE_hmt[table_index][cnt];
  3487. }
  3488. }
  3489. /*subtration MTP_OFFSET value from generated gamma table*/
  3490. mtp_offset_substraction(pSmart, str);
  3491. }
  3492. static int gradation_offset_K_fhd_revE_hmt_single[][9] = {
  3493. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  3494. {0, 3, 8, 8, 10, 9, 10, 10, 9},
  3495. {0, 3, 7, 7, 8, 8, 7, 9, 7},
  3496. {0, 3, 6, 5, 5, 7, 7, 8, 7},
  3497. {0, 3, 5, 2, 2, 3, 5, 8, 7},
  3498. };
  3499. static int rgb_offset_K_fhd_revE_hmt_single[][RGB_COMPENSATION] = {
  3500. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  3501. R87 G87 B87 R51 G51 B51 R35 G35 B35
  3502. R23 G23 B23 R11 G11 B11
  3503. */
  3504. {-3, -2, -3, 1, 0, 0, 0, 0, 0, -3, -1, -3, 1, 1, -1, -1, 1, -3, -5, -1, 1, 6, 10, -6},
  3505. {0, 1, 2, 2, 1, 1, 0, 0, 0, -1, 0, -1, -1, 1, -3, -2, 1, -3, 2, 3, 4, 2, 6, -7},
  3506. {-1, -1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, -1, -4, -2, -6, 1, 2, 4, 1, 4, -6},
  3507. {0, 0, 1, 0, 0, 0, 2, 1, 0, 2, 4, 3, 4, 4, 3, -2, -1, -5, 0, 1, 1, -9, -3, -12},
  3508. };
  3509. static void gamma_init_K_fhd_revE_hmt_single(struct SMART_DIM *pSmart, char *str, int size)
  3510. {
  3511. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  3512. int bl_index[S6E3_TABLE_MAX] = {-1, };
  3513. long long temp_cal_data = 0;
  3514. int bl_level;
  3515. int level_255_temp_MSB = 0;
  3516. int level_V255 = 0;
  3517. int point_index;
  3518. int cnt;
  3519. int table_index;
  3520. pr_debug("%s : start !!\n",__func__);
  3521. /*calculate candela level */
  3522. if (pSmart->brightness_level == 80)
  3523. bl_level = 250;
  3524. else if (pSmart->brightness_level == 95)
  3525. bl_level = 270;
  3526. else if (pSmart->brightness_level == 115)
  3527. bl_level = 260;
  3528. else if (pSmart->brightness_level == 130)
  3529. bl_level = 288;
  3530. else
  3531. bl_level = 333;
  3532. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3533. point_index = S6E3_ARRAY[cnt+1];
  3534. temp_cal_data =
  3535. ((long long)(candela_coeff_2p15[point_index])) *
  3536. ((long long)(bl_level));
  3537. candela_level[cnt] = temp_cal_data;
  3538. }
  3539. #ifdef SMART_DIMMING_DEBUG
  3540. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3541. candela_level[0], candela_level[1], candela_level[2]);
  3542. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3543. candela_level[3], candela_level[4], candela_level[5]);
  3544. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3545. candela_level[6], candela_level[7], candela_level[8]);
  3546. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  3547. #endif
  3548. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3549. if (searching_function(candela_level[cnt],
  3550. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3551. pr_info("%s searching functioin error cnt:%d\n",
  3552. __func__, cnt);
  3553. }
  3554. }
  3555. /*
  3556. * Candela compensation
  3557. */
  3558. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  3559. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3560. if (table_index == -1) {
  3561. table_index = CCG6_MAX_TABLE_HMT;
  3562. pr_info("%s fail candela table_index cnt : %d brightness %d",
  3563. __func__, cnt, pSmart->brightness_level);
  3564. }
  3565. bl_index[S6E3_TABLE_MAX - cnt] +=
  3566. gradation_offset_K_fhd_revE_hmt_single[table_index][cnt - 1];
  3567. /* THERE IS M-GRAY0 target */
  3568. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  3569. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  3570. }
  3571. #ifdef SMART_DIMMING_DEBUG
  3572. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3573. bl_index[0], bl_index[1], bl_index[2]);
  3574. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3575. bl_index[3], bl_index[4], bl_index[5]);
  3576. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3577. bl_index[6], bl_index[7], bl_index[8]);
  3578. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3579. #endif
  3580. /*Generate Gamma table*/
  3581. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3582. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3583. /*
  3584. * RGB compensation
  3585. */
  3586. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  3587. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3588. if (table_index == -1) {
  3589. table_index = CCG6_MAX_TABLE_HMT;
  3590. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  3591. __func__, cnt, pSmart->brightness_level);
  3592. }
  3593. if (cnt < 3) {
  3594. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  3595. level_V255 +=
  3596. rgb_offset_K_fhd_revE_hmt_single[table_index][cnt];
  3597. level_255_temp_MSB = level_V255 / 256;
  3598. str[cnt * 2] = level_255_temp_MSB & 0xff;
  3599. str[(cnt * 2) + 1] = level_V255 & 0xff;
  3600. } else {
  3601. str[cnt+3] += rgb_offset_K_fhd_revE_hmt_single[table_index][cnt];
  3602. }
  3603. }
  3604. /*subtration MTP_OFFSET value from generated gamma table*/
  3605. mtp_offset_substraction(pSmart, str);
  3606. }
  3607. static int gradation_offset_K_wqhd_hmt[][9] = {
  3608. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  3609. {0, 7, 11, 11, 14, 14, 13, 16, 6},
  3610. {0, 7, 11, 11, 11, 10, 11, 14, 5},
  3611. {0, 6, 11, 9, 9, 9, 9, 11, 5},
  3612. {0, 4, 9, 9, 9, 7, 8, 9, 5},
  3613. };
  3614. static int rgb_offset_K_wqhd_hmt[][RGB_COMPENSATION] = {
  3615. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  3616. R87 G87 B87 R51 G51 B51 R35 G35 B35
  3617. R23 G23 B23 R11 G11 B11
  3618. */
  3619. {-10, -8, -12, 1, -1, 1, -1, 1, -2, 0, 0, -3, -4, -2, -9, -3, -1, -7, 3, 3, 0, -12, 2, -20},
  3620. {-5, -3, -6, 1, 0, 2, -1, 0, -2, 0, 0, -2, 1, 1, -5, 2, 3, -3, 0, 0, -4, 2, 2, -20},
  3621. {-5, -4, -7, 1, -1, 1, -1, -1, -2, 0, 1, -2, 1, 1, -3, -1, 0, -5, 4, 4, 0, -1, 0, -23},
  3622. {-4, -3, -5, 1, 0, 2, -1, 0, -2, 0, 0, -2, 2, 2, -3, 3, 4, -1, 3, 3, -2, 3, 6, -15},
  3623. };
  3624. static void gamma_init_K_wqhd_hmt(struct SMART_DIM *pSmart, char *str, int size)
  3625. {
  3626. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  3627. int bl_index[S6E3_TABLE_MAX] = {-1, };
  3628. long long temp_cal_data = 0;
  3629. int bl_level;
  3630. int level_255_temp_MSB = 0;
  3631. int level_V255 = 0;
  3632. int point_index;
  3633. int cnt;
  3634. int table_index;
  3635. pr_debug("%s : start !!\n",__func__);
  3636. /*calculate candela level */
  3637. if (pSmart->brightness_level == 80)
  3638. bl_level = 250;
  3639. else if (pSmart->brightness_level == 95)
  3640. bl_level = 270;
  3641. else if (pSmart->brightness_level == 115)
  3642. bl_level = 260;
  3643. else if (pSmart->brightness_level == 130)
  3644. bl_level = 288;
  3645. else
  3646. bl_level = 288;
  3647. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3648. point_index = S6E3_ARRAY[cnt+1];
  3649. temp_cal_data =
  3650. ((long long)(candela_coeff_2p15[point_index])) *
  3651. ((long long)(bl_level));
  3652. candela_level[cnt] = temp_cal_data;
  3653. }
  3654. #ifdef SMART_DIMMING_DEBUG
  3655. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3656. candela_level[0], candela_level[1], candela_level[2]);
  3657. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3658. candela_level[3], candela_level[4], candela_level[5]);
  3659. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3660. candela_level[6], candela_level[7], candela_level[8]);
  3661. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  3662. #endif
  3663. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3664. if (searching_function(candela_level[cnt],
  3665. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3666. pr_info("%s searching functioin error cnt:%d\n",
  3667. __func__, cnt);
  3668. }
  3669. }
  3670. /*
  3671. * Candela compensation
  3672. */
  3673. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  3674. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3675. if (table_index == -1) {
  3676. table_index = CCG6_MAX_TABLE_HMT;
  3677. pr_info("%s fail candela table_index cnt : %d brightness %d",
  3678. __func__, cnt, pSmart->brightness_level);
  3679. }
  3680. bl_index[S6E3_TABLE_MAX - cnt] +=
  3681. gradation_offset_K_wqhd_hmt[table_index][cnt - 1];
  3682. /* THERE IS M-GRAY0 target */
  3683. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  3684. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  3685. }
  3686. #ifdef SMART_DIMMING_DEBUG
  3687. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3688. bl_index[0], bl_index[1], bl_index[2]);
  3689. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3690. bl_index[3], bl_index[4], bl_index[5]);
  3691. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3692. bl_index[6], bl_index[7], bl_index[8]);
  3693. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3694. #endif
  3695. /*Generate Gamma table*/
  3696. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3697. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3698. /*
  3699. * RGB compensation
  3700. */
  3701. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  3702. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3703. if (table_index == -1) {
  3704. table_index = CCG6_MAX_TABLE_HMT;
  3705. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  3706. __func__, cnt, pSmart->brightness_level);
  3707. }
  3708. if (cnt < 3) {
  3709. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  3710. level_V255 +=
  3711. rgb_offset_K_wqhd_hmt[table_index][cnt];
  3712. level_255_temp_MSB = level_V255 / 256;
  3713. str[cnt * 2] = level_255_temp_MSB & 0xff;
  3714. str[(cnt * 2) + 1] = level_V255 & 0xff;
  3715. } else {
  3716. str[cnt+3] += rgb_offset_K_wqhd_hmt[table_index][cnt];
  3717. }
  3718. }
  3719. /*subtration MTP_OFFSET value from generated gamma table*/
  3720. mtp_offset_substraction(pSmart, str);
  3721. }
  3722. static int gradation_offset_K_wqhd_hmt_single[][9] = {
  3723. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  3724. {0, 8, 10, 8, 9, 9, 8, 9, 4},
  3725. {0, 6, 8, 8, 7, 7, 7, 9, 4},
  3726. {0, 6, 8, 6, 6, 7, 6, 7, 3},
  3727. {0, 5, 8, 7, 7, 5, 5, 6, 3},
  3728. };
  3729. static int rgb_offset_K_wqhd_hmt_single[][RGB_COMPENSATION] = {
  3730. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  3731. R87 G87 B87 R51 G51 B51 R35 G35 B35
  3732. R23 G23 B23 R11 G11 B11
  3733. */
  3734. {-9, -8, -11, 0, -1, 1, 0, 1, -1, 0, 1, -1, -2, -1, -4, -3, -1, -6, -3, 1, -1, -8, 2, -25},
  3735. {-3, -1, -2, 2, 0, 1, -1, 1, -1, -1, 0, -2, 1, 1, -2, -2, -1, -5, -3, 1, -3, -11, 0, -24},
  3736. {-5, -4, -6, 2, -1, 1, 1, 1, 0, -1, 0, -2, -2, 0, -3, -5, -4, -7, 1, 4, 1, -13, -3, -24},
  3737. {-4, -3, -4, 1, -1, 1, 0, 1, 0, -1, -1, -2, 0, 1, -2, 1, 2, -1, 1, 3, -1, -14, -4, -6},
  3738. };
  3739. static void gamma_init_K_wqhd_hmt_single(struct SMART_DIM *pSmart, char *str, int size)
  3740. {
  3741. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  3742. int bl_index[S6E3_TABLE_MAX] = {-1, };
  3743. long long temp_cal_data = 0;
  3744. int bl_level;
  3745. int level_255_temp_MSB = 0;
  3746. int level_V255 = 0;
  3747. int point_index;
  3748. int cnt;
  3749. int table_index;
  3750. pr_debug("%s : start !!\n",__func__);
  3751. /*calculate candela level */
  3752. if (pSmart->brightness_level == 80)
  3753. bl_level = 250;
  3754. else if (pSmart->brightness_level == 95)
  3755. bl_level = 270;
  3756. else if (pSmart->brightness_level == 115)
  3757. bl_level = 260;
  3758. else if (pSmart->brightness_level == 130)
  3759. bl_level = 288;
  3760. else
  3761. bl_level = 288;
  3762. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3763. point_index = S6E3_ARRAY[cnt+1];
  3764. temp_cal_data =
  3765. ((long long)(candela_coeff_2p15[point_index])) *
  3766. ((long long)(bl_level));
  3767. candela_level[cnt] = temp_cal_data;
  3768. }
  3769. #ifdef SMART_DIMMING_DEBUG
  3770. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3771. candela_level[0], candela_level[1], candela_level[2]);
  3772. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3773. candela_level[3], candela_level[4], candela_level[5]);
  3774. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3775. candela_level[6], candela_level[7], candela_level[8]);
  3776. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  3777. #endif
  3778. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3779. if (searching_function(candela_level[cnt],
  3780. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3781. pr_info("%s searching functioin error cnt:%d\n",
  3782. __func__, cnt);
  3783. }
  3784. }
  3785. /*
  3786. * Candela compensation
  3787. */
  3788. for (cnt = 1; cnt < S6E3_TABLE_MAX; cnt++) {
  3789. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3790. if (table_index == -1) {
  3791. table_index = CCG6_MAX_TABLE_HMT;
  3792. pr_info("%s fail candela table_index cnt : %d brightness %d",
  3793. __func__, cnt, pSmart->brightness_level);
  3794. }
  3795. bl_index[S6E3_TABLE_MAX - cnt] +=
  3796. gradation_offset_K_wqhd_hmt_single[table_index][cnt - 1];
  3797. /* THERE IS M-GRAY0 target */
  3798. if (bl_index[S6E3_TABLE_MAX - cnt] == 0)
  3799. bl_index[S6E3_TABLE_MAX - cnt] = 1;
  3800. }
  3801. #ifdef SMART_DIMMING_DEBUG
  3802. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3803. bl_index[0], bl_index[1], bl_index[2]);
  3804. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3805. bl_index[3], bl_index[4], bl_index[5]);
  3806. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3807. bl_index[6], bl_index[7], bl_index[8]);
  3808. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3809. #endif
  3810. /*Generate Gamma table*/
  3811. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3812. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3813. /*
  3814. * RGB compensation
  3815. */
  3816. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  3817. table_index = find_cadela_table_hmt(pSmart->brightness_level);
  3818. if (table_index == -1) {
  3819. table_index = CCG6_MAX_TABLE_HMT;
  3820. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  3821. __func__, cnt, pSmart->brightness_level);
  3822. }
  3823. if (cnt < 3) {
  3824. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  3825. level_V255 +=
  3826. rgb_offset_K_wqhd_hmt_single[table_index][cnt];
  3827. level_255_temp_MSB = level_V255 / 256;
  3828. str[cnt * 2] = level_255_temp_MSB & 0xff;
  3829. str[(cnt * 2) + 1] = level_V255 & 0xff;
  3830. } else {
  3831. str[cnt+3] += rgb_offset_K_wqhd_hmt_single[table_index][cnt];
  3832. }
  3833. }
  3834. /*subtration MTP_OFFSET value from generated gamma table*/
  3835. mtp_offset_substraction(pSmart, str);
  3836. }
  3837. #endif
  3838. #endif
  3839. static void pure_gamma_init(struct SMART_DIM *pSmart, char *str, int size)
  3840. {
  3841. long long candela_level[S6E3_TABLE_MAX] = {-1, };
  3842. int bl_index[S6E3_TABLE_MAX] = {-1, };
  3843. long long temp_cal_data = 0;
  3844. int bl_level, cnt;
  3845. int point_index;
  3846. bl_level = pSmart->brightness_level;
  3847. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3848. point_index = S6E3_ARRAY[cnt+1];
  3849. temp_cal_data =
  3850. ((long long)(candela_coeff_2p2[point_index])) *
  3851. ((long long)(bl_level));
  3852. candela_level[cnt] = temp_cal_data;
  3853. }
  3854. #ifdef SMART_DIMMING_DEBUG
  3855. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  3856. candela_level[0], candela_level[1], candela_level[2]);
  3857. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  3858. candela_level[3], candela_level[4], candela_level[5]);
  3859. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  3860. candela_level[6], candela_level[7], candela_level[8]);
  3861. printk(KERN_INFO "candela_255:%llu\n", candela_level[9]);
  3862. #endif
  3863. /*calculate brightness level*/
  3864. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++) {
  3865. if (searching_function(candela_level[cnt],
  3866. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  3867. pr_info("%s searching functioin error cnt:%d\n",
  3868. __func__, cnt);
  3869. }
  3870. }
  3871. /*
  3872. * 210CD ~ 190CD compensation
  3873. * V3 level + 1
  3874. */
  3875. if ((bl_level >= 190) && (bl_level <= 210))
  3876. bl_index[1] += 1;
  3877. #ifdef SMART_DIMMING_DEBUG
  3878. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  3879. bl_index[0], bl_index[1], bl_index[2]);
  3880. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  3881. bl_index[3], bl_index[4], bl_index[5]);
  3882. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  3883. bl_index[5], bl_index[7], bl_index[8]);
  3884. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  3885. #endif
  3886. /*Generate Gamma table*/
  3887. for (cnt = 0; cnt < S6E3_TABLE_MAX; cnt++)
  3888. (void)Make_hexa[cnt](bl_index , pSmart, str);
  3889. mtp_offset_substraction(pSmart, str);
  3890. temp_candela_coeff = candela_coeff_2p25;
  3891. temp_candela_coeff = candela_coeff_2p1;
  3892. temp_candela_coeff = candela_coeff_2p05;
  3893. temp_candela_coeff = candela_coeff_2p0;
  3894. temp_candela_coeff = candela_coeff_1p95;
  3895. temp_candela_coeff = candela_coeff_1p9;
  3896. temp_candela_coeff = candela_coeff_1p85;
  3897. temp_candela_coeff = candela_coeff_1p8;
  3898. temp_candela_coeff = candela_coeff_1p75;
  3899. temp_candela_coeff = candela_coeff_1p7;
  3900. temp_candela_coeff = candela_coeff_1p65;
  3901. temp_candela_coeff = candela_coeff_1p6;
  3902. temp_candela_coeff = s6e63m0_candela_coeff;
  3903. temp_candela_coeff = s6e63m0_curve_2p2;
  3904. temp_candela_coeff = curve_2p2;
  3905. temp_candela_coeff = curve_1p9;
  3906. temp_candela_coeff = candela_coeff_2p2;
  3907. temp_candela_coeff = candela_coeff_2p15;
  3908. temp_candela_coeff = curve_1p9_350;
  3909. temp_candela_coeff = curve_2p15_350;
  3910. temp_candela_coeff = curve_2p2_350;
  3911. }
  3912. static void set_max_lux_table(void)
  3913. {
  3914. max_lux_table[0] = V255_300CD_R_MSB;
  3915. max_lux_table[1] = V255_300CD_R_LSB;
  3916. max_lux_table[2] = V255_300CD_G_MSB;
  3917. max_lux_table[3] = V255_300CD_G_LSB;
  3918. max_lux_table[4] = V255_300CD_B_MSB;
  3919. max_lux_table[5] = V255_300CD_B_LSB;
  3920. max_lux_table[6] = V203_300CD_R;
  3921. max_lux_table[7] = V203_300CD_G;
  3922. max_lux_table[8] = V203_300CD_B;
  3923. max_lux_table[9] = V151_300CD_R;
  3924. max_lux_table[10] = V151_300CD_G;
  3925. max_lux_table[11] = V151_300CD_B;
  3926. max_lux_table[12] = V87_300CD_R;
  3927. max_lux_table[13] = V87_300CD_G;
  3928. max_lux_table[14] = V87_300CD_B;
  3929. max_lux_table[15] = V51_300CD_R;
  3930. max_lux_table[16] = V51_300CD_G;
  3931. max_lux_table[17] = V51_300CD_B;
  3932. max_lux_table[18] = V35_300CD_R;
  3933. max_lux_table[19] = V35_300CD_G;
  3934. max_lux_table[20] = V35_300CD_B;
  3935. max_lux_table[21] = V23_300CD_R;
  3936. max_lux_table[22] = V23_300CD_G;
  3937. max_lux_table[23] = V23_300CD_B;
  3938. max_lux_table[24] = V11_300CD_R;
  3939. max_lux_table[25] = V11_300CD_G;
  3940. max_lux_table[26] = V11_300CD_B;
  3941. max_lux_table[27] = V3_300CD_R;
  3942. max_lux_table[28] = V3_300CD_G;
  3943. max_lux_table[29] = V3_300CD_B;
  3944. max_lux_table[30] = VT_300CD_R;
  3945. max_lux_table[31] = VT_300CD_G;
  3946. max_lux_table[32] = VT_300CD_B;
  3947. }
  3948. static void set_min_lux_table(struct SMART_DIM *psmart)
  3949. {
  3950. psmart->brightness_level = MIN_CANDELA;
  3951. pure_gamma_init(psmart, min_lux_table, GAMMA_SET_MAX);
  3952. }
  3953. static void get_min_lux_table(char *str, int size)
  3954. {
  3955. memcpy(str, min_lux_table, size);
  3956. }
  3957. static void generate_gamma(struct SMART_DIM *psmart, char *str, int size)
  3958. {
  3959. int lux_loop;
  3960. struct illuminance_table *ptable = (struct illuminance_table *)
  3961. (&(psmart->gen_table));
  3962. /* searching already generated gamma table */
  3963. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  3964. if (ptable[lux_loop].lux == psmart->brightness_level) {
  3965. memcpy(str, &(ptable[lux_loop].gamma_setting), size);
  3966. break;
  3967. }
  3968. }
  3969. /* searching fail... Setting 300CD value on gamma table */
  3970. if (lux_loop == psmart->lux_table_max) {
  3971. pr_info("%s searching fail lux : %d\n", __func__,
  3972. psmart->brightness_level);
  3973. memcpy(str, max_lux_table, size);
  3974. }
  3975. #ifdef SMART_DIMMING_DEBUG
  3976. if (lux_loop != psmart->lux_table_max)
  3977. pr_info("%s searching ok index : %d lux : %d", __func__,
  3978. lux_loop, ptable[lux_loop].lux);
  3979. #endif
  3980. }
  3981. static void gamma_cell_determine(int ldi_revision)
  3982. {
  3983. pr_info("%s ldi_revision: 0x%x", __func__, ldi_revision);
  3984. V255_300CD_R_MSB = V255_300CD_R_MSB_20;
  3985. V255_300CD_R_LSB = V255_300CD_R_LSB_20;
  3986. V255_300CD_G_MSB = V255_300CD_G_MSB_20;
  3987. V255_300CD_G_LSB = V255_300CD_G_LSB_20;
  3988. V255_300CD_B_MSB = V255_300CD_B_MSB_20;
  3989. V255_300CD_B_LSB = V255_300CD_B_LSB_20;
  3990. V203_300CD_R = V203_300CD_R_20;
  3991. V203_300CD_G = V203_300CD_G_20;
  3992. V203_300CD_B = V203_300CD_B_20;
  3993. V151_300CD_R = V151_300CD_R_20;
  3994. V151_300CD_G = V151_300CD_G_20;
  3995. V151_300CD_B = V151_300CD_B_20;
  3996. V87_300CD_R = V87_300CD_R_20;
  3997. V87_300CD_G = V87_300CD_G_20;
  3998. V87_300CD_B = V87_300CD_B_20;
  3999. V51_300CD_R = V51_300CD_R_20;
  4000. V51_300CD_G = V51_300CD_G_20;
  4001. V51_300CD_B = V51_300CD_B_20;
  4002. V35_300CD_R = V35_300CD_R_20;
  4003. V35_300CD_G = V35_300CD_G_20;
  4004. V35_300CD_B = V35_300CD_B_20;
  4005. V23_300CD_R = V23_300CD_R_20;
  4006. V23_300CD_G = V23_300CD_G_20;
  4007. V23_300CD_B = V23_300CD_B_20;
  4008. V11_300CD_R = V11_300CD_R_20;
  4009. V11_300CD_G = V11_300CD_G_20;
  4010. V11_300CD_B = V11_300CD_B_20;
  4011. V3_300CD_R = V3_300CD_R_20;
  4012. V3_300CD_G = V3_300CD_G_20;
  4013. V3_300CD_B = V3_300CD_B_20;
  4014. VT_300CD_R = VT_300CD_R_20;
  4015. VT_300CD_G = VT_300CD_G_20;
  4016. VT_300CD_B = VT_300CD_B_20;
  4017. }
  4018. static void mtp_sorting(struct SMART_DIM *psmart)
  4019. {
  4020. int sorting[GAMMA_SET_MAX] = {
  4021. 0, 1, 6, 9, 12, 15, 18, 21, 24, 27, 30, /* R*/
  4022. 2, 3, 7, 10, 13, 16, 19, 22, 25, 28, 31, /* G */
  4023. 4, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, /* B */
  4024. };
  4025. int loop;
  4026. char *pfrom, *pdest;
  4027. pfrom = (char *)&(psmart->MTP_ORIGN);
  4028. pdest = (char *)&(psmart->MTP);
  4029. for (loop = 0; loop < GAMMA_SET_MAX; loop++)
  4030. pdest[loop] = pfrom[sorting[loop]];
  4031. }
  4032. static int smart_dimming_init(struct SMART_DIM *psmart)
  4033. {
  4034. int lux_loop;
  4035. int id1, id2, id3;
  4036. #ifdef SMART_DIMMING_DEBUG
  4037. int cnt;
  4038. char pBuffer[256];
  4039. memset(pBuffer, 0x00, 256);
  4040. #endif
  4041. id1 = (psmart->ldi_revision & 0x00FF0000) >> 16;
  4042. id2 = (psmart->ldi_revision & 0x0000FF00) >> 8;
  4043. id3 = psmart->ldi_revision & 0xFF;
  4044. pr_debug("%s : ++\n",__func__);
  4045. mtp_sorting(psmart);
  4046. gamma_cell_determine(psmart->ldi_revision);
  4047. set_max_lux_table();
  4048. #ifdef SMART_DIMMING_DEBUG
  4049. print_RGB_offset(psmart);
  4050. #endif
  4051. psmart->vregout_voltage = S6E3_VREG0_REF_6P0;
  4052. v255_adjustment(psmart);
  4053. vt_adjustment(psmart);
  4054. v203_adjustment(psmart);
  4055. v151_adjustment(psmart);
  4056. v87_adjustment(psmart);
  4057. v51_adjustment(psmart);
  4058. v35_adjustment(psmart);
  4059. v23_adjustment(psmart);
  4060. v11_adjustment(psmart);
  4061. v3_adjustment(psmart);
  4062. if (generate_gray_scale(psmart)) {
  4063. pr_info(KERN_ERR "lcd smart dimming fail generate_gray_scale\n");
  4064. return -EINVAL;
  4065. }
  4066. /*Generating lux_table*/
  4067. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  4068. /* To set brightness value */
  4069. psmart->brightness_level = psmart->plux_table[lux_loop];
  4070. /* To make lux table index*/
  4071. psmart->gen_table[lux_loop].lux = psmart->plux_table[lux_loop];
  4072. #if defined(AID_OPERATION)
  4073. if ((id3 == EVT0_S_hd_REVA)||(id3 == EVT0_S_hd_REVC)) {
  4074. gamma_init_S_hd_revA(psmart,
  4075. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4076. GAMMA_SET_MAX);
  4077. } else if(id3 == EVT1_S_hd_REVD){
  4078. gamma_init_S_hd_revD(psmart,
  4079. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4080. GAMMA_SET_MAX);
  4081. }else if(id3 == EVT1_S_hd_REVF){
  4082. gamma_init_S_hd_revF(psmart,
  4083. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4084. GAMMA_SET_MAX);
  4085. }else if(id3 >= EVT1_S_hd_REVG){
  4086. gamma_init_S_hd_revG(psmart,
  4087. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4088. GAMMA_SET_MAX);
  4089. }
  4090. #else
  4091. pure_gamma_init(psmart,
  4092. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4093. GAMMA_SET_MAX);
  4094. #endif
  4095. }
  4096. /* set 300CD max gamma table */
  4097. memcpy(&(psmart->gen_table[lux_loop-1].gamma_setting),
  4098. max_lux_table, GAMMA_SET_MAX);
  4099. set_min_lux_table(psmart);
  4100. #ifdef SMART_DIMMING_DEBUG
  4101. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  4102. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  4103. snprintf(pBuffer + strnlen(pBuffer, 256), 256, " %d",
  4104. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  4105. pr_info("lux : %3d %s", psmart->plux_table[lux_loop], pBuffer);
  4106. memset(pBuffer, 0x00, 256);
  4107. }
  4108. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  4109. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  4110. snprintf(pBuffer + strnlen(pBuffer, 256), 256,
  4111. " %02X",
  4112. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  4113. pr_info("lux : %3d %s", psmart->plux_table[lux_loop], pBuffer);
  4114. memset(pBuffer, 0x00, 256);
  4115. }
  4116. #endif
  4117. pr_info("%s done\n",__func__);
  4118. return 0;
  4119. }
  4120. /* ----------------------------------------------------------------------------
  4121. * Wrapper functions for smart dimming to work with 8974 generic code
  4122. * ----------------------------------------------------------------------------
  4123. */
  4124. static void wrap_generate_gamma(int cd, char *cmd_str) {
  4125. smart_S6E3.brightness_level = cd;
  4126. generate_gamma(&smart_S6E3, cmd_str, GAMMA_SET_MAX);
  4127. }
  4128. static void wrap_smart_dimming_init(void) {
  4129. smart_S6E3.plux_table = __S6E3__.lux_tab;
  4130. smart_S6E3.lux_table_max = __S6E3__.lux_tabsize;
  4131. smart_S6E3.ldi_revision = __S6E3__.man_id;
  4132. smart_dimming_init(&smart_S6E3);
  4133. }
  4134. struct smartdim_conf *smart_S6E3_get_conf(void) {
  4135. __S6E3__.generate_gamma = wrap_generate_gamma;
  4136. __S6E3__.init = wrap_smart_dimming_init;
  4137. __S6E3__.get_min_lux_table = get_min_lux_table;
  4138. __S6E3__.mtp_buffer = (char *)(&smart_S6E3.MTP_ORIGN);
  4139. __S6E3__.print_aid_log = print_aid_log;
  4140. return (struct smartdim_conf *)&__S6E3__;
  4141. }
  4142. #if defined(CONFIG_LCD_HMT)
  4143. static int smart_dimming_init_hmt(struct SMART_DIM *psmart, int dual)
  4144. {
  4145. int lux_loop;
  4146. int id1, id2, id3;
  4147. #ifdef SMART_DIMMING_DEBUG
  4148. int cnt;
  4149. char pBuffer[256];
  4150. memset(pBuffer, 0x00, 256);
  4151. #endif
  4152. id1 = (psmart->ldi_revision & 0x00FF0000) >> 16;
  4153. id2 = (psmart->ldi_revision & 0x0000FF00) >> 8;
  4154. id3 = psmart->ldi_revision & 0xFF;
  4155. pr_debug("[HMT] %s : ++\n",__func__);
  4156. mtp_sorting(psmart);
  4157. gamma_cell_determine(psmart->ldi_revision);
  4158. set_max_lux_table();
  4159. #ifdef SMART_DIMMING_DEBUG
  4160. print_RGB_offset(psmart);
  4161. #endif
  4162. if (get_lcd_panel_res()) // 1 : FHD
  4163. psmart->vregout_voltage = S6E3_VREG0_REF_6P3;
  4164. else // 0 : WQHD
  4165. psmart->vregout_voltage = S6E3_VREG0_REF_6P2;
  4166. v255_adjustment(psmart);
  4167. vt_adjustment(psmart);
  4168. v203_adjustment(psmart);
  4169. v151_adjustment(psmart);
  4170. v87_adjustment(psmart);
  4171. v51_adjustment(psmart);
  4172. v35_adjustment(psmart);
  4173. v23_adjustment(psmart);
  4174. v11_adjustment(psmart);
  4175. v3_adjustment(psmart);
  4176. if (generate_gray_scale(psmart)) {
  4177. pr_info(KERN_ERR "lcd smart dimming fail generate_gray_scale\n");
  4178. return -EINVAL;
  4179. }
  4180. /*Generating lux_table*/
  4181. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  4182. /* To set brightness value */
  4183. psmart->brightness_level = psmart->plux_table[lux_loop];
  4184. /* To make lux table index*/
  4185. psmart->gen_table[lux_loop].lux = psmart->plux_table[lux_loop];
  4186. #if defined(AID_OPERATION)
  4187. if (get_lcd_panel_res()) { // 1 : FHD
  4188. if (id3 <= EVT1_K_fhd_REVH) {
  4189. if (dual)
  4190. gamma_init_K_fhd_revE_hmt(psmart,
  4191. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4192. GAMMA_SET_MAX);
  4193. else
  4194. gamma_init_K_fhd_revE_hmt_single(psmart,
  4195. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4196. GAMMA_SET_MAX);
  4197. }
  4198. } else { /* 0 : WQHD */
  4199. //if (id3 == EVT0_K_wqhd_REVE) {
  4200. if (1) {
  4201. if (dual)
  4202. gamma_init_K_wqhd_hmt(psmart,
  4203. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4204. GAMMA_SET_MAX);
  4205. else
  4206. gamma_init_K_wqhd_hmt_single(psmart,
  4207. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4208. GAMMA_SET_MAX);
  4209. }
  4210. }
  4211. #else
  4212. pure_gamma_init(psmart,
  4213. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  4214. GAMMA_SET_MAX);
  4215. #endif
  4216. }
  4217. #ifdef SMART_DIMMING_DEBUG
  4218. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  4219. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  4220. snprintf(pBuffer + strnlen(pBuffer, 256), 256, " %d",
  4221. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  4222. pr_info("lux : %3d %s", psmart->plux_table[lux_loop], pBuffer);
  4223. memset(pBuffer, 0x00, 256);
  4224. }
  4225. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  4226. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  4227. snprintf(pBuffer + strnlen(pBuffer, 256), 256,
  4228. " %02X",
  4229. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  4230. pr_info("lux : %3d %s", psmart->plux_table[lux_loop], pBuffer);
  4231. memset(pBuffer, 0x00, 256);
  4232. }
  4233. #endif
  4234. pr_info("[HMT] %s --\n",__func__);
  4235. return 0;
  4236. }
  4237. static void wrap_generate_gamma_hmt(int cd, char *cmd_str, int dual) {
  4238. if (dual) {
  4239. smart_S6E3_hmt.brightness_level = cd;
  4240. generate_gamma(&smart_S6E3_hmt, cmd_str, GAMMA_SET_MAX);
  4241. } else {
  4242. smart_S6E3_hmt_single.brightness_level = cd;
  4243. generate_gamma(&smart_S6E3_hmt_single, cmd_str, GAMMA_SET_MAX);
  4244. }
  4245. }
  4246. static void wrap_smart_dimming_init_hmt(int dual) {
  4247. if (dual) {
  4248. smart_S6E3_hmt.plux_table = __S6E3_HMT__.lux_tab;
  4249. smart_S6E3_hmt.lux_table_max = __S6E3_HMT__.lux_tabsize;
  4250. smart_S6E3_hmt.ldi_revision = __S6E3_HMT__.man_id;
  4251. smart_dimming_init_hmt(&smart_S6E3_hmt, dual);
  4252. } else {
  4253. smart_S6E3_hmt_single.plux_table = __S6E3_HMT_S__.lux_tab;
  4254. smart_S6E3_hmt_single.lux_table_max = __S6E3_HMT_S__.lux_tabsize;
  4255. smart_S6E3_hmt_single.ldi_revision = __S6E3_HMT_S__.man_id;
  4256. smart_dimming_init_hmt(&smart_S6E3_hmt_single, dual);
  4257. }
  4258. }
  4259. struct smartdim_conf_hmt *smart_S6E3_get_conf_hmt(int dual) {
  4260. if (dual) {
  4261. __S6E3_HMT__.generate_gamma = wrap_generate_gamma_hmt;
  4262. __S6E3_HMT__.init = wrap_smart_dimming_init_hmt;
  4263. __S6E3_HMT__.get_min_lux_table = get_min_lux_table;
  4264. __S6E3_HMT__.mtp_buffer = (char *)(&smart_S6E3_hmt.MTP_ORIGN);
  4265. __S6E3_HMT__.print_aid_log = print_aid_log_hmt;
  4266. return (struct smartdim_conf_hmt *)&__S6E3_HMT__;
  4267. } else {
  4268. __S6E3_HMT_S__.generate_gamma = wrap_generate_gamma_hmt;
  4269. __S6E3_HMT_S__.init = wrap_smart_dimming_init_hmt;
  4270. __S6E3_HMT_S__.get_min_lux_table = get_min_lux_table;
  4271. __S6E3_HMT_S__.mtp_buffer = (char *)(&smart_S6E3_hmt_single.MTP_ORIGN);
  4272. __S6E3_HMT_S__.print_aid_log = print_aid_log_hmt;
  4273. return (struct smartdim_conf_hmt *)&__S6E3_HMT_S__;
  4274. }
  4275. }
  4276. /*
  4277. static void wrap_generate_gamma_hmt_single(int cd, char *cmd_str) {
  4278. smart_S6E3_hmt_single.brightness_level = cd;
  4279. generate_gamma(&smart_S6E3_hmt_single, cmd_str, GAMMA_SET_MAX);
  4280. }
  4281. static void wrap_smart_dimming_init_hmt_single(void) {
  4282. smart_S6E3_hmt_single.plux_table = __S6E3_HMT_S__.lux_tab;
  4283. smart_S6E3_hmt_single.lux_table_max = __S6E3_HMT_S__.lux_tabsize;
  4284. smart_S6E3_hmt_single.ldi_revision = __S6E3_HMT_S__.man_id;
  4285. smart_dimming_init_hmt(&smart_S6E3_hmt_single);
  4286. }
  4287. struct smartdim_conf *smart_S6E3_get_conf_hmt_single(void) {
  4288. __S6E3_HMT_S__.generate_gamma = wrap_generate_gamma_hmt_single;
  4289. __S6E3_HMT_S__.init = wrap_smart_dimming_init_hmt;
  4290. __S6E3_HMT_S__.get_min_lux_table = get_min_lux_table;
  4291. __S6E3_HMT_S__.mtp_buffer = (char *)(&smart_S6E3_hmt_single.MTP_ORIGN);
  4292. __S6E3_HMT_S__.print_aid_log = print_aid_log_hmt;
  4293. return (struct smartdim_conf *)&__S6E3_HMT_S__;
  4294. }
  4295. */
  4296. #endif
  4297. /* ----------------------------------------------------------------------------
  4298. * END - Wrapper
  4299. * ----------------------------------------------------------------------------
  4300. */