From patchwork Sun Nov 7 17:15:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11432C433FE for ; Sun, 7 Nov 2021 17:16:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E389F61355 for ; Sun, 7 Nov 2021 17:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235920AbhKGRSo (ORCPT ); Sun, 7 Nov 2021 12:18:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36186 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235918AbhKGRSn (ORCPT ); Sun, 7 Nov 2021 12:18:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dGSvvr9ix576I1a7Ujvg1bDF0KcvkvIRz076If3X540=; b=bQARd6FcDWXX0qwAeUjJ3Hm0/lDscldgDO96RzyWUlTNy1aXfH3/1TeYCYiVmlslEIWJ9d qv2D+F7PlQAFZom9YBkyMZmjqFH2am2VRQ8GTVfhIN/SHqdyBgn5TcB00w+1AkUIaQDAJq z1g2TtJaYRam/EpF2RC5D/bUsPY3WfI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-xGyWAghSPTSYEcq3uNQ9cw-1; Sun, 07 Nov 2021 12:15:56 -0500 X-MC-Unique: xGyWAghSPTSYEcq3uNQ9cw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE3AF802C8F; Sun, 7 Nov 2021 17:15:54 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id A38A457CD3; Sun, 7 Nov 2021 17:15:52 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 01/11] media: atomisp-ov2680: Remove a bunch of unused vars from ov2680_device Date: Sun, 7 Nov 2021 18:15:39 +0100 Message-Id: <20211107171549.267583-2-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Remove a couple of variables which where either completely unused, or only ever got a value assigned to them but were never read. Signed-off-by: Hans de Goede --- .../media/atomisp/i2c/atomisp-ov2680.c | 25 ------------------- drivers/staging/media/atomisp/i2c/ov2680.h | 4 --- 2 files changed, 29 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index ef439937717b..56f95e44316d 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -166,8 +166,6 @@ static int ov2680_get_intg_factor(struct i2c_client *client, struct camera_mipi_info *info, const struct ov2680_resolution *res) { - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct ov2680_device *dev = to_ov2680_sensor(sd); struct atomisp_sensor_mode_data *buf = &info->data; unsigned int pix_clk_freq_hz; u16 reg_val; @@ -180,7 +178,6 @@ static int ov2680_get_intg_factor(struct i2c_client *client, /* pixel clock */ pix_clk_freq_hz = res->pix_clk_freq * 1000000; - dev->vt_pix_clk_freq_mhz = pix_clk_freq_hz; buf->vt_pix_clk_freq_mhz = pix_clk_freq_hz; /* get integration time */ @@ -434,24 +431,8 @@ static int ov2680_q_exposure(struct v4l2_subdev *sd, s32 *value) return ret; } -static u32 ov2680_translate_bayer_order(enum atomisp_bayer_order code) -{ - switch (code) { - case atomisp_bayer_order_rggb: - return MEDIA_BUS_FMT_SRGGB10_1X10; - case atomisp_bayer_order_grbg: - return MEDIA_BUS_FMT_SGRBG10_1X10; - case atomisp_bayer_order_bggr: - return MEDIA_BUS_FMT_SBGGR10_1X10; - case atomisp_bayer_order_gbrg: - return MEDIA_BUS_FMT_SGBRG10_1X10; - } - return 0; -} - static int ov2680_v_flip(struct v4l2_subdev *sd, s32 value) { - struct ov2680_device *dev = to_ov2680_sensor(sd); struct camera_mipi_info *ov2680_info = NULL; struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; @@ -476,15 +457,12 @@ static int ov2680_v_flip(struct v4l2_subdev *sd, s32 value) ov2680_info = v4l2_get_subdev_hostdata(sd); if (ov2680_info) { ov2680_info->raw_bayer_order = ov2680_bayer_order_mapping[index]; - dev->format.code = ov2680_translate_bayer_order( - ov2680_info->raw_bayer_order); } return ret; } static int ov2680_h_flip(struct v4l2_subdev *sd, s32 value) { - struct ov2680_device *dev = to_ov2680_sensor(sd); struct camera_mipi_info *ov2680_info = NULL; struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; @@ -510,8 +488,6 @@ static int ov2680_h_flip(struct v4l2_subdev *sd, s32 value) ov2680_info = v4l2_get_subdev_hostdata(sd); if (ov2680_info) { ov2680_info->raw_bayer_order = ov2680_bayer_order_mapping[index]; - dev->format.code = ov2680_translate_bayer_order( - ov2680_info->raw_bayer_order); } return ret; } @@ -1199,7 +1175,6 @@ static int ov2680_probe(struct i2c_client *client) dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; dev->pad.flags = MEDIA_PAD_FL_SOURCE; - dev->format.code = MEDIA_BUS_FMT_SBGGR10_1X10; dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = v4l2_ctrl_handler_init(&dev->ctrl_handler, diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index 535440ed14d7..9f9f6695eed9 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -169,14 +169,10 @@ struct ov2680_format { struct ov2680_device { struct v4l2_subdev sd; struct media_pad pad; - struct v4l2_mbus_framefmt format; struct mutex input_lock; struct v4l2_ctrl_handler ctrl_handler; struct ov2680_resolution *res; struct camera_sensor_platform_data *platform_data; - int vt_pix_clk_freq_mhz; - int run_mode; - u8 type; }; /** From patchwork Sun Nov 7 17:15:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FB74C4332F for ; Sun, 7 Nov 2021 17:16:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CBA961354 for ; Sun, 7 Nov 2021 17:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235922AbhKGRSo (ORCPT ); Sun, 7 Nov 2021 12:18:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51437 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234970AbhKGRSn (ORCPT ); Sun, 7 Nov 2021 12:18:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GZ3baJ666XDmjUnz4Kzy7jLpsf5tFuWiQGpNFfbpdhI=; b=aCbRHTzE3pl3KgH29i9bWTuiGDyptCG9JgGYnquJxub2cFwyt2DKLHD9bidsZB3P6kf6j7 9t2x+HD9KgUciFOTccng4pziYa549sz7RiksYLkVQTgi4ZWh9zGOO1qOxJ6dtfWxLf9uXh +wezhjIGb3HG57slP/vw8Qw1CL4oQ0E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-501-RcHZYAYmMyOIRzHWlBrSqw-1; Sun, 07 Nov 2021 12:15:58 -0500 X-MC-Unique: RcHZYAYmMyOIRzHWlBrSqw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06DAC1006AA0; Sun, 7 Nov 2021 17:15:57 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01E8B57CD3; Sun, 7 Nov 2021 17:15:54 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 02/11] media: atomisp-ov2680: Turn on power only once Date: Sun, 7 Nov 2021 18:15:40 +0100 Message-Id: <20211107171549.267583-3-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a power_on bool to track if the power is on, and make power_up() a no-op if the power is already on. This also removes a power_down() call from ov2680_s_config() since that is a no-op now, this is ok because s_config() is only called once on probe and the sensor is off at boot. Besides avoiding to the work in power_up() multiple times this patch is also a preparation for switching to the clk and regulator frameworks which keep an enable count, so there we must call enable() and disable() only once per power-cycle. Signed-off-by: Hans de Goede --- .../media/atomisp/i2c/atomisp-ov2680.c | 27 +++++++++---------- drivers/staging/media/atomisp/i2c/ov2680.h | 1 + 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 56f95e44316d..7b7cf7a68823 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -736,6 +736,9 @@ static int power_up(struct v4l2_subdev *sd) return -ENODEV; } + if (dev->power_on) + return 0; /* Already on */ + /* power control */ ret = power_ctrl(sd, 1); if (ret) @@ -760,6 +763,7 @@ static int power_up(struct v4l2_subdev *sd) /* according to DS, 20ms is needed between PWDN and i2c access */ msleep(20); + dev->power_on = true; return 0; fail_clk: @@ -785,6 +789,9 @@ static int power_down(struct v4l2_subdev *sd) return -ENODEV; } + if (!dev->power_on) + return 0; /* Already off */ + ret = dev->platform_data->flisclk_ctrl(sd, 0); if (ret) dev_err(&client->dev, "flisclk failed\n"); @@ -799,10 +806,13 @@ static int power_down(struct v4l2_subdev *sd) /* power control */ ret = power_ctrl(sd, 0); - if (ret) + if (ret) { dev_err(&client->dev, "vprog failed.\n"); + return ret; + } - return ret; + dev->power_on = false; + return 0; } static int ov2680_s_power(struct v4l2_subdev *sd, int on) @@ -866,7 +876,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, dev_dbg(&client->dev, "%s: %dx%d\n", __func__, fmt->width, fmt->height); - // IS IT NEEDED? + /* s_power has not been called yet for std v4l2 clients (camorama) */ power_up(sd); ret = ov2680_write_reg_array(client, dev->res->regs); if (ret) @@ -998,16 +1008,6 @@ static int ov2680_s_config(struct v4l2_subdev *sd, (struct camera_sensor_platform_data *)platform_data; mutex_lock(&dev->input_lock); - /* - * power off the module, then power on it in future - * as first power on by board may not fulfill the - * power on sequqence needed by the module - */ - ret = power_down(sd); - if (ret) { - dev_err(&client->dev, "ov2680 power-off err.\n"); - goto fail_power_off; - } ret = power_up(sd); if (ret) { @@ -1041,7 +1041,6 @@ static int ov2680_s_config(struct v4l2_subdev *sd, fail_power_on: power_down(sd); dev_err(&client->dev, "sensor power-gating failed\n"); -fail_power_off: mutex_unlock(&dev->input_lock); return ret; } diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index 9f9f6695eed9..edd87bb8563f 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -173,6 +173,7 @@ struct ov2680_device { struct v4l2_ctrl_handler ctrl_handler; struct ov2680_resolution *res; struct camera_sensor_platform_data *platform_data; + bool power_on; }; /** From patchwork Sun Nov 7 17:15:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90953C433EF for ; Sun, 7 Nov 2021 17:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77DF860EBD for ; Sun, 7 Nov 2021 17:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235952AbhKGRTS (ORCPT ); Sun, 7 Nov 2021 12:19:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25230 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235939AbhKGRTR (ORCPT ); Sun, 7 Nov 2021 12:19:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305394; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WiPLWJPgTA6gAhs9VVSBRkfSI3oaxNGGr5gWgMBCnms=; b=V+hyZflDqt/ieuOMePoIACBAeTz6MQVWUeFtv04Mey6ng6WopyDqDN+TROW8mW93nlWZzd 3wuo1OuA/CssMXKsdO92z1pcGJJc6AkI4UTzmOD98SkIkCuDmK2KufpvlKgOJRdairpSEw RLDn6CNcZgXXy/MHTX62xGwENmdac40= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-9C25friiPU-VnG2Q_i6LMQ-1; Sun, 07 Nov 2021 12:16:01 -0500 X-MC-Unique: 9C25friiPU-VnG2Q_i6LMQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 743A28042CF; Sun, 7 Nov 2021 17:15:59 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50F2057CD3; Sun, 7 Nov 2021 17:15:57 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 03/11] media: atomisp-ov2680: Push the input_lock taking up into ov2680_s_power() Date: Sun, 7 Nov 2021 18:15:41 +0100 Message-Id: <20211107171549.267583-4-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org ov2680_s_power() is the only caller of ov2680_init(), push the input_lock taking from ov2680_init() up into ov2680_s_power(), this way the new power_on bool is also protected by it. Signed-off-by: Hans de Goede --- .../media/atomisp/i2c/atomisp-ov2680.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 7b7cf7a68823..2721223ebcde 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -655,21 +655,11 @@ static int ov2680_init_registers(struct v4l2_subdev *sd) static int ov2680_init(struct v4l2_subdev *sd) { - struct ov2680_device *dev = to_ov2680_sensor(sd); - - int ret; - - mutex_lock(&dev->input_lock); - /* restore settings */ ov2680_res = ov2680_res_preview; N_RES = N_RES_PREVIEW; - ret = ov2680_init_registers(sd); - - mutex_unlock(&dev->input_lock); - - return ret; + return ov2680_init_registers(sd); } static int power_ctrl(struct v4l2_subdev *sd, bool flag) @@ -817,15 +807,21 @@ static int power_down(struct v4l2_subdev *sd) static int ov2680_s_power(struct v4l2_subdev *sd, int on) { + struct ov2680_device *dev = to_ov2680_sensor(sd); int ret; + mutex_lock(&dev->input_lock); + if (on == 0) { ret = power_down(sd); } else { ret = power_up(sd); if (!ret) - return ov2680_init(sd); + ret = ov2680_init(sd); } + + mutex_unlock(&dev->input_lock); + return ret; } From patchwork Sun Nov 7 17:15:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F6F2C433F5 for ; Sun, 7 Nov 2021 17:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 858D061355 for ; Sun, 7 Nov 2021 17:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235924AbhKGRSu (ORCPT ); Sun, 7 Nov 2021 12:18:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20325 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235923AbhKGRSs (ORCPT ); Sun, 7 Nov 2021 12:18:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iomUZ6tTneEsDY36qk52jXAdQ4IFcPyraE5IvBWRl7E=; b=bFCY7b7t7EMz4DHOibKp1qCptBwuvls/owHtBc3BvhCC02O9ct6j5yoJpW2rYkPdLRxMjr 0LWr1/uGNsupERraiuKwO2zSahtSyhnoxN/Zo2tjto89HgziAdnlCKDRSGjMfrZzVtfyc7 +V6ZJwlxXbDLuDZW+O3C93KIiCKdkQM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-Zi77muTXM5K4CPq9ge6XZw-1; Sun, 07 Nov 2021 12:16:03 -0500 X-MC-Unique: Zi77muTXM5K4CPq9ge6XZw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C353710055A7; Sun, 7 Nov 2021 17:16:01 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07CD57CD3; Sun, 7 Nov 2021 17:15:59 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 04/11] media: atomisp-ov2680: Remove the ov2680_res and N_RES global variables Date: Sun, 7 Nov 2021 18:15:42 +0100 Message-Id: <20211107171549.267583-5-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov2680_res and N_RES global variables are just hardcoded as aliases for ov2680_res_preview and N_RES_PREVIEW, remove them. Signed-off-by: Hans de Goede --- .../media/atomisp/i2c/atomisp-ov2680.c | 28 +++++-------------- drivers/staging/media/atomisp/i2c/ov2680.h | 3 -- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 2721223ebcde..b6927f9be022 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -653,15 +653,6 @@ static int ov2680_init_registers(struct v4l2_subdev *sd) return ret; } -static int ov2680_init(struct v4l2_subdev *sd) -{ - /* restore settings */ - ov2680_res = ov2680_res_preview; - N_RES = N_RES_PREVIEW; - - return ov2680_init_registers(sd); -} - static int power_ctrl(struct v4l2_subdev *sd, bool flag) { int ret = 0; @@ -817,7 +808,7 @@ static int ov2680_s_power(struct v4l2_subdev *sd, int on) } else { ret = power_up(sd); if (!ret) - ret = ov2680_init(sd); + ret = ov2680_init_registers(sd); } mutex_unlock(&dev->input_lock); @@ -857,7 +848,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, ARRAY_SIZE(ov2680_res_preview), width, height, fmt->width, fmt->height); if (!res) - res = &ov2680_res[N_RES - 1]; + res = &ov2680_res_preview[N_RES_PREVIEW - 1]; fmt->width = res->width; fmt->height = res->height; @@ -975,11 +966,6 @@ static int ov2680_s_stream(struct v4l2_subdev *sd, int enable) ret = ov2680_write_reg(client, 1, OV2680_SW_STREAM, enable ? OV2680_START_STREAMING : OV2680_STOP_STREAMING); -#if 0 - /* restore settings */ - ov2680_res = ov2680_res_preview; - N_RES = N_RES_PREVIEW; -#endif //otp valid at stream on state //if(!dev->otp_data) @@ -1069,13 +1055,13 @@ static int ov2680_enum_frame_size(struct v4l2_subdev *sd, { int index = fse->index; - if (index >= N_RES) + if (index >= N_RES_PREVIEW) return -EINVAL; - fse->min_width = ov2680_res[index].width; - fse->min_height = ov2680_res[index].height; - fse->max_width = ov2680_res[index].width; - fse->max_height = ov2680_res[index].height; + fse->min_width = ov2680_res_preview[index].width; + fse->min_height = ov2680_res_preview[index].height; + fse->max_width = ov2680_res_preview[index].width; + fse->max_height = ov2680_res_preview[index].height; return 0; } diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index edd87bb8563f..c1998c9132a2 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -838,7 +838,4 @@ static struct ov2680_resolution ov2680_res_preview[] = { #define N_RES_PREVIEW (ARRAY_SIZE(ov2680_res_preview)) -static struct ov2680_resolution *ov2680_res = ov2680_res_preview; -static unsigned long N_RES = N_RES_PREVIEW; - #endif From patchwork Sun Nov 7 17:15:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CE24C433FE for ; Sun, 7 Nov 2021 17:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6B4D61354 for ; Sun, 7 Nov 2021 17:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235931AbhKGRSx (ORCPT ); Sun, 7 Nov 2021 12:18:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53889 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235925AbhKGRSw (ORCPT ); Sun, 7 Nov 2021 12:18:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TN3M1d5XJcSeQr02Uxkvd7ceeDIpLiFFnrD5J9Lli10=; b=FK6CHOFTjcO8yc3PDlnFJnWfF/pGjfMe3o011xrhBaI3aUnvIolpKW8Vu+t0/62UZ+nyUQ uS8zU0ERIkBeBBNWkiBp2n0rFM9/9XaRYdjvWVUYz5XJY/lZYi1+C3tMMnD8CQRFAIFQM3 JC05SpccjC9JUop+Ybma4yuwBtkY4Fo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-0XbMcXJAPYqkjy0SMzLjRw-1; Sun, 07 Nov 2021 12:16:05 -0500 X-MC-Unique: 0XbMcXJAPYqkjy0SMzLjRw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B32115720; Sun, 7 Nov 2021 17:16:04 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CE3B57CD3; Sun, 7 Nov 2021 17:16:01 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 05/11] media: atomisp-ov2680: Move ov2680_init_registers() call to power_up() Date: Sun, 7 Nov 2021 18:15:43 +0100 Message-Id: <20211107171549.267583-6-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Move ov2680_init_registers() call to power_up(), so that we also init the registers on code-paths which do not call ov2680_s_power() like running camorama. Signed-off-by: Hans de Goede --- Note we should really look into makeing sure that s_power() is always called when it should and remove the power_up() call from ov2680_set_fmt() when that is done. Even then we still need the power_on bool though since power_down() gets called on every runtime-suspend, even if power_up() was never called. --- drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index b6927f9be022..83608ba4e70a 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -744,9 +744,15 @@ static int power_up(struct v4l2_subdev *sd) /* according to DS, 20ms is needed between PWDN and i2c access */ msleep(20); + ret = ov2680_init_registers(sd); + if (ret) + goto fail_init_registers; + dev->power_on = true; return 0; +fail_init_registers: + dev->platform_data->flisclk_ctrl(sd, 0); fail_clk: gpio_ctrl(sd, 0); fail_power: @@ -807,8 +813,6 @@ static int ov2680_s_power(struct v4l2_subdev *sd, int on) ret = power_down(sd); } else { ret = power_up(sd); - if (!ret) - ret = ov2680_init_registers(sd); } mutex_unlock(&dev->input_lock); From patchwork Sun Nov 7 17:15:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65860C433EF for ; Sun, 7 Nov 2021 17:16:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C9461355 for ; Sun, 7 Nov 2021 17:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235940AbhKGRS4 (ORCPT ); Sun, 7 Nov 2021 12:18:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20706 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235923AbhKGRSy (ORCPT ); Sun, 7 Nov 2021 12:18:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YqyauolxCwJzENXehwNcrAs/KmXm1xUKj3TqZRG8H1M=; b=CNeGdHz6wwePOv/7tXOEAH+JmWm1ITV4o2f0cqFMdvfoEIEknPO6HaMv+LLoMnPNUm7m+x O0/Bn0pBf28f5fXbTEcDPbEjnJ/MqhmQ1cpaEpJFVyf16F4qM7fwMeXBWI+UPWnjoIUv7a mAlChm/yfcE4GXRQlMfgqf4mVWoo+iE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-pG036CGqOruzRHVuqAfdVw-1; Sun, 07 Nov 2021 12:16:08 -0500 X-MC-Unique: pG036CGqOruzRHVuqAfdVw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6742D104ED1A; Sun, 7 Nov 2021 17:16:06 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6288E57CD3; Sun, 7 Nov 2021 17:16:04 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 06/11] media: atomisp-ov2680: Save/restore exposure and gain over sensor power-down Date: Sun, 7 Nov 2021 18:15:44 +0100 Message-Id: <20211107171549.267583-7-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Save/restore exposure and gain over sensor power-down and don't write them to the sensor when ov2680_set_exposure() is called while the sensor is off. Signed-off-by: Hans de Goede --- .../staging/media/atomisp/i2c/atomisp-ov2680.c | 15 ++++++++++++++- drivers/staging/media/atomisp/i2c/ov2680.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 83608ba4e70a..5b192218ba91 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -359,7 +359,14 @@ static int ov2680_set_exposure(struct v4l2_subdev *sd, int exposure, int ret; mutex_lock(&dev->input_lock); - ret = __ov2680_set_exposure(sd, exposure, gain, digitgain); + + dev->exposure = exposure; + dev->gain = gain; + dev->digitgain = digitgain; + + if (dev->power_on) + ret = __ov2680_set_exposure(sd, exposure, gain, digitgain); + mutex_unlock(&dev->input_lock); return ret; @@ -748,6 +755,10 @@ static int power_up(struct v4l2_subdev *sd) if (ret) goto fail_init_registers; + ret = __ov2680_set_exposure(sd, dev->exposure, dev->gain, dev->digitgain); + if (ret) + goto fail_init_registers; + dev->power_on = true; return 0; @@ -1140,6 +1151,8 @@ static int ov2680_probe(struct i2c_client *client) mutex_init(&dev->input_lock); dev->res = &ov2680_res_preview[0]; + dev->exposure = dev->res->lines_per_frame - OV2680_INTEGRATION_TIME_MARGIN; + dev->gain = 250; /* 0-2047 */ v4l2_i2c_subdev_init(&dev->sd, client, &ov2680_ops); pdata = gmin_camera_platform_data(&dev->sd, diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index c1998c9132a2..ca20ce5aa285 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -174,6 +174,9 @@ struct ov2680_device { struct ov2680_resolution *res; struct camera_sensor_platform_data *platform_data; bool power_on; + u16 exposure; + u16 gain; + u16 digitgain; }; /** From patchwork Sun Nov 7 17:15:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 523F1C433F5 for ; Sun, 7 Nov 2021 17:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B58761355 for ; Sun, 7 Nov 2021 17:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235947AbhKGRTG (ORCPT ); Sun, 7 Nov 2021 12:19:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31285 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235942AbhKGRTF (ORCPT ); Sun, 7 Nov 2021 12:19:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=INP/po4e8nraFLBHME9OkzJGog791g7efMD+eWiNZt8=; b=W6bsk/zZD1A32mYdq3ue8DhO8OoD9MnTXHNWQUPJyink902BzK1i1UyvgF7A45rbNqqzpt 6FW+Ix1NgHtt++yU6K4y2IDQ089J7wtPkG2pzm/7Y8aDEgVSjlnoVDkVPtA91jqyehnsQk 7Ost3iT/7LDvSQ+7VJbgTJ+7x9YzHvE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-559-rzmznxzNMHqKZF5TqC87sw-1; Sun, 07 Nov 2021 12:16:10 -0500 X-MC-Unique: rzmznxzNMHqKZF5TqC87sw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8E218042A8; Sun, 7 Nov 2021 17:16:08 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0C4367843; Sun, 7 Nov 2021 17:16:06 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 07/11] media: atomisp-ov2680: Make ov2680_read_reg() support 24 bit registers Date: Sun, 7 Nov 2021 18:15:45 +0100 Message-Id: <20211107171549.267583-8-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some ov2680 registers like exposure are 24 bit, ov2680_read_reg() already mostly supports this, we just need to change the return type from u16 to u32. Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 5b192218ba91..7e49f4eb0410 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -48,7 +48,7 @@ static enum atomisp_bayer_order ov2680_bayer_order_mapping[] = { /* i2c read/write stuff */ static int ov2680_read_reg(struct i2c_client *client, - int len, u16 reg, u16 *val) + int len, u16 reg, u32 *val) { struct i2c_msg msgs[2]; u8 addr_buf[2] = { reg >> 8, reg & 0xff }; @@ -168,7 +168,7 @@ static int ov2680_get_intg_factor(struct i2c_client *client, { struct atomisp_sensor_mode_data *buf = &info->data; unsigned int pix_clk_freq_hz; - u16 reg_val; + u32 reg_val; int ret; dev_dbg(&client->dev, "++++ov2680_get_intg_factor\n"); @@ -410,7 +410,7 @@ static long ov2680_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) static int ov2680_q_exposure(struct v4l2_subdev *sd, s32 *value) { struct i2c_client *client = v4l2_get_subdevdata(sd); - u16 reg_v, reg_v2; + u32 reg_v, reg_v2; int ret; /* get exposure */ @@ -433,7 +433,7 @@ static int ov2680_q_exposure(struct v4l2_subdev *sd, s32 *value) if (ret) goto err; - *value = reg_v + (((u32)reg_v2 << 16)); + *value = reg_v + (reg_v2 << 16); err: return ret; } @@ -443,7 +443,7 @@ static int ov2680_v_flip(struct v4l2_subdev *sd, s32 value) struct camera_mipi_info *ov2680_info = NULL; struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; - u16 val; + u32 val; u8 index; dev_dbg(&client->dev, "@%s: value:%d\n", __func__, value); @@ -473,7 +473,7 @@ static int ov2680_h_flip(struct v4l2_subdev *sd, s32 value) struct camera_mipi_info *ov2680_info = NULL; struct i2c_client *client = v4l2_get_subdevdata(sd); int ret; - u16 val; + u32 val; u8 index; dev_dbg(&client->dev, "@%s: value:%d\n", __func__, value); @@ -933,7 +933,7 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd, static int ov2680_detect(struct i2c_client *client) { struct i2c_adapter *adapter = client->adapter; - u16 high, low; + u32 high, low; int ret; u16 id; u8 revision; From patchwork Sun Nov 7 17:15:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3536C433F5 for ; Sun, 7 Nov 2021 17:16:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD7DE6135A for ; Sun, 7 Nov 2021 17:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235946AbhKGRTB (ORCPT ); Sun, 7 Nov 2021 12:19:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23927 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235943AbhKGRTB (ORCPT ); Sun, 7 Nov 2021 12:19:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kFRnRVo7m67vnXPldImfmaggNaRRIwxaAtsgE2VRJtU=; b=cZd5NsM26CK3VwUGTTmKaf7+wUMKamXMRVUl9ibAeo4KTQYVczfP6dl/OPE6YtmdOk430r dPmJbPlhw3KjVLCDdjmFIQ8G0nNvAw7KunFFQNhnBy1rOkwutgTb1csGklQFWkOQktrQ+h pu2jv7z/g8obqLoHdA7pv1LGYpUUXSU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-310-_-ssiAWgOJ2ZSXzrhCChPQ-1; Sun, 07 Nov 2021 12:16:12 -0500 X-MC-Unique: _-ssiAWgOJ2ZSXzrhCChPQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F8AB8042DB; Sun, 7 Nov 2021 17:16:11 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BFD267843; Sun, 7 Nov 2021 17:16:08 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 08/11] media: atomisp-ov2680: Fix and simplify ov2680_q_exposure() Date: Sun, 7 Nov 2021 18:15:46 +0100 Message-Id: <20211107171549.267583-9-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Switch to ov2680_read_reg() to read all 24 bits in one go; and the exposure value sits in bits 4-19 of the 24 bit exposure register, so we need to shift the read value by 4 to report the correct value. Signed-off-by: Hans de Goede --- .../media/atomisp/i2c/atomisp-ov2680.c | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 7e49f4eb0410..d6a5f75fdd66 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -410,32 +410,17 @@ static long ov2680_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) static int ov2680_q_exposure(struct v4l2_subdev *sd, s32 *value) { struct i2c_client *client = v4l2_get_subdevdata(sd); - u32 reg_v, reg_v2; + u32 reg_val; int ret; /* get exposure */ - ret = ov2680_read_reg(client, 1, - OV2680_EXPOSURE_L, - ®_v); - if (ret) - goto err; - - ret = ov2680_read_reg(client, 1, - OV2680_EXPOSURE_M, - ®_v2); + ret = ov2680_read_reg(client, 3, OV2680_EXPOSURE_H, ®_val); if (ret) - goto err; - - reg_v += reg_v2 << 8; - ret = ov2680_read_reg(client, 1, - OV2680_EXPOSURE_H, - ®_v2); - if (ret) - goto err; + return ret; - *value = reg_v + (reg_v2 << 16); -err: - return ret; + /* Lower four bits are not part of the exposure val (always 0) */ + *value = reg_val >> 4; + return 0; } static int ov2680_v_flip(struct v4l2_subdev *sd, s32 value) From patchwork Sun Nov 7 17:15:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B58B0C433EF for ; Sun, 7 Nov 2021 17:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DD526135A for ; Sun, 7 Nov 2021 17:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235943AbhKGRTM (ORCPT ); Sun, 7 Nov 2021 12:19:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52534 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235939AbhKGRTL (ORCPT ); Sun, 7 Nov 2021 12:19:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7+Hqx1r7abyFwhHyL4T7QRDlfh0b0QeNO6qd+NH8FsI=; b=cMrMM708s1GqhFa74NM9U8ManUb5NXj1IhtbQZ6a8XL4b1tZIWMQyjROTfLoeIZhr6KL7j cXp1cgmehyOzq6ML1otYCpzEBzKvdpaxy29zTBwSxm9hXI7Hl6XSg+6dDvf3+fgKTZVD+8 Xp3cfbcz/qvMQ4e7Wybw8DR+36XlBWY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-8l3GUbqXOjame68Uy9tWcQ-1; Sun, 07 Nov 2021 12:16:22 -0500 X-MC-Unique: 8l3GUbqXOjame68Uy9tWcQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE6E11006AA0; Sun, 7 Nov 2021 17:16:20 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56BBD67843; Sun, 7 Nov 2021 17:16:11 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 09/11] media: atomisp-ov2680: Fix ov2680_write_reg() always writing 0 to 16 bit registers Date: Sun, 7 Nov 2021 18:15:47 +0100 Message-Id: <20211107171549.267583-10-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The shift << 16 of the value in the code path for 16 bit values is bogus, put_unaligned_be16() takes the lower 16 bits which will not always be 0. This was causing __ov2680_set_exposure() to always set the OV2680_AGC and OV2680_TIMING_VTS registers to 0. Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index d6a5f75fdd66..1092d1c2993f 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -86,7 +86,7 @@ static int ov2680_write_reg(struct i2c_client *client, unsigned int len, int ret; if (len == 2) - put_unaligned_be16(val << (8 * (4 - len)), buf + 2); + put_unaligned_be16(val, buf + 2); else if (len == 1) buf[2] = val; else From patchwork Sun Nov 7 17:15:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E07E8C433F5 for ; Sun, 7 Nov 2021 17:16:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA5A46135A for ; Sun, 7 Nov 2021 17:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235945AbhKGRTJ (ORCPT ); Sun, 7 Nov 2021 12:19:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29752 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235942AbhKGRTJ (ORCPT ); Sun, 7 Nov 2021 12:19:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AZE+SwkuPYRErMSs9z2ne7lj3jBCy4dZV1VKcSaj8j4=; b=J0AcOF56MPtQ8H1OrnDOyEBiIk1GTsXpDdbDkjGa9G348bH6YI+yQvZmMlQc8nsbDkjMFa 2Cn+/pIWgAU1IOX84Vva+U/LEnblq8PQZmffO7XY5iDBtSWnuiRb+Q8T2B48ik48a4y9RG 8ynK94+K9sCLZfcpvMprjIncDBg9HOA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-brC9p_KtOhCPAEauaNudKw-1; Sun, 07 Nov 2021 12:16:24 -0500 X-MC-Unique: brC9p_KtOhCPAEauaNudKw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2526B15720; Sun, 7 Nov 2021 17:16:23 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 220A857CD3; Sun, 7 Nov 2021 17:16:20 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 10/11] media: atomisp-ov2680: Fix ov2680_set_fmt() clobbering the exposure Date: Sun, 7 Nov 2021 18:15:48 +0100 Message-Id: <20211107171549.267583-11-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Now that we restore the default or last user set exposure setting on power_up() there is no need for the registers written by ov2680_set_fmt() to write to the exposure register. Not doing so fixes the exposure always being reset to the value from the res->regs array after a set_fmt(). Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/i2c/ov2680.h | 24 ---------------------- 1 file changed, 24 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index ca20ce5aa285..d52b7fbe3c06 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -288,8 +288,6 @@ static struct ov2680_reg const ov2680_global_setting[] = { */ static struct ov2680_reg const ov2680_QCIF_30fps[] = { {0x3086, 0x01}, - {0x3501, 0x24}, - {0x3502, 0x40}, {0x370a, 0x23}, {0x3801, 0xa0}, {0x3802, 0x00}, @@ -333,8 +331,6 @@ static struct ov2680_reg const ov2680_QCIF_30fps[] = { */ static struct ov2680_reg const ov2680_CIF_30fps[] = { {0x3086, 0x01}, - {0x3501, 0x24}, - {0x3502, 0x40}, {0x370a, 0x23}, {0x3801, 0xa0}, {0x3802, 0x00}, @@ -376,8 +372,6 @@ static struct ov2680_reg const ov2680_CIF_30fps[] = { */ static struct ov2680_reg const ov2680_QVGA_30fps[] = { {0x3086, 0x01}, - {0x3501, 0x24}, - {0x3502, 0x40}, {0x370a, 0x23}, {0x3801, 0xa0}, {0x3802, 0x00}, @@ -419,8 +413,6 @@ static struct ov2680_reg const ov2680_QVGA_30fps[] = { */ static struct ov2680_reg const ov2680_656x496_30fps[] = { {0x3086, 0x01}, - {0x3501, 0x24}, - {0x3502, 0x40}, {0x370a, 0x23}, {0x3801, 0xa0}, {0x3802, 0x00}, @@ -462,8 +454,6 @@ static struct ov2680_reg const ov2680_656x496_30fps[] = { */ static struct ov2680_reg const ov2680_720x592_30fps[] = { {0x3086, 0x01}, - {0x3501, 0x26}, - {0x3502, 0x40}, {0x370a, 0x23}, {0x3801, 0x00}, // X_ADDR_START; {0x3802, 0x00}, @@ -507,8 +497,6 @@ static struct ov2680_reg const ov2680_720x592_30fps[] = { */ static struct ov2680_reg const ov2680_800x600_30fps[] = { {0x3086, 0x01}, - {0x3501, 0x26}, - {0x3502, 0x40}, {0x370a, 0x23}, {0x3801, 0x00}, {0x3802, 0x00}, @@ -550,8 +538,6 @@ static struct ov2680_reg const ov2680_800x600_30fps[] = { */ static struct ov2680_reg const ov2680_720p_30fps[] = { {0x3086, 0x00}, - {0x3501, 0x48}, - {0x3502, 0xe0}, {0x370a, 0x21}, {0x3801, 0xa0}, {0x3802, 0x00}, @@ -593,8 +579,6 @@ static struct ov2680_reg const ov2680_720p_30fps[] = { */ static struct ov2680_reg const ov2680_1296x976_30fps[] = { {0x3086, 0x00}, - {0x3501, 0x48}, - {0x3502, 0xe0}, {0x370a, 0x21}, {0x3801, 0xa0}, {0x3802, 0x00}, @@ -636,8 +620,6 @@ static struct ov2680_reg const ov2680_1296x976_30fps[] = { */ static struct ov2680_reg const ov2680_1456x1096_30fps[] = { {0x3086, 0x00}, - {0x3501, 0x48}, - {0x3502, 0xe0}, {0x370a, 0x21}, {0x3801, 0x90}, {0x3802, 0x00}, @@ -681,8 +663,6 @@ static struct ov2680_reg const ov2680_1456x1096_30fps[] = { static struct ov2680_reg const ov2680_1616x916_30fps[] = { {0x3086, 0x00}, - {0x3501, 0x48}, - {0x3502, 0xe0}, {0x370a, 0x21}, {0x3801, 0x00}, {0x3802, 0x00}, @@ -725,8 +705,6 @@ static struct ov2680_reg const ov2680_1616x916_30fps[] = { #if 0 static struct ov2680_reg const ov2680_1616x1082_30fps[] = { {0x3086, 0x00}, - {0x3501, 0x48}, - {0x3502, 0xe0}, {0x370a, 0x21}, {0x3801, 0x00}, {0x3802, 0x00}, @@ -768,8 +746,6 @@ static struct ov2680_reg const ov2680_1616x1082_30fps[] = { */ static struct ov2680_reg const ov2680_1616x1216_30fps[] = { {0x3086, 0x00}, - {0x3501, 0x48}, - {0x3502, 0xe0}, {0x370a, 0x21}, {0x3801, 0x00}, {0x3802, 0x00}, From patchwork Sun Nov 7 17:15:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12606915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12207C433F5 for ; Sun, 7 Nov 2021 17:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0EF46135A for ; Sun, 7 Nov 2021 17:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235951AbhKGRTO (ORCPT ); Sun, 7 Nov 2021 12:19:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49572 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235939AbhKGRTN (ORCPT ); Sun, 7 Nov 2021 12:19:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MXF6tbV0Bo36Zm4e8SD6y0RRWBH+qoROmu/xiP3S664=; b=Aq457okuILFtdVCLpYs8aztiEHPLLGPf+FGaQffvHGkfCXhDv1NPzSFQlUH/41de1VpB/u VbWZjkIkVINaHUwJk2EqKs7C64zjO3mzLeAMOkHw6Jv/tgvQrzqdiz4teewNZLSpqqJhUr LE1vWgCvBfKhdNfBrkR91mEumI6GYLQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-33-Fyr0zfBUMTyXwVEp98zf5g-1; Sun, 07 Nov 2021 12:16:27 -0500 X-MC-Unique: Fyr0zfBUMTyXwVEp98zf5g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70F251006AA0; Sun, 7 Nov 2021 17:16:25 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C36757CD3; Sun, 7 Nov 2021 17:16:23 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 11/11] media: atomisp-ov2680: Fix ov2680_set_fmt() messing up high exposure settings Date: Sun, 7 Nov 2021 18:15:49 +0100 Message-Id: <20211107171549.267583-12-hdegoede@redhat.com> In-Reply-To: <20211107171549.267583-1-hdegoede@redhat.com> References: <20211107171549.267583-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For exposure settings > (lines_per_frame - vts_margin) the VTS register needs to be programmed to (exposure + vts_margin) rather then being set to lines_per_frame. The res->regs register array was clobbering this higher setting causing high exposure settings to not work. Fix this by letting ov2680_set_fmt() calculate the vts value, instead of hardcoding it. This is the last in a series of fixes which fixes exposure and gain settings not working, with this everything works, so drop the comment that it does not work. Signed-off-by: Hans de Goede --- .../media/atomisp/i2c/atomisp-ov2680.c | 13 ++++++++-- drivers/staging/media/atomisp/i2c/ov2680.h | 24 ------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 1092d1c2993f..34d008236bd9 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -387,7 +387,6 @@ static long ov2680_s_exposure(struct v4l2_subdev *sd, return -EINVAL; } - // EXPOSURE CONTROL DISABLED FOR INITIAL CHECKIN, TUNING DOESN'T WORK return ov2680_set_exposure(sd, coarse_itg, analog_gain, digital_gain); } @@ -825,7 +824,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, struct i2c_client *client = v4l2_get_subdevdata(sd); struct camera_mipi_info *ov2680_info = NULL; struct ov2680_resolution *res; - int ret = 0; + int vts, ret = 0; dev_dbg(&client->dev, "%s: %s: pad: %d, fmt: %p\n", __func__, @@ -870,6 +869,16 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, dev_err(&client->dev, "ov2680 write resolution register err: %d\n", ret); + /* If necessary increase the VTS to match exposure + MARGIN */ + if (dev->exposure > vts - OV2680_INTEGRATION_TIME_MARGIN) + vts = dev->exposure + OV2680_INTEGRATION_TIME_MARGIN; + else + vts = dev->res->lines_per_frame; + + ret = ov2680_write_reg(client, 2, OV2680_TIMING_VTS_H, vts); + if (ret) + dev_err(&client->dev, "ov2680 write vts err: %d\n", ret); + ret = ov2680_get_intg_factor(client, ov2680_info, res); if (ret) { dev_err(&client->dev, "failed to get integration factor\n"); diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index d52b7fbe3c06..e53be612a1e4 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -302,8 +302,6 @@ static struct ov2680_reg const ov2680_QCIF_30fps[] = { {0x380b, 0xa0}, {0x380c, 0x06}, {0x380d, 0xb0}, - {0x380e, 0x02}, - {0x380f, 0x84}, {0x3810, 0x00}, {0x3811, 0x04}, {0x3812, 0x00}, @@ -345,8 +343,6 @@ static struct ov2680_reg const ov2680_CIF_30fps[] = { {0x380b, 0x30}, {0x380c, 0x06}, {0x380d, 0xb0}, - {0x380e, 0x02}, - {0x380f, 0x84}, {0x3810, 0x00}, {0x3811, 0x04}, {0x3812, 0x00}, @@ -386,8 +382,6 @@ static struct ov2680_reg const ov2680_QVGA_30fps[] = { {0x380b, 0x00}, {0x380c, 0x06}, {0x380d, 0xb0}, - {0x380e, 0x02}, - {0x380f, 0x84}, {0x3810, 0x00}, {0x3811, 0x04}, {0x3812, 0x00}, @@ -427,8 +421,6 @@ static struct ov2680_reg const ov2680_656x496_30fps[] = { {0x380b, 0xf0}, {0x380c, 0x06}, {0x380d, 0xb0}, - {0x380e, 0x02}, - {0x380f, 0x84}, {0x3810, 0x00}, {0x3811, 0x04}, {0x3812, 0x00}, @@ -468,8 +460,6 @@ static struct ov2680_reg const ov2680_720x592_30fps[] = { {0x380b, 0x50}, // Y_OUTPUT_SIZE; {0x380c, 0x06}, {0x380d, 0xac}, // HTS; - {0x380e, 0x02}, - {0x380f, 0x84}, // VTS; {0x3810, 0x00}, {0x3811, 0x00}, {0x3812, 0x00}, @@ -511,8 +501,6 @@ static struct ov2680_reg const ov2680_800x600_30fps[] = { {0x380b, 0x58}, {0x380c, 0x06}, {0x380d, 0xac}, - {0x380e, 0x02}, - {0x380f, 0x84}, {0x3810, 0x00}, {0x3811, 0x00}, {0x3812, 0x00}, @@ -552,8 +540,6 @@ static struct ov2680_reg const ov2680_720p_30fps[] = { {0x380b, 0xe0}, {0x380c, 0x06}, {0x380d, 0xa8}, - {0x380e, 0x05}, - {0x380f, 0x0e}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, @@ -593,8 +579,6 @@ static struct ov2680_reg const ov2680_1296x976_30fps[] = { {0x380b, 0xd0}, {0x380c, 0x06}, {0x380d, 0xa8}, - {0x380e, 0x05}, - {0x380f, 0x0e}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, @@ -634,8 +618,6 @@ static struct ov2680_reg const ov2680_1456x1096_30fps[] = { {0x380b, 0x48}, {0x380c, 0x06}, {0x380d, 0xa8}, - {0x380e, 0x05}, - {0x380f, 0x0e}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, @@ -677,8 +659,6 @@ static struct ov2680_reg const ov2680_1616x916_30fps[] = { {0x380b, 0x94}, {0x380c, 0x06}, {0x380d, 0xa8}, - {0x380e, 0x05}, - {0x380f, 0x0e}, {0x3810, 0x00}, {0x3811, 0x00}, {0x3812, 0x00}, @@ -719,8 +699,6 @@ static struct ov2680_reg const ov2680_1616x1082_30fps[] = { {0x380b, 0x3a}, {0x380c, 0x06}, {0x380d, 0xa8}, - {0x380e, 0x05}, - {0x380f, 0x0e}, {0x3810, 0x00}, {0x3811, 0x00}, {0x3812, 0x00}, @@ -760,8 +738,6 @@ static struct ov2680_reg const ov2680_1616x1216_30fps[] = { {0x380b, 0xc0},//c0}, {0x380c, 0x06}, {0x380d, 0xa8}, - {0x380e, 0x05}, - {0x380f, 0x0e}, {0x3810, 0x00}, {0x3811, 0x00}, {0x3812, 0x00},