smart_mtp_patek.c 68 KB

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