From patchwork Sun May 6 14:19:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10382833 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 7BF5560236 for ; Sun, 6 May 2018 14:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 680862892B for ; Sun, 6 May 2018 14:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C8CF28970; Sun, 6 May 2018 14:20:31 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 16F7728A2D for ; Sun, 6 May 2018 14:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751819AbeEFOUT (ORCPT ); Sun, 6 May 2018 10:20:19 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35929 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818AbeEFOUR (ORCPT ); Sun, 6 May 2018 10:20:17 -0400 Received: by mail-pf0-f196.google.com with SMTP id w129so15400716pfd.3; Sun, 06 May 2018 07:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aPUd2Y+cSVjEzhHSynnLkHZKGcGBthfdP4vfBsC9svc=; b=hn2N6AFFpIk789klO6GahXE4rXPfnriaEY9kPm+dE+rddzmCxfVa12JNtQvHxgA2ok Dq+xkC7+o1deHuKniP4DhgYqFrJSjxlvjS+qAv/6RHFa7dtHsRjn0g1ssfv8uDHXklPO X7XimlxlgZgZz9EgGww8vQJCN3yHI6UOMYVHBtF1XgjX3t6/kTnvFTHo4EARE0NC2exA WQAK0EpwgFHKuyqe1lSZhWkmPUbiczxZqVBL5+eUM4UdBQ8yJPV3MWABoyugMYRllVUi RZASQVctK/YHPKT+FtI/IgUzR0hqftHXZqoQWjzB2JYAL4ON7aVT7eHL6lb3kl4/MqMu nGUw== 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=aPUd2Y+cSVjEzhHSynnLkHZKGcGBthfdP4vfBsC9svc=; b=t2ZvXnCExbZMG7Nl9jCO9Fd6G4LGsXolXuPRdWaQ5WzM+n1Ircbl3FS7ieyG6WFSJU rFAkINNL8rksSMk03ZYJ5FI8sAgqfACAFwRd6SovyGpbcVplbJpQNyetZxVJCBWmB4Cl ozTkh2uOBlLxqp+2KfJUj9yI8Z8e1LsppDnKaztqQOttz6cEq/+AlIA2wopcyQW7yJ8g Ij0g741bJzc9zUCO3R9ytKiM5TqAMNLQjmszEy2Ux/sCyZgEyAiNjAj1X+yL7R5ctHPu 7UfySTsU2ExXIZ9/nwIgDSDa3Q1psvnId4uglUTe+yvDfO4pXis6KU6Z5Q4IWyZY69G2 78rg== X-Gm-Message-State: ALQs6tAY0yNtAVWEy0SBEcKiyrgK6du6naCN5SgffZ264SeuQsIIg8QD +FFJxMI4LV2Dh8ZG9v2X6ydcCA== X-Google-Smtp-Source: AB8JxZr6zZK5gGuhPAF8krXf0GX4Qc5iudXofWj0jF4ZrcLB0mflT/7/3WprzCY25WawXWzPl035sw== X-Received: by 10.98.12.21 with SMTP id u21mr32842256pfi.218.1525616416799; Sun, 06 May 2018 07:20:16 -0700 (PDT) Received: from localhost.localdomain ([240f:4:c2bc:1:141a:15e1:5268:11ce]) by smtp.gmail.com with ESMTPSA id s88sm58766771pfe.43.2018.05.06.07.20.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 May 2018 07:20:16 -0700 (PDT) From: Akinobu Mita To: linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: Akinobu Mita , Jacopo Mondi , Laurent Pinchart , Hans Verkuil , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH v5 11/14] media: ov772x: use v4l2_ctrl to get current control value Date: Sun, 6 May 2018 23:19:26 +0900 Message-Id: <1525616369-8843-12-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525616369-8843-1-git-send-email-akinobu.mita@gmail.com> References: <1525616369-8843-1-git-send-email-akinobu.mita@gmail.com> 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 The ov772x driver provides three V4L2 controls and the current value of each control is saved as a variable in the private data structure. We don't need to keep track of the current value by ourself, if we use v4l2_ctrl returned from v4l2_ctrl_new_std() instead. This is a preparatory change to avoid accessing registers under power saving mode. This simplifies s_ctrl() by making it just return without saving the current control value in private area when it is called under power saving mode. Cc: Jacopo Mondi Cc: Laurent Pinchart Cc: Hans Verkuil Cc: Sakari Ailus Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- * v5 - No changes drivers/media/i2c/ov772x.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c index 92ad13f..9292a18 100644 --- a/drivers/media/i2c/ov772x.c +++ b/drivers/media/i2c/ov772x.c @@ -419,10 +419,10 @@ struct ov772x_priv { struct gpio_desc *rstb_gpio; const struct ov772x_color_format *cfmt; const struct ov772x_win_size *win; - unsigned short flag_vflip:1; - unsigned short flag_hflip:1; + struct v4l2_ctrl *vflip_ctrl; + struct v4l2_ctrl *hflip_ctrl; /* band_filter = COM8[5] ? 256 - BDBASE : 0 */ - unsigned short band_filter; + struct v4l2_ctrl *band_filter_ctrl; unsigned int fps; /* lock to protect power_count */ struct mutex lock; @@ -768,13 +768,11 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_VFLIP: val = ctrl->val ? VFLIP_IMG : 0x00; - priv->flag_vflip = ctrl->val; if (priv->info && (priv->info->flags & OV772X_FLAG_VFLIP)) val ^= VFLIP_IMG; return ov772x_mask_set(client, COM3, VFLIP_IMG, val); case V4L2_CID_HFLIP: val = ctrl->val ? HFLIP_IMG : 0x00; - priv->flag_hflip = ctrl->val; if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP)) val ^= HFLIP_IMG; return ov772x_mask_set(client, COM3, HFLIP_IMG, val); @@ -794,8 +792,7 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) ret = ov772x_mask_set(client, BDBASE, 0xff, val); } - if (!ret) - priv->band_filter = ctrl->val; + return ret; } @@ -1075,9 +1072,9 @@ static int ov772x_set_params(struct ov772x_priv *priv, val |= VFLIP_IMG; if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP)) val |= HFLIP_IMG; - if (priv->flag_vflip) + if (priv->vflip_ctrl->val) val ^= VFLIP_IMG; - if (priv->flag_hflip) + if (priv->hflip_ctrl->val) val ^= HFLIP_IMG; ret = ov772x_mask_set(client, @@ -1096,11 +1093,13 @@ static int ov772x_set_params(struct ov772x_priv *priv, goto ov772x_set_fmt_error; /* Set COM8. */ - if (priv->band_filter) { + if (priv->band_filter_ctrl->val) { + unsigned short band_filter = priv->band_filter_ctrl->val; + ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, BNDF_ON_OFF); if (!ret) ret = ov772x_mask_set(client, BDBASE, - 0xff, 256 - priv->band_filter); + 0xff, 256 - band_filter); if (ret < 0) goto ov772x_set_fmt_error; } @@ -1341,12 +1340,13 @@ static int ov772x_probe(struct i2c_client *client, v4l2_i2c_subdev_init(&priv->subdev, client, &ov772x_subdev_ops); v4l2_ctrl_handler_init(&priv->hdl, 3); - v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, - V4L2_CID_VFLIP, 0, 1, 1, 0); - v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, - V4L2_CID_HFLIP, 0, 1, 1, 0); - v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, - V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0); + priv->vflip_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, + V4L2_CID_VFLIP, 0, 1, 1, 0); + priv->hflip_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, + V4L2_CID_HFLIP, 0, 1, 1, 0); + priv->band_filter_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, + V4L2_CID_BAND_STOP_FILTER, + 0, 256, 1, 0); priv->subdev.ctrl_handler = &priv->hdl; if (priv->hdl.error) { ret = priv->hdl.error;