drm/exynos: Stop using drm_framebuffer_unregister_private
[linux/fpc-iii.git] / drivers / gpu / drm / amd / powerplay / eventmgr / eventmgr.c
blobfb88e4e5d625815ab213b1011392bce0ef96eae6
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 <linux/types.h>
24 #include <linux/kernel.h>
25 #include <linux/slab.h>
26 #include "eventmgr.h"
27 #include "hwmgr.h"
28 #include "eventinit.h"
29 #include "eventmanagement.h"
31 static int pem_init(struct pp_eventmgr *eventmgr)
33 int result = 0;
34 struct pem_event_data event_data = { {0} };
36 /* Initialize PowerPlay feature info */
37 pem_init_feature_info(eventmgr);
39 /* Initialize event action chains */
40 pem_init_event_action_chains(eventmgr);
42 /* Call initialization event */
43 result = pem_handle_event(eventmgr, AMD_PP_EVENT_INITIALIZE, &event_data);
45 if (0 != result)
46 return result;
48 /* Register interrupt callback functions */
49 result = pem_register_interrupts(eventmgr);
50 return 0;
53 static void pem_fini(struct pp_eventmgr *eventmgr)
55 struct pem_event_data event_data = { {0} };
57 pem_uninit_featureInfo(eventmgr);
58 pem_unregister_interrupts(eventmgr);
60 pem_handle_event(eventmgr, AMD_PP_EVENT_UNINITIALIZE, &event_data);
63 int eventmgr_init(struct pp_instance *handle)
65 int result = 0;
66 struct pp_eventmgr *eventmgr;
68 if (handle == NULL)
69 return -EINVAL;
71 eventmgr = kzalloc(sizeof(struct pp_eventmgr), GFP_KERNEL);
72 if (eventmgr == NULL)
73 return -ENOMEM;
75 eventmgr->hwmgr = handle->hwmgr;
76 handle->eventmgr = eventmgr;
78 eventmgr->platform_descriptor = &(eventmgr->hwmgr->platform_descriptor);
79 eventmgr->pp_eventmgr_init = pem_init;
80 eventmgr->pp_eventmgr_fini = pem_fini;
82 return result;
85 int eventmgr_fini(struct pp_eventmgr *eventmgr)
87 kfree(eventmgr);
88 return 0;
91 static int pem_handle_event_unlocked(struct pp_eventmgr *eventmgr, enum amd_pp_event event, struct pem_event_data *data)
93 if (eventmgr == NULL || event >= AMD_PP_EVENT_MAX || data == NULL)
94 return -EINVAL;
96 return pem_excute_event_chain(eventmgr, eventmgr->event_chain[event], data);
99 int pem_handle_event(struct pp_eventmgr *eventmgr, enum amd_pp_event event, struct pem_event_data *event_data)
101 int r = 0;
103 r = pem_handle_event_unlocked(eventmgr, event, event_data);
105 return r;
108 bool pem_is_hw_access_blocked(struct pp_eventmgr *eventmgr)
110 return (eventmgr->block_adjust_power_state || phm_is_hw_access_blocked(eventmgr->hwmgr));