[{"id":1770702,"web_url":"http://patchwork.ozlabs.org/comment/1770702/","msgid":"<20170919073643.szwwdmff6cp2v2fn@valkosipuli.retiisi.org.uk>","list_archive_url":null,"date":"2017-09-19T07:36:43","subject":"Re: [PATCH v5 3/3] media: ov7670: Add the s_power operation","submitter":{"id":1593,"url":"http://patchwork.ozlabs.org/api/people/1593/","name":"Sakari Ailus","email":"sakari.ailus@iki.fi"},"content":"Hi Wenyou,\n\nOn Tue, Sep 19, 2017 at 08:45:09AM +0800, Wenyou Yang wrote:\n> Add the s_power operation which is responsible for manipulating the\n> power dowm mode through the PWDN pin and the reset operation through\n> the RESET pin.\n\nThis is still broken: accessing controls through the sub-device node won't\nwork when the device is powered off. The options are what I suggested the\nprevious time: keep it powered at all times, fix it or convert to runtime\nPM.\n\n> \n> Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>\n> ---\n> \n> Changes in v5: None\n> Changes in v4: None\n> Changes in v3: None\n> Changes in v2:\n>  - Add the patch to support the get_fmt ops.\n>  - Remove the redundant invoking ov7670_init_gpio().\n> \n>  drivers/media/i2c/ov7670.c | 32 +++++++++++++++++++++++++++-----\n>  1 file changed, 27 insertions(+), 5 deletions(-)\n> \n> diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c\n> index 73ceec63a8ca..8e86479d8a24 100644\n> --- a/drivers/media/i2c/ov7670.c\n> +++ b/drivers/media/i2c/ov7670.c\n> @@ -1544,6 +1544,22 @@ static int ov7670_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regis\n>  }\n>  #endif\n>  \n> +static int ov7670_s_power(struct v4l2_subdev *sd, int on)\n> +{\n> +\tstruct ov7670_info *info = to_state(sd);\n> +\n> +\tif (info->pwdn_gpio)\n> +\t\tgpiod_direction_output(info->pwdn_gpio, !on);\n> +\tif (on && info->resetb_gpio) {\n> +\t\tgpiod_set_value(info->resetb_gpio, 1);\n> +\t\tusleep_range(500, 1000);\n> +\t\tgpiod_set_value(info->resetb_gpio, 0);\n> +\t\tusleep_range(3000, 5000);\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n>  static void ov7670_get_default_format(struct v4l2_subdev *sd,\n>  \t\t\t\t      struct v4l2_mbus_framefmt *format)\n>  {\n> @@ -1577,6 +1593,7 @@ static const struct v4l2_subdev_core_ops ov7670_core_ops = {\n>  \t.g_register = ov7670_g_register,\n>  \t.s_register = ov7670_s_register,\n>  #endif\n> +\t.s_power = ov7670_s_power,\n>  };\n>  \n>  static const struct v4l2_subdev_video_ops ov7670_video_ops = {\n> @@ -1694,23 +1711,25 @@ static int ov7670_probe(struct i2c_client *client,\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> -\tret = ov7670_init_gpio(client, info);\n> -\tif (ret)\n> -\t\tgoto clk_disable;\n> -\n>  \tinfo->clock_speed = clk_get_rate(info->clk) / 1000000;\n>  \tif (info->clock_speed < 10 || info->clock_speed > 48) {\n>  \t\tret = -EINVAL;\n>  \t\tgoto clk_disable;\n>  \t}\n>  \n> +\tret = ov7670_init_gpio(client, info);\n> +\tif (ret)\n> +\t\tgoto clk_disable;\n> +\n> +\tov7670_s_power(sd, 1);\n> +\n>  \t/* Make sure it's an ov7670 */\n>  \tret = ov7670_detect(sd);\n>  \tif (ret) {\n>  \t\tv4l_dbg(1, debug, client,\n>  \t\t\t\"chip found @ 0x%x (%s) is not an ov7670 chip.\\n\",\n>  \t\t\tclient->addr << 1, client->adapter->name);\n> -\t\tgoto clk_disable;\n> +\t\tgoto power_off;\n>  \t}\n>  \tv4l_info(client, \"chip found @ 0x%02x (%s)\\n\",\n>  \t\t\tclient->addr << 1, client->adapter->name);\n> @@ -1789,6 +1808,8 @@ static int ov7670_probe(struct i2c_client *client,\n>  #endif\n>  hdl_free:\n>  \tv4l2_ctrl_handler_free(&info->hdl);\n> +power_off:\n> +\tov7670_s_power(sd, 0);\n>  clk_disable:\n>  \tclk_disable_unprepare(info->clk);\n>  \treturn ret;\n> @@ -1806,6 +1827,7 @@ static int ov7670_remove(struct i2c_client *client)\n>  #if defined(CONFIG_MEDIA_CONTROLLER)\n>  \tmedia_entity_cleanup(&info->sd.entity);\n>  #endif\n> +\tov7670_s_power(sd, 0);\n>  \treturn 0;\n>  }\n>  \n> -- \n> 2.13.0\n>","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"bCVb1TWs\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxF873prsz9sBZ\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 17:37:23 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1duD5q-0001hI-DP; Tue, 19 Sep 2017 07:37:18 +0000","from hillosipuli.retiisi.org.uk ([2001:1bc8:1a6:d3d5::81:2])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1duD5k-0001ao-1E for linux-arm-kernel@lists.infradead.org;\n\tTue, 19 Sep 2017 07:37:15 +0000","from valkosipuli.localdomain (valkosipuli.retiisi.org.uk\n\t[IPv6:2001:1bc8:1a6:d3d5::80:2])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id DC40160117;\n\tTue, 19 Sep 2017 10:36:43 +0300 (EEST)","from sakke by valkosipuli.localdomain with local (Exim 4.89)\n\t(envelope-from <sakke@valkosipuli.retiisi.org.uk>)\n\tid 1duD5H-00057M-ED; Tue, 19 Sep 2017 10:36:43 +0300"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=VSAVyAgMzS9DpmF4P43AfHftTV6hcW5vPCPp9VPOkTY=;\n\tb=bCVb1TWs0+XEb8\n\tFch3ffH0pQRr+djBh6hyWBtxounggdJ1kBiO7QPfIHxngUb4j0xlhSdi8oVU1kjudYxNwqh6plVkY\n\tEuX5zAPv1JD9sq4wMSFlTs+fqL8/IioiP+FY3i4ZnD49xU9Q9g4LqDlG8cj+Dhy8Ksr+Jqtt3uU5M\n\toVsVGoqaoJaJe+ID/6UwHNUyYczePZewxlpes1ycH/cyUEI4uCK1l49nvRNdpPdr8iAhUK+jlJZXI\n\tSpi9xAQzxK5TE4X3BsAj61vm/8WJidm3y9F97Qg3HAGmTkRY+yVyVTI96edYe26+ch1UQE4JpZzxz\n\tDaX6yS+ohcAGAg2YrGQA==;","Date":"Tue, 19 Sep 2017 10:36:43 +0300","From":"Sakari Ailus <sakari.ailus@iki.fi>","To":"Wenyou Yang <wenyou.yang@microchip.com>","Subject":"Re: [PATCH v5 3/3] media: ov7670: Add the s_power operation","Message-ID":"<20170919073643.szwwdmff6cp2v2fn@valkosipuli.retiisi.org.uk>","References":"<20170919004509.12722-1-wenyou.yang@microchip.com>\n\t<20170919004509.12722-4-wenyou.yang@microchip.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20170919004509.12722-4-wenyou.yang@microchip.com>","User-Agent":"NeoMutt/20170113 (1.7.2)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170919_003712_638117_51910BF3 ","X-CRM114-Status":"GOOD (  19.75  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level\n\tmail domains are different\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jonathan Corbet <corbet@lwn.net>, linux-kernel@vger.kernel.org,\n\tMauro Carvalho Chehab <mchehab@s-opensource.com>,\n\tlinux-arm-kernel@lists.infradead.org,\n\tLinux Media Mailing List <linux-media@vger.kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}}]