From patchwork Mon Jun 20 17:55:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12888029 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 774E7C43334 for ; Mon, 20 Jun 2022 17:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A6NW5h+U4QvQ7CRf2k2kXowxGX/1uOY1v8/exAGypK8=; b=nTbgDIcYGr6kGf 5VBJIBA4XijZ7tzwa6RMpZ/scFITZ/xgtI1uJltyrvVFiDCOM7aX8q2PdLmND3b1NW+4FxMdvn62W CKsgfwkG3TrKiSGO+rOBaa5U4NpGREFVgxTOxtGUndQQseJdL2RbcR6fxx/jvCWdUKwByKo6Oe8uf hk6kQGQ+zI/7cyIodvJNQKkf/ambEDPRlLdcHvyYmIjRnk+4lnMY8UTd8smvOAu0dZrpvRluL3I5r Bx2jDcN/Uf+Xb37wQKnFY84q2M5q7H26Uz9IsEbz/7NP9pi4eAbKEfrcdYfH+aALRE4mOksTqmK/k E+fZk/quO57DcaQwa+BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Lfc-001iZb-11; Mon, 20 Jun 2022 17:58:40 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Lcj-001hSm-CS for linux-arm-kernel@lists.infradead.org; Mon, 20 Jun 2022 17:55:43 +0000 Received: by mail-wm1-x32b.google.com with SMTP id a10so6225110wmj.5 for ; Mon, 20 Jun 2022 10:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rO76farMqYrPQC4ew78x4uRO3kIuRntTwzkVO3g3BmE=; b=IXKYt1GNB0skST+g+G4WX5y6frV6Y4HqH2GhmT+UmjHsf9n/eI/8mQ/1U9DblJ6nA+ EuQQBR7A64ljTuDVW0sTn1xiDxxQCPWO8F5rfuzYDMXiCFM+o5ZCoJHN9uhhUWbNC/ma Cy12wOo2F6wvVmCZc8uA73rbiBazH+msWsg66pnnXJhV3hyoRqDw8eVrI/KkeWDFyNoj JUHYPoUJjygpC98Hd13+KqHXDnQEkd5ywSFlDtsbDwPzT5Tciop659ZSJ3q2yNV3IP+7 KaaYG2DOOU60fAyt7bmRps3R+IZzONdJS5MaxDw4ryX58jj8QbNzXmXO+wmzKVLghsqc dyBw== 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=rO76farMqYrPQC4ew78x4uRO3kIuRntTwzkVO3g3BmE=; b=o7Os+CmEIbpE6QM+y1T6ec+34lPxuHvLKzsyRecwHVu/434gvNk+Kh5SNGdAXj81E1 J5QDJbHOhy1HS/jKGFBIss/jffBCJnGdUClmAGGTA8+/kfzyBaL5B9m4TnmDoAAnOAfJ 2nYpqryDKbhWAuAYRgJAXpZ4tI7AOe5bWeev4zFYbsQXngvRc46MtPE+2xalqZWB9wSt KHzXKOgBj6NoiJ8kqJuZCsibkIZClaSWEpjlkjtZEMH3giAYnMVMNUwOPASneDPEEFGV BcJLiLVfewOX4C2hXqYjh/kTYzlB/xBclc+INfKBRjaAtPCwy16m7bAv8Q8sPtBsQoNj vB1A== X-Gm-Message-State: AJIora9iuu/49EQShuXQZQEcdKWBgt7h1xPk/u2Ig53Nfz+28F4ggt/g 3XXjED9fX0QhOHydZ4GiXuA= X-Google-Smtp-Source: AGRyM1u30Dw+JFAP13t7yhgHTvIDNuEJxA8aQ+DfNlPldZrFipM6Pgrn21E14dvHe/90gjXmt5wvtA== X-Received: by 2002:a1c:4e15:0:b0:3a0:1990:afeb with SMTP id g21-20020a1c4e15000000b003a01990afebmr4215164wmh.137.1655747736907; Mon, 20 Jun 2022 10:55:36 -0700 (PDT) Received: from kista.localdomain (213-161-3-76.dynamic.telemach.net. [213.161.3.76]) by smtp.gmail.com with ESMTPSA id 184-20020a1c02c1000000b0039db31f6372sm19620752wmc.2.2022.06.20.10.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 10:55:36 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, samuel@sholland.org Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 6/7] media: cedrus: Add helper for determining number of elements Date: Mon, 20 Jun 2022 19:55:16 +0200 Message-Id: <20220620175517.648767-7-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620175517.648767-1-jernej.skrabec@gmail.com> References: <20220620175517.648767-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220620_105541_472407_4FFF0AC8 X-CRM114-Status: GOOD ( 13.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that controls can be dynamic arrays, we need to know how many elements are in such array. Add a helper for that. Signed-off-by: Jernej Skrabec Reviewed-by: Ezequiel Garcia --- drivers/staging/media/sunxi/cedrus/cedrus.c | 11 +++++++++++ drivers/staging/media/sunxi/cedrus/cedrus.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 99c87319d2b4..b855e608885c 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -232,6 +232,17 @@ void *cedrus_find_control_data(struct cedrus_ctx *ctx, u32 id) return NULL; } +u32 cedrus_get_num_of_controls(struct cedrus_ctx *ctx, u32 id) +{ + unsigned int i; + + for (i = 0; ctx->ctrls[i]; i++) + if (ctx->ctrls[i]->id == id) + return ctx->ctrls[i]->elems; + + return 0; +} + static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx) { struct v4l2_ctrl_handler *hdl = &ctx->hdl; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index d2b697a9ded2..15a1bdbf6a1f 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -261,5 +261,6 @@ vb2_to_cedrus_buffer(const struct vb2_buffer *p) } void *cedrus_find_control_data(struct cedrus_ctx *ctx, u32 id); +u32 cedrus_get_num_of_controls(struct cedrus_ctx *ctx, u32 id); #endif