video: driver: add resource ops macro support

Added call_res_op() macro and used at all possible
places to avoid invalid pointer dereference issue.

Also added changes to cleanup unused functions.

Change-Id: Id77711ad9eaf7b407208567b0fde1f2693588641
Signed-off-by: Govindaraj Rajagopal <quic_grajagop@quicinc.com>
This commit is contained in:
Govindaraj Rajagopal
2022-10-10 10:57:25 +05:30
parent ca9cc59d28
commit 3560442234
17 changed files with 84 additions and 189 deletions

View File

@@ -231,6 +231,5 @@ static inline bool is_mmrm_supported(struct msm_vidc_core *core)
int msm_vidc_init_platform(struct platform_device *pdev); int msm_vidc_init_platform(struct platform_device *pdev);
int msm_vidc_deinit_platform(struct platform_device *pdev); int msm_vidc_deinit_platform(struct platform_device *pdev);
int msm_vidc_read_efuse(struct msm_vidc_core *core);
#endif // _MSM_VIDC_PLATFORM_H_ #endif // _MSM_VIDC_PLATFORM_H_

View File

@@ -6,7 +6,6 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/of.h> #include <linux/of.h>
#include <soc/qcom/of_common.h>
#include "msm_vidc_platform.h" #include "msm_vidc_platform.h"
#include "msm_vidc_debug.h" #include "msm_vidc_debug.h"
@@ -447,51 +446,3 @@ int msm_vidc_init_platform(struct platform_device *pdev)
return rc; return rc;
} }
int msm_vidc_read_efuse(struct msm_vidc_core *core)
{
int rc = 0;
void __iomem *base;
u32 i = 0, efuse = 0, efuse_data_count = 0;
struct msm_vidc_efuse_data *efuse_data = NULL;
struct msm_vidc_platform_data *platform_data;
if (!core || !core->platform || !core->pdev) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
platform_data = &core->platform->data;
efuse_data = platform_data->efuse_data;
efuse_data_count = platform_data->efuse_data_size;
if (!efuse_data)
return 0;
for (i = 0; i < efuse_data_count; i++) {
switch (efuse_data[i].purpose) {
case SKU_VERSION:
base = devm_ioremap(&core->pdev->dev, efuse_data[i].start_address,
efuse_data[i].size);
if (!base) {
d_vpr_e("failed efuse: start %#x, size %d\n",
efuse_data[i].start_address,
efuse_data[i].size);
return -EINVAL;
}
efuse = readl_relaxed(base);
platform_data->sku_version =
(efuse & efuse_data[i].mask) >>
efuse_data[i].shift;
break;
default:
break;
}
if (platform_data->sku_version) {
d_vpr_h("efuse 0x%x, platform version 0x%x\n",
efuse, platform_data->sku_version);
break;
}
}
return rc;
}

View File

@@ -201,9 +201,7 @@ static u32 msm_vidc_decoder_persist_size_iris2(struct msm_vidc_inst *inst)
static u32 msm_vidc_decoder_dpb_size_iris2(struct msm_vidc_inst *inst) static u32 msm_vidc_decoder_dpb_size_iris2(struct msm_vidc_inst *inst)
{ {
u32 size = 0; u32 color_fmt, width, height, size = 0;
u32 color_fmt;
u32 width, height;
struct v4l2_format *f; struct v4l2_format *f;
if (!inst) { if (!inst) {

View File

@@ -249,7 +249,6 @@ static int __setup_ucregion_memory_map_iris2(struct msm_vidc_core *vidc_core)
static int __power_off_iris2_hardware(struct msm_vidc_core *core) static int __power_off_iris2_hardware(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0, i; int rc = 0, i;
u32 value = 0; u32 value = 0;
@@ -322,12 +321,12 @@ static int __power_off_iris2_hardware(struct msm_vidc_core *core)
disable_power: disable_power:
/* power down process */ /* power down process */
rc = res_ops->gdsc_off(core, "vcodec"); rc = call_res_op(core, gdsc_off, core, "vcodec");
if (rc) { if (rc) {
d_vpr_e("%s: disable regulator vcodec failed\n", __func__); d_vpr_e("%s: disable regulator vcodec failed\n", __func__);
rc = 0; rc = 0;
} }
rc = res_ops->clk_disable(core, "vcodec_clk"); rc = call_res_op(core, clk_disable, core, "vcodec_clk");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare vcodec_clk failed\n", __func__); d_vpr_e("%s: disable unprepare vcodec_clk failed\n", __func__);
rc = 0; rc = 0;
@@ -338,7 +337,6 @@ disable_power:
static int __power_off_iris2_controller(struct msm_vidc_core *core) static int __power_off_iris2_controller(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
/* /*
@@ -381,27 +379,27 @@ static int __power_off_iris2_controller(struct msm_vidc_core *core)
d_vpr_h("%s: debug bridge release failed\n", __func__); d_vpr_h("%s: debug bridge release failed\n", __func__);
/* Turn off MVP MVS0C core clock */ /* Turn off MVP MVS0C core clock */
rc = res_ops->clk_disable(core, "core_clk"); rc = call_res_op(core, clk_disable, core, "core_clk");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare core_clk failed\n", __func__); d_vpr_e("%s: disable unprepare core_clk failed\n", __func__);
rc = 0; rc = 0;
} }
/* Disable GCC_VIDEO_AXI0_CLK clock */ /* Disable GCC_VIDEO_AXI0_CLK clock */
rc = res_ops->clk_disable(core, "gcc_video_axi0"); rc = call_res_op(core, clk_disable, core, "gcc_video_axi0");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare gcc_video_axi0 failed\n", __func__); d_vpr_e("%s: disable unprepare gcc_video_axi0 failed\n", __func__);
rc = 0; rc = 0;
} }
rc = res_ops->reset_bridge(core); rc = call_res_op(core, reset_bridge, core);
if (rc) { if (rc) {
d_vpr_e("%s: reset bridge failed\n", __func__); d_vpr_e("%s: reset bridge failed\n", __func__);
rc = 0; rc = 0;
} }
/* power down process */ /* power down process */
rc = res_ops->gdsc_off(core, "iris-ctl"); rc = call_res_op(core, gdsc_off, core, "iris-ctl");
if (rc) { if (rc) {
d_vpr_e("%s: disable regulator iris-ctl failed\n", __func__); d_vpr_e("%s: disable regulator iris-ctl failed\n", __func__);
rc = 0; rc = 0;
@@ -412,7 +410,6 @@ static int __power_off_iris2_controller(struct msm_vidc_core *core)
static int __power_off_iris2(struct msm_vidc_core *core) static int __power_off_iris2(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core || !core->capabilities) { if (!core || !core->capabilities) {
@@ -427,7 +424,7 @@ static int __power_off_iris2(struct msm_vidc_core *core)
* Reset video_cc_mvs0_clk_src value to resolve MMRM high video * Reset video_cc_mvs0_clk_src value to resolve MMRM high video
* clock projection issue. * clock projection issue.
*/ */
rc = res_ops->set_clks(core, 0); rc = call_res_op(core, set_clks, core, 0);
if (rc) if (rc)
d_vpr_e("%s: resetting clocks failed\n", __func__); d_vpr_e("%s: resetting clocks failed\n", __func__);
@@ -437,7 +434,8 @@ static int __power_off_iris2(struct msm_vidc_core *core)
if (__power_off_iris2_controller(core)) if (__power_off_iris2_controller(core))
d_vpr_e("%s: failed to power off controller\n", __func__); d_vpr_e("%s: failed to power off controller\n", __func__);
if (res_ops->set_bw(core, 0, 0)) rc = call_res_op(core, set_bw, core, 0, 0);
if (rc)
d_vpr_e("%s: failed to unvote buses\n", __func__); d_vpr_e("%s: failed to unvote buses\n", __func__);
if (!(core->intr_status & WRAPPER_INTR_STATUS_A2HWD_BMSK_IRIS2)) if (!(core->intr_status & WRAPPER_INTR_STATUS_A2HWD_BMSK_IRIS2))
@@ -451,60 +449,57 @@ static int __power_off_iris2(struct msm_vidc_core *core)
static int __power_on_iris2_controller(struct msm_vidc_core *core) static int __power_on_iris2_controller(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
rc = res_ops->gdsc_on(core, "iris-ctl"); rc = call_res_op(core, gdsc_on, core, "iris-ctl");
if (rc) if (rc)
goto fail_regulator; goto fail_regulator;
rc = res_ops->reset_bridge(core); rc = call_res_op(core, reset_bridge, core);
if (rc) if (rc)
goto fail_reset_ahb2axi; goto fail_reset_ahb2axi;
rc = res_ops->clk_enable(core, "gcc_video_axi0"); rc = call_res_op(core, clk_enable, core, "gcc_video_axi0");
if (rc) if (rc)
goto fail_clk_axi; goto fail_clk_axi;
rc = res_ops->clk_enable(core, "core_clk"); rc = call_res_op(core, clk_enable, core, "core_clk");
if (rc) if (rc)
goto fail_clk_controller; goto fail_clk_controller;
return 0; return 0;
fail_clk_controller: fail_clk_controller:
res_ops->clk_disable(core, "gcc_video_axi0"); call_res_op(core, clk_disable, core, "gcc_video_axi0");
fail_clk_axi: fail_clk_axi:
fail_reset_ahb2axi: fail_reset_ahb2axi:
res_ops->gdsc_off(core, "iris-ctl"); call_res_op(core, gdsc_off, core, "iris-ctl");
fail_regulator: fail_regulator:
return rc; return rc;
} }
static int __power_on_iris2_hardware(struct msm_vidc_core *core) static int __power_on_iris2_hardware(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
rc = res_ops->gdsc_on(core, "vcodec"); rc = call_res_op(core, gdsc_on, core, "vcodec");
if (rc) if (rc)
goto fail_regulator; goto fail_regulator;
rc = res_ops->clk_enable(core, "vcodec_clk"); rc = call_res_op(core, clk_enable, core, "vcodec_clk");
if (rc) if (rc)
goto fail_clk_controller; goto fail_clk_controller;
return 0; return 0;
fail_clk_controller: fail_clk_controller:
res_ops->gdsc_off(core, "vcodec"); call_res_op(core, gdsc_off, core, "vcodec");
fail_regulator: fail_regulator:
return rc; return rc;
} }
static int __power_on_iris2(struct msm_vidc_core *core) static int __power_on_iris2(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
struct frequency_table *freq_tbl; struct frequency_table *freq_tbl;
u32 freq = 0; u32 freq = 0;
int rc = 0; int rc = 0;
@@ -513,7 +508,7 @@ static int __power_on_iris2(struct msm_vidc_core *core)
return 0; return 0;
/* Vote for all hardware resources */ /* Vote for all hardware resources */
rc = res_ops->set_bw(core, INT_MAX, INT_MAX); rc = call_res_op(core, set_bw, core, INT_MAX, INT_MAX);
if (rc) { if (rc) {
d_vpr_e("%s: failed to vote buses, rc %d\n", __func__, rc); d_vpr_e("%s: failed to vote buses, rc %d\n", __func__, rc);
goto fail_vote_buses; goto fail_vote_buses;
@@ -537,7 +532,7 @@ static int __power_on_iris2(struct msm_vidc_core *core)
freq = core->power.clk_freq ? core->power.clk_freq : freq = core->power.clk_freq ? core->power.clk_freq :
freq_tbl[0].freq; freq_tbl[0].freq;
rc = res_ops->set_clks(core, freq); rc = call_res_op(core, set_clks, core, freq);
if (rc) { if (rc) {
d_vpr_e("%s: failed to scale clocks\n", __func__); d_vpr_e("%s: failed to scale clocks\n", __func__);
rc = 0; rc = 0;
@@ -560,7 +555,7 @@ static int __power_on_iris2(struct msm_vidc_core *core)
fail_power_on_hardware: fail_power_on_hardware:
__power_off_iris2_controller(core); __power_off_iris2_controller(core);
fail_power_on_controller: fail_power_on_controller:
res_ops->set_bw(core, 0, 0); call_res_op(core, set_bw, core, 0, 0);
fail_vote_buses: fail_vote_buses:
core->power_enabled = false; core->power_enabled = false;
return rc; return rc;

View File

@@ -269,7 +269,6 @@ static bool is_iris3_hw_power_collapsed(struct msm_vidc_core *core)
static int __power_off_iris3_hardware(struct msm_vidc_core *core) static int __power_off_iris3_hardware(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0, i; int rc = 0, i;
u32 value = 0; u32 value = 0;
bool pwr_collapsed = false; bool pwr_collapsed = false;
@@ -361,13 +360,13 @@ static int __power_off_iris3_hardware(struct msm_vidc_core *core)
disable_power: disable_power:
/* power down process */ /* power down process */
rc = res_ops->gdsc_off(core, "vcodec"); rc = call_res_op(core, gdsc_off, core, "vcodec");
if (rc) { if (rc) {
d_vpr_e("%s: disable regulator vcodec failed\n", __func__); d_vpr_e("%s: disable regulator vcodec failed\n", __func__);
rc = 0; rc = 0;
} }
rc = res_ops->clk_disable(core, "vcodec_clk"); rc = call_res_op(core, clk_disable, core, "vcodec_clk");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare vcodec_clk failed\n", __func__); d_vpr_e("%s: disable unprepare vcodec_clk failed\n", __func__);
rc = 0; rc = 0;
@@ -378,7 +377,6 @@ disable_power:
static int __power_off_iris3_controller(struct msm_vidc_core *core) static int __power_off_iris3_controller(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
/* /*
@@ -439,14 +437,14 @@ static int __power_off_iris3_controller(struct msm_vidc_core *core)
return rc; return rc;
/* Turn off MVP MVS0C core clock */ /* Turn off MVP MVS0C core clock */
rc = res_ops->clk_disable(core, "core_clk"); rc = call_res_op(core, clk_disable, core, "core_clk");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare core_clk failed\n", __func__); d_vpr_e("%s: disable unprepare core_clk failed\n", __func__);
rc = 0; rc = 0;
} }
/* power down process */ /* power down process */
rc = res_ops->gdsc_off(core, "iris-ctl"); rc = call_res_op(core, gdsc_off, core, "iris-ctl");
if (rc) { if (rc) {
d_vpr_e("%s: disable regulator iris-ctl failed\n", __func__); d_vpr_e("%s: disable regulator iris-ctl failed\n", __func__);
rc = 0; rc = 0;
@@ -457,7 +455,6 @@ static int __power_off_iris3_controller(struct msm_vidc_core *core)
static int __power_off_iris3(struct msm_vidc_core *core) static int __power_off_iris3(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core || !core->capabilities) { if (!core || !core->capabilities) {
@@ -472,7 +469,7 @@ static int __power_off_iris3(struct msm_vidc_core *core)
* Reset video_cc_mvs0_clk_src value to resolve MMRM high video * Reset video_cc_mvs0_clk_src value to resolve MMRM high video
* clock projection issue. * clock projection issue.
*/ */
rc = res_ops->set_clks(core, 0); rc = call_res_op(core, set_clks, core, 0);
if (rc) if (rc)
d_vpr_e("%s: resetting clocks failed\n", __func__); d_vpr_e("%s: resetting clocks failed\n", __func__);
@@ -482,7 +479,8 @@ static int __power_off_iris3(struct msm_vidc_core *core)
if (__power_off_iris3_controller(core)) if (__power_off_iris3_controller(core))
d_vpr_e("%s: failed to power off controller\n", __func__); d_vpr_e("%s: failed to power off controller\n", __func__);
if (res_ops->set_bw(core, 0, 0)) rc = call_res_op(core, set_bw, core, 0, 0);
if (rc)
d_vpr_e("%s: failed to unvote buses\n", __func__); d_vpr_e("%s: failed to unvote buses\n", __func__);
if (!(core->intr_status & WRAPPER_INTR_STATUS_A2HWD_BMSK_IRIS3)) if (!(core->intr_status & WRAPPER_INTR_STATUS_A2HWD_BMSK_IRIS3))
@@ -496,60 +494,57 @@ static int __power_off_iris3(struct msm_vidc_core *core)
static int __power_on_iris3_controller(struct msm_vidc_core *core) static int __power_on_iris3_controller(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
rc = res_ops->gdsc_on(core, "iris-ctl"); rc = call_res_op(core, gdsc_on, core, "iris-ctl");
if (rc) if (rc)
goto fail_regulator; goto fail_regulator;
rc = res_ops->reset_bridge(core); rc = call_res_op(core, reset_bridge, core);
if (rc) if (rc)
goto fail_reset_ahb2axi; goto fail_reset_ahb2axi;
rc = res_ops->clk_enable(core, "gcc_video_axi0"); rc = call_res_op(core, clk_enable, core, "gcc_video_axi0");
if (rc) if (rc)
goto fail_clk_axi; goto fail_clk_axi;
rc = res_ops->clk_enable(core, "core_clk"); rc = call_res_op(core, clk_enable, core, "core_clk");
if (rc) if (rc)
goto fail_clk_controller; goto fail_clk_controller;
return 0; return 0;
fail_clk_controller: fail_clk_controller:
res_ops->clk_disable(core, "gcc_video_axi0"); call_res_op(core, clk_disable, core, "gcc_video_axi0");
fail_clk_axi: fail_clk_axi:
fail_reset_ahb2axi: fail_reset_ahb2axi:
res_ops->gdsc_off(core, "iris-ctl"); call_res_op(core, gdsc_off, core, "iris-ctl");
fail_regulator: fail_regulator:
return rc; return rc;
} }
static int __power_on_iris3_hardware(struct msm_vidc_core *core) static int __power_on_iris3_hardware(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
rc = res_ops->gdsc_on(core, "vcodec"); rc = call_res_op(core, gdsc_on, core, "vcodec");
if (rc) if (rc)
goto fail_regulator; goto fail_regulator;
rc = res_ops->clk_enable(core, "vcodec_clk"); rc = call_res_op(core, clk_enable, core, "vcodec_clk");
if (rc) if (rc)
goto fail_clk_controller; goto fail_clk_controller;
return 0; return 0;
fail_clk_controller: fail_clk_controller:
res_ops->gdsc_off(core, "vcodec"); call_res_op(core, gdsc_off, core, "vcodec");
fail_regulator: fail_regulator:
return rc; return rc;
} }
static int __power_on_iris3(struct msm_vidc_core *core) static int __power_on_iris3(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
struct frequency_table *freq_tbl; struct frequency_table *freq_tbl;
u32 freq = 0; u32 freq = 0;
int rc = 0; int rc = 0;
@@ -558,7 +553,7 @@ static int __power_on_iris3(struct msm_vidc_core *core)
return 0; return 0;
/* Vote for all hardware resources */ /* Vote for all hardware resources */
rc = res_ops->set_bw(core, INT_MAX, INT_MAX); rc = call_res_op(core, set_bw, core, INT_MAX, INT_MAX);
if (rc) { if (rc) {
d_vpr_e("%s: failed to vote buses, rc %d\n", __func__, rc); d_vpr_e("%s: failed to vote buses, rc %d\n", __func__, rc);
goto fail_vote_buses; goto fail_vote_buses;
@@ -582,7 +577,7 @@ static int __power_on_iris3(struct msm_vidc_core *core)
freq = core->power.clk_freq ? core->power.clk_freq : freq = core->power.clk_freq ? core->power.clk_freq :
freq_tbl[0].freq; freq_tbl[0].freq;
rc = res_ops->set_clks(core, freq); rc = call_res_op(core, set_clks, core, freq);
if (rc) { if (rc) {
d_vpr_e("%s: failed to scale clocks\n", __func__); d_vpr_e("%s: failed to scale clocks\n", __func__);
rc = 0; rc = 0;
@@ -602,7 +597,7 @@ static int __power_on_iris3(struct msm_vidc_core *core)
fail_power_on_hardware: fail_power_on_hardware:
__power_off_iris3_controller(core); __power_off_iris3_controller(core);
fail_power_on_controller: fail_power_on_controller:
res_ops->set_bw(core, 0, 0); call_res_op(core, set_bw, core, 0, 0);
fail_vote_buses: fail_vote_buses:
core->power_enabled = false; core->power_enabled = false;
return rc; return rc;

View File

@@ -265,7 +265,6 @@ static u64 __calculate_decoder(struct vidc_bus_vote_data *d)
/* Derived parameters */ /* Derived parameters */
int lcu_per_frame, collocated_bytes_per_lcu, tnbr_per_lcu; int lcu_per_frame, collocated_bytes_per_lcu, tnbr_per_lcu;
unsigned long bitrate; unsigned long bitrate;
unsigned int num_vpp_pipes;
fp_t bins_to_bit_factor, vsp_read_factor, vsp_write_factor, fp_t bins_to_bit_factor, vsp_read_factor, vsp_write_factor,
dpb_factor, dpb_write_factor, y_bw_no_ubwc_8bpp; dpb_factor, dpb_write_factor, y_bw_no_ubwc_8bpp;
@@ -317,8 +316,6 @@ static u64 __calculate_decoder(struct vidc_bus_vote_data *d)
opb_write_compression_factor = opb_compression_enabled ? opb_write_compression_factor = opb_compression_enabled ?
dpb_write_compression_factor : FP_ONE; dpb_write_compression_factor : FP_ONE;
num_vpp_pipes = d->num_vpp_pipes;
if (d->use_sys_cache) { if (d->use_sys_cache) {
llc_ref_read_l2_cache_enabled = true; llc_ref_read_l2_cache_enabled = true;
if (is_h264_category) if (is_h264_category)

View File

@@ -280,7 +280,6 @@ static bool is_iris33_hw_power_collapsed(struct msm_vidc_core *core)
static int __power_off_iris33_hardware(struct msm_vidc_core *core) static int __power_off_iris33_hardware(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0, i; int rc = 0, i;
u32 value = 0; u32 value = 0;
bool pwr_collapsed = false; bool pwr_collapsed = false;
@@ -368,13 +367,13 @@ static int __power_off_iris33_hardware(struct msm_vidc_core *core)
disable_power: disable_power:
/* power down process */ /* power down process */
rc = res_ops->gdsc_off(core, "vcodec"); rc = call_res_op(core, gdsc_off, core, "vcodec");
if (rc) { if (rc) {
d_vpr_e("%s: disable regulator vcodec failed\n", __func__); d_vpr_e("%s: disable regulator vcodec failed\n", __func__);
rc = 0; rc = 0;
} }
rc = res_ops->clk_disable(core, "vcodec_clk"); rc = call_res_op(core, clk_disable, core, "vcodec_clk");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare vcodec_clk failed\n", __func__); d_vpr_e("%s: disable unprepare vcodec_clk failed\n", __func__);
rc = 0; rc = 0;
@@ -385,7 +384,6 @@ disable_power:
static int __power_off_iris33_controller(struct msm_vidc_core *core) static int __power_off_iris33_controller(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
int value = 0; int value = 0;
@@ -493,21 +491,21 @@ static int __power_off_iris33_controller(struct msm_vidc_core *core)
/* Turn off MVP MVS0C core clock */ /* Turn off MVP MVS0C core clock */
rc = res_ops->clk_disable(core, "core_clk"); rc = call_res_op(core, clk_disable, core, "core_clk");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare core_clk failed\n", __func__); d_vpr_e("%s: disable unprepare core_clk failed\n", __func__);
rc = 0; rc = 0;
} }
/* power down process */ /* power down process */
rc = res_ops->gdsc_off(core, "iris-ctl"); rc = call_res_op(core, gdsc_off, core, "iris-ctl");
if (rc) { if (rc) {
d_vpr_e("%s: disable regulator iris-ctl failed\n", __func__); d_vpr_e("%s: disable regulator iris-ctl failed\n", __func__);
rc = 0; rc = 0;
} }
/* Turn off GCC AXI clock */ /* Turn off GCC AXI clock */
rc = res_ops->clk_disable(core, "gcc_video_axi0"); rc = call_res_op(core, clk_disable, core, "gcc_video_axi0");
if (rc) { if (rc) {
d_vpr_e("%s: disable unprepare core_clk failed\n", __func__); d_vpr_e("%s: disable unprepare core_clk failed\n", __func__);
rc = 0; rc = 0;
@@ -518,7 +516,6 @@ static int __power_off_iris33_controller(struct msm_vidc_core *core)
static int __power_off_iris33(struct msm_vidc_core *core) static int __power_off_iris33(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core || !core->capabilities) { if (!core || !core->capabilities) {
@@ -533,7 +530,7 @@ static int __power_off_iris33(struct msm_vidc_core *core)
* Reset video_cc_mvs0_clk_src value to resolve MMRM high video * Reset video_cc_mvs0_clk_src value to resolve MMRM high video
* clock projection issue. * clock projection issue.
*/ */
rc = res_ops->set_clks(core, 0); rc = call_res_op(core, set_clks, core, 0);
if (rc) if (rc)
d_vpr_e("%s: resetting clocks failed\n", __func__); d_vpr_e("%s: resetting clocks failed\n", __func__);
@@ -543,7 +540,8 @@ static int __power_off_iris33(struct msm_vidc_core *core)
if (__power_off_iris33_controller(core)) if (__power_off_iris33_controller(core))
d_vpr_e("%s: failed to power off controller\n", __func__); d_vpr_e("%s: failed to power off controller\n", __func__);
if (res_ops->set_bw(core, 0, 0)) rc = call_res_op(core, set_bw, core, 0, 0);
if (rc)
d_vpr_e("%s: failed to unvote buses\n", __func__); d_vpr_e("%s: failed to unvote buses\n", __func__);
if (!(core->intr_status & WRAPPER_INTR_STATUS_A2HWD_BMSK_IRIS33)) if (!(core->intr_status & WRAPPER_INTR_STATUS_A2HWD_BMSK_IRIS33))
@@ -557,60 +555,57 @@ static int __power_off_iris33(struct msm_vidc_core *core)
static int __power_on_iris33_controller(struct msm_vidc_core *core) static int __power_on_iris33_controller(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
rc = res_ops->gdsc_on(core, "iris-ctl"); rc = call_res_op(core, gdsc_on, core, "iris-ctl");
if (rc) if (rc)
goto fail_regulator; goto fail_regulator;
rc = res_ops->reset_bridge(core); rc = call_res_op(core, reset_bridge, core);
if (rc) if (rc)
goto fail_reset_ahb2axi; goto fail_reset_ahb2axi;
rc = res_ops->clk_enable(core, "gcc_video_axi0"); rc = call_res_op(core, clk_enable, core, "gcc_video_axi0");
if (rc) if (rc)
goto fail_clk_axi; goto fail_clk_axi;
rc = res_ops->clk_enable(core, "core_clk"); rc = call_res_op(core, clk_enable, core, "core_clk");
if (rc) if (rc)
goto fail_clk_controller; goto fail_clk_controller;
return 0; return 0;
fail_clk_controller: fail_clk_controller:
res_ops->clk_disable(core, "gcc_video_axi0"); call_res_op(core, clk_disable, core, "gcc_video_axi0");
fail_clk_axi: fail_clk_axi:
fail_reset_ahb2axi: fail_reset_ahb2axi:
res_ops->gdsc_off(core, "iris-ctl"); call_res_op(core, gdsc_off, core, "iris-ctl");
fail_regulator: fail_regulator:
return rc; return rc;
} }
static int __power_on_iris33_hardware(struct msm_vidc_core *core) static int __power_on_iris33_hardware(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
rc = res_ops->gdsc_on(core, "vcodec"); rc = call_res_op(core, gdsc_on, core, "vcodec");
if (rc) if (rc)
goto fail_regulator; goto fail_regulator;
rc = res_ops->clk_enable(core, "vcodec_clk"); rc = call_res_op(core, clk_enable, core, "vcodec_clk");
if (rc) if (rc)
goto fail_clk_controller; goto fail_clk_controller;
return 0; return 0;
fail_clk_controller: fail_clk_controller:
res_ops->gdsc_off(core, "vcodec"); call_res_op(core, gdsc_off, core, "vcodec");
fail_regulator: fail_regulator:
return rc; return rc;
} }
static int __power_on_iris33(struct msm_vidc_core *core) static int __power_on_iris33(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
struct frequency_table *freq_tbl; struct frequency_table *freq_tbl;
u32 freq = 0; u32 freq = 0;
int rc = 0; int rc = 0;
@@ -619,7 +614,7 @@ static int __power_on_iris33(struct msm_vidc_core *core)
return 0; return 0;
/* Vote for all hardware resources */ /* Vote for all hardware resources */
rc = res_ops->set_bw(core, INT_MAX, INT_MAX); rc = call_res_op(core, set_bw, core, INT_MAX, INT_MAX);
if (rc) { if (rc) {
d_vpr_e("%s: failed to vote buses, rc %d\n", __func__, rc); d_vpr_e("%s: failed to vote buses, rc %d\n", __func__, rc);
goto fail_vote_buses; goto fail_vote_buses;
@@ -643,7 +638,7 @@ static int __power_on_iris33(struct msm_vidc_core *core)
freq = core->power.clk_freq ? core->power.clk_freq : freq = core->power.clk_freq ? core->power.clk_freq :
freq_tbl[0].freq; freq_tbl[0].freq;
rc = res_ops->set_clks(core, freq); rc = call_res_op(core, set_clks, core, freq);
if (rc) { if (rc) {
d_vpr_e("%s: failed to scale clocks\n", __func__); d_vpr_e("%s: failed to scale clocks\n", __func__);
rc = 0; rc = 0;
@@ -663,7 +658,7 @@ static int __power_on_iris33(struct msm_vidc_core *core)
fail_power_on_hardware: fail_power_on_hardware:
__power_off_iris33_controller(core); __power_off_iris33_controller(core);
fail_power_on_controller: fail_power_on_controller:
res_ops->set_bw(core, 0, 0); call_res_op(core, set_bw, core, 0, 0);
fail_vote_buses: fail_vote_buses:
core->power_enabled = false; core->power_enabled = false;
return rc; return rc;

View File

@@ -264,7 +264,6 @@ static u64 __calculate_decoder(struct vidc_bus_vote_data *d)
/* Derived parameters */ /* Derived parameters */
int lcu_per_frame, collocated_bytes_per_lcu, tnbr_per_lcu; int lcu_per_frame, collocated_bytes_per_lcu, tnbr_per_lcu;
unsigned long bitrate; unsigned long bitrate;
unsigned int num_vpp_pipes;
fp_t bins_to_bit_factor, vsp_read_factor, vsp_write_factor, fp_t bins_to_bit_factor, vsp_read_factor, vsp_write_factor,
dpb_factor, dpb_write_factor, y_bw_no_ubwc_8bpp; dpb_factor, dpb_write_factor, y_bw_no_ubwc_8bpp;
@@ -316,8 +315,6 @@ static u64 __calculate_decoder(struct vidc_bus_vote_data *d)
opb_write_compression_factor = opb_compression_enabled ? opb_write_compression_factor = opb_compression_enabled ?
dpb_write_compression_factor : FP_ONE; dpb_write_compression_factor : FP_ONE;
num_vpp_pipes = d->num_vpp_pipes;
if (d->use_sys_cache) { if (d->use_sys_cache) {
llc_ref_read_l2_cache_enabled = true; llc_ref_read_l2_cache_enabled = true;
if (is_h264_category) if (is_h264_category)

View File

@@ -115,8 +115,6 @@ int msm_vidc_set_preprocess(void *instance,
enum msm_vidc_inst_capability_type cap_id); enum msm_vidc_inst_capability_type cap_id);
int msm_vidc_set_reserve_duration(void *instance, int msm_vidc_set_reserve_duration(void *instance,
enum msm_vidc_inst_capability_type cap_id); enum msm_vidc_inst_capability_type cap_id);
int msm_vidc_set_u32_enum(void *instance,
enum msm_vidc_inst_capability_type cap_id);
int msm_vidc_set_q16(void *instance, int msm_vidc_set_q16(void *instance,
enum msm_vidc_inst_capability_type cap_id); enum msm_vidc_inst_capability_type cap_id);
int msm_vidc_v4l2_menu_to_hfi(struct msm_vidc_inst *inst, int msm_vidc_v4l2_menu_to_hfi(struct msm_vidc_inst *inst,

View File

@@ -251,7 +251,6 @@ static inline int __bpp(enum msm_vidc_colorformat_type f)
u64 msm_vidc_max_freq(struct msm_vidc_inst* inst); u64 msm_vidc_max_freq(struct msm_vidc_inst* inst);
int msm_vidc_get_inst_load(struct msm_vidc_inst *inst); int msm_vidc_get_inst_load(struct msm_vidc_inst *inst);
int msm_vidc_get_mbps(struct msm_vidc_inst *inst);
int msm_vidc_scale_power(struct msm_vidc_inst *inst, bool scale_buses); int msm_vidc_scale_power(struct msm_vidc_inst *inst, bool scale_buses);
void msm_vidc_power_data_reset(struct msm_vidc_inst *inst); void msm_vidc_power_data_reset(struct msm_vidc_inst *inst);
#endif #endif

View File

@@ -197,6 +197,10 @@ struct msm_vidc_resource {
int fw_cookie; int fw_cookie;
}; };
#define call_res_op(c, op, ...) \
(((c) && (c)->res_ops && (c)->res_ops->op) ? \
((c)->res_ops->op(__VA_ARGS__)) : 0)
struct msm_vidc_resources_ops { struct msm_vidc_resources_ops {
int (*init)(struct msm_vidc_core *core); int (*init)(struct msm_vidc_core *core);

View File

@@ -2186,8 +2186,6 @@ int msm_vdec_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat; f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width; f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height; f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
pix_fmt = v4l2_colorformat_to_driver(inst,
f->fmt.pix_mp.pixelformat, __func__);
} }
if (inst->bufq[INPUT_PORT].vb2q->streaming) { if (inst->bufq[INPUT_PORT].vb2q->streaming) {
f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height; f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;

View File

@@ -591,13 +591,11 @@ static int msm_venc_queue_input_internal_buffers(struct msm_vidc_inst *inst)
static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst) static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst)
{ {
int i, rc = 0; int i, rc = 0;
struct msm_vidc_core *core;
if (!inst || !inst->core) { if (!inst) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
core = inst->core;
for (i = 0; i < ARRAY_SIZE(msm_venc_output_internal_buffer_type); i++) { for (i = 0; i < ARRAY_SIZE(msm_venc_output_internal_buffer_type); i++) {
rc = msm_vidc_get_internal_buffers(inst, rc = msm_vidc_get_internal_buffers(inst,
@@ -693,16 +691,14 @@ static int msm_venc_metadata_delivery(struct msm_vidc_inst *inst,
enum msm_vidc_port_type port) enum msm_vidc_port_type port)
{ {
int rc = 0; int rc = 0;
struct msm_vidc_core *core;
u32 payload[32] = {0}; u32 payload[32] = {0};
u32 i, count = 0; u32 i, count = 0;
struct msm_vidc_inst_capability *capability; struct msm_vidc_inst_capability *capability;
if (!inst || !inst->core) { if (!inst) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
core = inst->core;
i_vpr_h(inst, "%s()\n", __func__); i_vpr_h(inst, "%s()\n", __func__);
capability = inst->capabilities; capability = inst->capabilities;
@@ -1047,7 +1043,6 @@ int msm_venc_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width; f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height; f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat; f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
pix_fmt = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
} }
} else if (f->type == INPUT_META_PLANE) { } else if (f->type == INPUT_META_PLANE) {
f->fmt.meta.dataformat = inst->fmts[INPUT_META_PORT].fmt.meta.dataformat; f->fmt.meta.dataformat = inst->fmts[INPUT_META_PORT].fmt.meta.dataformat;

View File

@@ -6398,14 +6398,12 @@ static int msm_vidc_check_inst_mbpf(struct msm_vidc_inst *inst)
u32 msm_vidc_get_max_bitrate(struct msm_vidc_inst* inst) u32 msm_vidc_get_max_bitrate(struct msm_vidc_inst* inst)
{ {
struct msm_vidc_inst_capability *capability;
u32 max_bitrate = 0x7fffffff; u32 max_bitrate = 0x7fffffff;
if (!inst || !inst->capabilities) { if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
capability = inst->capabilities;
if (inst->capabilities->cap[LOWLATENCY_MODE].value) if (inst->capabilities->cap[LOWLATENCY_MODE].value)
max_bitrate = min(max_bitrate, max_bitrate = min(max_bitrate,

View File

@@ -112,20 +112,8 @@ u64 msm_vidc_max_freq(struct msm_vidc_inst *inst)
return freq; return freq;
} }
int msm_vidc_get_mbps(struct msm_vidc_inst *inst)
{
u32 mbpf, fps, input_rate;
mbpf = msm_vidc_get_mbs_per_frame(inst);
fps = msm_vidc_get_fps(inst);
input_rate = msm_vidc_get_input_rate(inst);
return mbpf * max(fps, input_rate);
}
int msm_vidc_get_inst_load(struct msm_vidc_inst *inst) int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
{ {
int load = 0;
u32 mbpf, fps; u32 mbpf, fps;
u32 frame_rate, operating_rate, input_rate, timestamp_rate; u32 frame_rate, operating_rate, input_rate, timestamp_rate;
@@ -136,7 +124,7 @@ int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
/* return zero load for thumbnail and NRT session */ /* return zero load for thumbnail and NRT session */
if (is_thumbnail_session(inst) || !is_realtime_session(inst)) if (is_thumbnail_session(inst) || !is_realtime_session(inst))
return load; return 0;
/* calculate load for RT session */ /* calculate load for RT session */
mbpf = msm_vidc_get_mbs_per_frame(inst); mbpf = msm_vidc_get_mbs_per_frame(inst);
@@ -151,7 +139,7 @@ int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
fps = max(fps, timestamp_rate); fps = max(fps, timestamp_rate);
} }
return load = mbpf * fps; return mbpf * fps;
} }
static int fill_dynamic_stats(struct msm_vidc_inst *inst, static int fill_dynamic_stats(struct msm_vidc_inst *inst,

View File

@@ -51,7 +51,6 @@ static inline bool is_video_context_bank_device(struct device *dev)
static int msm_vidc_init_resources(struct msm_vidc_core *core) static int msm_vidc_init_resources(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops;
struct msm_vidc_resource *res = NULL; struct msm_vidc_resource *res = NULL;
int rc = 0; int rc = 0;
@@ -59,7 +58,6 @@ static int msm_vidc_init_resources(struct msm_vidc_core *core)
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
res_ops = core->res_ops;
res = devm_kzalloc(&core->pdev->dev, sizeof(*res), GFP_KERNEL); res = devm_kzalloc(&core->pdev->dev, sizeof(*res), GFP_KERNEL);
if (!res) { if (!res) {
@@ -69,7 +67,7 @@ static int msm_vidc_init_resources(struct msm_vidc_core *core)
res->core = core; res->core = core;
core->resource = res; core->resource = res;
rc = res_ops->init(core); rc = call_res_op(core, init, core);
if (rc) { if (rc) {
d_vpr_e("%s: Failed to init resources: %d\n", __func__, rc); d_vpr_e("%s: Failed to init resources: %d\n", __func__, rc);
return rc; return rc;

View File

@@ -444,7 +444,6 @@ static int __release_subcaches(struct msm_vidc_core *core)
static int __set_subcaches(struct msm_vidc_core *core) static int __set_subcaches(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
struct subcache_info *sinfo; struct subcache_info *sinfo;
struct hfi_buffer buf; struct hfi_buffer buf;
@@ -504,7 +503,7 @@ static int __set_subcaches(struct msm_vidc_core *core)
return 0; return 0;
err_fail_set_subacaches: err_fail_set_subacaches:
res_ops->llcc(core, false); call_res_op(core, llcc, core, false);
return rc; return rc;
} }
@@ -567,7 +566,6 @@ static int __venus_power_on(struct msm_vidc_core *core)
static int __suspend(struct msm_vidc_core *core) static int __suspend(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core) { if (!core) {
@@ -590,7 +588,7 @@ static int __suspend(struct msm_vidc_core *core)
goto err_tzbsp_suspend; goto err_tzbsp_suspend;
} }
res_ops->llcc(core, false); call_res_op(core, llcc, core, false);
__venus_power_off(core); __venus_power_off(core);
d_vpr_h("Venus power off\n"); d_vpr_h("Venus power off\n");
@@ -602,7 +600,6 @@ err_tzbsp_suspend:
static int __resume(struct msm_vidc_core *core) static int __resume(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core) { if (!core) {
@@ -642,7 +639,7 @@ static int __resume(struct msm_vidc_core *core)
* (s/w triggered) to fast (HW triggered) unless the h/w vote is * (s/w triggered) to fast (HW triggered) unless the h/w vote is
* present. * present.
*/ */
res_ops->gdsc_hw_ctrl(core); call_res_op(core, gdsc_hw_ctrl, core);
/* Wait for boot completion */ /* Wait for boot completion */
rc = call_venus_op(core, boot_firmware, core); rc = call_venus_op(core, boot_firmware, core);
@@ -653,7 +650,7 @@ static int __resume(struct msm_vidc_core *core)
__sys_set_debug(core, (msm_vidc_debug & FW_LOGMASK) >> FW_LOGSHIFT); __sys_set_debug(core, (msm_vidc_debug & FW_LOGMASK) >> FW_LOGSHIFT);
rc = res_ops->llcc(core, true); rc = call_res_op(core, llcc, core, true);
if (rc) { if (rc) {
d_vpr_e("Failed to activate subcache\n"); d_vpr_e("Failed to activate subcache\n");
goto err_reset_core; goto err_reset_core;
@@ -663,7 +660,7 @@ static int __resume(struct msm_vidc_core *core)
rc = __sys_set_power_control(core, true); rc = __sys_set_power_control(core, true);
if (rc) { if (rc) {
d_vpr_e("%s: set power control failed\n", __func__); d_vpr_e("%s: set power control failed\n", __func__);
res_ops->gdsc_sw_ctrl(core); call_res_op(core, gdsc_sw_ctrl, core);
rc = 0; rc = 0;
} }
@@ -684,7 +681,6 @@ err_venus_power_on:
int __load_fw(struct msm_vidc_core *core) int __load_fw(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
d_vpr_h("%s\n", __func__); d_vpr_h("%s\n", __func__);
@@ -709,7 +705,7 @@ int __load_fw(struct msm_vidc_core *core)
* (s/w triggered) to fast (HW triggered) unless the h/w vote is * (s/w triggered) to fast (HW triggered) unless the h/w vote is
* present. * present.
*/ */
res_ops->gdsc_hw_ctrl(core); call_res_op(core, gdsc_hw_ctrl, core);
trace_msm_v4l2_vidc_fw_load("END"); trace_msm_v4l2_vidc_fw_load("END");
return rc; return rc;
@@ -722,13 +718,11 @@ fail_power:
void __unload_fw(struct msm_vidc_core *core) void __unload_fw(struct msm_vidc_core *core)
{ {
int rc = 0;
if (!core->resource->fw_cookie) if (!core->resource->fw_cookie)
return; return;
cancel_delayed_work(&core->pm_work); cancel_delayed_work(&core->pm_work);
rc = fw_unload(core); fw_unload(core);
__venus_power_off(core); __venus_power_off(core);
core->cpu_watchdog = false; core->cpu_watchdog = false;
@@ -891,13 +885,13 @@ static int __sys_image_version(struct msm_vidc_core *core)
int venus_hfi_core_init(struct msm_vidc_core *core) int venus_hfi_core_init(struct msm_vidc_core *core)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core) { if (!core) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
d_vpr_h("%s(): core %pK\n", __func__, core); d_vpr_h("%s(): core %pK\n", __func__, core);
rc = __strict_check(core, __func__); rc = __strict_check(core, __func__);
@@ -916,7 +910,7 @@ int venus_hfi_core_init(struct msm_vidc_core *core)
if (rc) if (rc)
goto error; goto error;
rc = res_ops->llcc(core, true); rc = call_res_op(core, llcc, core, true);
if (rc) if (rc)
goto error; goto error;
@@ -939,7 +933,7 @@ int venus_hfi_core_init(struct msm_vidc_core *core)
rc = __sys_set_power_control(core, true); rc = __sys_set_power_control(core, true);
if (rc) { if (rc) {
d_vpr_e("%s: set power control failed\n", __func__); d_vpr_e("%s: set power control failed\n", __func__);
res_ops->gdsc_sw_ctrl(core); call_res_op(core, gdsc_sw_ctrl, core);
rc = 0; rc = 0;
} }
@@ -953,13 +947,13 @@ error:
int venus_hfi_core_deinit(struct msm_vidc_core *core, bool force) int venus_hfi_core_deinit(struct msm_vidc_core *core, bool force)
{ {
const struct msm_vidc_resources_ops *res_ops = core->res_ops;
int rc = 0; int rc = 0;
if (!core) { if (!core) {
d_vpr_h("%s(): invalid params\n", __func__); d_vpr_h("%s(): invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
d_vpr_h("%s(): core %pK\n", __func__, core); d_vpr_h("%s(): core %pK\n", __func__, core);
rc = __strict_check(core, __func__); rc = __strict_check(core, __func__);
if (rc) if (rc)
@@ -970,7 +964,7 @@ int venus_hfi_core_deinit(struct msm_vidc_core *core, bool force)
__resume(core); __resume(core);
__flush_debug_queue(core, (!force ? core->packet : NULL), core->packet_size); __flush_debug_queue(core, (!force ? core->packet : NULL), core->packet_size);
__release_subcaches(core); __release_subcaches(core);
res_ops->llcc(core, false); call_res_op(core, llcc, core, false);
__unload_fw(core); __unload_fw(core);
/** /**
* coredump need to be called after firmware unload, coredump also * coredump need to be called after firmware unload, coredump also
@@ -1997,7 +1991,6 @@ unlock:
int venus_hfi_scale_clocks(struct msm_vidc_inst* inst, u64 freq) int venus_hfi_scale_clocks(struct msm_vidc_inst* inst, u64 freq)
{ {
const struct msm_vidc_resources_ops *res_ops;
int rc = 0; int rc = 0;
struct msm_vidc_core* core; struct msm_vidc_core* core;
@@ -2006,7 +1999,6 @@ int venus_hfi_scale_clocks(struct msm_vidc_inst* inst, u64 freq)
return -EINVAL; return -EINVAL;
} }
core = inst->core; core = inst->core;
res_ops = core->res_ops;
core_lock(core, __func__); core_lock(core, __func__);
rc = __resume(core); rc = __resume(core);
@@ -2014,7 +2006,7 @@ int venus_hfi_scale_clocks(struct msm_vidc_inst* inst, u64 freq)
i_vpr_e(inst, "%s: Resume from power collapse failed\n", __func__); i_vpr_e(inst, "%s: Resume from power collapse failed\n", __func__);
goto exit; goto exit;
} }
rc = res_ops->set_clks(core, freq); rc = call_res_op(core, set_clks, core, freq);
if (rc) if (rc)
goto exit; goto exit;
@@ -2026,7 +2018,6 @@ exit:
int venus_hfi_scale_buses(struct msm_vidc_inst *inst, u64 bw_ddr, u64 bw_llcc) int venus_hfi_scale_buses(struct msm_vidc_inst *inst, u64 bw_ddr, u64 bw_llcc)
{ {
const struct msm_vidc_resources_ops *res_ops;
int rc = 0; int rc = 0;
struct msm_vidc_core* core; struct msm_vidc_core* core;
@@ -2035,7 +2026,6 @@ int venus_hfi_scale_buses(struct msm_vidc_inst *inst, u64 bw_ddr, u64 bw_llcc)
return -EINVAL; return -EINVAL;
} }
core = inst->core; core = inst->core;
res_ops = core->res_ops;
core_lock(core, __func__); core_lock(core, __func__);
rc = __resume(core); rc = __resume(core);
@@ -2043,7 +2033,7 @@ int venus_hfi_scale_buses(struct msm_vidc_inst *inst, u64 bw_ddr, u64 bw_llcc)
i_vpr_e(inst, "%s: Resume from power collapse failed\n", __func__); i_vpr_e(inst, "%s: Resume from power collapse failed\n", __func__);
goto exit; goto exit;
} }
rc = res_ops->set_bw(core, bw_ddr, bw_llcc); rc = call_res_op(core, set_bw, core, bw_ddr, bw_llcc);
if (rc) if (rc)
goto exit; goto exit;