From patchwork Thu Aug 3 13:50:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9879213 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 45C3760360 for ; Thu, 3 Aug 2017 13:50:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BF7E288BD for ; Thu, 3 Aug 2017 13:50:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A85B2890C; Thu, 3 Aug 2017 13:50: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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 E1F13288BD for ; Thu, 3 Aug 2017 13:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbdHCNu3 (ORCPT ); Thu, 3 Aug 2017 09:50:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:40350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbdHCNu2 (ORCPT ); Thu, 3 Aug 2017 09:50:28 -0400 Received: from CookieMonster.cookiemonster.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9758122BF3; Thu, 3 Aug 2017 13:50:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9758122BF3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=kbingham@kernel.org From: Kieran Bingham To: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, niklas.soderlund@ragnatech.se Cc: sakari.ailus@iki.fi, kieran.bingham@ideasonboard.com, Kieran Bingham Subject: [PATCH] media: i2c: adv748x: Store the pixel rate ctrl on CSI objects Date: Thu, 3 Aug 2017 14:50:23 +0100 Message-Id: <1501768223-23654-1-git-send-email-kbingham@kernel.org> X-Mailer: git-send-email 2.7.4 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: Kieran Bingham The current implementation has to search the list of controls for the pixel rate control, each time it is set. This can be optimised easily by storing the ctrl pointer in the CSI/TX object, and referencing that directly. While at it, fix up a missing blank line also highlighted in review comments. Signed-off-by: Kieran Bingham Tested-by: Niklas Söderlund Acked-by: Sakari Ailus --- Small enhancement and fixup as suggested by Sakari, after driver acceptance. Niklas, with my current 8 Camera set up - I can't fully test this change. Could you give it a spin if you get chance please? drivers/media/i2c/adv748x/adv748x-afe.c | 1 + drivers/media/i2c/adv748x/adv748x-csi2.c | 15 +++++++-------- drivers/media/i2c/adv748x/adv748x.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c index b33ccfc08708..134d981d69d3 100644 --- a/drivers/media/i2c/adv748x/adv748x-afe.c +++ b/drivers/media/i2c/adv748x/adv748x-afe.c @@ -262,6 +262,7 @@ static int adv748x_afe_g_input_status(struct v4l2_subdev *sd, u32 *status) ret = adv748x_afe_status(afe, status, NULL); mutex_unlock(&state->mutex); + return ret; } diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index b4fee7f52d6a..609d960c0749 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -223,13 +223,12 @@ static const struct v4l2_subdev_ops adv748x_csi2_ops = { int adv748x_csi2_set_pixelrate(struct v4l2_subdev *sd, s64 rate) { - struct v4l2_ctrl *ctrl; + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); - ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE); - if (!ctrl) + if (!tx->pixel_rate) return -EINVAL; - return v4l2_ctrl_s_ctrl_int64(ctrl, rate); + return v4l2_ctrl_s_ctrl_int64(tx->pixel_rate, rate); } static int adv748x_csi2_s_ctrl(struct v4l2_ctrl *ctrl) @@ -248,12 +247,12 @@ static const struct v4l2_ctrl_ops adv748x_csi2_ctrl_ops = { static int adv748x_csi2_init_controls(struct adv748x_csi2 *tx) { - struct v4l2_ctrl *ctrl; - v4l2_ctrl_handler_init(&tx->ctrl_hdl, 1); - ctrl = v4l2_ctrl_new_std(&tx->ctrl_hdl, &adv748x_csi2_ctrl_ops, - V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); + tx->pixel_rate = v4l2_ctrl_new_std(&tx->ctrl_hdl, + &adv748x_csi2_ctrl_ops, + V4L2_CID_PIXEL_RATE, 1, INT_MAX, + 1, 1); tx->sd.ctrl_handler = &tx->ctrl_hdl; if (tx->ctrl_hdl.error) { diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h index cc4151b5b31e..6789e2f3bc8c 100644 --- a/drivers/media/i2c/adv748x/adv748x.h +++ b/drivers/media/i2c/adv748x/adv748x.h @@ -97,6 +97,7 @@ struct adv748x_csi2 { struct media_pad pads[ADV748X_CSI2_NR_PADS]; struct v4l2_ctrl_handler ctrl_hdl; + struct v4l2_ctrl *pixel_rate; struct v4l2_subdev sd; };