WIP FPC-III support
[linux/fpc-iii.git] / drivers / media / platform / qcom / venus / pm_helpers.h
blobaa2f6afa2354432fc0f58b6735f45356214f3579
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2019 Linaro Ltd. */
3 #ifndef __VENUS_PM_HELPERS_H__
4 #define __VENUS_PM_HELPERS_H__
6 struct device;
8 #define POWER_ON 1
9 #define POWER_OFF 0
11 struct venus_pm_ops {
12 int (*core_get)(struct device *dev);
13 void (*core_put)(struct device *dev);
14 int (*core_power)(struct device *dev, int on);
16 int (*vdec_get)(struct device *dev);
17 void (*vdec_put)(struct device *dev);
18 int (*vdec_power)(struct device *dev, int on);
20 int (*venc_get)(struct device *dev);
21 void (*venc_put)(struct device *dev);
22 int (*venc_power)(struct device *dev, int on);
24 int (*coreid_power)(struct venus_inst *inst, int on);
26 int (*load_scale)(struct venus_inst *inst);
29 const struct venus_pm_ops *venus_pm_get(enum hfi_version version);
31 static inline int venus_pm_load_scale(struct venus_inst *inst)
33 struct venus_core *core = inst->core;
35 if (!core->pm_ops || !core->pm_ops->load_scale)
36 return 0;
38 return core->pm_ops->load_scale(inst);
41 static inline int venus_pm_acquire_core(struct venus_inst *inst)
43 struct venus_core *core = inst->core;
44 const struct venus_pm_ops *pm_ops = core->pm_ops;
45 int ret = 0;
47 if (pm_ops && pm_ops->coreid_power)
48 ret = pm_ops->coreid_power(inst, POWER_ON);
50 return ret;
53 static inline int venus_pm_release_core(struct venus_inst *inst)
55 struct venus_core *core = inst->core;
56 const struct venus_pm_ops *pm_ops = core->pm_ops;
57 int ret = 0;
59 if (pm_ops && pm_ops->coreid_power)
60 ret = pm_ops->coreid_power(inst, POWER_OFF);
62 return ret;
65 #endif