From patchwork Thu Jun 28 16:20:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10494427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDF7F603EE for ; Thu, 28 Jun 2018 16:22:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F9A02A608 for ; Thu, 28 Jun 2018 16:22:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7407A2A63F; Thu, 28 Jun 2018 16:22:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19A732A608 for ; Thu, 28 Jun 2018 16:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967304AbeF1QVb (ORCPT ); Thu, 28 Jun 2018 12:21:31 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:42987 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753722AbeF1QV2 (ORCPT ); Thu, 28 Jun 2018 12:21:28 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYZfV-0004p6-Dh; Thu, 28 Jun 2018 18:21:13 +0200 Received: from mfe by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fYZfQ-0007FY-LW; Thu, 28 Jun 2018 18:21:08 +0200 From: Marco Felsch To: mchehab@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: p.zabel@pengutronix.de, afshin.nasser@gmail.com, javierm@redhat.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 08/22] [media] tvp5150: trigger autodetection on subdev open to reset cropping Date: Thu, 28 Jun 2018 18:20:40 +0200 Message-Id: <20180628162054.25613-9-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180628162054.25613-1-m.felsch@pengutronix.de> References: <20180628162054.25613-1-m.felsch@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Philipp Zabel If cropping isn't set explicitly by userspace, reset it to the maximum possible rectangle in subdevice open if a standard change is detected. Signed-off-by: Philipp Zabel [m.felsch@pengutronix.de: move code from internal_ops.open() to pad_ops.init_cfg()] [m.felsch@pengutronix.de: make use of tvp5150_set_default() helper] Signed-off-by: Marco Felsch --- drivers/media/i2c/tvp5150.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index c73536cfcc62..dbfc56c87434 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -55,6 +55,7 @@ struct tvp5150 { struct regmap *regmap; v4l2_std_id norm; /* Current set standard */ + v4l2_std_id detected_norm; u32 input; u32 output; int enable; @@ -1034,6 +1035,27 @@ static int tvp5150_g_mbus_config(struct v4l2_subdev *sd, /**************************************************************************** V4L2 subdev pad ops ****************************************************************************/ +static int tvp5150_init_cfg(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg) +{ + struct tvp5150 *decoder = to_tvp5150(sd); + v4l2_std_id std; + + /* + * Reset selection to maximum on subdev_open() if autodetection is on + * and a standard change is detected. + */ + if (decoder->norm == V4L2_STD_ALL) { + std = tvp5150_read_std(sd); + if (std != decoder->detected_norm) { + decoder->detected_norm = std; + tvp5150_set_default(std, &decoder->rect); + } + } + + return 0; +} + static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) @@ -1308,6 +1330,7 @@ static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = { }; static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = { + .init_cfg = tvp5150_init_cfg, .enum_mbus_code = tvp5150_enum_mbus_code, .enum_frame_size = tvp5150_enum_frame_size, .set_fmt = tvp5150_fill_fmt, @@ -1640,6 +1663,7 @@ static int tvp5150_probe(struct i2c_client *c, return res; core->norm = V4L2_STD_ALL; /* Default is autodetect */ + core->detected_norm = V4L2_STD_UNKNOWN; core->input = TVP5150_COMPOSITE1; core->enable = true;