smart_mtp_patek.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * =================================================================
  3. *
  4. * Filename: smart_mtp_ea8061v.h
  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. #ifndef _SMART_MTP_EA8061V_H_
  32. #define _SMART_MTP_EA8061V_H_
  33. #include <linux/module.h>
  34. #include <linux/kernel.h>
  35. #include <linux/errno.h>
  36. #include <linux/mutex.h>
  37. #include <linux/wait.h>
  38. #include <linux/ctype.h>
  39. #include <asm/div64.h>
  40. #define AID_OPERATION
  41. /* EA8061V ldi id3 */
  42. #define EA8061V_REV_A 0x40
  43. #define EA8061V_REV_B 0x40
  44. #define EA8061V_REV_C 0x41
  45. #define EA8061V_REV_D 0x42
  46. #define EA8061V_REV_E 0x42
  47. #define EA8061V_REV_F 0x43
  48. enum {
  49. GAMMA_CURVE_1P9 = 0,
  50. GAMMA_CURVE_2P15,
  51. GAMMA_CURVE_2P2,
  52. };
  53. #define MTP_START_ADDR 0xC8
  54. #define LUMINANCE_MAX 62
  55. #define GAMMA_SET_MAX 33
  56. #define BIT_SHIFT 22
  57. /*
  58. it means BIT_SHIFT is 22. pow(2,BIT_SHIFT) is 4194304.
  59. BIT_SHIFT is used for right bit shfit
  60. */
  61. #define BIT_SHFIT_MUL 4194304
  62. #define GRAY_SCALE_MAX 256
  63. /*6.3*4194304 */
  64. #define VREG0_REF_6P3 26424115
  65. /*6.0*4194304 */
  66. #define VREG0_REF_6P0 25165824
  67. /*V0,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  68. #define TP_MAX 10
  69. /* PANEL DEPENDENT THINGS */
  70. #define MAX_CANDELA 360
  71. #define MIN_CANDELA 5
  72. /*
  73. * ID 0x20
  74. */
  75. #define V255_300CD_R_MSB 0x01
  76. #define V255_300CD_R_LSB 0x00
  77. #define V255_300CD_G_MSB 0x01
  78. #define V255_300CD_G_LSB 0x00
  79. #define V255_300CD_B_MSB 0x01
  80. #define V255_300CD_B_LSB 0x00
  81. #define V203_300CD_R 0x80
  82. #define V203_300CD_G 0x80
  83. #define V203_300CD_B 0x80
  84. #define V151_300CD_R 0x80
  85. #define V151_300CD_G 0x80
  86. #define V151_300CD_B 0x80
  87. #define V87_300CD_R 0x80
  88. #define V87_300CD_G 0x80
  89. #define V87_300CD_B 0x80
  90. #define V51_300CD_R 0x80
  91. #define V51_300CD_G 0x80
  92. #define V51_300CD_B 0x80
  93. #define V35_300CD_R 0x80
  94. #define V35_300CD_G 0x80
  95. #define V35_300CD_B 0x80
  96. #define V23_300CD_R 0x80
  97. #define V23_300CD_G 0x80
  98. #define V23_300CD_B 0x80
  99. #define V11_300CD_R 0x80
  100. #define V11_300CD_G 0x80
  101. #define V11_300CD_B 0x80
  102. #define V3_300CD_R 0x80
  103. #define V3_300CD_G 0x80
  104. #define V3_300CD_B 0x80
  105. #define VT_300CD_R 0x00
  106. #define VT_300CD_G 0x00
  107. #define VT_300CD_B 0x00
  108. /* PANEL DEPENDENT THINGS END*/
  109. enum {
  110. V0_INDEX = 0,
  111. V3_INDEX = 1,
  112. V11_INDEX = 2,
  113. V23_INDEX = 3,
  114. V35_INDEX = 4,
  115. V51_INDEX = 5,
  116. V87_INDEX = 6,
  117. V151_INDEX = 7,
  118. V203_INDEX = 8,
  119. V255_INDEX = 9,
  120. };
  121. struct GAMMA_LEVEL {
  122. int level_0;
  123. // int level_1;
  124. int level_3;
  125. int level_11;
  126. int level_23;
  127. int level_35;
  128. int level_51;
  129. int level_87;
  130. int level_151;
  131. int level_203;
  132. int level_255;
  133. } __packed;
  134. struct RGB_OUTPUT_VOLTARE {
  135. struct GAMMA_LEVEL R_VOLTAGE;
  136. struct GAMMA_LEVEL G_VOLTAGE;
  137. struct GAMMA_LEVEL B_VOLTAGE;
  138. } __packed;
  139. struct GRAY_VOLTAGE {
  140. /*
  141. This voltage value use 14bit right shit
  142. it means voltage is divied by 16384.
  143. */
  144. int R_Gray;
  145. int G_Gray;
  146. int B_Gray;
  147. } __packed;
  148. struct GRAY_SCALE {
  149. struct GRAY_VOLTAGE TABLE[GRAY_SCALE_MAX];
  150. struct GRAY_VOLTAGE VT_TABLE;
  151. } __packed;
  152. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  153. struct MTP_SET {
  154. char OFFSET_255_MSB;
  155. char OFFSET_255_LSB;
  156. char OFFSET_203;
  157. char OFFSET_151;
  158. char OFFSET_87;
  159. char OFFSET_51;
  160. char OFFSET_35;
  161. char OFFSET_23;
  162. char OFFSET_11;
  163. char OFFSET_3;
  164. char OFFSET_1;
  165. } __packed;
  166. #ifdef CONFIG_HBM_PSRE
  167. struct MTP_OFFSET_400CD {
  168. struct MTP_SET R_OFFSET;
  169. struct MTP_SET G_OFFSET;
  170. struct MTP_SET B_OFFSET;
  171. char mtp_400cd[6]; /*gamma for 400cd*/
  172. char elvss_400cd; /*elvss for 400cd*/
  173. } __packed;
  174. #endif
  175. struct MTP_OFFSET {
  176. struct MTP_SET R_OFFSET;
  177. struct MTP_SET G_OFFSET;
  178. struct MTP_SET B_OFFSET;
  179. } __packed;
  180. struct illuminance_table {
  181. int lux;
  182. char gamma_setting[GAMMA_SET_MAX];
  183. } __packed;
  184. struct SMART_DIM {
  185. #ifdef CONFIG_HBM_PSRE
  186. struct MTP_OFFSET_400CD MTP_ORIGN;
  187. #else
  188. struct MTP_OFFSET MTP_ORIGN;
  189. #endif
  190. struct MTP_OFFSET MTP;
  191. struct RGB_OUTPUT_VOLTARE RGB_OUTPUT;
  192. struct GRAY_SCALE GRAY;
  193. /* Because of AID funtion, below members are added*/
  194. int lux_table_max;
  195. int *plux_table;
  196. struct illuminance_table gen_table[LUMINANCE_MAX];
  197. int brightness_level;
  198. int ldi_revision;
  199. int vregout_voltage;
  200. } __packed;
  201. #endif