smart_mtp_se6e8fa.h 5.3 KB

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