smart_mtp_ea8064.h 4.9 KB

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