smart_mtp_s6e8aa4.h 4.9 KB

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