From patchwork Mon Jul 11 21:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914288 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 39A6CC43334 for ; Mon, 11 Jul 2022 21:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiGKVLy (ORCPT ); Mon, 11 Jul 2022 17:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiGKVLw (ORCPT ); Mon, 11 Jul 2022 17:11:52 -0400 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 029BB45064 for ; Mon, 11 Jul 2022 14:11:52 -0700 (PDT) Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-10bffc214ffso8219696fac.1 for ; Mon, 11 Jul 2022 14:11:51 -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=LyzUozuJU4BdsAIYqhi4n317kUN4El07MnlD4WMek9A=; b=GiUsAiGhNhkqEvptw+JKaLtTm4VODxNLVRyC8XKIxO8El5hyrgsjyq0rcgPvDS9ivs cCrLuIMpEKojgIHNfyVXej4Xu+UmuaTbo6qfPZD16zijup63334FxpBWWglPJzgzdl5t RcKUgya+Opa4EwY9ni2K7YxVP5hLiIR8lLsvPAgfR5PXj11keW17MoWiobcU4I8idpPf KbdD0TWw702UWVaEjp0Q/MLN6mPXZXlT1vGvz26UjFPbbVXZmUuv+39E3e8FX8jZlxV8 t8UwVF0wAYLiQvkq5qT2/WpHmH32QriPsMc5wUAj7zlc9Pab/jdld/XZHALml0loT3KU V1AQ== 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=LyzUozuJU4BdsAIYqhi4n317kUN4El07MnlD4WMek9A=; b=7aRYKmSYgBVTuOwNDaocd0fScQuINDT9hOY+meq95utPAQUXH1OzWuwhLBe32Ghg8k i4dYOCq+Q4+2B5/jHil5Kj5JTUTwp8J40LqTTkM4dm9WxqeZBN92OhQ8JjE9W1flHen4 QLG8u7wURRgUll0nxu4gGqlJ8Qt1lxk24WUwQq3F0g89qxFOWBgVa8XcWpli3m1TWH5E 1WyE2aPJ46NO8gaVnO7WoFy5CIvQKr8WlKUq8IUfhuiQ/lScWTs7X0cSg9hPn1YwhlVo zvDFJx497oxFztJ0Sg1ThYjofnpzAgtE46JMT3ts9rqto0ilJJf0AcUAx9i5N7ItmtnY DPfA== X-Gm-Message-State: AJIora8LKFs/MH0e7uh472qh8OojaOSkoA6RvMCO78j8spyF1UznXpyd xHn91yT4tJN0/G50qAX3FRXOgipM2ThL3QRq X-Google-Smtp-Source: AGRyM1vu3pSG3WIGRVXNNIZR77WzqoZE4bXt7ev5n7SYrsj7fTJ/whAiwWHnR22EqT18JI5TR1/69A== X-Received: by 2002:a05:6870:1490:b0:10c:3362:23c3 with SMTP id k16-20020a056870149000b0010c336223c3mr168171oab.73.1657573910976; Mon, 11 Jul 2022 14:11:50 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:50 -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 v2 1/8] videobuf2: Introduce vb2_find_buffer() Date: Mon, 11 Jul 2022 18:11:34 -0300 Message-Id: <20220711211141.349902-2-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa Reviewed-by: Philipp Zabel --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 12 ++++++++++++ include/media/videobuf2-v4l2.h | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 075d24ebf44c..f26cb8586bd4 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -638,6 +638,18 @@ int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, } EXPORT_SYMBOL_GPL(vb2_find_timestamp); +struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) +{ + unsigned int i; + + for (i = 0; i < q->num_buffers; i++) + if (q->bufs[i]->copied_timestamp && + q->bufs[i]->timestamp == timestamp) + return vb2_get_buffer(q, i); + return NULL; +} +EXPORT_SYMBOL_GPL(vb2_find_buffer); + /* * vb2_querybuf() - query video buffer information * @q: videobuf queue diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index d818d9707695..76e405c0b003 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -78,6 +78,16 @@ 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. + */ +struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp); + int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b); /** From patchwork Mon Jul 11 21:11:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914289 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 936B3C433EF for ; Mon, 11 Jul 2022 21:12:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231473AbiGKVMB (ORCPT ); Mon, 11 Jul 2022 17:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiGKVLz (ORCPT ); Mon, 11 Jul 2022 17:11:55 -0400 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B276A74E1E for ; Mon, 11 Jul 2022 14:11:54 -0700 (PDT) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-10be0d7476aso8201818fac.2 for ; Mon, 11 Jul 2022 14:11:54 -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=rKGgcE4D53nz5yukyjdYatlUUVmoyTwfHEisyp8wQM8=; b=bmedWoIZpXFzm5DN3AUodSCGdcB/l7svD47pCNTTiaopxVTSpEn1l5EEDTOZudmU0X zQcsYY08SMCuH8JxNpuV4ud23nwCTPg+i4yi2AYAvjbIYPxsvBZXC4m8ogAr5E7tWoT8 AUWgAuFxH7Qd55xCp+v+gp3Qd3xoXNTFcN90DJs1fobIt3qRSu/c5bJHGWR7J4VcNVMW FIz0KL2GWmClQCe7zV3q0I/Ocs99qxtSg/n8v60VnmOmYK0iSnnC8fbqS2qfyuyFQau4 6Ok+yBBFHTOF9ZDEwL1dJPnSeJcIx0WCDCU0Fty/TC/3vvix7g7RjpTKWvdihpX9ZoN0 RFjw== 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=rKGgcE4D53nz5yukyjdYatlUUVmoyTwfHEisyp8wQM8=; b=0GVOJ/nNcrWho7Are2z+mXUhHytfCFNoU6/ls12K6uvZMrDamXLg8oe6LjWl/XNHYw K8P32rHFF23ahIvIrATdhgStfYjG6PTk2tfjjWtWNOGnA8Sragyg5M42i385ldNeYMCS TjaZFVGp9fjCOMDOd+1goe5UUD8Ifx4QjjVdNykIJdKkdj2olQH+tUsvetPU34OGn/f6 U8Mjx8+gfw+LLsnBAyi+JRUrcRefIhYJHDG7R66Yw4KW5cNVVwikjVLj8f3GC9k5JHmQ hPHN1pUHdddjtavuBLcPv/oGRrXY2jHrYCw2FV4WK9AxIqZL9wDegNKILU+8yHGT9SQk PRog== X-Gm-Message-State: AJIora8jZU3//d8AfJsatIm2+gEjIvNBalWp/yjjBQkD/pgSP5u6l88d mPtMCLiHBv/mD+YRo2zAV3AgmjREXsnYYOHG X-Google-Smtp-Source: AGRyM1vQoTHx4g9p2QF2jwTbasjG4At+dY5PWBP9r4Esr44vJuaofMz7Dp/pOq+UBM1aPk1oRLpr5A== X-Received: by 2002:a05:6870:b38f:b0:10c:f54:c7fa with SMTP id w15-20020a056870b38f00b0010c0f54c7famr162620oap.153.1657573913773; Mon, 11 Jul 2022 14:11:53 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:53 -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 v2 2/8] mediatek: vcodec: Use vb2_find_buffer Date: Mon, 11 Jul 2022 18:11:35 -0300 Message-Id: <20220711211141.349902-3-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa --- .../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 Mon Jul 11 21:11:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914290 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 CD054C43334 for ; Mon, 11 Jul 2022 21:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbiGKVME (ORCPT ); Mon, 11 Jul 2022 17:12:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231423AbiGKVL7 (ORCPT ); Mon, 11 Jul 2022 17:11:59 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2636D7D791 for ; Mon, 11 Jul 2022 14:11:57 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-10c0430e27dso8195891fac.4 for ; Mon, 11 Jul 2022 14:11:57 -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=tAr/6Y2JT0X2q9f8RcMvQYEj4YgACkIpvESpYtDF704=; b=oo9nuFNkl/BWxzgOPw9R+S9JOZ16DZ/KWAf1Hord1PvcSj9WhiXhVhWtrQOxGS75D2 Mj7max0alIsH4nYmBjSPC8zD74BgxSL1yVqL5ei9alY2YbJB+e2z29bOBKB+deGEc6pB +0DkwAyML6Dn9uzmaNI/X3vwdkkqJamuOLrF0Mft5PN5oFp5z6QA1t+EPnU+lEbB4dfB HvtlMnd0h16JNSdv2XrfhHvG+QMXeLpoxzblinEkbdib+hR30TBttsLRip5K37YtrHBm cdaqaxbFIYn9CmnNcGihP5WpTutM/GZl+RpVEF7GC9h949P6oNrrAuHLhRehPAZPqT7x Wipg== 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=tAr/6Y2JT0X2q9f8RcMvQYEj4YgACkIpvESpYtDF704=; b=X1CGKiREPSGJd12BHUw/qIgoPBc+L9R5PbbK58pWHs8zf8GJO6g8L0Q8rlvV5Ko3tO v8dE5n7qZ67WwlzfD7ov43/rZeoJPJNHJETLo1U33eVJRRxWbkskgiS4HGeK7qgh/+6B ZyU+fs3RvLUYlGUerp8gBUW40Bmx3ok5edkcHK00OKLqNsq0nw82G99eE+SZP/GJ5ymX Q5TJvi4yQ+F3yPgcEFKYkv/8+TVfdc4Q3q8ZAPRr+uB4QUbbliZ+Q99F0U0R0pD7j+nI U/G+0nbDtNgayB6b2ZslFpxUldx+5viVDRMXCXGoaTN38wQjny8fNPYivIeaaJFuEUpL tvzg== X-Gm-Message-State: AJIora9VK8et17zMjuPkZqP+CkVZzWDlxpBNIluNMzZRXRSK+seKEUw0 6j4fLMEh1ko4DTVfjAo/xY5Gp8T6Zr+tM1DZ X-Google-Smtp-Source: AGRyM1tg9hSwfZP1V+ywQGku8lFPrIMMij6ay1NeYFRjGah8M74Hnvs/PFKI2zbqt59QbCXF29x1vQ== X-Received: by 2002:a05:6870:17a7:b0:10b:af88:599e with SMTP id r39-20020a05687017a700b0010baf88599emr181289oae.18.1657573916107; Mon, 11 Jul 2022 14:11:56 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:55 -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 v2 3/8] tegra-vde: Use vb2_find_buffer Date: Mon, 11 Jul 2022 18:11:36 -0300 Message-Id: <20220711211141.349902-4-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa Acked-by: Dmitry Osipenko --- 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 Mon Jul 11 21:11:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914291 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 278DFCCA47B for ; Mon, 11 Jul 2022 21:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbiGKVMG (ORCPT ); Mon, 11 Jul 2022 17:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231312AbiGKVMC (ORCPT ); Mon, 11 Jul 2022 17:12:02 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 845458053E for ; Mon, 11 Jul 2022 14:11:59 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id v187so288191oie.7 for ; Mon, 11 Jul 2022 14:11:59 -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=BdZMxq9teW/ciKdL4QEeNQpROyhqmipkWHr+gWlgS6A=; b=GaV4iujd2/CrRe0qzyvgqkBxvbgvSW1A/XGMohTKkjsGm5MaDXQjhwpFJY68VNHVC8 0W4/3eTNXIiP0yr0yk1zn9jVdK8yjLQ1SEWXQ2j4eNMUqlM9xTvy9R+4JECLBNGRU5jv X+kvJv+PvL5Gu49Eyjod3qMPXorHQva68hJ05rlvOQvQAEey1W9jVVvO+dFqVU1fuk06 yJp510pHfwCfJ2Z6CSfi12SzSA5TpPfU8+SjDDy+SBfLcStvz9q04+octlfF96RvtcT9 h7n5EJ7OATi4PB264m+X387KJ5y2Gc9Hpe86VLexz0VGpbxhIvOM03d/0hFlEVbhK/lj V4Nw== 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=BdZMxq9teW/ciKdL4QEeNQpROyhqmipkWHr+gWlgS6A=; b=D7lPaNSlxuQvwneOrfLB+ztCu/Zm4aTDhrShRXJcSNCMowAjMJjHLmIrhR8pVQxT9t sV1PbyMBlSCqtkLFlbP4D0MvqpwaB8DPK56Ut1eRFFiQ4l/lBfAQFTEgZAtIZXMIxMLy Qtu8fl+EMB7G9SIHjdYnWjfsNbNqgOOt0rB7LS7Ne46491pbWO1SlLZeNm3SepnJp3WL NverQQXQnxdb+41rLii33a7PpmQ2ia+FcMaCxOWUhgpaUPicy4YpKjmE4Npe/5ko1uTb 6i2fS9ifvNVPt/2s+6na3GuMYzA9Zm69sr1I/iNkD4YOxiV2OViTcX0o6NNxK2meeqYX zgZA== X-Gm-Message-State: AJIora9NCMePln+SecjHjlA8kSyJe8+PzBa5zsFCzlC1gzsc1+DFEN1T yGkVLln9KEhfCaZSoNQWHp84fwMi1AwtNyMw X-Google-Smtp-Source: AGRyM1t86dPpMrWW4AD4sTKOgSAlld2F0HoRsm7zOKOCxo+kAwCnWnRsJILey4wO6ZWbweTtdx1Heg== X-Received: by 2002:a05:6808:1a2a:b0:33a:381:c5 with SMTP id bk42-20020a0568081a2a00b0033a038100c5mr196317oib.9.1657573918269; Mon, 11 Jul 2022 14:11:58 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:11:57 -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 v2 4/8] vicodec: Use vb2_find_buffer Date: Mon, 11 Jul 2022 18:11:37 -0300 Message-Id: <20220711211141.349902-5-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa --- 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 Mon Jul 11 21:11:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914292 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 4ED1CC433EF for ; Mon, 11 Jul 2022 21:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231751AbiGKVMH (ORCPT ); Mon, 11 Jul 2022 17:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231719AbiGKVME (ORCPT ); Mon, 11 Jul 2022 17:12:04 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA199804AE for ; Mon, 11 Jul 2022 14:12:01 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-10c8e8d973eso6367352fac.5 for ; Mon, 11 Jul 2022 14:12:01 -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=/WA3B+oJQPaCUSKWO1kYwgTDh8dNmGQop6oukbbkhI0=; b=O9SPIG+W18OzzmbRWEyaybl/cIecyTTauRNUeFplMk14mb3PSuUp03CXwwPf5FVtJJ z11ohFqFGW/H43Aupcs8Nusef79N8MXTfY1mGRAH7xXQ73KwjsJ1X2ECa+tIYs17AG+5 woDNhzbOQyk3Ik4Lm2z8FmZLbRpsSn1z28yZnxOAUl1PIgXbaMU0Q4GJuS0rtzLZ3CXr Sl/bfVsZtHC30FmYi8Ylx7s5XI49NK0Is86xgXK7ukLUNlducHHzfMtB/uymnV+EBHi2 9768ExZqzX33S1RaJOcz0BdDH6W5Y4ISPuFDJympzBXflJH2YTj4DC3zHswr4SOYlVVI nzAQ== 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=/WA3B+oJQPaCUSKWO1kYwgTDh8dNmGQop6oukbbkhI0=; b=1b3A9TzPgrQZI6gnLal5/lGPMb4lBlaMwZAeYib1JoORgWrLjbApABcLeNb9426ZaD 5XWDyQ3ExgSi9/Yq/A0GsNdw7svbLswXLAIJ2Fv+G8SxIldg27pETVWxbDpvmQVgPJgO pO2fGP0/9OR0lAhqCyvNfJLWZf7cE7ENIXhAHjYRP0FvGqdhAI7EzVDOhQ775asGkxyD cZuH62bMUMdUwQTd3Eq29Re1syyKQSKWc0V3X+LB83rbFtjvtH00jaIaiFQ39mT58KMJ aOv+rAhOq/5jtFkDQx8jPR/lbS01ZMwRhxDNxH8ry7f4Wvv3ehpCOGe5mIbjycCAcxji 3lEA== X-Gm-Message-State: AJIora8oC+4w6iBuUj+zXw4VlS48jmHzuQZjfltSIQa3+v5C2ysr11wR OvdqOQbgaTWocnTXkZ9n/qW2HzYhHvR2RrGs X-Google-Smtp-Source: AGRyM1vw9AWihe3B3I4UpvLIKTNVK29B1XuoFaIYm2CrZADlUfU3O83MwoZmtQ3f+cGuZaBsynL7aA== X-Received: by 2002:a05:6871:1d0:b0:101:59af:c6b7 with SMTP id q16-20020a05687101d000b0010159afc6b7mr154782oad.89.1657573920614; Mon, 11 Jul 2022 14:12:00 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:12:00 -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 v2 5/8] hantro: Use vb2_find_buffer Date: Mon, 11 Jul 2022 18:11:38 -0300 Message-Id: <20220711211141.349902-6-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa Reviewed-by: Philipp Zabel --- 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 Mon Jul 11 21:11:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914293 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 EA93FC43334 for ; Mon, 11 Jul 2022 21:12:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbiGKVMN (ORCPT ); Mon, 11 Jul 2022 17:12:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbiGKVMJ (ORCPT ); Mon, 11 Jul 2022 17:12:09 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB3F274E17 for ; Mon, 11 Jul 2022 14:12:03 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id r136so1322802oie.11 for ; Mon, 11 Jul 2022 14:12:03 -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=J842dPfS98pOzE3Un07UlioU9tGxPmHO38YZQY1HP2s=; b=P3gQ44mE07AhPN5AIifhi/MCViL7rTm94zbC3lBfyQGQs6w3zj0Pr2iIG12cgtRnzQ pzMo0EIonB91at2zx8DuEwwaNnPLLtqlqKqg6r4FTrc8qX301XBQIR9VLdtpsQo/S2Dp 4pW8wlpGg0X2mWFm1RrNflDtpSktK+cUM/JW4vEgU6WaeV3jUFWzcQdUXTtYwpkpW8TI ZLheprW6sDAIALQkMMpgx1dpBM7RnrljPsOW1fOlCIL1P35najBKk915BkYX6WOaz3Uv ROQzXE7cNSjfhVD34312rOOGi4AuMaetm/Ltls/14f9DiaS6pQGkKaJsDv3wgRLZ/lAw YuoQ== 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=J842dPfS98pOzE3Un07UlioU9tGxPmHO38YZQY1HP2s=; b=W4IvpPISxU1QjNKToTBNAj0IH1VZLNRdI6uQbagYx+bJMcf1SlY8RlAQB8NO51Spay QDGOOlgxnKLyWiwSV2623KfKm3JM6SK332Z/rnpMXX0Z6zMjQwpce3yAVFeIimQsA5uH Rj2fE4kQXLi/l8XekFQpBQIlloidKEBhfjrQxxStCAyAcKJA5dSh7OwxNFcjzKELygsa 8VQVXktC2c1ojoxx7qIGnLshPG3gEpMz9ODty6wZOE9h5oarkIJDjMLvexkkw1ROEbJw E4jL00MpDljwQsL2/wFWIhHmK5Wt962St37HiHmNo0ZkFZ9dyZaHVlFBSickYNe+sL/y BiMA== X-Gm-Message-State: AJIora87uJpYfCTG4hhKLLrfQQ+O7Z1DRoWXsOzFcP6zbz1Y08tlzK/z RgfuJ6KpZDnbVPFV96+H+CnZQWF6f4IQq82Q X-Google-Smtp-Source: AGRyM1uh69mg9uNn3E3mHaaHtwi54SyyhFS3QYiIqFsrwm48Yb+fTNiTBfZrPCRr3dKSw9wmB+E2MQ== X-Received: by 2002:a05:6808:138b:b0:339:bbff:8054 with SMTP id c11-20020a056808138b00b00339bbff8054mr190364oiw.266.1657573922811; Mon, 11 Jul 2022 14:12:02 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:12:02 -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 v2 6/8] rkvdec: Use vb2_find_buffer Date: Mon, 11 Jul 2022 18:11:39 -0300 Message-Id: <20220711211141.349902-7-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa --- 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 Mon Jul 11 21:11:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914294 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 C98B5C433EF for ; Mon, 11 Jul 2022 21:12:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbiGKVM3 (ORCPT ); Mon, 11 Jul 2022 17:12:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbiGKVMM (ORCPT ); Mon, 11 Jul 2022 17:12:12 -0400 Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854BA8051C for ; Mon, 11 Jul 2022 14:12:06 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-10be0d7476aso8202298fac.2 for ; Mon, 11 Jul 2022 14:12:06 -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=A792au2VT1LlwA2CxXREJLZ4s++KMx+3sQTvofamLP8=; b=EaYKvznWP2pwtR8wciXBs9CPufXGCXvSPk00hhV/bSB+BpQsssLr4tyOypqDekPht+ hcxtnIRerAyAmOt/+pVy19/Q1fhpq28ALj70+Uu8RmPNkW2JOKti798WsGbVvodHuDRT cikpnXXayJQhsCisu1sRpxngygYXINgzv6GqgmxNWMyBgfREIB+E9qSJ2h/5gTRaYrWv I/+PVS7kRlOAIN8U+oQIpFqiu+UuB3ilzH9vZTLY2Q1FQJO3oSAWQQ7z22pNx7UGy+Xp 88KmpCBwXtwu/ItZm6m7OnydNpGGz19QDzV4qJi0KwP5tQxvX0oE7rASBOrmCmvpp8gE +pQw== 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=A792au2VT1LlwA2CxXREJLZ4s++KMx+3sQTvofamLP8=; b=izahDa7iMa6Z/hYGcsn910j9jj7oiR56TJTDWjT+jZ5abFjhw95ezVBEiLc5lC7156 um421hcRAvqB/19R4cnzrjSZUjCpg74sNyK734EjnxRf81XyzCcwGKDwnEqP7qbFRxha ut5k55nuMoPAqrfyThp9dYJYvo6ncU26G+bKBuq8ILeK3i+a0PkxyQvwjiOStq2kjTK/ /VcWFvb/ufC55MyAcKdjoUunC5s2GYSzDwC6c9ivQh2ESKj7prXeiaseLJrqP4RpbLBb I20a9bTC84WrAAiO6cFVjbAXf/ux6fhLDYFqKs0sXEbbtC6pN5gYKB335Zezq/PKqbsA zJaw== X-Gm-Message-State: AJIora+ChK5/WxwJyrD46OwSfDGuoP5sTGfzh9L+iMhuLy8qp//hIPj6 NdB3j1tbAm9kML4G7Db3V5CgcjCBGrSwSdLM X-Google-Smtp-Source: AGRyM1usv+xY6kM8ee0QJ04Kw/9vVhimVKga1EmRQVMBw+IqDWSK1X3QoLlwFd/305yrMHQpGDQw4A== X-Received: by 2002:a05:6870:e245:b0:de:9321:9ea3 with SMTP id d5-20020a056870e24500b000de93219ea3mr158212oac.79.1657573925467; Mon, 11 Jul 2022 14:12:05 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:12:05 -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 v2 7/8] cedrus: Use vb2_find_buffer Date: Mon, 11 Jul 2022 18:11:40 -0300 Message-Id: <20220711211141.349902-8-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa Reviewed-by: Paul Kocialkowski Signed-off-by: Nicolas Dufresne --- drivers/staging/media/sunxi/cedrus/cedrus.h | 24 ++++++----- .../staging/media/sunxi/cedrus/cedrus_h264.c | 16 +++---- .../staging/media/sunxi/cedrus/cedrus_h265.c | 16 +++---- .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 28 ++++-------- .../staging/media/sunxi/cedrus/cedrus_vp8.c | 43 ++++--------------- 5 files changed, 46 insertions(+), 81 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 3bc094eb497f..c054dbe3d3bc 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -233,19 +233,23 @@ 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; + return buf ? cedrus_buf_addr(buf, &ctx->dst_fmt, plane) : 0; +} - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - if (vq) - buf = vb2_get_buffer(vq, index); +static inline void cedrus_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); - return buf ? cedrus_buf_addr(buf, &ctx->dst_fmt, plane) : 0; + 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 inline struct cedrus_buffer * 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..22d6cae9a710 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -54,13 +54,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 +119,19 @@ 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); + cedrus_write_ref_buf_addr(ctx, vq, pic->forward_ref_ts, + VE_DEC_MPEG_FWD_REF_LUMA_ADDR, + VE_DEC_MPEG_FWD_REF_CHROMA_ADDR); + cedrus_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..196cf692186d 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c @@ -661,7 +661,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 +804,17 @@ 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); - } + cedrus_write_ref_buf_addr(ctx, cap_q, slice->last_frame_ts, + VE_VP8_FWD_LUMA, VE_VP8_FWD_CHROMA); + cedrus_write_ref_buf_addr(ctx, cap_q, slice->golden_frame_ts, + VE_VP8_BWD_LUMA, VE_VP8_BWD_CHROMA); + cedrus_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 Mon Jul 11 21:11:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 12914295 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 AA334C433EF for ; Mon, 11 Jul 2022 21:12:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231954AbiGKVMd (ORCPT ); Mon, 11 Jul 2022 17:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231948AbiGKVMP (ORCPT ); Mon, 11 Jul 2022 17:12:15 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E77528247B for ; Mon, 11 Jul 2022 14:12:08 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-10be0d7476aso8202389fac.2 for ; Mon, 11 Jul 2022 14:12:08 -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=UdBFHF56DJCJ7TVTujTvKpBH89sBJrOSHbI3IjUu/5k=; b=Abr43rShDbmDOl7eDvr+8IqRRqycv2rTEkZVORgxxj/Eynw9PS7PIaSw8WFrvyvLSi zLmKk/B8dmnrUX3o78pS4bHrMaT5Qc7mo4nt3RjY933+33KocRDQ8nv3mLzd9du86DJ2 6CwpqlESkxYh4rEOPPmD7CxtPPb4a8gauROm/6zfR/ggnFW/Spz7cmrLsBGwLcSYAQ96 a4V/IGvrwCE8mN5mwmqEHaCWEAdTNpgmWTfqe/ZZCRbp8/ZH8eqLxh0BmmfQ8I8ba9UM wyNq/U6g2WZU21efd3OQQ61I4CyInHBs4PHUqT8Y9SUGNeFQTWpELp6i6J1PoUXWK0pO fXEw== 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=UdBFHF56DJCJ7TVTujTvKpBH89sBJrOSHbI3IjUu/5k=; b=t3uRDRUpz10m3vv6N0nzh48TQPa7ZoFjXo/0NvZugl1VifPbunMOn7KUEpLdF0zWKt W1QCpXaingv2cU4bWwaBjurLqsbBG0p0ZZzvhvkyu4THFuWkm+n9/dLuElpOUrsLAXWV 2HOCdcUy+iI9jrddKNHlik7IHEbUarGNkugcRgTsM4J/dq6noysophWnsm6dRJNC47mY CFT6jpZ28N3NtvoZUeh/Z0lfoR3noLocZ7SiFiSIrGKCU869mZqpMWntCQr1HnTmhZ7+ 2ib4l7xL0eUxSQxilTaDUWghF1iaBlV+Qlh4+2I0rkR6H+0Cq4P2gg4R5ZpYLhL+zvjN 1FWQ== X-Gm-Message-State: AJIora/4GBZulGS3mN3gIM9kWl3FAo6K2ZnVdJ2YoyzuDJ9DqjBW/bEY 0eIvHsPn6kMdlQzhdGe16DCw3C1IbUx2t6dY X-Google-Smtp-Source: AGRyM1v1o3gDWK5MQ0gtVhHxbLXfSGQeLVeGwJDTrU3G+4bYsZkIF+Fc8L8jKMPdGN1n5vDPaNj+IA== X-Received: by 2002:a05:6870:c149:b0:100:9ea3:7913 with SMTP id g9-20020a056870c14900b001009ea37913mr167513oad.150.1657573927728; Mon, 11 Jul 2022 14:12:07 -0700 (PDT) Received: from zeta-build.. ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id c128-20020aca3586000000b00338869042fdsm3198817oia.32.2022.07.11.14.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:12:07 -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 v2 8/8] videobuf2: Remove vb2_find_timestamp() Date: Mon, 11 Jul 2022 18:11:41 -0300 Message-Id: <20220711211141.349902-9-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20220711211141.349902-1-ezequiel@vanguardiasur.com.ar> References: <20220711211141.349902-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 Acked-by: Tomasz Figa --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 13 ------------- include/media/videobuf2-v4l2.h | 16 ---------------- 2 files changed, 29 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index f26cb8586bd4..4e84a0e1aca2 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -625,19 +625,6 @@ 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) -{ - unsigned int i; - - for (i = start_idx; i < q->num_buffers; i++) - if (q->bufs[i]->copied_timestamp && - q->bufs[i]->timestamp == timestamp) - return i; - return -1; -} -EXPORT_SYMBOL_GPL(vb2_find_timestamp); - struct vb2_buffer *vb2_find_buffer(struct vb2_queue *q, u64 timestamp) { unsigned int i; diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 76e405c0b003..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 *