Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF30368 for ; Sun, 7 Nov 2021 17:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636305373; 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=Ocnb+DB+0sxHXLL9NPZrQvEmPKtp49OUIhYqvqjElythZCP/UG8a4P4owWIbW6iCsi6OqX 55weF0KRYkCztdU0XYf7UYWOfmlfZxFL5t2eT8TaF8Nq4KnNBMTaX96ZMvG4S7CUTyOxs3 Q/vFB7IV4kR3tfS4My/9yRcLFymWnLo= 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> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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) -- 2.31.1