From patchwork Mon Jan 30 14:16:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 50322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2205100wrn; Mon, 30 Jan 2023 06:21:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXscFjYUzccmmJTQQ2DEPG1NiUmc1iYSMWe2P/gi6iLaTznOEteTovxdpJ8Ydg/3GvSMnc5j X-Received: by 2002:a17:906:3a4d:b0:873:393f:1bda with SMTP id a13-20020a1709063a4d00b00873393f1bdamr45166421ejf.47.1675088492329; Mon, 30 Jan 2023 06:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675088492; cv=none; d=google.com; s=arc-20160816; b=Hd3E4zih3E0FJQB3AwQuROKCDvRvS7072lrnTfoPITKM1Imjx76aJjqkh5/S7zLGHb xSY8O30U63AJEaYqJcv9i28vAIrEW8iVn5xDL7oTMGPoDbQdd/bkLU1JiH6lLPc4NqV3 Iu8cK/+yZ1BtYhxlh8SZE1PXK388LnJvtbI6Q27SRXZxnimGP6L8aGvfjZkNWX4GeG5/ wY/H6Flko0IJxAC8LUFwiZGdyXtKPV6tUJFXKeoIg78uKt2EcR0AMJXutJHQyS2CGzsP lihQZITVIcvHcBNrrN5LhVBywXJd1U6sErpo9ZzCs2gRXHXSKAyEgd2DJlFt8dBcwLdx BYvA== 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=hDiV5rOlFdW2m46RMT95urn/gnlTWYvRe5STpBeX4qE=; b=CttCKlqN4ym5HIZRKS+ijhgL9HjjhFTZlEoIIdndqUVo/FwTrSd9jMh6Hy17Sf5r8Y 7VlZfUMIEwFv+ieGSM8hnFFNrfcP6fpPzbUZ6n8g9kALuQNJKQMpfnEIB8ogWk1IEM4Q 9IfnNohNlQjbUV89fbSZ3W7BoYU8rayee2QSopwVBKFZ+W+mGOn3xndveLw4+S7d3Jje RAIT5hl+hoQ7Ufkp5kgTJTnV0kikCJwFaNVzqXLmyKZ6+ciVWe/6m/RUp4DZEqBQkfnT BT79LdmtSzSkqLHE/X/Iz5evyldW1zW7vVKSltGHrRHS8dDRnNqq6RIDdqyI+70lAFpu JQSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dTaZ8eki; 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 fv33-20020a17090750a100b0087a4d61bb9asi11161276ejc.849.2023.01.30.06.21.08; Mon, 30 Jan 2023 06:21:32 -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=dTaZ8eki; 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 S237710AbjA3OUU (ORCPT + 99 others); Mon, 30 Jan 2023 09:20:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237694AbjA3OTv (ORCPT ); Mon, 30 Jan 2023 09:19:51 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 084F53F28B; Mon, 30 Jan 2023 06:18:34 -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 7FD83100013; Mon, 30 Jan 2023 14:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675088278; 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=hDiV5rOlFdW2m46RMT95urn/gnlTWYvRe5STpBeX4qE=; b=dTaZ8ekiaoFzA+GugG7iQ4Xe6kD5t4varRI3pqUp4Q7RP1J8/w/XYJ571hQdL/RUtFsiXj E3r4mXwheiX11D8+PPevN0da7Mofffbao/J+goXMsSht6DPOg+fp8fWisdKlmc+j1Mj7Go ecMMPXTQTfX/qYiUGiDX18m9cSjHJqiEyvnkHKF4C3vkue3mnAdx/BPplpu9ZZFfJvgE9V LEO9sR5sYH3GK2f3FWgr0TmJ2BORM6GM/yCoqPZheAPyr2OdXNllzQDgRE4O5U71CfWKML vgGTagCPTBJMFJsvc5Yayq/iWEpM5n958HfJeY5InGiYgXNS2EgKaLarjdk56Q== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , 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 v4 20/21] staging: media: tegra-video: add H/V flip controls Date: Mon, 30 Jan 2023 15:16:02 +0100 Message-Id: <20230130141603.323221-21-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230130141603.323221-1-luca.ceresoli@bootlin.com> References: <20230130141603.323221-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 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?1756457591027355011?= X-GMAIL-MSGID: =?utf-8?q?1756457591027355011?= Tegra20 can do horizontal and vertical image flip, but Tegra210 cannot (either the hardware, or this driver). In preparation to adding Tegra20 support, add a flag in struct tegra_vi_soc so the generic vi.c code knows whether the flip controls should be added or not. Also provide a generic implementation that simply sets two flags in the channel struct. The Tegra20 implementation will enable flipping at stream start based on those flags. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 14 +++++++++++++- drivers/staging/media/tegra-video/vi.h | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 4a066b61ab8e..d1c6877163c2 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -29,7 +29,7 @@ #include "vi.h" #include "video.h" -#define MAX_CID_CONTROLS 1 +#define MAX_CID_CONTROLS 3 /** * struct tegra_vi_graph_entity - Entity in the video graph @@ -893,6 +893,12 @@ static int vi_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY: chan->syncpt_timeout_retry = ctrl->val; break; + case V4L2_CID_HFLIP: + chan->hflip = ctrl->val; + break; + case V4L2_CID_VFLIP: + chan->vflip = ctrl->val; + break; default: return -EINVAL; } @@ -964,6 +970,12 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) v4l2_ctrl_handler_free(&chan->ctrl_handler); return ret; } + + if (chan->vi->soc->has_h_v_flip) { + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); + } + #endif /* setup the controls */ diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 0503eb678556..8fa817757059 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -74,6 +74,7 @@ struct tegra_vi_ops { * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels * @vi_max_clk_hz: VI clock max frequency + * @has_h_v_flip: the chip can do H adn V flip, and the driver implements it */ struct tegra_vi_soc { const struct tegra_video_format *video_formats; @@ -83,6 +84,7 @@ struct tegra_vi_soc { u32 hw_revision; unsigned int vi_max_channels; unsigned int vi_max_clk_hz; + bool has_h_v_flip:1; }; /** @@ -170,6 +172,9 @@ struct tegra_vi { * @syncpt_timeout_retry: syncpt timeout retry count for the capture * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier + * + * @hflip: Horizontal flip is enabled + * @vflip: Vertical flip is enabled */ struct tegra_vi_channel { struct list_head list; @@ -218,6 +223,9 @@ struct tegra_vi_channel { enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; + + bool hflip:1; + bool vflip:1; }; /**