From patchwork Tue Apr 18 08:00:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 84654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2667637vqo; Tue, 18 Apr 2023 01:11:04 -0700 (PDT) X-Google-Smtp-Source: AKy350bssS0amfykRlXgJG78JY+u4oyurMaX2ER1bnk2PzaUDzHlmS33xxT27hJqrlSteDVrU94a X-Received: by 2002:a05:6a20:a10c:b0:ef:9f35:7b54 with SMTP id q12-20020a056a20a10c00b000ef9f357b54mr9404039pzk.12.1681805464487; Tue, 18 Apr 2023 01:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681805464; cv=none; d=google.com; s=arc-20160816; b=NthizzowRoTGxa4AKTVTESrUgpIJydM58iQamKua2LKMA/iv07pZWCmOIRClbs7u3k 640Ckgm82S6bugRyKZrOOxbi2CGaXnYX9rLy1VVQm61tyg05KRrkZg55T2H3UPX5ZUfy KTkDTv3YsAWrLsh0KM/FVaCFc/no/PXN58DLRPXYb4CXGgZ0bpnk4bzStqlrHn8b/HJb 37I+5uSmUQOI79Ws4zGPKSeqnFHZfJlA8weVBu75mK+psuncjEw72A7k1Nsq2btLa3JI UndMb+miB4McGrm/ibH/0Y2fqfAnlDXRvTT2OzGoYgF3HAyXBu8n/8fC2GT8rbv3oX+P RBhw== 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=PsM0loFRr7Qqghs8TxnS6mVQjrcznghYt4siqeLqiTA=; b=F8Hn5rFVn6N693xGnKVLpp9R5FPUp2waPTw3Zb9UlQXIdiJonPte2AcWTTVqFjVewL vjFzUHCGeD5LITvB/AzG+O0BKAzcDfZ8ZLz3VCpGCJ3qVUkAcO4NK1Mf/5CuAhu0fYgG TLYX+0Ll8Wk/6VtRNNY+XSkY52joXbTUIYAvIiY6S1qbJ6UpRQkrgwbG5loDm8uX6dk/ g+eRs3w5iZmalVnk+TvXtmswW1Fo55Wp8i2F9AuSjEzFCBeFvsgzvrSKJtBO/W5qmw3i gICotPwTOuMgy5BnvfY1EButaWlnm2MZdL7J9T/JcFrwJiXTDamItAe7y7SAE9C+Zm16 w2OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="TUwe/Pdt"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a632009000000b0050bf0c6b2f4si13234306pgg.379.2023.04.18.01.10.52; Tue, 18 Apr 2023 01:11: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=@bootlin.com header.s=gm1 header.b="TUwe/Pdt"; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbjDRIEJ (ORCPT + 99 others); Tue, 18 Apr 2023 04:04:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbjDRIDm (ORCPT ); Tue, 18 Apr 2023 04:03:42 -0400 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [IPv6:2001:4b98:dc4:8::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D67E293DE; Tue, 18 Apr 2023 01:02:48 -0700 (PDT) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id E5270240017; Tue, 18 Apr 2023 08:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1681804930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PsM0loFRr7Qqghs8TxnS6mVQjrcznghYt4siqeLqiTA=; b=TUwe/PdtzCx0VYAlos4wo9jTu8GD4uuLKuwxLrUhSYm7uLHmv/t1jD7+BnwEBMUrbRaI4U CGY427TlyZ3vEhGSeXlx+0EipsBeTz9i+EKETqQz+N7yu5W9AzzA+w/NAkvsvuDxrCvNmg yB53EC/4jjS+YSIzgKLOOju5ErmoRjeHX+PU9bWoNnZy4BE3xaICAcXKW8XaymY+tjfTqH dINyRVBjJK9UFRYle3ayhapaQCC9b1rYhu8KKD3SJeNbJsIvsTrEmayLWJrejJNCvOD64i JHo3ro4qcOb1nkXzpl151Oy1Os45FZJF5lVty60n6h+9SjloCnlEgsRf/nLonA== From: Luca Ceresoli To: linux-tegra@vger.kernel.org Cc: Luca Ceresoli , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Laurent Pinchart , Hans Verkuil , Thomas Petazzoni , Paul Kocialkowski , Richard Leitner , Dmitry Osipenko Subject: [PATCH v6 18/20] staging: media: tegra-video: add hooks for planar YUV and H/V flip Date: Tue, 18 Apr 2023 10:00:52 +0200 Message-Id: <20230418080054.452955-19-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418080054.452955-1-luca.ceresoli@bootlin.com> References: <20230418080054.452955-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1763500846579875823?= X-GMAIL-MSGID: =?utf-8?q?1763500846579875823?= Tegra20 supports planar YUV422 capture, which can be implemented by writing U and V base address registers in addition to the "main" base buffer address register. It also supports H and V flip, which among others requires to write the start address (i.e. the 1st offset to write, at the end of the buffer or line) in more registers for Y and, for planar formats, U and V. Add minimal hooks in VI to allow per-SoC optional support to those features: - variables in struct tegra_vi for the U and V buffer base offsets - variables in struct tegra_vi for the Y, U and V buffer start offsets - an optional per-soc VI operation to compute those values on queue setup Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- No changes in v6 No changes in v5 Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 4 ++++ drivers/staging/media/tegra-video/vi.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index b74cdd1d1c82..5ab24977ec46 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -102,6 +102,7 @@ tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) /* * videobuf2 queue operations */ + static int tegra_channel_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, @@ -117,6 +118,9 @@ static int tegra_channel_queue_setup(struct vb2_queue *vq, sizes[0] = chan->format.sizeimage; alloc_devs[0] = chan->vi->dev; + if (chan->vi->ops->channel_queue_setup) + chan->vi->ops->channel_queue_setup(chan); + return 0; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 02f940f2e2eb..cadf80b742a8 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -47,6 +47,7 @@ struct tegra_vi_channel; * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry + * @channel_queue_setup: additional operations at the end of vb2_ops::queue_setup * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -58,6 +59,7 @@ struct tegra_vi_ops { int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); + void (*channel_queue_setup)(struct tegra_vi_channel *chan); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; @@ -148,6 +150,12 @@ struct tegra_vi { * @queue: vb2 buffers queue * @sequence: V4L2 buffers sequence number * + * @addr_offset_u: U plane base address, relative to buffer base address (only for planar) + * @addr_offset_v: V plane base address, relative to buffer base address (only for planar) + * @start_offset: 1st Y byte to write, relative to buffer base address (for H/V flip) + * @start_offset_u: 1st U byte to write, relative to buffer base address (for H/V flip) + * @start_offset_v: 1st V byte to write, relative to buffer base address (for H/V flip) + * * @capture: list of queued buffers for capture * @start_lock: protects the capture queued list * @done: list of capture done queued buffers @@ -189,6 +197,12 @@ struct tegra_vi_channel { struct vb2_queue queue; u32 sequence; + unsigned int addr_offset_u; + unsigned int addr_offset_v; + unsigned int start_offset; + unsigned int start_offset_u; + unsigned int start_offset_v; + struct list_head capture; /* protects the capture queued list */ spinlock_t start_lock;