mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
media: qcom: venus: add power domain enable logic for Venus cores
Attach power domains for vdec and venc cores and power them up if a vdec or venc session is started. Vcodec clocks are added and enabled to the core Venus device both for vcodec0 and vcodec1. To ensure they are added only once, introduce a new property "vcodec_clks", which is an array of clocks which are enabled both during decode and encode and is retrieved from the device tree only once. Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com> Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
This commit is contained in:
parent
c53e055028
commit
86a366c02d
|
|
@ -79,6 +79,7 @@ struct venus_resources {
|
|||
const struct hfi_ubwc_config *ubwc_conf;
|
||||
const char * const clks[VIDC_CLKS_NUM_MAX];
|
||||
unsigned int clks_num;
|
||||
const char * const vcodec_clks[VIDC_VCODEC_CLKS_NUM_MAX];
|
||||
const char * const vcodec0_clks[VIDC_VCODEC_CLKS_NUM_MAX];
|
||||
const char * const vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX];
|
||||
unsigned int vcodec_clks_num;
|
||||
|
|
@ -143,6 +144,7 @@ struct venus_format {
|
|||
* @aon_base: AON base address
|
||||
* @irq: Venus irq
|
||||
* @clks: an array of struct clk pointers
|
||||
* @vcodec_clks: an array of vcodec struct clk pointers
|
||||
* @vcodec0_clks: an array of vcodec0 struct clk pointers
|
||||
* @vcodec1_clks: an array of vcodec1 struct clk pointers
|
||||
* @video_path: an interconnect handle to video to/from memory path
|
||||
|
|
@ -197,6 +199,7 @@ struct venus_core {
|
|||
void __iomem *aon_base;
|
||||
int irq;
|
||||
struct clk *clks[VIDC_CLKS_NUM_MAX];
|
||||
struct clk *vcodec_clks[VIDC_VCODEC_CLKS_NUM_MAX];
|
||||
struct clk *vcodec0_clks[VIDC_VCODEC_CLKS_NUM_MAX];
|
||||
struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX];
|
||||
struct icc_path *video_path;
|
||||
|
|
|
|||
|
|
@ -89,12 +89,23 @@ static void core_clks_disable(struct venus_core *core)
|
|||
|
||||
static int core_clks_set_rate(struct venus_core *core, unsigned long freq)
|
||||
{
|
||||
int ret;
|
||||
const struct venus_resources *res = core->res;
|
||||
int ret, i;
|
||||
|
||||
ret = dev_pm_opp_set_rate(core->dev, freq);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!res->vcodec_clks_num)
|
||||
goto set_rates;
|
||||
|
||||
for (i = 0; i < res->vcodec_clks_num; i++) {
|
||||
ret = clk_set_rate(core->vcodec_clks[i], freq);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
set_rates:
|
||||
ret = clk_set_rate(core->vcodec0_clks[0], freq);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -297,10 +308,33 @@ static int load_scale_v1(struct venus_inst *inst)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int vcodec_domains_get_v1(struct venus_core *core)
|
||||
{
|
||||
struct device *dev = core->dev;
|
||||
const struct venus_resources *res = core->res;
|
||||
const struct dev_pm_domain_attach_data vcodec_data = {
|
||||
.pd_names = res->vcodec_pmdomains,
|
||||
.num_pd_names = res->vcodec_pmdomains_num,
|
||||
.pd_flags = PD_FLAG_NO_DEV_LINK,
|
||||
};
|
||||
|
||||
if (!res->vcodec_pmdomains)
|
||||
return 0;
|
||||
|
||||
return devm_pm_domain_attach_list(dev, &vcodec_data,
|
||||
&core->pmdomains);
|
||||
}
|
||||
|
||||
static int core_get_v1(struct venus_core *core)
|
||||
{
|
||||
const struct venus_resources *res = core->res;
|
||||
struct device *dev = core->dev;
|
||||
int ret;
|
||||
|
||||
ret = vcodec_domains_get_v1(core);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = core_clks_get(core);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -309,9 +343,79 @@ static int core_get_v1(struct venus_core *core)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!res->vcodec_pmdomains)
|
||||
return 0;
|
||||
|
||||
ret = vcodec_clks_get(core, dev, core->vcodec_clks,
|
||||
res->vcodec_clks);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vcodec_domains_enable(struct venus_core *core)
|
||||
{
|
||||
const struct venus_resources *res = core->res;
|
||||
struct device *pd_dev;
|
||||
int i = 0, ret;
|
||||
|
||||
if (!res->vcodec_pmdomains)
|
||||
return 0;
|
||||
|
||||
for (; i < res->vcodec_pmdomains_num; i++) {
|
||||
pd_dev = core->pmdomains->pd_devs[i];
|
||||
ret = pm_runtime_resume_and_get(pd_dev);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
while (i--) {
|
||||
pd_dev = core->pmdomains->pd_devs[i];
|
||||
pm_runtime_put_sync(pd_dev);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void vcodec_domains_disable(struct venus_core *core)
|
||||
{
|
||||
const struct venus_resources *res = core->res;
|
||||
struct device *pd_dev;
|
||||
int i = res->vcodec_pmdomains_num;
|
||||
|
||||
if (!res->vcodec_pmdomains)
|
||||
return;
|
||||
|
||||
while (i--) {
|
||||
pd_dev = core->pmdomains->pd_devs[i];
|
||||
pm_runtime_put_sync(pd_dev);
|
||||
}
|
||||
}
|
||||
|
||||
static int vcodec_domains_set_hw(struct venus_core *core, bool is_hw)
|
||||
{
|
||||
const struct venus_resources *res = core->res;
|
||||
struct device *pd_dev;
|
||||
int i = 0, ret;
|
||||
|
||||
for (; i < res->vcodec_pmdomains_num; i++) {
|
||||
pd_dev = core->pmdomains->pd_devs[i];
|
||||
ret = dev_pm_genpd_set_hwmode(pd_dev, is_hw);
|
||||
if (ret && ret != -EOPNOTSUPP)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
while (i--) {
|
||||
pd_dev = core->pmdomains->pd_devs[i];
|
||||
dev_pm_genpd_set_hwmode(pd_dev, !is_hw);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void core_put_v1(struct venus_core *core)
|
||||
{
|
||||
}
|
||||
|
|
@ -320,11 +424,43 @@ static int core_power_v1(struct venus_core *core, int on)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
if (on == POWER_ON)
|
||||
ret = core_clks_enable(core);
|
||||
else
|
||||
core_clks_disable(core);
|
||||
if (on == POWER_ON) {
|
||||
ret = vcodec_domains_enable(core);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = core_clks_enable(core);
|
||||
if (ret)
|
||||
goto fail_pmdomains;
|
||||
|
||||
if (!core->res->vcodec_pmdomains)
|
||||
return 0;
|
||||
|
||||
ret = vcodec_clks_enable(core, core->vcodec_clks);
|
||||
if (ret)
|
||||
goto fail_core_clks;
|
||||
|
||||
ret = vcodec_domains_set_hw(core, true);
|
||||
if (ret)
|
||||
goto fail_vcodec_clks;
|
||||
|
||||
} else {
|
||||
if (core->res->vcodec_pmdomains) {
|
||||
vcodec_domains_set_hw(core, false);
|
||||
vcodec_clks_disable(core, core->vcodec_clks);
|
||||
}
|
||||
core_clks_disable(core);
|
||||
vcodec_domains_disable(core);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail_vcodec_clks:
|
||||
vcodec_clks_disable(core, core->vcodec_clks);
|
||||
fail_core_clks:
|
||||
core_clks_disable(core);
|
||||
fail_pmdomains:
|
||||
vcodec_domains_disable(core);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -875,7 +1011,7 @@ static int venc_power_v4(struct device *dev, int on)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int vcodec_domains_get(struct venus_core *core)
|
||||
static int vcodec_domains_get_v4(struct venus_core *core)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = core->dev;
|
||||
|
|
@ -999,7 +1135,7 @@ static int core_get_v4(struct venus_core *core)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = vcodec_domains_get(core);
|
||||
ret = vcodec_domains_get_v4(core);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user