smart_mtp_s6e3ha1.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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_S6E3HA1_H_
  33. #define _SMART_MTP_S6E3HA1_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. /* octa ldi id3 */
  42. #define ID_REV_A 0x03
  43. #define AID_OPERATION
  44. #define GAMMA_CURVE_2P25 1
  45. #define GAMMA_CURVE_2P2 2
  46. #define GAMMA_CURVE_2P15 3
  47. #define GAMMA_CURVE_2P1 4
  48. #define GAMMA_CURVE_2P0 5
  49. #define GAMMA_CURVE_1P9 6
  50. #define MTP_START_ADDR 0xC8
  51. #define LUMINANCE_MAX 62
  52. #define GAMMA_SET_MAX 33
  53. #define BIT_SHIFT 22
  54. /*
  55. it means BIT_SHIFT is 22. pow(2,BIT_SHIFT) is 4194304.
  56. BIT_SHIFT is used for right bit shfit
  57. */
  58. #define BIT_SHFIT_MUL 4194304
  59. #define S6E3HA1_GRAY_SCALE_MAX 256
  60. /*6.8*4194304 */
  61. #define S6E3HA1_VREG0_REF 28521267
  62. /*V0,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  63. #define S6E3HA1_MAX 11
  64. /* PANEL DEPENDENT THINGS */
  65. #define MAX_CANDELA 300
  66. #define MIN_CANDELA 5
  67. /*
  68. * ID 0x20
  69. */
  70. #define V255_300CD_R_MSB_20 0x01
  71. #define V255_300CD_R_LSB_20 0x00
  72. #define V255_300CD_G_MSB_20 0x01
  73. #define V255_300CD_G_LSB_20 0x00
  74. #define V255_300CD_B_MSB_20 0x01
  75. #define V255_300CD_B_LSB_20 0x00
  76. #define V203_300CD_R_20 0x80
  77. #define V203_300CD_G_20 0x80
  78. #define V203_300CD_B_20 0x80
  79. #define V151_300CD_R_20 0x80
  80. #define V151_300CD_G_20 0x80
  81. #define V151_300CD_B_20 0x80
  82. #define V87_300CD_R_20 0x80
  83. #define V87_300CD_G_20 0x80
  84. #define V87_300CD_B_20 0x80
  85. #define V51_300CD_R_20 0x80
  86. #define V51_300CD_G_20 0x80
  87. #define V51_300CD_B_20 0x80
  88. #define V35_300CD_R_20 0x80
  89. #define V35_300CD_G_20 0x80
  90. #define V35_300CD_B_20 0x80
  91. #define V23_300CD_R_20 0x80
  92. #define V23_300CD_G_20 0x80
  93. #define V23_300CD_B_20 0x80
  94. #define V11_300CD_R_20 0x80
  95. #define V11_300CD_G_20 0x80
  96. #define V11_300CD_B_20 0x80
  97. #define V3_300CD_R_20 0x80
  98. #define V3_300CD_G_20 0x80
  99. #define V3_300CD_B_20 0x80
  100. #define VT_300CD_R_20 0x00
  101. #define VT_300CD_G_20 0x00
  102. #define VT_300CD_B_20 0x00
  103. /* PANEL DEPENDENT THINGS END*/
  104. enum {
  105. V1_INDEX = 0,
  106. V3_INDEX = 1,
  107. V11_INDEX = 2,
  108. V23_INDEX = 3,
  109. V35_INDEX = 4,
  110. V51_INDEX = 5,
  111. V87_INDEX = 6,
  112. V151_INDEX = 7,
  113. V203_INDEX = 8,
  114. V255_INDEX = 9,
  115. };
  116. struct GAMMA_LEVEL {
  117. int level_0;
  118. int level_1;
  119. int level_3;
  120. int level_11;
  121. int level_23;
  122. int level_35;
  123. int level_51;
  124. int level_87;
  125. int level_151;
  126. int level_203;
  127. int level_255;
  128. } __packed;
  129. struct RGB_OUTPUT_VOLTARE {
  130. struct GAMMA_LEVEL R_VOLTAGE;
  131. struct GAMMA_LEVEL G_VOLTAGE;
  132. struct GAMMA_LEVEL B_VOLTAGE;
  133. } __packed;
  134. struct GRAY_VOLTAGE {
  135. /*
  136. This voltage value use 14bit right shit
  137. it means voltage is divied by 16384.
  138. */
  139. int R_Gray;
  140. int G_Gray;
  141. int B_Gray;
  142. } __packed;
  143. struct GRAY_SCALE {
  144. struct GRAY_VOLTAGE TABLE[S6E3HA1_GRAY_SCALE_MAX];
  145. struct GRAY_VOLTAGE VT_TABLE;
  146. } __packed;
  147. /*V0,V1,V3,V11,V23,V35,V51,V87,V151,V203,V255*/
  148. struct MTP_SET {
  149. char OFFSET_255_MSB;
  150. char OFFSET_255_LSB;
  151. char OFFSET_203;
  152. char OFFSET_151;
  153. char OFFSET_87;
  154. char OFFSET_51;
  155. char OFFSET_35;
  156. char OFFSET_23;
  157. char OFFSET_11;
  158. char OFFSET_3;
  159. char OFFSET_1;
  160. } __packed;
  161. #ifdef CONFIG_HBM_PSRE
  162. struct MTP_OFFSET_400CD {
  163. struct MTP_SET R_OFFSET;
  164. struct MTP_SET G_OFFSET;
  165. struct MTP_SET B_OFFSET;
  166. char mtp_400cd[6]; /*gamma for 400cd*/
  167. char elvss_400cd; /*elvss for 400cd*/
  168. } __packed;
  169. #endif
  170. struct MTP_OFFSET {
  171. struct MTP_SET R_OFFSET;
  172. struct MTP_SET G_OFFSET;
  173. struct MTP_SET B_OFFSET;
  174. } __packed;
  175. struct illuminance_table {
  176. int lux;
  177. char gamma_setting[GAMMA_SET_MAX];
  178. } __packed;
  179. struct SMART_DIM {
  180. #ifdef CONFIG_HBM_PSRE
  181. struct MTP_OFFSET_400CD MTP_ORIGN;
  182. #else
  183. struct MTP_OFFSET MTP_ORIGN;
  184. #endif
  185. struct MTP_OFFSET MTP;
  186. struct RGB_OUTPUT_VOLTARE RGB_OUTPUT;
  187. struct GRAY_SCALE GRAY;
  188. /* Because of AID funtion, below members are added*/
  189. int lux_table_max;
  190. int *plux_table;
  191. struct illuminance_table gen_table[LUMINANCE_MAX];
  192. int brightness_level;
  193. int ldi_revision;
  194. } __packed;
  195. #endif