smart_mtp_ea8061.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * =================================================================
  3. *
  4. * Filename: smart_mtp_se6e8fa.h
  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. #ifndef _SMART_MTP_SE6E8FA_H_
  33. #define _SMART_MTP_SE6E8FA_H_
  34. #include <linux/module.h>
  35. #include <linux/kernel.h>
  36. #include <linux/errno.h>
  37. #include <linux/mutex.h>
  38. #include <linux/wait.h>
  39. #include <linux/ctype.h>
  40. #include <asm/div64.h>
  41. #define VT232_ID 0x02
  42. #define CCG6_ID 0x03
  43. #define EVT1_ID 0x23
  44. #define EVT1_SECOND_ID 0x44
  45. /* EVT1_THIRD_ID & EVT1_FOUTRH_ID has same smart-dimming algo */
  46. #define EVT1_THIRD_ID 0x25
  47. #define EVT1_FOUTRH_ID 0x45
  48. /* for REV H LDI */
  49. #define EVT1_REV_H_ID3_1 0x46
  50. #define EVT1_REV_H_ID3_2 0x26
  51. /* for REV I LDI */
  52. #define EVT1_REV_I_ID3_1 0x47
  53. #define EVT1_REV_I_ID3_2 0x27
  54. /* octa ldi id3 */
  55. #define EVT0_ID 0x00
  56. #define EVT0_SECOND_ID 0x01
  57. #define EVT1_H_REV_I 0x23
  58. #define EVT1_H_REV_J 0x24
  59. /* youm ldi id3 */
  60. #define EVT0_F_REV_A 0x10
  61. #define EVT0_F_REV_E 0x11
  62. #define EVT0_F_REV_F 0x12
  63. #define EVT2_F_REV_G 0x32
  64. #define EVT2_FRESCO_REV_G 0x43
  65. /* EA8061V ldi id3 */
  66. #define EVT0_EA8061V_REV_A 0x82
  67. #define EVT2_EA8061V_REV_C 0x95
  68. #define EVT2_EA8061V_REV_D 0x96
  69. #define EVT2_EA8061V_REV_E 0x97
  70. #define EVT0_EA8061V_KMINI_REV_A 0x84
  71. /* EA8061 ldi id3 */
  72. #define EVT2_EA8061_HESTIA_REV_I 0x47
  73. #define EVT2_EA8061_HESTIA_REV_J 0x48
  74. #define EVT2_EA8061_HESTIA_REV_A 0x40
  75. /*
  76. * From 4.8 inch model use AID function
  77. * CASE#1 is used for now.
  78. */
  79. #define AID_OPERATION
  80. #define GAMMA_CURVE_2P25 1
  81. #define GAMMA_CURVE_2P2 2
  82. #define GAMMA_CURVE_2P15 3
  83. #define GAMMA_CURVE_2P1 4
  84. #define GAMMA_CURVE_2P0 5
  85. #define GAMMA_CURVE_1P9 6
  86. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  87. #define LUMINANCE_MAX 75
  88. #define MTP_START_ADDR 0xFE
  89. #else
  90. #define LUMINANCE_MAX 72
  91. #define MTP_START_ADDR 0xC8
  92. #endif
  93. #define GAMMA_SET_MAX 33
  94. /*
  95. * Each of R, G, B have 1 count so the offset of VT is
  96. * GAMMA_SET_MAX -3
  97. */
  98. #define VT_GAMMA_SET_MAX 3
  99. #define VT_GAMMA_OFFSET GAMMA_SET_MAX - VT_GAMMA_SET_MAX
  100. enum {
  101. VT_GAMMA_OFFSET_R = 0,
  102. VT_GAMMA_OFFSET_G = 0,
  103. VT_GAMMA_OFFSET_B = 1,
  104. };
  105. enum {
  106. VT_GAMMA_BIT_SHIFT_R = 0,
  107. VT_GAMMA_BIT_SHIFT_G = 4,
  108. VT_GAMMA_BIT_SHIFT_B = 0,
  109. };
  110. enum {
  111. VT_GAMMA_BIT_MASK_R = 0xF,
  112. VT_GAMMA_BIT_MASK_G = 0xF,
  113. VT_GAMMA_BIT_MASK_B = 0xFF,
  114. };
  115. #define BIT_SHIFT 22
  116. /*
  117. it means BIT_SHIFT is 22. pow(2,BIT_SHIFT) is 4194304.
  118. BIT_SHIFT is used for right bit shfit
  119. */
  120. #define BIT_SHFIT_MUL 4194304
  121. #define S6E8FA_GRAY_SCALE_MAX 256
  122. /*6.3*4194304 */
  123. #define S6E8FA_VREG0_REF 26424115
  124. /*6.1*4194304 */
  125. #define EA8061_VREG0_REF_6P1 25585284
  126. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  127. #define S6E8FA_MAX 11
  128. /* PANEL DEPENDENT THINGS */
  129. #define MAX_CANDELA 350
  130. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  131. #define MIN_CANDELA 2
  132. #else
  133. #define MIN_CANDELA 5
  134. #endif
  135. /*
  136. * ID 0x20
  137. */
  138. #define V255_300CD_R_MSB_20 0x01
  139. #define V255_300CD_R_LSB_20 0x00
  140. #define V255_300CD_G_MSB_20 0x01
  141. #define V255_300CD_G_LSB_20 0x00
  142. #define V255_300CD_B_MSB_20 0x01
  143. #define V255_300CD_B_LSB_20 0x00
  144. #define V203_300CD_R_20 0x80
  145. #define V203_300CD_G_20 0x80
  146. #define V203_300CD_B_20 0x80
  147. #define V151_300CD_R_20 0x80
  148. #define V151_300CD_G_20 0x80
  149. #define V151_300CD_B_20 0x80
  150. #define V87_300CD_R_20 0x80
  151. #define V87_300CD_G_20 0x80
  152. #define V87_300CD_B_20 0x80
  153. #define V51_300CD_R_20 0x80
  154. #define V51_300CD_G_20 0x80
  155. #define V51_300CD_B_20 0x80
  156. #define V35_300CD_R_20 0x80
  157. #define V35_300CD_G_20 0x80
  158. #define V35_300CD_B_20 0x80
  159. #define V23_300CD_R_20 0x80
  160. #define V23_300CD_G_20 0x80
  161. #define V23_300CD_B_20 0x80
  162. #define V11_300CD_R_20 0x80
  163. #define V11_300CD_G_20 0x80
  164. #define V11_300CD_B_20 0x80
  165. #define V3_300CD_R_20 0x80
  166. #define V3_300CD_G_20 0x80
  167. #define V3_300CD_B_20 0x80
  168. #define VT_300CD_R_20 0x00
  169. #define VT_300CD_G_20 0x00
  170. #define VT_300CD_B_20 0x00
  171. /* PANEL DEPENDENT THINGS END*/
  172. enum {
  173. V1_INDEX = 0,
  174. V3_INDEX = 1,
  175. V11_INDEX = 2,
  176. V23_INDEX = 3,
  177. V35_INDEX = 4,
  178. V51_INDEX = 5,
  179. V87_INDEX = 6,
  180. V151_INDEX = 7,
  181. V203_INDEX = 8,
  182. V255_INDEX = 9,
  183. };
  184. struct GAMMA_LEVEL {
  185. int level_0;
  186. int level_1;
  187. int level_3;
  188. int level_11;
  189. int level_23;
  190. int level_35;
  191. int level_51;
  192. int level_87;
  193. int level_151;
  194. int level_203;
  195. int level_255;
  196. } __packed;
  197. struct RGB_OUTPUT_VOLTARE {
  198. struct GAMMA_LEVEL R_VOLTAGE;
  199. struct GAMMA_LEVEL G_VOLTAGE;
  200. struct GAMMA_LEVEL B_VOLTAGE;
  201. } __packed;
  202. struct GRAY_VOLTAGE {
  203. /*
  204. This voltage value use 14bit right shit
  205. it means voltage is divied by 16384.
  206. */
  207. int R_Gray;
  208. int G_Gray;
  209. int B_Gray;
  210. } __packed;
  211. struct GRAY_SCALE {
  212. struct GRAY_VOLTAGE TABLE[S6E8FA_GRAY_SCALE_MAX];
  213. struct GRAY_VOLTAGE VT_TABLE;
  214. } __packed;
  215. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  216. struct MTP_SET {
  217. char OFFSET_255_MSB;
  218. char OFFSET_255_LSB;
  219. char OFFSET_203;
  220. char OFFSET_151;
  221. char OFFSET_87;
  222. char OFFSET_51;
  223. char OFFSET_35;
  224. char OFFSET_23;
  225. char OFFSET_11;
  226. char OFFSET_3;
  227. char OFFSET_1;
  228. } __packed;
  229. #ifdef CONFIG_HBM_PSRE
  230. struct MTP_OFFSET_400CD {
  231. struct MTP_SET R_OFFSET;
  232. struct MTP_SET G_OFFSET;
  233. struct MTP_SET B_OFFSET;
  234. char mtp_400cd[6]; /*gamma for 400cd*/
  235. char elvss_400cd; /*elvss for 400cd*/
  236. } __packed;
  237. #endif
  238. struct MTP_OFFSET {
  239. struct MTP_SET R_OFFSET;
  240. struct MTP_SET G_OFFSET;
  241. struct MTP_SET B_OFFSET;
  242. } __packed;
  243. struct illuminance_table {
  244. int lux;
  245. char gamma_setting[GAMMA_SET_MAX];
  246. } __packed;
  247. struct SMART_DIM {
  248. #ifdef CONFIG_HBM_PSRE
  249. struct MTP_OFFSET_400CD MTP_ORIGN;
  250. #else
  251. struct MTP_OFFSET MTP_ORIGN;
  252. #endif
  253. struct MTP_OFFSET MTP;
  254. struct RGB_OUTPUT_VOLTARE RGB_OUTPUT;
  255. struct GRAY_SCALE GRAY;
  256. /* Because of AID funtion, below members are added*/
  257. int lux_table_max;
  258. int *plux_table;
  259. struct illuminance_table gen_table[LUMINANCE_MAX];
  260. int brightness_level;
  261. int ldi_revision;
  262. int vregout_voltage;
  263. } __packed;
  264. #endif