mmdvfs_mgr.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (C) 2015 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __MMDVFS_MGR_H__
  14. #define __MMDVFS_MGR_H__
  15. #include <aee.h>
  16. #include <mt_smi.h>
  17. #define MMDVFS_LOG_TAG "MMDVFS"
  18. #define MMDVFSMSG(string, args...) pr_debug("[pid=%d]"string, current->tgid, ##args)
  19. #define MMDVFSMSG2(string, args...) pr_debug(string, ##args)
  20. #define MMDVFSTMP(string, args...) pr_debug("[pid=%d]"string, current->tgid, ##args)
  21. #define MMDVFSERR(string, args...) \
  22. do {\
  23. pr_debug("error: "string, ##args); \
  24. aee_kernel_warning(MMDVFS_LOG_TAG, "error: "string, ##args); \
  25. } while (0)
  26. #define _BIT_(_bit_) (unsigned)(1 << (_bit_))
  27. #define _BITS_(_bits_, _val_) ((((unsigned) -1 >> (31 - ((1) ? _bits_))) \
  28. & ~((1U << ((0) ? _bits_)) - 1)) & ((_val_)<<((0) ? _bits_)))
  29. #define _BITMASK_(_bits_) (((unsigned) -1 >> (31 - ((1) ? _bits_))) & ~((1U << ((0) ? _bits_)) - 1))
  30. #define _GET_BITS_VAL_(_bits_, _val_) (((_val_) & (_BITMASK_(_bits_))) >> ((0) ? _bits_))
  31. /* MMDVFS extern APIs */
  32. extern void mmdvfs_init(MTK_SMI_BWC_MM_INFO *info);
  33. extern void mmdvfs_handle_cmd(MTK_MMDVFS_CMD *cmd);
  34. extern void mmdvfs_notify_scenario_enter(MTK_SMI_BWC_SCEN scen);
  35. extern void mmdvfs_notify_scenario_exit(MTK_SMI_BWC_SCEN scen);
  36. extern void mmdvfs_notify_scenario_concurrency(unsigned int u4Concurrency);
  37. extern void mmdvfs_mhl_enable(int enable);
  38. extern void mmdvfs_mjc_enable(int enable);
  39. /* screen size */
  40. extern unsigned int DISP_GetScreenWidth(void);
  41. extern unsigned int DISP_GetScreenHeight(void);
  42. #define MMSYS_CLK_LOW (0)
  43. #define MMSYS_CLK_HIGH (1)
  44. #define MMSYS_CLK_MEDIUM (2)
  45. #define MMDVFS_EVENT_OVL_SINGLE_LAYER_ENTER 0
  46. #define MMDVFS_EVENT_OVL_SINGLE_LAYER_EXIT 1
  47. #define MMDVFS_EVENT_UI_IDLE_ENTER 2
  48. #define MMDVFS_EVENT_UI_IDLE_EXIT 3
  49. #define MMDVFS_CLIENT_ID_ISP 0
  50. typedef int (*clk_switch_cb)(int ori_mmsys_clk_mode, int update_mmsys_clk_mode);
  51. typedef int (*vdec_ctrl_cb)(void);
  52. /* MMDVFS V2 only APIs */
  53. extern int mmdvfs_notify_mmclk_switch_request(int event);
  54. extern int mmdvfs_raise_mmsys_by_mux(void);
  55. extern int mmdvfs_lower_mmsys_by_mux(void);
  56. extern int register_mmclk_switch_cb(clk_switch_cb notify_cb,
  57. clk_switch_cb notify_cb_nolock);
  58. extern int mmdvfs_register_mmclk_switch_cb(clk_switch_cb notify_cb, int mmdvfs_client_id);
  59. extern void dump_mmdvfs_info(void);
  60. /* Extern from other module */
  61. extern MTK_SMI_BWC_SCEN smi_get_current_profile(void);
  62. extern int is_mmdvfs_freq_hopping_disabled(void);
  63. extern int is_mmdvfs_freq_mux_disabled(void);
  64. extern int is_force_max_mmsys_clk(void);
  65. extern int is_force_camera_hpm(void);
  66. extern int is_mmdvfs_disabled(void);
  67. #ifdef MMDVFS_STANDALONE
  68. #define vcorefs_request_dvfs_opp(scen, mode) do { \
  69. MMDVFSMSG("vcorefs_request_dvfs_opp"); \
  70. MMDVFSMSG("MMDVFS_STANDALONE mode enabled\n"); \
  71. } while (0)
  72. #define fliper_set_bw(BW_THRESHOLD_HIGH) do { \
  73. MMDVFSMSG("MMDVFS_STANDALONE mode enabled\n"); \
  74. MMDVFSMSG("fliper_set_bw");\
  75. } while (0)
  76. #define fliper_restore_bw() do {\
  77. MMDVFSMSG("MMDVFS_STANDALONE mode enabled\n"); \
  78. MMDVFSMSG("fliper_restore_bw(): fliper normal\n"); \
  79. } while (0)
  80. #endif /* MMDVFS_STANDALONE */
  81. #ifdef MMDVFS_WQHD_1_0V
  82. #include "disp_session.h"
  83. extern int primary_display_switch_mode_for_mmdvfs(int sess_mode, unsigned int session, int blocking);
  84. #endif
  85. /* D2 plus only */
  86. #if defined(SMI_D2)
  87. extern void mt_set_vencpll_con1(int val);
  88. extern int clkmux_sel(int id, unsigned int clksrc, char *name);
  89. #endif
  90. /* D1 plus implementation only */
  91. extern u32 get_devinfo_with_index(u32 index);
  92. #define MMDVFS_PROFILE_UNKNOWN (0)
  93. #define MMDVFS_PROFILE_R1 (1)
  94. #define MMDVFS_PROFILE_J1 (2)
  95. #define MMDVFS_PROFILE_D1 (3)
  96. #define MMDVFS_PROFILE_D1_PLUS (4)
  97. #define MMDVFS_PROFILE_D2 (5)
  98. #define MMDVFS_PROFILE_D2_M_PLUS (6)
  99. #define MMDVFS_PROFILE_D2_P_PLUS (7)
  100. #define MMDVFS_PROFILE_D3 (8)
  101. #define MMDVFS_PROFILE_E1 (9)
  102. enum {
  103. MMDVFS_CAM_MON_SCEN = SMI_BWC_SCEN_CNT, MMDVFS_SCEN_MHL, MMDVFS_SCEN_MJC, MMDVFS_SCEN_DISP,
  104. MMDVFS_SCEN_ISP, MMDVFS_SCEN_VP_HIGH_RESOLUTION , MMDVFS_SCEN_COUNT
  105. };
  106. /* Backward compatible */
  107. #define SMI_BWC_SCEN_120HZ MMDVFS_SCEN_DISP
  108. #ifndef CONFIG_MTK_SMI_EXT
  109. #define mmdvfs_set_step(scenario, step)
  110. #else
  111. int mmdvfs_set_step(MTK_SMI_BWC_SCEN scenario, mmdvfs_voltage_enum step);
  112. #endif /* CONFIG_MTK_SMI_EXT */
  113. extern int mmdvfs_get_mmdvfs_profile(void);
  114. extern int is_mmdvfs_supported(void);
  115. extern int mmdvfs_set_mmsys_clk(MTK_SMI_BWC_SCEN scenario, int mmsys_clk_mode);
  116. #endif /* __MMDVFS_MGR_H__ */