smart_mtp_se6e3fa.c 150 KB

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