Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions driver/platform/common/inc/msm_vidc_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ static inline bool is_mmrm_supported(struct msm_vidc_core *core)
}

int msm_vidc_init_platform_capabilities(struct msm_vidc_core *core);
int msm_vidc_update_ubwc_config(struct msm_vidc_core *core);
enum msm_vidc_hw_version msm_vidc_get_hw_version(void);
int msm_vidc_read_efuse(struct msm_vidc_core *core);

Expand Down
4 changes: 4 additions & 0 deletions driver/platform/common/src/msm_vidc_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ int msm_vidc_init_platform_capabilities(struct msm_vidc_core *core)
if (rc)
return rc;

rc = msm_vidc_update_ubwc_config(core);
if (rc)
return rc;

rc = msm_vidc_init_vpu(core);

return rc;
Expand Down
100 changes: 100 additions & 0 deletions driver/platform/common/src/msm_vidc_ubwc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#include <linux/err.h>
#include <linux/version.h>

#include "msm_vidc_platform.h"
#include "msm_vidc_debug.h"

#ifndef MSM_VIDC_HAS_QCOM_UBWC_HEADER
/*
* Downstream driver: enable if kernel provides global UBWC config database
* (include/linux/soc/qcom/ubwc.h with qcom_ubwc_config_get_data()).
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
#define MSM_VIDC_HAS_QCOM_UBWC_HEADER 1
#else
#define MSM_VIDC_HAS_QCOM_UBWC_HEADER 0
#endif
#endif

#if MSM_VIDC_HAS_QCOM_UBWC_HEADER
#include <linux/soc/qcom/ubwc.h>

static bool msm_vidc_qcom_ubwc_min_acc_length_64b(
const struct qcom_ubwc_cfg_data *cfg)
{
return cfg->ubwc_enc_version == UBWC_1_0 &&
(cfg->ubwc_dec_version == UBWC_2_0 ||
cfg->ubwc_dec_version == UBWC_3_0);
}

static bool msm_vidc_qcom_ubwc_macrotile_mode(
const struct qcom_ubwc_cfg_data *cfg)
{
return cfg->macrotile_mode;
}

static bool msm_vidc_qcom_ubwc_bank_spread(
const struct qcom_ubwc_cfg_data *cfg)
{
return cfg->ubwc_bank_spread;
}

static u32 msm_vidc_qcom_ubwc_swizzle(
const struct qcom_ubwc_cfg_data *cfg)
{
return cfg->ubwc_swizzle;
}

int msm_vidc_update_ubwc_config(struct msm_vidc_core *core)
{
const struct qcom_ubwc_cfg_data *ubwc_cfg;
struct msm_vidc_ubwc_config_data *ubwc_config;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You definitely don't follow the reviews. Stop using msm_vidc_ubwc_config_data, and switch to qcom_ubwc_cfg_data. Provide necessary kludges (and definitions) if the struct is not available (because of the kernel being too old).

u32 swizzle;

if (!core || !core->platform || !core->platform->data.ubwc_config)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defensive coding. Why? Can core be NULL here?

return 0;

ubwc_cfg = qcom_ubwc_config_get_data();
if (IS_ERR(ubwc_cfg)) {
long rc = PTR_ERR(ubwc_cfg);

if (rc == -EINVAL) {
d_vpr_h("%s: no global UBWC config for this platform, using platform defaults\n",
__func__);
return 0;
}

d_vpr_e("%s: failed to get global UBWC config: %ld\n",
__func__, rc);
return rc;
}

ubwc_config = core->platform->data.ubwc_config;
swizzle = msm_vidc_qcom_ubwc_swizzle(ubwc_cfg);

ubwc_config->max_channels =
msm_vidc_qcom_ubwc_macrotile_mode(ubwc_cfg) ? 8 : 4;
ubwc_config->mal_length =
msm_vidc_qcom_ubwc_min_acc_length_64b(ubwc_cfg) ? 64 : 32;
ubwc_config->highest_bank_bit = ubwc_cfg->highest_bank_bit;
ubwc_config->bank_swzl_level = !!(swizzle & UBWC_SWIZZLE_ENABLE_LVL1);
ubwc_config->bank_swz2_level = !!(swizzle & UBWC_SWIZZLE_ENABLE_LVL2);
ubwc_config->bank_swz3_level = !!(swizzle & UBWC_SWIZZLE_ENABLE_LVL3);
ubwc_config->bank_spreading =
msm_vidc_qcom_ubwc_bank_spread(ubwc_cfg);

d_vpr_h("%s: global UBWC config applied\n", __func__);

return 0;
}
#else
int msm_vidc_update_ubwc_config(struct msm_vidc_core *core)
{
return 0;
}
#endif
1 change: 1 addition & 0 deletions driver/platform/monaco/src/monaco.c
Original file line number Diff line number Diff line change
Expand Up @@ -2154,5 +2154,6 @@ int msm_vidc_init_platform_monaco(struct msm_vidc_core *core)
if (rc)
return rc;


return rc;
}
1 change: 1 addition & 0 deletions msm_video/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ msm_video-objs += $(VIDEO_DRIVER_REL_PATH)/platform/nordau/src/msm_vidc_nordau.o
endif

msm_video-objs += $(VIDEO_DRIVER_REL_PATH)/platform/common/src/msm_vidc_platform.o \
$(VIDEO_DRIVER_REL_PATH)/platform/common/src/msm_vidc_ubwc.o \
$(VIDEO_DRIVER_REL_PATH)/platform/common/src/msm_vidc_platform_ext.o \
$(VIDEO_DRIVER_REL_PATH)/variant/common/src/msm_vidc_variant.o \
$(VIDEO_DRIVER_REL_PATH)/vidc/src/msm_vidc_v4l2.o \
Expand Down
1 change: 1 addition & 0 deletions video/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ iris_vpu-objs += $(VIDEO_DRIVER_REL_PATH)/platform/lemans/src/lemans.o \
endif

iris_vpu-objs += $(VIDEO_DRIVER_REL_PATH)/platform/common/src/msm_vidc_platform.o \
$(VIDEO_DRIVER_REL_PATH)/platform/common/src/msm_vidc_ubwc.o \
$(VIDEO_DRIVER_REL_PATH)/variant/common/src/msm_vidc_variant.o \
$(VIDEO_DRIVER_REL_PATH)/vidc/src/msm_vidc_v4l2.o \
$(VIDEO_DRIVER_REL_PATH)/vidc/src/msm_vidc_vb2.o \
Expand Down