From patchwork Wed Jul 6 18:26:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D42B2C43334 for ; Wed, 6 Jul 2022 18:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234049AbiGFS1T (ORCPT ); Wed, 6 Jul 2022 14:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234028AbiGFS1S (ORCPT ); Wed, 6 Jul 2022 14:27:18 -0400 Received: from mail-ua1-x929.google.com (mail-ua1-x929.google.com [IPv6:2607:f8b0:4864:20::929]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1EE96436 for ; Wed, 6 Jul 2022 11:27:16 -0700 (PDT) Received: by mail-ua1-x929.google.com with SMTP id u12so3263482uap.11 for ; Wed, 06 Jul 2022 11:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5IdTe03T4AbQW3cQ+frSJyoDxiG9eWKIQ4uCqO8KXZ4=; b=a44ubRV55zQ1AZtYKCbVMinunDOe4rwc2pZvSauSYy5diqTxZLw4LVdSpi/sCWmxt1 QFkHr6JdsWo+xDl7rtVC5oEBYvpgvQFSp9padrA/TJLthCjvZ2QmRM4+jCrssNtDReNn sCKs9n0NEKjtPrEdrlpBT4AazVTbw4+e3URQc7B0YRVrL71UkORan40s5NR4ykw8mrz7 WaTse9b6Kt2wg/EP+ApZ6kt8zi2WKtzcnzxxxAt1ZMWpu82NyCdwSFOPpS00gI14vlb9 ut4neTFBBpdMKuG9VlA6OrFWLdf2t5iiZ3Q7KQd29FTta2nuF4ADtcVjmwLKpvPeRUvs 957w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5IdTe03T4AbQW3cQ+frSJyoDxiG9eWKIQ4uCqO8KXZ4=; b=ro1ObF8jFAL9iFUlHuJRNgHHOMsVl470F10SJyenAHUK1JnB4WjRmD6s2w/HdaD/G8 ioC8ep6Xlr38iXG/vwibY4Kg8AJv7+lrEx0+DO+uOzZMsi7rJ8AosHV0NRe9IylIVIao tN1WoVnJjZwX1WR7vsUDlIlzfc6fQOC06jWM518UY8GfQS39IzGnb3xR/G5W0O9j6kAV GSlCv8Rk+KIBa/B5wjKw7vZPI6ooph1DZSznElSpIntlWSV3JUX8lJUrFfpw9EEePvjI PLWodf2oDUr2ik2iEdvxGgEiuWlqoAm6hh8drkau3rzR1X6gRdJqE9+6+HU6bgioJNxv PlEg== X-Gm-Message-State: AJIora+NhjcAfERC0TB1uRc8fDK8wtnbNCxHKqjJbsQobuxRTKD6GfJD fwnu40RPc5zJKU+qdnb4JPeIZnVrbNxmtSc9 X-Google-Smtp-Source: AGRyM1vejyMjrY8q5Bjgz6aa4ackRpzH3NS3rC3B3F2Wtht3Ptl8sWiaNRGi38LCC0c/FymCA6Dogg== X-Received: by 2002:a9f:35ef:0:b0:37f:18d2:4578 with SMTP id u44-20020a9f35ef000000b0037f18d24578mr20821637uad.65.1657132035461; Wed, 06 Jul 2022 11:27:15 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:15 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia Subject: [PATCH 1/8] videobuf2: Introduce vb2_find_buffer() Date: Wed, 6 Jul 2022 15:26:50 -0300 Message-Id: <20220706182657.210650-2-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Ezequiel Garcia All users of vb2_find_timestamp() combine it with vb2_get_buffer() to retrieve a videobuf2 buffer, given a u64 timestamp. Introduce an API for this use-case. Users will be converted to the new API as follow-up commits. Signed-off-by: Ezequiel Garcia --- include/media/videobuf2-v4l2.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index d818d9707695..7f9ae5b39b78 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -78,6 +78,24 @@ struct vb2_v4l2_buffer { int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, unsigned int start_idx); +/** + * vb2_find_buffer() - Find a buffer with given timestamp + * + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @timestamp: the timestamp to find. + * + * Returns the buffer with the given @timestamp, or NULL if not found. + */ +static inline struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, + u64 timestamp) +{ + int index = vb2_find_timestamp(q, timestamp, 0); + + if (index < 0) + return NULL; + return vb2_get_buffer(q, index); +} + int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b); /** From patchwork Wed Jul 6 18:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D6D1C433EF for ; Wed, 6 Jul 2022 18:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234095AbiGFS13 (ORCPT ); Wed, 6 Jul 2022 14:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234145AbiGFS12 (ORCPT ); Wed, 6 Jul 2022 14:27:28 -0400 Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4682D9FCF for ; Wed, 6 Jul 2022 11:27:27 -0700 (PDT) Received: by mail-vs1-xe32.google.com with SMTP id 189so15968346vsh.2 for ; Wed, 06 Jul 2022 11:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8Rmltu/GTnpTlLdYo/MNEstdQCKTczD8RA5cX6ipHd8=; b=JH9USA94gvmK6YDhHjP/yBAH+tHWm8x3rui4VYK208tU2ra7hucZaPpti6OZMAIMWS dLoCpU+k2a7mrNHQR281RLlfWO2g8e7ZL7YmuRjkVxoBZGZZPBwICVLLCs7di7kscvlq 4+1N88SuSGO6COwuH1M4NLG13jIz+7rIAK2NiK7zxd3ukwDdNlJ1JS5SNhX5RBAXFi2i 91P478sl5u6vmppzeI7R9EknYfBcNiahmHI9bmBpiTyQIrAGHAbdrtXVr7wJr5rfFH/V ZYFSU5+4CUjoE2QQPICx1DY664aZrTlxlk3AEal4tNoDv8sTLDxwDI9H7qJtjtJgUytl UV+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8Rmltu/GTnpTlLdYo/MNEstdQCKTczD8RA5cX6ipHd8=; b=W6y1gR1iGbQpJkkcP39DZDPRo2ifKHxYht3Cmrj9Q7Hwu+47Cxt73T01wNKb+W18T7 8hPLZEjhjS42k+lmpyf8WIEhRewrZ8THXP8OgxVyZJJCgYXnl7uC8fpVdDBkCDgnNww2 CBmJ+XwIJr4d127901wTNCyWlRSbRwI74QjfSkT0Cb8vfrCIYmXsD7aKsCt3iTMhfWOK 0+EWCNoOQQWJuN2NHGIwVm1Ezya87Cv4eQ15VSiyCfyN3QVsMg9et5NaTgW0cDFa19Lr ZZJ+i1dqs4UzUgHkHzI3RfK0jBZLLV9b0Oj03dC/pXcq++G2zgf/SoUCp/+E+PkxHCR/ kMfg== X-Gm-Message-State: AJIora/LU7tXOeOKgFDb9VHex0k/1ZZZQfFybnTmAw/LZKSzR6xtPLKs UP1PsZO70dPBDijQiqTNdxhLsG6qzEFRYpjQ X-Google-Smtp-Source: AGRyM1vpu99IP7GL+Z3x58hcvIBYzKcSt0dLA4x5vkKQiAc1xWYkDpFs173Fs9G3yPfTdKIeL4x1Xw== X-Received: by 2002:a67:b74c:0:b0:357:6c9:113 with SMTP id l12-20020a67b74c000000b0035706c90113mr4431618vsh.51.1657132045973; Wed, 06 Jul 2022 11:27:25 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:25 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia , Tiffany Lin , Andrew-CT Chen , Yunfei Dong Subject: [PATCH 2/8] mediatek: vcodec: Use vb2_find_buffer Date: Wed, 6 Jul 2022 15:26:51 -0300 Message-Id: <20220706182657.210650-3-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced vb2_find_buffer API to get a vb2_buffer given a buffer timestamp. Cc: Tiffany Lin Cc: Andrew-CT Chen Cc: Yunfei Dong Signed-off-by: Ezequiel Garcia --- .../platform/mediatek/vcodec/vdec/vdec_h264_req_common.c | 7 +++---- .../media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c | 7 +++---- .../platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.c index ca628321d272..580ce979e2a3 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.c @@ -51,7 +51,7 @@ void mtk_vdec_h264_fill_dpb_info(struct mtk_vcodec_ctx *ctx, struct vb2_queue *vq; struct vb2_buffer *vb; struct vb2_v4l2_buffer *vb2_v4l2; - int index, vb2_index; + int index; vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); @@ -62,8 +62,8 @@ void mtk_vdec_h264_fill_dpb_info(struct mtk_vcodec_ctx *ctx, continue; } - vb2_index = vb2_find_timestamp(vq, dpb->reference_ts, 0); - if (vb2_index < 0) { + vb = vb2_find_buffer(vq, dpb->reference_ts); + if (!vb) { dev_err(&ctx->dev->plat_dev->dev, "Reference invalid: dpb_index(%d) reference_ts(%lld)", index, dpb->reference_ts); @@ -76,7 +76,6 @@ void mtk_vdec_h264_fill_dpb_info(struct mtk_vcodec_ctx *ctx, else h264_dpb_info[index].reference_flag = 2; - vb = vq->bufs[vb2_index]; vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf); h264_dpb_info[index].field = vb2_v4l2->field; diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c index eef102f3f4f3..e1fe2603e92e 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c @@ -237,7 +237,7 @@ static int vdec_vp8_slice_get_decode_parameters(struct vdec_vp8_slice_inst *inst struct vb2_queue *vq; struct vb2_buffer *vb; u64 referenct_ts; - int index, vb2_index; + int index; frame_header = vdec_vp8_slice_get_ctrl_ptr(inst->ctx, V4L2_CID_STATELESS_VP8_FRAME); if (IS_ERR(frame_header)) @@ -246,8 +246,8 @@ static int vdec_vp8_slice_get_decode_parameters(struct vdec_vp8_slice_inst *inst vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); for (index = 0; index < 3; index++) { referenct_ts = vdec_vp8_slice_get_ref_by_ts(frame_header, index); - vb2_index = vb2_find_timestamp(vq, referenct_ts, 0); - if (vb2_index < 0) { + vb = vb2_find_buffer(vq, referenct_ts); + if (!vb) { if (!V4L2_VP8_FRAME_IS_KEY_FRAME(frame_header)) mtk_vcodec_err(inst, "reference invalid: index(%d) ts(%lld)", index, referenct_ts); @@ -256,7 +256,6 @@ static int vdec_vp8_slice_get_decode_parameters(struct vdec_vp8_slice_inst *inst } inst->vsi->vp8_dpb_info[index].reference_flag = 1; - vb = vq->bufs[vb2_index]; inst->vsi->vp8_dpb_info[index].y_dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0); if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index 81de876d5126..fb1c36a3592d 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -1672,7 +1672,6 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst struct vdec_vp9_slice_reference *ref; int plane; int size; - int idx; int w; int h; int i; @@ -1715,15 +1714,16 @@ static int vdec_vp9_slice_setup_core_buffer(struct vdec_vp9_slice_instance *inst */ for (i = 0; i < 3; i++) { ref = &vsi->frame.ref[i]; - idx = vb2_find_timestamp(vq, pfc->ref_idx[i], 0); - if (idx < 0) { + vb = vb2_find_buffer(vq, pfc->ref_idx[i]); + if (!vb) { ref->frame_width = w; ref->frame_height = h; memset(&vsi->ref[i], 0, sizeof(vsi->ref[i])); } else { + int idx = vb->index; + ref->frame_width = instance->dpb[idx].width; ref->frame_height = instance->dpb[idx].height; - vb = vq->bufs[idx]; vsi->ref[i].y.dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0); if (plane == 1) From patchwork Wed Jul 6 18:26:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0C90C433EF for ; Wed, 6 Jul 2022 18:27:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234204AbiGFS1i (ORCPT ); Wed, 6 Jul 2022 14:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234169AbiGFS1g (ORCPT ); Wed, 6 Jul 2022 14:27:36 -0400 Received: from mail-vs1-xe31.google.com (mail-vs1-xe31.google.com [IPv6:2607:f8b0:4864:20::e31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 422AE1570A for ; Wed, 6 Jul 2022 11:27:33 -0700 (PDT) Received: by mail-vs1-xe31.google.com with SMTP id 185so4794991vse.6 for ; Wed, 06 Jul 2022 11:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FyZPG7ecMtPTu7c8gkIkFgQ1x9YPQvFNs7IqBS9P2iw=; b=AMczT6RYxuWehfaVB4N6c/YCGTIUDa5AonsWRb9tk0ZgIB8E18MZBsP45Ils2GHr2S GykDSQkeasORYtEvX2DWlWovRf8degKgU73O7ghh+YgX4aBx3UyDjYRxx8lrOKHK844W QU4poqa9He4qO5LcH7XLfBcK2c6EHsK9J/kszxeSVWNUWNpc2NYzUMYuiUaGMPIFeMoE tb/XCxAJ0pXfwUfh7oszL/W7NCWBtIGdvPfbVGBK7KfGImnt+Hdbk/SVC/adbAYTqnr8 rFUNmU4+Ig0gvs3fEVomfBsntx3V/PoE8h8HqGIczGAQUABzuh1pD7Zwv0utzvSWRK77 +L9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FyZPG7ecMtPTu7c8gkIkFgQ1x9YPQvFNs7IqBS9P2iw=; b=UQTGvW3hPUqblk7N0NVvtELwSLhLO+1R3Jl2L74b1xVMn+rGoAROSvXY0tB0KVDpcd tmPlRAwPd2qMBc4fbQv9DoEZigAb1ABVsv7yWmSTNUek5mTh582zOQv7ELu7gKQTYUty 4inbyaWmIoXswSrpzcoEpjvdqh82Uz3D9CHq5v+RY+7lgzEjnOS3TK4aAl1VmMNwJQsa KyISQzNzzGqoj1Ekdvtm/36hNyXpB1c+P7SKA7JkrGlwAabmzJqcTtep2cS9VWASWqDE PX0GOsP/tX7IZxk3Cq83rFgMDLwROyRyQ2WzFhhNySSF80kBg9NXsPkWAQgzCq4AOh/r mmiA== X-Gm-Message-State: AJIora/aX4gRInu8vad5p+cErp1TDMDzDz99lYv5namiH2wd343bNhJ6 lGutu7FJUGhpsLTfEH9yDdtfuZ6W8KjgwEey X-Google-Smtp-Source: AGRyM1tszaPEGImA9JSpi/gagvfI+XhMcXbb2tzzDh0J0vODfixd06pXodsQX2mdEZzJ750HWUCmHA== X-Received: by 2002:a67:fbc2:0:b0:356:fd6b:8d09 with SMTP id o2-20020a67fbc2000000b00356fd6b8d09mr5415717vsr.45.1657132052034; Wed, 06 Jul 2022 11:27:32 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:31 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia , Dmitry Osipenko Subject: [PATCH 3/8] tegra-vde: Use vb2_find_buffer Date: Wed, 6 Jul 2022 15:26:52 -0300 Message-Id: <20220706182657.210650-4-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced vb2_find_buffer API to get a vb2_buffer given a buffer timestamp. Cc: Dmitry Osipenko Signed-off-by: Ezequiel Garcia --- drivers/media/platform/nvidia/tegra-vde/h264.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-vde/h264.c b/drivers/media/platform/nvidia/tegra-vde/h264.c index 88f81a134ba0..204e474d57f7 100644 --- a/drivers/media/platform/nvidia/tegra-vde/h264.c +++ b/drivers/media/platform/nvidia/tegra-vde/h264.c @@ -659,20 +659,19 @@ static struct vb2_buffer *get_ref_buf(struct tegra_ctx *ctx, { const struct v4l2_h264_dpb_entry *dpb = ctx->h264.decode_params->dpb; struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q; - int buf_idx = -1; + struct vb2_buffer *vb = NULL; if (dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) - buf_idx = vb2_find_timestamp(cap_q, - dpb[dpb_idx].reference_ts, 0); + vb = vb2_find_buffer(cap_q, dpb[dpb_idx].reference_ts); /* * If a DPB entry is unused or invalid, address of current destination * buffer is returned. */ - if (buf_idx < 0) + if (!vb) return &dst->vb2_buf; - return vb2_get_buffer(cap_q, buf_idx); + return vb; } static int tegra_vde_validate_vb_size(struct tegra_ctx *ctx, From patchwork Wed Jul 6 18:26:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67852C43334 for ; Wed, 6 Jul 2022 18:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233420AbiGFS1i (ORCPT ); Wed, 6 Jul 2022 14:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234139AbiGFS1g (ORCPT ); Wed, 6 Jul 2022 14:27:36 -0400 Received: from mail-vk1-xa32.google.com (mail-vk1-xa32.google.com [IPv6:2607:f8b0:4864:20::a32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 263FC1055B for ; Wed, 6 Jul 2022 11:27:35 -0700 (PDT) Received: by mail-vk1-xa32.google.com with SMTP id b5so7805033vkp.4 for ; Wed, 06 Jul 2022 11:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gwI3B/pNe57ukV/bZE0Q4gbpZ46EhYOPKwpHR+DMozk=; b=3rvLnDYjlDgAD6tjeHhgDfzll8/87learjvs4vwZzZikbMzP5g45wL3sG3r9IjFxQo S7RxwQzGjMBsNt9zx5YODv4VurfvXp5AbuTQiTrAf+PaAaalad6KvP1vCbhbT39bsaK4 eRid6zFuGSoCBzephrUkmOB6HPTzgz1R5XAtcc9iNIp7Sm/Jrz7Nfzq3UMZi5zIyhwrQ rM1MEq87lsdW3FrFfDQ19DkE4eoVTrZijFQOyIFNMrRlw5XedpF8dZNHIid3LVnL+e4G 7QDQ8z0rXNmRz1+CpPQ6/qagXfdMfJN4VuyfH0XtJ88JhGlacyAw3N7FIgHGrjuYYxna FJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gwI3B/pNe57ukV/bZE0Q4gbpZ46EhYOPKwpHR+DMozk=; b=Zc3fcufST/TkvnAJLD4XmCIXeDSlxfiIsKieEpRCdHESlwWM0lLgaXwm9bjpmR4hcW nLLVFQiAAJ6CCbC6bp8udUSzUVE8x5gOwO5igOIjp5Q1PCxcKR/OCHO7ET8XYB9dUfs1 LXlnoap2FtfNboaSqcuiX2+RH42QTBDwMBopZ9rzEp5CSQqFusma9wNerCzOS6xzSkyi 8vU4k3gq5+MCz12G11CidoQ57BifnK5T9ApPZoqbSClYoHKUy1328NBT1NHQRpMWZQ4d 3GXUAWbPDGBISyAFsnpWqqBUywgzOb8mrWsbZKiOuZPPPytgW3bREgsWWnYkmttBplh0 T4dw== X-Gm-Message-State: AJIora/f/87gfvTxhV3sBzLp8MkkeaV1/pJIeDAsa9wImc/RnhT2DhK/ 82ml6S/sD0xGsCJ1Sm6mXsKxDTArrTlVb+EM X-Google-Smtp-Source: AGRyM1v9RiWAEK11B6u6zMGoJ9dRE/OGrpnfiKi/Fn85mPh8O24xcD6ETQWvSfKzXZZJAWTTCG6LqA== X-Received: by 2002:a1f:3296:0:b0:374:19b8:1df5 with SMTP id y144-20020a1f3296000000b0037419b81df5mr5446639vky.7.1657132054008; Wed, 06 Jul 2022 11:27:34 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:33 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia Subject: [PATCH 4/8] vicodec: Use vb2_find_buffer Date: Wed, 6 Jul 2022 15:26:53 -0300 Message-Id: <20220706182657.210650-5-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced vb2_find_buffer API to get a vb2_buffer given a buffer timestamp. Cc: Hans Verkuil Signed-off-by: Ezequiel Garcia --- drivers/media/test-drivers/vicodec/vicodec-core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index be43f7d32df9..1d1bee111732 100644 --- a/drivers/media/test-drivers/vicodec/vicodec-core.c +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c @@ -280,17 +280,13 @@ static int device_process(struct vicodec_ctx *ctx, */ if (!(ntohl(ctx->state.header.flags) & V4L2_FWHT_FL_I_FRAME)) { struct vb2_buffer *ref_vb2_buf; - int ref_buf_idx; struct vb2_queue *vq_cap = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - ref_buf_idx = vb2_find_timestamp(vq_cap, - ctx->state.ref_frame_ts, 0); - if (ref_buf_idx < 0) + ref_vb2_buf = vb2_find_buffer(vq_cap, ctx->state.ref_frame_ts); + if (!ref_vb2_buf) return -EINVAL; - - ref_vb2_buf = vq_cap->bufs[ref_buf_idx]; if (ref_vb2_buf->state == VB2_BUF_STATE_ERROR) ret = -EINVAL; ctx->state.ref_frame.buf = From patchwork Wed Jul 6 18:26:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26A1FC43334 for ; Wed, 6 Jul 2022 18:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234350AbiGFS1l (ORCPT ); Wed, 6 Jul 2022 14:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234055AbiGFS1h (ORCPT ); Wed, 6 Jul 2022 14:27:37 -0400 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F14D13E83 for ; Wed, 6 Jul 2022 11:27:37 -0700 (PDT) Received: by mail-vs1-xe30.google.com with SMTP id t127so2002519vsb.8 for ; Wed, 06 Jul 2022 11:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=McgJarXoZM45I88Tjkykz9D1NEdll4H/rO3vnYMbjF8=; b=oX/Uyq2BPSSGb8F4U0b+VccUzMVgyUrnFb+uaTpEyDeQjNmBZ9Jz6JEUch2ZwMQ0nH mNQIncj0ZpUFFDVh8Q5HQkJC21RJOCKwiLQKjNUiByiIcThxrTLU1Oe7/JDB4Wag9sfR Bf4Z5hC5erNOALnSNp8zYEonzu2g+5FkZpEM0VbLiLquxlXab7g7HqRXcy8E3CQBpoY9 gwrx5SxJWbj6DyQlyybXjAOPvjhTfUBL2b3YjYWSRDJfNUz+tSqR66E50Bkhk91ecFhb tZVH5RUQXW6GDP7ARjQWNBxDbpVKM7wNOp7cR0/whrPNG3pLVWU/7W0KkoMdL1TKRM4u 5O7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=McgJarXoZM45I88Tjkykz9D1NEdll4H/rO3vnYMbjF8=; b=C+S8KUvR88FVt8Z0Ek9rKWQWstiFyfs4jbDb0hWCae2lgDJlVtfuZ4wApdH7CbqEdm 5soP7eL0oVGUjDf579L5ZqW54Np2MfOgJdmbd4cOGZQ5TbAJx6Z0IQqg4e/mEXihpSuB mjLgrFQ1g1Tczwr2GuSHkBznVSlUIAJyk/x2tjbCwdYMBOxu+a+YSmqdVHhRW+zIWUAr 4Ysmh3O/94q5KtosvMKNcgnJrE+0bR+SDAuqGUr4vZAn52bAD4rjTAWfh5HxtB81EAz7 NywpM6SHXINp8fuUH4tjVGuUhEIYFCCgygBHD2Ngke6C3m+897RcKo5RlK0OunIuI4nc XhXA== X-Gm-Message-State: AJIora9v5fa2u3HOvPhXU1OpIhUDdIcJP3z3gXyEts9tHqd7kVNH5NXd aoJHk9Y12AbxvCD+ojUo24VmVLUzTEjr2kwy X-Google-Smtp-Source: AGRyM1u+9y1GvDNJjTADUZtxLGQcFZ4mTEixyb9LWGvZao1+L59nYg+Zu6EIMXAbEu6UcCVPeOVgvQ== X-Received: by 2002:a67:ba09:0:b0:354:5d45:67ed with SMTP id l9-20020a67ba09000000b003545d4567edmr23473379vsn.18.1657132056035; Wed, 06 Jul 2022 11:27:36 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:35 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia , Philipp Zabel Subject: [PATCH 5/8] hantro: Use vb2_find_buffer Date: Wed, 6 Jul 2022 15:26:54 -0300 Message-Id: <20220706182657.210650-6-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced vb2_find_buffer API to get a vb2_buffer given a buffer timestamp. Cc: Philipp Zabel Signed-off-by: Ezequiel Garcia --- drivers/staging/media/hantro/hantro_drv.c | 6 ++---- drivers/staging/media/hantro/hantro_g2_vp9_dec.c | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index 01d33dcb0467..8cb5cf53e5e7 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -47,12 +47,10 @@ dma_addr_t hantro_get_ref(struct hantro_ctx *ctx, u64 ts) { struct vb2_queue *q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx); struct vb2_buffer *buf; - int index; - index = vb2_find_timestamp(q, ts, 0); - if (index < 0) + buf = vb2_find_buffer(q, ts); + if (!buf) return 0; - buf = vb2_get_buffer(q, index); return hantro_get_dec_buf_addr(ctx, buf); } diff --git a/drivers/staging/media/hantro/hantro_g2_vp9_dec.c b/drivers/staging/media/hantro/hantro_g2_vp9_dec.c index 91c21b634fab..6d452c779633 100644 --- a/drivers/staging/media/hantro/hantro_g2_vp9_dec.c +++ b/drivers/staging/media/hantro/hantro_g2_vp9_dec.c @@ -111,17 +111,17 @@ get_ref_buf(struct hantro_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp) { struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; - int buf_idx; + struct vb2_buffer *buf; /* * If a ref is unused or invalid, address of current destination * buffer is returned. */ - buf_idx = vb2_find_timestamp(cap_q, timestamp, 0); - if (buf_idx < 0) - return vb2_to_hantro_decoded_buf(&dst->vb2_buf); + buf = vb2_find_buffer(cap_q, timestamp); + if (!buf) + buf = &dst->vb2_buf; - return vb2_to_hantro_decoded_buf(vb2_get_buffer(cap_q, buf_idx)); + return vb2_to_hantro_decoded_buf(buf); } static void update_dec_buf_info(struct hantro_decoded_buffer *buf, From patchwork Wed Jul 6 18:26:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CF14C43334 for ; Wed, 6 Jul 2022 18:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234425AbiGFS1y (ORCPT ); Wed, 6 Jul 2022 14:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234347AbiGFS1k (ORCPT ); Wed, 6 Jul 2022 14:27:40 -0400 Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F79D626F for ; Wed, 6 Jul 2022 11:27:39 -0700 (PDT) Received: by mail-vs1-xe29.google.com with SMTP id 126so15923966vsq.13 for ; Wed, 06 Jul 2022 11:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=asP5WW1PtGLGLgC0vcc0NACNPp01Esm7Z0OiLq0F9GE=; b=e6E0l3l2m7wx9DfuBdN98IXo/uMT8eNuaVhyKairk07glycS6SudxNgAO1q4AusERU QqHy5C1dtQxgTSgXQlqQVF7geYlOnafE+9Rhmvfx7oEeqhL1sbONHn3w53Kpn+5SxlmH f20csUOIZN4FmseOzNRXO3LNHMPCp+5MRl4mucPDVJElmG9XKdMIlpA5IwzywZVhrpWY xeZTj644UAInFi3V5Co4thuUKWdNdGpNC6Jr+fjZi/hS/BS+p/POoGy+tT8Vo1vAUgLL VGGQC+jMLHxWYoJJ4Wt0u+wGV3cRHu+iz0yYBwGS/Tx9kEot903tHMWxK1a7xqP7lNzi TQZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=asP5WW1PtGLGLgC0vcc0NACNPp01Esm7Z0OiLq0F9GE=; b=YKH0OX3771AKlegXkh76Ih3OB8dAe30akHDHMCV/s/HIS8UA4xp7mmklPW0cKoVNMI Fli4ZeLPPkemZnYt6tRd/1qTaifmQVrpMiEsRBVybhJrAkqm2Mwe28idrKvgH5JEvhJ3 qKeBk1/mGcR95DWrlOqBYEDMDTGayfeoBrlMJnx3lWdhtnmp2QVvxhMYU9TOYa+bbT9d YbvmvzbZaRXfwCK6TWfrdEYGiKvl+1McX8RVN9NMqaEvZIauuLpxkKbkaCzQuHJSb2k+ uXuJFWnakLvIVspDxcYVKUcnk0RGXywcYPCF78t8JVnMMJ/k2l0fInkL8BAwydcfC3+R Hzig== X-Gm-Message-State: AJIora8vnp0dDKvaNl4bxlaLJ1UB7AW6Fr4MGkPFn+gkz064MYvYNZ+x oYX/saN1LlVlZZenSxdTrM0G6lqGjQAXJMqm X-Google-Smtp-Source: AGRyM1sRmSJOnVT2Z9R7fyhZzK3ZT/63r3+D4BCtYWOheW/rx5RrOQ2VTSy0I31C9Jr/wNmHWAW39g== X-Received: by 2002:a05:6102:ed3:b0:356:11c2:5ea3 with SMTP id m19-20020a0561020ed300b0035611c25ea3mr22570290vst.15.1657132058001; Wed, 06 Jul 2022 11:27:38 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:37 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia Subject: [PATCH 6/8] rkvdec: Use vb2_find_buffer Date: Wed, 6 Jul 2022 15:26:55 -0300 Message-Id: <20220706182657.210650-7-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced vb2_find_buffer API to get a vb2_buffer given a buffer timestamp. Signed-off-by: Ezequiel Garcia --- drivers/staging/media/rkvdec/rkvdec-h264.c | 41 ++++++++-------------- drivers/staging/media/rkvdec/rkvdec-vp9.c | 10 +++--- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index 2992fb87cf72..4af5a831bde0 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -109,7 +109,7 @@ struct rkvdec_h264_run { const struct v4l2_ctrl_h264_sps *sps; const struct v4l2_ctrl_h264_pps *pps; const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; - int ref_buf_idx[V4L2_H264_NUM_DPB_ENTRIES]; + struct vb2_buffer *ref_buf[V4L2_H264_NUM_DPB_ENTRIES]; }; struct rkvdec_h264_ctx { @@ -742,17 +742,16 @@ static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; - int buf_idx = -1; + struct vb2_buffer *buf = NULL; if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) { - buf_idx = vb2_find_timestamp(cap_q, - dpb[i].reference_ts, 0); - if (buf_idx < 0) + buf = vb2_find_buffer(cap_q, dpb[i].reference_ts); + if (!buf) pr_debug("No buffer for reference_ts %llu", dpb[i].reference_ts); } - run->ref_buf_idx[i] = buf_idx; + run->ref_buf[i] = buf; } } @@ -805,7 +804,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, if (WARN_ON(ref->index >= ARRAY_SIZE(dec_params->dpb))) continue; - dpb_valid = run->ref_buf_idx[ref->index] >= 0; + dpb_valid = run->ref_buf[ref->index] != NULL; bottom = ref->fields == V4L2_H264_BOTTOM_FIELD_REF; set_ps_field(hw_rps, DPB_INFO(i, j), @@ -881,24 +880,6 @@ static const u32 poc_reg_tbl_bottom_field[16] = { RKVDEC_REG_H264_POC_REFER2(1) }; -static struct vb2_buffer * -get_ref_buf(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run, - unsigned int dpb_idx) -{ - struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; - struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; - int buf_idx = run->ref_buf_idx[dpb_idx]; - - /* - * If a DPB entry is unused or invalid, address of current destination - * buffer is returned. - */ - if (buf_idx < 0) - return &run->base.bufs.dst->vb2_buf; - - return vb2_get_buffer(cap_q, buf_idx); -} - static void config_registers(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run) { @@ -971,8 +952,14 @@ static void config_registers(struct rkvdec_ctx *ctx, /* config ref pic address & poc */ for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { - struct vb2_buffer *vb_buf = get_ref_buf(ctx, run, i); - + struct vb2_buffer *vb_buf = run->ref_buf[i]; + + /* + * If a DPB entry is unused or invalid, address of current destination + * buffer is returned. + */ + if (!vb_buf) + vb_buf = &dst_buf->vb2_buf; refer_addr = vb2_dma_contig_plane_dma_addr(vb_buf, 0); if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) diff --git a/drivers/staging/media/rkvdec/rkvdec-vp9.c b/drivers/staging/media/rkvdec/rkvdec-vp9.c index c2f42e76be10..d8c1c0db15c7 100644 --- a/drivers/staging/media/rkvdec/rkvdec-vp9.c +++ b/drivers/staging/media/rkvdec/rkvdec-vp9.c @@ -383,17 +383,17 @@ get_ref_buf(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp) { struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; - int buf_idx; + struct vb2_buffer *buf; /* * If a ref is unused or invalid, address of current destination * buffer is returned. */ - buf_idx = vb2_find_timestamp(cap_q, timestamp, 0); - if (buf_idx < 0) - return vb2_to_rkvdec_decoded_buf(&dst->vb2_buf); + buf = vb2_find_buffer(cap_q, timestamp); + if (!buf) + buf = &dst->vb2_buf; - return vb2_to_rkvdec_decoded_buf(vb2_get_buffer(cap_q, buf_idx)); + return vb2_to_rkvdec_decoded_buf(buf); } static dma_addr_t get_mv_base_addr(struct rkvdec_decoded_buffer *buf) From patchwork Wed Jul 6 18:26:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3846CCCA481 for ; Wed, 6 Jul 2022 18:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234440AbiGFS2J (ORCPT ); Wed, 6 Jul 2022 14:28:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234279AbiGFS1s (ORCPT ); Wed, 6 Jul 2022 14:27:48 -0400 Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAFC1ADA8 for ; Wed, 6 Jul 2022 11:27:41 -0700 (PDT) Received: by mail-ua1-x936.google.com with SMTP id n3so3532730uak.13 for ; Wed, 06 Jul 2022 11:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3otKT1ZkeoSoRtH+ozMyr43VyMZOo72OStANlEPpJEI=; b=4rX7JkzmwMbGPpgfzxDYbbu6ZGutkVZKcv0RSmlpRPwmh3FyPMF/5ycz7p/ydzLswi L7hOwuT+9CzoUxSZNINlsFbIFcHwXogV7JF4u8rvYwRiChEdkv5Tlz7IvAnq8kS/C3j8 XIlaFX178XTY65DxVhoB/mtDJM3JPyMnWjobkk3HZJqhUKPRZlMEK5eNIUBJXQtegHqB gXUMSZgMgMLmvQ2NRYGKdXltpysN2Sd6qmxVNGxt/1xUizgUzRrYNHv6jMcntovzhaqu EmjxylP0L1fDyXqLAc0lWgRWWW5VXIeFi1yS0qK6Uk1Wja1z9aKNd6QrWzDSupWnRDde 3r2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3otKT1ZkeoSoRtH+ozMyr43VyMZOo72OStANlEPpJEI=; b=mAaoVyLWK1v7XMj135FQhjx/sJF7cbzB1HEk2zOu8mKpo54AnSBZRlJU9Mj19uR+wC m2/TcUCpWkG8zZLDumCd3CbeCcwzj4/MSVyvrTZofZIo/t+xENLdywQySjtM9kBtiyw6 m1rd28+x0GsfT16PFi71Pb6L6NqJloY3z523NipB3Z97XuWqYMFkNhcpw3HBxLgTju+a 4nQk6vjv9+32rarP1uApOsT/sCCHQE18N7InnMn2WMEOWD79hE6QaY5dO/4ToWlknhBz oDiD6yFxeuDWufjSDu73CiErzRHR/Uv04sPLCdJmOPsC0jn/h1MYPmgy3glf9EXxGtuk OCEQ== X-Gm-Message-State: AJIora/3MkW8/i75NyTwTetukxqWD5p9UuKd6qyVqjbCci59gWUu5ciz sWK2U6CLXxzPtAEC39vD6UZeYAUsSQSk0J/b X-Google-Smtp-Source: AGRyM1vEbBKRodzxnzA1N9nmG59U9TjaxOkOJZtrIDUVL1tP0FQ44IV32SMwiCr8FYVjtdKLg95gUw== X-Received: by 2002:ab0:7a43:0:b0:382:96f8:7457 with SMTP id a3-20020ab07a43000000b0038296f87457mr8555649uat.45.1657132060316; Wed, 06 Jul 2022 11:27:40 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:39 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia , Maxime Ripard , Paul Kocialkowski , Jernej Skrabec Subject: [PATCH 7/8] cedrus: Use vb2_find_buffer Date: Wed, 6 Jul 2022 15:26:56 -0300 Message-Id: <20220706182657.210650-8-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced vb2_find_buffer API to get a vb2_buffer given a buffer timestamp. Cc: Maxime Ripard Cc: Paul Kocialkowski Cc: Jernej Skrabec Signed-off-by: Ezequiel Garcia --- drivers/staging/media/sunxi/cedrus/cedrus.h | 13 +---- .../staging/media/sunxi/cedrus/cedrus_h264.c | 16 +++--- .../staging/media/sunxi/cedrus/cedrus_h265.c | 16 +++--- .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 36 ++++++------- .../staging/media/sunxi/cedrus/cedrus_vp8.c | 50 ++++++------------- 5 files changed, 49 insertions(+), 82 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 3bc094eb497f..a9908cc5c848 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -233,18 +233,9 @@ static inline dma_addr_t cedrus_buf_addr(struct vb2_buffer *buf, } static inline dma_addr_t cedrus_dst_buf_addr(struct cedrus_ctx *ctx, - int index, unsigned int plane) + struct vb2_buffer *buf, + unsigned int plane) { - struct vb2_buffer *buf = NULL; - struct vb2_queue *vq; - - if (index < 0) - return 0; - - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - if (vq) - buf = vb2_get_buffer(vq, index); - return buf ? cedrus_buf_addr(buf, &ctx->dst_fmt, plane) : 0; } diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index d8fb93035470..0559efeac125 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -111,16 +111,16 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx, for (i = 0; i < ARRAY_SIZE(decode->dpb); i++) { const struct v4l2_h264_dpb_entry *dpb = &decode->dpb[i]; struct cedrus_buffer *cedrus_buf; - int buf_idx; + struct vb2_buffer *buf; if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID)) continue; - buf_idx = vb2_find_timestamp(cap_q, dpb->reference_ts, 0); - if (buf_idx < 0) + buf = vb2_find_buffer(cap_q, dpb->reference_ts); + if (!buf) continue; - cedrus_buf = vb2_to_cedrus_buffer(cap_q->bufs[buf_idx]); + cedrus_buf = vb2_to_cedrus_buffer(buf); position = cedrus_buf->codec.h264.position; used_dpbs |= BIT(position); @@ -186,7 +186,7 @@ static void _cedrus_write_ref_list(struct cedrus_ctx *ctx, const struct v4l2_h264_dpb_entry *dpb; const struct cedrus_buffer *cedrus_buf; unsigned int position; - int buf_idx; + struct vb2_buffer *buf; u8 dpb_idx; dpb_idx = ref_list[i].index; @@ -195,11 +195,11 @@ static void _cedrus_write_ref_list(struct cedrus_ctx *ctx, if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) continue; - buf_idx = vb2_find_timestamp(cap_q, dpb->reference_ts, 0); - if (buf_idx < 0) + buf = vb2_find_buffer(cap_q, dpb->reference_ts); + if (!buf) continue; - cedrus_buf = vb2_to_cedrus_buffer(cap_q->bufs[buf_idx]); + cedrus_buf = vb2_to_cedrus_buffer(buf); position = cedrus_buf->codec.h264.position; sram_array[i] |= position << 1; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index 44f385be9f6c..60cc13e4d0a9 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -102,14 +102,14 @@ static void cedrus_h265_frame_info_write_single(struct cedrus_ctx *ctx, unsigned int index, bool field_pic, u32 pic_order_cnt[], - int buffer_index) + struct vb2_buffer *buf) { struct cedrus_dev *dev = ctx->dev; - dma_addr_t dst_luma_addr = cedrus_dst_buf_addr(ctx, buffer_index, 0); - dma_addr_t dst_chroma_addr = cedrus_dst_buf_addr(ctx, buffer_index, 1); + dma_addr_t dst_luma_addr = cedrus_dst_buf_addr(ctx, buf, 0); + dma_addr_t dst_chroma_addr = cedrus_dst_buf_addr(ctx, buf, 1); dma_addr_t mv_col_buf_addr[2] = { - cedrus_h265_frame_info_mv_col_buf_addr(ctx, buffer_index, 0), - cedrus_h265_frame_info_mv_col_buf_addr(ctx, buffer_index, + cedrus_h265_frame_info_mv_col_buf_addr(ctx, buf->index, 0), + cedrus_h265_frame_info_mv_col_buf_addr(ctx, buf->index, field_pic ? 1 : 0) }; u32 offset = VE_DEC_H265_SRAM_OFFSET_FRAME_INFO + @@ -141,7 +141,7 @@ static void cedrus_h265_frame_info_write_dpb(struct cedrus_ctx *ctx, unsigned int i; for (i = 0; i < num_active_dpb_entries; i++) { - int buffer_index = vb2_find_timestamp(vq, dpb[i].timestamp, 0); + struct vb2_buffer *buf = vb2_find_buffer(vq, dpb[i].timestamp); u32 pic_order_cnt[2] = { dpb[i].pic_order_cnt[0], dpb[i].pic_order_cnt[1] @@ -149,7 +149,7 @@ static void cedrus_h265_frame_info_write_dpb(struct cedrus_ctx *ctx, cedrus_h265_frame_info_write_single(ctx, i, dpb[i].field_pic, pic_order_cnt, - buffer_index); + buf); } } @@ -616,7 +616,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx, cedrus_h265_frame_info_write_single(ctx, output_pic_list_index, slice_params->pic_struct != 0, pic_order_cnt, - run->dst->vb2_buf.index); + &run->dst->vb2_buf); cedrus_write(dev, VE_DEC_H265_OUTPUT_FRAME_IDX, output_pic_list_index); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c index 5dad2f296c6d..ab9cfa001a49 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -13,6 +13,16 @@ #include "cedrus_hw.h" #include "cedrus_regs.h" +static void write_ref_buf_addr(struct cedrus_ctx *ctx, struct vb2_queue *q, + u64 timestamp, u32 luma_reg, u32 chroma_reg) +{ + struct cedrus_dev *dev = ctx->dev; + struct vb2_buffer *buf = vb2_find_buffer(q, timestamp); + + cedrus_write(dev, luma_reg, cedrus_dst_buf_addr(ctx, buf, 0)); + cedrus_write(dev, chroma_reg, cedrus_dst_buf_addr(ctx, buf, 1)); +} + static enum cedrus_irq_status cedrus_mpeg2_irq_status(struct cedrus_ctx *ctx) { struct cedrus_dev *dev = ctx->dev; @@ -54,13 +64,9 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) const struct v4l2_ctrl_mpeg2_picture *pic; const struct v4l2_ctrl_mpeg2_quantisation *quantisation; dma_addr_t src_buf_addr, dst_luma_addr, dst_chroma_addr; - dma_addr_t fwd_luma_addr, fwd_chroma_addr; - dma_addr_t bwd_luma_addr, bwd_chroma_addr; struct cedrus_dev *dev = ctx->dev; struct vb2_queue *vq; const u8 *matrix; - int forward_idx; - int backward_idx; unsigned int i; u32 reg; @@ -123,27 +129,17 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg); /* Forward and backward prediction reference buffers. */ - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - forward_idx = vb2_find_timestamp(vq, pic->forward_ref_ts, 0); - fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0); - fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1); - - cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr); - cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr); - - backward_idx = vb2_find_timestamp(vq, pic->backward_ref_ts, 0); - bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0); - bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1); - - cedrus_write(dev, VE_DEC_MPEG_BWD_REF_LUMA_ADDR, bwd_luma_addr); - cedrus_write(dev, VE_DEC_MPEG_BWD_REF_CHROMA_ADDR, bwd_chroma_addr); + write_ref_buf_addr(ctx, vq, pic->forward_ref_ts, + VE_DEC_MPEG_FWD_REF_LUMA_ADDR, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR); + write_ref_buf_addr(ctx, vq, pic->backward_ref_ts, + VE_DEC_MPEG_BWD_REF_LUMA_ADDR, VE_DEC_MPEG_BWD_REF_CHROMA_ADDR); /* Destination luma and chroma buffers. */ - dst_luma_addr = cedrus_dst_buf_addr(ctx, run->dst->vb2_buf.index, 0); - dst_chroma_addr = cedrus_dst_buf_addr(ctx, run->dst->vb2_buf.index, 1); + dst_luma_addr = cedrus_dst_buf_addr(ctx, &run->dst->vb2_buf, 0); + dst_chroma_addr = cedrus_dst_buf_addr(ctx, &run->dst->vb2_buf, 1); cedrus_write(dev, VE_DEC_MPEG_REC_LUMA, dst_luma_addr); cedrus_write(dev, VE_DEC_MPEG_REC_CHROMA, dst_chroma_addr); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c index f4016684b32d..a253f6b92135 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c @@ -516,6 +516,16 @@ static void process_ref_frame_info(struct cedrus_dev *dev) read_bits(dev, 1, VP8_PROB_HALF); } +static void write_ref_buf_addr(struct cedrus_ctx *ctx, struct vb2_queue *q, + u64 timestamp, u32 luma_reg, u32 chroma_reg) +{ + struct cedrus_dev *dev = ctx->dev; + struct vb2_buffer *buf = vb2_find_buffer(q, timestamp); + + cedrus_write(dev, luma_reg, cedrus_dst_buf_addr(ctx, buf, 0)); + cedrus_write(dev, chroma_reg, cedrus_dst_buf_addr(ctx, buf, 1)); +} + static void cedrus_irq_clear(struct cedrus_dev *dev) { cedrus_write(dev, VE_H264_STATUS, @@ -661,7 +671,6 @@ static void cedrus_vp8_setup(struct cedrus_ctx *ctx, dma_addr_t luma_addr, chroma_addr; dma_addr_t src_buf_addr; int header_size; - int qindex; u32 reg; cedrus_engine_enable(ctx, CEDRUS_CODEC_VP8); @@ -805,43 +814,14 @@ static void cedrus_vp8_setup(struct cedrus_ctx *ctx, reg |= VE_VP8_LF_DELTA0(slice->lf.mb_mode_delta[0]); cedrus_write(dev, VE_VP8_MODE_LF_DELTA, reg); - luma_addr = cedrus_dst_buf_addr(ctx, run->dst->vb2_buf.index, 0); - chroma_addr = cedrus_dst_buf_addr(ctx, run->dst->vb2_buf.index, 1); + luma_addr = cedrus_dst_buf_addr(ctx, &run->dst->vb2_buf, 0); + chroma_addr = cedrus_dst_buf_addr(ctx, &run->dst->vb2_buf, 1); cedrus_write(dev, VE_VP8_REC_LUMA, luma_addr); cedrus_write(dev, VE_VP8_REC_CHROMA, chroma_addr); - qindex = vb2_find_timestamp(cap_q, slice->last_frame_ts, 0); - if (qindex >= 0) { - luma_addr = cedrus_dst_buf_addr(ctx, qindex, 0); - chroma_addr = cedrus_dst_buf_addr(ctx, qindex, 1); - cedrus_write(dev, VE_VP8_FWD_LUMA, luma_addr); - cedrus_write(dev, VE_VP8_FWD_CHROMA, chroma_addr); - } else { - cedrus_write(dev, VE_VP8_FWD_LUMA, 0); - cedrus_write(dev, VE_VP8_FWD_CHROMA, 0); - } - - qindex = vb2_find_timestamp(cap_q, slice->golden_frame_ts, 0); - if (qindex >= 0) { - luma_addr = cedrus_dst_buf_addr(ctx, qindex, 0); - chroma_addr = cedrus_dst_buf_addr(ctx, qindex, 1); - cedrus_write(dev, VE_VP8_BWD_LUMA, luma_addr); - cedrus_write(dev, VE_VP8_BWD_CHROMA, chroma_addr); - } else { - cedrus_write(dev, VE_VP8_BWD_LUMA, 0); - cedrus_write(dev, VE_VP8_BWD_CHROMA, 0); - } - - qindex = vb2_find_timestamp(cap_q, slice->alt_frame_ts, 0); - if (qindex >= 0) { - luma_addr = cedrus_dst_buf_addr(ctx, qindex, 0); - chroma_addr = cedrus_dst_buf_addr(ctx, qindex, 1); - cedrus_write(dev, VE_VP8_ALT_LUMA, luma_addr); - cedrus_write(dev, VE_VP8_ALT_CHROMA, chroma_addr); - } else { - cedrus_write(dev, VE_VP8_ALT_LUMA, 0); - cedrus_write(dev, VE_VP8_ALT_CHROMA, 0); - } + write_ref_buf_addr(ctx, cap_q, slice->last_frame_ts, VE_VP8_FWD_LUMA, VE_VP8_FWD_CHROMA); + write_ref_buf_addr(ctx, cap_q, slice->golden_frame_ts, VE_VP8_BWD_LUMA, VE_VP8_BWD_CHROMA); + write_ref_buf_addr(ctx, cap_q, slice->alt_frame_ts, VE_VP8_ALT_LUMA, VE_VP8_ALT_CHROMA); cedrus_write(dev, VE_H264_CTRL, VE_H264_CTRL_VP8 | VE_H264_CTRL_DECODE_ERR_INT | From patchwork Wed Jul 6 18:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12908457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0732CC433EF for ; Wed, 6 Jul 2022 18:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234385AbiGFS2J (ORCPT ); Wed, 6 Jul 2022 14:28:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbiGFS1t (ORCPT ); Wed, 6 Jul 2022 14:27:49 -0400 Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDDD31401A for ; Wed, 6 Jul 2022 11:27:42 -0700 (PDT) Received: by mail-vs1-xe36.google.com with SMTP id u187so4618279vsb.3 for ; Wed, 06 Jul 2022 11:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a46G/5Kp8bkaeYYmOpRfozUG4SaHDyNgsSP9Rr+h6QE=; b=g0SLq0LnuE9jAGE7P2zsWXYZ9YETu++Y61y6oUR2yC7BEEp/PdsmGRziTsBeBDaxC6 9FzbHO7dv2IO47fouu86nQllnNbe9tEOAZnteVMWvpPh5/aYXD/Db4Xde+j8eBVwwwui PRhrpX34FlKXStOwMYGKecxTGBawU1RHOx25vMMHP+RVrU6mFY5uRzbxdQYBlzakz2Cb To+RAmYL22jrqYohsVXjN4KR5H+cXBoUhP5rZ/g3Y/sqMtXbQzTO53ZFzxk3Ik7i3vT4 0xcjNSrA2RUVKOXkNBjxtY6lqCRJkRuAVoG+36Hn1ytGPiaMnM3YOE5jevKrUsxYPAus J6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a46G/5Kp8bkaeYYmOpRfozUG4SaHDyNgsSP9Rr+h6QE=; b=g2IfuSQ77Ma8T3RhbLqdUNIOXprEpCtSI+NONa07Bqclg1bLOSDY8y5C4vBg6aAxfd lv+Dad0lqX749SxSkrIyGbBEtKZFtJ1z+7sEOrRtkqQKqiFXucQYKdXGdLNlnDNIjULc S+EvNO9NUxtVVLzHe/Li2McnG6AkV0MiAenZifeyPTmC6I+HDk7xu31CYtVBSXD2PYlv FvtrO6GiG9DOpe53Xw2QywD4DJbD98r3sBbmDSUkADqIOJ40abcPMwXsERXkOvNfIF5s lpIPsPJCu9OYe2NIP8fMw/yY1jFuQuCWpXmzrBrcVXEI7D71/nupOb6GZKSldj3dnHGW G9dQ== X-Gm-Message-State: AJIora+fFRaG0y4EGaNepN7Yc81sd22jzc5ikt1uq9koV6ZlcrjOpGgw PgZV5rrS4v6gKh9rsn+gxE7uA3qfeIVh8R9C X-Google-Smtp-Source: AGRyM1uSdkj6qPOlusiT7/0GDbe5C66rPoAbPf5ElEfgtvV7wAFLaBx/s4AsuvBVjFUVEDA8xWCZAg== X-Received: by 2002:a67:b805:0:b0:354:4207:2fc6 with SMTP id i5-20020a67b805000000b0035442072fc6mr22080725vsf.64.1657132062185; Wed, 06 Jul 2022 11:27:42 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id bl9-20020a056102508900b003563680212asm7445539vsb.27.2022.07.06.11.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:27:41 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Marek Szyprowski , Ezequiel Garcia Subject: [PATCH 8/8] videobuf2: Remove vb2_find_timestamp() Date: Wed, 6 Jul 2022 15:26:57 -0300 Message-Id: <20220706182657.210650-9-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> References: <20220706182657.210650-1-ezequiel@vanguardiasur.com.ar> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Now that we've transitioned all users to vb2_find_buffer API, remove the unused vb2_find_timestamp(). Signed-off-by: Ezequiel Garcia --- .../media/common/videobuf2/videobuf2-v4l2.c | 12 ++++----- include/media/videobuf2-v4l2.h | 26 +------------------ 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 075d24ebf44c..a9696442dfba 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -625,18 +625,18 @@ static const struct vb2_buf_ops v4l2_buf_ops = { .copy_timestamp = __copy_timestamp, }; -int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, - unsigned int start_idx) +struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) { unsigned int i; - for (i = start_idx; i < q->num_buffers; i++) + for (i = 0; i < q->num_buffers; i++) if (q->bufs[i]->copied_timestamp && q->bufs[i]->timestamp == timestamp) - return i; - return -1; + return vb2_get_buffer(q, i); + + return NULL; } -EXPORT_SYMBOL_GPL(vb2_find_timestamp); +EXPORT_SYMBOL_GPL(vb2_find_buffer); /* * vb2_querybuf() - query video buffer information diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 7f9ae5b39b78..5a845887850b 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -62,22 +62,6 @@ struct vb2_v4l2_buffer { #define to_vb2_v4l2_buffer(vb) \ container_of(vb, struct vb2_v4l2_buffer, vb2_buf) -/** - * vb2_find_timestamp() - Find buffer with given timestamp in the queue - * - * @q: pointer to &struct vb2_queue with videobuf2 queue. - * @timestamp: the timestamp to find. - * @start_idx: the start index (usually 0) in the buffer array to start - * searching from. Note that there may be multiple buffers - * with the same timestamp value, so you can restart the search - * by setting @start_idx to the previously found index + 1. - * - * Returns the buffer index of the buffer with the given @timestamp, or - * -1 if no buffer with @timestamp was found. - */ -int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, - unsigned int start_idx); - /** * vb2_find_buffer() - Find a buffer with given timestamp * @@ -86,15 +70,7 @@ int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, * * Returns the buffer with the given @timestamp, or NULL if not found. */ -static inline struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, - u64 timestamp) -{ - int index = vb2_find_timestamp(q, timestamp, 0); - - if (index < 0) - return NULL; - return vb2_get_buffer(q, index); -} +struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp); int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);