From patchwork Mon Apr 15 13:03:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13630011 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 CC0F5128368 for ; Mon, 15 Apr 2024 13:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186220; cv=none; b=mNSyxDBk5AWA3Eqt8a/NaGWjJWB4k7eLyPEOP47G59IMu+rvKpvJJfzKkCcfMuTJ9rZgQSxGpEX9wCAg/+rYNOyRkZXLQWvlEMKvjgu1Ekjti0HdmeLnYxIlanJM2DLY4Pk0aU2zROumEdsCZR3RUEKE95UNYYQFUgvg7FWhbdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186220; c=relaxed/simple; bh=Efxx58K/N0orGY0hE2CJwZX/RRmuEEABPA/uA1hluxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ETU++VcQBawomqlRki8n/gyRWzWavs3r4rWFMU6EO4lpvoON0qWDOoIc42p3NdGUlLFrOv3S+xnlTwZRl4Zx/DZ3re5Ev4eB5syPPu5BtNlS1JDMNEr/c1FkfDFLJk7TYrTDuVTyUx+iRDrkJbMumScMzBojEFr8eofVXoVaMxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EgoyVwzK; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EgoyVwzK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713186216; 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=rkHdOeBNWHtREjZ+WBbco95yCBYqIHo6d028fUo1cSw=; b=EgoyVwzKjfHp5yuiYbJ3l9tT2pQcA/bdoLymEc2fA3xWUOa/vWVI92+MlfuoH40yyffUwf 2J2LLf/qzPZPfjhVECXgFjM2Dhb42dO54cxRYY3HfYwJKzGfRY5HmnLwggUwoCZUCNZcMI y3CT+JKDHBP0/yAHoxN0+BidLT9ilKU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-5hZV9yMHOkqIhQkcBHvmNg-1; Mon, 15 Apr 2024 09:03:33 -0400 X-MC-Unique: 5hZV9yMHOkqIhQkcBHvmNg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA1C71044573; Mon, 15 Apr 2024 13:03:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2E561121306; Mon, 15 Apr 2024 13:03:31 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Rui Miguel Silva Cc: Hans de Goede , Mauro Carvalho Chehab , Kate Hsuan , Kieran Bingham , linux-media@vger.kernel.org Subject: [PATCH v2 1/5] media: ov2680: Stop sending more data then requested Date: Mon, 15 Apr 2024 15:03:14 +0200 Message-ID: <20240415130318.234222-2-hdegoede@redhat.com> In-Reply-To: <20240415130318.234222-1-hdegoede@redhat.com> References: <20240415130318.234222-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 There is no reason to send OV2680_END_MARGIN extra columns on top of the mode width and the same for sending extra lines over the mode height. This sending of extra lines/columns was inherited from the atomisp ov2680 driver, it is unclear why this was done and this complicates adding V4L2_CID_VBLANK support, so remove it. Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede --- drivers/media/i2c/ov2680.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index a857763c7984..4429b569ded0 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -86,9 +86,6 @@ #define OV2680_PIXELS_PER_LINE 1704 #define OV2680_LINES_PER_FRAME 1294 -/* If possible send 16 extra rows / lines to the ISP as padding */ -#define OV2680_END_MARGIN 16 - /* Max exposure time is VTS - 8 */ #define OV2680_INTEGRATION_TIME_MARGIN 8 @@ -359,11 +356,9 @@ static void ov2680_calc_mode(struct ov2680_dev *sensor) sensor->mode.v_start = (sensor->mode.crop.top + (sensor->mode.crop.height - height) / 2) & ~1; sensor->mode.h_end = - min(sensor->mode.h_start + width + OV2680_END_MARGIN - 1, - OV2680_NATIVE_WIDTH - 1); + min(sensor->mode.h_start + width - 1, OV2680_NATIVE_WIDTH - 1); sensor->mode.v_end = - min(sensor->mode.v_start + height + OV2680_END_MARGIN - 1, - OV2680_NATIVE_HEIGHT - 1); + min(sensor->mode.v_start + height - 1, OV2680_NATIVE_HEIGHT - 1); sensor->mode.h_output_size = orig_width; sensor->mode.v_output_size = orig_height; sensor->mode.hts = OV2680_PIXELS_PER_LINE; From patchwork Mon Apr 15 13:03:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13630012 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 90262128386 for ; Mon, 15 Apr 2024 13:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186221; cv=none; b=C30vq/uZf3qOXk0e+fc/62TM2tB3o0fUC/iHj76Xx4/brAcNM+Th0tMZsrdlA52iUlfTEKn1dKvKPKvtpnnQyU9HCCeAekMWFPY50jUIWbg8Iw8HoD/P43n/HFOQskhqFOm8Bb0EsL2qESWEPRLlmX0X0OyypcEIFPNO+J/cU88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186221; c=relaxed/simple; bh=Tdu6OBH5DJtj6de6x7md59ZW+6g0lUQEhSHmlok/Ahs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RrE9Ad337mWf041L++nTOIM8LBBmPMB3r2MmpZ24l2H1sXAOfUiAKZh2n9CfewlInMbdgXDLJsLOH1l7V+dUcM1AJUjfoSB1ltnsd4usZD+KflKbz3XmXVpJszieqF7i2WQxeB3S4L1ytNCmASWZpglxAhnPpBrFRlkerspYuws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TNLFDFfy; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TNLFDFfy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713186218; 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=BeH60ThU8MRnDZbjttDVNCJKnlAoPaM/0kQfoJ+lgec=; b=TNLFDFfyPWZu72ct3h/1vmcTDpSXEyHjB0a1VCI+oT7j3p+o640bBO8U2eOUu5RqytqUSs Usv5awx4YW4x/l4w6VZifYD5sf5tVlJoEFk48IBkMzeI9n2kwi14MTZ30gnlp4Xgf6UPby PW/QtKqXHELLHGfG5/4UJdlkkjz4tTs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-rv-2z3xONTu79x8nMT914Q-1; Mon, 15 Apr 2024 09:03:34 -0400 X-MC-Unique: rv-2z3xONTu79x8nMT914Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F339C881E66; Mon, 15 Apr 2024 13:03:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB1E21121312; Mon, 15 Apr 2024 13:03:32 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Rui Miguel Silva Cc: Hans de Goede , Mauro Carvalho Chehab , Kate Hsuan , Kieran Bingham , linux-media@vger.kernel.org Subject: [PATCH v2 2/5] media: ov2680: Drop hts, vts ov2680_mode struct members Date: Mon, 15 Apr 2024 15:03:15 +0200 Message-ID: <20240415130318.234222-3-hdegoede@redhat.com> In-Reply-To: <20240415130318.234222-1-hdegoede@redhat.com> References: <20240415130318.234222-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 The hts, vts ov2680_mode struct members always contain OV2680_PIXELS_PER_LINE resp. OV2680_LINES_PER_FRAME, drop them and simply use these values directly. Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede --- drivers/media/i2c/ov2680.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 4429b569ded0..6c3d7862b2aa 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -140,8 +140,6 @@ struct ov2680_mode { u16 v_end; u16 h_output_size; u16 v_output_size; - u16 hts; - u16 vts; }; struct ov2680_dev { @@ -361,8 +359,6 @@ static void ov2680_calc_mode(struct ov2680_dev *sensor) min(sensor->mode.v_start + height - 1, OV2680_NATIVE_HEIGHT - 1); sensor->mode.h_output_size = orig_width; sensor->mode.v_output_size = orig_height; - sensor->mode.hts = OV2680_PIXELS_PER_LINE; - sensor->mode.vts = OV2680_LINES_PER_FRAME; } static int ov2680_set_mode(struct ov2680_dev *sensor) @@ -397,9 +393,9 @@ static int ov2680_set_mode(struct ov2680_dev *sensor) cci_write(sensor->regmap, OV2680_REG_VERTICAL_OUTPUT_SIZE, sensor->mode.v_output_size, &ret); cci_write(sensor->regmap, OV2680_REG_TIMING_HTS, - sensor->mode.hts, &ret); + OV2680_PIXELS_PER_LINE, &ret); cci_write(sensor->regmap, OV2680_REG_TIMING_VTS, - sensor->mode.vts, &ret); + OV2680_LINES_PER_FRAME, &ret); cci_write(sensor->regmap, OV2680_REG_ISP_X_WIN, 0, &ret); cci_write(sensor->regmap, OV2680_REG_ISP_Y_WIN, 0, &ret); cci_write(sensor->regmap, OV2680_REG_X_INC, inc, &ret); From patchwork Mon Apr 15 13:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13630014 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 B1567127E33 for ; Mon, 15 Apr 2024 13:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186225; cv=none; b=fu6d810Mg0Ti1IvBe+74G3z85CfLQaXv1X4ERRJGZMFRcLipN0krTSmRVhJtyNbeVeXB6YYTE1vcL5a75q7XXDdWcOTvu0HD5Zl3dIZG6Ucv+bbqjrBOuJ+urhzd/nHb844mmKdHSf51VWdcIe6WL0KLxVc5kRZBcbGA65GuEeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186225; c=relaxed/simple; bh=QXIAhsGejHIqLMH9Q1qTWO8Ds3pfu49miUtQzMNppGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YDJfwFXrh0xsGmyZZmNZ6dRRfp1Jqx5UcnJNXP/cDTFfXYQ5AbNg4HaIBNqywhvAsvB6+wQHTTruNy+yb5Uqp8Ao497ltjrFZGF9ehtxgmb0JuNmQo368fX9aNGmDPgUTwCGex5bexmwL7dUwYrGAfOCC9In7/hSCGidFKsk/FM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=R4TMV1GT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R4TMV1GT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713186219; 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=6pNuHo4YKN6k38sMgA99YpIUkHjY6Q7qGnTJlbNlN1M=; b=R4TMV1GT4ajTYhUZqeThoCFLGCtCM1puzuFrZM9jhQCTNtY2JFToZo/TYgb+SeimgKyMcX DQD6abT5djahlS+jFXP9cqF33o9U3wsWJBRe6i0GEOoCbgzUtdK+3XXNWTgVdKeLbNGvPe d8I7bvuEE3YTv5VASS1mqMbdQ37P7M0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-khkPYU6nMzmVzx5gwsaPOw-1; Mon, 15 Apr 2024 09:03:35 -0400 X-MC-Unique: khkPYU6nMzmVzx5gwsaPOw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2B45D3C0ED49; Mon, 15 Apr 2024 13:03:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 309D31121306; Mon, 15 Apr 2024 13:03:34 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Rui Miguel Silva Cc: Hans de Goede , Mauro Carvalho Chehab , Kate Hsuan , Kieran Bingham , linux-media@vger.kernel.org Subject: [PATCH v2 3/5] media: ov2680: Add vblank control Date: Mon, 15 Apr 2024 15:03:16 +0200 Message-ID: <20240415130318.234222-4-hdegoede@redhat.com> In-Reply-To: <20240415130318.234222-1-hdegoede@redhat.com> References: <20240415130318.234222-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Add vblank control to allow changing the framerate / higher exposure values. Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede --- Changes in v2: - Add error checking to __v4l2_ctrl_modify_range() and __v4l2_ctrl_s_ctrl() calls --- drivers/media/i2c/ov2680.c | 56 +++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 6c3d7862b2aa..1a246c87d289 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -75,6 +75,8 @@ #define OV2680_ACTIVE_START_TOP 8 #define OV2680_MIN_CROP_WIDTH 2 #define OV2680_MIN_CROP_HEIGHT 2 +#define OV2680_MIN_VBLANK 4 +#define OV2680_MAX_VBLANK 0xffff /* Fixed pre-div of 1/2 */ #define OV2680_PLL_PREDIV0 2 @@ -84,7 +86,7 @@ /* 66MHz pixel clock: 66MHz / 1704 * 1294 = 30fps */ #define OV2680_PIXELS_PER_LINE 1704 -#define OV2680_LINES_PER_FRAME 1294 +#define OV2680_LINES_PER_FRAME_30FPS 1294 /* Max exposure time is VTS - 8 */ #define OV2680_INTEGRATION_TIME_MARGIN 8 @@ -127,6 +129,7 @@ struct ov2680_ctrls { struct v4l2_ctrl *test_pattern; struct v4l2_ctrl *link_freq; struct v4l2_ctrl *pixel_rate; + struct v4l2_ctrl *vblank; }; struct ov2680_mode { @@ -394,8 +397,7 @@ static int ov2680_set_mode(struct ov2680_dev *sensor) sensor->mode.v_output_size, &ret); cci_write(sensor->regmap, OV2680_REG_TIMING_HTS, OV2680_PIXELS_PER_LINE, &ret); - cci_write(sensor->regmap, OV2680_REG_TIMING_VTS, - OV2680_LINES_PER_FRAME, &ret); + /* VTS gets set by the vblank ctrl */ cci_write(sensor->regmap, OV2680_REG_ISP_X_WIN, 0, &ret); cci_write(sensor->regmap, OV2680_REG_ISP_Y_WIN, 0, &ret); cci_write(sensor->regmap, OV2680_REG_X_INC, inc, &ret); @@ -469,6 +471,15 @@ static int ov2680_exposure_set(struct ov2680_dev *sensor, u32 exp) NULL); } +static int ov2680_exposure_update_range(struct ov2680_dev *sensor) +{ + int exp_max = sensor->mode.fmt.height + sensor->ctrls.vblank->val - + OV2680_INTEGRATION_TIME_MARGIN; + + return __v4l2_ctrl_modify_range(sensor->ctrls.exposure, 0, exp_max, + 1, exp_max); +} + static int ov2680_stream_enable(struct ov2680_dev *sensor) { int ret; @@ -635,7 +646,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *try_fmt; const struct v4l2_rect *crop; unsigned int width, height; - int ret = 0; + int def, max, ret = 0; crop = __ov2680_get_pad_crop(sensor, sd_state, format->pad, format->which); @@ -664,6 +675,21 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, sensor->mode.fmt = format->format; ov2680_calc_mode(sensor); + /* vblank range is height dependent adjust and reset to default */ + max = OV2680_MAX_VBLANK - height; + def = OV2680_LINES_PER_FRAME_30FPS - height; + ret = __v4l2_ctrl_modify_range(sensor->ctrls.vblank, OV2680_MIN_VBLANK, + max, 1, def); + if (ret) + goto unlock; + + ret = __v4l2_ctrl_s_ctrl(sensor->ctrls.vblank, def); + if (ret) + goto unlock; + + /* exposure range depends on vts which may have changed */ + ret = ov2680_exposure_update_range(sensor); + unlock: mutex_unlock(&sensor->lock); @@ -833,6 +859,13 @@ static int ov2680_s_ctrl(struct v4l2_ctrl *ctrl) struct ov2680_dev *sensor = to_ov2680_dev(sd); int ret; + /* Update exposure range on vblank changes */ + if (ctrl->id == V4L2_CID_VBLANK) { + ret = ov2680_exposure_update_range(sensor); + if (ret) + return ret; + } + /* Only apply changes to the controls if the device is powered up */ if (!pm_runtime_get_if_in_use(sensor->sd.dev)) { ov2680_set_bayer_order(sensor, &sensor->mode.fmt); @@ -855,6 +888,10 @@ static int ov2680_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEST_PATTERN: ret = ov2680_test_pattern_set(sensor, ctrl->val); break; + case V4L2_CID_VBLANK: + ret = cci_write(sensor->regmap, OV2680_REG_TIMING_VTS, + sensor->mode.fmt.height + ctrl->val, NULL); + break; default: ret = -EINVAL; break; @@ -913,8 +950,7 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) const struct v4l2_ctrl_ops *ops = &ov2680_ctrl_ops; struct ov2680_ctrls *ctrls = &sensor->ctrls; struct v4l2_ctrl_handler *hdl = &ctrls->handler; - int exp_max = OV2680_LINES_PER_FRAME - OV2680_INTEGRATION_TIME_MARGIN; - int ret = 0; + int def, max, ret = 0; v4l2_i2c_subdev_init(&sensor->sd, client, &ov2680_subdev_ops); sensor->sd.internal_ops = &ov2680_internal_ops; @@ -939,8 +975,9 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) ARRAY_SIZE(test_pattern_menu) - 1, 0, 0, test_pattern_menu); + max = OV2680_LINES_PER_FRAME_30FPS - OV2680_INTEGRATION_TIME_MARGIN; ctrls->exposure = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_EXPOSURE, - 0, exp_max, 1, exp_max); + 0, max, 1, max); ctrls->gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_ANALOGUE_GAIN, 0, 1023, 1, 250); @@ -951,6 +988,11 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) 0, sensor->pixel_rate, 1, sensor->pixel_rate); + max = OV2680_MAX_VBLANK - OV2680_DEFAULT_HEIGHT; + def = OV2680_LINES_PER_FRAME_30FPS - OV2680_DEFAULT_HEIGHT; + ctrls->vblank = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_VBLANK, + OV2680_MIN_VBLANK, max, 1, def); + if (hdl->error) { ret = hdl->error; goto cleanup_entity; From patchwork Mon Apr 15 13:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13630013 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5F5FE127E2F for ; Mon, 15 Apr 2024 13:03:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186224; cv=none; b=A+FCRj10y4zG1LFS+mOrS4CDmVlRVMGFpNTg4aDv2JM+7j3xBdn1QgEYswA0ByD+TASsD7z0dsXKMLuvtPTlO02GKfhDSXhZcq3KS/89/4THITeK53BuzGH4gp4VphQaGHrR+Dh+k+Udm3ftrWTachsesJI7RR4r0IctKrvarV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186224; c=relaxed/simple; bh=bEPArUTWrzamd6i5M0Ty67Hk9+jye2HDeJUrLCJH1cE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SqIrPy5iSPEHFE6Xv/SJLmavy4JQVUpD8tsvBu0v7tvnJfDZRmERxdV1bfn2vCeij841D1oNy4ejZuJwI9o0JVz0vrSbKnHTJFnoW9233kZBfgK9EGRhXtqPB6xc33wqoOpLIE3wIxgIc6+Rhkx6Hy10oZwVHHKDWaGPPT5Wk6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pe1Q9HfU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pe1Q9HfU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713186220; 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=x/dDUfV6mf9MevbuSaMGXYeUfYIgBvEQc/2A4SKOMt4=; b=Pe1Q9HfUSt8NS+gLSVJ3DtEk11cejtPI334iABOHb7pXjW1oLE8VxJbTsjLzCiFINx5api hHuMlhmf4ooFtL0GELk1qi1rMsTOsvkIbcBEx8HOgUZ0Ol/mYx8P+qavI2XWAPAstvxBn6 dIKynLn4gSQR7JmwmR7fMN5dKcgwYMk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-fWRU6yzDO9u2nScAv5dHIQ-1; Mon, 15 Apr 2024 09:03:36 -0400 X-MC-Unique: fWRU6yzDO9u2nScAv5dHIQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5706E3C0ED46; Mon, 15 Apr 2024 13:03:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C579112131D; Mon, 15 Apr 2024 13:03:35 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Rui Miguel Silva Cc: Hans de Goede , Mauro Carvalho Chehab , Kate Hsuan , Kieran Bingham , linux-media@vger.kernel.org Subject: [PATCH v2 4/5] media: ov2680: Add hblank control Date: Mon, 15 Apr 2024 15:03:17 +0200 Message-ID: <20240415130318.234222-5-hdegoede@redhat.com> In-Reply-To: <20240415130318.234222-1-hdegoede@redhat.com> References: <20240415130318.234222-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Add hblank control so that the sensor has all the mandatory controls for libcamera. Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede --- Changes in v2: - Add error checking to __v4l2_ctrl_modify_range() and set read-only flag after checking hdl->error --- drivers/media/i2c/ov2680.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index 1a246c87d289..e8ec2a6d27db 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -130,6 +130,7 @@ struct ov2680_ctrls { struct v4l2_ctrl *link_freq; struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *vblank; + struct v4l2_ctrl *hblank; }; struct ov2680_mode { @@ -689,6 +690,12 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd, /* exposure range depends on vts which may have changed */ ret = ov2680_exposure_update_range(sensor); + if (ret) + goto unlock; + + /* adjust hblank value for new width */ + def = OV2680_PIXELS_PER_LINE - width; + ret = __v4l2_ctrl_modify_range(sensor->ctrls.hblank, def, def, 1, def); unlock: mutex_unlock(&sensor->lock); @@ -993,6 +1000,10 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) ctrls->vblank = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_VBLANK, OV2680_MIN_VBLANK, max, 1, def); + def = OV2680_PIXELS_PER_LINE - OV2680_DEFAULT_WIDTH; + ctrls->hblank = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HBLANK, + def, def, 1, def); + if (hdl->error) { ret = hdl->error; goto cleanup_entity; @@ -1001,6 +1012,7 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) ctrls->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; ctrls->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; ctrls->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + ctrls->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; sensor->sd.ctrl_handler = hdl; From patchwork Mon Apr 15 13:03:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13630015 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 74F41128361 for ; Mon, 15 Apr 2024 13:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186225; cv=none; b=rdP+UDGeXASuwclsmNJxjkz1xowbqjAl5HqeMswM2csYr96MFjOIhEWV7SmYiJk6HfDY/sQjBRGV3w5FoOFuW7rMb33EFXIgWB6WZ4xl8rV8BkrYzTmk/EUHqtv/sqW3sZPjzNfaxM8bnU0y2izzSQw6kZG6nNSmiJE68oIiqe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713186225; c=relaxed/simple; bh=RjOM+zY+lr15oCkXtk8/8oSu0AyjCcJCx8StnLJ07p0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cN8ZlpD1qIhbRnjlOOgxzf8ihNuraFxTZS4C2CeQWqrJtBWzySFnT41As+5iYsuuB/GH1JoO91rPJlpyN+UDGhlOSxTR6o651ChMdxKU64gxMbs/b041wQd49p/0Pm/kYpXBo1mnkgcCUlHce9yAGd1wuGr5Nju4fVvb2VLdOyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AWC8jLo3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AWC8jLo3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713186222; 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=ufrGXuakCTM/hzn6KUyp9Vnvpd3dyrREV21w5m5mQlw=; b=AWC8jLo32c2h/d5huX8TN8kYj0wiclQ4r1jlY5Sq2A3FLE6ZlBph+A7KH0u5itZht+YvyW Xj5uwiIG4dJl2Jd6rwDqclC3I2uLoAEJ7kH3OQWf7FgOqMg5QQmDCNuX+xoBsz/D4BmmeP /pF4y7I5gPcsOG26D5W5dYQz9PANRU8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-2wm4b_7_M6SydqICdGzvJw-1; Mon, 15 Apr 2024 09:03:38 -0400 X-MC-Unique: 2wm4b_7_M6SydqICdGzvJw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8237D1C0C65D; Mon, 15 Apr 2024 13:03:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.195.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89AA61121313; Mon, 15 Apr 2024 13:03:36 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Rui Miguel Silva Cc: Hans de Goede , Mauro Carvalho Chehab , Kate Hsuan , Kieran Bingham , linux-media@vger.kernel.org Subject: [PATCH v2 5/5] media: ov2680: Add camera orientation and sensor rotation controls Date: Mon, 15 Apr 2024 15:03:18 +0200 Message-ID: <20240415130318.234222-6-hdegoede@redhat.com> In-Reply-To: <20240415130318.234222-1-hdegoede@redhat.com> References: <20240415130318.234222-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Add camera orientation and sensor rotation controls using the v4l2_fwnode_device_parse() and v4l2_ctrl_new_fwnode_properties() helpers. Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede --- Changes in v2: -Use hdl->error to error check v4l2_ctrl_new_fwnode_properties() --- drivers/media/i2c/ov2680.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c index e8ec2a6d27db..6236a13a4981 100644 --- a/drivers/media/i2c/ov2680.c +++ b/drivers/media/i2c/ov2680.c @@ -957,6 +957,7 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) const struct v4l2_ctrl_ops *ops = &ov2680_ctrl_ops; struct ov2680_ctrls *ctrls = &sensor->ctrls; struct v4l2_ctrl_handler *hdl = &ctrls->handler; + struct v4l2_fwnode_device_properties props; int def, max, ret = 0; v4l2_i2c_subdev_init(&sensor->sd, client, &ov2680_subdev_ops); @@ -1004,6 +1005,12 @@ static int ov2680_v4l2_register(struct ov2680_dev *sensor) ctrls->hblank = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HBLANK, def, def, 1, def); + ret = v4l2_fwnode_device_parse(sensor->dev, &props); + if (ret) + goto cleanup_entity; + + v4l2_ctrl_new_fwnode_properties(hdl, ops, &props); + if (hdl->error) { ret = hdl->error; goto cleanup_entity;