Skip to content

Commit

Permalink
media: venus: set ubwc configuration on specific video hardware
Browse files Browse the repository at this point in the history
UBWC configuration parameters would vary across video hardware
generations. At the same time, driver is expected to configure
these parameters, without relying on video firmware to use the
default configurations.
Setting the configuration parameters for sc7280.

Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
  • Loading branch information
Vikash-Garodia authored and intel-lab-lkp committed Apr 28, 2022
1 parent 3d59142 commit 22d299b
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/media/platform/qcom/venus/core.c
Expand Up @@ -832,6 +832,10 @@ static const struct reg_val sm7280_reg_preset[] = {
{ 0xb0088, 0 },
};

static const struct ubwc_config sc7280_ubwc_config[] = {
{{1, 1, 1, 0, 0, 0}, 8, 32, 14, 0, 0},
};

static const struct venus_resources sc7280_res = {
.freq_tbl = sc7280_freq_table,
.freq_tbl_size = ARRAY_SIZE(sc7280_freq_table),
Expand All @@ -841,6 +845,7 @@ static const struct venus_resources sc7280_res = {
.bw_tbl_enc_size = ARRAY_SIZE(sc7280_bw_table_enc),
.bw_tbl_dec = sc7280_bw_table_dec,
.bw_tbl_dec_size = ARRAY_SIZE(sc7280_bw_table_dec),
.ubwc_conf = sc7280_ubwc_config,
.clks = {"core", "bus", "iface"},
.clks_num = 3,
.vcodec0_clks = {"vcodec_core", "vcodec_bus"},
Expand Down
18 changes: 18 additions & 0 deletions drivers/media/platform/qcom/venus/core.h
Expand Up @@ -47,6 +47,23 @@ struct bw_tbl {
u32 peak_10bit;
};

struct ubwc_config {
struct {
u32 max_channel_override : 1;
u32 mal_length_override : 1;
u32 hb_override : 1;
u32 bank_swzl_level_override : 1;
u32 bank_spreading_override : 1;
u32 reserved : 27;
} override_bit_info;

u32 max_channels;
u32 mal_length;
u32 highest_bank_bit;
u32 bank_swzl_level;
u32 bank_spreading;
};

struct venus_resources {
u64 dma_mask;
const struct freq_tbl *freq_tbl;
Expand All @@ -57,6 +74,7 @@ struct venus_resources {
unsigned int bw_tbl_dec_size;
const struct reg_val *reg_tbl;
unsigned int reg_tbl_size;
const struct ubwc_config *ubwc_conf;
const char * const clks[VIDC_CLKS_NUM_MAX];
unsigned int clks_num;
const char * const vcodec0_clks[VIDC_VCODEC_CLKS_NUM_MAX];
Expand Down
9 changes: 9 additions & 0 deletions drivers/media/platform/qcom/venus/hfi_cmds.c
Expand Up @@ -58,6 +58,15 @@ void pkt_sys_coverage_config(struct hfi_sys_set_property_pkt *pkt, u32 mode)
pkt->data[1] = mode;
}

void pkt_sys_ubwc_config(struct hfi_sys_set_property_pkt *pkt, struct hfi_ubwc_config *hfi)
{
pkt->hdr.size = struct_size(pkt, data, 1) + sizeof(*hfi);
pkt->hdr.pkt_type = HFI_CMD_SYS_SET_PROPERTY;
pkt->num_properties = 1;
pkt->data[0] = HFI_PROPERTY_SYS_UBWC_CONFIG;
memcpy(&pkt->data[1], hfi, sizeof(*hfi));
}

int pkt_sys_set_resource(struct hfi_sys_set_resource_pkt *pkt, u32 id, u32 size,
u32 addr, void *cookie)
{
Expand Down
1 change: 1 addition & 0 deletions drivers/media/platform/qcom/venus/hfi_cmds.h
Expand Up @@ -256,6 +256,7 @@ void pkt_sys_init(struct hfi_sys_init_pkt *pkt, u32 arch_type);
void pkt_sys_pc_prep(struct hfi_sys_pc_prep_pkt *pkt);
void pkt_sys_idle_indicator(struct hfi_sys_set_property_pkt *pkt, u32 enable);
void pkt_sys_power_control(struct hfi_sys_set_property_pkt *pkt, u32 enable);
void pkt_sys_ubwc_config(struct hfi_sys_set_property_pkt *pkt, struct hfi_ubwc_config *hfi);
int pkt_sys_set_resource(struct hfi_sys_set_resource_pkt *pkt, u32 id, u32 size,
u32 addr, void *cookie);
int pkt_sys_unset_resource(struct hfi_sys_release_resource_pkt *pkt, u32 id,
Expand Down
20 changes: 20 additions & 0 deletions drivers/media/platform/qcom/venus/hfi_helper.h
Expand Up @@ -427,6 +427,7 @@
#define HFI_PROPERTY_SYS_CODEC_POWER_PLANE_CTRL 0x5
#define HFI_PROPERTY_SYS_IMAGE_VERSION 0x6
#define HFI_PROPERTY_SYS_CONFIG_COVERAGE 0x7
#define HFI_PROPERTY_SYS_UBWC_CONFIG 0x8

/*
* HFI_PROPERTY_PARAM_COMMON_START
Expand Down Expand Up @@ -626,6 +627,25 @@ struct hfi_debug_config {
u32 mode;
};

struct hfi_ubwc_config {
u32 size;
u32 packet_type;
struct {
u32 max_channel_override : 1;
u32 mal_length_override : 1;
u32 hb_override : 1;
u32 bank_swzl_level_override : 1;
u32 bank_spreading_override : 1;
u32 reserved : 27;
} override_bit_info;
u32 max_channels;
u32 mal_length;
u32 highest_bank_bit;
u32 bank_swzl_level;
u32 bank_spreading;
u32 reserved[2];
};

struct hfi_enable {
u32 enable;
};
Expand Down
54 changes: 54 additions & 0 deletions drivers/media/platform/qcom/venus/hfi_venus.c
Expand Up @@ -904,6 +904,52 @@ static int venus_sys_set_power_control(struct venus_hfi_device *hdev,
return 0;
}

static int venus_sys_set_ubwc_config(struct venus_hfi_device *hdev)
{
struct hfi_sys_set_property_pkt *pkt;
u8 packet[IFACEQ_VAR_SMALL_PKT_SIZE];
struct hfi_ubwc_config *hfi;
const struct venus_resources *res = hdev->core->res;
const struct ubwc_config *ubwc_conf = res->ubwc_conf;
int ret;

hfi = kzalloc(sizeof(*hfi), GFP_KERNEL);
if (!hfi)
return -ENOMEM;

pkt = (struct hfi_sys_set_property_pkt *)packet;

hfi->max_channels = ubwc_conf->max_channels;
hfi->override_bit_info.max_channel_override =
ubwc_conf->override_bit_info.max_channel_override;

hfi->mal_length = ubwc_conf->mal_length;
hfi->override_bit_info.mal_length_override =
ubwc_conf->override_bit_info.mal_length_override;

hfi->highest_bank_bit = ubwc_conf->highest_bank_bit;
hfi->override_bit_info.hb_override =
ubwc_conf->override_bit_info.hb_override;

hfi->bank_swzl_level = ubwc_conf->bank_swzl_level;
hfi->override_bit_info.bank_swzl_level_override =
ubwc_conf->override_bit_info.bank_swzl_level_override;

hfi->bank_spreading = ubwc_conf->bank_spreading;
hfi->override_bit_info.bank_spreading_override =
ubwc_conf->override_bit_info.bank_spreading_override;

pkt_sys_ubwc_config(pkt, hfi);

kfree(hfi);

ret = venus_iface_cmdq_write(hdev, pkt, false);
if (ret)
return ret;

return 0;
}

static int venus_get_queue_size(struct venus_hfi_device *hdev,
unsigned int index)
{
Expand All @@ -922,6 +968,7 @@ static int venus_get_queue_size(struct venus_hfi_device *hdev,
static int venus_sys_set_default_properties(struct venus_hfi_device *hdev)
{
struct device *dev = hdev->core->dev;
const struct venus_resources *res = hdev->core->res;
int ret;

ret = venus_sys_set_debug(hdev, venus_fw_debug);
Expand All @@ -945,6 +992,13 @@ static int venus_sys_set_default_properties(struct venus_hfi_device *hdev)
dev_warn(dev, "setting hw power collapse ON failed (%d)\n",
ret);

/* For specific venus core, it is mandatory to set the UBWC configuration */
if (res->ubwc_conf) {
ret = venus_sys_set_ubwc_config();
if (ret)
dev_warn(dev, "setting ubwc config failed (%d)\n", ret);
}

return ret;
}

Expand Down

0 comments on commit 22d299b

Please sign in to comment.