smart_mtp_ea8061.c 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989
  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_ea8061.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. static int *temp_candela_coeff;
  41. /*
  42. * To support different center cell gamma setting
  43. */
  44. static char V255_300CD_R_MSB;
  45. static char V255_300CD_R_LSB;
  46. static char V255_300CD_G_MSB;
  47. static char V255_300CD_G_LSB;
  48. static char V255_300CD_B_MSB;
  49. static char V255_300CD_B_LSB;
  50. static char V203_300CD_R;
  51. static char V203_300CD_G;
  52. static char V203_300CD_B;
  53. static char V151_300CD_R;
  54. static char V151_300CD_G;
  55. static char V151_300CD_B;
  56. static char V87_300CD_R;
  57. static char V87_300CD_G;
  58. static char V87_300CD_B;
  59. static char V51_300CD_R;
  60. static char V51_300CD_G;
  61. static char V51_300CD_B;
  62. static char V35_300CD_R;
  63. static char V35_300CD_G;
  64. static char V35_300CD_B;
  65. static char V23_300CD_R;
  66. static char V23_300CD_G;
  67. static char V23_300CD_B;
  68. static char V11_300CD_R;
  69. static char V11_300CD_G;
  70. static char V11_300CD_B;
  71. static char V3_300CD_R;
  72. static char V3_300CD_G;
  73. static char V3_300CD_B;
  74. static char VT_300CD_R;
  75. static char VT_300CD_G;
  76. static char VT_300CD_B;
  77. static int char_to_int(char data1)
  78. {
  79. int cal_data;
  80. if (data1 & 0x80) {
  81. cal_data = data1 & 0x7F;
  82. cal_data *= -1;
  83. } else
  84. cal_data = data1;
  85. return cal_data;
  86. }
  87. static int char_to_int_v255(char data1, char data2)
  88. {
  89. int cal_data;
  90. if (data1)
  91. cal_data = (data2 ^ 0xFF) * -1;
  92. else
  93. cal_data = data2;
  94. return cal_data;
  95. }
  96. #ifdef SMART_DIMMING_DEBUG
  97. static void print_RGB_offset(struct SMART_DIM *pSmart)
  98. {
  99. pr_info("%s MTP Offset VT R:%d G:%d B:%d\n", __func__,
  100. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1),
  101. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1),
  102. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1));
  103. pr_info("%s MTP Offset V3 R:%d G:%d B:%d\n", __func__,
  104. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3),
  105. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3),
  106. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3));
  107. pr_info("%s MTP Offset V11 R:%d G:%d B:%d\n", __func__,
  108. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11),
  109. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11),
  110. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11));
  111. pr_info("%s MTP Offset V23 R:%d G:%d B:%d\n", __func__,
  112. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23),
  113. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23),
  114. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23));
  115. pr_info("%s MTP Offset V35 R:%d G:%d B:%d\n", __func__,
  116. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35),
  117. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35),
  118. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35));
  119. pr_info("%s MTP Offset V51 R:%d G:%d B:%d\n", __func__,
  120. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51),
  121. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51),
  122. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51));
  123. pr_info("%s MTP Offset V87 R:%d G:%d B:%d\n", __func__,
  124. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87),
  125. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87),
  126. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87));
  127. pr_info("%s MTP Offset V151 R:%d G:%d B:%d\n", __func__,
  128. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151),
  129. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151),
  130. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151));
  131. pr_info("%s MTP Offset V203 R:%d G:%d B:%d\n", __func__,
  132. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203),
  133. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203),
  134. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203));
  135. pr_info("%s MTP Offset V255 R:%d G:%d B:%d\n", __func__,
  136. char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  137. pSmart->MTP.R_OFFSET.OFFSET_255_LSB),
  138. char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  139. pSmart->MTP.G_OFFSET.OFFSET_255_LSB),
  140. char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  141. pSmart->MTP.B_OFFSET.OFFSET_255_LSB));
  142. }
  143. #endif
  144. #define v255_coefficient 46
  145. #define v255_denominator 605
  146. static int v255_adjustment(struct SMART_DIM *pSmart)
  147. {
  148. unsigned long long result_1, result_2, result_3, result_4;
  149. int add_mtp;
  150. int LSB;
  151. int v255_value;
  152. v255_value = (V255_300CD_R_MSB << 8) | (V255_300CD_R_LSB);
  153. LSB = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  154. pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
  155. add_mtp = LSB + v255_value;
  156. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  157. do_div(result_2, v255_denominator);
  158. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  159. result_4 = pSmart->vregout_voltage - result_3;
  160. pSmart->RGB_OUTPUT.R_VOLTAGE.level_255 = result_4;
  161. pSmart->RGB_OUTPUT.R_VOLTAGE.level_0 = pSmart->vregout_voltage;
  162. v255_value = (V255_300CD_G_MSB << 8) | (V255_300CD_G_LSB);
  163. LSB = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  164. pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
  165. add_mtp = LSB + v255_value;
  166. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  167. do_div(result_2, v255_denominator);
  168. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  169. result_4 = pSmart->vregout_voltage - result_3;
  170. pSmart->RGB_OUTPUT.G_VOLTAGE.level_255 = result_4;
  171. pSmart->RGB_OUTPUT.G_VOLTAGE.level_0 = pSmart->vregout_voltage;
  172. v255_value = (V255_300CD_B_MSB << 8) | (V255_300CD_B_LSB);
  173. LSB = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  174. pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
  175. add_mtp = LSB + v255_value;
  176. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  177. do_div(result_2, v255_denominator);
  178. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  179. result_4 = pSmart->vregout_voltage - result_3;
  180. pSmart->RGB_OUTPUT.B_VOLTAGE.level_255 = result_4;
  181. pSmart->RGB_OUTPUT.B_VOLTAGE.level_0 = pSmart->vregout_voltage;
  182. #ifdef SMART_DIMMING_DEBUG
  183. pr_info("%s V255 RED:%d GREEN:%d BLUE:%d\n", __func__,
  184. pSmart->RGB_OUTPUT.R_VOLTAGE.level_255,
  185. pSmart->RGB_OUTPUT.G_VOLTAGE.level_255,
  186. pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
  187. #endif
  188. return 0;
  189. }
  190. static void v255_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  191. {
  192. unsigned long long result_1, result_2, result_3;
  193. result_1 = pSmart->vregout_voltage -
  194. (pSmart->GRAY.TABLE[index[V255_INDEX]].R_Gray);
  195. result_2 = result_1 * v255_denominator;
  196. do_div(result_2, pSmart->vregout_voltage);
  197. result_3 = result_2 - v255_coefficient;
  198. str[0] = (result_3 & 0xff00) >> 8;
  199. str[1] = result_3 & 0xff;
  200. result_1 = pSmart->vregout_voltage -
  201. (pSmart->GRAY.TABLE[index[V255_INDEX]].G_Gray);
  202. result_2 = result_1 * v255_denominator;
  203. do_div(result_2, pSmart->vregout_voltage);
  204. result_3 = result_2 - v255_coefficient;
  205. str[2] = (result_3 & 0xff00) >> 8;
  206. str[3] = result_3 & 0xff;
  207. result_1 = pSmart->vregout_voltage -
  208. (pSmart->GRAY.TABLE[index[V255_INDEX]].B_Gray);
  209. result_2 = result_1 * v255_denominator;
  210. do_div(result_2, pSmart->vregout_voltage);
  211. result_3 = result_2 - v255_coefficient;
  212. str[4] = (result_3 & 0xff00) >> 8;
  213. str[5] = result_3 & 0xff;
  214. }
  215. static int vt_coefficient[] = {
  216. 0, 12, 24, 36, 48,
  217. 60, 72, 84, 96, 108,
  218. 138, 148, 158, 168,
  219. 178, 186,
  220. };
  221. #define vt_denominator 860
  222. static int vt_adjustment(struct SMART_DIM *pSmart)
  223. {
  224. unsigned long long result_1, result_2, result_3, result_4;
  225. int add_mtp;
  226. int LSB;
  227. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1);
  228. add_mtp = LSB + VT_300CD_R;
  229. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  230. do_div(result_2, vt_denominator);
  231. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  232. result_4 = pSmart->vregout_voltage - result_3;
  233. pSmart->GRAY.VT_TABLE.R_Gray = result_4;
  234. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1);
  235. add_mtp = LSB + VT_300CD_G;
  236. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  237. do_div(result_2, vt_denominator);
  238. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  239. result_4 = pSmart->vregout_voltage - result_3;
  240. pSmart->GRAY.VT_TABLE.G_Gray = result_4;
  241. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1);
  242. add_mtp = LSB + VT_300CD_B;
  243. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  244. do_div(result_2, vt_denominator);
  245. result_3 = (pSmart->vregout_voltage * result_2) >> BIT_SHIFT;
  246. result_4 = pSmart->vregout_voltage - result_3;
  247. pSmart->GRAY.VT_TABLE.B_Gray = result_4;
  248. #ifdef SMART_DIMMING_DEBUG
  249. pr_info("%s VT RED:%d GREEN:%d BLUE:%d\n", __func__,
  250. pSmart->GRAY.VT_TABLE.R_Gray,
  251. pSmart->GRAY.VT_TABLE.G_Gray,
  252. pSmart->GRAY.VT_TABLE.B_Gray);
  253. #endif
  254. return 0;
  255. }
  256. static void vt_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  257. {
  258. str[30] = VT_300CD_R;
  259. str[31] = VT_300CD_G;
  260. str[32] = VT_300CD_B;
  261. }
  262. #define v203_coefficient 64
  263. #define v203_denominator 320
  264. static int v203_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_203);
  270. add_mtp = LSB + V203_300CD_R;
  271. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  272. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_255);
  273. result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
  274. do_div(result_2, v203_denominator);
  275. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  276. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  277. pSmart->RGB_OUTPUT.R_VOLTAGE.level_203 = result_4;
  278. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203);
  279. add_mtp = LSB + V203_300CD_G;
  280. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  281. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_255);
  282. result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
  283. do_div(result_2, v203_denominator);
  284. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  285. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  286. pSmart->RGB_OUTPUT.G_VOLTAGE.level_203 = result_4;
  287. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203);
  288. add_mtp = LSB + V203_300CD_B;
  289. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  290. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
  291. result_2 = (v203_coefficient+add_mtp) << BIT_SHIFT;
  292. do_div(result_2, v203_denominator);
  293. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  294. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  295. pSmart->RGB_OUTPUT.B_VOLTAGE.level_203 = result_4;
  296. #ifdef SMART_DIMMING_DEBUG
  297. pr_info("%s V203 RED:%d GREEN:%d BLUE:%d\n", __func__,
  298. pSmart->RGB_OUTPUT.R_VOLTAGE.level_203,
  299. pSmart->RGB_OUTPUT.G_VOLTAGE.level_203,
  300. pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
  301. #endif
  302. return 0;
  303. }
  304. static void v203_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  305. {
  306. unsigned long long result_1, result_2, result_3;
  307. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  308. - (pSmart->GRAY.TABLE[index[V203_INDEX]].R_Gray);
  309. result_2 = result_1 * v203_denominator;
  310. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  311. - (pSmart->GRAY.TABLE[index[V255_INDEX]].R_Gray);
  312. do_div(result_2, result_3);
  313. str[6] = (result_2 - v203_coefficient) & 0xff;
  314. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  315. - (pSmart->GRAY.TABLE[index[V203_INDEX]].G_Gray);
  316. result_2 = result_1 * v203_denominator;
  317. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  318. - (pSmart->GRAY.TABLE[index[V255_INDEX]].G_Gray);
  319. do_div(result_2, result_3);
  320. str[7] = (result_2 - v203_coefficient) & 0xff;
  321. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  322. - (pSmart->GRAY.TABLE[index[V203_INDEX]].B_Gray);
  323. result_2 = result_1 * v203_denominator;
  324. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  325. - (pSmart->GRAY.TABLE[index[V255_INDEX]].B_Gray);
  326. do_div(result_2, result_3);
  327. str[8] = (result_2 - v203_coefficient) & 0xff;
  328. }
  329. #define v151_coefficient 64
  330. #define v151_denominator 320
  331. static int v151_adjustment(struct SMART_DIM *pSmart)
  332. {
  333. unsigned long long result_1, result_2, result_3, result_4;
  334. int add_mtp;
  335. int LSB;
  336. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151);
  337. add_mtp = LSB + V151_300CD_R;
  338. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  339. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_203);
  340. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  341. do_div(result_2, v151_denominator);
  342. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  343. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  344. pSmart->RGB_OUTPUT.R_VOLTAGE.level_151 = result_4;
  345. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151);
  346. add_mtp = LSB + V151_300CD_G;
  347. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  348. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_203);
  349. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  350. do_div(result_2, v151_denominator);
  351. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  352. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  353. pSmart->RGB_OUTPUT.G_VOLTAGE.level_151 = result_4;
  354. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151);
  355. add_mtp = LSB + V151_300CD_B;
  356. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  357. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
  358. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  359. do_div(result_2, v151_denominator);
  360. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  361. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  362. pSmart->RGB_OUTPUT.B_VOLTAGE.level_151 = result_4;
  363. #ifdef SMART_DIMMING_DEBUG
  364. pr_info("%s V151 RED:%d GREEN:%d BLUE:%d\n", __func__,
  365. pSmart->RGB_OUTPUT.R_VOLTAGE.level_151,
  366. pSmart->RGB_OUTPUT.G_VOLTAGE.level_151,
  367. pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
  368. #endif
  369. return 0;
  370. }
  371. static void v151_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  372. {
  373. unsigned long long result_1, result_2, result_3;
  374. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  375. - (pSmart->GRAY.TABLE[index[V151_INDEX]].R_Gray);
  376. result_2 = result_1 * v151_denominator;
  377. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  378. - (pSmart->GRAY.TABLE[index[V203_INDEX]].R_Gray);
  379. do_div(result_2, result_3);
  380. str[9] = (result_2 - v151_coefficient) & 0xff;
  381. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  382. - (pSmart->GRAY.TABLE[index[V151_INDEX]].G_Gray);
  383. result_2 = result_1 * v151_denominator;
  384. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  385. - (pSmart->GRAY.TABLE[index[V203_INDEX]].G_Gray);
  386. do_div(result_2, result_3);
  387. str[10] = (result_2 - v151_coefficient) & 0xff;
  388. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  389. - (pSmart->GRAY.TABLE[index[V151_INDEX]].B_Gray);
  390. result_2 = result_1 * v151_denominator;
  391. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  392. - (pSmart->GRAY.TABLE[index[V203_INDEX]].B_Gray);
  393. do_div(result_2, result_3);
  394. str[11] = (result_2 - v151_coefficient) & 0xff;
  395. }
  396. #define v87_coefficient 64
  397. #define v87_denominator 320
  398. static int v87_adjustment(struct SMART_DIM *pSmart)
  399. {
  400. unsigned long long result_1, result_2, result_3, result_4;
  401. int add_mtp;
  402. int LSB;
  403. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87);
  404. add_mtp = LSB + V87_300CD_R;
  405. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  406. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_151);
  407. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  408. do_div(result_2, v87_denominator);
  409. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  410. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  411. pSmart->RGB_OUTPUT.R_VOLTAGE.level_87 = result_4;
  412. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87);
  413. add_mtp = LSB + V87_300CD_G;
  414. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  415. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_151);
  416. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  417. do_div(result_2, v87_denominator);
  418. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  419. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  420. pSmart->RGB_OUTPUT.G_VOLTAGE.level_87 = result_4;
  421. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87);
  422. add_mtp = LSB + V87_300CD_B;
  423. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  424. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
  425. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  426. do_div(result_2, v87_denominator);
  427. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  428. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  429. pSmart->RGB_OUTPUT.B_VOLTAGE.level_87 = result_4;
  430. #ifdef SMART_DIMMING_DEBUG
  431. pr_info("%s V87 RED:%d GREEN:%d BLUE:%d\n", __func__,
  432. pSmart->RGB_OUTPUT.R_VOLTAGE.level_87,
  433. pSmart->RGB_OUTPUT.G_VOLTAGE.level_87,
  434. pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
  435. #endif
  436. return 0;
  437. }
  438. static void v87_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  439. {
  440. unsigned long long result_1, result_2, result_3;
  441. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  442. - (pSmart->GRAY.TABLE[index[V87_INDEX]].R_Gray);
  443. result_2 = result_1 * v87_denominator;
  444. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  445. - (pSmart->GRAY.TABLE[index[V151_INDEX]].R_Gray);
  446. do_div(result_2, result_3);
  447. str[12] = (result_2 - v87_coefficient) & 0xff;
  448. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  449. - (pSmart->GRAY.TABLE[index[V87_INDEX]].G_Gray);
  450. result_2 = result_1 * v87_denominator;
  451. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  452. - (pSmart->GRAY.TABLE[index[V151_INDEX]].G_Gray);
  453. do_div(result_2, result_3);
  454. str[13] = (result_2 - v87_coefficient) & 0xff;
  455. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  456. - (pSmart->GRAY.TABLE[index[V87_INDEX]].B_Gray);
  457. result_2 = result_1 * v87_denominator;
  458. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  459. - (pSmart->GRAY.TABLE[index[V151_INDEX]].B_Gray);
  460. do_div(result_2, result_3);
  461. str[14] = (result_2 - v87_coefficient) & 0xff;
  462. }
  463. #define v51_coefficient 64
  464. #define v51_denominator 320
  465. static int v51_adjustment(struct SMART_DIM *pSmart)
  466. {
  467. unsigned long long result_1, result_2, result_3, result_4;
  468. int add_mtp;
  469. int LSB;
  470. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51);
  471. add_mtp = LSB + V51_300CD_R;
  472. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  473. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_87);
  474. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  475. do_div(result_2, v51_denominator);
  476. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  477. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  478. pSmart->RGB_OUTPUT.R_VOLTAGE.level_51 = result_4;
  479. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51);
  480. add_mtp = LSB + V51_300CD_G;
  481. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  482. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_87);
  483. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  484. do_div(result_2, v51_denominator);
  485. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  486. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  487. pSmart->RGB_OUTPUT.G_VOLTAGE.level_51 = result_4;
  488. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51);
  489. add_mtp = LSB + V51_300CD_B;
  490. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  491. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
  492. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  493. do_div(result_2, v51_denominator);
  494. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  495. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  496. pSmart->RGB_OUTPUT.B_VOLTAGE.level_51 = result_4;
  497. #ifdef SMART_DIMMING_DEBUG
  498. pr_info("%s V51 RED:%d GREEN:%d BLUE:%d\n", __func__,
  499. pSmart->RGB_OUTPUT.R_VOLTAGE.level_51,
  500. pSmart->RGB_OUTPUT.G_VOLTAGE.level_51,
  501. pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
  502. #endif
  503. return 0;
  504. }
  505. static void v51_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  506. {
  507. unsigned long long result_1, result_2, result_3;
  508. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  509. - (pSmart->GRAY.TABLE[index[V51_INDEX]].R_Gray);
  510. result_2 = result_1 * v51_denominator;
  511. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  512. - (pSmart->GRAY.TABLE[index[V87_INDEX]].R_Gray);
  513. do_div(result_2, result_3);
  514. str[15] = (result_2 - v51_coefficient) & 0xff;
  515. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  516. - (pSmart->GRAY.TABLE[index[V51_INDEX]].G_Gray);
  517. result_2 = result_1 * v51_denominator;
  518. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  519. - (pSmart->GRAY.TABLE[index[V87_INDEX]].G_Gray);
  520. do_div(result_2, result_3);
  521. str[16] = (result_2 - v51_coefficient) & 0xff;
  522. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  523. - (pSmart->GRAY.TABLE[index[V51_INDEX]].B_Gray);
  524. result_2 = result_1 * v51_denominator;
  525. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  526. - (pSmart->GRAY.TABLE[index[V87_INDEX]].B_Gray);
  527. do_div(result_2, result_3);
  528. str[17] = (result_2 - v51_coefficient) & 0xff;
  529. }
  530. #define v35_coefficient 64
  531. #define v35_denominator 320
  532. static int v35_adjustment(struct SMART_DIM *pSmart)
  533. {
  534. unsigned long long result_1, result_2, result_3, result_4;
  535. int add_mtp;
  536. int LSB;
  537. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35);
  538. add_mtp = LSB + V35_300CD_R;
  539. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  540. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_51);
  541. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  542. do_div(result_2, v35_denominator);
  543. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  544. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  545. pSmart->RGB_OUTPUT.R_VOLTAGE.level_35 = result_4;
  546. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35);
  547. add_mtp = LSB + V35_300CD_G;
  548. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  549. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_51);
  550. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  551. do_div(result_2, v35_denominator);
  552. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  553. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  554. pSmart->RGB_OUTPUT.G_VOLTAGE.level_35 = result_4;
  555. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35);
  556. add_mtp = LSB + V35_300CD_B;
  557. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  558. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
  559. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  560. do_div(result_2, v35_denominator);
  561. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  562. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  563. pSmart->RGB_OUTPUT.B_VOLTAGE.level_35 = result_4;
  564. #ifdef SMART_DIMMING_DEBUG
  565. pr_info("%s V35 RED:%d GREEN:%d BLUE:%d\n", __func__,
  566. pSmart->RGB_OUTPUT.R_VOLTAGE.level_35,
  567. pSmart->RGB_OUTPUT.G_VOLTAGE.level_35,
  568. pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
  569. #endif
  570. return 0;
  571. }
  572. static void v35_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  573. {
  574. unsigned long long result_1, result_2, result_3;
  575. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  576. - (pSmart->GRAY.TABLE[index[V35_INDEX]].R_Gray);
  577. result_2 = result_1 * v35_denominator;
  578. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  579. - (pSmart->GRAY.TABLE[index[V51_INDEX]].R_Gray);
  580. do_div(result_2, result_3);
  581. str[18] = (result_2 - v35_coefficient) & 0xff;
  582. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  583. - (pSmart->GRAY.TABLE[index[V35_INDEX]].G_Gray);
  584. result_2 = result_1 * v35_denominator;
  585. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  586. - (pSmart->GRAY.TABLE[index[V51_INDEX]].G_Gray);
  587. do_div(result_2, result_3);
  588. str[19] = (result_2 - v35_coefficient) & 0xff;
  589. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  590. - (pSmart->GRAY.TABLE[index[V35_INDEX]].B_Gray);
  591. result_2 = result_1 * v35_denominator;
  592. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  593. - (pSmart->GRAY.TABLE[index[V51_INDEX]].B_Gray);
  594. do_div(result_2, result_3);
  595. str[20] = (result_2 - v35_coefficient) & 0xff;
  596. }
  597. #define v23_coefficient 64
  598. #define v23_denominator 320
  599. static int v23_adjustment(struct SMART_DIM *pSmart)
  600. {
  601. unsigned long long result_1, result_2, result_3, result_4;
  602. int add_mtp;
  603. int LSB;
  604. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23);
  605. add_mtp = LSB + V23_300CD_R;
  606. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  607. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_35);
  608. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  609. do_div(result_2, v23_denominator);
  610. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  611. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  612. pSmart->RGB_OUTPUT.R_VOLTAGE.level_23 = result_4;
  613. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23);
  614. add_mtp = LSB + V23_300CD_G;
  615. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  616. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_35);
  617. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  618. do_div(result_2, v23_denominator);
  619. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  620. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  621. pSmart->RGB_OUTPUT.G_VOLTAGE.level_23 = result_4;
  622. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23);
  623. add_mtp = LSB + V23_300CD_B;
  624. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  625. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
  626. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  627. do_div(result_2, v23_denominator);
  628. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  629. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  630. pSmart->RGB_OUTPUT.B_VOLTAGE.level_23 = result_4;
  631. #ifdef SMART_DIMMING_DEBUG
  632. pr_info("%s V23 RED:%d GREEN:%d BLUE:%d\n", __func__,
  633. pSmart->RGB_OUTPUT.R_VOLTAGE.level_23,
  634. pSmart->RGB_OUTPUT.G_VOLTAGE.level_23,
  635. pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
  636. #endif
  637. return 0;
  638. }
  639. static void v23_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  640. {
  641. unsigned long long result_1, result_2, result_3;
  642. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  643. - (pSmart->GRAY.TABLE[index[V23_INDEX]].R_Gray);
  644. result_2 = result_1 * v23_denominator;
  645. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  646. - (pSmart->GRAY.TABLE[index[V35_INDEX]].R_Gray);
  647. do_div(result_2, result_3);
  648. str[21] = (result_2 - v23_coefficient) & 0xff;
  649. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  650. - (pSmart->GRAY.TABLE[index[V23_INDEX]].G_Gray);
  651. result_2 = result_1 * v23_denominator;
  652. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  653. - (pSmart->GRAY.TABLE[index[V35_INDEX]].G_Gray);
  654. do_div(result_2, result_3);
  655. str[22] = (result_2 - v23_coefficient) & 0xff;
  656. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  657. - (pSmart->GRAY.TABLE[index[V23_INDEX]].B_Gray);
  658. result_2 = result_1 * v23_denominator;
  659. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  660. - (pSmart->GRAY.TABLE[index[V35_INDEX]].B_Gray);
  661. do_div(result_2, result_3);
  662. str[23] = (result_2 - v23_coefficient) & 0xff;
  663. }
  664. #define v11_coefficient 64
  665. #define v11_denominator 320
  666. static int v11_adjustment(struct SMART_DIM *pSmart)
  667. {
  668. unsigned long long result_1, result_2, result_3, result_4;
  669. int add_mtp;
  670. int LSB;
  671. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11);
  672. add_mtp = LSB + V11_300CD_R;
  673. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  674. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_23);
  675. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  676. do_div(result_2, v11_denominator);
  677. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  678. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  679. pSmart->RGB_OUTPUT.R_VOLTAGE.level_11 = result_4;
  680. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11);
  681. add_mtp = LSB + V11_300CD_G;
  682. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  683. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_23);
  684. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  685. do_div(result_2, v11_denominator);
  686. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  687. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  688. pSmart->RGB_OUTPUT.G_VOLTAGE.level_11 = result_4;
  689. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11);
  690. add_mtp = LSB + V11_300CD_B;
  691. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  692. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
  693. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  694. do_div(result_2, v11_denominator);
  695. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  696. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  697. pSmart->RGB_OUTPUT.B_VOLTAGE.level_11 = result_4;
  698. #ifdef SMART_DIMMING_DEBUG
  699. pr_info("%s V11 RED:%d GREEN:%d BLUE:%d\n", __func__,
  700. pSmart->RGB_OUTPUT.R_VOLTAGE.level_11,
  701. pSmart->RGB_OUTPUT.G_VOLTAGE.level_11,
  702. pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
  703. #endif
  704. return 0;
  705. }
  706. static void v11_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  707. {
  708. unsigned long long result_1, result_2, result_3;
  709. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  710. - (pSmart->GRAY.TABLE[index[V11_INDEX]].R_Gray);
  711. result_2 = result_1 * v11_denominator;
  712. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  713. - (pSmart->GRAY.TABLE[index[V23_INDEX]].R_Gray);
  714. do_div(result_2, result_3);
  715. str[24] = (result_2 - v11_coefficient) & 0xff;
  716. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  717. - (pSmart->GRAY.TABLE[index[V11_INDEX]].G_Gray);
  718. result_2 = result_1 * v11_denominator;
  719. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  720. - (pSmart->GRAY.TABLE[index[V23_INDEX]].G_Gray);
  721. do_div(result_2, result_3);
  722. str[25] = (result_2 - v11_coefficient) & 0xff;
  723. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  724. - (pSmart->GRAY.TABLE[index[V11_INDEX]].B_Gray);
  725. result_2 = result_1 * v11_denominator;
  726. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  727. - (pSmart->GRAY.TABLE[index[V23_INDEX]].B_Gray);
  728. do_div(result_2, result_3);
  729. str[26] = (result_2 - v11_coefficient) & 0xff;
  730. }
  731. #define v3_coefficient 64
  732. #define v3_denominator 320
  733. static int v3_adjustment(struct SMART_DIM *pSmart)
  734. {
  735. unsigned long long result_1, result_2, result_3, result_4;
  736. int add_mtp;
  737. int LSB;
  738. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3);
  739. add_mtp = LSB + V3_300CD_R;
  740. result_1 = (pSmart->vregout_voltage)
  741. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_11);
  742. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  743. do_div(result_2, v3_denominator);
  744. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  745. result_4 = (pSmart->vregout_voltage) - result_3;
  746. pSmart->RGB_OUTPUT.R_VOLTAGE.level_3 = result_4;
  747. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3);
  748. add_mtp = LSB + V3_300CD_G;
  749. result_1 = (pSmart->vregout_voltage)
  750. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_11);
  751. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  752. do_div(result_2, v3_denominator);
  753. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  754. result_4 = (pSmart->vregout_voltage) - result_3;
  755. pSmart->RGB_OUTPUT.G_VOLTAGE.level_3 = result_4;
  756. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3);
  757. add_mtp = LSB + V3_300CD_B;
  758. result_1 = (pSmart->vregout_voltage)
  759. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
  760. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  761. do_div(result_2, v3_denominator);
  762. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  763. result_4 = (pSmart->vregout_voltage) - result_3;
  764. pSmart->RGB_OUTPUT.B_VOLTAGE.level_3 = result_4;
  765. #ifdef SMART_DIMMING_DEBUG
  766. pr_info("%s V3 RED:%d GREEN:%d BLUE:%d\n", __func__,
  767. pSmart->RGB_OUTPUT.R_VOLTAGE.level_3,
  768. pSmart->RGB_OUTPUT.G_VOLTAGE.level_3,
  769. pSmart->RGB_OUTPUT.B_VOLTAGE.level_3);
  770. #endif
  771. return 0;
  772. }
  773. static void v3_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  774. {
  775. unsigned long long result_1, result_2, result_3;
  776. result_1 = (pSmart->vregout_voltage)
  777. - (pSmart->GRAY.TABLE[index[V3_INDEX]].R_Gray);
  778. result_2 = result_1 * v3_denominator;
  779. result_3 = (pSmart->vregout_voltage)
  780. - (pSmart->GRAY.TABLE[index[V11_INDEX]].R_Gray);
  781. do_div(result_2, result_3);
  782. str[27] = (result_2 - v3_coefficient) & 0xff;
  783. result_1 = (pSmart->vregout_voltage)
  784. - (pSmart->GRAY.TABLE[index[V3_INDEX]].G_Gray);
  785. result_2 = result_1 * v3_denominator;
  786. result_3 = (pSmart->vregout_voltage)
  787. - (pSmart->GRAY.TABLE[index[V11_INDEX]].G_Gray);
  788. do_div(result_2, result_3);
  789. str[28] = (result_2 - v3_coefficient) & 0xff;
  790. result_1 = (pSmart->vregout_voltage)
  791. - (pSmart->GRAY.TABLE[index[V3_INDEX]].B_Gray);
  792. result_2 = result_1 * v3_denominator;
  793. result_3 = (pSmart->vregout_voltage)
  794. - (pSmart->GRAY.TABLE[index[V11_INDEX]].B_Gray);
  795. do_div(result_2, result_3);
  796. str[29] = (result_2 - v3_coefficient) & 0xff;
  797. }
  798. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  799. static int S6E8FA_ARRAY[S6E8FA_MAX] = {0, 1, 3, 11, 23, 35, 51, 87, 151, 203, 255};
  800. #define V0toV3_Coefficient 2
  801. #define V0toV3_Multiple 1
  802. #define V0toV3_denominator 3
  803. #define V3toV11_Coefficient 7
  804. #define V3toV11_Multiple 1
  805. #define V3toV11_denominator 8
  806. #define V11toV23_Coefficient 11
  807. #define V11toV23_Multiple 1
  808. #define V11toV23_denominator 12
  809. #define V23toV35_Coefficient 11
  810. #define V23toV35_Multiple 1
  811. #define V23toV35_denominator 12
  812. #define V35toV51_Coefficient 15
  813. #define V35toV51_Multiple 1
  814. #define V35toV51_denominator 16
  815. #define V51toV87_Coefficient 35
  816. #define V51toV87_Multiple 1
  817. #define V51toV87_denominator 36
  818. #define V87toV151_Coefficient 63
  819. #define V87toV151_Multiple 1
  820. #define V87toV151_denominator 64
  821. #define V151toV203_Coefficient 51
  822. #define V151toV203_Multiple 1
  823. #define V151toV203_denominator 52
  824. #define V203toV255_Coefficient 51
  825. #define V203toV255_Multiple 1
  826. #define V203toV255_denominator 52
  827. static int cal_gray_scale_linear(int up, int low, int coeff,
  828. int mul, int deno, int cnt)
  829. {
  830. unsigned long long result_1, result_2, result_3, result_4;
  831. result_1 = up - low;
  832. result_2 = (result_1 * (coeff - (cnt * mul))) << BIT_SHIFT;
  833. do_div(result_2, deno);
  834. result_3 = result_2 >> BIT_SHIFT;
  835. result_4 = low + result_3;
  836. return (int)result_4;
  837. }
  838. static int generate_gray_scale(struct SMART_DIM *pSmart)
  839. {
  840. int cnt = 0, cal_cnt = 0;
  841. int array_index = 0;
  842. struct GRAY_VOLTAGE *ptable = (struct GRAY_VOLTAGE *)
  843. (&(pSmart->GRAY.TABLE));
  844. for (cnt = 0; cnt < S6E8FA_MAX; cnt++) {
  845. pSmart->GRAY.TABLE[S6E8FA_ARRAY[cnt]].R_Gray =
  846. ((int *)&(pSmart->RGB_OUTPUT.R_VOLTAGE))[cnt];
  847. pSmart->GRAY.TABLE[S6E8FA_ARRAY[cnt]].G_Gray =
  848. ((int *)&(pSmart->RGB_OUTPUT.G_VOLTAGE))[cnt];
  849. pSmart->GRAY.TABLE[S6E8FA_ARRAY[cnt]].B_Gray =
  850. ((int *)&(pSmart->RGB_OUTPUT.B_VOLTAGE))[cnt];
  851. }
  852. /*
  853. below codes use hard coded value.
  854. So it is possible to modify on each model.
  855. V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255
  856. */
  857. for (cnt = 0; cnt < S6E8FA_GRAY_SCALE_MAX; cnt++) {
  858. if (cnt == S6E8FA_ARRAY[0]) {
  859. /* 0 */
  860. array_index = 0;
  861. cal_cnt = 0;
  862. } else if ((cnt > S6E8FA_ARRAY[0]) &&
  863. (cnt < S6E8FA_ARRAY[2])) {
  864. /* 1 ~ 2 */
  865. array_index = 2;
  866. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  867. ptable[S6E8FA_ARRAY[array_index-2]].R_Gray,
  868. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  869. V0toV3_Coefficient, V0toV3_Multiple,
  870. V0toV3_denominator, cal_cnt);
  871. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  872. ptable[S6E8FA_ARRAY[array_index-2]].G_Gray,
  873. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  874. V0toV3_Coefficient, V0toV3_Multiple,
  875. V0toV3_denominator, cal_cnt);
  876. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  877. ptable[S6E8FA_ARRAY[array_index-2]].B_Gray,
  878. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  879. V0toV3_Coefficient, V0toV3_Multiple,
  880. V0toV3_denominator , cal_cnt);
  881. cal_cnt++;
  882. } else if (cnt == S6E8FA_ARRAY[2]) {
  883. /* 3 */
  884. cal_cnt = 0;
  885. } else if ((cnt > S6E8FA_ARRAY[2]) &&
  886. (cnt < S6E8FA_ARRAY[3])) {
  887. /* 4 ~ 10 */
  888. array_index = 3;
  889. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  890. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  891. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  892. V3toV11_Coefficient, V3toV11_Multiple,
  893. V3toV11_denominator, cal_cnt);
  894. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  895. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  896. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  897. V3toV11_Coefficient, V3toV11_Multiple,
  898. V3toV11_denominator, cal_cnt);
  899. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  900. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  901. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  902. V3toV11_Coefficient, V3toV11_Multiple,
  903. V3toV11_denominator , cal_cnt);
  904. cal_cnt++;
  905. } else if (cnt == S6E8FA_ARRAY[3]) {
  906. /* 11 */
  907. cal_cnt = 0;
  908. } else if ((cnt > S6E8FA_ARRAY[3]) &&
  909. (cnt < S6E8FA_ARRAY[4])) {
  910. /* 12 ~ 22 */
  911. array_index = 4;
  912. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  913. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  914. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  915. V11toV23_Coefficient, V11toV23_Multiple,
  916. V11toV23_denominator, cal_cnt);
  917. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  918. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  919. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  920. V11toV23_Coefficient, V11toV23_Multiple,
  921. V11toV23_denominator, cal_cnt);
  922. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  923. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  924. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  925. V11toV23_Coefficient, V11toV23_Multiple,
  926. V11toV23_denominator , cal_cnt);
  927. cal_cnt++;
  928. } else if (cnt == S6E8FA_ARRAY[4]) {
  929. /* 23 */
  930. cal_cnt = 0;
  931. } else if ((cnt > S6E8FA_ARRAY[4]) &&
  932. (cnt < S6E8FA_ARRAY[5])) {
  933. /* 24 ~ 34 */
  934. array_index = 5;
  935. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  936. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  937. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  938. V23toV35_Coefficient, V23toV35_Multiple,
  939. V23toV35_denominator, cal_cnt);
  940. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  941. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  942. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  943. V23toV35_Coefficient, V23toV35_Multiple,
  944. V23toV35_denominator, cal_cnt);
  945. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  946. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  947. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  948. V23toV35_Coefficient, V23toV35_Multiple,
  949. V23toV35_denominator , cal_cnt);
  950. cal_cnt++;
  951. } else if (cnt == S6E8FA_ARRAY[5]) {
  952. /* 35 */
  953. cal_cnt = 0;
  954. } else if ((cnt > S6E8FA_ARRAY[5]) &&
  955. (cnt < S6E8FA_ARRAY[6])) {
  956. /* 36 ~ 50 */
  957. array_index = 6;
  958. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  959. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  960. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  961. V35toV51_Coefficient, V35toV51_Multiple,
  962. V35toV51_denominator, cal_cnt);
  963. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  964. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  965. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  966. V35toV51_Coefficient, V35toV51_Multiple,
  967. V35toV51_denominator, cal_cnt);
  968. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  969. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  970. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  971. V35toV51_Coefficient, V35toV51_Multiple,
  972. V35toV51_denominator, cal_cnt);
  973. cal_cnt++;
  974. } else if (cnt == S6E8FA_ARRAY[6]) {
  975. /* 51 */
  976. cal_cnt = 0;
  977. } else if ((cnt > S6E8FA_ARRAY[6]) &&
  978. (cnt < S6E8FA_ARRAY[7])) {
  979. /* 52 ~ 86 */
  980. array_index = 7;
  981. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  982. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  983. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  984. V51toV87_Coefficient, V51toV87_Multiple,
  985. V51toV87_denominator, cal_cnt);
  986. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  987. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  988. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  989. V51toV87_Coefficient, V51toV87_Multiple,
  990. V51toV87_denominator, cal_cnt);
  991. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  992. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  993. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  994. V51toV87_Coefficient, V51toV87_Multiple,
  995. V51toV87_denominator, cal_cnt);
  996. cal_cnt++;
  997. } else if (cnt == S6E8FA_ARRAY[7]) {
  998. /* 87 */
  999. cal_cnt = 0;
  1000. } else if ((cnt > S6E8FA_ARRAY[7]) &&
  1001. (cnt < S6E8FA_ARRAY[8])) {
  1002. /* 88 ~ 150 */
  1003. array_index = 8;
  1004. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1005. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  1006. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  1007. V87toV151_Coefficient, V87toV151_Multiple,
  1008. V87toV151_denominator, cal_cnt);
  1009. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1010. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  1011. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  1012. V87toV151_Coefficient, V87toV151_Multiple,
  1013. V87toV151_denominator, cal_cnt);
  1014. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1015. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  1016. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  1017. V87toV151_Coefficient, V87toV151_Multiple,
  1018. V87toV151_denominator, cal_cnt);
  1019. cal_cnt++;
  1020. } else if (cnt == S6E8FA_ARRAY[8]) {
  1021. /* 151 */
  1022. cal_cnt = 0;
  1023. } else if ((cnt > S6E8FA_ARRAY[8]) &&
  1024. (cnt < S6E8FA_ARRAY[9])) {
  1025. /* 152 ~ 202 */
  1026. array_index = 9;
  1027. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1028. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  1029. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  1030. V151toV203_Coefficient, V151toV203_Multiple,
  1031. V151toV203_denominator, cal_cnt);
  1032. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1033. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  1034. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  1035. V151toV203_Coefficient, V151toV203_Multiple,
  1036. V151toV203_denominator, cal_cnt);
  1037. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1038. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  1039. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  1040. V151toV203_Coefficient, V151toV203_Multiple,
  1041. V151toV203_denominator, cal_cnt);
  1042. cal_cnt++;
  1043. } else if (cnt == S6E8FA_ARRAY[9]) {
  1044. /* 203 */
  1045. cal_cnt = 0;
  1046. } else if ((cnt > S6E8FA_ARRAY[9]) &&
  1047. (cnt < S6E8FA_ARRAY[10])) {
  1048. /* 204 ~ 254 */
  1049. array_index = 10;
  1050. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1051. ptable[S6E8FA_ARRAY[array_index-1]].R_Gray,
  1052. ptable[S6E8FA_ARRAY[array_index]].R_Gray,
  1053. V203toV255_Coefficient, V203toV255_Multiple,
  1054. V203toV255_denominator, cal_cnt);
  1055. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1056. ptable[S6E8FA_ARRAY[array_index-1]].G_Gray,
  1057. ptable[S6E8FA_ARRAY[array_index]].G_Gray,
  1058. V203toV255_Coefficient, V203toV255_Multiple,
  1059. V203toV255_denominator, cal_cnt);
  1060. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1061. ptable[S6E8FA_ARRAY[array_index-1]].B_Gray,
  1062. ptable[S6E8FA_ARRAY[array_index]].B_Gray,
  1063. V203toV255_Coefficient, V203toV255_Multiple,
  1064. V203toV255_denominator, cal_cnt);
  1065. cal_cnt++;
  1066. } else {
  1067. if (cnt == S6E8FA_ARRAY[10]) {
  1068. pr_info("%s end\n", __func__);
  1069. } else {
  1070. pr_err("%s fail cnt:%d\n", __func__, cnt);
  1071. return -EINVAL;
  1072. }
  1073. }
  1074. }
  1075. #ifdef SMART_DIMMING_DEBUG
  1076. for (cnt = 0; cnt < S6E8FA_GRAY_SCALE_MAX; cnt++) {
  1077. pr_info("%s %8d %8d %8d %d\n", __func__,
  1078. pSmart->GRAY.TABLE[cnt].R_Gray,
  1079. pSmart->GRAY.TABLE[cnt].G_Gray,
  1080. pSmart->GRAY.TABLE[cnt].B_Gray, cnt);
  1081. }
  1082. #endif
  1083. return 0;
  1084. }
  1085. static void mtp_offset_substraction(struct SMART_DIM *pSmart, char *str)
  1086. {
  1087. int level_255_temp = 0;
  1088. int level_255_temp_MSB = 0;
  1089. int MTP_V255;
  1090. /*subtration MTP_OFFSET value from generated gamma table*/
  1091. level_255_temp = (str[0] << 8) | str[1] ;
  1092. MTP_V255 = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  1093. pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
  1094. level_255_temp -= MTP_V255;
  1095. level_255_temp_MSB = level_255_temp / 256;
  1096. str[0] = level_255_temp_MSB & 0xff;
  1097. str[1] = level_255_temp & 0xff;
  1098. level_255_temp = (str[2] << 8) | str[3] ;
  1099. MTP_V255 = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  1100. pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
  1101. level_255_temp -= MTP_V255;
  1102. level_255_temp_MSB = level_255_temp / 256;
  1103. str[2] = level_255_temp_MSB & 0xff;
  1104. str[3] = level_255_temp & 0xff;
  1105. level_255_temp = (str[4] << 8) | str[5] ;
  1106. MTP_V255 = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  1107. pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
  1108. level_255_temp -= MTP_V255;
  1109. level_255_temp_MSB = level_255_temp / 256;
  1110. str[4] = level_255_temp_MSB & 0xff;
  1111. str[5] = level_255_temp & 0xff;
  1112. str[6] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203);
  1113. str[7] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203);
  1114. str[8] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203);
  1115. str[9] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151);
  1116. str[10] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151);
  1117. str[11] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151);
  1118. str[12] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87);
  1119. str[13] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87);
  1120. str[14] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87);
  1121. str[15] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51);
  1122. str[16] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51);
  1123. str[17] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51);
  1124. str[18] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35);
  1125. str[19] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35);
  1126. str[20] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35);
  1127. str[21] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23);
  1128. str[22] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23);
  1129. str[23] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23);
  1130. str[24] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11);
  1131. str[25] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11);
  1132. str[26] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11);
  1133. str[27] -= char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3);
  1134. str[28] -= char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3);
  1135. str[29] -= char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3);
  1136. }
  1137. static int searching_function(long long candela, int *index, int gamma_curve)
  1138. {
  1139. long long delta_1 = 0, delta_2 = 0;
  1140. int cnt;
  1141. /*
  1142. * This searching_functin should be changed with improved
  1143. searcing algorithm to reduce searching time.
  1144. */
  1145. *index = -1;
  1146. for (cnt = 0; cnt < (S6E8FA_GRAY_SCALE_MAX-1); cnt++) {
  1147. if (gamma_curve == GAMMA_CURVE_1P9) {
  1148. delta_1 = candela - curve_1p9[cnt];
  1149. delta_2 = candela - curve_1p9[cnt+1];
  1150. } else {
  1151. delta_1 = candela - curve_2p2[cnt];
  1152. delta_2 = candela - curve_2p2[cnt+1];
  1153. }
  1154. if (delta_2 < 0) {
  1155. *index = (delta_1 + delta_2) <= 0 ? cnt : cnt+1;
  1156. break;
  1157. }
  1158. if (delta_1 == 0) {
  1159. *index = cnt;
  1160. break;
  1161. }
  1162. if (delta_2 == 0) {
  1163. *index = cnt+1;
  1164. break;
  1165. }
  1166. }
  1167. if (*index == -1)
  1168. return -EINVAL;
  1169. else
  1170. return 0;
  1171. }
  1172. /* -1 means V1 */
  1173. #define S6E8FA_TABLE_MAX (S6E8FA_MAX-1)
  1174. static void(*Make_hexa[S6E8FA_TABLE_MAX])(int*, struct SMART_DIM*, char*) = {
  1175. v255_hexa,
  1176. v203_hexa,
  1177. v151_hexa,
  1178. v87_hexa,
  1179. v51_hexa,
  1180. v35_hexa,
  1181. v23_hexa,
  1182. v11_hexa,
  1183. v3_hexa,
  1184. vt_hexa,
  1185. };
  1186. #if defined(AID_OPERATION)
  1187. /*
  1188. * Because of AID operation & display quality.
  1189. *
  1190. * only smart dimmg range : 300CD ~ 190CD
  1191. * AOR fix range : 180CD ~ 110CD AOR 40%
  1192. * AOR adjust range : 100CD ~ 10CD
  1193. */
  1194. #define AOR_FIX_CD 183
  1195. #define AOR_ADJUST_CD 110
  1196. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1197. #define CCG6_MAX_TABLE 74
  1198. static int ccg6_candela_table[][2] = {
  1199. {2, 0,},
  1200. {3, 1,},
  1201. {4, 2,},
  1202. {5, 3,},
  1203. {6, 4,},
  1204. {7, 5,},
  1205. {8, 6,},
  1206. {9, 7,},
  1207. {10, 8,},
  1208. {11, 9,},
  1209. {12, 10,},
  1210. {13, 11,},
  1211. {14, 12,},
  1212. {15, 13,},
  1213. {16, 14,},
  1214. {17, 15,},
  1215. {19, 16,},
  1216. {20, 17,},
  1217. {21, 18,},
  1218. {22, 19,},
  1219. {24, 20,},
  1220. {25, 21,},
  1221. {27, 22,},
  1222. {29, 23,},
  1223. {30, 24,},
  1224. {32, 25,},
  1225. {34, 26,},
  1226. {37, 27,},
  1227. {39, 28,},
  1228. {41, 29,},
  1229. {44, 30,},
  1230. {47, 31,},
  1231. {50, 32,},
  1232. {53, 33,},
  1233. {56, 34,},
  1234. {60, 35,},
  1235. {64, 36,},
  1236. {68, 37,},
  1237. {72, 38,},
  1238. {77, 39,},
  1239. {82, 40,},
  1240. {87, 41,},
  1241. {93, 42,},
  1242. {98, 43,},
  1243. {105, 44,},
  1244. {106, 45,},
  1245. {107, 46,},
  1246. {108, 47,},
  1247. {109, 48,},
  1248. {110, 49,},
  1249. {111, 50,},
  1250. {119, 51,},
  1251. {126, 52,},
  1252. {134, 53,},
  1253. {143, 54,},
  1254. {152, 55,},
  1255. {162, 56,},
  1256. {172, 57,},
  1257. {173, 58,},
  1258. {175, 59,},
  1259. {177, 60,},
  1260. {179, 61,},
  1261. {181, 62,},
  1262. {183, 63,},
  1263. {195, 64,},
  1264. {207, 65,},
  1265. {220, 66,},
  1266. {234, 67,},
  1267. {249, 68,},
  1268. {265, 69,},
  1269. {282, 70,},
  1270. {300, 71,},
  1271. {316, 72,},
  1272. {333, 73,},
  1273. {350,74,},
  1274. };
  1275. #else
  1276. #define CCG6_MAX_TABLE 71
  1277. static int ccg6_candela_table[][2] = {
  1278. {5, 0,},
  1279. {6, 1,},
  1280. {7, 2,},
  1281. {8, 3,},
  1282. {9, 4,},
  1283. {10, 5,},
  1284. {11, 6,},
  1285. {12, 7,},
  1286. {13, 8,},
  1287. {14, 9,},
  1288. {15, 10,},
  1289. {16, 11,},
  1290. {17, 12,},
  1291. {19, 13,},
  1292. {20, 14,},
  1293. {21, 15,},
  1294. {22, 16,},
  1295. {24, 17,},
  1296. {25, 18,},
  1297. {27, 19,},
  1298. {29, 20,},
  1299. {30, 21,},
  1300. {32, 22,},
  1301. {34, 23,},
  1302. {37, 24,},
  1303. {39, 25,},
  1304. {41, 26,},
  1305. {44, 27,},
  1306. {47, 28,},
  1307. {50, 29,},
  1308. {53, 30,},
  1309. {56, 31,},
  1310. {60, 32,},
  1311. {64, 33,},
  1312. {68, 34,},
  1313. {72, 35,},
  1314. {77, 36,},
  1315. {82, 37,},
  1316. {87, 38,},
  1317. {93, 39,},
  1318. {98, 40,},
  1319. {105, 41,},
  1320. {106, 42,},
  1321. {107, 43,},
  1322. {108, 44,},
  1323. {109, 45,},
  1324. {110, 46,},
  1325. {111, 47,},
  1326. {119, 48,},
  1327. {126, 49,},
  1328. {134, 50,},
  1329. {143, 51,},
  1330. {152, 52,},
  1331. {162, 53,},
  1332. {172, 54,},
  1333. {173, 55,},
  1334. {175, 56,},
  1335. {177, 57,},
  1336. {179, 58,},
  1337. {181, 59,},
  1338. {183, 60,},
  1339. {195, 61,},
  1340. {207, 62,},
  1341. {220, 63,},
  1342. {234, 64,},
  1343. {249, 65,},
  1344. {265, 66,},
  1345. {282, 67,},
  1346. {300, 68,},
  1347. {316, 69,},
  1348. {333, 70,},
  1349. {350, 71,},
  1350. };
  1351. #endif
  1352. #define RGB_COMPENSATION 24
  1353. static int find_cadela_table(int brightness)
  1354. {
  1355. int loop;
  1356. int err = -1;
  1357. for(loop = 0; loop <= CCG6_MAX_TABLE; loop++)
  1358. if (ccg6_candela_table[loop][0] == brightness)
  1359. return ccg6_candela_table[loop][1];
  1360. return err;
  1361. }
  1362. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1363. static int gradation_offset_revJ[][9] = {
  1364. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1365. /* 2 */ {0, 10, 19, 28, 37, 41, 45, 0, 0},
  1366. /* 3 */ {0, 7, 15, 23, 30, 33, 36, 39, 39},
  1367. /* 4 */ {0, 8, 14, 20, 26, 28, 32, 34, 39},
  1368. /* 5 */ {0, 5, 8, 13, 17, 19, 22, 24, 8},
  1369. /* 6 */ {0, 4, 6, 9, 13, 15, 19, 23, 8},
  1370. /* 7 */ {0, 3, 5, 8, 12, 14, 18, 22, 8},
  1371. /* 8 */ {0, 3, 5, 7, 11, 13, 17, 21, 8},
  1372. /* 9*/ {0, 3, 5, 7, 11, 12, 16, 20, 8},
  1373. /* 10 */ {0, 3, 4, 6, 10, 11, 15, 19, 8},
  1374. /* 11 */ {0, 3, 4, 6, 9, 10, 14, 19, 8},
  1375. /* 12 */ {0, 3, 4, 5, 8, 9, 13, 16, 8},
  1376. /* 13 */ { 0, 3, 4, 5, 7, 8, 12, 17, 8 },
  1377. /* 14 */ { 0, 3, 4, 5, 7, 8, 11, 18, 8 },
  1378. /* 15 */ { 0, 3, 4, 5, 7, 8, 11, 15, 8 },
  1379. /* 16 */ { 0, 3, 4, 4, 6, 8, 11, 15, 8 },
  1380. /* 17 */ { 0, 3, 4, 4, 6, 8, 10, 14, 8 },
  1381. /* 19 */ { 0, 3, 3, 4, 5, 7, 9, 13, 8 },
  1382. /* 20 */ { 0, 3, 3, 4, 5, 7, 9, 12, 8 },
  1383. /* 21 */ { 0, 3, 3, 4, 4, 6, 9, 12, 8 },
  1384. /* 22 */ { 0, 2, 3, 4, 4, 6, 8, 11, 8 },
  1385. /* 24 */ { 0, 2, 3, 3, 4, 6, 8, 11, 8 },
  1386. /* 25 */ { 0, 2, 3, 3, 4, 6, 7, 10, 8 },
  1387. /* 27 */ { 0, 2, 3, 3, 4, 5, 7, 10, 8 },
  1388. /* 29 */ { 0, 2, 3, 3, 3, 5, 7, 10, 8 },
  1389. /* 30 */ { 0, 2, 3, 3, 3, 5, 7, 10, 8 },
  1390. /* 32 */ { 0, 2, 3, 3, 3, 4, 7, 10, 8 },
  1391. /* 34 */ { 0, 2, 3, 2, 3, 4, 6, 8, 7 },
  1392. /* 37 */ { 0, 2, 3, 2, 3, 4, 6, 8, 7 },
  1393. /* 39 */ { 0, 2, 3, 2, 2, 3, 5, 7, 7 },
  1394. /* 41 */ { 0, 2, 2, 2, 2, 3, 5, 7, 7 },
  1395. /* 44 */ { 0, 2, 2, 2, 2, 3, 4, 6, 6 },
  1396. /* 47 */ { 0, 2, 2, 2, 2, 2, 4, 6, 6 },
  1397. /* 50 */ { 0, 2, 2, 1, 2, 2, 4, 5, 6 },
  1398. /* 53 */ { 0, 2, 2, 1, 2, 2, 3, 5, 5 },
  1399. /* 56 */ { 0, 2, 2, 1, 1, 2, 3, 4, 5 },
  1400. /* 60 */ { 0, 2, 2, 1, 1, 1, 3, 4, 5 },
  1401. /* 64 */ { 0, 2, 2, 1, 1, 1, 2, 3, 5 },
  1402. /* 68 */ { 0, 2, 2, 1, 1, 1, 2, 3, 5 },
  1403. /* 72 */ { 0, 2, 2, 1, 1, 1, 2, 3, 4 },
  1404. /* 77 */ { 0, 2, 2, 1, 1, 1, 1, 3, 4 },
  1405. /* 82 */ { 0, 2, 2, 1, 1, 1, 1, 2, 3 },
  1406. /* 87 */ { 0, 1, 2, 1, 1, 1, 1, 2, 3 },
  1407. /* 93 */ { 0, 1, 2, 1, 1, 1, 1, 2, 3 },
  1408. /* 98 */ { 0, 1, 2, 1, 1, 1, 1, 1, 3 },
  1409. /* 105*/{ 0, 1, 2, 1, 1, 1, 1, 1, 3 },
  1410. /* 106*/{ 0, 1, 1, 1, 1, 1, 1, 2, 4 },
  1411. /* 107*/{ 0, 1, 1, 1, 1, 2, 2, 3, 4 },
  1412. /* 108*/{ 0, 1, 1, 1, 1, 2, 3, 3, 3 },
  1413. /* 109*/{ 0, 0, 1, 1, 1, 2, 3, 4, 3 },
  1414. /* 110*/{ 0, 1, 2, 2, 2, 3, 3, 4, 3 },
  1415. /* 111*/{ 0, 1, 2, 2, 1, 2, 2, 3, 4 },
  1416. /* 119*/{ 0, 1, 2, 2, 1, 2, 2, 3, 4 },
  1417. /* 126*/{ 0, 1, 1, 1, 1, 1, 2, 3, 3 },
  1418. /* 134*/{ 0, 1, 1, 1, 1, 1, 2, 3, 3 },
  1419. /* 143*/{ 0, 1, 2, 2, 1, 1, 1, 2, 3 },
  1420. /* 152*/{ 0, 1, 2, 2, 1, 1, 1, 2, 3 },
  1421. /* 162*/{ 0, 2, 2, 2, 1, 0, 1, 2, 3 },
  1422. /* 172*/{ 0, 2, 2, 2, 1, 0, 1, 2, 3 },
  1423. /* 173*/{ 0, 1, 2, 2, 2, 2, 2, 1, 2 },
  1424. /* 175*/{ 0, 1, 2, 2, 2, 2, 2, 1, 2 },
  1425. /* 177*/{ 0, 1, 2, 2, 2, 2, 2, 1, 2 },
  1426. /* 179*/{ 0, 1, 2, 2, 1, 1, 1, 1, 2 },
  1427. /* 181*/{ 0, 1, 2, 2, 2, 1, 1, 1, 2 },
  1428. /* 183*/{ 3, 2, 3, 2, 1, 1, 1, 1, 3 },
  1429. /* 195*/{ 4, 1, 2, 2, 1, 1, 1, 1, 3 },
  1430. /* 207*/{ 4, 1, 2, 1, 0, 1, 0, 1, 2 },
  1431. /* 220*/{ 4, 1, 2, 1, 0, 1, 0, 1, 1 },
  1432. /* 234*/{ 4, 1, 2, 1, 0, 1, 0, 0, 2 },
  1433. /* 249*/{ 3, 1, 1, 1, 0, 0, 0, 1, 2 },
  1434. /* 265*/{ 3, 0, 1, 1, 0, 0, 0, 1, 2 },
  1435. /* 282*/{ 2, 0, 1, 1, 0, 0, 0, 0, 1 },
  1436. /* 300*/{ 2, 0, 0, 0, 0, 0, 0, 0, 0 },
  1437. /* 316*/{ 2, 0, 0, 0, 0, 0, 0, 0, 0 },
  1438. /* 333*/{ 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1439. /* 350*/{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  1440. };
  1441. static int rgb_offset_revJ[][RGB_COMPENSATION] = {
  1442. /* R255 G255 B255 R203 G203 B203 R151 G151 B151 R87 G87 B87 R51 G51 B51 R35 G35 B35 R23 G23 B23 R11 G11 B11*/
  1443. /* 2 */ { -7, 1, -7, -6, -2, -6, -9, -1, -8, -17, 3, -14, -15, 4, -16, -2, 1, -8, 3, 1, -6, 0, -2, 0 },
  1444. /* 3 */ { -4, 1, -4, -5, -1, -5, -8, -1, -8, -15, 4, -13, -15, 6, -16, -5, 2, -8, 2, 2, -8, -1, 1, -8 },
  1445. /* 4 */ { -4, 0, -4, -4, 0, -4, -6, 1, -5, -14, 5, -12, -14, 7, -16, -7, 4, -9, 0, 4, -9, -2, 4, -10 },
  1446. /* 5 */ { -2, 1, -2, -2, 1, -2, -2, 4, -1, -10, 8, -7, -10, 9, -15, -1, 7, -5, -4, 5, -9, -13, 7, -17 },
  1447. /* 6 */ { -1, 1, -1, -2, 1, -1, -3, 4, -1, -10, 8, -7, -10, 8, -14, -4, 7, -6, -10, 6, -14, -12, 7, -16 },
  1448. /* 7 */ { -1, 1, -1, -2, 1, -2, -2, 4, 0, -10, 8, -6, -8, 8, -13, -4, 5, -6, -10, 6, -14, -11, 7, -15 },
  1449. /* 8 */ { -1, 1, -1, -2, 1, -1, -2, 3, 0, -8, 8, -5, -8, 7, -12, -4, 5, -6, -10, 6, -14, -10, 7, -14 },
  1450. /* 9 */ { -1, 1, -1, -2, 0, -1, -2, 3, 0, -8, 6, -5, -8, 7, -13, -4, 5, -6, -10, 6, -13, -9, 7, -13 },
  1451. /* 10 */ { 0, 1, -1, -3, 0, -1, -2, 2, 0, -8, 5, -6, -9, 6, -14, -3, 5, -9, -10, 6, -13, -9, 7, -12 },
  1452. /* 11 */ { 0, 1, 0, -2, 0, -1, -2, 2, 0, -8, 5, -4, -8, 6, -14, -4, 6, -9, -10, 6, -12, -4, 6, -8 },
  1453. /* 12 */ { 0, 1, 0, -2, 0, -1, -1, 2, 1, -8, 5, -5, -7, 6, -12, -3, 5, -9, -10, 6, -11, -9, 6, -20 },
  1454. /* 13 */ { 0, 1, 0, -2, 0, -1, -1, 2, 1, -8, 4, -4, -6, 7, -11, -2, 5, -8, -10, 6, -11, -8, 6, -20},
  1455. /* 14 */ { 0, 1, 0, -2, 0, -1, -1, 1, 1, -8, 4, -4, -6, 6, -10, -4, 6, -8, -11, 6, -16, -8, 6, -20 },
  1456. /* 15 */ { 0, 1, 0, -2, 0, -1, -1, 1, 1, -8, 3, -4, -6, 6, -10, -4, 5, -8, -10, 6, -13, -5, 6, -13 },
  1457. /* 16 */ { 0, 1, 0, -2, 0, -1, -1, 1, 1, -7, 3, -4, -4, 6, -9, -5, 4, -6, -10, 6, -13, -5, 6, -12 },
  1458. /* 17 */ { 0, 1, 0, -1, 0, 0, -2, 1, 0, -7, 3, -3, -2, 6, -8, -5, 4, -7, -10, 6, -14, -5, 6, -13 },
  1459. /* 19 */ { 0, 1, 0, -1, 0, 0, -1, 1, 0, -7, 2, -3, -3, 6, -7, -6, 3, -10, -9, 6, -13, -7, 6, -16 },
  1460. /* 20 */ { -1, 0, -1, -1, 0, 0, -1, 1, 0, -7, 2, -3, -2, 6, -7, -6, 3, -8, -8, 6, -12, -8, 6, -19 },
  1461. /* 21 */ { -1, 0, -1, -1, 0, 0, -1, 1, 0, -7, 2, -3, -3, 6, -7, -6, 3, -8, -7, 6, -11, -9, 6, -20 },
  1462. /* 22 */ { -1, 0, -1, -1, 0, 0, -1, 1, 0, -6, 2, -2, -1, 6, -6, -7, 2, -8, -7, 6, -13, -10, 6, -20 },
  1463. /* 24 */ { 0, 0, -1, -1, 0, 0, -1, 1, 0, -6, 2, -2, 0, 4, -6, -7, 2, -7, -7, 6, -12, -9, 6, -20 },
  1464. /* 25 */ { 0, 0, -1, -2, 0, 0, -1, 0, 0, -5, 2, -2, 0, 5, -6, -7, 2, -6, -7, 6, -13, -7, 6, -20 },
  1465. /* 27 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -6, 1, -2, -1, 4, -7, -5, 2, -7, -7, 6, -12, -10, 6, -20 },
  1466. /* 29 */ { 0, 1, 0, 0, 0, 0, -1, 0, 0, -6, 1, -2, -2, 4, -6, -5, 2, -6, -5, 5, -10, -7, 6, -18 },
  1467. /* 30 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -6, 1, -1, -2, 4, -6, -5, 2, -6, -5, 4, -10, -7, 6, -18 },
  1468. /* 32 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -6, 1, -2, -2, 3, -7, -4, 2, -6, -6, 4, -10, -7, 6, -16 },
  1469. /* 34 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -5, 1, -2, -1, 3, -6, -4, 2, -5, -6, 4, -10, -9, 6, -22 },
  1470. /* 37 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -5, 1, -2, 0, 2, -6, -3, 2, -5, -5, 4, -7, -9, 6, -19 },
  1471. /* 39 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -5, 1, -2, -1, 3, -5, -4, 2, -4, -4, 4, -8, -9, 6, -21 },
  1472. /* 41 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -5, 1, -1, 0, 3, -5, -4, 2,-4, -4, 4, -7, -9, 6, -20},
  1473. /* 44 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -5, 1, -1, 0, 3, -5, -3, 2, -3, -3, 4, -7, -8, 6, -20 },
  1474. /* 47 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -5, 1, -2, 1, 2, -5, -3, 2, -3, -4, 4, -6, -7, 7, -19 },
  1475. /* 50 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -5, 1, -1, 1, 2, -6, -3, 2, -3, -4, 3, -5, -8, 7, -21 },
  1476. /* 53 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, -1, 1, 2, -5, -3, 1, -2, -3, 3, -6, -8, 7, -19 },
  1477. /* 56 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, -1, 1, 3, -3, -2, 1, -3, -3, 2, -5, -7, 7, -21},
  1478. /* 60 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, -1, 1, 2, -3, -1, 1, -2, -2, 2, -4, -6, 6, -19 },
  1479. /* 64 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -3, 1, -1, 1, 2, -3, -1, 1, -1, -2, 2, -4, -4, 6, -19 },
  1480. /* 68 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, 0, 1, 1, -4, 0, 1, -1, -2, 2, -4, -4, 6, -17 },
  1481. /* 72 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -3, 1, 0, 1, 1, -4, -1, 0, -1, -1, 2, -2, -3, 5, -16 },
  1482. /* 77 */ { 0, 0, 0, -1, 0, 1, -1, 0, 0, -4, 1, 0, 1, 0, -4, 0, 0, -1, 0, 2, -2, -2, 5, -14 },
  1483. /* 82 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 0, -1, 1, 1, -3, 0, 0, 0, 0, 1, -2, -1, 5, -14 },
  1484. /* 87 */ { 0, 0, 0, -1, 0, -1, -1, 0, 0, -4, 0, -1, 1, 0, -3, 0, 0, 0, 1, 0, -2, -2, 4, -13 },
  1485. /* 93 */ { 0, 0, 0, 0, 0, 0, -1, 0, 0, -4, 0, -1, 1, 0, -3, 0, -1, 0, 1, 0, -1, -1, 4, -11 },
  1486. /* 98 */ { 0, 0, 0, 0, 0, 0, -1, 0, 0, -4, 0, 0, 1, 0, -4, 0, -1, 0, 2, 0, 0, 3, 5, -10 },
  1487. /* 105 */{ 0, 0, 0, 0, 0, 0, -1, 0, 0, -4, 0, 0, 2, 0, -3, 0, -1, 1, 1, 0, 0, 3, 3, -10 },
  1488. /* 106 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, -2, 0, -1, 0, 2, -2, -1, 1, -4 },
  1489. /* 107 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, -1, -2, 0, -1, -1, 2, -4, -1, 1, -4 },
  1490. /* 108 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, -1, -2, 1, -1, -2, 2, -5, -2, 2, -5 },
  1491. /* 109 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, -1, -2, 1, -1, -3, 2, -5, -2, 2, -5 },
  1492. /* 110 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 0, -2, -1, 1, -1, -4, -2, -5, -2, 2, -5 },
  1493. /* 111 */{ 0, 0, 0, 0, 0, -1, 0, 0, 1, -4, 0, 0, -1, 0, -3, 0, 0, -3, -2, 1, -2, -4, 7, -14 },
  1494. /* 119 */{ 0, 0, 0, 0, 0, 0, 0, 0, 1, -3, 0, -1, 0, 0, -3, 0, 2, -1, -2, 1, -3, -3, 7, -13 },
  1495. /* 126 */{ 1, 0, 1, 0, 0, -1, 0, 0, 0, -3, 0, -1, -1, 0, -3, 1, 2, -1, -2, 1, -3, -2, 7, -12 },
  1496. /* 134 */{ 1, 0, 1, 0, 0, -1, 0, 0, 1, -3, 0, -1, -2, 0, -3, 1, 2, -1, -2, 1, -3, -2, 7, -11 },
  1497. /* 143 */{ 0, 0, 1, 0, 0, -1, -1, 0, 0, -1, 0, 1, -2, 0, -2, 1, 2, -2, -2, 1, -2, -1, 8, -10 },
  1498. /* 152 */{ -1, 0, 0, 0, 0, -1, 1, 0, 0, -2, 0, 1, -2, 0, -3, 0, 1, -2, -2, 1, -2, -2, 8, -9 },
  1499. /* 162 */{ 0, 0, 1, 0, 0, -1, 1, 0, 0, -2, 0, 0, -1, 0, -2, 0, 1, -2, -2, 1, -2, -1, 9, -6 },
  1500. /* 172 */{ -1, 0, 0, 2, 0, 1, 0, 0, 0, -2, 0, 1, -1, 0, -3, 0, 1, -2, -4, 0, -4, -2, 7, -8 },
  1501. /* 173 */{ 0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 0, 0, 0, -2, 3, 1, -3, -2, 2, 1, -4, 2, -4 },
  1502. /* 175 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 4, 1, -3, -3, 2, 1, -4, 2, -4 },
  1503. /* 177 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 4, 1, -3, -3, 2, 0, -4, 2, -4 },
  1504. /* 179 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 5, 1, -3, -3, 1, 0, -4, 2, -4 },
  1505. /* 181 */{ 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -2, 0, -1, 5, 1, -3, -4, 1, -1, -4, 2, -3 },
  1506. /* 183 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1507. /* 195 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1508. /* 207 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1509. /* 220 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1510. /* 234 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1511. /* 249 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1512. /* 265 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1513. /* 282 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1514. /* 300 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1515. /* 316 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1516. /* 333 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1517. /* 350 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1518. };
  1519. static void gamma_init_revJ(
  1520. struct SMART_DIM *pSmart, char *str, int size)
  1521. {
  1522. long long candela_level[S6E8FA_TABLE_MAX] = {-1, };
  1523. int bl_index[S6E8FA_TABLE_MAX] = {-1, };
  1524. long long temp_cal_data = 0;
  1525. int bl_level;
  1526. int level_255_temp_MSB = 0;
  1527. int level_V255 = 0;
  1528. int point_index;
  1529. int cnt;
  1530. int table_index;
  1531. pr_debug("%s : start !!\n",__func__);
  1532. /*calculate candela level */
  1533. if (pSmart->brightness_level == 350)
  1534. bl_level = 350;
  1535. else if (pSmart->brightness_level == 333)
  1536. bl_level = 333;
  1537. else if (pSmart->brightness_level == 316)
  1538. bl_level = 316;
  1539. else if (pSmart->brightness_level == 300)
  1540. bl_level = 300;
  1541. else if (pSmart->brightness_level == 282)
  1542. bl_level = 282;
  1543. else if (pSmart->brightness_level == 265)
  1544. bl_level = 266;
  1545. else if (pSmart->brightness_level == 249)
  1546. bl_level = 249;
  1547. else if (pSmart->brightness_level == 234)
  1548. bl_level = 234;
  1549. else if (pSmart->brightness_level == 220)
  1550. bl_level = 220;
  1551. else if (pSmart->brightness_level == 207)
  1552. bl_level = 207;
  1553. else if (pSmart->brightness_level == 195)
  1554. bl_level = 195;
  1555. else if (pSmart->brightness_level == 183)
  1556. bl_level = 183;
  1557. else if (pSmart->brightness_level == 181)
  1558. bl_level = 198;
  1559. else if (pSmart->brightness_level == 179)
  1560. bl_level = 219;
  1561. else if (pSmart->brightness_level == 177)
  1562. bl_level = 228;
  1563. else if (pSmart->brightness_level == 175)
  1564. bl_level = 243;
  1565. else if (pSmart->brightness_level == 173)
  1566. bl_level = 258;
  1567. else if (pSmart->brightness_level == 172)
  1568. bl_level = 274;
  1569. else if (pSmart->brightness_level == 162)
  1570. bl_level = 264;
  1571. else if (pSmart->brightness_level == 153)
  1572. bl_level = 248;
  1573. else if (pSmart->brightness_level == 142)
  1574. bl_level = 233;
  1575. else if (pSmart->brightness_level == 134)
  1576. bl_level = 221;
  1577. else if (pSmart->brightness_level == 126)
  1578. bl_level = 209;
  1579. else if (pSmart->brightness_level == 119)
  1580. bl_level = 198;
  1581. else if (pSmart->brightness_level == 111)
  1582. bl_level = 185;
  1583. else if (pSmart->brightness_level == 110)
  1584. bl_level = 171;
  1585. else if (pSmart->brightness_level == 109)
  1586. bl_level = 159;
  1587. else if (pSmart->brightness_level == 108)
  1588. bl_level = 147;
  1589. else if (pSmart->brightness_level == 107)
  1590. bl_level = 134;
  1591. else if(pSmart->brightness_level == 106)
  1592. bl_level = 122;
  1593. else
  1594. bl_level = 110;
  1595. if (pSmart->brightness_level < 350) {
  1596. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1597. point_index = S6E8FA_ARRAY[cnt+1];
  1598. temp_cal_data =
  1599. ((long long)(candela_coeff_2p15[point_index])) *
  1600. ((long long)(bl_level));
  1601. candela_level[cnt] = temp_cal_data;
  1602. }
  1603. } else {
  1604. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1605. point_index = S6E8FA_ARRAY[cnt+1];
  1606. temp_cal_data =
  1607. ((long long)(candela_coeff_2p2[point_index])) *
  1608. ((long long)(bl_level));
  1609. candela_level[cnt] = temp_cal_data;
  1610. }
  1611. }
  1612. #ifdef SMART_DIMMING_DEBUG
  1613. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  1614. candela_level[0], candela_level[1], candela_level[2]);
  1615. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  1616. candela_level[3], candela_level[4], candela_level[5]);
  1617. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  1618. candela_level[6], candela_level[7], candela_level[8]);
  1619. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  1620. #endif
  1621. /* max 350cd */
  1622. memcpy(curve_1p9, curve_1p9_350, sizeof(curve_1p9_350));
  1623. memcpy(curve_2p2, curve_2p2_350, sizeof(curve_1p9_350));
  1624. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1625. if (searching_function(candela_level[cnt],
  1626. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  1627. pr_info("%s searching functioin error cnt:%d\n",
  1628. __func__, cnt);
  1629. }
  1630. }
  1631. /*
  1632. * Candela compensation
  1633. */
  1634. for (cnt = 1; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1635. table_index = find_cadela_table(pSmart->brightness_level);
  1636. if (table_index == -1) {
  1637. table_index = CCG6_MAX_TABLE;
  1638. pr_info("%s fail candela table_index cnt : %d brightness %d",
  1639. __func__, cnt, pSmart->brightness_level);
  1640. }
  1641. bl_index[S6E8FA_TABLE_MAX - cnt] +=
  1642. gradation_offset_revJ[table_index][cnt - 1];
  1643. if (bl_index[S6E8FA_TABLE_MAX - cnt] == 0)
  1644. bl_index[S6E8FA_TABLE_MAX - cnt] = 1;
  1645. }
  1646. #ifdef SMART_DIMMING_DEBUG
  1647. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  1648. bl_index[0], bl_index[1], bl_index[2]);
  1649. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  1650. bl_index[3], bl_index[4], bl_index[5]);
  1651. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  1652. bl_index[6], bl_index[7], bl_index[8]);
  1653. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  1654. #endif
  1655. /*Generate Gamma table*/
  1656. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++)
  1657. (void)Make_hexa[cnt](bl_index , pSmart, str);
  1658. /*
  1659. * RGB compensation
  1660. */
  1661. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  1662. table_index = find_cadela_table(pSmart->brightness_level);
  1663. if (table_index == -1) {
  1664. table_index = CCG6_MAX_TABLE;
  1665. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  1666. __func__, cnt, pSmart->brightness_level);
  1667. }
  1668. if (cnt < 3) {
  1669. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  1670. level_V255 +=
  1671. rgb_offset_revJ[table_index][cnt];
  1672. level_255_temp_MSB = level_V255 / 256;
  1673. str[cnt * 2] = level_255_temp_MSB & 0xff;
  1674. str[(cnt * 2) + 1] = level_V255 & 0xff;
  1675. } else {
  1676. str[cnt+3] += rgb_offset_revJ[table_index][cnt];
  1677. }
  1678. }
  1679. /*subtration MTP_OFFSET value from generated gamma table*/
  1680. mtp_offset_substraction(pSmart, str);
  1681. }
  1682. static int gradation_offset_revI[][9] = {
  1683. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1684. /* 2 */ {0, 11, 20, 29, 38, 42, 46, 0, 0},
  1685. /* 3 */ {0, 8, 6, 24, 31, 34, 37, 40, 40},
  1686. /* 4 */ {0, 8, 14, 20, 26, 28, 32, 34, 39},
  1687. /* 5 */ {0, 5, 8, 13, 17, 19, 22, 24, 8},
  1688. /* 6 */ {0, 4, 6, 9, 13, 15, 19, 23, 8},
  1689. /* 7 */ {0, 3, 5, 8, 12, 14, 18, 22, 8},
  1690. /* 8 */ {0, 3, 5, 7, 11, 13, 17, 21, 8},
  1691. /* 9*/ {0, 3, 5, 7, 11, 12, 16, 20, 8},
  1692. /* 10 */ {0, 3, 4, 6, 10, 11, 15, 19, 8},
  1693. /* 11 */ {0, 3, 4, 6, 9, 10, 14, 19, 8},
  1694. /* 12 */ {0, 3, 4, 5, 8, 9, 13, 16, 8},
  1695. /* 13 */ { 0, 3, 4, 5, 7, 8, 12, 17, 8 },
  1696. /* 14 */ { 0, 3, 4, 5, 7, 8, 11, 18, 8 },
  1697. /* 15 */ { 0, 3, 4, 5, 7, 8, 11, 15, 8 },
  1698. /* 16 */ { 0, 3, 4, 4, 6, 8, 11, 15, 8 },
  1699. /* 17 */ { 0, 3, 4, 4, 6, 8, 10, 14, 8 },
  1700. /* 19 */ { 0, 3, 3, 4, 5, 7, 9, 13, 8 },
  1701. /* 20 */ { 0, 3, 3, 4, 5, 7, 9, 12, 8 },
  1702. /* 21 */ { 0, 3, 3, 4, 4, 6, 9, 12, 8 },
  1703. /* 22 */ { 0, 2, 3, 4, 4, 6, 8, 11, 8 },
  1704. /* 24 */ { 0, 2, 3, 3, 4, 6, 8, 11, 8 },
  1705. /* 25 */ { 0, 2, 3, 3, 4, 6, 7, 10, 8 },
  1706. /* 27 */ { 0, 2, 3, 3, 4, 5, 7, 10, 8 },
  1707. /* 29 */ { 0, 2, 3, 3, 3, 5, 7, 10, 8 },
  1708. /* 30 */ { 0, 2, 3, 3, 3, 5, 7, 10, 8 },
  1709. /* 32 */ { 0, 2, 3, 3, 3, 4, 7, 10, 8 },
  1710. /* 34 */ { 0, 2, 3, 2, 3, 4, 6, 8, 7 },
  1711. /* 37 */ { 0, 2, 3, 2, 3, 4, 6, 8, 7 },
  1712. /* 39 */ { 0, 2, 3, 2, 2, 3, 5, 7, 7 },
  1713. /* 41 */ { 0, 2, 2, 2, 2, 3, 5, 7, 7 },
  1714. /* 44 */ { 0, 2, 2, 2, 2, 3, 4, 6, 6 },
  1715. /* 47 */ { 0, 2, 2, 2, 2, 2, 4, 6, 6 },
  1716. /* 50 */ { 0, 2, 2, 1, 2, 2, 4, 5, 6 },
  1717. /* 53 */ { 0, 2, 2, 1, 2, 2, 3, 5, 5 },
  1718. /* 56 */ { 0, 2, 2, 1, 1, 2, 3, 4, 5 },
  1719. /* 60 */ { 0, 2, 2, 1, 1, 1, 3, 4, 5 },
  1720. /* 64 */ { 0, 2, 2, 1, 1, 1, 2, 3, 5 },
  1721. /* 68 */ { 0, 2, 2, 1, 1, 1, 2, 3, 5 },
  1722. /* 72 */ { 0, 2, 2, 1, 1, 1, 2, 3, 4 },
  1723. /* 77 */ { 0, 2, 2, 1, 1, 1, 1, 3, 4 },
  1724. /* 82 */ { 0, 2, 2, 1, 1, 1, 1, 2, 3 },
  1725. /* 87 */ { 0, 1, 2, 1, 1, 1, 1, 2, 3 },
  1726. /* 93 */ { 0, 1, 2, 1, 1, 1, 1, 2, 3 },
  1727. /* 98 */ { 0, 1, 2, 1, 1, 1, 1, 1, 3 },
  1728. /* 105*/{ 0, 1, 2, 1, 1, 1, 1, 1, 3 },
  1729. /* 106*/{ 0, -4, -5, -3, -2, -2, -2, -2, -1 },
  1730. /* 107*/{ 0, -8, -7, -4, -2, -2, -1, 0, 1 },
  1731. /* 108*/{ 0, -14, -10, -6, -4, -3, -1, 0, 2 },
  1732. /* 109*/{ 0, -19, -15, -9, -5, -4, -2, 0, 1 },
  1733. /* 110*/{ 0, -22, -18, -10, -6, -4, -3, -1, 1 },
  1734. /* 111*/{ 0, 1, 2, 2, 1, 2, 2, 3, 4 },
  1735. /* 119*/{ 0, 1, 2, 2, 1, 2, 2, 3, 4 },
  1736. /* 126*/{ 0, 1, 1, 1, 1, 1, 2, 3, 3 },
  1737. /* 134*/{ 0, 1, 1, 1, 1, 1, 2, 3, 3 },
  1738. /* 143*/{ 0, 1, 2, 2, 1, 1, 1, 2, 3 },
  1739. /* 152*/{ 0, 1, 2, 2, 1, 1, 1, 2, 3},
  1740. /* 162*/{ 0, 2, 2, 2, 1, 0, 1, 2, 3 },
  1741. /* 172*/{ 0, 2, 2, 2, 1, 0, 1, 2, 3 },
  1742. /* 173*/{-3, -12, -18, -12, -7, -5, -3, -1, 0 },
  1743. /* 175*/{ -3, -20, -14, -10, -6, -4, -3, -1, 1 },
  1744. /* 177*/{-3, -14, -9, -6, -4, -2, -2, 1, 2 },
  1745. /* 179*/{ -4, -7, -5, -3, -2, -1, 0, 1, 0 },
  1746. /* 181*/{-4, -1, 0, 0, -1, 0, 0, 1, 0 },
  1747. /* 183*/{ 3, 2, 3, 2, 1, 1, 1, 1, 3 },
  1748. /* 195*/{ 4, 1, 2, 2, 1, 1, 1, 1, 3 },
  1749. /* 207*/{ 4, 1, 2, 1, 0, 1, 0, 1, 2 },
  1750. /* 220*/{ 4, 1, 2, 1, 0, 1, 0, 1, 1 },
  1751. /* 234*/{ 4, 1, 2, 1, 0, 1, 0, 0, 2 },
  1752. /* 249*/{3, 1, 1, 1, 0, 0, 0, 1, 2 },
  1753. /* 265*/{3, 0, 1, 1, 0, 0, 0, 1, 2 },
  1754. /* 282*/{ 2, 0, 1, 1, 0, 0, 0, 0, 1 },
  1755. /* 300*/{ 2, 0, 0, 0, 0, 0, 0, 0, 0 },
  1756. /* 316*/{ 2, 0, 0, 0, 0, 0, 0, 0, 0 },
  1757. /* 333*/{ 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1758. /* 350*/{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  1759. };
  1760. static int rgb_offset_revI[][RGB_COMPENSATION] = {
  1761. /* R255 G255 B255 R203 G203 B203 R151 G151 B151 R87 G87 B87 R51 G51 B51 R35 G35 B35 R23 G23 B23 R11 G11 B11*/
  1762. /* 2 */ { -7, 1, -7, -6, 1, -6, -9, 2, -8, -17, 6, -14, -15, 7, -16, -2, 4, -6, 3, 4, -6, 0, 0, 0 },
  1763. /* 3 */ { -4, 1, -4, -5, 1, -5, -8, 1, -8, -15, 6, -13, -15, 8, -16, -5, 4, -8, 2, 4, -8, -1, 3, -8 },
  1764. /* 4 */ { -4, 0, -4, -4, 0, -4, -6, 1, -5, -14, 5, -12, -14, 7, -16, -7, 4, -9, 0, 4, -9, -2, 4, -10 },
  1765. /* 5 */ { -2, 1, -2, -2, 1, -2, -2, 4, -1, -10, 8, -7, -10, 9, -15, -1, 7, -5, -4, 5, -9, -13, 7, -17 },
  1766. /* 6 */ { -1, 1, -1, -2, 1, -1, -3, 4, -1, -10, 8, -7, -10, 8, -14, -4, 7, -6, -10, 6, -14, -12, 7, -16 },
  1767. /* 7 */ { -1, 1, -1, -2, 1, -2, -2, 4, 0, -10, 8, -6, -8, 8, -13, -4, 5, -6, -10, 6, -14, -11, 7, -15 },
  1768. /* 8 */ { -1, 1, -1, -2, 1, -1, -2, 3, 0, -8, 8, -5, -8, 7, -12, -4, 5, -6, -10, 6, -14, -10, 7, -14 },
  1769. /* 9 */ { -1, 1, -1, -2, 0, -1, -2, 3, 0, -8, 6, -5, -8, 7, -13, -4, 5, -6, -10, 6, -13, -9, 7, -13 },
  1770. /* 10 */ { 0, 1, -1, -3, 0, -1, -2, 2, 0, -8, 5, -6, -9, 6, -14, -4, 6, -9, -10, 6, -12, -4, 6, -8 },
  1771. /* 11 */ { 0, 1, 0, -2, 0, -1, -2, 2, 0, -8, 5, -4, -8, 6, -14, -4, 6, -9, -10, 6, -12, -4, 6, -8 },
  1772. /* 12 */ { 0, 1, 0, -2, 0, -1, -1, 2, 1, -8, 5, -5, -7, 6, -12, -3, 5, -9, -10, 6, -11, -9, 6, -20 },
  1773. /* 13 */ { 0, 1, 0, -2, 0, -1, -1, 2, 1, -8, 4, -4, -6, 7, -11, -2, 5, -8, -10, 6, -11, -8, 6, -20},
  1774. /* 14 */ { 0, 1, 0, -2, 0, -1, -1, 1, 1, -8, 4, -4, -6, 6, -10, -4, 6, -8, -11, 6, -16, -8, 6, -20 },
  1775. /* 15 */ { 0, 1, 0, -2, 0, -1, -1, 1, 1, -8, 3, -4, -6, 6, -10, -4, 5, -8, -10, 6, -13, -5, 6, -13 },
  1776. /* 16 */ { 0, 1, 0, -2, 0, -1, -1, 1, 1, -7, 3, -4, -4, 6, -9, -5, 4, -6, -10, 6, -13, -5, 6, -12 },
  1777. /* 17 */ { -1, 1, 0, -1, 0, 0, -2, 1, 0, -7, 3, -3, -2, 6, -8, -5, 4, -7, -10, 6, -14, -5, 6, -13 },
  1778. /* 19 */ { -1, 0, 0, -1, 0, 0, -1, 1, 0, -7, 2, -3, -3, 6, -7, -6, 3, -10, -9, 6, -13, -7, 6, -16 },
  1779. /* 20 */ { 0, 0, -1, -1, 0, 0, -1, 1, 0, -7, 2, -3, -2, 6, -7, -6, 3, -8, -8, 6, -12, -8, 6, -19 },
  1780. /* 21 */ { 0, 0, -1, -1, 0, 0, -1, 1, 0, -7, 2, -3, -3, 6, -7, -6, 3, -8, -7, 6, -11, -9, 6, -20 },
  1781. /* 22 */ { 0, 0, -1, -1, 0, 0, -1, 1, 0, -6, 2, -2, -1, 6, -6, -7, 2, -8, -7, 6, -13, -10, 6, -20 },
  1782. /* 24 */ { 0, 0, -1, -1, 0, 0, -1, 1, 0, -6, 2, -2, 0, 4, -6, -7, 2, -7, -7, 6, -12, -9, 6, -20 },
  1783. /* 25 */ { 0, 0, -1, -2, 0, 0, -1, 0, 0, -5, 2, -2, 0, 5, -6, -7, 2, -6, -7, 6, -13, -7, 6, -20 },
  1784. /* 27 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -6, 1, -2, -1, 4, -7, -5, 2, -7, -7, 6, -12, -10, 6, -20 },
  1785. /* 29 */ { 0, 1, 0, 0, 0, 0, -1, 0, 0, -6, 1, -2, -2, 4, -6, -5, 2, -6, -5, 5, -10, -7, 6, -18 },
  1786. /* 30 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -6, 1, -1, -2, 4, -6, -5, 2, -6, -5, 4, -10, -7, 6, -18 },
  1787. /* 32 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -6, 1, -2, -2, 3, -7, -4, 2, -6, -6, 4, -10, -7, 6, -16 },
  1788. /* 34 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -5, 1, -2, -1, 3, -6, -4, 2, -5, -6, 4, -10, -9, 6, -22 },
  1789. /* 37 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -5, 1, -2, 0, 2, -6, -3, 2, -5, -5, 4, -7, -9, 6, -19 },
  1790. /* 39 */ { 0, 0, -1, -1, 0, 0, -1, 0, 1, -5, 1, -2, -1, 3, -5, -4, 2, -4, -4, 4, -8, -9, 6, -21 },
  1791. /* 41 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -5, 1, -1, 0, 3, -5, -4, 2,-4, -4, 4, -7, -9, 6, -20},
  1792. /* 44 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -5, 1, -1, 0, 3, -5, -3, 2, -3, -3, 4, -7, -8, 6, -20 },
  1793. /* 47 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -5, 1, -2, 1, 2, -5, -3, 2, -3, -4, 4, -6, -7, 7, -19 },
  1794. /* 50 */ { 0, 0, -1, -1, 0, 0, -1, 0, 0, -5, 1, -1, 1, 2, -6, -3, 2, -3, -4, 3, -5, -8, 7, -21 },
  1795. /* 53 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, -1, 1, 2, -5, -3, 1, -2, -3, 3, -6, -8, 7, -19 },
  1796. /* 56 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, -1, 1, 3, -3, -2, 1, -3, -3, 2, -5, -7, 7, -21},
  1797. /* 60 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, -1, 1, 2, -3, -1, 1, -2, -2, 2, -4, -6, 6, -19 },
  1798. /* 64 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -3, 1, -1, 1, 2, -3, -1, 1, -1, -2, 2, -4, -4, 6, -19 },
  1799. /* 68 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 1, 0, 1, 1, -4, 0, 1, -1, -2, 2, -4, -4, 6, -17 },
  1800. /* 72 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -3, 1, 0, 1, 1, -4, -1, 0, -1, -1, 2, -2, -3, 5, -16 },
  1801. /* 77 */ { 0, 0, 0, -1, 0, 1, -1, 0, 0, -4, 1, 0, 1, 0, -4, 0, 0, -1, 0, 2, -2, -2, 5, -14 },
  1802. /* 82 */ { 0, 0, 0, -1, 0, 0, -1, 0, 0, -4, 0, -1, 1, 1, -3, 0, 0, 0, 0, 1, -2, -1, 5, -14 },
  1803. /* 87 */ { 0, 0, 0, -1, 0, -1, -1, 0, 0, -4, 0, -1, 1, 0, -3, 0, 0, 0, 1, 0, -2, -2, 4, -13 },
  1804. /* 93 */ { 0, 0, 0, 0, 0, 0, -1, 0, 0, -4, 0, -1, 1, 0, -3, 0, -1, 0, 1, 0, -1, -1, 4, -11 },
  1805. /* 98 */ { 0, 0, 0, 0, 0, 0, -1, 0, 0, -4, 0, 0, 1, 0, -4, 0, -1, 0, 2, 0, 0, 3, 5, -10 },
  1806. /* 105 */{ 0, 0, 0, 0, 0, 0, -1, 0, 0, -4, 0, 0, 2, 0, -3, 0, -1, 1, 1, 0, 0, 3, 3, -10 },
  1807. /* 106 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, -4, 0, -3, 6, 5, -3, 5, 12, -7, 15 },
  1808. /* 107 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -6, -2, -1, 3, 6, -1, 2, 5, 0, -2 },
  1809. /* 108 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -7, -2, -1, 3, 6, -1, 2, 5, 0, -2 },
  1810. /* 109 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -6, -2, -2, 4, 7, -2, 2, 4, 0, -2 },
  1811. /* 110 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, -6, 0, -1, 4, 5, -1, 2, 5, 0, -1 },
  1812. /* 111 */{ 0, 0, 0, 0, 0, -1, 0, 0, 1, -4, 0, 0, -1, 0, -3, 0, 0, -3, -2, 1, -2, -4, 7, -14 },
  1813. /* 119 */{ 0, 0, 0, 0, 0, 0, 0, 0, 1, -3, 0, -1, 0, 0, -3, 0, 2, -1, -2, 1, -3, -3, 7, -13 },
  1814. /* 126 */{ 1, 0, 1, 0, 0, -1, 0, 0, 0, -3, 0, -1, -1, 0, -3, 1, 2, -1, -2, 1, -3, -2, 7, -12 },
  1815. /* 134 */{ 1, 0, 1, 0, 0, -1, 0, 0, 1, -3, 0, -1, -2, 0, -3, 1, 2, -1, -2, 1, -3, -2, 7, -11 },
  1816. /* 143 */{ 0, 0, 1, 0, 0, -1, -1, 0, 0, -1, 0, 1, -2, 0, -2, 1, 2, -2, -2, 1, -2, -1, 8, -10 },
  1817. /* 152 */{ -1, 0, 0, 0, 0, -1, 1, 0, 0, -2, 0, 1, -2, 0, -3, 0, 1, -2, -2, 1, -2, -2, 8, -9 },
  1818. /* 162 */{ 0, 0, 1, 0, 0, -1, 1, 0, 0, -2, 0, 0, -1, 0, -2, 0, 1, -2, -2, 1, -2, -1, 9, -6 },
  1819. /* 172 */{ -1, 0, 0, 2, 0, 1, 0, 0, 0, -2, 0, 1, -1, 0, -3, 0, 1, -2, -4, 0, -4, -2, 7, -8 },
  1820. /* 173 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -2, 3, 1, 2, 6, 0, 0 },
  1821. /* 175 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, -4, 2, 1, 2, 6, 0, -1 },
  1822. /* 177 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, -3, 2, 1, 2, 6, 0, -1 },
  1823. /* 179 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, -3, 0, 1, 2, 5, 0, -2 },
  1824. /* 181 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 2, -4, 1, 2, 3, 5, 1, -2 },
  1825. /* 183 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1826. /* 195 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1827. /* 207 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1828. /* 220 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1829. /* 234 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1830. /* 249 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1831. /* 265 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1832. /* 282 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1833. /* 300 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1834. /* 316 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1835. /* 333 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1836. /* 350 */{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  1837. };
  1838. static void gamma_init_revI(
  1839. struct SMART_DIM *pSmart, char *str, int size)
  1840. {
  1841. long long candela_level[S6E8FA_TABLE_MAX] = {-1, };
  1842. int bl_index[S6E8FA_TABLE_MAX] = {-1, };
  1843. long long temp_cal_data = 0;
  1844. int bl_level;
  1845. int level_255_temp_MSB = 0;
  1846. int level_V255 = 0;
  1847. int point_index;
  1848. int cnt;
  1849. int table_index;
  1850. pr_debug("%s : start !!\n",__func__);
  1851. /*calculate candela level */
  1852. if (pSmart->brightness_level == 350)
  1853. bl_level = 350;
  1854. else if (pSmart->brightness_level == 333)
  1855. bl_level = 333;
  1856. else if (pSmart->brightness_level == 316)
  1857. bl_level = 316;
  1858. else if (pSmart->brightness_level == 300)
  1859. bl_level = 300;
  1860. else if (pSmart->brightness_level == 282)
  1861. bl_level = 282;
  1862. else if (pSmart->brightness_level == 265)
  1863. bl_level = 266;
  1864. else if (pSmart->brightness_level == 249)
  1865. bl_level = 249;
  1866. else if (pSmart->brightness_level == 234)
  1867. bl_level = 234;
  1868. else if (pSmart->brightness_level == 220)
  1869. bl_level = 220;
  1870. else if (pSmart->brightness_level == 207)
  1871. bl_level = 207;
  1872. else if (pSmart->brightness_level == 195)
  1873. bl_level = 195;
  1874. else if (pSmart->brightness_level == 183)
  1875. bl_level = 183;
  1876. else if (pSmart->brightness_level == 181)
  1877. bl_level = 198;
  1878. else if (pSmart->brightness_level == 179)
  1879. bl_level = 219;
  1880. else if (pSmart->brightness_level == 177)
  1881. bl_level = 228;
  1882. else if (pSmart->brightness_level == 175)
  1883. bl_level = 243;
  1884. else if (pSmart->brightness_level == 173)
  1885. bl_level = 258;
  1886. else if (pSmart->brightness_level == 172)
  1887. bl_level = 274;
  1888. else if (pSmart->brightness_level == 162)
  1889. bl_level = 264;
  1890. else if (pSmart->brightness_level == 153)
  1891. bl_level = 248;
  1892. else if (pSmart->brightness_level == 142)
  1893. bl_level = 233;
  1894. else if (pSmart->brightness_level == 134)
  1895. bl_level = 221;
  1896. else if (pSmart->brightness_level == 126)
  1897. bl_level = 209;
  1898. else if (pSmart->brightness_level == 119)
  1899. bl_level = 198;
  1900. else if (pSmart->brightness_level == 111)
  1901. bl_level = 185;
  1902. else if (pSmart->brightness_level == 110)
  1903. bl_level = 171;
  1904. else if (pSmart->brightness_level == 109)
  1905. bl_level = 159;
  1906. else if (pSmart->brightness_level == 108)
  1907. bl_level = 147;
  1908. else if (pSmart->brightness_level == 107)
  1909. bl_level = 134;
  1910. else if(pSmart->brightness_level == 106)
  1911. bl_level = 122;
  1912. else
  1913. bl_level = 110;
  1914. if (pSmart->brightness_level < 350) {
  1915. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1916. point_index = S6E8FA_ARRAY[cnt+1];
  1917. temp_cal_data =
  1918. ((long long)(candela_coeff_2p15[point_index])) *
  1919. ((long long)(bl_level));
  1920. candela_level[cnt] = temp_cal_data;
  1921. }
  1922. } else {
  1923. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1924. point_index = S6E8FA_ARRAY[cnt+1];
  1925. temp_cal_data =
  1926. ((long long)(candela_coeff_2p2[point_index])) *
  1927. ((long long)(bl_level));
  1928. candela_level[cnt] = temp_cal_data;
  1929. }
  1930. }
  1931. #ifdef SMART_DIMMING_DEBUG
  1932. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  1933. candela_level[0], candela_level[1], candela_level[2]);
  1934. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  1935. candela_level[3], candela_level[4], candela_level[5]);
  1936. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  1937. candela_level[6], candela_level[7], candela_level[8]);
  1938. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  1939. #endif
  1940. /* max 350cd */
  1941. memcpy(curve_1p9, curve_1p9_350, sizeof(curve_1p9_350));
  1942. memcpy(curve_2p2, curve_2p2_350, sizeof(curve_1p9_350));
  1943. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1944. if (searching_function(candela_level[cnt],
  1945. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  1946. pr_info("%s searching functioin error cnt:%d\n",
  1947. __func__, cnt);
  1948. }
  1949. }
  1950. /*
  1951. * Candela compensation
  1952. */
  1953. for (cnt = 1; cnt < S6E8FA_TABLE_MAX; cnt++) {
  1954. table_index = find_cadela_table(pSmart->brightness_level);
  1955. if (table_index == -1) {
  1956. table_index = CCG6_MAX_TABLE;
  1957. pr_info("%s fail candela table_index cnt : %d brightness %d",
  1958. __func__, cnt, pSmart->brightness_level);
  1959. }
  1960. bl_index[S6E8FA_TABLE_MAX - cnt] +=
  1961. gradation_offset_revI[table_index][cnt - 1];
  1962. if (bl_index[S6E8FA_TABLE_MAX - cnt] == 0)
  1963. bl_index[S6E8FA_TABLE_MAX - cnt] = 1;
  1964. }
  1965. #ifdef SMART_DIMMING_DEBUG
  1966. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  1967. bl_index[0], bl_index[1], bl_index[2]);
  1968. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  1969. bl_index[3], bl_index[4], bl_index[5]);
  1970. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  1971. bl_index[6], bl_index[7], bl_index[8]);
  1972. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  1973. #endif
  1974. /*Generate Gamma table*/
  1975. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++)
  1976. (void)Make_hexa[cnt](bl_index , pSmart, str);
  1977. /*
  1978. * RGB compensation
  1979. */
  1980. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  1981. table_index = find_cadela_table(pSmart->brightness_level);
  1982. if (table_index == -1) {
  1983. table_index = CCG6_MAX_TABLE;
  1984. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  1985. __func__, cnt, pSmart->brightness_level);
  1986. }
  1987. if (cnt < 3) {
  1988. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  1989. level_V255 +=
  1990. rgb_offset_revI[table_index][cnt];
  1991. level_255_temp_MSB = level_V255 / 256;
  1992. str[cnt * 2] = level_255_temp_MSB & 0xff;
  1993. str[(cnt * 2) + 1] = level_V255 & 0xff;
  1994. } else {
  1995. str[cnt+3] += rgb_offset_revI[table_index][cnt];
  1996. }
  1997. }
  1998. /*subtration MTP_OFFSET value from generated gamma table*/
  1999. mtp_offset_substraction(pSmart, str);
  2000. }
  2001. #else
  2002. static int gradation_offset[][9] = {
  2003. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  2004. {0, 5, 10, 17, 22, 24, 28, 28, 28},
  2005. {0, 5, 10, 16, 21, 23, 27, 27, 27},
  2006. {0, 5, 9, 15, 20, 22, 26, 26, 26},
  2007. {0, 4, 8, 13, 17, 18, 21, 23, 23},
  2008. {0, 4, 7, 12, 16, 17, 20, 22, 22},
  2009. {0, 4, 6, 11, 14, 15, 18, 20, 20},
  2010. {0, 4, 6, 11, 14, 15, 18, 20, 20},
  2011. {0, 4, 5, 10, 13, 14, 17, 19, 19},
  2012. {0, 3, 5, 9, 12, 13, 16, 18, 18},
  2013. {0, 3, 4, 8, 11, 12, 14, 16, 16},
  2014. {0, 3, 4, 7, 10, 11, 13, 15, 15},
  2015. {0, 3, 4, 7, 10, 11, 13, 15, 15},
  2016. {0, 3, 4, 7, 10, 11, 13, 15, 15},
  2017. {0, 3, 4, 6, 9, 10, 12, 14, 14},
  2018. {0, 3, 3, 6, 9, 10, 12, 14, 14},
  2019. {0, 2, 3, 5, 8, 8, 10, 12, 12},
  2020. {0, 2, 2, 5, 8, 8, 10, 12, 12},
  2021. {0, 2, 2, 4, 7, 7, 9, 11, 11},
  2022. {0, 2, 2, 4, 7, 7, 9, 11, 11},
  2023. {0, 2, 2, 4, 7, 7, 8, 10, 10},
  2024. {0, 2, 2, 4, 6, 7, 7, 9, 9},
  2025. {0, 2, 2, 4, 6, 7, 7, 9, 9},
  2026. {0, 2, 2, 3, 5, 6, 7, 8, 8},
  2027. {0, 2, 2, 3, 5, 6, 7, 8, 8},
  2028. {0, 2, 2, 3, 4, 5, 6, 7, 7},
  2029. {0, 2, 2, 3, 4, 5, 6, 7, 7},
  2030. {0, 2, 2, 1, 1, 0, 2, 2, 2},
  2031. {0, 2, 2, 1, 1, 0, 2, 2, 2},
  2032. {0, 2, 2, 1, 1, 0, 2, 2, 2},
  2033. {0, 2, 2, 1, 1, 0, 2, 2, 2},
  2034. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2035. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2036. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2037. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2038. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2039. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2040. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2041. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2042. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2043. {0, 1, 1, 0, 1, 0, 0, 0, 0},
  2044. {0, 1, 1, 0, 1, 0, 0, 0, 0},
  2045. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2046. {0, 1, 1, 1, 1, 1, 1, 2, 4},
  2047. {0, 1, 1, 1, 1, 2, 2, 3, 5},
  2048. {0, 1, 1, 1, 1, 2, 3, 3, 5},
  2049. {0, 0, 1, 1, 1, 2, 3, 4, 7},
  2050. {0, 1, 2, 2, 2, 3, 3, 4, 7},
  2051. {0, 1, 1, 0, 1, 0, 1, 1, 1},
  2052. {0, 1, 2, 1, 1, 1, 2, 1, 1},
  2053. {0, 1, 2, 1, 1, 2, 2, 1, 1},
  2054. {0, 1, 2, 2, 1, 2, 2, 1, 1},
  2055. {0, 1, 3, 2, 2, 2, 2, 1, 1},
  2056. {0, 1, 3, 2, 2, 2, 2, 1, 1},
  2057. {0, 1, 3, 2, 2, 2, 2, 1, 1},
  2058. {0, 1, 3, 2, 2, 2, 2, 1, 1},
  2059. {0, 1, 2, 2, 2, 2, 2, 1, 2},
  2060. {0, 1, 2, 2, 2, 2, 2, 1, 2},
  2061. {0, 1, 2, 2, 2, 2, 2, 1, 2},
  2062. {0, 1, 2, 2, 1, 1, 1, 1, 2},
  2063. {0, 1, 2, 2, 2, 1, 1, 1, 2},
  2064. {3, 4, 4, 3, 2, 2, 1, 1, 1},
  2065. {3, 4, 4, 3, 2, 2, 1, 1, 1},
  2066. {3, 4, 4, 3, 2, 2, 1, 1, 1},
  2067. {2, 3, 3, 3, 2, 2, 1, 1, 1},
  2068. {2, 3, 3, 3, 2, 2, 1, 1, 1},
  2069. {2, 3, 2, 2, 2, 2, 1, 1, 1},
  2070. {1, 2, 2, 1, 1, 1, 1, 1, 1},
  2071. {1, 2, 2, 1, 1, 1, 0, 1, 1},
  2072. {1, 1, 1, 1, 1, 1, 0, 1, 1},
  2073. {1, 1, 1, 0, 0, 0, 0, 1, 1},
  2074. {1, 1, 0, 0, 0, 0, 0, 0, 0},
  2075. {0, 1, 0, 0, 0, 0, 0, 0, 0},
  2076. };
  2077. static int rgb_offset_evt1_third[][RGB_COMPENSATION] = {
  2078. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  2079. R87 G87 B87 R51 G51 B51 R35 G35 B35
  2080. R23 G23 B23 R11 G11 B11
  2081. */
  2082. {-2, 0, -2, -2, 0, -3, -2, 2, -5, -11, 5, -12, -11, 9, -13, -10, 2, -11, 8, 3, -9, -10, 5, -11},
  2083. {-2, 0, -2, -2, 0, -3, -2, 2, -5, -10, 5, -11, -11, 9, -13, -9, 3, -11, 7, 3, -9, -9, 5, -11},
  2084. {-2, 0, -2, -2, 0, -3, -2, 2, -5, -9, 4, -10, -12, 8, -13, -7, 4, -10, 7, 3, -10, -8, 5, -11},
  2085. {-1, 0, -1, -1, 0, -2, -1, 1, -4, -8, 4, -9, -12, 8, -12, -6, 5, -9, -1, 5, -11, -6, 6, -10},
  2086. {-1, 0, -1, -1, 0, -2, -1, 1, -3, -7, 3, -8, -13, 7, -12, -5, 6, -8, -1, 5, -11, -4, 6, -10},
  2087. {-1, 0, -1, -1, 0, -2, -1, 1, -3, -5, 3, -7, -13, 7, -12, -4, 7, -7, -2, 5, -12, -3, 6, -10},
  2088. {-1, 0, -1, -1, 0, -2, -1, 1, -3, -5, 3, -7, -13, 7, -12, -5, 7, -7, -3, 5, -12, -3, 6, -11},
  2089. {-1, 0, -1, -1, 0, -2, -1, 1, -3, -5, 3, -7, -12, 7, -12, -6, 6, -7, -4, 5, -12, -4, 6, -13},
  2090. {-1, 0, -1, -1, 0, -2, 0, 1, -2, -5, 3, -7, -11, 6, -11, -6, 6, -7, -5, 6, -13, -4, 6, -13},
  2091. {0, 0, 0, 0, 0, -1, 0, 1, -2, -4, 2, -8, -10, 6, -11, -7, 5, -6, -6, 6, -13, -5, 7, -15},
  2092. {0, 0, 0, 0, 0, -1, 0, 1, -2, -4, 2, -8, -9, 6, -11, -8, 4, -6, -6, 6, -13, -6, 8, -17},
  2093. {0, 0, 0, 0, 0, -1, 0, 1, -2, -4, 2, -8, -9, 6, -11, -8, 4, -6, -7, 6, -13, -7, 8, -19},
  2094. {0, 0, 0, 0, 0, -1, 0, 1, -2, -4, 2, -8, -9, 6, -11, -8, 4, -6, -7, 6, -13, -5, 8, -19},
  2095. {0, 0, 0, 0, 0, -1, 0, 1, -2, -3, 2, -7, -9, 6, -11, -8, 4, -6, -7, 6, -12, -4, 8, -19},
  2096. {0, 0, 0, 0, 0, -1, 0, 1, -1, -3, 2, -7, -9, 6, -11, -9, 4, -5, -7, 6, -12, -3, 7, -19},
  2097. {0, 0, 0, -1, 0, -1, 1, 1, -1, -2, 2, -6, -8, 5, -12, -9, 3, -5, -6, 5, -11, -2, 7, -19},
  2098. {0, 0, 0, -1, 0, -1, 1, 1, 0, -2, 2, -5, -8, 5, -12, -10, 3, -4, -6, 5, -11, -1, 7, -19},
  2099. {0, 0, 0, -1, 0, -1, 1, 1, 0, -1, 2, -4, -8, 5, -12, -10, 3, -4, -6, 5, -10, 0, 7, -19},
  2100. {0, 0, 0, -1, 0, -1, 1, 1, 0, -1, 2, -4, -8, 5, -12, -10, 3, -4, -6, 5, -10, 0, 7, -19},
  2101. {0, 0, 0, -1, 0, -1, 1, 1, 0, -1, 2, -4, -8, 5, -12, -10, 3, -4, -6, 5, -9, 0, 7, -19},
  2102. {0, 0, 0, -1, 0, -1, 1, 1, 0, 0, 2, -4, -8, 5, -11, -9, 3, -4, -5, 5, -9, -1, 7, -20},
  2103. {0, 0, 0, -1, 0, -1, 1, 1, 0, 0, 2, -3, -8, 5, -10, -8, 3, -4, -4, 5, -8, -1, 7, -20},
  2104. {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, -3, -7, 4, -9, -7, 3, -3, -3, 4, -8, -2, 6, -21},
  2105. {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, -3, -7, 4, -8, -6, 3, -3, -3, 4, -7, -2, 6, -21},
  2106. {0, 0, 0, 0, 0, 0, 1, 1, 0, 2, 1, -2, -7, 4, -7, -5, 3, -3, -2, 4, -7, -3, 6, -22},
  2107. {0, 0, 0, 0, 0, 0, 1, 1, 0, 2, 1, -2, -7, 4, -7, -5, 3, -3, -2, 4, -7, -3, 6, -22},
  2108. {0, 0, 0, 0, 0, 0, -2, 0, -1, -4, 0, -1, 4, 3, -7, -7, 1, -2, -2, 0, 0, -18, 6, -3},
  2109. {0, 0, 0, 0, 0, 0, -2, 0, -1, -4, 0, -1, 5, 3, -7, -7, 1, -1, -1, 0, 0, -17, 6, -4},
  2110. {0, 0, 0, 0, 0, 0, -2, 0, -1, -4, 0, -1, 5, 3, -7, -7, 1, -1, 0, 0, 0, -16, 5, -5},
  2111. {0, 0, 0, 0, 0, 0, -1, 0, -1, -4, 0, -1, 5, 3, -7, -6, 1, -1, 0, 0, 0, -14, 5, -5},
  2112. {0, 0, 0, 0, 0, 0, -1, 0, -1, -3, 0, 0, 4, 2, -6, -6, 0, -1, 0, 0, 1, -12, 4, -4},
  2113. {0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, -6, -5, 0, -1, 0, 0, 1, -10, 4, -4},
  2114. {0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, -6, -5, 0, -1, 0, 0, 1, -8, 4, -4},
  2115. {0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, -6, -4, 0, -1, 0, 0, 1, -6, 3, -4},
  2116. {0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, -6, -4, 0, 0, 1, 0, 2, -4, 3, -4},
  2117. {0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, -6, -3, 0, 1, 3, 0, 4, 1, 2, -5},
  2118. {0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 4, 2, -6, -3, 0, 1, 3, 0, 4, 2, 1, -5},
  2119. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 5, 2, -5, -2, 0, 2, 4, 0, 5, 4, -1, -6},
  2120. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 5, 2, -5, -2, 0, 2, 4, 0, 5, 5, -1, -6},
  2121. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 4, 2, -4, -1, 0, 2, 5, 0, 4, 7, -1, -5},
  2122. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 4, 2, -4, -1, 0, 2, 5, 0, 4, 9, -1, -4},
  2123. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 5, 2, -4, -1, 0, 2, 5, -1, 5, 8, -2, -5},
  2124. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, -2, 0, -1, 0, 2, -2, -1, 1, -4},
  2125. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, -1, -2, 0, -1, -1, 2, -4, -1, 1, -4},
  2126. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, -1, -2, 1, -1, -2, 2, -5, -2, 2, -5},
  2127. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, -1, -2, 1, -1, -3, 2, -5, -2, 2, -5},
  2128. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 0, -2, -1, 1, -1, -4, 2, -5, -2, 2, -5},
  2129. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 4, 2, -4, 0, 0, 2, 4, 0, 5, 6, 0, -5},
  2130. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 4, 0, -4, 0, 0, 1, 3, 0, 4, 5, 0, -5},
  2131. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 3, 0, -3, 1, 1, 0, 2, 1, 4, 4, 1, -4},
  2132. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 2, 0, -3, 1, 1, -1, 1, 1, 3, 3, 1, -4},
  2133. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 1, 0, -3, 2, 1, -2, 0, 2, 3, 1, 2, -4},
  2134. {0, 0, 0, 0, 0, 1, -1, 0, 0, -2, 0, 0, 1, 0, -4, 2, 1, -3, -1, 2, 3, -4, 2, -5},
  2135. {0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 0, 1, 0, -3, 2, 1, -3, -1, 2, 2, -4, 2, -5},
  2136. {0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 0, 1, 0, -3, 3, 1, -3, -2, 2, 2, -4, 2, -5},
  2137. {0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 0, 0, 0, -2, 3, 1, -3, -2, 2, 1, -4, 2, -4},
  2138. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 4, 1, -3, -3, 2, 1, -4, 2, -4},
  2139. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 4, 1, -3, -3, 2, 0, -4, 2, -4},
  2140. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 5, 1, -3, -3, 1, 0, -4, 2, -4},
  2141. {0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -2, 0, -1, 5, 1, -3, -4, 1, -1, -4, 2, -3},
  2142. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, -3, 2, 0, -1, 1, 0, 5, 4, 0, -3},
  2143. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, -3, 2, 0, -1, 1, 0, 5, 4, 0, -3},
  2144. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, -2, 3, 0, -2, 0, 0, 4, 3, 0, -2},
  2145. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, -2, 3, 0, -3, 0, 0, 4, 3, 0, -1},
  2146. {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, -2, 4, 0, -3, -1, 0, 3, 3, 0, 0},
  2147. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 4, 0, -4, -1, 0, 3, 2, 0, 0},
  2148. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 5, 0, -4, -1, 0, 2, 2, 0, 0},
  2149. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 5, 1, -3, 0, 0, 2, 2, 0, 0},
  2150. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 0, -1, 0, 1, 1, 0, 0},
  2151. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 0, 0, 0, 1, 1, 0, 1},
  2152. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 3, 0, 0, 0, 0, 1, 0, 1},
  2153. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  2154. };
  2155. static void gamma_init_evt1_third(
  2156. struct SMART_DIM *pSmart, char *str, int size)
  2157. {
  2158. long long candela_level[S6E8FA_TABLE_MAX] = {-1, };
  2159. int bl_index[S6E8FA_TABLE_MAX] = {-1, };
  2160. long long temp_cal_data = 0;
  2161. int bl_level;
  2162. int level_255_temp_MSB = 0;
  2163. int level_V255 = 0;
  2164. int point_index;
  2165. int cnt;
  2166. int table_index;
  2167. /*calculate candela level */
  2168. if (pSmart->brightness_level >= AOR_FIX_CD) {
  2169. /* 350CD ~ 183CD */
  2170. bl_level = pSmart->brightness_level;
  2171. } else if ((pSmart->brightness_level < AOR_FIX_CD) &&
  2172. (pSmart->brightness_level > 172)) {
  2173. /* 173CD ~ 181CD */
  2174. if (pSmart->brightness_level == 173)
  2175. bl_level = 258;
  2176. else if (pSmart->brightness_level == 175)
  2177. bl_level = 243;
  2178. else if (pSmart->brightness_level == 177)
  2179. bl_level = 228;
  2180. else if (pSmart->brightness_level == 179)
  2181. bl_level = 213;
  2182. else if (pSmart->brightness_level == 181)
  2183. bl_level = 198;
  2184. } else if ((pSmart->brightness_level <= 172) &&
  2185. (pSmart->brightness_level > AOR_ADJUST_CD)) {
  2186. /* 172CD ~ 111CD */
  2187. if (pSmart->brightness_level == 111)
  2188. bl_level = 185;
  2189. else if (pSmart->brightness_level == 119)
  2190. bl_level = 198;
  2191. else if (pSmart->brightness_level == 126)
  2192. bl_level = 209;
  2193. else if (pSmart->brightness_level == 134)
  2194. bl_level = 221;
  2195. else if (pSmart->brightness_level == 143)
  2196. bl_level = 233;
  2197. else if (pSmart->brightness_level == 152)
  2198. bl_level = 248;
  2199. else if (pSmart->brightness_level == 162)
  2200. bl_level = 264;
  2201. else
  2202. bl_level = 274;
  2203. } else if ((pSmart->brightness_level <= AOR_ADJUST_CD) &&
  2204. (pSmart->brightness_level > 105)) {
  2205. /* 106CD ~ 110CD */
  2206. if (pSmart->brightness_level == 106)
  2207. bl_level = 122;
  2208. else if (pSmart->brightness_level == 107)
  2209. bl_level = 134;
  2210. else if (pSmart->brightness_level == 108)
  2211. bl_level = 147;
  2212. else if (pSmart->brightness_level == 109)
  2213. bl_level = 159;
  2214. else if (pSmart->brightness_level == 110)
  2215. bl_level = 171;
  2216. } else {
  2217. /* 100CD ~ 10CD */
  2218. bl_level = AOR_ADJUST_CD;
  2219. }
  2220. if (pSmart->brightness_level < 350) {
  2221. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  2222. point_index = S6E8FA_ARRAY[cnt+1];
  2223. temp_cal_data =
  2224. ((long long)(candela_coeff_2p15[point_index])) *
  2225. ((long long)(bl_level));
  2226. candela_level[cnt] = temp_cal_data;
  2227. }
  2228. } else {
  2229. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  2230. point_index = S6E8FA_ARRAY[cnt+1];
  2231. temp_cal_data =
  2232. ((long long)(candela_coeff_2p2[point_index])) *
  2233. ((long long)(bl_level));
  2234. candela_level[cnt] = temp_cal_data;
  2235. }
  2236. }
  2237. #ifdef SMART_DIMMING_DEBUG
  2238. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2239. candela_level[0], candela_level[1], candela_level[2]);
  2240. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2241. candela_level[3], candela_level[4], candela_level[5]);
  2242. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2243. candela_level[6], candela_level[7], candela_level[8]);
  2244. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  2245. #endif
  2246. /* max 350cd */
  2247. memcpy(curve_1p9, curve_1p9_350, sizeof(curve_1p9_350));
  2248. memcpy(curve_2p2, curve_2p2_350, sizeof(curve_1p9_350));
  2249. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  2250. if (searching_function(candela_level[cnt],
  2251. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2252. pr_info("%s searching functioin error cnt:%d\n",
  2253. __func__, cnt);
  2254. }
  2255. }
  2256. /*
  2257. * Candela compensation
  2258. */
  2259. for (cnt = 1; cnt < S6E8FA_TABLE_MAX; cnt++) {
  2260. table_index = find_cadela_table(pSmart->brightness_level);
  2261. if (table_index == -1) {
  2262. table_index = CCG6_MAX_TABLE;
  2263. pr_info("%s fail candela table_index cnt : %d brightness %d",
  2264. __func__, cnt, pSmart->brightness_level);
  2265. }
  2266. bl_index[S6E8FA_TABLE_MAX - cnt] +=
  2267. gradation_offset[table_index][cnt - 1];
  2268. }
  2269. #ifdef SMART_DIMMING_DEBUG
  2270. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2271. bl_index[0], bl_index[1], bl_index[2]);
  2272. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2273. bl_index[3], bl_index[4], bl_index[5]);
  2274. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2275. bl_index[6], bl_index[7], bl_index[8]);
  2276. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2277. #endif
  2278. /*Generate Gamma table*/
  2279. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++)
  2280. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2281. /*
  2282. * RGB compensation
  2283. */
  2284. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  2285. table_index = find_cadela_table(pSmart->brightness_level);
  2286. if (table_index == -1) {
  2287. table_index = CCG6_MAX_TABLE;
  2288. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  2289. __func__, cnt, pSmart->brightness_level);
  2290. }
  2291. if (cnt < 3) {
  2292. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  2293. level_V255 +=
  2294. rgb_offset_evt1_third[table_index][cnt];
  2295. level_255_temp_MSB = level_V255 / 256;
  2296. str[cnt * 2] = level_255_temp_MSB & 0xff;
  2297. str[(cnt * 2) + 1] = level_V255 & 0xff;
  2298. } else {
  2299. str[cnt+3] += rgb_offset_evt1_third[table_index][cnt];
  2300. }
  2301. }
  2302. /*subtration MTP_OFFSET value from generated gamma table*/
  2303. mtp_offset_substraction(pSmart, str);
  2304. }
  2305. #endif
  2306. #endif
  2307. static void pure_gamma_init(struct SMART_DIM *pSmart, char *str, int size)
  2308. {
  2309. long long candela_level[S6E8FA_TABLE_MAX] = {-1, };
  2310. int bl_index[S6E8FA_TABLE_MAX] = {-1, };
  2311. long long temp_cal_data = 0;
  2312. int bl_level, cnt;
  2313. int point_index;
  2314. bl_level = pSmart->brightness_level;
  2315. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  2316. point_index = S6E8FA_ARRAY[cnt+1];
  2317. temp_cal_data =
  2318. ((long long)(candela_coeff_2p2[point_index])) *
  2319. ((long long)(bl_level));
  2320. candela_level[cnt] = temp_cal_data;
  2321. }
  2322. #ifdef SMART_DIMMING_DEBUG
  2323. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  2324. candela_level[0], candela_level[1], candela_level[2]);
  2325. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  2326. candela_level[3], candela_level[4], candela_level[5]);
  2327. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  2328. candela_level[6], candela_level[7], candela_level[8]);
  2329. printk(KERN_INFO "candela_255:%llu\n", candela_level[9]);
  2330. #endif
  2331. memcpy(curve_1p9, curve_1p9_350, sizeof(curve_1p9_350));
  2332. memcpy(curve_2p2, curve_2p2_350, sizeof(curve_1p9_350));
  2333. /*calculate brightness level*/
  2334. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++) {
  2335. if (searching_function(candela_level[cnt],
  2336. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  2337. pr_info("%s searching functioin error cnt:%d\n",
  2338. __func__, cnt);
  2339. }
  2340. }
  2341. /*
  2342. * 210CD ~ 190CD compensation
  2343. * V3 level + 1
  2344. */
  2345. if ((bl_level >= 190) && (bl_level <= 210))
  2346. bl_index[1] += 1;
  2347. #ifdef SMART_DIMMING_DEBUG
  2348. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  2349. bl_index[0], bl_index[1], bl_index[2]);
  2350. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  2351. bl_index[3], bl_index[4], bl_index[5]);
  2352. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  2353. bl_index[5], bl_index[7], bl_index[8]);
  2354. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  2355. #endif
  2356. /*Generate Gamma table*/
  2357. for (cnt = 0; cnt < S6E8FA_TABLE_MAX; cnt++)
  2358. (void)Make_hexa[cnt](bl_index , pSmart, str);
  2359. mtp_offset_substraction(pSmart, str);
  2360. /*
  2361. * Avoid build waring there are the list of gamma table
  2362. * that defined but not used for ea8061 ldi
  2363. */
  2364. temp_candela_coeff = curve_2p15_350;
  2365. temp_candela_coeff = s6e63m0_curve_2p2;
  2366. temp_candela_coeff = s6e63m0_candela_coeff;
  2367. temp_candela_coeff = candela_coeff_1p6;
  2368. temp_candela_coeff = candela_coeff_1p65;
  2369. temp_candela_coeff = candela_coeff_1p7;
  2370. temp_candela_coeff = candela_coeff_1p75;
  2371. temp_candela_coeff = candela_coeff_1p8;
  2372. temp_candela_coeff = candela_coeff_1p85;
  2373. temp_candela_coeff = candela_coeff_1p9;
  2374. temp_candela_coeff = candela_coeff_1p95;
  2375. temp_candela_coeff = candela_coeff_2p0;
  2376. temp_candela_coeff = candela_coeff_2p05;
  2377. temp_candela_coeff = candela_coeff_2p1;
  2378. temp_candela_coeff = candela_coeff_2p25;
  2379. temp_candela_coeff = curve_1p9_360;
  2380. temp_candela_coeff = curve_2p15_360;
  2381. temp_candela_coeff = curve_2p2_360;
  2382. }
  2383. static void set_max_lux_table(void)
  2384. {
  2385. max_lux_table[0] = V255_300CD_R_MSB;
  2386. max_lux_table[1] = V255_300CD_R_LSB;
  2387. max_lux_table[2] = V255_300CD_G_MSB;
  2388. max_lux_table[3] = V255_300CD_G_LSB;
  2389. max_lux_table[4] = V255_300CD_B_MSB;
  2390. max_lux_table[5] = V255_300CD_B_LSB;
  2391. max_lux_table[6] = V203_300CD_R;
  2392. max_lux_table[7] = V203_300CD_G;
  2393. max_lux_table[8] = V203_300CD_B;
  2394. max_lux_table[9] = V151_300CD_R;
  2395. max_lux_table[10] = V151_300CD_G;
  2396. max_lux_table[11] = V151_300CD_B;
  2397. max_lux_table[12] = V87_300CD_R;
  2398. max_lux_table[13] = V87_300CD_G;
  2399. max_lux_table[14] = V87_300CD_B;
  2400. max_lux_table[15] = V51_300CD_R;
  2401. max_lux_table[16] = V51_300CD_G;
  2402. max_lux_table[17] = V51_300CD_B;
  2403. max_lux_table[18] = V35_300CD_R;
  2404. max_lux_table[19] = V35_300CD_G;
  2405. max_lux_table[20] = V35_300CD_B;
  2406. max_lux_table[21] = V23_300CD_R;
  2407. max_lux_table[22] = V23_300CD_G;
  2408. max_lux_table[23] = V23_300CD_B;
  2409. max_lux_table[24] = V11_300CD_R;
  2410. max_lux_table[25] = V11_300CD_G;
  2411. max_lux_table[26] = V11_300CD_B;
  2412. max_lux_table[27] = V3_300CD_R;
  2413. max_lux_table[28] = V3_300CD_G;
  2414. max_lux_table[29] = V3_300CD_B;
  2415. max_lux_table[30] = VT_300CD_R;
  2416. max_lux_table[31] = VT_300CD_G;
  2417. max_lux_table[32] = VT_300CD_B;
  2418. }
  2419. static void set_min_lux_table(struct SMART_DIM *psmart)
  2420. {
  2421. psmart->brightness_level = MIN_CANDELA;
  2422. pure_gamma_init(psmart, min_lux_table, GAMMA_SET_MAX);
  2423. }
  2424. static void get_min_lux_table(char *str, int size)
  2425. {
  2426. memcpy(str, min_lux_table, size);
  2427. }
  2428. static void generate_gamma(struct SMART_DIM *psmart, char *str, int size)
  2429. {
  2430. int lux_loop;
  2431. struct illuminance_table *ptable = (struct illuminance_table *)
  2432. (&(psmart->gen_table));
  2433. /* searching already generated gamma table */
  2434. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  2435. if (ptable[lux_loop].lux == psmart->brightness_level) {
  2436. memcpy(str, &(ptable[lux_loop].gamma_setting), size);
  2437. break;
  2438. }
  2439. }
  2440. /* searching fail... Setting 300CD value on gamma table */
  2441. if (lux_loop == psmart->lux_table_max) {
  2442. pr_info("%s searching fail lux : %d\n", __func__,
  2443. psmart->brightness_level);
  2444. memcpy(str, max_lux_table, size);
  2445. }
  2446. #ifdef SMART_DIMMING_DEBUG
  2447. if (lux_loop != psmart->lux_table_max)
  2448. pr_info("%s searching ok index : %d lux : %d", __func__,
  2449. lux_loop, ptable[lux_loop].lux);
  2450. #endif
  2451. }
  2452. static void gamma_cell_determine(int ldi_revision)
  2453. {
  2454. pr_info("%s ldi_revision: 0x%x", __func__, ldi_revision);
  2455. V255_300CD_R_MSB = V255_300CD_R_MSB_20;
  2456. V255_300CD_R_LSB = V255_300CD_R_LSB_20;
  2457. V255_300CD_G_MSB = V255_300CD_G_MSB_20;
  2458. V255_300CD_G_LSB = V255_300CD_G_LSB_20;
  2459. V255_300CD_B_MSB = V255_300CD_B_MSB_20;
  2460. V255_300CD_B_LSB = V255_300CD_B_LSB_20;
  2461. V203_300CD_R = V203_300CD_R_20;
  2462. V203_300CD_G = V203_300CD_G_20;
  2463. V203_300CD_B = V203_300CD_B_20;
  2464. V151_300CD_R = V151_300CD_R_20;
  2465. V151_300CD_G = V151_300CD_G_20;
  2466. V151_300CD_B = V151_300CD_B_20;
  2467. V87_300CD_R = V87_300CD_R_20;
  2468. V87_300CD_G = V87_300CD_G_20;
  2469. V87_300CD_B = V87_300CD_B_20;
  2470. V51_300CD_R = V51_300CD_R_20;
  2471. V51_300CD_G = V51_300CD_G_20;
  2472. V51_300CD_B = V51_300CD_B_20;
  2473. V35_300CD_R = V35_300CD_R_20;
  2474. V35_300CD_G = V35_300CD_G_20;
  2475. V35_300CD_B = V35_300CD_B_20;
  2476. V23_300CD_R = V23_300CD_R_20;
  2477. V23_300CD_G = V23_300CD_G_20;
  2478. V23_300CD_B = V23_300CD_B_20;
  2479. V11_300CD_R = V11_300CD_R_20;
  2480. V11_300CD_G = V11_300CD_G_20;
  2481. V11_300CD_B = V11_300CD_B_20;
  2482. V3_300CD_R = V3_300CD_R_20;
  2483. V3_300CD_G = V3_300CD_G_20;
  2484. V3_300CD_B = V3_300CD_B_20;
  2485. VT_300CD_R = VT_300CD_R_20;
  2486. VT_300CD_G = VT_300CD_G_20;
  2487. VT_300CD_B = VT_300CD_B_20;
  2488. }
  2489. static void mtp_sorting(struct SMART_DIM *psmart)
  2490. {
  2491. int sorting[GAMMA_SET_MAX] = {
  2492. 0, 1, 6, 9, 12, 15, 18, 21, 24, 27, 30, /* R*/
  2493. 2, 3, 7, 10, 13, 16, 19, 22, 25, 28, 31, /* G */
  2494. 4, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, /* B */
  2495. };
  2496. int loop;
  2497. char *pfrom, *pdest;
  2498. int vt_offset[VT_GAMMA_SET_MAX] =\
  2499. {VT_GAMMA_OFFSET_R, VT_GAMMA_OFFSET_G, VT_GAMMA_OFFSET_B,};
  2500. int vt_bit_shift[VT_GAMMA_SET_MAX] =\
  2501. {VT_GAMMA_BIT_SHIFT_R, VT_GAMMA_BIT_SHIFT_G, VT_GAMMA_BIT_SHIFT_B,};
  2502. int vt_bit_mask[VT_GAMMA_SET_MAX] =\
  2503. {VT_GAMMA_BIT_MASK_R, VT_GAMMA_BIT_MASK_G, VT_GAMMA_BIT_MASK_B,};
  2504. pfrom = (char *)&(psmart->MTP_ORIGN);
  2505. pdest = (char *)&(psmart->MTP);
  2506. /*
  2507. * Sort gamma setting for VT only
  2508. * 31th para : VT G/R
  2509. * 23th para : VT B
  2510. */
  2511. for (loop = VT_GAMMA_SET_MAX - 1; loop >= 0; loop--)
  2512. pfrom[VT_GAMMA_OFFSET + loop] =\
  2513. (pfrom[VT_GAMMA_OFFSET + vt_offset[loop]] >> vt_bit_shift[loop]) & vt_bit_mask[loop];
  2514. for (loop = 0; loop < GAMMA_SET_MAX; loop++)
  2515. pdest[loop] = pfrom[sorting[loop]];
  2516. }
  2517. static int smart_dimming_init(struct SMART_DIM *psmart)
  2518. {
  2519. int lux_loop;
  2520. int id3; // id1, id2;
  2521. #ifdef SMART_DIMMING_DEBUG
  2522. int cnt;
  2523. char pBuffer[256];
  2524. memset(pBuffer, 0x00, 256);
  2525. #endif
  2526. /*id1 = (psmart->ldi_revision & 0x00FF0000) >> 16;
  2527. id2 = (psmart->ldi_revision & 0x0000FF00) >> 8;*/
  2528. id3 = psmart->ldi_revision & 0xFF;
  2529. pr_debug("%s : ++\n",__func__);
  2530. mtp_sorting(psmart);
  2531. gamma_cell_determine(psmart->ldi_revision);
  2532. set_max_lux_table();
  2533. #ifdef SMART_DIMMING_DEBUG
  2534. print_RGB_offset(psmart);
  2535. #endif
  2536. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  2537. psmart->vregout_voltage = EA8061_VREG0_REF_6P1;
  2538. #else
  2539. psmart->vregout_voltage = S6E8FA_VREG0_REF;
  2540. #endif
  2541. v255_adjustment(psmart);
  2542. vt_adjustment(psmart);
  2543. v203_adjustment(psmart);
  2544. v151_adjustment(psmart);
  2545. v87_adjustment(psmart);
  2546. v51_adjustment(psmart);
  2547. v35_adjustment(psmart);
  2548. v23_adjustment(psmart);
  2549. v11_adjustment(psmart);
  2550. v3_adjustment(psmart);
  2551. if (generate_gray_scale(psmart)) {
  2552. pr_info(KERN_ERR "lcd smart dimming fail generate_gray_scale\n");
  2553. return -EINVAL;
  2554. }
  2555. /*Generating lux_table*/
  2556. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  2557. /* To set brightness value */
  2558. psmart->brightness_level = psmart->plux_table[lux_loop];
  2559. /* To make lux table index*/
  2560. psmart->gen_table[lux_loop].lux = psmart->plux_table[lux_loop];
  2561. #if defined(AID_OPERATION)
  2562. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  2563. if((id3 == EVT2_EA8061_HESTIA_REV_J) ||(id3 == EVT2_EA8061_HESTIA_REV_A))
  2564. gamma_init_revJ(psmart,
  2565. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  2566. GAMMA_SET_MAX);
  2567. else
  2568. gamma_init_revI(psmart,
  2569. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  2570. GAMMA_SET_MAX);
  2571. #else
  2572. gamma_init_evt1_third(psmart,
  2573. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  2574. GAMMA_SET_MAX);
  2575. #endif
  2576. #else
  2577. pure_gamma_init(psmart,
  2578. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  2579. GAMMA_SET_MAX);
  2580. #endif
  2581. }
  2582. /* set 300CD max gamma table */
  2583. memcpy(&(psmart->gen_table[lux_loop-1].gamma_setting),
  2584. max_lux_table, GAMMA_SET_MAX);
  2585. set_min_lux_table(psmart);
  2586. #ifdef SMART_DIMMING_DEBUG
  2587. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  2588. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  2589. snprintf(pBuffer + strnlen(pBuffer, 256), 256, " %d",
  2590. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  2591. pr_info("lux : %d %s", psmart->plux_table[lux_loop], pBuffer);
  2592. memset(pBuffer, 0x00, 256);
  2593. }
  2594. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  2595. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  2596. snprintf(pBuffer + strnlen(pBuffer, 256), 256,
  2597. " %02X",
  2598. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  2599. pr_info("lux : %d %s", psmart->plux_table[lux_loop], pBuffer);
  2600. memset(pBuffer, 0x00, 256);
  2601. }
  2602. #endif
  2603. return 0;
  2604. }
  2605. /* ----------------------------------------------------------------------------
  2606. * Wrapper functions for smart dimming to work with 8974 generic code
  2607. * ----------------------------------------------------------------------------
  2608. */
  2609. static struct SMART_DIM smart_S6E8FA0;
  2610. static struct smartdim_conf __S6E8FA0__ ;
  2611. static void wrap_generate_gamma(int cd, char *cmd_str) {
  2612. smart_S6E8FA0.brightness_level = cd;
  2613. generate_gamma(&smart_S6E8FA0, cmd_str, GAMMA_SET_MAX);
  2614. }
  2615. static void wrap_smart_dimming_init(void) {
  2616. smart_S6E8FA0.plux_table = __S6E8FA0__.lux_tab;
  2617. smart_S6E8FA0.lux_table_max = __S6E8FA0__.lux_tabsize;
  2618. smart_S6E8FA0.ldi_revision = __S6E8FA0__.man_id;
  2619. smart_dimming_init(&smart_S6E8FA0);
  2620. }
  2621. struct smartdim_conf *smart_S6E8FA0_get_conf(void){
  2622. __S6E8FA0__.generate_gamma = wrap_generate_gamma;
  2623. __S6E8FA0__.init = wrap_smart_dimming_init;
  2624. __S6E8FA0__.get_min_lux_table = get_min_lux_table;
  2625. __S6E8FA0__.mtp_buffer = (char *)(&smart_S6E8FA0.MTP_ORIGN);
  2626. return (struct smartdim_conf *)&__S6E8FA0__;
  2627. }
  2628. struct smartdim_conf *smart_S6E3FA0_get_conf(void){
  2629. __S6E8FA0__.generate_gamma = wrap_generate_gamma;
  2630. __S6E8FA0__.init = wrap_smart_dimming_init;
  2631. __S6E8FA0__.get_min_lux_table = get_min_lux_table;
  2632. __S6E8FA0__.mtp_buffer = (char *)(&smart_S6E8FA0.MTP_ORIGN);
  2633. return (struct smartdim_conf *)&__S6E8FA0__;
  2634. }
  2635. /* ----------------------------------------------------------------------------
  2636. * END - Wrapper
  2637. * ----------------------------------------------------------------------------
  2638. */