From patchwork Wed Feb 26 21:59:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11407349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F10A014B4 for ; Wed, 26 Feb 2020 22:00:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D08C024656 for ; Wed, 26 Feb 2020 22:00:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nXwnc1BO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727715AbgBZWAM (ORCPT ); Wed, 26 Feb 2020 17:00:12 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39918 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbgBZWAM (ORCPT ); Wed, 26 Feb 2020 17:00:12 -0500 Received: by mail-lj1-f196.google.com with SMTP id o15so884184ljg.6 for ; Wed, 26 Feb 2020 14:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4YOgxx6r3afGhYc6lPiOHhyKgCrl1sOqiBB2Itl3m5s=; b=nXwnc1BO91TUBSvST7irz6/aCJY4ms204X6IkAZ48304Z6/HellAUfPTooG7QpYbfQ 49JbjmxPTlt+WKC0GVdZ4uuvgU0JSlhg3R4Pp8bGwAQkBxkVozeHVm9/SmEma1u7McgI H80hJQpUAGQM5EZxrWF+lUjoMZhNoUcxY9Zg1p4ff9sDawykDVmYGW5wPdY0Lp7qg9z8 NR5LC7SfN1CJaujxvPQllhZaP9e1ktwqAmdVESxANcLjy2s/7WlNrIpwvrSevUmfOv6x CrWjcrmbQRFTvHMLck1tJsXgErjJu1JqtVLuQMqAk69CvUuWYVtRgTBhE81yGWp8j5mZ bEXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4YOgxx6r3afGhYc6lPiOHhyKgCrl1sOqiBB2Itl3m5s=; b=VY9ZGaIY6elaGyj//3V1dKgUo2vZAI1rwQYRlnR/KIdXIhurM7Vc5XjtvsToZvrrZe AUN5/d97o/Mt5pn0mYU3/FhaTSpQ6BjvKxF39ZvIjh+3ENTiqz6O09Cfhw3Hs9flOBCo AVTPcn+99uHzpw1cWHsxpY9rF2/SFIsMYCmxF3BhbBsr9LgAeycy28PqbJnyocUTa1kZ oD/0srSbWBkBQhPos9EHXFBo2i4ofROILGlsPA3zq0mO2s1v9ZIF6NegpKpks3PL7YKI wWB09wOu9Qts6ev2tz465gxB16v0ml6qeIUnAwIN0BfSTmxF0y6FBU5ymwNG6cB3ip8u PIXw== X-Gm-Message-State: ANhLgQ3/JOqAtl9mvxXu6enV6wid1W1Yc88eBXbi4IBQapZzIkl60quv A7f8N/m31XjBzsF5AffhK1AGjQ== X-Google-Smtp-Source: ADFU+vs78+nzViHBPIEbiewEFBUg+RwCXMDCT9d4tczbvxrgDA5nMJhrQzRORrWVa+yH4OSRZuZ/tw== X-Received: by 2002:a2e:9041:: with SMTP id n1mr673031ljg.133.1582754408670; Wed, 26 Feb 2020 14:00:08 -0800 (PST) Received: from localhost.localdomain (95-28-65-22.broadband.corbina.ru. [95.28.65.22]) by smtp.googlemail.com with ESMTPSA id a9sm316856lfr.37.2020.02.26.14.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 14:00:08 -0800 (PST) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi Cc: linux-media@vger.kernel.org, manivannan.sadhasivam@linaro.org, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH 1/3] media: i2c: imx290: set the format before VIDIOC_SUBDEV_G_FMT is called Date: Thu, 27 Feb 2020 00:59:11 +0300 Message-Id: <20200226215913.10631-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200226215913.10631-1-andrey.konovalov@linaro.org> References: <20200226215913.10631-1-andrey.konovalov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org With the current driver 'media-ctl -p' issued right after the imx290 driver is loaded prints: pad0: Source [fmt:unknown/0x0] The format value of zero is due to the current_format field of the imx290 struct not being initialized yet. As imx290_entity_init_cfg() calls imx290_set_fmt(), the current_mode field is also initialized, so the line which set current_mode to a default value in driver's probe() function is no longer needed. Signed-off-by: Andrey Konovalov Reviewed-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index f7678e5a5d87..2d8c38ffe2f0 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -722,9 +722,6 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } - /* Set default mode to max resolution */ - imx290->current_mode = &imx290_modes[0]; - /* get system clock (xclk) */ imx290->xclk = devm_clk_get(dev, "xclk"); if (IS_ERR(imx290->xclk)) { @@ -809,6 +806,9 @@ static int imx290_probe(struct i2c_client *client) goto free_ctrl; } + /* Initialize the frame format (this also sets imx290->current_mode) */ + imx290_entity_init_cfg(&imx290->sd, NULL); + ret = v4l2_async_register_subdev(&imx290->sd); if (ret < 0) { dev_err(dev, "Could not register v4l2 device\n"); From patchwork Wed Feb 26 21:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11407351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1F4914B4 for ; Wed, 26 Feb 2020 22:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1AF72467A for ; Wed, 26 Feb 2020 22:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gmnsmX27" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727736AbgBZWAP (ORCPT ); Wed, 26 Feb 2020 17:00:15 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36414 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbgBZWAP (ORCPT ); Wed, 26 Feb 2020 17:00:15 -0500 Received: by mail-lf1-f66.google.com with SMTP id f24so490292lfh.3 for ; Wed, 26 Feb 2020 14:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uyUS9Qrs/Z0OPucsNs7VCy+xNY1BgSvPcX046PaoEd0=; b=gmnsmX27jolZIi2TCvxMy6vZR1vzYlc5BwWzCOT05cyEUC/DtdWu/Xy8FsQ4u5+xqJ XzVLBEr4wvG7EkkCgqPK9RFgSF4RWHOn51NfBlX21Nk9mCcsQdPBumdAs20fSAlPZebL 3VrebLynzxRdRu42s1W21c8UhliwxG+mSTUoKHK0HRPzuDR/+kkzKILo0VHNCZn6pWlA HA47VBp75rkNk6VYtrkNq0A/QC04qecnXfW1y42nwMTakFgsQ0v/PsN0CihMxq728zyl DNppj2LgfrVcLElJ6Fq0PUsgrr2UJ3IjCm7JkHrOzY67/DQlcJgHaI6LjQGjA2IdFqRJ Pn/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uyUS9Qrs/Z0OPucsNs7VCy+xNY1BgSvPcX046PaoEd0=; b=N6Rr8yIgoGpew4Yg5k6EoluXjpM31WSShiZ/qpasBf2PDndm01AnZg7qW2DQShjldU 7uJMLgF+wGjpqGIbH5F0xf6pxOu/E/xy16iM5HslPuq3Kicpz2Gp4iYdQieEqXZHTANR KFQHNIUiUzQJiwJstKsI1L7Up8uV2qX4OveUazpol6sZs/TgQ75zGY1fnLqe4kSuCV34 bEVl6K2Rhz0q+PqhiBAtFw4pIuQJ4N1ATBhO1Oe06ciXSS2CZoeXTQOTGBSRsobISmkT ux6v0viSdYR0nVOriRLbIjvRTwdX7C5JKVgU22f/PF9fHKuF9sXmt/Y+0MjvkyPirTIV Ieww== X-Gm-Message-State: ANhLgQ08tlm9StWcqNTZUF1O0SmyrQGL9Jy5whudiMGKUnj+VfKnmaNn K5CZ9X8AhXYVhVFv0l5ZhifmaA== X-Google-Smtp-Source: ADFU+vsA82ed28b+MQEg8V0WzaZ9al0ZZrv+I915xq1Bw+ty/aJ+LdkF7s4molW+Sky7hTV5Dss2eQ== X-Received: by 2002:a05:6512:70:: with SMTP id i16mr357709lfo.93.1582754412049; Wed, 26 Feb 2020 14:00:12 -0800 (PST) Received: from localhost.localdomain (95-28-65-22.broadband.corbina.ru. [95.28.65.22]) by smtp.googlemail.com with ESMTPSA id a9sm316856lfr.37.2020.02.26.14.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 14:00:11 -0800 (PST) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi Cc: linux-media@vger.kernel.org, manivannan.sadhasivam@linaro.org, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH 2/3] media: i2c: imx290: fix the order of the args in SET_RUNTIME_PM_OPS() Date: Thu, 27 Feb 2020 00:59:12 +0300 Message-Id: <20200226215913.10631-3-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200226215913.10631-1-andrey.konovalov@linaro.org> References: <20200226215913.10631-1-andrey.konovalov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This macro is defined as SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn), so imx290_power_off must be the 1st arg, and imx290_power_on the 2nd. Signed-off-by: Andrey Konovalov Reviewed-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 2d8c38ffe2f0..d0322f9a8856 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -648,7 +648,7 @@ static int imx290_power_off(struct device *dev) } static const struct dev_pm_ops imx290_pm_ops = { - SET_RUNTIME_PM_OPS(imx290_power_on, imx290_power_off, NULL) + SET_RUNTIME_PM_OPS(imx290_power_off, imx290_power_on, NULL) }; static const struct v4l2_subdev_video_ops imx290_video_ops = { From patchwork Wed Feb 26 21:59:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11407353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4719314B4 for ; Wed, 26 Feb 2020 22:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 271B82467B for ; Wed, 26 Feb 2020 22:00:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wYKAQgnB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbgBZWAS (ORCPT ); Wed, 26 Feb 2020 17:00:18 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45886 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbgBZWAS (ORCPT ); Wed, 26 Feb 2020 17:00:18 -0500 Received: by mail-lf1-f68.google.com with SMTP id z5so452561lfd.12 for ; Wed, 26 Feb 2020 14:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QErWqDNx6ma/Mrb8WHfJQvYV3gtMn9M2hXBvJASL1DQ=; b=wYKAQgnBinTi8kDWS/NFRHJMD9GAw64zo5eozb9jwu2ChqYkoQlXLHXWHQVd3wtOjx 0PJP8a70J3eYoSwneNct4ohjl/G2sxiTQtadgLWWQ7+yAgUCniFoEkwrLJJdIaEamhzm fH7FFCHX8YfoX4CiAtHkTM9NMi2DfykIHP56AieGZaH11al+OXbnMQqcX1jw3fT39yqy xV4DEMJ2qzTv2M+OQsfzC+Uh2I7HY+xa24g0WpFno4lldbm0eU6gqNCftwmgWLK8rGRi vKmUeRijS2PSQJzxlUcdnYgK7ifhxW1WUVUOfOijGfV+UbM7NF6WphUnhFryjbDrUhxs DCmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QErWqDNx6ma/Mrb8WHfJQvYV3gtMn9M2hXBvJASL1DQ=; b=FjZ6T1f8xyeOy4nrc+Xfvky41wgqhBGSXfiwagQioWtHAy/otRbIDUKQckSiAJPHMw 25u9n7X0A+39wCuY/V9Nd3seJ85i0C1ph98WfFU48N2GgGEEIkHGeP7ljsYlgiyQolrw buLSirtPS66WM+Z9mo3qKnmfTUnKY7p83ljDoNSXu5u5t4Tkg6A621omzHFWAxzVNikL JpWKPq4/SjHJIl+i3hRadskFGgzLuknbNZzL8CSbHhgSsekhGmDROlnErDa9Hbj2eBWR w4Low5NPzzUDm5uL5J2yvOmTxiNENH2XAZtQUgICfa+j3bwunPyy59ak8xNgae4e6vhW oV4w== X-Gm-Message-State: ANhLgQ3pMxXY/h2D0cLUR/G1R+4zlXExnf1dbq5HYsNP4UEyfgBLstd5 TXYyyR53LQU9aAdvPBIsjLFwuA== X-Google-Smtp-Source: ADFU+vsIMS6/a2zeGP/md2OrcANipbEX9d3cbZW7MWcbV0NSirOCb9TdCOsgHRjqrLaNdaE40a3eGA== X-Received: by 2002:a19:878a:: with SMTP id j132mr357831lfd.83.1582754416436; Wed, 26 Feb 2020 14:00:16 -0800 (PST) Received: from localhost.localdomain (95-28-65-22.broadband.corbina.ru. [95.28.65.22]) by smtp.googlemail.com with ESMTPSA id a9sm316856lfr.37.2020.02.26.14.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 14:00:15 -0800 (PST) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi Cc: linux-media@vger.kernel.org, manivannan.sadhasivam@linaro.org, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH 3/3] media: i2c: imx290: fix reset GPIO pin handling Date: Thu, 27 Feb 2020 00:59:13 +0300 Message-Id: <20200226215913.10631-4-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200226215913.10631-1-andrey.konovalov@linaro.org> References: <20200226215913.10631-1-andrey.konovalov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org According to https://www.kernel.org/doc/Documentation/gpio/consumer.txt, - all of the gpiod_set_value_xxx() functions operate with the *logical* value. So in imx290_power_on() the reset signal should be cleared/de-asserted with gpiod_set_value_cansleep(imx290->rst_gpio, 0), and in imx290_power_off() the value of 1 must be used to apply/assert the reset to the sensor. In the device tree the reset pin is described as GPIO_ACTIVE_LOW, and gpiod_set_value_xxx() functions take this into account, - when devm_gpiod_get_optional() is called with GPIOD_ASIS, the GPIO is not initialized, and the direction must be set later; using a GPIO without setting its direction first is illegal and will result in undefined behavior. Fix this by using GPIOD_OUT_HIGH instead of GPIOD_ASIS (this asserts the reset signal to the sensor initially). Signed-off-by: Andrey Konovalov Reviewed-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index d0322f9a8856..7b1de1f0c8b7 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -628,7 +628,7 @@ static int imx290_power_on(struct device *dev) } usleep_range(1, 2); - gpiod_set_value_cansleep(imx290->rst_gpio, 1); + gpiod_set_value_cansleep(imx290->rst_gpio, 0); usleep_range(30000, 31000); return 0; @@ -641,7 +641,7 @@ static int imx290_power_off(struct device *dev) struct imx290 *imx290 = to_imx290(sd); clk_disable_unprepare(imx290->xclk); - gpiod_set_value_cansleep(imx290->rst_gpio, 0); + gpiod_set_value_cansleep(imx290->rst_gpio, 1); regulator_bulk_disable(IMX290_NUM_SUPPLIES, imx290->supplies); return 0; @@ -757,7 +757,8 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } - imx290->rst_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS); + imx290->rst_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); if (IS_ERR(imx290->rst_gpio)) { dev_err(dev, "Cannot get reset gpio\n"); ret = PTR_ERR(imx290->rst_gpio);