smart_mtp_s6e3ha1.c 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186
  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_s6e3ha1.h"
  33. #include "smart_mtp_2p2_gamma.h"
  34. #include "smart_dimming.h"
  35. /*
  36. #define SMART_DIMMING_DEBUG
  37. */
  38. static char max_lux_table[GAMMA_SET_MAX];
  39. static char min_lux_table[GAMMA_SET_MAX];
  40. /*
  41. * To support different center cell gamma setting
  42. */
  43. static char V255_300CD_R_MSB;
  44. static char V255_300CD_R_LSB;
  45. static char V255_300CD_G_MSB;
  46. static char V255_300CD_G_LSB;
  47. static char V255_300CD_B_MSB;
  48. static char V255_300CD_B_LSB;
  49. static char V203_300CD_R;
  50. static char V203_300CD_G;
  51. static char V203_300CD_B;
  52. static char V151_300CD_R;
  53. static char V151_300CD_G;
  54. static char V151_300CD_B;
  55. static char V87_300CD_R;
  56. static char V87_300CD_G;
  57. static char V87_300CD_B;
  58. static char V51_300CD_R;
  59. static char V51_300CD_G;
  60. static char V51_300CD_B;
  61. static char V35_300CD_R;
  62. static char V35_300CD_G;
  63. static char V35_300CD_B;
  64. static char V23_300CD_R;
  65. static char V23_300CD_G;
  66. static char V23_300CD_B;
  67. static char V11_300CD_R;
  68. static char V11_300CD_G;
  69. static char V11_300CD_B;
  70. static char V3_300CD_R;
  71. static char V3_300CD_G;
  72. static char V3_300CD_B;
  73. static char VT_300CD_R;
  74. static char VT_300CD_G;
  75. static char VT_300CD_B;
  76. static int char_to_int(char data1)
  77. {
  78. int cal_data;
  79. if (data1 & 0x80) {
  80. cal_data = data1 & 0x7F;
  81. cal_data *= -1;
  82. } else
  83. cal_data = data1;
  84. return cal_data;
  85. }
  86. static int char_to_int_v255(char data1, char data2)
  87. {
  88. int cal_data;
  89. if (data1)
  90. cal_data = data2 * -1;
  91. else
  92. cal_data = data2;
  93. return cal_data;
  94. }
  95. #ifdef SMART_DIMMING_DEBUG
  96. static void print_RGB_offset(struct SMART_DIM *pSmart)
  97. {
  98. pr_info("%s MTP Offset VT R:%d G:%d B:%d\n", __func__,
  99. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1),
  100. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1),
  101. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1));
  102. pr_info("%s MTP Offset V3 R:%d G:%d B:%d\n", __func__,
  103. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3),
  104. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3),
  105. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3));
  106. pr_info("%s MTP Offset V11 R:%d G:%d B:%d\n", __func__,
  107. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11),
  108. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11),
  109. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11));
  110. pr_info("%s MTP Offset V23 R:%d G:%d B:%d\n", __func__,
  111. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23),
  112. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23),
  113. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23));
  114. pr_info("%s MTP Offset V35 R:%d G:%d B:%d\n", __func__,
  115. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35),
  116. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35),
  117. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35));
  118. pr_info("%s MTP Offset V51 R:%d G:%d B:%d\n", __func__,
  119. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51),
  120. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51),
  121. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51));
  122. pr_info("%s MTP Offset V87 R:%d G:%d B:%d\n", __func__,
  123. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87),
  124. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87),
  125. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87));
  126. pr_info("%s MTP Offset V151 R:%d G:%d B:%d\n", __func__,
  127. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151),
  128. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151),
  129. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151));
  130. pr_info("%s MTP Offset V203 R:%d G:%d B:%d\n", __func__,
  131. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203),
  132. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203),
  133. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203));
  134. pr_info("%s MTP Offset V255 R:%d G:%d B:%d\n", __func__,
  135. char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  136. pSmart->MTP.R_OFFSET.OFFSET_255_LSB),
  137. char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  138. pSmart->MTP.G_OFFSET.OFFSET_255_LSB),
  139. char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  140. pSmart->MTP.B_OFFSET.OFFSET_255_LSB));
  141. }
  142. #endif
  143. #define v255_coefficient 72
  144. #define v255_denominator 860
  145. static int v255_adjustment(struct SMART_DIM *pSmart)
  146. {
  147. unsigned long long result_1, result_2, result_3, result_4;
  148. int add_mtp;
  149. int LSB;
  150. int v255_value;
  151. v255_value = (V255_300CD_R_MSB << 8) | (V255_300CD_R_LSB);
  152. LSB = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  153. pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
  154. add_mtp = LSB + v255_value;
  155. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  156. do_div(result_2, v255_denominator);
  157. result_3 = (S6E3HA1_VREG0_REF * result_2) >> BIT_SHIFT;
  158. result_4 = S6E3HA1_VREG0_REF - result_3;
  159. pSmart->RGB_OUTPUT.R_VOLTAGE.level_255 = result_4;
  160. pSmart->RGB_OUTPUT.R_VOLTAGE.level_0 = S6E3HA1_VREG0_REF;
  161. v255_value = (V255_300CD_G_MSB << 8) | (V255_300CD_G_LSB);
  162. LSB = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  163. pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
  164. add_mtp = LSB + v255_value;
  165. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  166. do_div(result_2, v255_denominator);
  167. result_3 = (S6E3HA1_VREG0_REF * result_2) >> BIT_SHIFT;
  168. result_4 = S6E3HA1_VREG0_REF - result_3;
  169. pSmart->RGB_OUTPUT.G_VOLTAGE.level_255 = result_4;
  170. pSmart->RGB_OUTPUT.G_VOLTAGE.level_0 = S6E3HA1_VREG0_REF;
  171. v255_value = (V255_300CD_B_MSB << 8) | (V255_300CD_B_LSB);
  172. LSB = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  173. pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
  174. add_mtp = LSB + v255_value;
  175. result_1 = result_2 = (v255_coefficient+add_mtp) << BIT_SHIFT;
  176. do_div(result_2, v255_denominator);
  177. result_3 = (S6E3HA1_VREG0_REF * result_2) >> BIT_SHIFT;
  178. result_4 = S6E3HA1_VREG0_REF - result_3;
  179. pSmart->RGB_OUTPUT.B_VOLTAGE.level_255 = result_4;
  180. pSmart->RGB_OUTPUT.B_VOLTAGE.level_0 = S6E3HA1_VREG0_REF;
  181. #ifdef SMART_DIMMING_DEBUG
  182. pr_info("%s MTP Offset VT R:%d G:%d B:%d\n", __func__,
  183. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1),
  184. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1),
  185. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1));
  186. pr_info("%s MTP Offset V3 R:%d G:%d B:%d\n", __func__,
  187. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3),
  188. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3),
  189. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3));
  190. pr_info("%s MTP Offset V11 R:%d G:%d B:%d\n", __func__,
  191. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11),
  192. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11),
  193. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11));
  194. pr_info("%s MTP Offset V23 R:%d G:%d B:%d\n", __func__,
  195. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23),
  196. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23),
  197. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23));
  198. pr_info("%s MTP Offset V35 R:%d G:%d B:%d\n", __func__,
  199. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35),
  200. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35),
  201. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35));
  202. pr_info("%s MTP Offset V51 R:%d G:%d B:%d\n", __func__,
  203. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51),
  204. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51),
  205. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51));
  206. pr_info("%s MTP Offset V87 R:%d G:%d B:%d\n", __func__,
  207. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87),
  208. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87),
  209. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87));
  210. pr_info("%s MTP Offset V151 R:%d G:%d B:%d\n", __func__,
  211. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151),
  212. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151),
  213. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151));
  214. pr_info("%s MTP Offset V203 R:%d G:%d B:%d\n", __func__,
  215. char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203),
  216. char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203),
  217. char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203));
  218. pr_info("%s MTP Offset V255 R:%d G:%d B:%d\n", __func__,
  219. char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  220. pSmart->MTP.R_OFFSET.OFFSET_255_LSB),
  221. char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  222. pSmart->MTP.G_OFFSET.OFFSET_255_LSB),
  223. char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  224. pSmart->MTP.B_OFFSET.OFFSET_255_LSB));
  225. pr_info("%s V255 RED:%d GREEN:%d BLUE:%d\n", __func__,
  226. pSmart->RGB_OUTPUT.R_VOLTAGE.level_255,
  227. pSmart->RGB_OUTPUT.G_VOLTAGE.level_255,
  228. pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
  229. #endif
  230. return 0;
  231. }
  232. static void v255_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  233. {
  234. unsigned long long result_1, result_2, result_3;
  235. result_1 = S6E3HA1_VREG0_REF -
  236. (pSmart->GRAY.TABLE[index[V255_INDEX]].R_Gray);
  237. result_2 = result_1 * v255_denominator;
  238. do_div(result_2, S6E3HA1_VREG0_REF);
  239. result_3 = result_2 - v255_coefficient;
  240. str[0] = (result_3 & 0xff00) >> 8;
  241. str[1] = result_3 & 0xff;
  242. result_1 = S6E3HA1_VREG0_REF -
  243. (pSmart->GRAY.TABLE[index[V255_INDEX]].G_Gray);
  244. result_2 = result_1 * v255_denominator;
  245. do_div(result_2, S6E3HA1_VREG0_REF);
  246. result_3 = result_2 - v255_coefficient;
  247. str[2] = (result_3 & 0xff00) >> 8;
  248. str[3] = result_3 & 0xff;
  249. result_1 = S6E3HA1_VREG0_REF -
  250. (pSmart->GRAY.TABLE[index[V255_INDEX]].B_Gray);
  251. result_2 = result_1 * v255_denominator;
  252. do_div(result_2, S6E3HA1_VREG0_REF);
  253. result_3 = result_2 - v255_coefficient;
  254. str[4] = (result_3 & 0xff00) >> 8;
  255. str[5] = result_3 & 0xff;
  256. }
  257. static int vt_coefficient[] = {
  258. 0, 12, 24, 36, 48,
  259. 60, 72, 84, 96, 108,
  260. 138, 148, 158, 168,
  261. 178, 186,
  262. };
  263. #define vt_denominator 860
  264. static int vt_adjustment(struct SMART_DIM *pSmart)
  265. {
  266. unsigned long long result_1, result_2, result_3, result_4;
  267. int add_mtp;
  268. int LSB;
  269. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_1);
  270. add_mtp = LSB + VT_300CD_R;
  271. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  272. do_div(result_2, vt_denominator);
  273. result_3 = (S6E3HA1_VREG0_REF * result_2) >> BIT_SHIFT;
  274. result_4 = S6E3HA1_VREG0_REF - result_3;
  275. pSmart->GRAY.VT_TABLE.R_Gray = result_4;
  276. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_1);
  277. add_mtp = LSB + VT_300CD_G;
  278. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  279. do_div(result_2, vt_denominator);
  280. result_3 = (S6E3HA1_VREG0_REF * result_2) >> BIT_SHIFT;
  281. result_4 = S6E3HA1_VREG0_REF - result_3;
  282. pSmart->GRAY.VT_TABLE.G_Gray = result_4;
  283. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_1);
  284. add_mtp = LSB + VT_300CD_B;
  285. result_1 = result_2 = vt_coefficient[LSB] << BIT_SHIFT;
  286. do_div(result_2, vt_denominator);
  287. result_3 = (S6E3HA1_VREG0_REF * result_2) >> BIT_SHIFT;
  288. result_4 = S6E3HA1_VREG0_REF - result_3;
  289. pSmart->GRAY.VT_TABLE.B_Gray = result_4;
  290. #ifdef SMART_DIMMING_DEBUG
  291. pr_info("%s VT RED:%d GREEN:%d BLUE:%d\n", __func__,
  292. pSmart->GRAY.VT_TABLE.R_Gray,
  293. pSmart->GRAY.VT_TABLE.G_Gray,
  294. pSmart->GRAY.VT_TABLE.B_Gray);
  295. #endif
  296. return 0;
  297. }
  298. static void vt_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  299. {
  300. str[30] = VT_300CD_R;
  301. str[31] = VT_300CD_G;
  302. str[32] = VT_300CD_B;
  303. }
  304. #define v203_coefficient 64
  305. #define v203_denominator 320
  306. static int v203_adjustment(struct SMART_DIM *pSmart)
  307. {
  308. unsigned long long result_1, result_2, result_3, result_4;
  309. int add_mtp;
  310. int LSB;
  311. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203);
  312. add_mtp = LSB + V203_300CD_R;
  313. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  314. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_255);
  315. result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
  316. do_div(result_2, v203_denominator);
  317. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  318. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  319. pSmart->RGB_OUTPUT.R_VOLTAGE.level_203 = result_4;
  320. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203);
  321. add_mtp = LSB + V203_300CD_G;
  322. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  323. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_255);
  324. result_2 = (v203_coefficient + add_mtp) << BIT_SHIFT;
  325. do_div(result_2, v203_denominator);
  326. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  327. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  328. pSmart->RGB_OUTPUT.G_VOLTAGE.level_203 = result_4;
  329. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203);
  330. add_mtp = LSB + V203_300CD_B;
  331. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  332. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_255);
  333. result_2 = (v203_coefficient+add_mtp) << BIT_SHIFT;
  334. do_div(result_2, v203_denominator);
  335. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  336. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  337. pSmart->RGB_OUTPUT.B_VOLTAGE.level_203 = result_4;
  338. #ifdef SMART_DIMMING_DEBUG
  339. pr_info("%s V203 RED:%d GREEN:%d BLUE:%d\n", __func__,
  340. pSmart->RGB_OUTPUT.R_VOLTAGE.level_203,
  341. pSmart->RGB_OUTPUT.G_VOLTAGE.level_203,
  342. pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
  343. #endif
  344. return 0;
  345. }
  346. static void v203_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  347. {
  348. unsigned long long result_1, result_2, result_3;
  349. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  350. - (pSmart->GRAY.TABLE[index[V203_INDEX]].R_Gray);
  351. result_2 = result_1 * v203_denominator;
  352. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  353. - (pSmart->GRAY.TABLE[index[V255_INDEX]].R_Gray);
  354. do_div(result_2, result_3);
  355. str[6] = (result_2 - v203_coefficient) & 0xff;
  356. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  357. - (pSmart->GRAY.TABLE[index[V203_INDEX]].G_Gray);
  358. result_2 = result_1 * v203_denominator;
  359. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  360. - (pSmart->GRAY.TABLE[index[V255_INDEX]].G_Gray);
  361. do_div(result_2, result_3);
  362. str[7] = (result_2 - v203_coefficient) & 0xff;
  363. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  364. - (pSmart->GRAY.TABLE[index[V203_INDEX]].B_Gray);
  365. result_2 = result_1 * v203_denominator;
  366. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  367. - (pSmart->GRAY.TABLE[index[V255_INDEX]].B_Gray);
  368. do_div(result_2, result_3);
  369. str[8] = (result_2 - v203_coefficient) & 0xff;
  370. }
  371. #define v151_coefficient 64
  372. #define v151_denominator 320
  373. static int v151_adjustment(struct SMART_DIM *pSmart)
  374. {
  375. unsigned long long result_1, result_2, result_3, result_4;
  376. int add_mtp;
  377. int LSB;
  378. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151);
  379. add_mtp = LSB + V151_300CD_R;
  380. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  381. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_203);
  382. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  383. do_div(result_2, v151_denominator);
  384. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  385. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  386. pSmart->RGB_OUTPUT.R_VOLTAGE.level_151 = result_4;
  387. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151);
  388. add_mtp = LSB + V151_300CD_G;
  389. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  390. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_203);
  391. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  392. do_div(result_2, v151_denominator);
  393. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  394. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  395. pSmart->RGB_OUTPUT.G_VOLTAGE.level_151 = result_4;
  396. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151);
  397. add_mtp = LSB + V151_300CD_B;
  398. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  399. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_203);
  400. result_2 = (v151_coefficient + add_mtp) << BIT_SHIFT;
  401. do_div(result_2, v151_denominator);
  402. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  403. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  404. pSmart->RGB_OUTPUT.B_VOLTAGE.level_151 = result_4;
  405. #ifdef SMART_DIMMING_DEBUG
  406. pr_info("%s V151 RED:%d GREEN:%d BLUE:%d\n", __func__,
  407. pSmart->RGB_OUTPUT.R_VOLTAGE.level_151,
  408. pSmart->RGB_OUTPUT.G_VOLTAGE.level_151,
  409. pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
  410. #endif
  411. return 0;
  412. }
  413. static void v151_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  414. {
  415. unsigned long long result_1, result_2, result_3;
  416. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  417. - (pSmart->GRAY.TABLE[index[V151_INDEX]].R_Gray);
  418. result_2 = result_1 * v151_denominator;
  419. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  420. - (pSmart->GRAY.TABLE[index[V203_INDEX]].R_Gray);
  421. do_div(result_2, result_3);
  422. str[9] = (result_2 - v151_coefficient) & 0xff;
  423. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  424. - (pSmart->GRAY.TABLE[index[V151_INDEX]].G_Gray);
  425. result_2 = result_1 * v151_denominator;
  426. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  427. - (pSmart->GRAY.TABLE[index[V203_INDEX]].G_Gray);
  428. do_div(result_2, result_3);
  429. str[10] = (result_2 - v151_coefficient) & 0xff;
  430. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  431. - (pSmart->GRAY.TABLE[index[V151_INDEX]].B_Gray);
  432. result_2 = result_1 * v151_denominator;
  433. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  434. - (pSmart->GRAY.TABLE[index[V203_INDEX]].B_Gray);
  435. do_div(result_2, result_3);
  436. str[11] = (result_2 - v151_coefficient) & 0xff;
  437. }
  438. #define v87_coefficient 64
  439. #define v87_denominator 320
  440. static int v87_adjustment(struct SMART_DIM *pSmart)
  441. {
  442. unsigned long long result_1, result_2, result_3, result_4;
  443. int add_mtp;
  444. int LSB;
  445. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87);
  446. add_mtp = LSB + V87_300CD_R;
  447. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  448. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_151);
  449. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  450. do_div(result_2, v87_denominator);
  451. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  452. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  453. pSmart->RGB_OUTPUT.R_VOLTAGE.level_87 = result_4;
  454. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87);
  455. add_mtp = LSB + V87_300CD_G;
  456. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  457. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_151);
  458. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  459. do_div(result_2, v87_denominator);
  460. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  461. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  462. pSmart->RGB_OUTPUT.G_VOLTAGE.level_87 = result_4;
  463. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87);
  464. add_mtp = LSB + V87_300CD_B;
  465. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  466. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_151);
  467. result_2 = (v87_coefficient + add_mtp) << BIT_SHIFT;
  468. do_div(result_2, v87_denominator);
  469. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  470. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  471. pSmart->RGB_OUTPUT.B_VOLTAGE.level_87 = result_4;
  472. #ifdef SMART_DIMMING_DEBUG
  473. pr_info("%s V87 RED:%d GREEN:%d BLUE:%d\n", __func__,
  474. pSmart->RGB_OUTPUT.R_VOLTAGE.level_87,
  475. pSmart->RGB_OUTPUT.G_VOLTAGE.level_87,
  476. pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
  477. #endif
  478. return 0;
  479. }
  480. static void v87_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  481. {
  482. unsigned long long result_1, result_2, result_3;
  483. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  484. - (pSmart->GRAY.TABLE[index[V87_INDEX]].R_Gray);
  485. result_2 = result_1 * v87_denominator;
  486. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  487. - (pSmart->GRAY.TABLE[index[V151_INDEX]].R_Gray);
  488. do_div(result_2, result_3);
  489. str[12] = (result_2 - v87_coefficient) & 0xff;
  490. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  491. - (pSmart->GRAY.TABLE[index[V87_INDEX]].G_Gray);
  492. result_2 = result_1 * v87_denominator;
  493. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  494. - (pSmart->GRAY.TABLE[index[V151_INDEX]].G_Gray);
  495. do_div(result_2, result_3);
  496. str[13] = (result_2 - v87_coefficient) & 0xff;
  497. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  498. - (pSmart->GRAY.TABLE[index[V87_INDEX]].B_Gray);
  499. result_2 = result_1 * v87_denominator;
  500. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  501. - (pSmart->GRAY.TABLE[index[V151_INDEX]].B_Gray);
  502. do_div(result_2, result_3);
  503. str[14] = (result_2 - v87_coefficient) & 0xff;
  504. }
  505. #define v51_coefficient 64
  506. #define v51_denominator 320
  507. static int v51_adjustment(struct SMART_DIM *pSmart)
  508. {
  509. unsigned long long result_1, result_2, result_3, result_4;
  510. int add_mtp;
  511. int LSB;
  512. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51);
  513. add_mtp = LSB + V51_300CD_R;
  514. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  515. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_87);
  516. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  517. do_div(result_2, v51_denominator);
  518. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  519. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  520. pSmart->RGB_OUTPUT.R_VOLTAGE.level_51 = result_4;
  521. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51);
  522. add_mtp = LSB + V51_300CD_G;
  523. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  524. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_87);
  525. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  526. do_div(result_2, v51_denominator);
  527. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  528. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  529. pSmart->RGB_OUTPUT.G_VOLTAGE.level_51 = result_4;
  530. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51);
  531. add_mtp = LSB + V51_300CD_B;
  532. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  533. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_87);
  534. result_2 = (v51_coefficient + add_mtp) << BIT_SHIFT;
  535. do_div(result_2, v51_denominator);
  536. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  537. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  538. pSmart->RGB_OUTPUT.B_VOLTAGE.level_51 = result_4;
  539. #ifdef SMART_DIMMING_DEBUG
  540. pr_info("%s V51 RED:%d GREEN:%d BLUE:%d\n", __func__,
  541. pSmart->RGB_OUTPUT.R_VOLTAGE.level_51,
  542. pSmart->RGB_OUTPUT.G_VOLTAGE.level_51,
  543. pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
  544. #endif
  545. return 0;
  546. }
  547. static void v51_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  548. {
  549. unsigned long long result_1, result_2, result_3;
  550. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  551. - (pSmart->GRAY.TABLE[index[V51_INDEX]].R_Gray);
  552. result_2 = result_1 * v51_denominator;
  553. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  554. - (pSmart->GRAY.TABLE[index[V87_INDEX]].R_Gray);
  555. do_div(result_2, result_3);
  556. str[15] = (result_2 - v51_coefficient) & 0xff;
  557. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  558. - (pSmart->GRAY.TABLE[index[V51_INDEX]].G_Gray);
  559. result_2 = result_1 * v51_denominator;
  560. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  561. - (pSmart->GRAY.TABLE[index[V87_INDEX]].G_Gray);
  562. do_div(result_2, result_3);
  563. str[16] = (result_2 - v51_coefficient) & 0xff;
  564. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  565. - (pSmart->GRAY.TABLE[index[V51_INDEX]].B_Gray);
  566. result_2 = result_1 * v51_denominator;
  567. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  568. - (pSmart->GRAY.TABLE[index[V87_INDEX]].B_Gray);
  569. do_div(result_2, result_3);
  570. str[17] = (result_2 - v51_coefficient) & 0xff;
  571. }
  572. #define v35_coefficient 64
  573. #define v35_denominator 320
  574. static int v35_adjustment(struct SMART_DIM *pSmart)
  575. {
  576. unsigned long long result_1, result_2, result_3, result_4;
  577. int add_mtp;
  578. int LSB;
  579. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35);
  580. add_mtp = LSB + V35_300CD_R;
  581. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  582. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_51);
  583. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  584. do_div(result_2, v35_denominator);
  585. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  586. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  587. pSmart->RGB_OUTPUT.R_VOLTAGE.level_35 = result_4;
  588. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35);
  589. add_mtp = LSB + V35_300CD_G;
  590. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  591. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_51);
  592. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  593. do_div(result_2, v35_denominator);
  594. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  595. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  596. pSmart->RGB_OUTPUT.G_VOLTAGE.level_35 = result_4;
  597. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35);
  598. add_mtp = LSB + V35_300CD_B;
  599. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  600. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_51);
  601. result_2 = (v35_coefficient + add_mtp) << BIT_SHIFT;
  602. do_div(result_2, v35_denominator);
  603. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  604. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  605. pSmart->RGB_OUTPUT.B_VOLTAGE.level_35 = result_4;
  606. #ifdef SMART_DIMMING_DEBUG
  607. pr_info("%s V35 RED:%d GREEN:%d BLUE:%d\n", __func__,
  608. pSmart->RGB_OUTPUT.R_VOLTAGE.level_35,
  609. pSmart->RGB_OUTPUT.G_VOLTAGE.level_35,
  610. pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
  611. #endif
  612. return 0;
  613. }
  614. static void v35_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  615. {
  616. unsigned long long result_1, result_2, result_3;
  617. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  618. - (pSmart->GRAY.TABLE[index[V35_INDEX]].R_Gray);
  619. result_2 = result_1 * v35_denominator;
  620. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  621. - (pSmart->GRAY.TABLE[index[V51_INDEX]].R_Gray);
  622. do_div(result_2, result_3);
  623. str[18] = (result_2 - v35_coefficient) & 0xff;
  624. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  625. - (pSmart->GRAY.TABLE[index[V35_INDEX]].G_Gray);
  626. result_2 = result_1 * v35_denominator;
  627. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  628. - (pSmart->GRAY.TABLE[index[V51_INDEX]].G_Gray);
  629. do_div(result_2, result_3);
  630. str[19] = (result_2 - v35_coefficient) & 0xff;
  631. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  632. - (pSmart->GRAY.TABLE[index[V35_INDEX]].B_Gray);
  633. result_2 = result_1 * v35_denominator;
  634. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  635. - (pSmart->GRAY.TABLE[index[V51_INDEX]].B_Gray);
  636. do_div(result_2, result_3);
  637. str[20] = (result_2 - v35_coefficient) & 0xff;
  638. }
  639. #define v23_coefficient 64
  640. #define v23_denominator 320
  641. static int v23_adjustment(struct SMART_DIM *pSmart)
  642. {
  643. unsigned long long result_1, result_2, result_3, result_4;
  644. int add_mtp;
  645. int LSB;
  646. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23);
  647. add_mtp = LSB + V23_300CD_R;
  648. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  649. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_35);
  650. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  651. do_div(result_2, v23_denominator);
  652. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  653. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  654. pSmart->RGB_OUTPUT.R_VOLTAGE.level_23 = result_4;
  655. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23);
  656. add_mtp = LSB + V23_300CD_G;
  657. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  658. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_35);
  659. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  660. do_div(result_2, v23_denominator);
  661. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  662. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  663. pSmart->RGB_OUTPUT.G_VOLTAGE.level_23 = result_4;
  664. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23);
  665. add_mtp = LSB + V23_300CD_B;
  666. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  667. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_35);
  668. result_2 = (v23_coefficient + add_mtp) << BIT_SHIFT;
  669. do_div(result_2, v23_denominator);
  670. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  671. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  672. pSmart->RGB_OUTPUT.B_VOLTAGE.level_23 = result_4;
  673. #ifdef SMART_DIMMING_DEBUG
  674. pr_info("%s V23 RED:%d GREEN:%d BLUE:%d\n", __func__,
  675. pSmart->RGB_OUTPUT.R_VOLTAGE.level_23,
  676. pSmart->RGB_OUTPUT.G_VOLTAGE.level_23,
  677. pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
  678. #endif
  679. return 0;
  680. }
  681. static void v23_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  682. {
  683. unsigned long long result_1, result_2, result_3;
  684. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  685. - (pSmart->GRAY.TABLE[index[V23_INDEX]].R_Gray);
  686. result_2 = result_1 * v23_denominator;
  687. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  688. - (pSmart->GRAY.TABLE[index[V35_INDEX]].R_Gray);
  689. do_div(result_2, result_3);
  690. str[21] = (result_2 - v23_coefficient) & 0xff;
  691. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  692. - (pSmart->GRAY.TABLE[index[V23_INDEX]].G_Gray);
  693. result_2 = result_1 * v23_denominator;
  694. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  695. - (pSmart->GRAY.TABLE[index[V35_INDEX]].G_Gray);
  696. do_div(result_2, result_3);
  697. str[22] = (result_2 - v23_coefficient) & 0xff;
  698. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  699. - (pSmart->GRAY.TABLE[index[V23_INDEX]].B_Gray);
  700. result_2 = result_1 * v23_denominator;
  701. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  702. - (pSmart->GRAY.TABLE[index[V35_INDEX]].B_Gray);
  703. do_div(result_2, result_3);
  704. str[23] = (result_2 - v23_coefficient) & 0xff;
  705. }
  706. #define v11_coefficient 64
  707. #define v11_denominator 320
  708. static int v11_adjustment(struct SMART_DIM *pSmart)
  709. {
  710. unsigned long long result_1, result_2, result_3, result_4;
  711. int add_mtp;
  712. int LSB;
  713. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11);
  714. add_mtp = LSB + V11_300CD_R;
  715. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  716. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_23);
  717. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  718. do_div(result_2, v11_denominator);
  719. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  720. result_4 = (pSmart->GRAY.VT_TABLE.R_Gray) - result_3;
  721. pSmart->RGB_OUTPUT.R_VOLTAGE.level_11 = result_4;
  722. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11);
  723. add_mtp = LSB + V11_300CD_G;
  724. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  725. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_23);
  726. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  727. do_div(result_2, v11_denominator);
  728. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  729. result_4 = (pSmart->GRAY.VT_TABLE.G_Gray) - result_3;
  730. pSmart->RGB_OUTPUT.G_VOLTAGE.level_11 = result_4;
  731. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11);
  732. add_mtp = LSB + V11_300CD_B;
  733. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  734. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_23);
  735. result_2 = (v11_coefficient + add_mtp) << BIT_SHIFT;
  736. do_div(result_2, v11_denominator);
  737. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  738. result_4 = (pSmart->GRAY.VT_TABLE.B_Gray) - result_3;
  739. pSmart->RGB_OUTPUT.B_VOLTAGE.level_11 = result_4;
  740. #ifdef SMART_DIMMING_DEBUG
  741. pr_info("%s V11 RED:%d GREEN:%d BLUE:%d\n", __func__,
  742. pSmart->RGB_OUTPUT.R_VOLTAGE.level_11,
  743. pSmart->RGB_OUTPUT.G_VOLTAGE.level_11,
  744. pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
  745. #endif
  746. return 0;
  747. }
  748. static void v11_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  749. {
  750. unsigned long long result_1, result_2, result_3;
  751. result_1 = (pSmart->GRAY.VT_TABLE.R_Gray)
  752. - (pSmart->GRAY.TABLE[index[V11_INDEX]].R_Gray);
  753. result_2 = result_1 * v11_denominator;
  754. result_3 = (pSmart->GRAY.VT_TABLE.R_Gray)
  755. - (pSmart->GRAY.TABLE[index[V23_INDEX]].R_Gray);
  756. do_div(result_2, result_3);
  757. str[24] = (result_2 - v11_coefficient) & 0xff;
  758. result_1 = (pSmart->GRAY.VT_TABLE.G_Gray)
  759. - (pSmart->GRAY.TABLE[index[V11_INDEX]].G_Gray);
  760. result_2 = result_1 * v11_denominator;
  761. result_3 = (pSmart->GRAY.VT_TABLE.G_Gray)
  762. - (pSmart->GRAY.TABLE[index[V23_INDEX]].G_Gray);
  763. do_div(result_2, result_3);
  764. str[25] = (result_2 - v11_coefficient) & 0xff;
  765. result_1 = (pSmart->GRAY.VT_TABLE.B_Gray)
  766. - (pSmart->GRAY.TABLE[index[V11_INDEX]].B_Gray);
  767. result_2 = result_1 * v11_denominator;
  768. result_3 = (pSmart->GRAY.VT_TABLE.B_Gray)
  769. - (pSmart->GRAY.TABLE[index[V23_INDEX]].B_Gray);
  770. do_div(result_2, result_3);
  771. str[26] = (result_2 - v11_coefficient) & 0xff;
  772. }
  773. #define v3_coefficient 64
  774. #define v3_denominator 320
  775. static int v3_adjustment(struct SMART_DIM *pSmart)
  776. {
  777. unsigned long long result_1, result_2, result_3, result_4;
  778. int add_mtp;
  779. int LSB;
  780. LSB = char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3);
  781. add_mtp = LSB + V3_300CD_R;
  782. result_1 = (S6E3HA1_VREG0_REF)
  783. - (pSmart->RGB_OUTPUT.R_VOLTAGE.level_11);
  784. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  785. do_div(result_2, v3_denominator);
  786. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  787. result_4 = (S6E3HA1_VREG0_REF) - result_3;
  788. pSmart->RGB_OUTPUT.R_VOLTAGE.level_3 = result_4;
  789. LSB = char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3);
  790. add_mtp = LSB + V3_300CD_G;
  791. result_1 = (S6E3HA1_VREG0_REF)
  792. - (pSmart->RGB_OUTPUT.G_VOLTAGE.level_11);
  793. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  794. do_div(result_2, v3_denominator);
  795. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  796. result_4 = (S6E3HA1_VREG0_REF) - result_3;
  797. pSmart->RGB_OUTPUT.G_VOLTAGE.level_3 = result_4;
  798. LSB = char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3);
  799. add_mtp = LSB + V3_300CD_B;
  800. result_1 = (S6E3HA1_VREG0_REF)
  801. - (pSmart->RGB_OUTPUT.B_VOLTAGE.level_11);
  802. result_2 = (v3_coefficient + add_mtp) << BIT_SHIFT;
  803. do_div(result_2, v3_denominator);
  804. result_3 = (result_1 * result_2) >> BIT_SHIFT;
  805. result_4 = (S6E3HA1_VREG0_REF) - result_3;
  806. pSmart->RGB_OUTPUT.B_VOLTAGE.level_3 = result_4;
  807. #ifdef SMART_DIMMING_DEBUG
  808. pr_info("%s V3 RED:%d GREEN:%d BLUE:%d\n", __func__,
  809. pSmart->RGB_OUTPUT.R_VOLTAGE.level_3,
  810. pSmart->RGB_OUTPUT.G_VOLTAGE.level_3,
  811. pSmart->RGB_OUTPUT.B_VOLTAGE.level_3);
  812. #endif
  813. return 0;
  814. }
  815. static void v3_hexa(int *index, struct SMART_DIM *pSmart, char *str)
  816. {
  817. unsigned long long result_1, result_2, result_3;
  818. result_1 = (S6E3HA1_VREG0_REF)
  819. - (pSmart->GRAY.TABLE[index[V3_INDEX]].R_Gray);
  820. result_2 = result_1 * v3_denominator;
  821. result_3 = (S6E3HA1_VREG0_REF)
  822. - (pSmart->GRAY.TABLE[index[V11_INDEX]].R_Gray);
  823. do_div(result_2, result_3);
  824. str[27] = (result_2 - v3_coefficient) & 0xff;
  825. result_1 = (S6E3HA1_VREG0_REF)
  826. - (pSmart->GRAY.TABLE[index[V3_INDEX]].G_Gray);
  827. result_2 = result_1 * v3_denominator;
  828. result_3 = (S6E3HA1_VREG0_REF)
  829. - (pSmart->GRAY.TABLE[index[V11_INDEX]].G_Gray);
  830. do_div(result_2, result_3);
  831. str[28] = (result_2 - v3_coefficient) & 0xff;
  832. result_1 = (S6E3HA1_VREG0_REF)
  833. - (pSmart->GRAY.TABLE[index[V3_INDEX]].B_Gray);
  834. result_2 = result_1 * v3_denominator;
  835. result_3 = (S6E3HA1_VREG0_REF)
  836. - (pSmart->GRAY.TABLE[index[V11_INDEX]].B_Gray);
  837. do_div(result_2, result_3);
  838. str[29] = (result_2 - v3_coefficient) & 0xff;
  839. }
  840. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  841. static int S6E3HA1_ARRAY[S6E3HA1_MAX] = {0, 1, 3, 11, 23, 35, 51, 87, 151, 203, 255};
  842. #define V0toV3_Coefficient 2
  843. #define V0toV3_Multiple 1
  844. #define V0toV3_denominator 3
  845. #define V3toV11_Coefficient 7
  846. #define V3toV11_Multiple 1
  847. #define V3toV11_denominator 8
  848. #define V11toV23_Coefficient 11
  849. #define V11toV23_Multiple 1
  850. #define V11toV23_denominator 12
  851. #define V23toV35_Coefficient 11
  852. #define V23toV35_Multiple 1
  853. #define V23toV35_denominator 12
  854. #define V35toV51_Coefficient 15
  855. #define V35toV51_Multiple 1
  856. #define V35toV51_denominator 16
  857. #define V51toV87_Coefficient 35
  858. #define V51toV87_Multiple 1
  859. #define V51toV87_denominator 36
  860. #define V87toV151_Coefficient 63
  861. #define V87toV151_Multiple 1
  862. #define V87toV151_denominator 64
  863. #define V151toV203_Coefficient 51
  864. #define V151toV203_Multiple 1
  865. #define V151toV203_denominator 52
  866. #define V203toV255_Coefficient 51
  867. #define V203toV255_Multiple 1
  868. #define V203toV255_denominator 52
  869. static int cal_gray_scale_linear(int up, int low, int coeff,
  870. int mul, int deno, int cnt)
  871. {
  872. unsigned long long result_1, result_2, result_3, result_4;
  873. result_1 = up - low;
  874. result_2 = (result_1 * (coeff - (cnt * mul))) << BIT_SHIFT;
  875. do_div(result_2, deno);
  876. result_3 = result_2 >> BIT_SHIFT;
  877. result_4 = low + result_3;
  878. return (int)result_4;
  879. }
  880. static int generate_gray_scale(struct SMART_DIM *pSmart)
  881. {
  882. int cnt = 0, cal_cnt = 0;
  883. int array_index = 0;
  884. struct GRAY_VOLTAGE *ptable = (struct GRAY_VOLTAGE *)
  885. (&(pSmart->GRAY.TABLE));
  886. for (cnt = 0; cnt < S6E3HA1_MAX; cnt++) {
  887. pSmart->GRAY.TABLE[S6E3HA1_ARRAY[cnt]].R_Gray =
  888. ((int *)&(pSmart->RGB_OUTPUT.R_VOLTAGE))[cnt];
  889. pSmart->GRAY.TABLE[S6E3HA1_ARRAY[cnt]].G_Gray =
  890. ((int *)&(pSmart->RGB_OUTPUT.G_VOLTAGE))[cnt];
  891. pSmart->GRAY.TABLE[S6E3HA1_ARRAY[cnt]].B_Gray =
  892. ((int *)&(pSmart->RGB_OUTPUT.B_VOLTAGE))[cnt];
  893. }
  894. /*
  895. below codes use hard coded value.
  896. So it is possible to modify on each model.
  897. V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255
  898. */
  899. for (cnt = 0; cnt < S6E3HA1_GRAY_SCALE_MAX; cnt++) {
  900. if (cnt == S6E3HA1_ARRAY[0]) {
  901. /* 0 */
  902. array_index = 0;
  903. cal_cnt = 0;
  904. } else if ((cnt > S6E3HA1_ARRAY[0]) &&
  905. (cnt < S6E3HA1_ARRAY[2])) {
  906. /* 1 ~ 2 */
  907. array_index = 2;
  908. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  909. ptable[S6E3HA1_ARRAY[array_index-2]].R_Gray,
  910. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  911. V0toV3_Coefficient, V0toV3_Multiple,
  912. V0toV3_denominator, cal_cnt);
  913. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  914. ptable[S6E3HA1_ARRAY[array_index-2]].G_Gray,
  915. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  916. V0toV3_Coefficient, V0toV3_Multiple,
  917. V0toV3_denominator, cal_cnt);
  918. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  919. ptable[S6E3HA1_ARRAY[array_index-2]].B_Gray,
  920. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  921. V0toV3_Coefficient, V0toV3_Multiple,
  922. V0toV3_denominator , cal_cnt);
  923. cal_cnt++;
  924. } else if (cnt == S6E3HA1_ARRAY[2]) {
  925. /* 3 */
  926. cal_cnt = 0;
  927. } else if ((cnt > S6E3HA1_ARRAY[2]) &&
  928. (cnt < S6E3HA1_ARRAY[3])) {
  929. /* 4 ~ 10 */
  930. array_index = 3;
  931. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  932. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  933. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  934. V3toV11_Coefficient, V3toV11_Multiple,
  935. V3toV11_denominator, cal_cnt);
  936. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  937. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  938. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  939. V3toV11_Coefficient, V3toV11_Multiple,
  940. V3toV11_denominator, cal_cnt);
  941. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  942. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  943. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  944. V3toV11_Coefficient, V3toV11_Multiple,
  945. V3toV11_denominator , cal_cnt);
  946. cal_cnt++;
  947. } else if (cnt == S6E3HA1_ARRAY[3]) {
  948. /* 11 */
  949. cal_cnt = 0;
  950. } else if ((cnt > S6E3HA1_ARRAY[3]) &&
  951. (cnt < S6E3HA1_ARRAY[4])) {
  952. /* 12 ~ 22 */
  953. array_index = 4;
  954. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  955. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  956. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  957. V11toV23_Coefficient, V11toV23_Multiple,
  958. V11toV23_denominator, cal_cnt);
  959. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  960. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  961. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  962. V11toV23_Coefficient, V11toV23_Multiple,
  963. V11toV23_denominator, cal_cnt);
  964. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  965. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  966. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  967. V11toV23_Coefficient, V11toV23_Multiple,
  968. V11toV23_denominator , cal_cnt);
  969. cal_cnt++;
  970. } else if (cnt == S6E3HA1_ARRAY[4]) {
  971. /* 23 */
  972. cal_cnt = 0;
  973. } else if ((cnt > S6E3HA1_ARRAY[4]) &&
  974. (cnt < S6E3HA1_ARRAY[5])) {
  975. /* 24 ~ 34 */
  976. array_index = 5;
  977. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  978. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  979. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  980. V23toV35_Coefficient, V23toV35_Multiple,
  981. V23toV35_denominator, cal_cnt);
  982. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  983. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  984. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  985. V23toV35_Coefficient, V23toV35_Multiple,
  986. V23toV35_denominator, cal_cnt);
  987. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  988. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  989. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  990. V23toV35_Coefficient, V23toV35_Multiple,
  991. V23toV35_denominator , cal_cnt);
  992. cal_cnt++;
  993. } else if (cnt == S6E3HA1_ARRAY[5]) {
  994. /* 35 */
  995. cal_cnt = 0;
  996. } else if ((cnt > S6E3HA1_ARRAY[5]) &&
  997. (cnt < S6E3HA1_ARRAY[6])) {
  998. /* 36 ~ 50 */
  999. array_index = 6;
  1000. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1001. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  1002. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  1003. V35toV51_Coefficient, V35toV51_Multiple,
  1004. V35toV51_denominator, cal_cnt);
  1005. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1006. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  1007. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  1008. V35toV51_Coefficient, V35toV51_Multiple,
  1009. V35toV51_denominator, cal_cnt);
  1010. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1011. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  1012. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  1013. V35toV51_Coefficient, V35toV51_Multiple,
  1014. V35toV51_denominator, cal_cnt);
  1015. cal_cnt++;
  1016. } else if (cnt == S6E3HA1_ARRAY[6]) {
  1017. /* 51 */
  1018. cal_cnt = 0;
  1019. } else if ((cnt > S6E3HA1_ARRAY[6]) &&
  1020. (cnt < S6E3HA1_ARRAY[7])) {
  1021. /* 52 ~ 86 */
  1022. array_index = 7;
  1023. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1024. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  1025. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  1026. V51toV87_Coefficient, V51toV87_Multiple,
  1027. V51toV87_denominator, cal_cnt);
  1028. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1029. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  1030. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  1031. V51toV87_Coefficient, V51toV87_Multiple,
  1032. V51toV87_denominator, cal_cnt);
  1033. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1034. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  1035. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  1036. V51toV87_Coefficient, V51toV87_Multiple,
  1037. V51toV87_denominator, cal_cnt);
  1038. cal_cnt++;
  1039. } else if (cnt == S6E3HA1_ARRAY[7]) {
  1040. /* 87 */
  1041. cal_cnt = 0;
  1042. } else if ((cnt > S6E3HA1_ARRAY[7]) &&
  1043. (cnt < S6E3HA1_ARRAY[8])) {
  1044. /* 88 ~ 150 */
  1045. array_index = 8;
  1046. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1047. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  1048. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  1049. V87toV151_Coefficient, V87toV151_Multiple,
  1050. V87toV151_denominator, cal_cnt);
  1051. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1052. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  1053. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  1054. V87toV151_Coefficient, V87toV151_Multiple,
  1055. V87toV151_denominator, cal_cnt);
  1056. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1057. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  1058. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  1059. V87toV151_Coefficient, V87toV151_Multiple,
  1060. V87toV151_denominator, cal_cnt);
  1061. cal_cnt++;
  1062. } else if (cnt == S6E3HA1_ARRAY[8]) {
  1063. /* 151 */
  1064. cal_cnt = 0;
  1065. } else if ((cnt > S6E3HA1_ARRAY[8]) &&
  1066. (cnt < S6E3HA1_ARRAY[9])) {
  1067. /* 152 ~ 202 */
  1068. array_index = 9;
  1069. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1070. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  1071. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  1072. V151toV203_Coefficient, V151toV203_Multiple,
  1073. V151toV203_denominator, cal_cnt);
  1074. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1075. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  1076. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  1077. V151toV203_Coefficient, V151toV203_Multiple,
  1078. V151toV203_denominator, cal_cnt);
  1079. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1080. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  1081. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  1082. V151toV203_Coefficient, V151toV203_Multiple,
  1083. V151toV203_denominator, cal_cnt);
  1084. cal_cnt++;
  1085. } else if (cnt == S6E3HA1_ARRAY[9]) {
  1086. /* 203 */
  1087. cal_cnt = 0;
  1088. } else if ((cnt > S6E3HA1_ARRAY[9]) &&
  1089. (cnt < S6E3HA1_ARRAY[10])) {
  1090. /* 204 ~ 254 */
  1091. array_index = 10;
  1092. pSmart->GRAY.TABLE[cnt].R_Gray = cal_gray_scale_linear(
  1093. ptable[S6E3HA1_ARRAY[array_index-1]].R_Gray,
  1094. ptable[S6E3HA1_ARRAY[array_index]].R_Gray,
  1095. V203toV255_Coefficient, V203toV255_Multiple,
  1096. V203toV255_denominator, cal_cnt);
  1097. pSmart->GRAY.TABLE[cnt].G_Gray = cal_gray_scale_linear(
  1098. ptable[S6E3HA1_ARRAY[array_index-1]].G_Gray,
  1099. ptable[S6E3HA1_ARRAY[array_index]].G_Gray,
  1100. V203toV255_Coefficient, V203toV255_Multiple,
  1101. V203toV255_denominator, cal_cnt);
  1102. pSmart->GRAY.TABLE[cnt].B_Gray = cal_gray_scale_linear(
  1103. ptable[S6E3HA1_ARRAY[array_index-1]].B_Gray,
  1104. ptable[S6E3HA1_ARRAY[array_index]].B_Gray,
  1105. V203toV255_Coefficient, V203toV255_Multiple,
  1106. V203toV255_denominator, cal_cnt);
  1107. cal_cnt++;
  1108. } else {
  1109. if (cnt == S6E3HA1_ARRAY[10]) {
  1110. pr_info("%s end\n", __func__);
  1111. } else {
  1112. pr_err("%s fail cnt:%d\n", __func__, cnt);
  1113. return -EINVAL;
  1114. }
  1115. }
  1116. }
  1117. #ifdef SMART_DIMMING_DEBUG
  1118. for (cnt = 0; cnt < S6E3HA1_GRAY_SCALE_MAX; cnt++) {
  1119. pr_info("%s %8d %8d %8d %d\n", __func__,
  1120. pSmart->GRAY.TABLE[cnt].R_Gray,
  1121. pSmart->GRAY.TABLE[cnt].G_Gray,
  1122. pSmart->GRAY.TABLE[cnt].B_Gray, cnt);
  1123. }
  1124. #endif
  1125. return 0;
  1126. }
  1127. char offset_cal(int offset, char value)
  1128. {
  1129. unsigned char real_value;
  1130. if (value < 0 )
  1131. real_value = value * -1;
  1132. else
  1133. real_value = value;
  1134. if (real_value - offset < 0)
  1135. return 0;
  1136. else if (real_value - offset > 255)
  1137. return 0xFF;
  1138. else
  1139. return real_value - offset;
  1140. }
  1141. static void mtp_offset_substraction(struct SMART_DIM *pSmart, char *str)
  1142. {
  1143. int level_255_temp = 0;
  1144. int level_255_temp_MSB = 0;
  1145. int MTP_V255;
  1146. /*subtration MTP_OFFSET value from generated gamma table*/
  1147. level_255_temp = (str[0] << 8) | str[1] ;
  1148. MTP_V255 = char_to_int_v255(pSmart->MTP.R_OFFSET.OFFSET_255_MSB,
  1149. pSmart->MTP.R_OFFSET.OFFSET_255_LSB);
  1150. level_255_temp -= MTP_V255;
  1151. level_255_temp_MSB = level_255_temp / 256;
  1152. str[0] = level_255_temp_MSB & 0xff;
  1153. str[1] = level_255_temp & 0xff;
  1154. level_255_temp = (str[2] << 8) | str[3] ;
  1155. MTP_V255 = char_to_int_v255(pSmart->MTP.G_OFFSET.OFFSET_255_MSB,
  1156. pSmart->MTP.G_OFFSET.OFFSET_255_LSB);
  1157. level_255_temp -= MTP_V255;
  1158. level_255_temp_MSB = level_255_temp / 256;
  1159. str[2] = level_255_temp_MSB & 0xff;
  1160. str[3] = level_255_temp & 0xff;
  1161. level_255_temp = (str[4] << 8) | str[5] ;
  1162. MTP_V255 = char_to_int_v255(pSmart->MTP.B_OFFSET.OFFSET_255_MSB,
  1163. pSmart->MTP.B_OFFSET.OFFSET_255_LSB);
  1164. level_255_temp -= MTP_V255;
  1165. level_255_temp_MSB = level_255_temp / 256;
  1166. str[4] = level_255_temp_MSB & 0xff;
  1167. str[5] = level_255_temp & 0xff;
  1168. str[6] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_203), str[6]);
  1169. str[7] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_203), str[7]);
  1170. str[8] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_203), str[8]);
  1171. str[9] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_151), str[9]);
  1172. str[10] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_151), str[10]);
  1173. str[11] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_151), str[11]);
  1174. str[12] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_87), str[12]);
  1175. str[13] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_87), str[13]);
  1176. str[14] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_87), str[14]);
  1177. str[15] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_51), str[15]);
  1178. str[16] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_51), str[16]);
  1179. str[17] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_51), str[17]);
  1180. str[18] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_35), str[18]);
  1181. str[19] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_35), str[19]);
  1182. str[20] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_35), str[20]);
  1183. str[21] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_23), str[21]);
  1184. str[22] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_23), str[22]);
  1185. str[23] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_23), str[23]);
  1186. str[24] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_11), str[24]);
  1187. str[25] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_11), str[25]);
  1188. str[26] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_11), str[26]);
  1189. str[27] = offset_cal(char_to_int(pSmart->MTP.R_OFFSET.OFFSET_3), str[27]);
  1190. str[28] = offset_cal(char_to_int(pSmart->MTP.G_OFFSET.OFFSET_3), str[28]);
  1191. str[29] = offset_cal(char_to_int(pSmart->MTP.B_OFFSET.OFFSET_3), str[29]);
  1192. }
  1193. static int searching_function(long long candela, int *index, int gamma_curve)
  1194. {
  1195. long long delta_1 = 0, delta_2 = 0;
  1196. int cnt;
  1197. /*
  1198. * This searching_functin should be changed with improved
  1199. searcing algorithm to reduce searching time.
  1200. */
  1201. *index = -1;
  1202. for (cnt = 0; cnt < (S6E3HA1_GRAY_SCALE_MAX-1); cnt++) {
  1203. if (gamma_curve == GAMMA_CURVE_1P9) {
  1204. delta_1 = candela - curve_1p9[cnt];
  1205. delta_2 = candela - curve_1p9[cnt+1];
  1206. } else {
  1207. delta_1 = candela - curve_2p2[cnt];
  1208. delta_2 = candela - curve_2p2[cnt+1];
  1209. }
  1210. if (delta_2 < 0) {
  1211. *index = (delta_1 + delta_2) <= 0 ? cnt : cnt+1;
  1212. break;
  1213. }
  1214. if (delta_1 == 0) {
  1215. *index = cnt;
  1216. break;
  1217. }
  1218. if (delta_2 == 0) {
  1219. *index = cnt+1;
  1220. break;
  1221. }
  1222. }
  1223. if (*index == -1)
  1224. return -EINVAL;
  1225. else
  1226. return 0;
  1227. }
  1228. /* -1 means V1 */
  1229. #define S6E3HA1_TABLE_MAX (S6E3HA1_MAX-1)
  1230. static void(*Make_hexa[S6E3HA1_TABLE_MAX])(int*, struct SMART_DIM*, char*) = {
  1231. v255_hexa,
  1232. v203_hexa,
  1233. v151_hexa,
  1234. v87_hexa,
  1235. v51_hexa,
  1236. v35_hexa,
  1237. v23_hexa,
  1238. v11_hexa,
  1239. v3_hexa,
  1240. vt_hexa,
  1241. };
  1242. #if defined(AID_OPERATION)
  1243. /*
  1244. * Because of AID operation & display quality.
  1245. *
  1246. * only smart dimmg range : 300CD ~ 190CD
  1247. * AOR fix range : 170CD ~ 72CD AOR 40%
  1248. * AOR adjust range : 100CD ~ 10CD
  1249. */
  1250. #define AOR_FIX_CD 170
  1251. #define AOR_ADJUST_CD 72
  1252. #define CCG6_MAX_TABLE 59
  1253. static int ccg6_candela_table[][2] = {
  1254. {4, 0,},
  1255. {5, 1,},
  1256. {6, 2,},
  1257. {7, 3,},
  1258. {8, 4,},
  1259. {9, 5,},
  1260. {10, 6,},
  1261. {11, 7,},
  1262. {12, 8,},
  1263. {13, 9,},
  1264. {14, 10,},
  1265. {15, 11,},
  1266. {16, 12,},
  1267. {17, 13,},
  1268. {19, 14,},
  1269. {20, 15,},
  1270. {21, 16,},
  1271. {22, 17,},
  1272. {24, 18,},
  1273. {25, 19,},
  1274. {27, 20,},
  1275. {29, 21,},
  1276. {30, 22,},
  1277. {32, 23,},
  1278. {34, 24,},
  1279. {37, 25,},
  1280. {39, 26,},
  1281. {41, 27,},
  1282. {44, 28,},
  1283. {47, 29,},
  1284. {50, 30,},
  1285. {53, 31,},
  1286. {56, 32,},
  1287. {60, 33,},
  1288. {64, 34,},
  1289. {68, 35,},
  1290. {72, 36,},
  1291. {77, 37,},
  1292. {82, 38,},
  1293. {87, 39,},
  1294. {93, 40,},
  1295. {98, 41,},
  1296. {105, 42,},
  1297. {111, 43,},
  1298. {119, 44,},
  1299. {126, 45,},
  1300. {134, 46,},
  1301. {143, 47,},
  1302. {152, 48,},
  1303. {162, 49,},
  1304. {172, 50,},
  1305. {183, 51,},
  1306. {195, 52,},
  1307. {207, 53,},
  1308. {220, 54,},
  1309. {234, 55,},
  1310. {249, 56,},
  1311. {265, 57,},
  1312. {282, 58,},
  1313. {300, 59,},
  1314. };
  1315. static int find_cadela_table(int brightness)
  1316. {
  1317. int loop;
  1318. int err = -1;
  1319. for(loop = 0; loop <= CCG6_MAX_TABLE; loop++)
  1320. if (ccg6_candela_table[loop][0] == brightness)
  1321. return ccg6_candela_table[loop][1];
  1322. return err;
  1323. }
  1324. #define RGB_COMPENSATION 24
  1325. static int gradation_offset_revA[][9] = {
  1326. /* V255 V203 V151 V87 V51 V35 V23 V11 V3 */
  1327. {0, 10, 19, 28, 37, 42, 44, 46, 46},
  1328. {0, 8, 16, 24, 32, 36, 38, 41, 42},
  1329. {0, 8, 15, 22, 29, 33, 35, 38, 36},
  1330. {0, 6, 13, 20, 26, 29, 32, 36, 36},
  1331. {0, 6, 13, 19, 24, 28, 30, 33, 35},
  1332. {0, 6, 12, 17, 22, 26, 28, 31, 32},
  1333. {0, 6, 11, 16, 20, 24, 26, 29, 33},
  1334. {0, 6, 11, 15, 19, 22, 25, 28, 32},
  1335. {0, 5, 10, 14, 17, 21, 23, 26, 28},
  1336. {0, 5, 10, 13, 16, 20, 22, 25, 27},
  1337. {0, 5, 9, 12, 15, 19, 21, 24, 26},
  1338. {0, 5, 9, 12, 14, 18, 19, 23, 25},
  1339. {0, 5, 8, 12, 14, 17, 18, 22, 25},
  1340. {0, 5, 8, 11, 13, 16, 18, 21, 23},
  1341. {0, 4, 8, 10, 12, 14, 16, 19, 22},
  1342. {0, 4, 8, 10, 11, 14, 16, 19, 21},
  1343. {0, 4, 7, 9, 11, 13, 15, 18, 20},
  1344. {0, 4, 7, 9, 11, 13, 15, 17, 19},
  1345. {0, 4, 7, 9, 10, 12, 14, 17, 19},
  1346. {0, 4, 7, 8, 9, 11, 13, 16, 18},
  1347. {0, 4, 7, 8, 9, 10, 12, 15, 17},
  1348. {0, 4, 6, 7, 8, 10, 11, 14, 16},
  1349. {0, 4, 6, 7, 8, 10, 11, 14, 15},
  1350. {0, 4, 6, 7, 7, 9, 10, 13, 14},
  1351. {0, 4, 6, 7, 7, 8, 9, 12, 13},
  1352. {0, 4, 6, 7, 6, 8, 8, 11, 12},
  1353. {0, 4, 6, 6, 6, 7, 8, 11, 12},
  1354. {0, 3, 5, 6, 5, 7, 7, 10, 11},
  1355. {0, 3, 4, 5, 4, 6, 6, 8, 10},
  1356. {0, 3, 5, 5, 5, 6, 6, 9, 10},
  1357. {0, 3, 4, 5, 5, 6, 6, 8, 9},
  1358. {0, 3, 4, 5, 4, 5, 5, 8, 8},
  1359. {0, 3, 4, 4, 4, 5, 5, 7, 7},
  1360. {0, 3, 4, 4, 3, 5, 4, 6, 6},
  1361. {0, 3, 3, 4, 3, 4, 4, 6, 6},
  1362. {0, 2, 4, 4, 3, 4, 3, 5, 6},
  1363. {0, 2, 4, 3, 2, 4, 3, 5, 5},
  1364. {0, 2, 3, 3, 2, 3, 3, 5, 5},
  1365. {0, 1, 3, 3, 2, 3, 4, 5, 6},
  1366. {0, 2, 3, 4, 3, 2, 3, 5, 5},
  1367. {0, 2, 4, 4, 3, 3, 4, 5, 6},
  1368. {0, 1, 4, 4, 3, 3, 3, 4, 6},
  1369. {0, 2, 4, 4, 3, 2, 3, 5, 6},
  1370. {0, 1, 4, 3, 3, 3, 3, 5, 6},
  1371. {0, 2, 5, 4, 3, 3, 3, 5, 6},
  1372. {0, 3, 5, 4, 3, 3, 3, 4, 7},
  1373. {0, 3, 6, 5, 3, 2, 4, 4, 6},
  1374. {0, 4, 6, 4, 4, 3, 3, 5, 5},
  1375. {0, 3, 6, 4, 4, 3, 4, 5, 5},
  1376. {0, 4, 5, 5, 3, 3, 3, 4, 5},
  1377. {0, 3, 6, 3, 3, 3, 4, 4, 5},
  1378. {0, 3, 5, 3, 3, 2, 3, 4, 4},
  1379. {0, 2, 4, 2, 2, 2, 3, 3, 3},
  1380. {0, 2, 4, 2, 2, 1, 2, 2, 3},
  1381. {0, 1, 3, 1, 1, 1, 2, 2, 2},
  1382. {0, 1, 2, 0, 1, 0, 1, 1, 1},
  1383. {0, 0, 1, 0, 0, 0, 1, 1, 1},
  1384. {0, 0, 1, 0, 0, -1, 0, 0, 1},
  1385. {0, -1, 0, -1, -1, -1, -1, 0, 1},
  1386. {0, 0, 0, 0, 0, 0, 0, 0, 0},
  1387. };
  1388. static int rgb_offset_revA[][RGB_COMPENSATION] = {
  1389. /* R255 G255 B255 R203 G203 B203 R151 G151 B151
  1390. R87 G87 B87 R51 G51 B51 R35 G35 B35
  1391. R23 G23 B23 R11 G11 B11
  1392. */
  1393. {-4, 1, -4, -5, 0, -4, -5, 1, -7, -11, 5, -12, -16, 8, -16, -11, 6, -14, -6, 6, -13, -10, 7, -16},
  1394. {-3, 0, -4, -3, 0, -3, -5, 1, -5, -12, 4, -10, -16, 8, -16, -11, 6, -13, -10, 6, -16, -10, 7, -16},
  1395. {-2, 0, -3, -3, 0, -3, -4, 1, -4, -10, 4, -8, -16, 8, -16, -12, 6, -14, -10, 6, -15, -10, 7, -16},
  1396. {-1, 0, -2, -3, 1, -4, -4, 0, -3, -8, 4, -8, -17, 7, -15, -13, 8, -16, -11, 8, -14, -5, 7, -16},
  1397. {-1, 0, -2, -3, 0, -4, -4, 0, -3, -8, 4, -8, -15, 6, -14, -13, 7, -14, -11, 7, -16, -7, 9, -18},
  1398. {-1, 0, -1, -3, 0, -3, -2, 0, -3, -9, 4, -8, -16, 6, -14, -13, 7, -14, -13, 7, -14, -4, 10, -20},
  1399. {-1, 0, -1, -2, 0, -3, -2, 0, -2, -8, 3, -7, -13, 6, -13, -16, 7, -16, -12, 7, -16, -8, 9, -19},
  1400. {-1, 0, -1, -3, 0, -3, 0, 0, -1, -9, 3, -8, -13, 5, -12, -14, 7, -16, -13, 7, -14, -9, 9, -20},
  1401. {0, 0, 0, -1, 0, -2, -3, 0, -3, -7, 3, -6, -11, 5, -12, -14, 7, -14, -14, 7, -15, -8, 11, -23},
  1402. {0, 0, 0, -2, 0, -2, -3, 1, -4, -7, 2, -6, -12, 6, -12, -13, 6, -12, -11, 6, -14, -13, 11, -24},
  1403. {0, 0, 0, -1, 0, -2, -3, 1, -4, -6, 1, -4, -13, 5, -12, -13, 7, -14, -14, 7, -13, -9, 12, -24},
  1404. {0, 0, 0, -1, 0, -1, -3, 0, -4, -5, 2, -4, -13, 5, -12, -11, 6, -12, -15, 6, -16, -8, 11, -22},
  1405. {0, 0, 0, 0, 0, -1, -3, 0, -4, -7, 2, -4, -11, 5, -11, -12, 6, -12, -17, 6, -17, -8, 11, -24},
  1406. {0, 0, 0, -1, 0, -1, -2, 0, -3, -6, 2, -5, -11, 4, -10, -14, 6, -14, -14, 6, -15, -12, 13, -28},
  1407. {0, 0, 0, 0, 0, -1, -2, 0, -3, -4, 2, -4, -8, 4, -9, -13, 6, -12, -16, 6, -17, -12, 13, -28},
  1408. {0, 0, 0, 0, 0, -1, -2, 0, -2, -4, 2, -4, -9, 4, -10, -13, 5, -11, -14, 5, -16, -13, 13, -27},
  1409. {0, 0, 0, 0, 0, -1, -2, 0, -3, -4, 1, -3, -9, 4, -10, -13, 5, -10, -14, 5, -18, -14, 14, -29},
  1410. {0, 0, 0, 0, 0, -1, -2, 0, -3, -4, 1, -3, -8, 4, -8, -11, 5, -10, -13, 5, -16, -16, 16, -33},
  1411. {0, 0, 0, 0, 0, 0, -1, 0, -2, -4, 1, -4, -8, 3, -8, -13, 4, -10, -11, 4, -17, -17, 13, -28},
  1412. {0, 0, 0, 0, 0, 0, -1, 0, -2, -4, 2, -4, -7, 2, -6, -13, 5, -12, -14, 5, -18, -13, 14, -28},
  1413. {0, 0, 0, 0, 0, 0, -1, 0, -1, -3, 2, -4, -7, 2, -6, -10, 5, -10, -14, 5, -18, -16, 12, -26},
  1414. {0, 0, 0, 0, 0, 0, 0, 0, -1, -3, 1, -3, -8, 3, -7, -8, 4, -8, -15, 4, -20, -16, 14, -28},
  1415. {0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 1, -3, -7, 2, -6, -11, 4, -10, -14, 4, -18, -15, 13, -28},
  1416. {0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 1, -3, -6, 2, -5, -10, 4, -10, -14, 4, -18, -15, 13, -27},
  1417. {0, 0, 0, 0, 0, 0, 0, 0, -1, -3, 1, -3, -5, 2, -4, -10, 4, -9, -14, 4, -19, -13, 14, -30},
  1418. {0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 1, -2, -5, 2, -4, -8, 4, -9, -14, 4, -18, -14, 15, -31},
  1419. {0, 0, 0, 0, 0, 0, 0, 0, -1, -3, 1, -2, -4, 2, -4, -8, 4, -8, -11, 4, -16, -14, 13, -28},
  1420. {0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 1, -2, -5, 1, -3, -6, 4, -9, -12, 4, -17, -13, 14, -29},
  1421. {0, 0, 1, 0, 0, 0, 0, 0, 0, -2, 0, -2, -5, 1, -3, -2, 3, -6, -13, 3, -13, -14, 15, -30},
  1422. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -4, 1, -3, -5, 4, -8, -10, 4, -14, -12, 14, -28},
  1423. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -4, 1, -3, -4, 3, -6, -10, 3, -14, -14, 16, -33},
  1424. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 1, -2, -3, 0, -2, -5, 4, -9, -8, 4, -14, -11, 12, -26},
  1425. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 1, -2, -2, 0, -1, -2, 3, -6, -8, 3, -14, -13, 15, -31},
  1426. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -3, 0, -2, -4, 2, -6, -5, 2, -13, -13, 16, -32},
  1427. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -1, 0, 0, -3, 3, -7, -5, 3, -12, -9, 14, -28},
  1428. {0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -2, 0, 0, -2, 3, -7, -5, 3, -12, -11, 14, -30},
  1429. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -3, 0, -2, -2, 2, -5, -3, 2, -12, -11, 13, -28},
  1430. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, 1, -3, 2, -6, -3, 2, -12, -9, 14, -28},
  1431. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, -3, 2, -6, -2, 2, -10, -8, 14, -28},
  1432. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 0, 0, -2, 2, -4, -2, 2, -11, -9, 14, -28},
  1433. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, -2, 1, -4, -3, 1, -9, -9, 14, -30},
  1434. {0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, 0, -2, 1, -4, -5, 1, -10, -8, 14, -30},
  1435. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -1, -2, 1, -4, -4, 1, -10, -5, 12, -25},
  1436. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -1, -2, 1, -3, -2, 1, -8, -8, 12, -26},
  1437. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -3, 1, -3, -2, 1, -8, -8, 13, -27},
  1438. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -1, 1, -2, -2, 1, -7, -5, 12, -26},
  1439. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 1, -2, -2, 0, -1, 0, 0, -6, -7, 12, -26},
  1440. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -3, 0, -2, -2, 0, -6, -4, 11, -22},
  1441. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 0, 0, 0, 0, -6, -5, 11, -22},
  1442. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, -2, 0, -2, -1, 0, -6, -4, 10, -22},
  1443. {1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, 0, 0, 0, -2, 0, -6, -5, 12, -24},
  1444. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, -1, -2, 0, -6, -1, 9, -20},
  1445. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, -4, 0, 10, -20},
  1446. {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -2, 0, 0, -4, 0, 10, -21},
  1447. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, -4, 3, 9, -19},
  1448. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, -5, 3, 8, -18},
  1449. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1450. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1451. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1452. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  1453. };
  1454. static void gamma_init_revA(
  1455. struct SMART_DIM *pSmart, char *str, int size)
  1456. {
  1457. long long candela_level[S6E3HA1_TABLE_MAX] = {-1, };
  1458. int bl_index[S6E3HA1_TABLE_MAX] = {-1, };
  1459. long long temp_cal_data = 0;
  1460. int bl_level;
  1461. int level_255_temp_MSB = 0;
  1462. int level_V255 = 0;
  1463. int point_index;
  1464. int cnt;
  1465. int table_index;
  1466. /*calculate candela level */
  1467. if (pSmart->brightness_level > AOR_FIX_CD) {
  1468. /* 300CD ~ 172CD */
  1469. if (pSmart->brightness_level <= 249)
  1470. bl_level = 253;
  1471. else if (pSmart->brightness_level == 282)
  1472. bl_level = 283;
  1473. else
  1474. bl_level = pSmart->brightness_level;
  1475. } else if ((pSmart->brightness_level <= AOR_FIX_CD) &&
  1476. (pSmart->brightness_level >= AOR_ADJUST_CD)) {
  1477. /* 162CD ~ 72CD */
  1478. if (pSmart->brightness_level == 72)
  1479. bl_level = 113;
  1480. else if (pSmart->brightness_level == 77)
  1481. bl_level = 120;
  1482. else if (pSmart->brightness_level == 82)
  1483. bl_level = 128;
  1484. else if (pSmart->brightness_level == 87)
  1485. bl_level = 136;
  1486. else if (pSmart->brightness_level == 93)
  1487. bl_level = 142;
  1488. else if (pSmart->brightness_level == 98)
  1489. bl_level = 152;
  1490. else if (pSmart->brightness_level == 105)
  1491. bl_level = 161;
  1492. else if (pSmart->brightness_level == 111)
  1493. bl_level = 170;
  1494. else if (pSmart->brightness_level == 119)
  1495. bl_level = 181;
  1496. else if (pSmart->brightness_level == 126)
  1497. bl_level = 189;
  1498. else if (pSmart->brightness_level == 134)
  1499. bl_level = 201;
  1500. else if (pSmart->brightness_level == 143)
  1501. bl_level = 212;
  1502. else if (pSmart->brightness_level == 152)
  1503. bl_level = 225;
  1504. else if (pSmart->brightness_level == 162)
  1505. bl_level = 240;
  1506. else
  1507. bl_level = 240;
  1508. } else {
  1509. /* 68CD ~ 2CD */
  1510. bl_level = 113;
  1511. }
  1512. if (pSmart->brightness_level < 300) {
  1513. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++) {
  1514. point_index = S6E3HA1_ARRAY[cnt+1];
  1515. temp_cal_data =
  1516. ((long long)(candela_coeff_2p15[point_index])) *
  1517. ((long long)(bl_level));
  1518. candela_level[cnt] = temp_cal_data;
  1519. }
  1520. } else {
  1521. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++) {
  1522. point_index = S6E3HA1_ARRAY[cnt+1];
  1523. temp_cal_data =
  1524. ((long long)(candela_coeff_2p2[point_index])) *
  1525. ((long long)(bl_level));
  1526. candela_level[cnt] = temp_cal_data;
  1527. }
  1528. }
  1529. #ifdef SMART_DIMMING_DEBUG
  1530. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  1531. candela_level[0], candela_level[1], candela_level[2]);
  1532. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  1533. candela_level[3], candela_level[4], candela_level[5]);
  1534. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  1535. candela_level[6], candela_level[7], candela_level[8]);
  1536. printk(KERN_INFO "candela_255:%llu brightness_level %d\n", candela_level[9], pSmart->brightness_level);
  1537. #endif
  1538. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++) {
  1539. if (searching_function(candela_level[cnt],
  1540. &(bl_index[cnt]), GAMMA_CURVE_2P15)) {
  1541. pr_info("%s searching functioin error cnt:%d\n",
  1542. __func__, cnt);
  1543. }
  1544. }
  1545. /*
  1546. * Candela compensation
  1547. */
  1548. for (cnt = 1; cnt < S6E3HA1_TABLE_MAX; cnt++) {
  1549. table_index = find_cadela_table(pSmart->brightness_level);
  1550. if (table_index == -1) {
  1551. table_index = CCG6_MAX_TABLE;
  1552. pr_info("%s fail candela table_index cnt : %d brightness %d",
  1553. __func__, cnt, pSmart->brightness_level);
  1554. }
  1555. bl_index[S6E3HA1_TABLE_MAX - cnt] +=
  1556. gradation_offset_revA[table_index][cnt - 1];
  1557. /* THERE IS M-GRAY0 target */
  1558. if (bl_index[S6E3HA1_TABLE_MAX - cnt] == 0)
  1559. bl_index[S6E3HA1_TABLE_MAX - cnt] = 1;
  1560. }
  1561. #ifdef SMART_DIMMING_DEBUG
  1562. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  1563. bl_index[0], bl_index[1], bl_index[2]);
  1564. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  1565. bl_index[3], bl_index[4], bl_index[5]);
  1566. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  1567. bl_index[6], bl_index[7], bl_index[8]);
  1568. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  1569. #endif
  1570. /*Generate Gamma table*/
  1571. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++)
  1572. (void)Make_hexa[cnt](bl_index , pSmart, str);
  1573. /*
  1574. * RGB compensation
  1575. */
  1576. for (cnt = 0; cnt < RGB_COMPENSATION; cnt++) {
  1577. table_index = find_cadela_table(pSmart->brightness_level);
  1578. if (table_index == -1) {
  1579. table_index = CCG6_MAX_TABLE;
  1580. pr_info("%s fail RGB table_index cnt : %d brightness %d",
  1581. __func__, cnt, pSmart->brightness_level);
  1582. }
  1583. if (cnt < 3) {
  1584. level_V255 = str[cnt * 2] << 8 | str[(cnt * 2) + 1];
  1585. level_V255 +=
  1586. rgb_offset_revA[table_index][cnt];
  1587. level_255_temp_MSB = level_V255 / 256;
  1588. str[cnt * 2] = level_255_temp_MSB & 0xff;
  1589. str[(cnt * 2) + 1] = level_V255 & 0xff;
  1590. } else {
  1591. str[cnt+3] += rgb_offset_revA[table_index][cnt];
  1592. }
  1593. }
  1594. /*subtration MTP_OFFSET value from generated gamma table*/
  1595. mtp_offset_substraction(pSmart, str);
  1596. }
  1597. #endif
  1598. static void pure_gamma_init(struct SMART_DIM *pSmart, char *str, int size)
  1599. {
  1600. long long candela_level[S6E3HA1_TABLE_MAX] = {-1, };
  1601. int bl_index[S6E3HA1_TABLE_MAX] = {-1, };
  1602. long long temp_cal_data = 0;
  1603. int bl_level, cnt;
  1604. int point_index;
  1605. bl_level = pSmart->brightness_level;
  1606. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++) {
  1607. point_index = S6E3HA1_ARRAY[cnt+1];
  1608. temp_cal_data =
  1609. ((long long)(candela_coeff_2p2[point_index])) *
  1610. ((long long)(bl_level));
  1611. candela_level[cnt] = temp_cal_data;
  1612. }
  1613. #ifdef SMART_DIMMING_DEBUG
  1614. printk(KERN_INFO "\n candela_1:%llu candela_3:%llu candela_11:%llu ",
  1615. candela_level[0], candela_level[1], candela_level[2]);
  1616. printk(KERN_INFO "candela_23:%llu candela_35:%llu candela_51:%llu ",
  1617. candela_level[3], candela_level[4], candela_level[5]);
  1618. printk(KERN_INFO "candela_87:%llu candela_151:%llu candela_203:%llu ",
  1619. candela_level[6], candela_level[7], candela_level[8]);
  1620. printk(KERN_INFO "candela_255:%llu\n", candela_level[9]);
  1621. #endif
  1622. /*calculate brightness level*/
  1623. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++) {
  1624. if (searching_function(candela_level[cnt],
  1625. &(bl_index[cnt]), GAMMA_CURVE_2P2)) {
  1626. pr_info("%s searching functioin error cnt:%d\n",
  1627. __func__, cnt);
  1628. }
  1629. }
  1630. /*
  1631. * 210CD ~ 190CD compensation
  1632. * V3 level + 1
  1633. */
  1634. if ((bl_level >= 190) && (bl_level <= 210))
  1635. bl_index[1] += 1;
  1636. #ifdef SMART_DIMMING_DEBUG
  1637. printk(KERN_INFO "\n bl_index_1:%d bl_index_3:%d bl_index_11:%d",
  1638. bl_index[0], bl_index[1], bl_index[2]);
  1639. printk(KERN_INFO "bl_index_23:%d bl_index_35:%d bl_index_51:%d",
  1640. bl_index[3], bl_index[4], bl_index[5]);
  1641. printk(KERN_INFO "bl_index_87:%d bl_index_151:%d bl_index_203:%d",
  1642. bl_index[5], bl_index[7], bl_index[8]);
  1643. printk(KERN_INFO "bl_index_255:%d\n", bl_index[9]);
  1644. #endif
  1645. /*Generate Gamma table*/
  1646. for (cnt = 0; cnt < S6E3HA1_TABLE_MAX; cnt++)
  1647. (void)Make_hexa[cnt](bl_index , pSmart, str);
  1648. mtp_offset_substraction(pSmart, str);
  1649. }
  1650. static void set_max_lux_table(void)
  1651. {
  1652. max_lux_table[0] = V255_300CD_R_MSB;
  1653. max_lux_table[1] = V255_300CD_R_LSB;
  1654. max_lux_table[2] = V255_300CD_G_MSB;
  1655. max_lux_table[3] = V255_300CD_G_LSB;
  1656. max_lux_table[4] = V255_300CD_B_MSB;
  1657. max_lux_table[5] = V255_300CD_B_LSB;
  1658. max_lux_table[6] = V203_300CD_R;
  1659. max_lux_table[7] = V203_300CD_G;
  1660. max_lux_table[8] = V203_300CD_B;
  1661. max_lux_table[9] = V151_300CD_R;
  1662. max_lux_table[10] = V151_300CD_G;
  1663. max_lux_table[11] = V151_300CD_B;
  1664. max_lux_table[12] = V87_300CD_R;
  1665. max_lux_table[13] = V87_300CD_G;
  1666. max_lux_table[14] = V87_300CD_B;
  1667. max_lux_table[15] = V51_300CD_R;
  1668. max_lux_table[16] = V51_300CD_G;
  1669. max_lux_table[17] = V51_300CD_B;
  1670. max_lux_table[18] = V35_300CD_R;
  1671. max_lux_table[19] = V35_300CD_G;
  1672. max_lux_table[20] = V35_300CD_B;
  1673. max_lux_table[21] = V23_300CD_R;
  1674. max_lux_table[22] = V23_300CD_G;
  1675. max_lux_table[23] = V23_300CD_B;
  1676. max_lux_table[24] = V11_300CD_R;
  1677. max_lux_table[25] = V11_300CD_G;
  1678. max_lux_table[26] = V11_300CD_B;
  1679. max_lux_table[27] = V3_300CD_R;
  1680. max_lux_table[28] = V3_300CD_G;
  1681. max_lux_table[29] = V3_300CD_B;
  1682. max_lux_table[30] = VT_300CD_R;
  1683. max_lux_table[31] = VT_300CD_G;
  1684. max_lux_table[32] = VT_300CD_B;
  1685. }
  1686. static void set_min_lux_table(struct SMART_DIM *psmart)
  1687. {
  1688. psmart->brightness_level = MIN_CANDELA;
  1689. pure_gamma_init(psmart, min_lux_table, GAMMA_SET_MAX);
  1690. }
  1691. static void get_min_lux_table(char *str, int size)
  1692. {
  1693. memcpy(str, min_lux_table, size);
  1694. }
  1695. static void generate_gamma(struct SMART_DIM *psmart, char *str, int size)
  1696. {
  1697. int lux_loop;
  1698. struct illuminance_table *ptable = (struct illuminance_table *)
  1699. (&(psmart->gen_table));
  1700. /* searching already generated gamma table */
  1701. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  1702. if (ptable[lux_loop].lux == psmart->brightness_level) {
  1703. memcpy(str, &(ptable[lux_loop].gamma_setting), size);
  1704. break;
  1705. }
  1706. }
  1707. /* searching fail... Setting 300CD value on gamma table */
  1708. if (lux_loop == psmart->lux_table_max) {
  1709. pr_info("%s searching fail lux : %d\n", __func__,
  1710. psmart->brightness_level);
  1711. memcpy(str, max_lux_table, size);
  1712. }
  1713. #ifdef SMART_DIMMING_DEBUG
  1714. if (lux_loop != psmart->lux_table_max)
  1715. pr_info("%s searching ok index : %d lux : %d", __func__,
  1716. lux_loop, ptable[lux_loop].lux);
  1717. #endif
  1718. }
  1719. static void gamma_cell_determine(int ldi_revision)
  1720. {
  1721. pr_info("%s ldi_revision: 0x%x", __func__, ldi_revision);
  1722. V255_300CD_R_MSB = V255_300CD_R_MSB_20;
  1723. V255_300CD_R_LSB = V255_300CD_R_LSB_20;
  1724. V255_300CD_G_MSB = V255_300CD_G_MSB_20;
  1725. V255_300CD_G_LSB = V255_300CD_G_LSB_20;
  1726. V255_300CD_B_MSB = V255_300CD_B_MSB_20;
  1727. V255_300CD_B_LSB = V255_300CD_B_LSB_20;
  1728. V203_300CD_R = V203_300CD_R_20;
  1729. V203_300CD_G = V203_300CD_G_20;
  1730. V203_300CD_B = V203_300CD_B_20;
  1731. V151_300CD_R = V151_300CD_R_20;
  1732. V151_300CD_G = V151_300CD_G_20;
  1733. V151_300CD_B = V151_300CD_B_20;
  1734. V87_300CD_R = V87_300CD_R_20;
  1735. V87_300CD_G = V87_300CD_G_20;
  1736. V87_300CD_B = V87_300CD_B_20;
  1737. V51_300CD_R = V51_300CD_R_20;
  1738. V51_300CD_G = V51_300CD_G_20;
  1739. V51_300CD_B = V51_300CD_B_20;
  1740. V35_300CD_R = V35_300CD_R_20;
  1741. V35_300CD_G = V35_300CD_G_20;
  1742. V35_300CD_B = V35_300CD_B_20;
  1743. V23_300CD_R = V23_300CD_R_20;
  1744. V23_300CD_G = V23_300CD_G_20;
  1745. V23_300CD_B = V23_300CD_B_20;
  1746. V11_300CD_R = V11_300CD_R_20;
  1747. V11_300CD_G = V11_300CD_G_20;
  1748. V11_300CD_B = V11_300CD_B_20;
  1749. V3_300CD_R = V3_300CD_R_20;
  1750. V3_300CD_G = V3_300CD_G_20;
  1751. V3_300CD_B = V3_300CD_B_20;
  1752. VT_300CD_R = VT_300CD_R_20;
  1753. VT_300CD_G = VT_300CD_G_20;
  1754. VT_300CD_B = VT_300CD_B_20;
  1755. }
  1756. static void mtp_sorting(struct SMART_DIM *psmart)
  1757. {
  1758. int sorting[GAMMA_SET_MAX] = {
  1759. 0, 1, 6, 9, 12, 15, 18, 21, 24, 27, 30, /* R*/
  1760. 2, 3, 7, 10, 13, 16, 19, 22, 25, 28, 31, /* G */
  1761. 4, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, /* B */
  1762. };
  1763. int loop;
  1764. char *pfrom, *pdest;
  1765. pfrom = (char *)&(psmart->MTP_ORIGN);
  1766. pdest = (char *)&(psmart->MTP);
  1767. for (loop = 0; loop < GAMMA_SET_MAX; loop++)
  1768. pdest[loop] = pfrom[sorting[loop]];
  1769. }
  1770. static int smart_dimming_init(struct SMART_DIM *psmart)
  1771. {
  1772. int lux_loop;
  1773. int id1, id2, id3;
  1774. #ifdef SMART_DIMMING_DEBUG
  1775. int cnt;
  1776. char pBuffer[256];
  1777. memset(pBuffer, 0x00, 256);
  1778. #endif
  1779. id1 = (psmart->ldi_revision & 0x00FF0000) >> 16;
  1780. id2 = (psmart->ldi_revision & 0x0000FF00) >> 8;
  1781. id3 = psmart->ldi_revision & 0xFF;
  1782. mtp_sorting(psmart);
  1783. gamma_cell_determine(psmart->ldi_revision);
  1784. set_max_lux_table();
  1785. #ifdef SMART_DIMMING_DEBUG
  1786. print_RGB_offset(psmart);
  1787. #endif
  1788. v255_adjustment(psmart);
  1789. vt_adjustment(psmart);
  1790. v203_adjustment(psmart);
  1791. v151_adjustment(psmart);
  1792. v87_adjustment(psmart);
  1793. v51_adjustment(psmart);
  1794. v35_adjustment(psmart);
  1795. v23_adjustment(psmart);
  1796. v11_adjustment(psmart);
  1797. v3_adjustment(psmart);
  1798. if (generate_gray_scale(psmart)) {
  1799. pr_info(KERN_ERR "lcd smart dimming fail generate_gray_scale\n");
  1800. return -EINVAL;
  1801. }
  1802. /*Generating lux_table*/
  1803. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  1804. /* To set brightness value */
  1805. psmart->brightness_level = psmart->plux_table[lux_loop];
  1806. /* To make lux table index*/
  1807. psmart->gen_table[lux_loop].lux = psmart->plux_table[lux_loop];
  1808. #if defined(AID_OPERATION)
  1809. gamma_init_revA(psmart,
  1810. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  1811. GAMMA_SET_MAX);
  1812. #else
  1813. pure_gamma_init(psmart,
  1814. (char *)(&(psmart->gen_table[lux_loop].gamma_setting)),
  1815. GAMMA_SET_MAX);
  1816. #endif
  1817. }
  1818. /* set 300CD max gamma table */
  1819. memcpy(&(psmart->gen_table[lux_loop-1].gamma_setting),
  1820. max_lux_table, GAMMA_SET_MAX);
  1821. set_min_lux_table(psmart);
  1822. #ifdef SMART_DIMMING_DEBUG
  1823. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  1824. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  1825. snprintf(pBuffer + strnlen(pBuffer, 256), 256, " %d",
  1826. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  1827. pr_info("lux : %d %s", psmart->plux_table[lux_loop], pBuffer);
  1828. memset(pBuffer, 0x00, 256);
  1829. }
  1830. for (lux_loop = 0; lux_loop < psmart->lux_table_max; lux_loop++) {
  1831. for (cnt = 0; cnt < GAMMA_SET_MAX; cnt++)
  1832. snprintf(pBuffer + strnlen(pBuffer, 256), 256,
  1833. " %02X",
  1834. psmart->gen_table[lux_loop].gamma_setting[cnt]);
  1835. pr_info("lux : %d %s", psmart->plux_table[lux_loop], pBuffer);
  1836. memset(pBuffer, 0x00, 256);
  1837. }
  1838. #endif
  1839. return 0;
  1840. }
  1841. /* ----------------------------------------------------------------------------
  1842. * Wrapper functions for smart dimming to work with 8974 generic code
  1843. * ----------------------------------------------------------------------------
  1844. */
  1845. static struct SMART_DIM smart_S6E3HA1;
  1846. static struct smartdim_conf __S6E3HA1__ ;
  1847. static void wrap_generate_gamma(int cd, char *cmd_str) {
  1848. smart_S6E3HA1.brightness_level = cd;
  1849. generate_gamma(&smart_S6E3HA1, cmd_str, GAMMA_SET_MAX);
  1850. }
  1851. static void wrap_smart_dimming_init(void) {
  1852. smart_S6E3HA1.plux_table = __S6E3HA1__.lux_tab;
  1853. smart_S6E3HA1.lux_table_max = __S6E3HA1__.lux_tabsize;
  1854. smart_S6E3HA1.ldi_revision = __S6E3HA1__.man_id;
  1855. smart_dimming_init(&smart_S6E3HA1);
  1856. }
  1857. struct smartdim_conf *smart_S6E3HA1_get_conf(void){
  1858. __S6E3HA1__.generate_gamma = wrap_generate_gamma;
  1859. __S6E3HA1__.init = wrap_smart_dimming_init;
  1860. __S6E3HA1__.get_min_lux_table = get_min_lux_table;
  1861. __S6E3HA1__.mtp_buffer = (char *)(&smart_S6E3HA1.MTP_ORIGN);
  1862. return (struct smartdim_conf *)&__S6E3HA1__;
  1863. }
  1864. /* ----------------------------------------------------------------------------
  1865. * END - Wrapper
  1866. * ----------------------------------------------------------------------------
  1867. */