Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5281986pxv; Tue, 6 Jul 2021 23:24:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWn/VnkI8uH2kLIH98P3FCBECh/sl9yaouzhh5iXpFkSOOEGtEkI4N5JFauneWlOJmb4RL X-Received: by 2002:a17:906:c41a:: with SMTP id u26mr22674223ejz.270.1625639047792; Tue, 06 Jul 2021 23:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625639047; cv=none; d=google.com; s=arc-20160816; b=RJfg8F30Tbs5UA6O515aRv8WTTv9G8nth4Tsu+6n7FaNixfOLPbqHDN/aQLj/fwd4i Now0wL9WMdF/rcEuUgz47yH8qhTX/uhjziw1y3gnOwUrkGqsqMcu9imypvE7gUIdJG27 OgnAPR232282ry2+Yilh8mkvkEpcLxo5E/p9iUhniH0tNYvd/fx3I3kWqxSkDaI208g1 Nl59SyHU0ShYG62m1v5p1l1a89FBt/dcSfyeje+9x3F7jGA2zIpNLsYGnwdJR1LUuWrU Apb+syTVu2T5WJ/bSgHfllQX7LPA1yTgY+VUZj4YYssPGeJB5R/vXi2jRU3XrsFR8Dut 8kUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=aappOzOHu2CmYzmnHBTqgTrY+5qY0Mdt2UKInK0K1C8=; b=jqkZuG1kzmfJI+9WgkemTIhGzd0UDCsPxdsWPK8UQb2yfuDQges6hsNPB4g7PxSLBa qoStvqC0Hrfje9+W+PEQpD53SsE1i4PSRgaA2nwzdq/3qi2UcHa4VGPfiASNGE5Y9b9E oBHk8DEK2QPzbt9m48Aczth3DiKFRcu/IaQJLr4DeNnatp/XFMtLIZ1//gIJMDR1cM7t xqve/Nx75UyWbB7+VpGd2HmIMohuu0JFpQ+kJ1svb8ROkn9SuC7qf+ZBcldsaw82YFUK Frll05xENWEWx+PQLv9Dm2v8weieBvJYhNjbii4n+fHiqSPViw8cg64PGFOkdWEhLa2r 6bFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds17si20432683ejc.467.2021.07.06.23.23.45; Tue, 06 Jul 2021 23:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbhGGGZX (ORCPT + 99 others); Wed, 7 Jul 2021 02:25:23 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:49974 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230351AbhGGGZO (ORCPT ); Wed, 7 Jul 2021 02:25:14 -0400 X-UUID: 2eee5894e9b04169bd6175bc9ca8f6b9-20210707 X-UUID: 2eee5894e9b04169bd6175bc9ca8f6b9-20210707 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 283410174; Wed, 07 Jul 2021 14:22:32 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 7 Jul 2021 14:22:29 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 7 Jul 2021 14:22:27 +0800 From: Yunfei Dong To: Yunfei Dong , Alexandre Courbot , Hans Verkuil , Tzung-Bi Shih , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa CC: Hsin-Yi Wang , Fritz Koenig , Irui Wang , , , , , , , Subject: [PATCH v1, 10/14] media: mtk-vcodec: Add core thread Date: Wed, 7 Jul 2021 14:21:53 +0800 Message-ID: <20210707062157.21176-11-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210707062157.21176-1-yunfei.dong@mediatek.com> References: <20210707062157.21176-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Core thread: 1. Gets lat_buf from core msg queue. 2. Proceeds core decode. 3. Puts the lat_buf back to lat msg queue. Both H264 and VP9 rely on the core thread. Signed-off-by: Yunfei Dong --- .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 9 ++++++ .../platform/mtk-vcodec/mtk_vcodec_drv.h | 2 ++ .../platform/mtk-vcodec/vdec_msg_queue.c | 32 +++++++++++++++++++ .../platform/mtk-vcodec/vdec_msg_queue.h | 6 ++++ 4 files changed, 49 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index f156a943ca62..1bcb070ef947 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -423,6 +423,15 @@ static int mtk_vcodec_probe(struct platform_device *pdev) goto err_res; } + if (VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) { + init_waitqueue_head(&dev->core_read); + INIT_LIST_HEAD(&dev->core_queue); + spin_lock_init(&dev->core_lock); + dev->kthread_core = kthread_run(vdec_msg_queue_core_thead, dev, + "mtk-%s", "core"); + dev->num_core = 0; + } + for (i = 0; i < MTK_VDEC_HW_MAX; i++) mutex_init(&dev->dec_mutex[i]); mutex_init(&dev->dev_mutex); diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h index 68b3fbcd95b0..9a2a3821d4e1 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -34,6 +34,7 @@ #define MTK_VCODEC_MAX_PLANES 3 #define MTK_V4L2_BENCHMARK 0 #define WAIT_INTR_TIMEOUT_MS 1000 +#define VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE) /* * enum mtk_hw_reg_idx - MTK hw register base index @@ -519,6 +520,7 @@ struct mtk_vcodec_dev { struct device_node *component_node[MTK_VDEC_HW_MAX]; int comp_idx; + struct task_struct *kthread_core; wait_queue_head_t core_read; struct list_head core_queue; spinlock_t core_lock; diff --git a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c index 9d684e5f051c..4841b7c17c41 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c +++ b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c @@ -232,3 +232,35 @@ void vdec_msg_queue_deinit( msg_queue->init_done = false; } + +int vdec_msg_queue_core_thead(void *data) +{ + struct mtk_vcodec_dev *dev = data; + struct vdec_lat_buf *lat_buf; + struct mtk_vcodec_ctx *ctx; + + set_freezable(); + for (;;) { + try_to_freeze(); + if (kthread_should_stop()) + break; + + lat_buf = vdec_msg_queue_get_core_buf(dev); + if (!lat_buf) + continue; + + ctx = lat_buf->ctx; + mtk_vcodec_set_curr_ctx(dev, ctx, MTK_VDEC_CORE); + + if (!lat_buf->core_decode) + mtk_v4l2_err("Core decode callback func is NULL"); + else + lat_buf->core_decode(lat_buf); + + mtk_vcodec_set_curr_ctx(dev, NULL, MTK_VDEC_CORE); + vdec_msg_queue_buf_to_lat(lat_buf); + } + + mtk_v4l2_debug(3, "Video Capture Thread End"); + return 0; +} diff --git a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.h b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.h index 62261702c464..dba127843f14 100644 --- a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.h +++ b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.h @@ -127,4 +127,10 @@ void vdec_msg_queue_deinit( struct mtk_vcodec_ctx *ctx, struct vdec_msg_queue *msg_queue); +/** + * vdec_msg_queue_core_thead - used for core decoder. + * @data: private data used for each codec + */ +int vdec_msg_queue_core_thead(void *data); + #endif -- 2.18.0