From patchwork Wed Nov 2 18:08:09 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: 13028766 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 42CF0C4332F for ; Wed, 2 Nov 2022 18:20:36 +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=cqIVGi7VIhbh+FCXfs3pu2d5SLivWFYTi0LONUAj9YM=; b=p2kOBYypUNsbz4 0dTOz8ecfO5bLQ3SUpwdF8yT85e4SHzu5kXP0j577FjmxK2awGMniDNPclRpXDwRY4fMd6g/hmzf/ BWZW7PqBbo0s3Pfu0wKppu+wWqmNQNUkvh7BCzOKEm3BQdc23+sGbhD998SKpiCjWSfZDXg9H9VvL GSV+7mqi7tGlMTsfh66BfaYvwleatngMatm+1PeQXB8Qz96SzXK4fg9UN7rACeq+MQ7JxtdayR912 zyQ/SCAtqd2M4lEnJ35S4T6mbJ8AJV0YCYptlWchqZ5nolsD2fJlgYSHnljEvHBal7HErHLZPnen1 sDce6BUlbR9K1lo/arpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIKX-00CvTA-1S; Wed, 02 Nov 2022 18:19:14 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqIAA-00Conl-QW for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2022 18:08:32 +0000 Received: by mail-ed1-x52a.google.com with SMTP id a67so27705011edf.12 for ; Wed, 02 Nov 2022 11:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zTX/CJSb7MB7yBzrjB/XPnpPEfJPqcJy2sRni4DNHhc=; b=BWwH0PLp6JQ9eYWdTML13I1KDHGFTpJL2HjwEIHw81SznXWlFHTHSGWOlc7rSeX503 9wqgaJhi0gATwz9JUOCOVIlEvlOcAAxSSw4jpkKHc1XQj8MYdzptxvQQa10K74lJnjKO jYsqyFNonzO42fSV0aDTHyZcLt48Xwneh3+krvC2SQV75tXrTQ6zEY8ieSrftyVNXarC FxZCPMocPoPCtGFhYjDdZjDakeFDyxbJUOA5ueFmLMmXM7e5+tsZ8JllrRhSr7gjS0Tj QXKdq4b+3GH/aCvfMgDMokftvmjIQP3LAxTJP355QlPNg/lpS8lip99Qg0Ha4m7/3OA1 daRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zTX/CJSb7MB7yBzrjB/XPnpPEfJPqcJy2sRni4DNHhc=; b=uqr4o2qSd9HvR+2vsu6PLvlklpXFUu79+fuYCSPXL8ilQqxyg1+juwATX4ngDrP0+m wEwM1KEWVjLIWNF322fjkqx7hjSHGp6D5+QlxvqiPnfN1fyFWIN9DlDmuAJrRgs+6lWW jZxc7DtsoyGdvQBkgkRFX51H3uERuJkVJmaHpx6CCuL9GjvURktxvmRvOFEg/1T6GRwj 9QvhV+sTl8rRZELrzY1lObGYmY7PHmupjgQMacSrqbk3CM0lqRkl16wU+W/Q+91LjDpK jVHU93dAbEovwT8rsqMs/ZmNK0JzWUh+rmNwKq56NbejQ200HiVRKY/RhCeZpO/52EoC sfiw== X-Gm-Message-State: ACrzQf3fDJyV5IUg3GGQjDKNi/8UeyrUEz10M/e45uYLFqOlUjfxgKKz CUP7GfaXXDUGszxTvyuw2N4= X-Google-Smtp-Source: AMsMyM7IKKboWbODn0dEZMDDWaIh2XhF9lJrzZnIHY8gQG+UF2lAOeAb//oR918UqPONo5aKDRZFjg== X-Received: by 2002:a05:6402:528a:b0:454:8613:6560 with SMTP id en10-20020a056402528a00b0045486136560mr26656883edb.252.1667412508810; Wed, 02 Nov 2022 11:08:28 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id gy8-20020a170906f24800b007317f017e64sm5677460ejb.134.2022.11.02.11.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 11:08:28 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, samuel@sholland.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 v2 10/11] media: cedrus: Adjust buffer size based on control values Date: Wed, 2 Nov 2022 19:08:09 +0100 Message-Id: <20221102180810.267252-11-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102180810.267252-1-jernej.skrabec@gmail.com> References: <20221102180810.267252-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-20221102_110830_904221_9615C3FF X-CRM114-Status: GOOD ( 14.82 ) 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 In some cases decoding engine needs extra space in capture buffers. This is the case for decoding 10-bit HEVC frames into 8-bit capture format. This commit only adds infrastructure for such cases. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 14 ++++++++++++++ drivers/staging/media/sunxi/cedrus/cedrus.h | 2 ++ drivers/staging/media/sunxi/cedrus/cedrus_video.c | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 6a2c08928613..c36999e47591 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -68,8 +68,22 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) return 0; } +static int cedrus_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct cedrus_ctx *ctx = container_of(ctrl->handler, + struct cedrus_ctx, hdl); + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, + V4L2_BUF_TYPE_VIDEO_CAPTURE); + + if (!vb2_is_busy(vq) && !vb2_is_streaming(vq)) + cedrus_reset_cap_format(ctx); + + return 0; +} + static const struct v4l2_ctrl_ops cedrus_ctrl_ops = { .try_ctrl = cedrus_try_ctrl, + .s_ctrl = cedrus_s_ctrl, }; static const struct cedrus_control cedrus_controls[] = { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 5904294f3108..774fe8048ce3 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -162,6 +162,8 @@ struct cedrus_dec_ops { int (*start)(struct cedrus_ctx *ctx); void (*stop)(struct cedrus_ctx *ctx); void (*trigger)(struct cedrus_ctx *ctx); + unsigned int (*extra_cap_size)(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt); }; struct cedrus_variant { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index dec5d3ae4871..dc67940f1ade 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -250,6 +250,10 @@ static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx, pix_fmt->height = ctx->src_fmt.height; cedrus_prepare_format(pix_fmt); + if (ctx->current_codec->extra_cap_size) + pix_fmt->sizeimage += + ctx->current_codec->extra_cap_size(ctx, pix_fmt); + return 0; }