From patchwork Thu Apr 9 12:11:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481669 X-Patchwork-Delegate: kieran@bingham.xyz 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 1118514DD for ; Thu, 9 Apr 2020 12:12:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA04420857 for ; Thu, 9 Apr 2020 12:12:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kVJ7jDjG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725970AbgDIMMJ (ORCPT ); Thu, 9 Apr 2020 08:12:09 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48718 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMMJ (ORCPT ); Thu, 9 Apr 2020 08:12:09 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2BDE4B76; Thu, 9 Apr 2020 14:12:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434328; bh=jkiEp6p3sUNMg2d8OX+XTJENo0FR4MrtmhfT7MeUK9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kVJ7jDjGpNdIrS/W71G64WAsnSkypm02zc+nUGiY29YMHwfdb6/BUKdHGJMbmeG6t 6tCrtzQ8F2iAx6S0RL8qFEbaLl0kTJdMMOvXHHQuCxd1ehNwcIs6bHhJbya4e6PtAV D+lB4r4m7Usx6Z4BU7hCsijU6/dxH00fqXVdELN8= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 01/13] squash! max9286: Update the bound_sources mask on unbind Date: Thu, 9 Apr 2020 13:11:50 +0100 Message-Id: <20200409121202.11130-2-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The bound_sources bit mask tracks sources which have been successfully bound through the v4l2 async notifier system. Ensure that the mask is updated accordingly when unbinding. Signed-off-by: Kieran Bingham Acked-by: Jacopo Mondi --- drivers/media/i2c/max9286.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index cb58782e5143..b84d2daa6561 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -493,9 +493,12 @@ static void max9286_notify_unbind(struct v4l2_async_notifier *notifier, struct v4l2_subdev *subdev, struct v4l2_async_subdev *asd) { + struct max9286_priv *priv = sd_to_max9286(notifier->sd); struct max9286_source *source = asd_to_max9286_source(asd); + unsigned int index = to_index(priv, source); source->sd = NULL; + priv->bound_sources &= ~BIT(index); } static const struct v4l2_async_notifier_operations max9286_notify_ops = { From patchwork Thu Apr 9 12:11:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481673 X-Patchwork-Delegate: kieran@bingham.xyz 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 34BAB14DD for ; Thu, 9 Apr 2020 12:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09F3E2078E for ; Thu, 9 Apr 2020 12:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IxWb3Hqe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726521AbgDIMML (ORCPT ); Thu, 9 Apr 2020 08:12:11 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgDIMML (ORCPT ); Thu, 9 Apr 2020 08:12:11 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A8F51DA9; Thu, 9 Apr 2020 14:12:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434329; bh=S3luRTSPZAsB8Ytob3I9t3Hd0nDjS9LWobOWyBZXHOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IxWb3HqetRH22DlOh1M2h4MzyVLU6ejiZpTRF0BK83dnGGLAS+ZmIOQRkuogPlJeV N/UI5ibunOoM+pHch4Ht9gAzoWj58nNHtG3HYqP0LMJpF0csoYEZrHIH0ecFBSNP+9 c2ZhQPorgdfwtEhZL5lyz8Lh//9x4fr4TyAW9u/w= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 02/13] squash! max9286: convert probe kzalloc Date: Thu, 9 Apr 2020 13:11:51 +0100 Message-Id: <20200409121202.11130-3-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org v8: - Convert probe kzalloc usage to devm_ variant --- drivers/media/i2c/max9286.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index b84d2daa6561..0a43137b8112 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1155,7 +1155,7 @@ static int max9286_probe(struct i2c_client *client) unsigned int i; int ret; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -1232,7 +1232,6 @@ static int max9286_probe(struct i2c_client *client) max9286_configure_i2c(priv, false); err_free: max9286_cleanup_dt(priv); - kfree(priv); return ret; } @@ -1253,8 +1252,6 @@ static int max9286_remove(struct i2c_client *client) gpiod_set_value_cansleep(priv->gpiod_pwdn, 0); - kfree(priv); - return 0; } From patchwork Thu Apr 9 12:11:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481671 X-Patchwork-Delegate: kieran@bingham.xyz 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 BD4AA17D4 for ; Thu, 9 Apr 2020 12:12:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91E7920771 for ; Thu, 9 Apr 2020 12:12:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BHZWZ7iw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726502AbgDIMMK (ORCPT ); Thu, 9 Apr 2020 08:12:10 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48746 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMMK (ORCPT ); Thu, 9 Apr 2020 08:12:10 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 32794DBE; Thu, 9 Apr 2020 14:12:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434329; bh=eoU4wi2UcnR4EjSywD/5ytmeVzkX0RAn9+pPmDPwfls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHZWZ7iworvkt2pK3yMKWJuWt7SnjRRe1FCN1c7GWIqFJDmGdQajNDx7AGHd76wAD tx6j5kS1kP19TKHfpqpZ4qig6tcJn/QkxX5iKs5s+cx9oFO/W2eFLtGgMenctF8APc 4hKU9BCqHHT9P9SMd+akwjkpBGDg78L4VO28R+EY= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 03/13] squash! max9286: Fix cleanup path from GPIO powerdown Date: Thu, 9 Apr 2020 13:11:52 +0100 Message-Id: <20200409121202.11130-4-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org - Fix up cleanup path from GPIO PowerDown registration --- drivers/media/i2c/max9286.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 0a43137b8112..cc99740b34c5 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1171,8 +1171,10 @@ static int max9286_probe(struct i2c_client *client) priv->gpiod_pwdn = devm_gpiod_get_optional(&client->dev, "enable", GPIOD_OUT_HIGH); - if (IS_ERR(priv->gpiod_pwdn)) - return PTR_ERR(priv->gpiod_pwdn); + if (IS_ERR(priv->gpiod_pwdn)) { + ret = PTR_ERR(priv->gpiod_pwdn); + goto err_cleanup_dt; + } gpiod_set_consumer_name(priv->gpiod_pwdn, "max9286-pwdn"); gpiod_set_value_cansleep(priv->gpiod_pwdn, 1); @@ -1193,7 +1195,7 @@ static int max9286_probe(struct i2c_client *client) PTR_ERR(priv->regulator)); ret = PTR_ERR(priv->regulator); priv->regulator = NULL; - goto err_free; + goto err_cleanup_dt; } /* @@ -1230,7 +1232,7 @@ static int max9286_probe(struct i2c_client *client) regulator_put(priv->regulator); max9286_i2c_mux_close(priv); max9286_configure_i2c(priv, false); -err_free: +err_cleanup_dt: max9286_cleanup_dt(priv); return ret; @@ -1248,10 +1250,10 @@ static int max9286_remove(struct i2c_client *client) regulator_disable(priv->regulator); regulator_put(priv->regulator); - max9286_cleanup_dt(priv); - gpiod_set_value_cansleep(priv->gpiod_pwdn, 0); + max9286_cleanup_dt(priv); + return 0; } From patchwork Thu Apr 9 12:11:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481675 X-Patchwork-Delegate: kieran@bingham.xyz 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 1554B81 for ; Thu, 9 Apr 2020 12:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEB242078E for ; Thu, 9 Apr 2020 12:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JEJ82y2v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726538AbgDIMMM (ORCPT ); Thu, 9 Apr 2020 08:12:12 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48746 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMML (ORCPT ); Thu, 9 Apr 2020 08:12:11 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B094E12F4; Thu, 9 Apr 2020 14:12:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434330; bh=xUCZkRKcSbIO0Lks2uwsKQj3NHo/YccCIwEjdM2ogcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JEJ82y2vVV3RszxfDPwYI28q046/bQdZzUYRZO19BLHUfHs3+4aNIo8F7Dp13piH1 mY6bjtgZkfrkq3vX1854BMYNYDdP1QD+HuUIgFNhqQjJTCL236xAStXCWd6CnGQpli d+smJkRygzGgRMcsUbKwFWbt4pSfFNEsLW3dQP5s= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 04/13] squash! max9286: cleanup GPIO device registration fail path Date: Thu, 9 Apr 2020 13:11:53 +0100 Message-Id: <20200409121202.11130-5-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org - cleanup GPIO device registration fail path --- drivers/media/i2c/max9286.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index cc99740b34c5..d0749c537152 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1185,7 +1185,7 @@ static int max9286_probe(struct i2c_client *client) ret = max9286_gpio(priv); if (ret) - return ret; + goto err_powerdown; priv->regulator = regulator_get(&client->dev, "poc"); if (IS_ERR(priv->regulator)) { @@ -1194,8 +1194,7 @@ static int max9286_probe(struct i2c_client *client) "Unable to get PoC regulator (%ld)\n", PTR_ERR(priv->regulator)); ret = PTR_ERR(priv->regulator); - priv->regulator = NULL; - goto err_cleanup_dt; + goto err_powerdown; } /* @@ -1232,6 +1231,8 @@ static int max9286_probe(struct i2c_client *client) regulator_put(priv->regulator); max9286_i2c_mux_close(priv); max9286_configure_i2c(priv, false); +err_powerdown: + gpiod_set_value_cansleep(priv->gpiod_pwdn, 0); err_cleanup_dt: max9286_cleanup_dt(priv); From patchwork Thu Apr 9 12:11:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481677 X-Patchwork-Delegate: kieran@bingham.xyz 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 7D9D917D4 for ; Thu, 9 Apr 2020 12:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 539BA2078E for ; Thu, 9 Apr 2020 12:12:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Gg0arIRu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726559AbgDIMMM (ORCPT ); Thu, 9 Apr 2020 08:12:12 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgDIMMM (ORCPT ); Thu, 9 Apr 2020 08:12:12 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4067913CB; Thu, 9 Apr 2020 14:12:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434330; bh=rHbDeXJMztOUf1um+41rM5Ol+trow3LDpX1T8XQm69w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gg0arIRuqxaDITf1D7mlblhzOfuYbMhJcHYXp7d/1LU3v5i/0NsJ3gZokoo1f83+G 0YHGSp8jozTKsv5wqLVbursx8TmNOZGPNPaeAKMGwVBhTj9whlAmv+/lb/VN61WZ/2 wMsHE04kE/IkbHefw6XUGn0g28Ev+M52o8SeIF2k= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 05/13] squash! max9286: Convert to use devm_regulator_get() Date: Thu, 9 Apr 2020 13:11:54 +0100 Message-Id: <20200409121202.11130-6-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org - Convert to use devm_regulator_get() --- drivers/media/i2c/max9286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index d0749c537152..c374078c7001 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1187,7 +1187,7 @@ static int max9286_probe(struct i2c_client *client) if (ret) goto err_powerdown; - priv->regulator = regulator_get(&client->dev, "poc"); + priv->regulator = devm_regulator_get(&client->dev, "poc"); if (IS_ERR(priv->regulator)) { if (PTR_ERR(priv->regulator) != -EPROBE_DEFER) dev_err(&client->dev, From patchwork Thu Apr 9 12:11:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481679 X-Patchwork-Delegate: kieran@bingham.xyz 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 53C2C14DD for ; Thu, 9 Apr 2020 12:12:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 295D92078E for ; Thu, 9 Apr 2020 12:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QJOHR4mW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726571AbgDIMMN (ORCPT ); Thu, 9 Apr 2020 08:12:13 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48746 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMMN (ORCPT ); Thu, 9 Apr 2020 08:12:13 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C7E9672C; Thu, 9 Apr 2020 14:12:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434331; bh=b66VwlnmIFe5JaA5ITggGp9v0tMapqp6S3Azm7bn0kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJOHR4mWvu4/2vMoaLWI8VlsOxxGX9+2YmPKVGiyMNZXQZ2ZG6rBfmFxZy7NtTiJh S6Vemo6se8EsSw7O1JpHQTr8AfnBhuNbEr8AE0jIEGH6m4n+HlqoldOwIArFfqzV5J eAHAVHGOxXzOiIqTDF67ZnKp9dPrD6pAqtgV6als= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 06/13] squash! max9286: Fit max9286_parse_dt print on one line Date: Thu, 9 Apr 2020 13:11:55 +0100 Message-Id: <20200409121202.11130-7-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org - Fit max9286_parse_dt print on one line --- drivers/media/i2c/max9286.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index c374078c7001..4656a1027d81 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1061,8 +1061,7 @@ static int max9286_parse_dt(struct max9286_priv *priv) continue; if (!of_device_is_available(node)) { - dev_dbg(dev, "Skipping disabled I2C bus port %u\n", - id); + dev_dbg(dev, "Skipping disabled I2C bus port %u\n", id); continue; } From patchwork Thu Apr 9 12:11:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481681 X-Patchwork-Delegate: kieran@bingham.xyz 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 F00CD17D4 for ; Thu, 9 Apr 2020 12:12:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C58322078E for ; Thu, 9 Apr 2020 12:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="H/dAbRrl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbgDIMMO (ORCPT ); Thu, 9 Apr 2020 08:12:14 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgDIMMN (ORCPT ); Thu, 9 Apr 2020 08:12:13 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5706C144E; Thu, 9 Apr 2020 14:12:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434331; bh=7Jtclyfb9VS6qcpjV466UJ/eXAdcguXpmZstAGn2co0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/dAbRrlLQHTRJkHVEVS4icUcPjNqXDkRh5qoyh1QswoQUpGP7UOMKbsQgbzzbjeG dssrjJ4eNd7JmwReLy3tX6icr6xXsUAon4lJkTyH1/cxnxPqEWmilSItd+98NEalus vrXIDfxqaYnZ/N7jh0FXiBBDLij1nNe9WED0kJ0c= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 07/13] squash! max9286: Move multi-device workarounds out of upstream Date: Thu, 9 Apr 2020 13:11:56 +0100 Message-Id: <20200409121202.11130-8-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org - Move multi-device workarounds out of upstream driver --- drivers/media/i2c/max9286.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 4656a1027d81..cdebee8a0a22 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -911,12 +911,6 @@ static int max9286_setup(struct max9286_priv *priv) return 0; } -static const struct of_device_id max9286_dt_ids[] = { - { .compatible = "maxim,max9286" }, - {}, -}; -MODULE_DEVICE_TABLE(of, max9286_dt_ids); - static void max9286_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -976,10 +970,6 @@ static int max9286_init(struct device *dev) struct i2c_client *client; int ret; - /* Skip non-max9286 devices. */ - if (!dev->of_node || !of_match_node(max9286_dt_ids, dev->of_node)) - return 0; - client = to_i2c_client(dev); priv = i2c_get_clientdata(client); @@ -1257,6 +1247,12 @@ static int max9286_remove(struct i2c_client *client) return 0; } +static const struct of_device_id max9286_dt_ids[] = { + { .compatible = "maxim,max9286" }, + {}, +}; +MODULE_DEVICE_TABLE(of, max9286_dt_ids); + static const struct i2c_device_id max9286_id[] = { { "max9286", 0 }, { } From patchwork Thu Apr 9 12:11:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481683 X-Patchwork-Delegate: kieran@bingham.xyz 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 BA97381 for ; Thu, 9 Apr 2020 12:12:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 904932078E for ; Thu, 9 Apr 2020 12:12:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P9jwI+it" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbgDIMMO (ORCPT ); Thu, 9 Apr 2020 08:12:14 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48746 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMMO (ORCPT ); Thu, 9 Apr 2020 08:12:14 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D05A3197C; Thu, 9 Apr 2020 14:12:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434332; bh=/i8VSC5ksIEGuKDnU07wtDJLKCWwHQrqZLvlXYuUgtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P9jwI+itR1UQASimt7fZduQph3tuCYzsd03+OKYJb3NwZB7PlBxibeZDHqaxJj3+0 ElrrFOu+yMzcfY7scMegzdb++naxyk1Nl5Qt45uHjZ920v303nkytXnEHdKJuLDDcj milV4f7b3dO+ql5c3iFGziIWiaBQj38oY3RckqX8= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 08/13] squash! max9286: Remove I2C mod-table Date: Thu, 9 Apr 2020 13:11:57 +0100 Message-Id: <20200409121202.11130-9-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org 'Technically' this table is still required for module autoloading, until some solution such as [0] is merged: [0] [PATCH RFC] modpost: Support I2C Aliases from OF tables https://lore.kernel.org/lkml/20190710193918.31135-1-kieran.bingham+renesas@ideasonboard.com/ However in practice, I think the only restriction that gets lost is device instantiation from sysfs, which wouldn't really work for this driver anyway, because it requires a description of connected endpoints. So - it should be quite safe to drop it. Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index cdebee8a0a22..911323d6d3c4 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1253,12 +1253,6 @@ static const struct of_device_id max9286_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, max9286_dt_ids); -static const struct i2c_device_id max9286_id[] = { - { "max9286", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, max9286_id); - static struct i2c_driver max9286_i2c_driver = { .driver = { .name = "max9286", @@ -1266,7 +1260,6 @@ static struct i2c_driver max9286_i2c_driver = { }, .probe_new = max9286_probe, .remove = max9286_remove, - .id_table = max9286_id, }; module_i2c_driver(max9286_i2c_driver); From patchwork Thu Apr 9 12:11:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481685 X-Patchwork-Delegate: kieran@bingham.xyz 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 4D4B614DD for ; Thu, 9 Apr 2020 12:12:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 229E92078E for ; Thu, 9 Apr 2020 12:12:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HIoPxHit" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725970AbgDIMMP (ORCPT ); Thu, 9 Apr 2020 08:12:15 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgDIMMP (ORCPT ); Thu, 9 Apr 2020 08:12:15 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57E32198C; Thu, 9 Apr 2020 14:12:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434332; bh=JbIOqp55h9Iyjdgg6lrfMYhU0LSQfUFZYn8XYjGi5Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HIoPxHitps3y7/iBR6yf58NxPdguzXwUbnMpVm6mIkp26VCPw2tFyILHX/suZuim9 jJXoMcv53+wVy3uXPKwu9316ZMbkMgwMn2j9nLxKQ+s2eMMpgfgGi6sZ205j6GUySI 4HGl3ahVvAHCN2XFVYPh/Ke4sPrPCsaiEB5ftrac= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 09/13] sqaush! max9286: Lock format changes Date: Thu, 9 Apr 2020 13:11:58 +0100 Message-Id: <20200409121202.11130-10-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Provide a mutex to protect against format changes on the pads. The mutex can also be used to protect against control changes, or other userspace facing interactions as necessary Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 911323d6d3c4..17830c362a50 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -157,6 +158,9 @@ struct max9286_priv { struct v4l2_mbus_framefmt fmt[MAX9286_N_SINKS]; + /* Protects controls and fmt structures */ + struct mutex mutex; + unsigned int nsources; unsigned int source_mask; unsigned int route_mask; @@ -680,7 +684,9 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, if (!cfg_fmt) return -EINVAL; + mutex_lock(&priv->mutex); *cfg_fmt = format->format; + mutex_unlock(&priv->mutex); return 0; } @@ -699,7 +705,9 @@ static int max9286_get_fmt(struct v4l2_subdev *sd, if (!cfg_fmt) return -EINVAL; + mutex_lock(&priv->mutex); format->format = *cfg_fmt; + mutex_unlock(&priv->mutex); return 0; } @@ -1148,6 +1156,8 @@ static int max9286_probe(struct i2c_client *client) if (!priv) return -ENOMEM; + mutex_init(&priv->mutex); + priv->client = client; i2c_set_clientdata(client, priv); From patchwork Thu Apr 9 12:11:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481687 X-Patchwork-Delegate: kieran@bingham.xyz 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 282DF81 for ; Thu, 9 Apr 2020 12:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 072E92078E for ; Thu, 9 Apr 2020 12:12:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hZZlCc/a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726082AbgDIMMQ (ORCPT ); Thu, 9 Apr 2020 08:12:16 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48746 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMMQ (ORCPT ); Thu, 9 Apr 2020 08:12:16 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D6AC1DA9; Thu, 9 Apr 2020 14:12:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434333; bh=As1xFdsW6xjPMs+VepKhf68/IQBQZt1bXv7lxBl8VvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZZlCc/a+DU6H/gxn6LbJl1m/0zGP66CSH625RilPQZUJSmDhz5CJD648spMr98fq P1LooPHDdS1THiETtiIAhB/PGv3QB1g7r4NpX5Kmpw+cpxlKKeAE8y3fCoTT4NEedy 465CMexHVtz3Smi5BSCWoMpclFEgSN8NgWIQdzBo= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 10/13] squash! max9286: Implement Pixelrate control Date: Thu, 9 Apr 2020 13:11:59 +0100 Message-Id: <20200409121202.11130-11-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Determine the (CSI2) pixel rate control by providing a control to read, and checking the rate from the upstream camera sensors, and their appropriate formats. Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 17830c362a50..008a93910300 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -155,6 +155,7 @@ struct max9286_priv { bool mux_open; struct v4l2_ctrl_handler ctrls; + struct v4l2_ctrl *pixelrate; struct v4l2_mbus_framefmt fmt[MAX9286_N_SINKS]; @@ -631,6 +632,16 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable) return 0; } +static int max9286_set_pixelrate(struct max9286_priv *priv, s64 rate) +{ + if (!priv->pixelrate) + return -EINVAL; + + dev_err(&priv->client->dev, "Setting pixel rate to %lld\n", rate); + + return v4l2_ctrl_s_ctrl_int64(priv->pixelrate, rate); +} + static int max9286_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) @@ -664,6 +675,7 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, { struct max9286_priv *priv = sd_to_max9286(sd); struct v4l2_mbus_framefmt *cfg_fmt; + s64 pixelrate; if (format->pad >= MAX9286_SRC_PAD) return -EINVAL; @@ -688,6 +700,12 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, *cfg_fmt = format->format; mutex_unlock(&priv->mutex); + /* Update pixel rate for the CSI2 receiver */ + pixelrate = cfg_fmt->width * cfg_fmt->height + * priv->nsources * 30 /*FPS*/; + + max9286_set_pixelrate(priv, pixelrate); + return 0; } @@ -756,6 +774,20 @@ static const struct v4l2_subdev_internal_ops max9286_subdev_internal_ops = { .open = max9286_open, }; +static int max9286_s_ctrl(struct v4l2_ctrl *ctrl) +{ + switch (ctrl->id) { + case V4L2_CID_PIXEL_RATE: + return 0; + default: + return -EINVAL; + } +} + +static const struct v4l2_ctrl_ops max9286_ctrl_ops = { + .s_ctrl = max9286_s_ctrl, +}; + static int max9286_v4l2_register(struct max9286_priv *priv) { struct device *dev = &priv->client->dev; @@ -777,12 +809,12 @@ static int max9286_v4l2_register(struct max9286_priv *priv) priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; v4l2_ctrl_handler_init(&priv->ctrls, 1); - /* - * FIXME: Compute the real pixel rate. The 50 MP/s value comes from the - * hardcoded frequency in the BSP CSI-2 receiver driver. - */ - v4l2_ctrl_new_std(&priv->ctrls, NULL, V4L2_CID_PIXEL_RATE, - 50000000, 50000000, 1, 50000000); + + priv->pixelrate = v4l2_ctrl_new_std(&priv->ctrls, + &max9286_ctrl_ops, + V4L2_CID_PIXEL_RATE, + 1, INT_MAX, 1, 50000000); + priv->sd.ctrl_handler = &priv->ctrls; ret = priv->ctrls.error; if (ret) From patchwork Thu Apr 9 12:12:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481689 X-Patchwork-Delegate: kieran@bingham.xyz 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 C112817D4 for ; Thu, 9 Apr 2020 12:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0D012078E for ; Thu, 9 Apr 2020 12:12:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l355kIDb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726502AbgDIMMQ (ORCPT ); Thu, 9 Apr 2020 08:12:16 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgDIMMQ (ORCPT ); Thu, 9 Apr 2020 08:12:16 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A808DBE; Thu, 9 Apr 2020 14:12:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434333; bh=gP4HZ6h6HVuGUDhI7Agd4PSBXApU2APvsJMz2lusseU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l355kIDbrOXkFDIeqQDbPf4/7kS4Cq63iTBKAOrwqjwSzr9bi5ABiV9wVnLIf3LY+ YNzgpyXrjUR67eOErsyNihvvQUD2apyiDLn/062vsAxDvh5BcBE7pvO9jCdq/+QF0j kDiuNgt6vyUvtSB8CI+Xnp0Vn4e+Svf761SBMRmc= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 11/13] squash! max9286: Disable overlap window Date: Thu, 9 Apr 2020 13:12:00 +0100 Message-Id: <20200409121202.11130-12-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Provide a function to control setting of the overlap window, but disable it by default. The function will allow the value to be easily updated in the future, either statically in the code, or via an external control mechanism. Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 008a93910300..61178ae363d6 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -118,6 +118,9 @@ #define MAX9286_REV_FLEN(n) ((n) - 20) /* Register 0x49 */ #define MAX9286_VIDEO_DETECT_MASK 0x0f +/* Register 0x64 */ +#define MAX9286_ENFSINLAST BIT(5) +#define MAX9286_OVLP_WINDOWH_MASK GENMASK(4, 0) /* Register 0x69 */ #define MAX9286_LFLTBMONMASKED BIT(7) #define MAX9286_LOCKMONMASKED BIT(6) @@ -632,6 +635,34 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable) return 0; } +/* + * The overlap window is a 13 bit value with the low byte in register 0x63 and + * the high byte(5bits) stored in the least significant bits of register 0x64. + */ +static int max9286_set_overlap_window(struct max9286_priv *priv, u16 window) +{ + int ret; + u8 val; + + ret = max9286_read(priv, 0x64); + if (ret < 0) + return -EIO; + + max9286_write(priv, 0x63, window & 0xff); + + /* + * Process the high byte, while preserve existing bits set in 0x64. + * TODO: Convert this all to regmap so we can utilise regmap_update_bits + */ + window >>= 8; + val = ret & ~MAX9286_OVLP_WINDOWH_MASK; + val |= window & MAX9286_OVLP_WINDOWH_MASK; + + max9286_write(priv, 0x64, val); + + return 0; +} + static int max9286_set_pixelrate(struct max9286_priv *priv, s64 rate) { if (!priv->pixelrate) @@ -942,6 +973,17 @@ static int max9286_setup(struct max9286_priv *priv) max9286_write(priv, 0x0c, MAX9286_HVEN | MAX9286_INVVS | MAX9286_HVSRC_D14); + /* + * The overlap window seems to provide additional validation by tracking + * the delay between vsync and frame sync, generating an error if the + * delay is bigger than the programmed window, though it's not yet clear + * what value should be set. + * + * As it's an optional value and can be disabled, we do so by setting + * a 0 overlap value. + */ + max9286_set_overlap_window(priv, 0); + /* * Wait for 2ms to allow the link to resynchronize after the * configuration change. From patchwork Thu Apr 9 12:12:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481691 X-Patchwork-Delegate: kieran@bingham.xyz 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 707EB14DD for ; Thu, 9 Apr 2020 12:12:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 449622078E for ; Thu, 9 Apr 2020 12:12:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LjwpGwAg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbgDIMMR (ORCPT ); Thu, 9 Apr 2020 08:12:17 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48746 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgDIMMR (ORCPT ); Thu, 9 Apr 2020 08:12:17 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D6D1E1A40; Thu, 9 Apr 2020 14:12:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434334; bh=koKgkFI4J6/xNpng+dPXWyaaFOTxX5vZys0IqcN1p88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LjwpGwAgc+5mPxNqm06HtNrQCunuW+aIvgsiMw/Dr5ekkp3Zy+naedgQAW459YNRh 6qw1KvyQ2K43DqZT3UqoBIButIkbfFkPOdhmY9z+JV/FrWGt5UpVgImRpgEMsdONeq zh1/zGPBZ1gKPwgoQ8fKcNBujvMiWKjz7V3E+Mec= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 12/13] sqaush! max9286: Describe pad index usage Date: Thu, 9 Apr 2020 13:12:01 +0100 Message-Id: <20200409121202.11130-13-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Sakari commented that the sink/source pad indexes are not the same as the OF port numbers. We define them such that they match, so that they can be used interchangably - but of course they are not the 'same thing'. Document this in a comment at the definition of the pad sizings. Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 61178ae363d6..6f114756a1e2 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -128,6 +128,10 @@ #define MAX9286_AUTOMASKEN BIT(4) #define MAX9286_MASKLINK(n) ((n) << 0) +/* + * The sink and source pads are created to match the OF graph port numbers so + * that their indexes can be used interchangeably. + */ #define MAX9286_NUM_GMSL 4 #define MAX9286_N_SINKS 4 #define MAX9286_N_PADS 5 From patchwork Thu Apr 9 12:12:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481693 X-Patchwork-Delegate: kieran@bingham.xyz 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 31B6C81 for ; Thu, 9 Apr 2020 12:12:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0770E2078E for ; Thu, 9 Apr 2020 12:12:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DuQxfqE1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725971AbgDIMMS (ORCPT ); Thu, 9 Apr 2020 08:12:18 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgDIMMS (ORCPT ); Thu, 9 Apr 2020 08:12:18 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E407B76; Thu, 9 Apr 2020 14:12:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434334; bh=pdHCUgdVl8LkYL5fW7b0d6FhnYAruiXmUZz019Mzh/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DuQxfqE1IhHFU6dNQZkPNeTN+ID9fN4/CgwcRm9whbMjqbpDj847w/qy/De6qKjnb H3iP6tfDm9/2rnRIJu3HxA9bCSdwA0EYX4jKRqfB8HuG52DmakpbKRtd+pxpbauQUQ YrjfOb+AbPejcv5cqoKdKbRpUcPXgTk3b6ZZpz34= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 13/13] sqaush! max9286: Remove poc_enabled workaround Date: Thu, 9 Apr 2020 13:12:02 +0100 Message-Id: <20200409121202.11130-14-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org This boolean is a flag used to handle the regulator when our multi-max9286 workaround is in place. It shouldn't be in the upstream driver, and is moved out. Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 6f114756a1e2..022f4cfaf294 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -152,7 +152,6 @@ struct max9286_priv { struct v4l2_subdev sd; struct media_pad pads[MAX9286_N_PADS]; struct regulator *regulator; - bool poc_enabled; struct gpio_chip gpio; u8 gpio_state; @@ -1066,8 +1065,6 @@ static int max9286_init(struct device *dev) return ret; } - priv->poc_enabled = true; - ret = max9286_setup(priv); if (ret) { dev_err(dev, "Unable to setup max9286\n"); @@ -1099,7 +1096,6 @@ static int max9286_init(struct device *dev) max9286_v4l2_unregister(priv); err_regulator: regulator_disable(priv->regulator); - priv->poc_enabled = false; return ret; } @@ -1324,8 +1320,7 @@ static int max9286_remove(struct i2c_client *client) max9286_v4l2_unregister(priv); - if (priv->poc_enabled) - regulator_disable(priv->regulator); + regulator_disable(priv->regulator); regulator_put(priv->regulator); gpiod_set_value_cansleep(priv->gpiod_pwdn, 0);