From 9f18b35929c4f82fb945c183840e72f625813d75 Mon Sep 17 00:00:00 2001 From: Sayantan Majumder Date: Tue, 15 Jun 2021 14:45:48 +0530 Subject: [PATCH 1/4] msm: vidc: enabling new DTSI compatibility for IOT specific target Added new compatibility string to enable video H/W acceleration for qcm6490 Change-Id: I51fcc010cc85e05f26ac5b1e8d3ba4ad5fa8b052 Signed-off-by: Sayantan Majumder --- msm/vidc/msm_vidc_platform.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index af7fb8f00f1f..74dd3730dd31 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -2155,6 +2155,10 @@ static const struct of_device_id msm_vidc_dt_device[] = { .compatible = "qcom,yupik-vidc", .data = &yupik_data, }, + { + .compatible = "qcom,qcm6490-vidc", + .data = &yupik_data, + }, {}, }; @@ -2312,6 +2316,19 @@ void *vidc_get_drv_data(struct device *dev) ARRAY_SIZE(yupik_capabilities_v1); } msm_vidc_ddr_ubwc_config(driver_data, 0xe); + } else if (!strcmp(match->compatible, "qcom,qcm6490-vidc")) { + if (driver_data->sku_version == SKU_VERSION_1) { + driver_data->clock_data = yupik_clock_data_v1; + driver_data->clock_data_length = + ARRAY_SIZE(yupik_clock_data_v1); + driver_data->common_data = yupik_common_data_v1; + driver_data->common_data_length = + ARRAY_SIZE(yupik_common_data_v1); + driver_data->codec_caps = yupik_capabilities_v1; + driver_data->codec_caps_count = + ARRAY_SIZE(yupik_capabilities_v1); + } + msm_vidc_ddr_ubwc_config(driver_data, 0xe); } exit: return driver_data; From 6ac9be10aaf828fe51725504a7327a951290f91c Mon Sep 17 00:00:00 2001 From: Sayantan Majumder Date: Thu, 17 Jun 2021 00:52:55 +0530 Subject: [PATCH 2/4] msm: vidc: enabling dynamic session context for different targets Adding support to enable dynamic maximum no of instances for video sessions based on the different platforms. Change-Id: I16b92cc8cc740809042947590dcd73dcf4801f96 Signed-off-by: Sayantan Majumder --- msm/vidc/msm_v4l2_vidc.c | 11 ++++++++++- msm/vidc/msm_vidc_common.c | 1 - msm/vidc/msm_vidc_debug.c | 24 +++++++++++------------- msm/vidc/msm_vidc_debug.h | 24 ++++++++---------------- msm/vidc/msm_vidc_internal.h | 13 ++++++++++++- msm/vidc/msm_vidc_platform.c | 9 ++++++++- msm/vidc/msm_vidc_res_parse.c | 3 ++- 7 files changed, 51 insertions(+), 34 deletions(-) diff --git a/msm/vidc/msm_v4l2_vidc.c b/msm/vidc/msm_v4l2_vidc.c index 48d435af9fbc..873b1a2053da 100644 --- a/msm/vidc/msm_v4l2_vidc.c +++ b/msm/vidc/msm_v4l2_vidc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include @@ -492,6 +492,12 @@ static int msm_vidc_probe_vidc_device(struct platform_device *pdev) core->id = MSM_VIDC_CORE_VENUS; + vidc_driver->ctxt = kcalloc(core->platform_data->max_inst_count, + sizeof(*vidc_driver->ctxt), GFP_KERNEL); + if (!vidc_driver->ctxt) + goto err_vidc_context; + vidc_driver->num_ctxt = core->platform_data->max_inst_count; + rc = v4l2_device_register(&pdev->dev, &core->v4l2_dev); if (rc) { d_vpr_e("Failed to register v4l2 device\n"); @@ -588,6 +594,8 @@ err_enc: err_dec: v4l2_device_unregister(&core->v4l2_dev); err_v4l2_register: + kfree(vidc_driver->ctxt); +err_vidc_context: sysfs_remove_group(&pdev->dev.kobj, &msm_vidc_core_attr_group); err_core_init: dev_set_drvdata(&pdev->dev, NULL); @@ -660,6 +668,7 @@ static int msm_vidc_remove(struct platform_device *pdev) mutex_destroy(&core->resources.cb_lock); mutex_destroy(&core->lock); kfree(core); + kfree(vidc_driver->ctxt); return rc; } diff --git a/msm/vidc/msm_vidc_common.c b/msm/vidc/msm_vidc_common.c index 13a4b9ecdfd5..b4de4e3b235e 100644 --- a/msm/vidc/msm_vidc_common.c +++ b/msm/vidc/msm_vidc_common.c @@ -3014,7 +3014,6 @@ static int msm_comm_init_core(struct msm_vidc_inst *inst) core->state = VIDC_CORE_INIT; core->smmu_fault_handled = false; core->trigger_ssr = false; - core->resources.max_inst_count = MAX_SUPPORTED_INSTANCES; core->resources.max_secure_inst_count = core->resources.max_secure_inst_count ? core->resources.max_secure_inst_count : diff --git a/msm/vidc/msm_vidc_debug.c b/msm/vidc/msm_vidc_debug.c index 18a78bf6e69b..263840a68581 100644 --- a/msm/vidc/msm_vidc_debug.c +++ b/msm/vidc/msm_vidc_debug.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #define CREATE_TRACE_POINTS @@ -31,8 +31,6 @@ int msm_vidc_vpp_delay; atomic_read(&__binfo->ref_count) >= 2 ? "video driver" : "firmware";\ }) -struct log_cookie ctxt[MAX_SUPPORTED_INSTANCES]; - struct core_inst_pair { struct msm_vidc_core *core; struct msm_vidc_inst *inst; @@ -614,16 +612,16 @@ int get_sid(u32 *sid, u32 session_type) { int i; - for (i = 0; i < MAX_SUPPORTED_INSTANCES; i++) { - if (!ctxt[i].used) { - ctxt[i].used = 1; + for (i = 0; i < vidc_driver->num_ctxt; i++) { + if (!vidc_driver->ctxt[i].used) { + vidc_driver->ctxt[i].used = 1; *sid = i+1; update_log_ctxt(*sid, session_type, 0); break; } } - return (i == MAX_SUPPORTED_INSTANCES); + return (i == vidc_driver->num_ctxt); } inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) @@ -632,7 +630,7 @@ inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) char type; u32 s_type = 0; - if (!sid || sid > MAX_SUPPORTED_INSTANCES) { + if (!sid || sid > vidc_driver->num_ctxt) { d_vpr_e("%s: invalid sid %#x\n", __func__, sid); } @@ -679,11 +677,11 @@ inline void update_log_ctxt(u32 sid, u32 session_type, u32 fourcc) break; } - ctxt[sid-1].session_type = s_type; - ctxt[sid-1].codec_type = fourcc; - memcpy(&ctxt[sid-1].name, codec, 4); - ctxt[sid-1].name[4] = type; - ctxt[sid-1].name[5] = '\0'; + vidc_driver->ctxt[sid-1].session_type = s_type; + vidc_driver->ctxt[sid-1].codec_type = fourcc; + memcpy(&vidc_driver->ctxt[sid-1].name, codec, 4); + vidc_driver->ctxt[sid-1].name[4] = type; + vidc_driver->ctxt[sid-1].name[5] = '\0'; } /* Mock all the missing parts for successful compilation starts here */ diff --git a/msm/vidc/msm_vidc_debug.h b/msm/vidc/msm_vidc_debug.h index 8dfaee14cd98..4c10d93863a4 100644 --- a/msm/vidc/msm_vidc_debug.h +++ b/msm/vidc/msm_vidc_debug.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #ifndef __MSM_VIDC_DEBUG__ @@ -92,13 +92,6 @@ enum vidc_err_recovery_disable { VIDC_DISABLE_NON_NOC_ERR_RECOV = 0x0002 }; -struct log_cookie { - u32 used; - u32 session_type; - u32 codec_type; - char name[20]; -}; - extern int msm_vidc_debug; extern int msm_vidc_fw_debug_mode; extern bool msm_vidc_fw_coverage; @@ -109,7 +102,6 @@ extern bool msm_vidc_lossless_encode; extern bool msm_vidc_cvp_usage; extern int msm_vidc_err_recovery_disable; extern int msm_vidc_vpp_delay; -extern struct log_cookie ctxt[MAX_SUPPORTED_INSTANCES]; #define dprintk(__level, sid, __fmt, ...) \ do { \ @@ -237,10 +229,10 @@ static inline bool is_print_allowed(u32 sid, u32 level) if (!((msm_vidc_debug >> 8) & 0xF)) return true; - if (!sid || sid > MAX_SUPPORTED_INSTANCES) + if (!sid || sid > vidc_driver->num_ctxt) return true; - if (ctxt[sid-1].session_type & msm_vidc_debug) + if (vidc_driver->ctxt[sid-1].session_type & msm_vidc_debug) return true; return false; @@ -248,21 +240,21 @@ static inline bool is_print_allowed(u32 sid, u32 level) static inline char *get_codec_name(u32 sid) { - if (!sid || sid > MAX_SUPPORTED_INSTANCES) + if (!sid || sid > vidc_driver->num_ctxt) return "....."; - return ctxt[sid-1].name; + return vidc_driver->ctxt[sid-1].name; } static inline void put_sid(u32 sid) { - if (!sid || sid > MAX_SUPPORTED_INSTANCES) { + if (!sid || sid > vidc_driver->num_ctxt) { d_vpr_e("%s: invalid sid %#x\n", __func__, sid); return; } - if (ctxt[sid-1].used) - ctxt[sid-1].used = 0; + if (vidc_driver->ctxt[sid-1].used) + vidc_driver->ctxt[sid-1].used = 0; } static inline void tic(struct msm_vidc_inst *i, enum profiling_points p, diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index 153464382683..62e8c0b6a110 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #ifndef _MSM_VIDC_INTERNAL_H_ @@ -39,6 +39,7 @@ #define MAX_NUM_OUTPUT_BUFFERS VIDEO_MAX_FRAME // same as VB2_MAX_FRAME #define MAX_SUPPORTED_INSTANCES 16 +#define MAX_SUPPORTED_INSTANCES_24 24 #define MAX_BSE_VPP_DELAY 6 #define DEFAULT_BSE_VPP_DELAY 2 @@ -310,6 +311,7 @@ struct msm_vidc_platform_data { uint32_t vpu_ver; uint32_t num_vpp_pipes; struct msm_vidc_ubwc_config_data *ubwc_config; + uint32_t max_inst_count; }; struct msm_vidc_format_desc { @@ -336,6 +338,13 @@ struct msm_vidc_format_constraint { u32 uv_buffer_alignment; }; +struct log_cookie { + u32 used; + u32 session_type; + u32 codec_type; + char name[20]; +}; + struct msm_vidc_drv { struct mutex lock; struct list_head cores; @@ -343,6 +352,8 @@ struct msm_vidc_drv { struct dentry *debugfs_root; int thermal_level; u32 sku_version; + struct log_cookie *ctxt; + u32 num_ctxt; }; struct msm_video_device { diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index 74dd3730dd31..51c99758de69 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. */ #include @@ -2012,6 +2012,7 @@ static struct msm_vidc_platform_data default_data = { .vpu_ver = VPU_VERSION_IRIS2, .num_vpp_pipes = 0x4, .ubwc_config = 0x0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data lahaina_data = { @@ -2036,6 +2037,7 @@ static struct msm_vidc_platform_data lahaina_data = { .codec_caps_count = ARRAY_SIZE(lahaina_capabilities), .vpss_caps = vpss_capabilities, .vpss_caps_count = ARRAY_SIZE(vpss_capabilities), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data yupik_data = { @@ -2060,6 +2062,7 @@ static struct msm_vidc_platform_data yupik_data = { .codec_caps_count = ARRAY_SIZE(yupik_capabilities_v0), .vpss_caps = vpss_capabilities, .vpss_caps_count = ARRAY_SIZE(vpss_capabilities), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data bengal_data = { @@ -2084,6 +2087,7 @@ static struct msm_vidc_platform_data bengal_data = { .codec_caps_count = ARRAY_SIZE(bengal_capabilities_v0), .vpss_caps = NULL, .vpss_caps_count = 0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data shima_data = { @@ -2108,6 +2112,7 @@ static struct msm_vidc_platform_data shima_data = { .codec_caps_count = ARRAY_SIZE(shima_capabilities_v0), .vpss_caps = vpss_capabilities, .vpss_caps_count = ARRAY_SIZE(vpss_capabilities), + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static struct msm_vidc_platform_data holi_data = { @@ -2132,6 +2137,7 @@ static struct msm_vidc_platform_data holi_data = { .codec_caps_count = ARRAY_SIZE(holi_capabilities), .vpss_caps = NULL, .vpss_caps_count = 0, + .max_inst_count = MAX_SUPPORTED_INSTANCES, }; static const struct of_device_id msm_vidc_dt_device[] = { @@ -2329,6 +2335,7 @@ void *vidc_get_drv_data(struct device *dev) ARRAY_SIZE(yupik_capabilities_v1); } msm_vidc_ddr_ubwc_config(driver_data, 0xe); + driver_data->max_inst_count = MAX_SUPPORTED_INSTANCES_24; } exit: return driver_data; diff --git a/msm/vidc/msm_vidc_res_parse.c b/msm/vidc/msm_vidc_res_parse.c index 1aa93ac5bb75..412fd52e9679 100644 --- a/msm/vidc/msm_vidc_res_parse.c +++ b/msm/vidc/msm_vidc_res_parse.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include @@ -822,6 +822,7 @@ int read_platform_resources_from_drv_data( res->vpu_ver = platform_data->vpu_ver; res->ubwc_config = platform_data->ubwc_config; + res->max_inst_count = platform_data->max_inst_count; return rc; From 0fbffa4b55ec3636d81994c822863f3010f427fd Mon Sep 17 00:00:00 2001 From: Vasantha Balla Date: Fri, 17 Dec 2021 14:48:52 +0530 Subject: [PATCH 3/4] msm: vidc: Add clock/bus votes for eos/flush commands If voting is not added for eos and flush command processing, Firmware is processing only high priority session commands which causes non real time session to wait for completion of realtime session for its eos processing. So adding votes for eos and flush commands. Change-Id: I9de8c1d0dc79e93d991d34d2d687e2fa1910531b Signed-off-by: Vasantha Balla --- msm/vidc/msm_vidc_clocks.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_clocks.c b/msm/vidc/msm_vidc_clocks.c index 168abc2f8080..667d62c38054 100644 --- a/msm/vidc/msm_vidc_clocks.c +++ b/msm/vidc/msm_vidc_clocks.c @@ -318,8 +318,16 @@ int msm_comm_set_buses(struct msm_vidc_core *core, u32 sid) mutex_unlock(&inst->registeredbufs.lock); if (!filled_len || !device_addr) { + mutex_lock(&inst->eosbufs.lock); + if (list_empty(&inst->eosbufs.list) && + !inst->in_flush && !inst->out_flush) { + s_vpr_l(sid, "%s: No pending eos/flush cmds\n", + __func__); + mutex_unlock(&inst->eosbufs.lock); + continue; + } + mutex_unlock(&inst->eosbufs.lock); s_vpr_l(sid, "%s: no input\n", __func__); - continue; } /* skip inactive session bus bandwidth */ @@ -856,8 +864,16 @@ int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid) mutex_unlock(&inst->registeredbufs.lock); if (!filled_len || !device_addr) { + mutex_lock(&inst->eosbufs.lock); + if (list_empty(&inst->eosbufs.list) && !inst->in_flush + && !inst->out_flush) { + s_vpr_l(sid, "%s: No pending eos/flush cmds\n", + __func__); + mutex_unlock(&inst->eosbufs.lock); + continue; + } + mutex_unlock(&inst->eosbufs.lock); s_vpr_l(sid, "%s: no input\n", __func__); - continue; } /* skip inactive session clock rate */ From 81426844a2671ef300781843e6880a1d4fd622a4 Mon Sep 17 00:00:00 2001 From: Rahul Ratneshwar Mandal Date: Tue, 9 Aug 2022 19:03:53 +0530 Subject: [PATCH 4/4] msm: vidc: Update avc/hevc dec capability as per PRD allow support upto level 6.2 for AVC/HEVC decoder. Change-Id: I095373a8dbbccee37e16f64d820261efeccbbd44 --- msm/vidc/msm_vidc_platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msm/vidc/msm_vidc_platform.c b/msm/vidc/msm_vidc_platform.c index 1abab9cf22bc..4dc258ae6214 100644 --- a/msm/vidc/msm_vidc_platform.c +++ b/msm/vidc/msm_vidc_platform.c @@ -532,10 +532,10 @@ static struct msm_vidc_codec_capability lahaina_capabilities[] = { /* Level for AVC, HEVC and VP9 decoder specific */ {CAP_H264_LEVEL, DEC, H264, V4L2_MPEG_VIDEO_H264_LEVEL_1_0, - V4L2_MPEG_VIDEO_H264_LEVEL_6_1, 1, + V4L2_MPEG_VIDEO_H264_LEVEL_6_2, 1, V4L2_MPEG_VIDEO_H264_LEVEL_5_0}, {CAP_HEVC_LEVEL, DEC, HEVC, V4L2_MPEG_VIDEO_HEVC_LEVEL_1, - V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1, 1, + V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2, 1, V4L2_MPEG_VIDEO_HEVC_LEVEL_5}, {CAP_VP9_LEVEL, DEC, VP9, V4L2_MPEG_VIDC_VIDEO_VP9_LEVEL_UNUSED, V4L2_MPEG_VIDC_VIDEO_VP9_LEVEL_51, 1,