Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6924653rwd; Tue, 6 Jun 2023 04:06:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+4rRxmPo/YFExC6v0V1xRO6YRJxKJ2rM2epRbCCk+M2LKcbXpdUdH2q2DApyg2cS9T/jw X-Received: by 2002:a05:620a:80c:b0:75d:435b:b482 with SMTP id s12-20020a05620a080c00b0075d435bb482mr1374692qks.33.1686049607430; Tue, 06 Jun 2023 04:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686049607; cv=none; d=google.com; s=arc-20160816; b=tINsMKIlHSRkoC6V0o1/4dqpahD561DR09nD5K3mXhH2zoSRmHofdfCfVaHntQYBh4 M+VZt7IJyfdCnzumH4bcsl1lEdKOZINmXqildatPZBjuAolrHoDmSoXU/bp20lzwhmjD hdQj/MsEjwMJcJUcThaJqQ7AbYHGcBwyFAB5I3jD8vevaQsYdnzX51Z+bjIgqVj8XlRE gLD2mJ6/tPkCHco1+7ejVOZp7wJJ+YrskA2djXnL5fsKCDSjiHcxNwFzIH4WPw7fl7ch /9SR6+B1oy2LdMm4SEm5Hpjx6GP9NuMvinT5im2Z8oydyApJxj0T/7VkAZ0SAncLfEKi BB8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aRqKhGnlaqoHaJo3/OjQwqbS/TpCJN0bn4kwvJDOJKk=; b=ovhTmzH9VfB7RlFOE7UIExkg9BqVmkfRZSJ+YYscKTbdzD0KLwy66InDLJBDwX+rNu ZI/u9E/PjMI/He+HWcknsR8dRPoB62hpWMMWnX+Hni4vQDSxTH+3q80szhFbUl4KaJ7u VZx0vVnb5FOS3GoXQvbRdh+Txw0gJYfvj/c2oiv08YkpmNu1nssy6KRyu3nRmLP1J5yM t2HWgxudkcvX9dV2/0rdRaQxz7ekwtIJQG1YiF6KUbZCcE3q1R4dddZNfnxscUw+emKv nWKcL6r2RsgwIT1Po9Fpc4Q8t9Il54yUXzcbdVkJ+3sXfM/NVlYOkXMA9U1b5+vbo+tQ spHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=pVi4BN5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a05620a13ed00b0074ae1273f52si5627423qkl.228.2023.06.06.04.06.32; Tue, 06 Jun 2023 04:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=pVi4BN5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237232AbjFFK6e (ORCPT + 99 others); Tue, 6 Jun 2023 06:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237007AbjFFK53 (ORCPT ); Tue, 6 Jun 2023 06:57:29 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B57310C4 for ; Tue, 6 Jun 2023 03:57:28 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-43b87490a27so472556137.0 for ; Tue, 06 Jun 2023 03:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1686049047; x=1688641047; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aRqKhGnlaqoHaJo3/OjQwqbS/TpCJN0bn4kwvJDOJKk=; b=pVi4BN5DvM+M/f2K1ZKvmhUAi0jM6E05abSte3DYeqSGo6blxMNO3o06T0Y0jD+53n z/IBHZmUMR7YJKaqHnHFc8VmHmON8epBGTwNIQoiEzKIJvSfVMqrMu6/yQA3Os7LqPVU MOif+3F2XRis+J5sfP447bXctfS8luyngoYJ+X4x1Q1RsMNX5YHfKIZamv3cDqLkn0Zy c2VxhJSf04mpEBoGOdRX1y+7VFm5lD4fusXSSATkrx8LhZkCYb4TQlJbH/3587J4yvlj uQ3WaVYKeRwTZnqDQ7JhBqGHIH1KPnzTfmno8p2awysJitE5RZiUYnes6vALrllKOQka Go5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686049047; x=1688641047; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aRqKhGnlaqoHaJo3/OjQwqbS/TpCJN0bn4kwvJDOJKk=; b=jl+/YNRra+lZ+7a0P8aNVleS5t105DSW5Z7DBHiMUOcYscCZGEB1GrSbnsM7+gjuyg j1EmpOLs6e+7I9wYyTyy84VkYRcOICCobFE2kYeoyhkWhOV92HSlrkHOjJxZgNrDK27N dFKIbLycosLkw0lJrjjWIgGx4A3CgBNR/JLdkYkze+MV6hxR/wq6yOhdkF0iCVp4CvNh KNSDKX+DYDwa+0boxC3VKAI7WF/jIc9Pqfja5YAGrlRU8Arhk1UV262x+D8YZY8Dwngm 6FQisASvxhtTRX9NeqIDDiJCTVBwLdpomgYHdLJntIJC67r4uOLR1E9t60xlBhj83Qye CE4w== X-Gm-Message-State: AC+VfDwr0+5/IsoNy4PQ4X7s4fhMm1RaUrZ7rq6Ch4Dud+cUiupm2El0 C1wxiClaZB/1qSKHhxAS++TQsYXUpyMuUlMLskAQ5w== X-Received: by 2002:a67:b408:0:b0:43b:3eec:5e36 with SMTP id x8-20020a67b408000000b0043b3eec5e36mr1114900vsl.15.1686049047327; Tue, 06 Jun 2023 03:57:27 -0700 (PDT) MIME-Version: 1.0 References: <20230406-feature-controls-lens-v2-0-faa8ad2bc404@wolfvision.net> <20230406-feature-controls-lens-v2-5-faa8ad2bc404@wolfvision.net> In-Reply-To: <20230406-feature-controls-lens-v2-5-faa8ad2bc404@wolfvision.net> From: Dave Stevenson Date: Tue, 6 Jun 2023 11:57:11 +0100 Message-ID: Subject: Re: [PATCH RFC v2 5/6] media: v4l2-ctrls: add lens calibration controls To: Michael Riesch Cc: Mauro Carvalho Chehab , libcamera-devel@lists.libcamera.org, Laurent Pinchart , Sakari Ailus , Hans Verkuil , Matthias Fend , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael On Tue, 25 Apr 2023 at 10:45, Michael Riesch wrote: > > Add the controls V4L2_CID_LENS_CALIB_CONTROL and V4L2_CID_LENS_CALIB_STATUS > that facilitate the control of the lens group calibration procedure. > > Signed-off-by: Michael Riesch > --- > .../userspace-api/media/v4l/ext-ctrls-camera.rst | 35 ++++++++++++++++++++++ > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 +++ > include/uapi/linux/v4l2-controls.h | 12 ++++++++ > 3 files changed, 51 insertions(+) > > diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst > index a17620ab03b9..8b54a0f3a617 100644 > --- a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst > +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst > @@ -297,6 +297,41 @@ enum v4l2_auto_focus_range - > (V4L2_CID_ZOOM_ABSOLUTE and V4L2_CID_ZOOM_RELATIVE). The unit is > driver-specific. The value should be a positive integer. > > +``V4L2_CID_LENS_CALIB_CONTROL (bitmask)`` > + Control the calibration procedure (or individual parts thereof) of the lens > + groups. For example, this could include the mechanical range detection > + of zoom lens motors. This is a write-only control. > + > +.. tabularcolumns:: |p{6.8cm}|p{10.7cm}| > + > +.. flat-table:: > + :header-rows: 0 > + :stub-columns: 0 > + > + * - ``V4L2_LENS_CALIB_STOP`` > + - Stop the lens calibration procedure. > + * - ``V4L2_LENS_CALIB_START`` > + - Start the complete lens calibration procedure. > + > +``V4L2_CID_LENS_CALIB_STATUS (bitmask)`` > + The status of the calibration procedure (or individual parts thereof) of > + the lens groups. This is a read-only control. > + > +.. tabularcolumns:: |p{6.8cm}|p{10.7cm}| > + > +.. flat-table:: > + :header-rows: 0 > + :stub-columns: 0 > + > + * - ``V4L2_LENS_CALIB_IDLE`` > + - Lens calibration procedure has not yet been started. Idle as a term would generally encompass both COMPLETE and FAILED as well as this case. Use V4L2_LENS_CALIB_UNCABLIBRATED or similar instead? > + * - ``V4L2_LENS_CALIB_BUSY`` > + - Lens calibration procedure is in progress. > + * - ``V4L2_LENS_CALIB_COMPLETE`` > + - Lens calibration procedure is complete. > + * - ``V4L2_LENS_CALIB_FAILED`` > + - Lens calibration procedure has failed. > + > ``V4L2_CID_IRIS_ABSOLUTE (integer)`` > This control sets the camera's aperture to the specified value. The > unit is undefined. Larger values open the iris wider, smaller values > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > index 3ef465ba73bd..faddfecba6d9 100644 > --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c > +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c > @@ -1050,6 +1050,8 @@ const char *v4l2_ctrl_get_name(u32 id) > case V4L2_CID_ZOOM_STATUS: return "Zoom, Status"; > case V4L2_CID_FOCUS_SPEED: return "Focus, Speed"; > case V4L2_CID_ZOOM_SPEED: return "Zoom, Speed"; > + case V4L2_CID_LENS_CALIB_CONTROL: return "Lens Calibration, Control"; > + case V4L2_CID_LENS_CALIB_STATUS: return "Lens Calibration, Status"; > > /* FM Radio Modulator controls */ > /* Keep the order of the 'case's the same as in v4l2-controls.h! */ > @@ -1596,6 +1598,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > case V4L2_CID_FOCUS_RELATIVE: > case V4L2_CID_IRIS_RELATIVE: > case V4L2_CID_ZOOM_RELATIVE: > + case V4L2_CID_LENS_CALIB_CONTROL: > *flags |= V4L2_CTRL_FLAG_WRITE_ONLY | > V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; > break; > @@ -1603,6 +1606,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, > case V4L2_CID_FOCUS_STATUS: > case V4L2_CID_ZOOM_CURRENT: > case V4L2_CID_ZOOM_STATUS: > + case V4L2_CID_LENS_CALIB_STATUS: > *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_VOLATILE; > break; > case V4L2_CID_FLASH_STROBE_STATUS: > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h > index 8d84508d4db8..24c0eb5f4d29 100644 > --- a/include/uapi/linux/v4l2-controls.h > +++ b/include/uapi/linux/v4l2-controls.h > @@ -1004,6 +1004,18 @@ enum v4l2_auto_focus_range { > #define V4L2_CID_FOCUS_SPEED (V4L2_CID_CAMERA_CLASS_BASE+41) > #define V4L2_CID_ZOOM_SPEED (V4L2_CID_CAMERA_CLASS_BASE+42) > > +#define V4L2_LENS_CALIB_STOP (0 << 0) > +#define V4L2_LENS_CALIB_START (1 << 0) Why a bitmask? What would setting both bits at the same time mean? > + > +#define V4L2_CID_LENS_CALIB_CONTROL (V4L2_CID_CAMERA_CLASS_BASE+43) > + > +#define V4L2_LENS_CALIB_IDLE (0 << 0) > +#define V4L2_LENS_CALIB_BUSY (1 << 0) > +#define V4L2_LENS_CALIB_COMPLETE (1 << 1) > +#define V4L2_LENS_CALIB_FAILED (1 << 2) Ditto. The status will only ever be one of these values, other than possibly COMPLETE | FAILED. Renaming COMPLETE to SUCCESS would remove that ambiguity and definitely make it one bit at a time. Dave > + > +#define V4L2_CID_LENS_CALIB_STATUS (V4L2_CID_CAMERA_CLASS_BASE+44) > + > /* FM Modulator class control IDs */ > > #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) > > -- > 2.37.2 >