ddp_misc.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #define LOG_TAG "MISC"
  32. #include <platform/ddp_reg.h>
  33. #include <platform/ddp_misc.h>
  34. #include <debug.h>
  35. void ddp_bypass_color(int idx, unsigned int width, unsigned int height, void * handle)
  36. {
  37. dprintf(ALWAYS, "bypass color\n");
  38. DISP_REG_SET(NULL,DISP_COLOR_CFG_MAIN, 1<<7); //bypass color engine
  39. DISP_REG_SET(NULL,DISP_COLOR_INTERNAL_IP_WIDTH, width); //bypass color engine
  40. DISP_REG_SET(NULL,DISP_COLOR_INTERNAL_IP_HEIGHT, height); //bypass color engine
  41. DISP_REG_SET(NULL,DISP_COLOR_START, 0x1); // start
  42. }
  43. void ddp_bypass_ccorr(unsigned int width, unsigned int height, void * handle)
  44. {
  45. dprintf(ALWAYS, "bypass ccorr\n");
  46. DISP_REG_MASK(NULL,DISP_REG_CCORR_CFG, 1, 1);
  47. DISP_REG_SET(NULL,DISP_REG_CCORR_SIZE, (width<<16)|height); //bypass color engine
  48. DISP_REG_SET(NULL,DISP_REG_CCORR_EN, 1);
  49. }
  50. void ddp_bypass_aal(unsigned int width, unsigned int height, void * handle)
  51. {
  52. dprintf(ALWAYS, "bypass aal\n");
  53. DISP_REG_SET_FIELD(handle,CFG_FLD_RELAY_MODE, DISP_AAL_CFG, 0x1); //relay_mode
  54. DISP_REG_SET(NULL,DISP_AAL_SIZE, (width<<16)|height); //bypass color engine
  55. DISP_REG_SET(handle,DISP_AAL_EN, 0x1); //bypass mode
  56. }
  57. void ddp_bypass_gamma(unsigned int width, unsigned int height, void * handle)
  58. {
  59. dprintf(ALWAYS, "bypass gamma\n");
  60. DISP_REG_MASK(NULL,DISP_REG_GAMMA_CFG, 1, 1);
  61. DISP_REG_SET(NULL,DISP_REG_GAMMA_SIZE, (width<<16)|height); //bypass color engine
  62. DISP_REG_SET(handle,DISP_REG_GAMMA_EN, 0x1); //bypass mode
  63. }
  64. static int config_color(DISP_MODULE_ENUM module, disp_ddp_path_config* pConfig, void* cmdq)
  65. {
  66. int color_idx;
  67. if (module == DISP_MODULE_COLOR0)
  68. color_idx = 0;
  69. else
  70. color_idx = 1;
  71. dprintf(ALWAYS, "config color dirty = %d\n", pConfig->dst_dirty);
  72. if (!pConfig->dst_dirty) {
  73. return 0;
  74. }
  75. ddp_bypass_color(color_idx,pConfig->dst_w, pConfig->dst_h,cmdq);
  76. return 0;
  77. }
  78. static int config_ccorr(DISP_MODULE_ENUM module, disp_ddp_path_config* pConfig, void* cmdq)
  79. {
  80. dprintf(ALWAYS, "config ccorr dirty = %d\n", pConfig->dst_dirty);
  81. if (!pConfig->dst_dirty) {
  82. return 0;
  83. }
  84. ddp_bypass_ccorr(pConfig->dst_w, pConfig->dst_h,cmdq);
  85. return 0;
  86. }
  87. static int config_aal(DISP_MODULE_ENUM module, disp_ddp_path_config* pConfig, void* cmdq)
  88. {
  89. dprintf(ALWAYS, "config aal dirty = %d\n", pConfig->dst_dirty);
  90. if (!pConfig->dst_dirty) {
  91. return 0;
  92. }
  93. ddp_bypass_aal(pConfig->dst_w, pConfig->dst_h,cmdq);
  94. return 0;
  95. }
  96. static int config_gamma(DISP_MODULE_ENUM module, disp_ddp_path_config* pConfig, void* cmdq)
  97. {
  98. dprintf(ALWAYS, "config gamma dirty = %d\n", pConfig->dst_dirty);
  99. if (!pConfig->dst_dirty) {
  100. return 0;
  101. }
  102. ddp_bypass_gamma(pConfig->dst_w, pConfig->dst_h,cmdq);
  103. return 0;
  104. }
  105. static int clock_on(DISP_MODULE_ENUM module,void * handle)
  106. {
  107. ddp_enable_module_clock(module);
  108. return 0;
  109. }
  110. static int clock_off(DISP_MODULE_ENUM module,void * handle)
  111. {
  112. ddp_disable_module_clock(module);
  113. return 0;
  114. }
  115. ///////////////////////////////////////////////////////////
  116. // color
  117. DDP_MODULE_DRIVER ddp_driver_color = {
  118. .init = clock_on,
  119. .deinit = clock_off,
  120. .config = config_color,
  121. .start = NULL,
  122. .trigger = NULL,
  123. .stop = NULL,
  124. .reset = NULL,
  125. .power_on = clock_on,
  126. .power_off = clock_off,
  127. .is_idle = NULL,
  128. .is_busy = NULL,
  129. .dump_info = NULL,
  130. .bypass = NULL,
  131. .build_cmdq = NULL,
  132. .set_lcm_utils = NULL,
  133. };
  134. // ccorr
  135. DDP_MODULE_DRIVER ddp_driver_ccorr = {
  136. .init = clock_on,
  137. .deinit = clock_off,
  138. .config = config_ccorr,
  139. .start = NULL,
  140. .trigger = NULL,
  141. .stop = NULL,
  142. .reset = NULL,
  143. .power_on = clock_on,
  144. .power_off = clock_off,
  145. .is_idle = NULL,
  146. .is_busy = NULL,
  147. .dump_info = NULL,
  148. .bypass = NULL,
  149. .build_cmdq = NULL,
  150. .set_lcm_utils = NULL,
  151. };
  152. // aal
  153. DDP_MODULE_DRIVER ddp_driver_aal = {
  154. .init = clock_on,
  155. .deinit = clock_off,
  156. .config = config_aal,
  157. .start = NULL,
  158. .trigger = NULL,
  159. .stop = NULL,
  160. .reset = NULL,
  161. .power_on = clock_on,
  162. .power_off = clock_off,
  163. .is_idle = NULL,
  164. .is_busy = NULL,
  165. .dump_info = NULL,
  166. .bypass = NULL,
  167. .build_cmdq = NULL,
  168. .set_lcm_utils = NULL,
  169. };
  170. // gamma
  171. DDP_MODULE_DRIVER ddp_driver_gamma = {
  172. .init = clock_on,
  173. .deinit = clock_off,
  174. .config = config_gamma,
  175. .start = NULL,
  176. .trigger = NULL,
  177. .stop = NULL,
  178. .reset = NULL,
  179. .power_on = clock_on,
  180. .power_off = clock_off,
  181. .is_idle = NULL,
  182. .is_busy = NULL,
  183. .dump_info = NULL,
  184. .bypass = NULL,
  185. .build_cmdq = NULL,
  186. .set_lcm_utils = NULL,
  187. };