From patchwork Mon Oct 24 20:15:05 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: 10348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682830wru; Mon, 24 Oct 2022 15:32:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4n7PHCrnWLaYOx3FgAaLziX0mtFWM+LneQ5hkxD5XudzGd42XNak5+a2vES06hKO6LcRTD X-Received: by 2002:a17:906:fe45:b0:788:15a5:7495 with SMTP id wz5-20020a170906fe4500b0078815a57495mr30023021ejb.633.1666650778291; Mon, 24 Oct 2022 15:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650778; cv=none; d=google.com; s=arc-20160816; b=yfoHzi/vQiM8nogsqO6KqjAuXpUBnYlUpVRrGTV7EMSOg/23SK0WcZ1717yhN6gGUO 77PBB+h7We8uxySxYy5uL5/WsEooDU2BFzh2YtRjwbmqQAM08It79mSDLxULGrhp7lnL WtmPEfT6gUYj4rjbIMw427mgVUxViQJyLa1m6X6giJP7uzmH5Xn5Sk9kHIxDBEwUXLZN hE/4tlqydtrMWmOGi6jhsqHpiKALcn55R2Gx0QRqS4UE+eFljpcqEKAJcUgXsE9H4aQY Vb9iWtynAqyL56d2mGf+y4wY5/xoXJ+O7Ubg6E6J9xwcm6LarfOdX2Vbh+SkF4II1cIj C7LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cnqNra0lgbLAKch8eagvznAxGId4NWgXejGlEDMRG8I=; b=O6L+DR1iYKQ/oHJQAg8QSbYuspkEY78P4FNbrfabxF0XmmB3UxxxgvlB20E2H/GLxY zw1fl14PiLSUHGu9TgOpMeUgvFeLZpfr2gjmyWNf044PbY25rEKP6lI4Lo4GqU6/P5jJ J5/lSEjuqPtFqCOYcu/A7GqrCXrf6ti1sTIQBGNUfs++AGyKYfWf9F1LLGZtQ6NF3Iq9 ACxac2FBlUNRtF2uegzgt6AW0ZGfMnFwx6PORAtWN68ZpgStFZPjcKF4vfpeI9D3SXCv GGeD68I9HqWYcJQM/5bLDRp7Vf+Q5OaOidHh/hsI5MZkv0HIHajzbW1utlwrYzVOyS+w pqrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lwrCsYSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a056402430500b0044ecd80f257si1122622edc.603.2022.10.24.15.32.34; Mon, 24 Oct 2022 15:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lwrCsYSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229974AbiJXWT3 (ORCPT + 99 others); Mon, 24 Oct 2022 18:19:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbiJXWS4 (ORCPT ); Mon, 24 Oct 2022 18:18:56 -0400 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E88FD8F63; Mon, 24 Oct 2022 13:36:09 -0700 (PDT) Received: by mail-ej1-f51.google.com with SMTP id d26so7645571eje.10; Mon, 24 Oct 2022 13:36:09 -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=cnqNra0lgbLAKch8eagvznAxGId4NWgXejGlEDMRG8I=; b=lwrCsYSnWfTQh15cwQ7ueF8f2lHMOTa+mOmouTY1ExaPRtPNGsHigtjtgstssCXaYm ancy3xk6f/FVT7y7wCLjlA6BsuUUXeHs4ZHkH4SuIUD7KjjDO3846Vc1R0rPTSumc61v LalmebgrfMGEjsqMPtBCY00khGcDmd7uTUYZNzbsyXfw6011zIQHliWjCMom/eIGcTUU ldtE2WbEj0OpKk06UYAkVBBhrUbOw1UONE7L3m1ucx1O9OA076r1vNBjPrjoUCV+wnK3 h//Ppkdlb5BCIptz5p+PM7yzrUGr+GOnMtaSUNN3xM3L67L+KB7CKZvV0Su+62ggUxKo 0ZuQ== 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=cnqNra0lgbLAKch8eagvznAxGId4NWgXejGlEDMRG8I=; b=irVARwCh1dfxT78scbt8RywEu40i/ITAPz7bZ5XwNQ31UiXyW+ebXjAzNgwAgPh5M1 np50p2DsV0NOxz4BUwSXD2nPSOKKnx4YCBDacUD+kruifvVdIz3LCqgY0z6ZM3tU66xl 4tvvvDkhobvZZtjQOoBCKv7auL5MoZu3asWLQaS4d66FyEZ7MpDaj0/7UsBRqLBEdRi+ 0k8KijjSqRuw6dfcOUyFapmqX9zdVzkTkh4ziwOZkebXFwdzjbmEFd2O0jxBl71LAy/6 hjjJgwTRFKicZ1fJdmXz3JW9Jl1DaUNlFO2f054l1dd6khVQTAmaS8FaCf1Mu69zszv1 CKVQ== X-Gm-Message-State: ACrzQf1Jmf6XRlOyNiLqhK95OlSNVBWGDoblf2k6c1kUPtg9FDNqdOQh +U671U/CwoxqGZSnKIiYrfymghVVBHqeuw== X-Received: by 2002:a17:907:c03:b0:781:fd5a:c093 with SMTP id ga3-20020a1709070c0300b00781fd5ac093mr29229259ejc.89.1666642530469; Mon, 24 Oct 2022 13:15:30 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:30 -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 01/11] media: cedrus: remove superfluous call Date: Mon, 24 Oct 2022 22:15:05 +0200 Message-Id: <20221024201515.34129-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610006641698453?= X-GMAIL-MSGID: =?utf-8?q?1747610006641698453?= cedrus_try_fmt_vid_out() is called two times inside cedrus_s_fmt_vid_out(), but nothing changes between calls which would influence output format. Remove first call, which was added later. Signed-off-by: Jernej Skrabec Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 33726175d980..1c3c1d080d31 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -309,10 +309,6 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv, struct vb2_queue *peer_vq; int ret; - ret = cedrus_try_fmt_vid_out(file, priv, f); - if (ret) - return ret; - vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); /* * In order to support dynamic resolution change, From patchwork Mon Oct 24 20:15:06 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: 10339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp672627wru; Mon, 24 Oct 2022 15:05:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6qx8pVGNCqAXnZhwFY5v2ichCXOCc1+l4GaiO7Ir4jIgIR/mqf2AtikbOWdUSfMf4Ey9mE X-Received: by 2002:a63:28c:0:b0:46e:9da9:80f8 with SMTP id 134-20020a63028c000000b0046e9da980f8mr20878991pgc.373.1666649099803; Mon, 24 Oct 2022 15:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666649099; cv=none; d=google.com; s=arc-20160816; b=kGTTveKtVcEi3bbnPHSkpMHN5Ns63NHZtF1d1lx5SC4OUY+Y6Ya65Ss46yvRJPiIkd HI/f49wwK+5Bu0V+/drqxDZGS4dw4Zq3JoplaDLf0l/qZsU8Q8PvGDTnujQ9aGAcs4nE ExCnNrpw++jST/HdLAJN3O0C5H7WwL14iZo76tzJJoxocZaestkFCWLxh7Uzl8p0pmGV QYhf4BGB64i8Vgi2cM8vzdGaAPtYIDdyM4xi+q/3xURS0VzYYNOloK0+fTZyGXw99QIu qZA9bUeKWCw7UToJVTmSS/QNoBHRXzuDpHMcvgdW5UQdw44zgskjNquMs8EY3PbxXI6R brdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4uzd84Lo8isAFXRphDOp8YM5rfTGeiE2OqupA7quo4Y=; b=rRt5rGTaz2oKGsZ9TTGxBvW7UgSAcqFXwSDg9HXTYo5jm9XqkVVDOjCfL74flh2vVD 5Qe9yFYxJjUDZklMXHYq1Br9iM0PX9hTkYwXUph9dvS83SfYnjLIAUFUh97n77EHeDOo LSNmWP4NKQLMxwRuTaJ8wk+xGZ6snyTKcuMKJJ1vSkIwVK4BdnsHcQ9iq/PypbU+h8tB 3HOgUEv6yVZ84gSeRZB9bX+FN7rebCYbo77C6eC78TZDbOK7fuGXyibkuZKus9xYk+sp nnOrjIMqyvA72G/8r+qqnqX50+l2YoRQeatbFsd+YSVmLwP5kID5ISgQ5kf3Bdep0wo/ FfYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cqKQd2gK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 9-20020a630309000000b0043c1cb75c22si743278pgd.333.2022.10.24.15.04.45; Mon, 24 Oct 2022 15:04:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cqKQd2gK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbiJXWEV (ORCPT + 99 others); Mon, 24 Oct 2022 18:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231588AbiJXWDj (ORCPT ); Mon, 24 Oct 2022 18:03:39 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9082C16; Mon, 24 Oct 2022 13:17:47 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id bj12so7530462ejb.13; Mon, 24 Oct 2022 13:17:47 -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=4uzd84Lo8isAFXRphDOp8YM5rfTGeiE2OqupA7quo4Y=; b=cqKQd2gKzVNMX+5x/YFpR+RBIFY+Djo+X6IMVKyhCRl8jxEW9kQOGfDZBiKyi7ljRg C/MtxDmJB5eZ5EinpJIBOJR2Ku57De+BBMw2S6bygvkqrRBWmJyM9vt3b1sC/f3LPXm9 TR3dGaW7uEsETlRJeqcAiqJrJgAMOTRm/FCAKLEyTXIt4oGAFgmBAlg7bcIYEDI44DJh hFyqnA2iWsa9rA3oJZtyGyum7LI4qFX8EOP+B5pjkgwxhnCtXb40WvpX4QSJMUU63ReV jGoVJzuekyzC2Zh8lvM2DKNIGS46F5G7smK/jWJNfEjha2sV8rojZkz3JNfg2GiPqnIB 8DEA== 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=4uzd84Lo8isAFXRphDOp8YM5rfTGeiE2OqupA7quo4Y=; b=hoRN24rfQwMTWHhr745hj1hCksBTq62lKdGFeb6U6T5mBs1N/k2kYSanl/mB8cL8On Fox7L2yQhEvHIHBYAu+glkjubAx3ju2tY72cTcMzJaJZHV+WRiPdKT/IHIFUmmfymq1S BoVtLipyVz05+46rzPU+kqQCb56NLj7qBKoitCc3aYg3llELP4Zb3r5TucTmHW4YTlCQ lemaw5UsiFcD/loj5a/sRzQUla6FNGoxOvVGO7M3eFHtKhN4MF3wjhWWTsKYIkN4ESjw uwtyZrKBqsyJIEsvRiO62HvoPYb4e85DKupCtE1hqmcOJTzAT8UxwTh9CrtKHVVkI/1w lDAA== X-Gm-Message-State: ACrzQf3soUkxJ+/XO6EHlWL/iVpHUggJUeHgB+JmsqWCmPQzu52fxgBA m6518+R/gt9aSqv8j8scUiE= X-Received: by 2002:a17:906:ef8c:b0:78d:46b7:6847 with SMTP id ze12-20020a170906ef8c00b0078d46b76847mr28751369ejb.241.1666642531636; Mon, 24 Oct 2022 13:15:31 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:31 -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 02/11] media: cedrus: Add format reset helpers Date: Mon, 24 Oct 2022 22:15:06 +0200 Message-Id: <20221024201515.34129-3-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747608246673386244?= X-GMAIL-MSGID: =?utf-8?q?1747608246673386244?= By re-arranging try format handlers and set out format handler, we can easily implement reset out/cap format helpers. There is only one subtle, but important functional change. Capture pixel format will be reset each time output format is set. This is actually expected behaviour per stateless decoder API. Signed-off-by: Jernej Skrabec --- .../staging/media/sunxi/cedrus/cedrus_video.c | 100 +++++++++++------- .../staging/media/sunxi/cedrus/cedrus_video.h | 2 + 2 files changed, 66 insertions(+), 36 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 1c3c1d080d31..27a7120fa6fb 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -241,12 +241,10 @@ static int cedrus_g_fmt_vid_out(struct file *file, void *priv, return 0; } -static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) +static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) { - struct cedrus_ctx *ctx = cedrus_file2ctx(file); struct cedrus_dev *dev = ctx->dev; - struct v4l2_pix_format *pix_fmt = &f->fmt.pix; struct cedrus_format *fmt = cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_DST, dev->capabilities); @@ -262,12 +260,16 @@ static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int cedrus_try_fmt_vid_out(struct file *file, void *priv, +static int cedrus_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - struct cedrus_ctx *ctx = cedrus_file2ctx(file); + return cedrus_try_fmt_vid_cap_p(cedrus_file2ctx(file), &f->fmt.pix); +} + +static int cedrus_try_fmt_vid_out_p(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) +{ struct cedrus_dev *dev = ctx->dev; - struct v4l2_pix_format *pix_fmt = &f->fmt.pix; struct cedrus_format *fmt = cedrus_find_format(pix_fmt->pixelformat, CEDRUS_DECODE_SRC, dev->capabilities); @@ -281,6 +283,12 @@ static int cedrus_try_fmt_vid_out(struct file *file, void *priv, return 0; } +static int cedrus_try_fmt_vid_out(struct file *file, void *priv, + struct v4l2_format *f) +{ + return cedrus_try_fmt_vid_out_p(cedrus_file2ctx(file), &f->fmt.pix); +} + static int cedrus_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { @@ -301,13 +309,60 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv, return 0; } +void cedrus_reset_cap_format(struct cedrus_ctx *ctx) +{ + ctx->dst_fmt.pixelformat = 0; + cedrus_try_fmt_vid_cap_p(ctx, &ctx->dst_fmt); +} + +static int cedrus_s_fmt_vid_out_p(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) +{ + struct vb2_queue *vq; + int ret; + + ret = cedrus_try_fmt_vid_out_p(ctx, pix_fmt); + if (ret) + return ret; + + ctx->src_fmt = *pix_fmt; + + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); + + switch (ctx->src_fmt.pixelformat) { + case V4L2_PIX_FMT_H264_SLICE: + case V4L2_PIX_FMT_HEVC_SLICE: + vq->subsystem_flags |= + VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; + break; + default: + vq->subsystem_flags &= + ~VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; + break; + } + + /* Propagate format information to capture. */ + ctx->dst_fmt.colorspace = pix_fmt->colorspace; + ctx->dst_fmt.xfer_func = pix_fmt->xfer_func; + ctx->dst_fmt.ycbcr_enc = pix_fmt->ycbcr_enc; + ctx->dst_fmt.quantization = pix_fmt->quantization; + cedrus_reset_cap_format(ctx); + + return 0; +} + +void cedrus_reset_out_format(struct cedrus_ctx *ctx) +{ + ctx->src_fmt.pixelformat = 0; + cedrus_s_fmt_vid_out_p(ctx, &ctx->src_fmt); +} + static int cedrus_s_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { struct cedrus_ctx *ctx = cedrus_file2ctx(file); struct vb2_queue *vq; struct vb2_queue *peer_vq; - int ret; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); /* @@ -328,34 +383,7 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv, if (vb2_is_busy(peer_vq)) return -EBUSY; - ret = cedrus_try_fmt_vid_out(file, priv, f); - if (ret) - return ret; - - ctx->src_fmt = f->fmt.pix; - - switch (ctx->src_fmt.pixelformat) { - case V4L2_PIX_FMT_H264_SLICE: - case V4L2_PIX_FMT_HEVC_SLICE: - vq->subsystem_flags |= - VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; - break; - default: - vq->subsystem_flags &= - ~VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; - break; - } - - /* Propagate format information to capture. */ - ctx->dst_fmt.colorspace = f->fmt.pix.colorspace; - ctx->dst_fmt.xfer_func = f->fmt.pix.xfer_func; - ctx->dst_fmt.ycbcr_enc = f->fmt.pix.ycbcr_enc; - ctx->dst_fmt.quantization = f->fmt.pix.quantization; - ctx->dst_fmt.width = ctx->src_fmt.width; - ctx->dst_fmt.height = ctx->src_fmt.height; - cedrus_prepare_format(&ctx->dst_fmt); - - return 0; + return cedrus_s_fmt_vid_out_p(cedrus_file2ctx(file), &f->fmt.pix); } const struct v4l2_ioctl_ops cedrus_ioctl_ops = { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.h b/drivers/staging/media/sunxi/cedrus/cedrus_video.h index 05050c0a0921..8e1afc16a6a1 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.h @@ -27,5 +27,7 @@ extern const struct v4l2_ioctl_ops cedrus_ioctl_ops; int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq); void cedrus_prepare_format(struct v4l2_pix_format *pix_fmt); +void cedrus_reset_cap_format(struct cedrus_ctx *ctx); +void cedrus_reset_out_format(struct cedrus_ctx *ctx); #endif From patchwork Mon Oct 24 20:15:07 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: 10347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682506wru; Mon, 24 Oct 2022 15:32:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5n8OjrZ/gO87fz0fIe04RgmpcJpEq2HahtEtMqlqLGfrV4A7sNwzY3/AbulSLXWx6bSr35 X-Received: by 2002:a17:906:8a61:b0:78d:9d00:c906 with SMTP id hy1-20020a1709068a6100b0078d9d00c906mr29669134ejc.321.1666650721795; Mon, 24 Oct 2022 15:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650721; cv=none; d=google.com; s=arc-20160816; b=K8A/x5XxO0bPB2jLl/uaDmrH8z0wUSTFnyi81Gsdtrxv3AAcN/zd83qBWIKR0Knkpf LMlR6wRkI6kepB8S1mzqtOQ5/0W6lJGX+2WwdbnvxwiRKs2xdMSptwBiyJCh21d8X0L/ iBFD7SZErw6czlMziF3E2tKFPTYnaV+jFlXSAnkyexYcrICNDADW2NY1DloEGCtX4+Lx qrHwLAmOf5IyLuTyoRLIkUbCmIUEQ3fZwGme9d1P7LmWQdUaL9Dm6jLKWVnO/P53Ny3t o+zxDeyVogzr4o+S5W0/UrkkFkRcK4KzmJg/U7Z0etuNWXeD6JZfJPmWjh3lEtr1oHue fyWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fz8kU4WpE9TC4fsj366svqLLQU9rq3YiiGANcwE6/pc=; b=o8gwGeQEAKi9Dwzhm3Kzdxo8lJYaY8auBZ0YZyo+OR20OHsEISY9KpWSIXYDUz5he0 k6hc+yTGTYXs67dASdWbzPoqbnkwoxogSmQW8j2rSl/VCb1JrwM6+Y1rfL4r2NQNmBp0 Dupjkzhqiqqkvm/RG/QiY2VGoP99lIsr8m6iN1THmrZLCVTzhcClunbOp0lxlLu3JsJY s0OItZw0ptJ+4TOGeDPHs2Bb8AMH0yhq33jCN+OyTVWk0dp6R+8QwSaWk7yvdIvtP/4G 5x8YvwQbKi0E7lrhWo0hMOQuv4xAt8p0hr1TQWbigWTI+x1qwPq629VFYCOBFAcuwKbg QoEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GD1Vrjxn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf29-20020a1709077f1d00b0078dec48d439si987153ejc.590.2022.10.24.15.31.37; Mon, 24 Oct 2022 15:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GD1Vrjxn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbiJXWP1 (ORCPT + 99 others); Mon, 24 Oct 2022 18:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbiJXWPB (ORCPT ); Mon, 24 Oct 2022 18:15:01 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AED36309D67; Mon, 24 Oct 2022 13:31:08 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id bs14so14252832ljb.9; Mon, 24 Oct 2022 13:31:07 -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=Fz8kU4WpE9TC4fsj366svqLLQU9rq3YiiGANcwE6/pc=; b=GD1VrjxnsI5PdS5Ql5clVdZZo3LcKOQlsk6Vyf7xKb8cFzGMJBN37iLlAIx/IxjfWG HHCEZ+i07Ndortqa/MXILhU7jraNG5CK57RmJVEKicdQxow7TqU3tQvrI6Z6wwqoXGeh oulyQoHw56xVdN8hDLx+9DhBr9TIHnsEMwzIeSrvKQqzb0QFYjFL+h+fjCWXs7ja4syg x5XTNBoV7oAM1htM7qDnRQnu1LrFFVEjwCQz6/ol6f0FH+oIc4byVyF3R+BgxjThRz/t AQtrTo4XIJVnvwpOpK1vzYKVRPVi48caLA5B6hZTrJxB+rhI9D3Sn2sq5V4x90idMyOD ptNA== 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=Fz8kU4WpE9TC4fsj366svqLLQU9rq3YiiGANcwE6/pc=; b=HigQVxhAbL15GuPlCjyPuAkVBn3IEgrCX7RzVNZ5OAAenhy468qi/4vehK8fMoSbAl ta56D7D5xKUgiHw+HFbz3qg2YzlTl8tQE6iQPpnXyU2gSNQlFVqcm+vZ9HsxEHCDJ3tD 3xRirdhhepJmHMuzGiHbT0R+yHatxH8Ei4wg0bFfgoqUyZbVEqGVOnpkhTho2MBDZ0WL SdbWi+ndhnNPXIn4ll90jf6kbRArbOXmXd1xHjEEKDdTObDa1xnxsy4IQLuY+OlQmo11 siZinaS8lT2rAobtIFrZ0qiyYksxbrpaSzJ9EKGUpHjjjOLHR/O4arXy7BcuTrN63YDf Wa9A== X-Gm-Message-State: ACrzQf3s3UAWUTQGmRTLM+IN2mQE1doh9Fn5n2al6C8+DGsQSwDX6/3e ybaGZyq1AAYKsqsmof8U8/OT8lDNfmjQBg== X-Received: by 2002:a17:907:b17:b0:78b:b909:e91a with SMTP id h23-20020a1709070b1700b0078bb909e91amr28116924ejl.687.1666642532756; Mon, 24 Oct 2022 13:15:32 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:32 -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 03/11] media: cedrus: use helper to set default formats Date: Mon, 24 Oct 2022 22:15:07 +0200 Message-Id: <20221024201515.34129-4-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747609946794684305?= X-GMAIL-MSGID: =?utf-8?q?1747609946794684305?= Now that set output format helper is available, let's use that for setting default values. Advantage of this is that values will be always valid. Current code produced invalid default values for V3s SoC, which doesn't support MPEG2 decoding. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 55c54dfdc585..2f284a58d787 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -361,16 +361,8 @@ static int cedrus_open(struct file *file) ret = PTR_ERR(ctx->fh.m2m_ctx); goto err_ctrls; } - ctx->dst_fmt.pixelformat = V4L2_PIX_FMT_NV12_32L32; - cedrus_prepare_format(&ctx->dst_fmt); - ctx->src_fmt.pixelformat = V4L2_PIX_FMT_MPEG2_SLICE; - /* - * TILED_NV12 has more strict requirements, so copy the width and - * height to src_fmt to ensure that is matches the dst_fmt resolution. - */ - ctx->src_fmt.width = ctx->dst_fmt.width; - ctx->src_fmt.height = ctx->dst_fmt.height; - cedrus_prepare_format(&ctx->src_fmt); + + cedrus_reset_out_format(ctx); v4l2_fh_add(&ctx->fh); From patchwork Mon Oct 24 20:15:08 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: 10338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp672536wru; Mon, 24 Oct 2022 15:04:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7mQs4XT09xlfn5UzpH4OS5fCQ97iJNCQey/BTynhM+gwd/HqbYQoGN99Z2aFiMnSovqiZJ X-Received: by 2002:a17:902:f60b:b0:178:6a49:d4e3 with SMTP id n11-20020a170902f60b00b001786a49d4e3mr35846107plg.75.1666649084375; Mon, 24 Oct 2022 15:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666649084; cv=none; d=google.com; s=arc-20160816; b=bSUnPGNvUzrRYY4tzmkkHqPQ94lYUflhcub0S8dzi3GlDWZt46cUv8awXF8DF3+hcL HvY7SYPXEMNwE/aN5uliriggkp60bCf7ZWVmk7xxMdt8YgVOX9UPtKltu0Lm+kahaeiS 1YnqrBuY2/1V9LvcUO40eKw3FCzqenecJjeku1ir/kXTcoBSDKYP6GcEcrkOP4ThvIRh 4D9GnfaHh0pcY5u7zVlKbsViGyVOhh21aEKezBCsU4bhp8+I0tGlr9rrslOECKeqO4Bs piUjA20mOveepe3AzEVgaQX3w5ID4EgnpWfKcmQXS+eiCCOLK87C5SrmMCg40kFicHvl 3m6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TCm+nwpQdSOn7t4hRCuqY5Xxb/T0BgOg5M1eXRCRU+o=; b=zP3zjWuJedU9xhb/JUmlDkGZnONh6zNJi+X/QRvDHwpJS/kGy9yf4xcT1vI7wLgLPx N18BPE6WYnJ7qpgPEyZIOim4vxoMK79K06ByrohvGrvmgu40X42XaMaA2qungSWGUoG9 uNgYl8+BVR42Emo1rtOCLyPmGHvU/L3B2AlIBYEYUgOd3eGKooPiyPOsCNGaLBH4xvqW dYfGPS+37VXQ/ygfT9oXaOZ4aFHb8ybPCPS078p0IAYhQGeaqxU2SvBuJfzriD/wNhdv +tH02n+J/NYsmUdmhzoOnwfSxkSxEaJcjZSRDmootv08WfNnolaYEgcSM9xX3iUls4D+ x0MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f6naWv65; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a17090a630400b001fdbf119f36si9202396pjj.105.2022.10.24.15.04.30; Mon, 24 Oct 2022 15:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f6naWv65; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbiJXWEL (ORCPT + 99 others); Mon, 24 Oct 2022 18:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbiJXWDi (ORCPT ); Mon, 24 Oct 2022 18:03:38 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 844DCC896D; Mon, 24 Oct 2022 13:17:34 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id b2so7640920eja.6; Mon, 24 Oct 2022 13:17:34 -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=TCm+nwpQdSOn7t4hRCuqY5Xxb/T0BgOg5M1eXRCRU+o=; b=f6naWv65smWskYD3+RwsOxR3AHdViC2myv5+IfMnG6D1Dt6XYeg7HfeaMkL93poPQL 2ViDSLas/oBsXUAw0uFGZ/Su7lZIBmuTfBE5fmWe7mM/pYunMmPjccClYW7bGFk8Nmop 1bHYNxrYiAszg11ugtyHUZekAkgk2Yxu3Eccvhx4PRu7mxehc7pgh1V/csXNHCYmcoH5 h80cKx+EDq+QL1Td35T1BpWEdg7F1TEFQgvlYpDd4xN04l7baH0gUF86ubDAVR1Sbpmt vsIyRMg/9cLx5yj/9S8pmxCORjdbfkKB72dQBiHapZwNkFu0B3+C0Re7UDImZjX6X2Z8 oLRw== 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=TCm+nwpQdSOn7t4hRCuqY5Xxb/T0BgOg5M1eXRCRU+o=; b=2J2OaeDU82SMN743Gf9Sir+QGJujRivt68uI0hdVpbJSMBhCeJT22oxhznRfKQkcgE C7b2phz3MokVQGa4bbawSDmEXY9kEQjEkr+BNJNmp3R+2wJ5dAuvvruuZ71ntK/0LrQm m3JT7GFEdIvJi2uUaVTMcSrPXrZj26gc3IPKMcPkcN+YQOiboVqRfuDh1Kn+1sZYOXPv SBmpn9z9Mvis3lJDW2y2MjWagXHs96h/4aEI09KwnSeuIupQoinG29kllmOb/VvwdzWX ijOCEgulF0y/Zc1ViQZIl64UnFhKIDYXnKVIbwrW+HAcIEADL1cMVFMjmWsmLyiOFMNC G5fg== X-Gm-Message-State: ACrzQf29QZoee3hZ9S1q6nBQdWDQgoK9IZoafdTx9sEq6ZYajJaLRyjD Fe+zQFL89bPzkVLHpH4Hti4= X-Received: by 2002:a17:906:5dce:b0:78d:ec48:6a58 with SMTP id p14-20020a1709065dce00b0078dec486a58mr29115013ejv.209.1666642533828; Mon, 24 Oct 2022 13:15:33 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:33 -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 04/11] media: cedrus: Add helper for checking capabilities Date: Mon, 24 Oct 2022 22:15:08 +0200 Message-Id: <20221024201515.34129-5-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747608229877043187?= X-GMAIL-MSGID: =?utf-8?q?1747608229877043187?= There is several different Cedrus cores with varying capabilities, so some operations like listing formats depends on checks if feature is supported or not. Currently check for capabilities is only in format enumeration helper, but it will be used also elsewhere later. Let's convert this check to helper and while at it, also simplify it. There is no need to check if capability mask is zero, condition will still work properly. No functional changes intended. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.h | 6 ++++++ drivers/staging/media/sunxi/cedrus/cedrus_video.c | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 9cffaf228422..1a98790a99af 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -268,6 +268,12 @@ vb2_to_cedrus_buffer(const struct vb2_buffer *p) return vb2_v4l2_to_cedrus_buffer(to_vb2_v4l2_buffer(p)); } +static inline bool +cedrus_is_capable(struct cedrus_ctx *ctx, unsigned int capabilities) +{ + return (ctx->dev->capabilities & capabilities) == capabilities; +} + void *cedrus_find_control_data(struct cedrus_ctx *ctx, u32 id); u32 cedrus_get_num_of_controls(struct cedrus_ctx *ctx, u32 id); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 27a7120fa6fb..04b7b87ef0b7 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -177,19 +177,13 @@ static int cedrus_enum_fmt(struct file *file, struct v4l2_fmtdesc *f, u32 direction) { struct cedrus_ctx *ctx = cedrus_file2ctx(file); - struct cedrus_dev *dev = ctx->dev; - unsigned int capabilities = dev->capabilities; - struct cedrus_format *fmt; unsigned int i, index; /* Index among formats that match the requested direction. */ index = 0; for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) { - fmt = &cedrus_formats[i]; - - if (fmt->capabilities && (fmt->capabilities & capabilities) != - fmt->capabilities) + if (!cedrus_is_capable(ctx, cedrus_formats[i].capabilities)) continue; if (!(cedrus_formats[i].directions & direction)) From patchwork Mon Oct 24 20:15: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: 10340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp672656wru; Mon, 24 Oct 2022 15:05:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QSbSO8YijRFNWYQpFd3mC8W2B3jXc7DKrun3kl05ZPGukiLta/KQpZBUkX6bTjMcR7YjD X-Received: by 2002:a63:354e:0:b0:439:837:692f with SMTP id c75-20020a63354e000000b004390837692fmr30347830pga.74.1666649103155; Mon, 24 Oct 2022 15:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666649103; cv=none; d=google.com; s=arc-20160816; b=AUXjNoG4Oi1757hUnebZJsB8R2nNreNrs3df+fsFuo62CUZKdLw3xlUvgha23ULtuR ruNDeLmQHBf0XDoBo9869scH6czpvSvDBiSUaZAHZlx6cDvqD1jwL5JFJitK1F64u+b5 aN/Wy9OIZxyr75Bg9UX17G+1mkL2877fgIHRwIGPvKu6C60BQw/8W1KpKLHK+1A4C6mY KTuTp5lqe1s/7XoaqAI50u2lw+DIwbVGmrOtuPAM/XlmPkU6p1MRRjklT9JfHLch+EcQ Ma4KOSBJrA0NE8ZgPNsNyKuV/HC4JNj497vVWEVCT4lkJCcXhUD1kOLmn9ylRFpqpflE Xajg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7jVp3CG27o9+HdXrqFxf0SW9oZkiMXAzJ2FPuuiQx3Y=; b=OPEwiHv1utW5plr+iY6Fr/BXDeES34wfi21/8oelc1IhiwcjKg8p/1b9SB6aBGbmE9 ZKRs23Lk7V03teybFTgu97d3AT6hyd9kae1QhcXZ15OHk5FWiJDf9AtGVEPoIpxeHWAj Edpo6AADh2lfQafiSKi+MpxEW3DdROtanQzN6X9rFSndbQrllxhCkFrFlvy9Kp8DdOpz ZUyUgtXKmwKdZ8h5GSJNzUUtd0CfrN7larqgmK4XHvowbzLNryCvW4mMYwi22DQEGmAj G9AXKLFoDM/AMbb7t4VSN3S6Zhg0bUd9AGNOZIeVuVxD+4ug03Vd03ydiXuRCe7gOauj 120g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AtN2GbQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn5-20020a17090b38c500b001fad0e954cesi1360187pjb.32.2022.10.24.15.04.50; Mon, 24 Oct 2022 15:05:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AtN2GbQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231709AbiJXWE2 (ORCPT + 99 others); Mon, 24 Oct 2022 18:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbiJXWDx (ORCPT ); Mon, 24 Oct 2022 18:03:53 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F345FFD; Mon, 24 Oct 2022 13:17:51 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id m15so33305250edb.13; Mon, 24 Oct 2022 13:17:51 -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=7jVp3CG27o9+HdXrqFxf0SW9oZkiMXAzJ2FPuuiQx3Y=; b=AtN2GbQYKT6lPoTuMCBqyujg/iuyMiylMdjB+nkJ73us1MGbIG6V5NCEdtNN48a3Je Z3QKpfNwo0N3X3fTZ8ijGu71yjluzrtZteqa+uIRMgxLCZ9n9+HhIPN5mE6sOdgAhuLk BxNBaxlN5ghjjysmLNPNH4+29o5Kfb/t2IyqglOHA0eu0Ybkp7gmAa4qWFtwiXb6+Zf4 jVCCk50+1ermsEL3r1qkRWODvUsIySj0CDoiWmhm38Ov+El7TNFL9URXEShbQ3usuBYT 8ItrcYb8/hOaZq1bJlJfSK7QQqDiGQizSwtncL3umvhsz5WoA/khIMoP3zmzwmbHcLIg bXaw== 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=7jVp3CG27o9+HdXrqFxf0SW9oZkiMXAzJ2FPuuiQx3Y=; b=MFRMLzSNlOrUwBXj6UE5eqrdiL083u/VZ1+2DD2juJf9G3GvLs3HsR96l4hNenVfbq z2EIsM1wNVCFDF4HKxJK2xZF9dCa9eRhC/OtLknuxagp9lp9qAom/8Vi1D6clRaQSs0z p+ohit2JgDyxYn9A8Nngfx0RBUSFSDArHv8X+gik4/wpr3F/W9MIUNrFKJNBPYBYZYgz XDt3iPhQKps804tFeKQ2cfWEF7QrmyhQOcq2qw3aIdwc6pMTlSRCa8pja1Q9YWClNOr+ vPtvwqCaPc+zwHQ3+VaIZ9IDu9HJvaOB6b8X5ZXb0qgE39ukyBlmBQmVghyR7i23u/ae heQw== X-Gm-Message-State: ACrzQf3920so5ztW5mxaX3JXaeGdOXpFCifUeT8PtLN1j6Qyf1W2Y905 OYMe2CxEn5inJreNqTLhbU4= X-Received: by 2002:a05:6402:b99:b0:461:afc3:9a02 with SMTP id cf25-20020a0564020b9900b00461afc39a02mr8405459edb.175.1666642534924; Mon, 24 Oct 2022 13:15:34 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:34 -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 05/11] media: cedrus: Filter controls based on capability Date: Mon, 24 Oct 2022 22:15:09 +0200 Message-Id: <20221024201515.34129-6-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747608249689560684?= X-GMAIL-MSGID: =?utf-8?q?1747608249689560684?= Because not all Cedrus variants supports all codecs, controls should be registered only if codec related to individual control is supported by Cedrus. Replace codec enum, which is not used at all, with capabilities flags and register control only if capabilities are met. Signed-off-by: Jernej Skrabec Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.c | 45 +++++++++++---------- drivers/staging/media/sunxi/cedrus/cedrus.h | 2 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 2f284a58d787..023566b02dc5 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -77,56 +77,56 @@ static const struct cedrus_control cedrus_controls[] = { .cfg = { .id = V4L2_CID_STATELESS_MPEG2_SEQUENCE, }, - .codec = CEDRUS_CODEC_MPEG2, + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_MPEG2_PICTURE, }, - .codec = CEDRUS_CODEC_MPEG2, + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_MPEG2_QUANTISATION, }, - .codec = CEDRUS_CODEC_MPEG2, + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_DECODE_PARAMS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_SLICE_PARAMS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_SPS, .ops = &cedrus_ctrl_ops, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_PPS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_SCALING_MATRIX, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_H264_PRED_WEIGHTS, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { @@ -134,7 +134,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, .def = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { @@ -142,7 +142,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_H264_START_CODE_NONE, .def = V4L2_STATELESS_H264_START_CODE_NONE, }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, /* * We only expose supported profiles information, @@ -160,20 +160,20 @@ static const struct cedrus_control cedrus_controls[] = { .menu_skip_mask = BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED), }, - .codec = CEDRUS_CODEC_H264, + .capabilities = CEDRUS_CAPABILITY_H264_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_SPS, .ops = &cedrus_ctrl_ops, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_PPS, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -181,13 +181,13 @@ static const struct cedrus_control cedrus_controls[] = { /* The driver can only handle 1 entry per slice for now */ .dims = { 1 }, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_SCALING_MATRIX, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -197,7 +197,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = 0xffffffff, .step = 1, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -205,7 +205,7 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, .def = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { @@ -213,19 +213,19 @@ static const struct cedrus_control cedrus_controls[] = { .max = V4L2_STATELESS_HEVC_START_CODE_NONE, .def = V4L2_STATELESS_HEVC_START_CODE_NONE, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_VP8_FRAME, }, - .codec = CEDRUS_CODEC_VP8, + .capabilities = CEDRUS_CAPABILITY_VP8_DEC, }, { .cfg = { .id = V4L2_CID_STATELESS_HEVC_DECODE_PARAMS, }, - .codec = CEDRUS_CODEC_H265, + .capabilities = CEDRUS_CAPABILITY_H265_DEC, }, }; @@ -275,6 +275,9 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx) return -ENOMEM; for (i = 0; i < CEDRUS_CONTROLS_COUNT; i++) { + if (!cedrus_is_capable(ctx, cedrus_controls[i].capabilities)) + continue; + ctrl = v4l2_ctrl_new_custom(hdl, &cedrus_controls[i].cfg, NULL); if (hdl->error) { diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 1a98790a99af..7a1619967513 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -57,7 +57,7 @@ enum cedrus_h264_pic_type { struct cedrus_control { struct v4l2_ctrl_config cfg; - enum cedrus_codec codec; + unsigned int capabilities; }; struct cedrus_h264_run { From patchwork Mon Oct 24 20:15:10 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: 10346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682504wru; Mon, 24 Oct 2022 15:32:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4oLtxzOOpJ7ox4laj9bQMCxDXFOvldMnJTcp5x/ZeiC5fX8vHuGqP1btTuzdGM+RsVJEyB X-Received: by 2002:a17:906:7308:b0:78e:191e:8389 with SMTP id di8-20020a170906730800b0078e191e8389mr29742101ejc.170.1666650710740; Mon, 24 Oct 2022 15:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650710; cv=none; d=google.com; s=arc-20160816; b=I637f/eGTZQRbumB/rawxaAVmcjZen7x2Hy0QtQKJkC9/P/rUH41EI5hN2ldwXjAnu N4i65Q4tc9XDF3omQI7JLgzNRcUat21I0unSBvKhtEMIwl8EoXe+gsC3RRuwC16OjJZ1 +ofjqxVfLTbmDXc1o8n4BhdoEIundjTcfWfDsEDKKPuHBpqCrkxTz9xqbOhn3vHymgqB K5J6i/V/ImwXLmcTg0vzuHrUb/fRaqQO7j3YvR6ItcDLTI35IhlDRSZiDze1g823yYTd HKBW9Sj9hctK/4OI34qYTur5C2mnB718WxjDFSq2NYm3zPsENQE340Xj+nl/n9Y9sZNd nNzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y/yrkhmb9tAthV0Ih6jG4Lgj5q7DIPyJ6gH6VCA6KiY=; b=rS5frL16aU68HMIoaENzwbmjJVaNHQi63UqBPB1Hwnp9bVKYtIfZkTfGt02tqHxDQ+ CwT6VJl81PlJgDNqF7IZmLrUBVp4gZ+xueF9z9v6BmAXluKkNZbtRYblYivvjC74Rk+4 nYZcCpCheONhzwtr8CCwwD699pyRBIaznTddQwlKCci/8E8UTaam5Hg4z7EOBc46ZZWo yn7eymfA8ESIfoJJ496R0shKtvR08v4FUiSISX7BYiEp5nvFtRuW/q/ynnBahgcd60pP 6XpPYQHvnurg3sJ5tGbxZTG94VE3oSTGxiYCBk+BMU8oRGIPyLCm1McHMeGJa/w8qh5h WlYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RoYMwdfZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ae4-20020a17090725c400b0079800b81731si1014266ejc.82.2022.10.24.15.31.26; Mon, 24 Oct 2022 15:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RoYMwdfZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbiJXWOX (ORCPT + 99 others); Mon, 24 Oct 2022 18:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232425AbiJXWOA (ORCPT ); Mon, 24 Oct 2022 18:14:00 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1E55FF47; Mon, 24 Oct 2022 13:30:02 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id d26so7638030eje.10; Mon, 24 Oct 2022 13:30:02 -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=Y/yrkhmb9tAthV0Ih6jG4Lgj5q7DIPyJ6gH6VCA6KiY=; b=RoYMwdfZ5hVLNE9a178c+4dilMAsXZLvQ6aJaNOlSOfy91iZdFwVz4IYyAMJhzDWOJ Y15WC9ST9YilKFbVoOOUkgtDYqUSinbPAbd7+cJ4wkDw7p+BCAEt4L9MgPMMbAIZCd/x 0mAamL/Y/RMmytDZ8N3CgTuu73It9W6l1tbEpTe6GVm1JXb3sEnUUOaW5RF3+ZkNzWun Yc6ch1AabQOrXdyWNqQhMYm0XRp0r7/BCbEs5J4uOTjNCGhMQSwDFuilO8kEpJPMEeDO lDE+/AAUygxZ6b7rZrHEi72oDPkh1OhIbiAaDWEzxpfzc0jBYb2O9GUHlrHQrDpvj7OM YvMw== 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=Y/yrkhmb9tAthV0Ih6jG4Lgj5q7DIPyJ6gH6VCA6KiY=; b=zS5v1R/h95xtzR9+LCKOFwzznO2D+xwK43IoLkxFIsZIVyVbGSHMC/Fd3delZHhl78 eQ+pOOKG4Dz/X7PlzZmMP9Vq7EjEM++g91VKmixCFLDZtA2lq4+5jA6nWHS5C6DL36M2 JmrKaMzwHXkZOUy6TCs4fLj3qHcJnYV/cj1hVSuoXPevJpdVV/o2GlxByDpZHc07f84B b0nXPgS+kY9PXhOVPRQGbuvvrWeRdIa0f3SM2VBZVXhowRYitn0vx8i86DXH8cucxkh8 G2C9xRSuDQij+lXeeX284O3PUnyNTB9EgmGHVaqe1qbXpCp9mSgQvgSJG/63AcGs0nNO telA== X-Gm-Message-State: ACrzQf273RVh92iVPYbDVmE57u11ojWyZBRbWG77Jk32JrG+5GDXlmD5 wN1bOAOs/YdRlK018+Z3wJgdKPL8edIy8g== X-Received: by 2002:a17:907:6d23:b0:78d:8f0f:1266 with SMTP id sa35-20020a1709076d2300b0078d8f0f1266mr29663460ejc.762.1666642535989; Mon, 24 Oct 2022 13:15:35 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:35 -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 06/11] media: cedrus: set codec ops immediately Date: Mon, 24 Oct 2022 22:15:10 +0200 Message-Id: <20221024201515.34129-7-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747609935493073825?= X-GMAIL-MSGID: =?utf-8?q?1747609935493073825?= We'll need codec ops soon after output format is set in following commits. Let's move current codec setup to set output format callback. While at it, let's remove one level of indirection by changing current_codec to point to codec ops structure directly. Signed-off-by: Jernej Skrabec Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.c | 5 --- drivers/staging/media/sunxi/cedrus/cedrus.h | 3 +- .../staging/media/sunxi/cedrus/cedrus_dec.c | 4 +- .../staging/media/sunxi/cedrus/cedrus_hw.c | 6 +-- .../staging/media/sunxi/cedrus/cedrus_video.c | 44 ++++++++----------- 5 files changed, 25 insertions(+), 37 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 023566b02dc5..8cfe47574c39 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -455,11 +455,6 @@ static int cedrus_probe(struct platform_device *pdev) return ret; } - dev->dec_ops[CEDRUS_CODEC_MPEG2] = &cedrus_dec_ops_mpeg2; - dev->dec_ops[CEDRUS_CODEC_H264] = &cedrus_dec_ops_h264; - dev->dec_ops[CEDRUS_CODEC_H265] = &cedrus_dec_ops_h265; - dev->dec_ops[CEDRUS_CODEC_VP8] = &cedrus_dec_ops_vp8; - mutex_init(&dev->dev_mutex); INIT_DELAYED_WORK(&dev->watchdog_work, cedrus_watchdog); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 7a1619967513..0b082b1fae22 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -126,7 +126,7 @@ struct cedrus_ctx { struct v4l2_pix_format src_fmt; struct v4l2_pix_format dst_fmt; - enum cedrus_codec current_codec; + struct cedrus_dec_ops *current_codec; struct v4l2_ctrl_handler hdl; struct v4l2_ctrl **ctrls; @@ -185,7 +185,6 @@ struct cedrus_dev { struct platform_device *pdev; struct device *dev; struct v4l2_m2m_dev *m2m_dev; - struct cedrus_dec_ops *dec_ops[CEDRUS_CODEC_LAST]; /* Device file mutex */ struct mutex dev_mutex; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index e7f7602a5ab4..fbbf9e6f0f50 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -94,7 +94,7 @@ void cedrus_device_run(void *priv) cedrus_dst_format_set(dev, &ctx->dst_fmt); - error = dev->dec_ops[ctx->current_codec]->setup(ctx, &run); + error = ctx->current_codec->setup(ctx, &run); if (error) v4l2_err(&ctx->dev->v4l2_dev, "Failed to setup decoding job: %d\n", error); @@ -110,7 +110,7 @@ void cedrus_device_run(void *priv) schedule_delayed_work(&dev->watchdog_work, msecs_to_jiffies(2000)); - dev->dec_ops[ctx->current_codec]->trigger(ctx); + ctx->current_codec->trigger(ctx); } else { v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index a6470a89851e..c3387cd1e80f 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -132,12 +132,12 @@ static irqreturn_t cedrus_irq(int irq, void *data) return IRQ_NONE; } - status = dev->dec_ops[ctx->current_codec]->irq_status(ctx); + status = ctx->current_codec->irq_status(ctx); if (status == CEDRUS_IRQ_NONE) return IRQ_NONE; - dev->dec_ops[ctx->current_codec]->irq_disable(ctx); - dev->dec_ops[ctx->current_codec]->irq_clear(ctx); + ctx->current_codec->irq_disable(ctx); + ctx->current_codec->irq_clear(ctx); if (status == CEDRUS_IRQ_ERROR) state = VB2_BUF_STATE_ERROR; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 04b7b87ef0b7..3591bf9d7d9c 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -335,6 +335,21 @@ static int cedrus_s_fmt_vid_out_p(struct cedrus_ctx *ctx, break; } + switch (ctx->src_fmt.pixelformat) { + case V4L2_PIX_FMT_MPEG2_SLICE: + ctx->current_codec = &cedrus_dec_ops_mpeg2; + break; + case V4L2_PIX_FMT_H264_SLICE: + ctx->current_codec = &cedrus_dec_ops_h264; + break; + case V4L2_PIX_FMT_HEVC_SLICE: + ctx->current_codec = &cedrus_dec_ops_h265; + break; + case V4L2_PIX_FMT_VP8_FRAME: + ctx->current_codec = &cedrus_dec_ops_vp8; + break; + } + /* Propagate format information to capture. */ ctx->dst_fmt.colorspace = pix_fmt->colorspace; ctx->dst_fmt.xfer_func = pix_fmt->xfer_func; @@ -493,34 +508,13 @@ static int cedrus_start_streaming(struct vb2_queue *vq, unsigned int count) struct cedrus_dev *dev = ctx->dev; int ret = 0; - switch (ctx->src_fmt.pixelformat) { - case V4L2_PIX_FMT_MPEG2_SLICE: - ctx->current_codec = CEDRUS_CODEC_MPEG2; - break; - - case V4L2_PIX_FMT_H264_SLICE: - ctx->current_codec = CEDRUS_CODEC_H264; - break; - - case V4L2_PIX_FMT_HEVC_SLICE: - ctx->current_codec = CEDRUS_CODEC_H265; - break; - - case V4L2_PIX_FMT_VP8_FRAME: - ctx->current_codec = CEDRUS_CODEC_VP8; - break; - - default: - return -EINVAL; - } - if (V4L2_TYPE_IS_OUTPUT(vq->type)) { ret = pm_runtime_resume_and_get(dev->dev); if (ret < 0) goto err_cleanup; - if (dev->dec_ops[ctx->current_codec]->start) { - ret = dev->dec_ops[ctx->current_codec]->start(ctx); + if (ctx->current_codec->start) { + ret = ctx->current_codec->start(ctx); if (ret) goto err_pm; } @@ -542,8 +536,8 @@ static void cedrus_stop_streaming(struct vb2_queue *vq) struct cedrus_dev *dev = ctx->dev; if (V4L2_TYPE_IS_OUTPUT(vq->type)) { - if (dev->dec_ops[ctx->current_codec]->stop) - dev->dec_ops[ctx->current_codec]->stop(ctx); + if (ctx->current_codec->stop) + ctx->current_codec->stop(ctx); pm_runtime_put(dev->dev); } From patchwork Mon Oct 24 20:15:11 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: 10337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp672459wru; Mon, 24 Oct 2022 15:04:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QeMbCgzybAvkfT/aX1dV0QliZQD/4j/WJP9fo4wOA18FkVQCLogvvhSdcVPw87hQkWJy0 X-Received: by 2002:a17:90a:1994:b0:212:f4e9:cebf with SMTP id 20-20020a17090a199400b00212f4e9cebfmr13166822pji.51.1666649075094; Mon, 24 Oct 2022 15:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666649075; cv=none; d=google.com; s=arc-20160816; b=fxIGKNmhdPcuQJ2dibeWbw0IXPxwv2abwtvg+ow1TtCLGHM7gRWPQ71CXWh2jqLmUD uV2B0/GrYxQSFNbBo4JtvBxRE2x5Exhik2glXFiR6OpdtJotaXm83oBpcOBILRH/u8Tb htPfLd2ZlrtuC72gOzXmUV0q253rjdybrhP/UvhJmYwXUsKfAX/A1j2CSJPi1+UHpROb 0sKxudslX4iiYzVdokdKZiPFtkrh/W6LllOL/c4ZpZz5WgPGbJrDbJoS3F1xRomjCP5h cQok4y9y0y392iIGzHPpXXKBkv/6lvnQMSCLDoKk3FFd59odTzTvGf2lFPNaUIxgkQfj LnpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oYPY8eOn0zkxqUP4mUno/SYzJ1DIlxFXrIT859K9TgU=; b=v+zwpddaYnBFM57GNE0baDh3ADpKX0C3yWUdyTKI+X25+LGFDrIEEw2U98RwyAHI51 gUZwdo9Mp4iuURnI101JuohZtlURhCrRmY0cYO7QIVBU5DZk+YNiRTL1K+h5rXgSD6+L ULg41q9o5Cf4F6HI3MhjA+EcWFluXPxhh8Dkzncf+IG9QQe0yws4EzB/5ZJu+UwGG/AD 4fXak5H9pvjxxghXgVf5Ae1APvA8bONa8cc0xbscskb9wBgkwhP4H9MOyXl7F3XwC+u9 wZx/qazHVmEH+nttrhqoytCBB9kzyXmSkRy7pdVXLRcQTuMVzIATEjo+k8lVOwcKslcS n2jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EJa3gJX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a17090a4e8300b00200642481bdsi1349207pjh.11.2022.10.24.15.04.21; Mon, 24 Oct 2022 15:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EJa3gJX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231601AbiJXWDr (ORCPT + 99 others); Mon, 24 Oct 2022 18:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbiJXWDX (ORCPT ); Mon, 24 Oct 2022 18:03:23 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9521B8980A; Mon, 24 Oct 2022 13:17:28 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id t25so2108089ejb.8; Mon, 24 Oct 2022 13:17:28 -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=oYPY8eOn0zkxqUP4mUno/SYzJ1DIlxFXrIT859K9TgU=; b=EJa3gJX9kpMHCgLySDmPpfU47pQabWL6PyiJcpU4NaqTOR7QqHeiCspctIO6x82Yl4 N87S3YjLt3Z10rirNDAv7RISUFTpqlQN1+amxqjyzKrwG3OB26uEzso5FhIZMkkz73yG iXLo/0lKQ/Of/I6RilPU5vunfpHg3CweixhF9xKG+lUGyQ5UWrpI0LwxoIq1w93XipTd CyfotY3hUJHustjs43cbxZ+9lgOTBErByMtqy20tYIA+VntaDriOGDAc74ChF0qK0nrl Ch/swzSdOWk1udjpQQnJg+L5yd6g1xE7J0c4xWI56R0enWi31p6PdCvwmne9n1v+PwD4 LhHw== 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=oYPY8eOn0zkxqUP4mUno/SYzJ1DIlxFXrIT859K9TgU=; b=kpsJmNFU3FjW7q3D3kY+Zedl08nJn7iE7htagAyno67KOnw423UFcxsjzljvD8r4z4 WE6blWzvA368SFX2pi6Lf3dOnAn1uOIiBtqGskA/sTQLqRdA0+ljwA9vL6xo8sJqFiII t/rlU5GfJKYeMa4RGBoIFkhl41M9/I/rmomOTDJi9Qa2uQatoILSs/cp+XYYCXNuXga7 70SznZ9jVOGVVezTIfa9CXOAH/lSPq3J7GafcoBoAVJ/ehfzImsqNFjuSXAYt22fedWK bNnmChzDns8pONI1bLwiCtlRlPyHmHC6CzNA0GnvNwzVItt8ex2AfvlZEqkqjxzaQMr/ EMLw== X-Gm-Message-State: ACrzQf2aLMvQvn0QvNRglUuyj3fIH1y/WsQ+RBfyPWhTuyCsjtcVXAgb 3dSYMyCttViVMEHkJxT3cXI= X-Received: by 2002:a17:907:2712:b0:78d:a223:729b with SMTP id w18-20020a170907271200b0078da223729bmr29546597ejk.443.1666642537061; Mon, 24 Oct 2022 13:15:37 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:36 -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 07/11] media: cedrus: Remove cedrus_codec enum Date: Mon, 24 Oct 2022 22:15:11 +0200 Message-Id: <20221024201515.34129-8-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747608220599468803?= X-GMAIL-MSGID: =?utf-8?q?1747608220599468803?= Last user of cedrus_codec enum is cedrus_engine_enable() but this argument is completely redundant. Same information can be obtained via source pixel format. Let's remove this argument and enum. No functional changes intended. Signed-off-by: Jernej Skrabec Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.h | 8 -------- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 12 ++++++------ drivers/staging/media/sunxi/cedrus/cedrus_hw.h | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 2 +- drivers/staging/media/sunxi/cedrus/cedrus_vp8.c | 2 +- 7 files changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 0b082b1fae22..5904294f3108 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -35,14 +35,6 @@ #define CEDRUS_CAPABILITY_VP8_DEC BIT(4) #define CEDRUS_CAPABILITY_H265_10_DEC BIT(5) -enum cedrus_codec { - CEDRUS_CODEC_MPEG2, - CEDRUS_CODEC_H264, - CEDRUS_CODEC_H265, - CEDRUS_CODEC_VP8, - CEDRUS_CODEC_LAST, -}; - enum cedrus_irq_status { CEDRUS_IRQ_NONE, CEDRUS_IRQ_ERROR, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index c92dec21c1ac..dfb401df138a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -518,7 +518,7 @@ static int cedrus_h264_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) struct cedrus_dev *dev = ctx->dev; int ret; - cedrus_engine_enable(ctx, CEDRUS_CODEC_H264); + cedrus_engine_enable(ctx); cedrus_write(dev, VE_H264_SDROT_CTRL, 0); cedrus_write(dev, VE_H264_EXTRA_BUFFER1, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index 7a438cd22c34..5d3da50ce46a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -471,7 +471,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) } /* Activate H265 engine. */ - cedrus_engine_enable(ctx, CEDRUS_CODEC_H265); + cedrus_engine_enable(ctx); /* Source offset and length in bits. */ diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index c3387cd1e80f..fa86a658fdc6 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -31,7 +31,7 @@ #include "cedrus_hw.h" #include "cedrus_regs.h" -int cedrus_engine_enable(struct cedrus_ctx *ctx, enum cedrus_codec codec) +int cedrus_engine_enable(struct cedrus_ctx *ctx) { u32 reg = 0; @@ -42,18 +42,18 @@ int cedrus_engine_enable(struct cedrus_ctx *ctx, enum cedrus_codec codec) reg |= VE_MODE_REC_WR_MODE_2MB; reg |= VE_MODE_DDR_MODE_BW_128; - switch (codec) { - case CEDRUS_CODEC_MPEG2: + switch (ctx->src_fmt.pixelformat) { + case V4L2_PIX_FMT_MPEG2_SLICE: reg |= VE_MODE_DEC_MPEG; break; /* H.264 and VP8 both use the same decoding mode bit. */ - case CEDRUS_CODEC_H264: - case CEDRUS_CODEC_VP8: + case V4L2_PIX_FMT_H264_SLICE: + case V4L2_PIX_FMT_VP8_FRAME: reg |= VE_MODE_DEC_H264; break; - case CEDRUS_CODEC_H265: + case V4L2_PIX_FMT_HEVC_SLICE: reg |= VE_MODE_DEC_H265; break; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.h b/drivers/staging/media/sunxi/cedrus/cedrus_hw.h index 7c92f00e36da..6f1e701b1ea8 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.h @@ -16,7 +16,7 @@ #ifndef _CEDRUS_HW_H_ #define _CEDRUS_HW_H_ -int cedrus_engine_enable(struct cedrus_ctx *ctx, enum cedrus_codec codec); +int cedrus_engine_enable(struct cedrus_ctx *ctx); void cedrus_engine_disable(struct cedrus_dev *dev); void cedrus_dst_format_set(struct cedrus_dev *dev, diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c index c1128d2cd555..10e98f08aafc 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -66,7 +66,7 @@ static int cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) quantisation = run->mpeg2.quantisation; /* Activate MPEG engine. */ - cedrus_engine_enable(ctx, CEDRUS_CODEC_MPEG2); + cedrus_engine_enable(ctx); /* Set intra quantisation matrix. */ matrix = quantisation->intra_quantiser_matrix; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c index f7714baae37d..969677a3bbf9 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c @@ -662,7 +662,7 @@ static int cedrus_vp8_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) int header_size; u32 reg; - cedrus_engine_enable(ctx, CEDRUS_CODEC_VP8); + cedrus_engine_enable(ctx); cedrus_write(dev, VE_H264_CTRL, VE_H264_CTRL_VP8); From patchwork Mon Oct 24 20:15:12 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: 10356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683045wru; Mon, 24 Oct 2022 15:33:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42bu2bP5zcYegHWGlTSNQVjrjKdBrnWlUrLj3oWCjhmW1x1jhkB+LlU+awwpT9a6h8UtFv X-Received: by 2002:a05:6402:1d86:b0:457:e84:f0e with SMTP id dk6-20020a0564021d8600b004570e840f0emr32498865edb.241.1666650817780; Mon, 24 Oct 2022 15:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650817; cv=none; d=google.com; s=arc-20160816; b=amiExFOVvEjN8JKVoQgREuXuY9LZ6Q7cgTSLjseDshZcJSYeA2pjvmbCKOdR+i+SsC +HuKZdaQ1df7f4Cp+otP5wAVbTXTIeNinQ222QxUedNkjLAmt3QmDy/899f5+RcruxcO Zka1E2SQLGkCKtFwtTaaY6wz5LfmaZSX1wjrxOr3EfZfqwtoTA6KmDez9lkGKC5ZhKTb G6Kp0VHlvqpahYE216a8Z9Qjy1N7B+Kanfsm4bRqGxrGnGyeyqRLyJJzWFm2thhWJRt+ FxFY1PgKbxd2zOJlqr3IVBixOplFhS3ty+1EjxyUAlZmiSYVAKQAV6ERZ9YuDiKLAfT0 mUGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BPbmxwiilRECyAIkSs4T2Anmm0TE3NuNMWpiALbuPqI=; b=fc6qRZpkC4ncIJtp9DwVT3P4UMrKrn11bltL333FAot2swYbC/d/7LMAcJv2T2yEfy Kfol5XQLwSb0WN+ZMrPmbBQMI8rbBDP+24MdZ675AdFmaQfnuFy+OD54dvfCOqrkCCTx DuJCXFTNbL5g4T5WPkd4FoW2doJxtl/N3DLiwSz4XDNPHcvPA7ddKA98dsKgPF4yfcl+ V/gGaZaloJdNYM91KEeCR7keqo6Mbh7vfnaviNBDmHc7l0IUOUfN0ut3RshwZQMSJnEv ePnSrDzoBKpTVCjlB4DMB/BJp00SUQ+2HGoxRxCuFlPJhVquOJc9WWHJjFo7qrngA4z0 rv+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GIk36OGr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056402278f00b0045907cec72dsi1085693ede.320.2022.10.24.15.33.13; Mon, 24 Oct 2022 15:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GIk36OGr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbiJXWPG (ORCPT + 99 others); Mon, 24 Oct 2022 18:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbiJXWOt (ORCPT ); Mon, 24 Oct 2022 18:14:49 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443D12D1D2D; Mon, 24 Oct 2022 13:30:50 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id y69so14383736ede.5; Mon, 24 Oct 2022 13:30:50 -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=BPbmxwiilRECyAIkSs4T2Anmm0TE3NuNMWpiALbuPqI=; b=GIk36OGrdtY37JF3S3GWILVLqs/z6Tx/vMuvomKPwWWFbc8epqiGhafuZSUiTXeDi4 VfM+L4ZQ3R/dsL85E8/1Csd5n+kC90guEPjPO4pooOftswdkn2vsLkK2uLg/R8p5YgRM W98Ej67KaWeHMEuW3dXygcLk7CLlcKG7RsA9nPaPS60ZXdmIlFF988HbITAJEb9/pf6c OOP+uRyeb9CxtcY8j39yKzLKfVGtFKmQOGzpcl8dK6N462ykSgYRn5eyDzhTtXbtAjyw q8zxm4ScQpQj/A2MimnI08GgnAxiooJRXtzch64T5O2v1B1MP3BlO/C0rcGaLR9135qK JdhA== 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=BPbmxwiilRECyAIkSs4T2Anmm0TE3NuNMWpiALbuPqI=; b=iuPfn2uiBBhlHVApy9RYo+DezwOoEbdLEWgYqD701WfsI+V8qfp4/t8Jrcd2zehzk/ gCsmkRxtHzb6NyHJLRlmtO8m8hKAPpQZL6gu7OSRd6DwOgjAUgzvScwnbx/9NN/a3Wd+ sBuwxLqdqzGxQymwLM7jK/lwCAciZ6dKAC4RwRfqf1GgzPu5XXSoPDAz0k0EebYc2/77 FWr9SBN+Oksaxg5tZ0rpGZqnVYcZ3TqcM7u9jICJo+LHclxnA5m5HzpvaUfcwMvpGHYe oEZuY0U2rxPPolepW3h/ofJ6lnHkjCE6R3qoMh0ZSGUJWtkM68h+lB3zWyYxQXZostKv uMRQ== X-Gm-Message-State: ACrzQf0IDS55hYdgilRgfGU68QgwODm81qQSrkuo/sKoNVWurol3Kojm FOxO8mZzRg1AvadLhLwX5nk69ciXeKXodw== X-Received: by 2002:a17:907:7611:b0:78d:9d69:adf9 with SMTP id jx17-20020a170907761100b0078d9d69adf9mr29603251ejc.283.1666642538198; Mon, 24 Oct 2022 13:15:38 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:37 -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 08/11] media: cedrus: prefer untiled capture format Date: Mon, 24 Oct 2022 22:15:12 +0200 Message-Id: <20221024201515.34129-9-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610047657969450?= X-GMAIL-MSGID: =?utf-8?q?1747610047657969450?= While all generations of display engine on Allwinner SoCs support untiled format, only first generation supports tiled format. Let's move untiled format up, so it can be picked before tiled one. If Cedrus variant doesn't support untiled format, tiled will still be picked as default format. Signed-off-by: Jernej Skrabec Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 3591bf9d7d9c..f9f723ea3f79 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -56,13 +56,13 @@ static struct cedrus_format cedrus_formats[] = { .capabilities = CEDRUS_CAPABILITY_VP8_DEC, }, { - .pixelformat = V4L2_PIX_FMT_NV12_32L32, + .pixelformat = V4L2_PIX_FMT_NV12, .directions = CEDRUS_DECODE_DST, + .capabilities = CEDRUS_CAPABILITY_UNTILED, }, { - .pixelformat = V4L2_PIX_FMT_NV12, + .pixelformat = V4L2_PIX_FMT_NV12_32L32, .directions = CEDRUS_DECODE_DST, - .capabilities = CEDRUS_CAPABILITY_UNTILED, }, }; From patchwork Mon Oct 24 20:15:13 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: 10345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682361wru; Mon, 24 Oct 2022 15:31:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4oBLrmgmFg7zghKu1KaOVjaCndtCosgO3uMAyMYPz8bhfSl6xFoLPsuBZaKQdyGdN0PFvJ X-Received: by 2002:aa7:ce92:0:b0:461:78c7:dfe2 with SMTP id y18-20020aa7ce92000000b0046178c7dfe2mr13543257edv.342.1666650696517; Mon, 24 Oct 2022 15:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650696; cv=none; d=google.com; s=arc-20160816; b=zFHxT6u81eOkIqHXCDAAleJlt+vXSUv6V7HG9HVmPSBJ1//7w8QxeabbR2bTlH11m7 fifQnjyNSM5zH+RCzk/W5ZMLzrDAlbZUPo2LyV1nLtmTxeBy0G8rWWzysl896d7ha3Ha 5N62PtOtRDmrZ8TYMJOj+TVanIftZ9eWx8K50OOdX9xxOUz0ircrA70SRVUj44gzS4/U g+txotPMX4OG4Y36Ox3T9JJG97EzFfrvnv7j78gk/rxU3PzMe9WhJZaM+hOGbzOqdcK9 Qjju5civvhTcbSZzIFxGqDYwedtrQ9JMDlLkhobWPOODzxSDuc+WLTWNfDiYYYS/bS5b yvVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JN/xnHSP6Pihw6a6lZykPULIKG9MjkS5qFCv+jz3gxE=; b=IaHMPn3rniushbS6xlNqB6nrmqPosGSkNHUm2/gasipB7vKGU0plYekGB82GwNXsPJ +fXkJhIXkoOMEHwO/bpPjov8hoU0tH4IDqvkuPW3RhArjh2mfKmv12PAbkNgv35PpYKy oyP/u4X+LY96dhyZJmfrotU35XYXyfPWXVPxPGYfFYqyIhks5XZTfTQmgGrCYQUl5I04 bHeCjtb1l0jK5bOaPK2NvKaiU9tWJSDhqrD7noQSReWUIB9VXIY/m9dWapNWkKO9mfhR iLjKd08rahIhshBP5ja2mLShXHsgLw4mLhI4lx2wHfGJ/VvRW73flCkRMvFNkm2e2+c8 EsLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N+mfby8B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r9-20020a1709063d6900b0078be5949d95si596663ejf.962.2022.10.24.15.31.08; Mon, 24 Oct 2022 15:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N+mfby8B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbiJXWJO (ORCPT + 99 others); Mon, 24 Oct 2022 18:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232327AbiJXWIf (ORCPT ); Mon, 24 Oct 2022 18:08:35 -0400 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D17D8256D28; Mon, 24 Oct 2022 13:22:10 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id m15so33305494edb.13; Mon, 24 Oct 2022 13:22:10 -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=JN/xnHSP6Pihw6a6lZykPULIKG9MjkS5qFCv+jz3gxE=; b=N+mfby8BkFCNhHQz7lyhNuAhDS+hrHknVOORsYO4JvozUCR/K0WBM3Gkg+waQhOIJU ScQUzjqOj3QzhJsGYier6ZIGKS1frZcxct4YTR2WB2IR76EZtDACbTGZF8/6t0sLZgcE zsCQlFhC1wwE/b8wxRBf+NGjmvb9ujEBStU9ZVNtEhULQhK4bCSIZqOpHKRNGNv+Klk7 c5Z5UwpUK9WvQnvtbgKFnH48IachlfG3LEgdh7U7zLAUF51XEU0Eo7HNa8KuuiEehQrT VshVg1k6XWtl6UuAxRFdarT4wCFj3F2pjHuoR4ecbQs9vnZ5+kMd1RKj7kGVlNP9aPZ7 xf9g== 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=JN/xnHSP6Pihw6a6lZykPULIKG9MjkS5qFCv+jz3gxE=; b=sPUI7lVbrGni/LDCs07jFdh6J5WEC/EVTy/QWqv0rHI9Xpsm8/P57bPSuq5MQPxHCw dlSRRU3pj2DqQ0KVxvRrVIHyI9UNQ3VUOgPu3GNE+mrex4e4tHMU1Fy9/C/sIXe8wDPM 86D+CAC1hoIHHoIcsh+vTEozwmJJTOtnG2klDwuyZgpSV57d1VjtN+dqROB6BrEF1yl2 yQswl4rC/wBChpT8uCci/bEwtSnI6Er8vg0rjzs+DyPHV17M0sOnqEyZgbp3FPbp9cUh UeOg82jKOkhnsQw01Vm7fPuQRictPxo8gxc/hmSfhjjP2GOVOG2gB/FXqA/840H/2w0l kOlg== X-Gm-Message-State: ACrzQf0Yqr9PUEZyNNfF0Y55gMaRDg9jwfX5CO/yco4OBHMER9bu5yFo 9mTW2UEW0dV6yZp04CGqIqg= X-Received: by 2002:a05:6402:1d4f:b0:461:d2ed:788c with SMTP id dz15-20020a0564021d4f00b00461d2ed788cmr5199794edb.418.1666642539269; Mon, 24 Oct 2022 13:15:39 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:38 -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 09/11] media: cedrus: initialize controls a bit later Date: Mon, 24 Oct 2022 22:15:13 +0200 Message-Id: <20221024201515.34129-10-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747609920653648009?= X-GMAIL-MSGID: =?utf-8?q?1747609920653648009?= While it doesn't matter if controls are initialized before or after queues and formats from open handler standpoint, initializing them last helps keeping s_ctrl handler simpler, since everything has already valid values. This is just preparation for follow up changes. No functional change is intended. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 8cfe47574c39..70b07d8bad2b 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -354,27 +354,27 @@ static int cedrus_open(struct file *file) file->private_data = &ctx->fh; ctx->dev = dev; - ret = cedrus_init_ctrls(dev, ctx); - if (ret) - goto err_free; - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &cedrus_queue_init); if (IS_ERR(ctx->fh.m2m_ctx)) { ret = PTR_ERR(ctx->fh.m2m_ctx); - goto err_ctrls; + goto err_free; } cedrus_reset_out_format(ctx); + ret = cedrus_init_ctrls(dev, ctx); + if (ret) + goto err_m2m_release; + v4l2_fh_add(&ctx->fh); mutex_unlock(&dev->dev_mutex); return 0; -err_ctrls: - v4l2_ctrl_handler_free(&ctx->hdl); +err_m2m_release: + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); err_free: kfree(ctx); mutex_unlock(&dev->dev_mutex); From patchwork Mon Oct 24 20:15:14 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: 10395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp698820wru; Mon, 24 Oct 2022 16:18:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7665e7jB4lAXN+YraSB+FbnQkrbs0aqMz9bw+XonjG4BV435XF+ZTTn63/v3wsfFE/Tl8n X-Received: by 2002:a17:90a:8c8e:b0:202:883b:2644 with SMTP id b14-20020a17090a8c8e00b00202883b2644mr76068522pjo.89.1666653494253; Mon, 24 Oct 2022 16:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666653494; cv=none; d=google.com; s=arc-20160816; b=ltDNgDF6MuHksiWcpwaZj98vORRb06p4yYCaZSS8VYrMVlbhXOcfYaYyV3bI+6iWsv 87cFjB6DCxZEvqr7OB+i+qRJdPkh14jBB53VUjTJUvY6qt+AtDurDQbQHaTdh+0vHaNu nrEJTIwq/yoaPAXUvYEVDEfhcXolumdk0+wJXmeqBK0NuUFR6dNTLMHS5+wEXpi2zVY7 GfSF1S7kAgRafcRBCddE99Xpnlrzlei1tf2ERz3cmA7dldBVK502alB7Dpg62PLx7lGu Unz5tr2uIazihOUyJxc6fBVR2J1ctRHiwzhHVJP+YAxzOSI1A+HKSrhBfgQfHCMx2Btn dFRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aG8/ur0Br/iI3XrRIjCBua/JFahdxthZWhXGPmYrCVY=; b=eBQNOK+M7/2vyVjhjkdkap4Tnr94jWO7073rX3C86CSginvyo6Wep77z8uSt1lf7AL cf4yC7ff2mkCRDArDztSltnncSlTLBJVrT78AkBLdxjKE0N4/WhxWoB1ynNfecI4s+3s aOCu8BowPAOTt3WQ6VE650SIAfuoHxZc01y+PoXr8Uxg4+rY7maiz2YI5V4H076MALyH 6IlXqm1Gujrg4iFiskQHLZVgbNJmsz47ivfAG3wqRShwEZGdTmN07zaqdUWV/cR1R7Dq DEWwwwQh5mlO4BEzwsAckLboKfbZ6SUW3b8ah39/ZZBiTPy8PeiFUvpVdrOl3u6Vkt1q qqUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b1VtBkfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j22-20020a170902759600b0017f685b47b8si809377pll.151.2022.10.24.16.18.01; Mon, 24 Oct 2022 16:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b1VtBkfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbiJXXLA (ORCPT + 99 others); Mon, 24 Oct 2022 19:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231787AbiJXXD5 (ORCPT ); Mon, 24 Oct 2022 19:03:57 -0400 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5002932BB0F; Mon, 24 Oct 2022 14:24:29 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id f37so18721147lfv.8; Mon, 24 Oct 2022 14:24:29 -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=aG8/ur0Br/iI3XrRIjCBua/JFahdxthZWhXGPmYrCVY=; b=b1VtBkfnMQzd5t4IFtX29bRFR2tFeeqSiyK+DgVMGnDMFkwI6Fdv3tQXaLqUfYRmBX LABuRSOpX3tq1jb12FjHU6AONUrmAIm6UtCJVjMth3JbjWKSa8lEGJFMsqhoLucJRxJ7 1EQRVkRLurSwogDmO+oiR+aT3lFzKn3a4DnRIwKUet1oBYG6Fz4SbxU9i3VHYcZ06Uv1 mJuSDGEYeBY+obEFffp+jSUTOioH8ymB9/SYto+FH+LiZl2eYtJHI9+gtE1oFz6Gg+Hc VX48riOkEnLyY1xyp2P1a+OZnxDJ+wZq8e6B6a3SiUZkzPuG8LBMUtruHPzNciDAdX1P Lt3w== 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=aG8/ur0Br/iI3XrRIjCBua/JFahdxthZWhXGPmYrCVY=; b=mixOW+fGieneYVbvhiWw574OufwzgS45i3+qjqC+FqgSbtN75XM+2PQ8hJZcCyRHz3 KlhLf+zkO++66fRqrYDD8XUUvsqMCiqs+PNzJy92nwQCcFKI4NNb/ms+PCpnmPWf9lIk ks/IzzJXP7dVGQMn844AtF68ubXijNS2VOrsmTpf0HEcSmiRIMOzP0pfl5BRSO+KIvhg vsEwASbeT8+jy+YTgGVnDoRihhN4DMTFeIZt2sAGKEcSalvVPy91MVeO5el/p1nMPdq5 kZ6Z6ajm2gXdLDyn2qGkY18TZ2iFDYeBN8xsEy9jnVKIXZAvMcxnz85X8IjbH2XQyMlK GxKg== X-Gm-Message-State: ACrzQf0HhwBdWUrImV/WvMmIFAwCwk410nDuno7NeIaUtVEBVs5voG/m 4zMVtV6Hot1jRLok/4t2W1t0q2eTae1EtQ== X-Received: by 2002:a17:907:7244:b0:78d:cedc:7a9e with SMTP id ds4-20020a170907724400b0078dcedc7a9emr28646077ejc.600.1666642540370; Mon, 24 Oct 2022 13:15:40 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:40 -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 10/11] media: cedrus: Adjust buffer size based on control values Date: Mon, 24 Oct 2022 22:15:14 +0200 Message-Id: <20221024201515.34129-11-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747612853882063520?= X-GMAIL-MSGID: =?utf-8?q?1747612853882063520?= 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 70b07d8bad2b..fbe3b2e7c1d4 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 f9f723ea3f79..53e65f74046b 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -251,6 +251,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; } From patchwork Mon Oct 24 20:15:15 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: 10341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp672676wru; Mon, 24 Oct 2022 15:05:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IbQAuC7me+PvyLamuNvMnuzAkEOPTOrR12u81TUjPq4Ss8Np/HkyXE5MtnlHul8wJx3Xy X-Received: by 2002:a05:6402:220b:b0:460:f0a1:c4ed with SMTP id cq11-20020a056402220b00b00460f0a1c4edmr21950184edb.318.1666649104995; Mon, 24 Oct 2022 15:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666649104; cv=none; d=google.com; s=arc-20160816; b=OhGrzd14cQlO+7ggoVn01Y+Iq9uj8AITgigkQdTMtKyfryQemtB2KcVgeyf9NW2nMT 0NZTRPgtD202HgLHFOzD8Y2nf7u8p0QSODpfgQoiBG4gf0cAzp9u/fKi3SteVNiqBuSU FiRzN/YfuitkFlHgGhIYLd5vr+EYq/QnOWE23TndF2yiOHx6YEg0iWF7yst1kE9RQU8y 5cZQWQbZ25XfnGj4uTV4CtmvjnviISLt5t/WyJFRuIbIWMlMePdG2O4koN+Brkq2CqoY To4Pv/rCd5gW5eD+9PWtSTUDFsfRpeB9MRh7xT/IHYasTL6QQ7tAVyVhWDevGhBCf7ZC iyxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=br85ZXo6PMYmOWPRWm1Lwu7e9xuitFs0s08ZOKz/bEw=; b=jD0IBlwfgnVVMi1Jl8+9RXk1oSuAwxhMMWh7gGWa3woS73xMXqoMHTkAF0epzTHVJ3 un2gsYD5HKqo4FE3x1EO31W8NuYz2UVBjs5bDEHi55lOB6t/5X5Yc9UAtuLSlTdespWq k/KSMozjbDicfZbqhsV2Sh8hA8wI1GkOgA43jZ4F/dm+VfLABvoPkba5/zLWNdrMPGtE eqhMAXcVf0z970tgAPWvSzHf+kFnKZf9dA0vFquPNppk46Yf8Y5EPn1S8L/Nne0oZ/Gf NdbxVl6Y18TM6PJItXYGqs5BvsOHMbAXWcLpvPQEsWN7dTu5r95/qSLqNi6fzmCWNAfX K50Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mlFlARER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a50fc07000000b00445f660de5asi836070edr.141.2022.10.24.15.04.40; Mon, 24 Oct 2022 15:05:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mlFlARER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbiJXWER (ORCPT + 99 others); Mon, 24 Oct 2022 18:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbiJXWDj (ORCPT ); Mon, 24 Oct 2022 18:03:39 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEAE51D374A; Mon, 24 Oct 2022 13:17:47 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id y14so7596468ejd.9; Mon, 24 Oct 2022 13:17:47 -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=br85ZXo6PMYmOWPRWm1Lwu7e9xuitFs0s08ZOKz/bEw=; b=mlFlARERiNpYjdF46Kjy8T2k8M5VqBqW+0lP/3ZaGdJdLyWr3eWrtj0AqiAmbWNmY5 mNJatXSjxSksNHCBcbS0M6aTlxc31B429GKIN6mfOm0h2uZrV/IZjg8LB+on5gOqe83g qJA/CU8X4aqCaKb2/0SJlcdTucW+ABvLWVczuoFRiahl37pPCD+xgHVfB+E4GZBmJGoY 82Af+7hFZVPBW3hsYibOIz9KRt8aOvoXrqXSNMt4RfE+4rojr6T8n2/J01/03QsmippX 3+qV0m58wEgxhmO2PzzLoJsrBAPSaZvN4RDZXMuQKupmwKZ8k2xCeEu7tJzPfiJyNGO9 4d4Q== 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=br85ZXo6PMYmOWPRWm1Lwu7e9xuitFs0s08ZOKz/bEw=; b=k0GXCafShBUCuuk0mhactDVUC9D5V8XY+VKsA/Jms+2mOVW1wKMuL0F9mX1Aib0rlz /FZ9it8nxOyNQRya1ut25aPlSaPEfhUP7o/PP+1w7bfAmslOTq4ZM2cwJP6T4Wk3Qx35 t3wCsJAMVISa+k8l56IuvAnIOoMFbcji78EzHObagMN2tbgQm2d2n4EhB6PnwZrfye2L O3/T7XeuJ8d66Hk5eQuStMIJvJ1PbBrdVm4hmRR2mMKGJt2OCy5/EVUxe4PYk3ULlD6p a+XFvWQpUGlxFraq1VPUGWUQ1RAgAu1iNLT1KWGDCnM3S1yvVZHiFsHzpswcjqz2CVuI iu+Q== X-Gm-Message-State: ACrzQf1mauvyfX3QEFv+v2126rSzVA1F05/sR/18vmDxBPslZuZRW3dG YUqa+1LLshQqmZzkarpavdg= X-Received: by 2002:a17:906:9bca:b0:78d:bc5a:9137 with SMTP id de10-20020a1709069bca00b0078dbc5a9137mr30735316ejc.25.1666642541563; Mon, 24 Oct 2022 13:15:41 -0700 (PDT) Received: from kista.localdomain (82-149-19-102.dynamic.telemach.net. [82.149.19.102]) by smtp.gmail.com with ESMTPSA id op7-20020a170906bce700b0073d638a7a89sm332023ejb.99.2022.10.24.13.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 13:15:41 -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 11/11] media: cedrus: h265: Support decoding 10-bit frames Date: Mon, 24 Oct 2022 22:15:15 +0200 Message-Id: <20221024201515.34129-12-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024201515.34129-1-jernej.skrabec@gmail.com> References: <20221024201515.34129-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747608252261264262?= X-GMAIL-MSGID: =?utf-8?q?1747608252261264262?= 10-bit frames needs extra buffer space when 8-bit capture format is used. Use previously prepared infrastructure to adjust buffer size. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus.c | 7 ++++ drivers/staging/media/sunxi/cedrus/cedrus.h | 1 + .../staging/media/sunxi/cedrus/cedrus_h265.c | 35 +++++++++++++++++++ .../staging/media/sunxi/cedrus/cedrus_regs.h | 16 +++++++++ 4 files changed, 59 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index fbe3b2e7c1d4..1054528dbb32 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -75,6 +75,13 @@ static int cedrus_s_ctrl(struct v4l2_ctrl *ctrl) struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + if (ctrl->id == V4L2_CID_STATELESS_HEVC_SPS) { + const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; + + ctx->bit_depth = max(sps->bit_depth_luma_minus8, + sps->bit_depth_chroma_minus8) + 8; + } + if (!vb2_is_busy(vq) && !vb2_is_streaming(vq)) cedrus_reset_cap_format(ctx); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 774fe8048ce3..522c184e2afc 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -119,6 +119,7 @@ struct cedrus_ctx { struct v4l2_pix_format src_fmt; struct v4l2_pix_format dst_fmt; struct cedrus_dec_ops *current_codec; + unsigned int bit_depth; struct v4l2_ctrl_handler hdl; struct v4l2_ctrl **ctrls; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index 5d3da50ce46a..fc9297232456 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -41,6 +41,19 @@ struct cedrus_h265_sram_pred_weight { __s8 offset; } __packed; +static unsigned int cedrus_h265_2bit_size(unsigned int width, + unsigned int height) +{ + /* + * Vendor library additionally aligns width and height to 16, + * but all capture formats are already aligned to that anyway, + * so we can skip that here. All formats are also one form of + * YUV 4:2:0 or another, so we can safely assume multiplication + * factor of 1.5. + */ + return ALIGN(width / 4, 32) * height * 3 / 2; +} + static enum cedrus_irq_status cedrus_h265_irq_status(struct cedrus_ctx *ctx) { struct cedrus_dev *dev = ctx->dev; @@ -802,6 +815,18 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) VE_DEC_H265_SRAM_OFFSET_PRED_WEIGHT_CHROMA_L1); } + if (ctx->bit_depth > 8) { + unsigned int stride = ALIGN(ctx->dst_fmt.width / 4, 32); + + reg = ctx->dst_fmt.sizeimage - + cedrus_h265_2bit_size(ctx->dst_fmt.width, + ctx->dst_fmt.height); + cedrus_write(dev, VE_DEC_H265_OFFSET_ADDR_FIRST_OUT, reg); + + reg = VE_DEC_H265_10BIT_CONFIGURE_FIRST_2BIT_STRIDE(stride); + cedrus_write(dev, VE_DEC_H265_10BIT_CONFIGURE, reg); + } + /* Enable appropriate interruptions. */ cedrus_write(dev, VE_DEC_H265_CTRL, VE_DEC_H265_CTRL_IRQ_MASK); @@ -874,6 +899,15 @@ static void cedrus_h265_trigger(struct cedrus_ctx *ctx) cedrus_write(dev, VE_DEC_H265_TRIGGER, VE_DEC_H265_TRIGGER_DEC_SLICE); } +static unsigned int cedrus_h265_extra_cap_size(struct cedrus_ctx *ctx, + struct v4l2_pix_format *pix_fmt) +{ + if (ctx->bit_depth > 8) + return cedrus_h265_2bit_size(pix_fmt->width, pix_fmt->height); + + return 0; +} + struct cedrus_dec_ops cedrus_dec_ops_h265 = { .irq_clear = cedrus_h265_irq_clear, .irq_disable = cedrus_h265_irq_disable, @@ -882,4 +916,5 @@ struct cedrus_dec_ops cedrus_dec_ops_h265 = { .start = cedrus_h265_start, .stop = cedrus_h265_stop, .trigger = cedrus_h265_trigger, + .extra_cap_size = cedrus_h265_extra_cap_size, }; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h index 655c05b389cf..05e6cbc548ab 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h @@ -498,6 +498,22 @@ #define VE_DEC_H265_LOW_ADDR (VE_ENGINE_DEC_H265 + 0x80) +#define VE_DEC_H265_OFFSET_ADDR_FIRST_OUT (VE_ENGINE_DEC_H265 + 0x84) +#define VE_DEC_H265_OFFSET_ADDR_SECOND_OUT (VE_ENGINE_DEC_H265 + 0x88) + +#define VE_DEC_H265_SECOND_OUT_FMT_8BIT_PLUS_2BIT 0 +#define VE_DEC_H265_SECOND_OUT_FMT_P010 1 +#define VE_DEC_H265_SECOND_OUT_FMT_10BIT_4x4_TILED 2 + +#define VE_DEC_H265_10BIT_CONFIGURE_SECOND_OUT_FMT(v) \ + SHIFT_AND_MASK_BITS(v, 24, 23) +#define VE_DEC_H265_10BIT_CONFIGURE_SECOND_2BIT_ENABLE BIT(22) +#define VE_DEC_H265_10BIT_CONFIGURE_SECOND_2BIT_STRIDE(v) \ + SHIFT_AND_MASK_BITS(v, 21, 11) +#define VE_DEC_H265_10BIT_CONFIGURE_FIRST_2BIT_STRIDE(v) \ + SHIFT_AND_MASK_BITS(v, 10, 0) +#define VE_DEC_H265_10BIT_CONFIGURE (VE_ENGINE_DEC_H265 + 0x8c) + #define VE_DEC_H265_LOW_ADDR_PRIMARY_CHROMA(a) \ SHIFT_AND_MASK_BITS(a, 31, 24) #define VE_DEC_H265_LOW_ADDR_SECONDARY_CHROMA(a) \