From patchwork Thu Dec 29 13:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403648wrt; Thu, 29 Dec 2022 05:35:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXs+qeoO3W3W55oi386kSGyVq03jc+eUZEhn4oOfLcXa3mkMFzGG6ymk1QSoP7HO39dAloVs X-Received: by 2002:a05:6402:1458:b0:47d:a733:c051 with SMTP id d24-20020a056402145800b0047da733c051mr26134959edx.15.1672320947439; Thu, 29 Dec 2022 05:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320947; cv=none; d=google.com; s=arc-20160816; b=Yw9pAHRKG5sRHhHSFf8HV+LDaIUcZ6DyFSG5lHrdYkI4oVXMRKgrmHR/kIQoZK0LSy pA1whXbztm1D2Y75y8d5hI7rLTFS9FOqA+Iq/pTer6SjWNAtCNMqiqPE+VaaD2/qyz6O hMb7LSNju8yvb8ic5eIw8hrYufZvspWvk689cOEcp71lLtQ1IusElN1HqKx0agwTmG1n +cKRvMUj0RmC71cnR4uFUM2kcsHPsv8sI7tVU/u9HjuYCapw+TrDXgbT0qFJuz6Hkrdw dL9yJNMgYIMjQoDgnvL17uJLNpUX9NQmvVq7+OICaAoma2w1c3Dul9Hd2vBYFciAKGnV kp7g== 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=CW64MxchVb9saBnb7wZiFjtE7xT/bCq9uwLuPiV613I=; b=w5S29FYBt619wWahXKSoZFDE8FXMHPKNTvs5yE11oli+tyzp0Kcemi+aH3mIVnPnax xnfRoy8dVL9Tbs1KlEWi73/W9V1/FYiaO6eE6IJnsAx6aFl685x1HqeOUY34SDyBf87K QzOQlUDRu+GSV7xKsm2/+SvZ7tFasFgU89vV7wd16EIcRzO3pQLgYjT3xmbnYB14sPe6 vH1bnd+me78LakCsJa2SVaSXdpHTP3gNtL2YDyGkqHnd5zG3IVKqsj8s1ygQwuazaTfC t/EEZOppEMEyEXVp4z5nKzXDgsOURapUlv8uDo9uxlei9UKwQ8JBvdq2q1ZjLPIp7WT9 npGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="IcrYx/bg"; 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 m7-20020a50cc07000000b0046cd5d896c3si13723862edi.165.2022.12.29.05.35.22; Thu, 29 Dec 2022 05:35:47 -0800 (PST) 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="IcrYx/bg"; 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 S233659AbiL2NeV (ORCPT + 99 others); Thu, 29 Dec 2022 08:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233564AbiL2Ndo (ORCPT ); Thu, 29 Dec 2022 08:33:44 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645C512755; Thu, 29 Dec 2022 05:33:06 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id DEB21FF80E; Thu, 29 Dec 2022 13:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320785; 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=CW64MxchVb9saBnb7wZiFjtE7xT/bCq9uwLuPiV613I=; b=IcrYx/bguyUZYs+cfdCWOZKBpYj9tOyR/uyKoCnbhNn511p6uce8S6pEgH79ipOpwfdfWI PULqa9PHCX62Fy380xq/DcIFGNRnTVbtSM6eUOo10mhqBbycLGIzlmSkzc8Lh7oAqR6IRy fKKsxQ/XagTMVei/I0VjseCFLdV+7jlTZ5khTRvW9KtIjgZqcAqztSyLbB9D4jEMz0BZ5X PIbSqyF33yvcg4cwZ/z5H5r7IhitRZRDUisxuYFXFoD9MPBJH7qGOUUpHmjXYv5218Yars j4B8lo9DAnixhULyqLbMQ67b3d3nV2pfFkIE010b9Pk/tO9kGoIdDWQYy+7J6Q== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 19/21] staging: media: tegra-video: add hooks for planar YUV and H/V flip Date: Thu, 29 Dec 2022 14:32:03 +0100 Message-Id: <20221229133205.981397-20-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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, 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?1753555609676809126?= X-GMAIL-MSGID: =?utf-8?q?1753555609676809126?= 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 --- 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 760606c65a97..4a066b61ab8e 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -92,6 +92,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, @@ -107,6 +108,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 d5e1ed4217e0..0503eb678556 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 @@ -187,6 +195,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;