drm/exynos: Stop using drm_framebuffer_unregister_private
[linux/fpc-iii.git] / drivers / gpu / drm / amd / powerplay / eventmgr / eventmanagement.c
blobcd1ca07ef7f72deaa10d171c241d1308dc9d1869
1 /*
2 * Copyright 2015 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 #include "eventmanagement.h"
24 #include "eventmgr.h"
25 #include "eventactionchains.h"
27 int pem_init_event_action_chains(struct pp_eventmgr *eventmgr)
29 int i;
31 for (i = 0; i < AMD_PP_EVENT_MAX; i++)
32 eventmgr->event_chain[i] = NULL;
34 eventmgr->event_chain[AMD_PP_EVENT_SUSPEND] = pem_get_suspend_action_chain(eventmgr);
35 eventmgr->event_chain[AMD_PP_EVENT_INITIALIZE] = pem_get_initialize_action_chain(eventmgr);
36 eventmgr->event_chain[AMD_PP_EVENT_UNINITIALIZE] = pem_get_uninitialize_action_chain(eventmgr);
37 eventmgr->event_chain[AMD_PP_EVENT_POWER_SOURCE_CHANGE] = pem_get_power_source_change_action_chain(eventmgr);
38 eventmgr->event_chain[AMD_PP_EVENT_HIBERNATE] = pem_get_hibernate_action_chain(eventmgr);
39 eventmgr->event_chain[AMD_PP_EVENT_RESUME] = pem_get_resume_action_chain(eventmgr);
40 eventmgr->event_chain[AMD_PP_EVENT_THERMAL_NOTIFICATION] = pem_get_thermal_notification_action_chain(eventmgr);
41 eventmgr->event_chain[AMD_PP_EVENT_VBIOS_NOTIFICATION] = pem_get_vbios_notification_action_chain(eventmgr);
42 eventmgr->event_chain[AMD_PP_EVENT_ENTER_THERMAL_STATE] = pem_get_enter_thermal_state_action_chain(eventmgr);
43 eventmgr->event_chain[AMD_PP_EVENT_EXIT_THERMAL_STATE] = pem_get_exit_thermal_state_action_chain(eventmgr);
44 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_POWER_PLAY] = pem_get_enable_powerplay_action_chain(eventmgr);
45 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_POWER_PLAY] = pem_get_disable_powerplay_action_chain(eventmgr);
46 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_OVER_DRIVE_TEST] = pem_get_enable_overdrive_test_action_chain(eventmgr);
47 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_OVER_DRIVE_TEST] = pem_get_disable_overdrive_test_action_chain(eventmgr);
48 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_GFX_CLOCK_GATING] = pem_get_enable_gfx_clock_gating_action_chain(eventmgr);
49 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_GFX_CLOCK_GATING] = pem_get_disable_gfx_clock_gating_action_chain(eventmgr);
50 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_CGPG] = pem_get_enable_cgpg_action_chain(eventmgr);
51 eventmgr->event_chain[AMD_PP_EVENT_DISABLE_CGPG] = pem_get_disable_cgpg_action_chain(eventmgr);
52 eventmgr->event_chain[AMD_PP_EVENT_COMPLETE_INIT] = pem_get_complete_init_action_chain(eventmgr);
53 eventmgr->event_chain[AMD_PP_EVENT_SCREEN_ON] = pem_get_screen_on_action_chain(eventmgr);
54 eventmgr->event_chain[AMD_PP_EVENT_SCREEN_OFF] = pem_get_screen_off_action_chain(eventmgr);
55 eventmgr->event_chain[AMD_PP_EVENT_PRE_SUSPEND] = pem_get_pre_suspend_action_chain(eventmgr);
56 eventmgr->event_chain[AMD_PP_EVENT_PRE_RESUME] = pem_get_pre_resume_action_chain(eventmgr);
57 eventmgr->event_chain[AMD_PP_EVENT_ENABLE_USER_STATE] = pem_enable_user_state_action_chain(eventmgr);
58 eventmgr->event_chain[AMD_PP_EVENT_READJUST_POWER_STATE] = pem_readjust_power_state_action_chain(eventmgr);
59 eventmgr->event_chain[AMD_PP_EVENT_DISPLAY_CONFIG_CHANGE] = pem_display_config_change_action_chain(eventmgr);
60 return 0;
63 int pem_excute_event_chain(struct pp_eventmgr *eventmgr, const struct action_chain *event_chain, struct pem_event_data *event_data)
65 const pem_event_action * const *paction_chain;
66 const pem_event_action *psub_chain;
67 int tmp_result = 0;
68 int result = 0;
70 if (eventmgr == NULL || event_chain == NULL || event_data == NULL)
71 return -EINVAL;
73 for (paction_chain = event_chain->action_chain; NULL != *paction_chain; paction_chain++) {
74 if (0 != result)
75 return result;
77 for (psub_chain = *paction_chain; NULL != *psub_chain; psub_chain++) {
78 tmp_result = (*psub_chain)(eventmgr, event_data);
79 if (0 == result)
80 result = tmp_result;
84 return result;
87 const struct action_chain *pem_get_suspend_action_chain(struct pp_eventmgr *eventmgr)
89 return &suspend_action_chain;
92 const struct action_chain *pem_get_initialize_action_chain(struct pp_eventmgr *eventmgr)
94 return &initialize_action_chain;
97 const struct action_chain *pem_get_uninitialize_action_chain(struct pp_eventmgr *eventmgr)
99 return &uninitialize_action_chain;
102 const struct action_chain *pem_get_power_source_change_action_chain(struct pp_eventmgr *eventmgr)
104 return &power_source_change_action_chain_pp_enabled; /* other case base on feature info*/
107 const struct action_chain *pem_get_resume_action_chain(struct pp_eventmgr *eventmgr)
109 return &resume_action_chain;
112 const struct action_chain *pem_get_hibernate_action_chain(struct pp_eventmgr *eventmgr)
114 return NULL;
117 const struct action_chain *pem_get_thermal_notification_action_chain(struct pp_eventmgr *eventmgr)
119 return NULL;
122 const struct action_chain *pem_get_vbios_notification_action_chain(struct pp_eventmgr *eventmgr)
124 return NULL;
127 const struct action_chain *pem_get_enter_thermal_state_action_chain(struct pp_eventmgr *eventmgr)
129 return NULL;
132 const struct action_chain *pem_get_exit_thermal_state_action_chain(struct pp_eventmgr *eventmgr)
134 return NULL;
137 const struct action_chain *pem_get_enable_powerplay_action_chain(struct pp_eventmgr *eventmgr)
139 return NULL;
142 const struct action_chain *pem_get_disable_powerplay_action_chain(struct pp_eventmgr *eventmgr)
144 return NULL;
147 const struct action_chain *pem_get_enable_overdrive_test_action_chain(struct pp_eventmgr *eventmgr)
149 return NULL;
152 const struct action_chain *pem_get_disable_overdrive_test_action_chain(struct pp_eventmgr *eventmgr)
154 return NULL;
157 const struct action_chain *pem_get_enable_gfx_clock_gating_action_chain(struct pp_eventmgr *eventmgr)
159 return &enable_gfx_clock_gating_action_chain;
162 const struct action_chain *pem_get_disable_gfx_clock_gating_action_chain(struct pp_eventmgr *eventmgr)
164 return &disable_gfx_clock_gating_action_chain;
167 const struct action_chain *pem_get_enable_cgpg_action_chain(struct pp_eventmgr *eventmgr)
169 return &enable_cgpg_action_chain;
172 const struct action_chain *pem_get_disable_cgpg_action_chain(struct pp_eventmgr *eventmgr)
174 return &disable_cgpg_action_chain;
177 const struct action_chain *pem_get_complete_init_action_chain(struct pp_eventmgr *eventmgr)
179 return &complete_init_action_chain;
182 const struct action_chain *pem_get_screen_on_action_chain(struct pp_eventmgr *eventmgr)
184 return NULL;
187 const struct action_chain *pem_get_screen_off_action_chain(struct pp_eventmgr *eventmgr)
189 return NULL;
192 const struct action_chain *pem_get_pre_suspend_action_chain(struct pp_eventmgr *eventmgr)
194 return NULL;
197 const struct action_chain *pem_get_pre_resume_action_chain(struct pp_eventmgr *eventmgr)
199 return NULL;
202 const struct action_chain *pem_enable_user_state_action_chain(struct pp_eventmgr *eventmgr)
204 return &enable_user_state_action_chain;
207 const struct action_chain *pem_readjust_power_state_action_chain(struct pp_eventmgr *eventmgr)
209 return &readjust_power_state_action_chain;
212 const struct action_chain *pem_display_config_change_action_chain(struct pp_eventmgr *eventmgr)
214 return &display_config_change_action_chain;