From patchwork Mon Jul 3 20:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 698899 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 527EFC001DD for ; Mon, 3 Jul 2023 20:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbjGCU3c (ORCPT ); Mon, 3 Jul 2023 16:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjGCU3b (ORCPT ); Mon, 3 Jul 2023 16:29:31 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7221BAF for ; Mon, 3 Jul 2023 13:29:30 -0700 (PDT) Received: from uno.localdomain (85-160-45-219.reb.o2.cz [85.160.45.219]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BBB18163D; Mon, 3 Jul 2023 22:28:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1688416125; bh=LT5UE6f4HX6W4EjBCuEdmm8h2SzCRv60eGn+B66DeZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0X5jPFhpWIWB4+AlOPmdQXTkdlDzrRfDtsZhEknHxMtZY3WnsRB6sStO7IrtUof5 8gHkUkE50ShXutI3E1zS19IkDqdAk/Vmz/gHaBZ6CXDuQy4MxAINQLtQMIatV+bHtx 1rKXLK41X1k98sm+j+QXa0uJPL8Vt1rQNiePjlHk= From: Jacopo Mondi To: linux-media@vger.kernel.org Cc: Jacopo Mondi , Hans Verkuil , Sakari Ailus , Laurent Pinchart Subject: [PATCH 1/2] Documentation: v4l: Flip handling for RAW sensors Date: Mon, 3 Jul 2023 22:29:09 +0200 Message-Id: <20230703202910.31142-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703202910.31142-1-jacopo.mondi@ideasonboard.com> References: <20230703202910.31142-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Document the requirement of notifying to userspace the possible re-ordering of the color sample components when a vertical or horizontal flip is applied to a RAW camera sensor. Signed-off-by: Jacopo Mondi --- Documentation/driver-api/media/camera-sensor.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/driver-api/media/camera-sensor.rst b/Documentation/driver-api/media/camera-sensor.rst index 93f4f2536c25..ee4a7fe5f72a 100644 --- a/Documentation/driver-api/media/camera-sensor.rst +++ b/Documentation/driver-api/media/camera-sensor.rst @@ -173,3 +173,19 @@ V4L2_CID_VFLIP controls with the values programmed by the register sequences. The default values of these controls shall be 0 (disabled). Especially these controls shall not be inverted, independently of the sensor's mounting rotation. + +Flip handling for raw camera sensors +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Applying vertical and horizontal flips on raw camera sensors inverts the color +sample reading direction on the sensor's pixel array. This causes the +re-ordering of the color samples on the sensor's output frame. As an example, a +raw camera sensor with a Bayer pattern color filter array and a native RGGB +Bayer order will produce frames with GRBG component ordering when a vertical +flip is applied. Camera sensor drivers where inverting the reading order +direction causes a re-ordering of the color components are requested to register +the ``V4L2_CID_VFLIP`` and ``V4L2_CID_HFLIP`` controls with the +``V4L2_CTRL_FLAG_MODIFY_LAYOUT`` flag enabled to notify userspace that enabling +a flip can potentially change the output buffer content layout. Flips should +also be taken into account when enumerating and handling media bus formats +on the camera sensor source pads. From patchwork Mon Jul 3 20:29:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 699145 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E044FC001B3 for ; Mon, 3 Jul 2023 20:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjGCU3d (ORCPT ); Mon, 3 Jul 2023 16:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbjGCU3b (ORCPT ); Mon, 3 Jul 2023 16:29:31 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1ADCE4E for ; Mon, 3 Jul 2023 13:29:30 -0700 (PDT) Received: from uno.localdomain (85-160-45-219.reb.o2.cz [85.160.45.219]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 662642589; Mon, 3 Jul 2023 22:28:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1688416125; bh=uckIxM5HxR8qadxd/UPKRwAvbaP6BUyy7y77anqZB4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fd33aeSLnm9j6jLVqzPi5e59UK/e7yjz5TiybVsMn9NRm5ZDaQMXEKhq8+NH2Vj/h 7r5sshY1tURZEI494lR302SJY06C/4DYCPVudfWPZF+xt3azzPFcSXMLg7NDGE5+nL GSfOlX6mc/JvUyYbYguqC9vzkzRYwCM6MnlS7B3w= From: Jacopo Mondi To: linux-media@vger.kernel.org Cc: Jacopo Mondi , Hans Verkuil , Sakari Ailus , Laurent Pinchart Subject: [PATCH 2/2] Documentation: v4l: Exposure/gain for camera sensor Date: Mon, 3 Jul 2023 22:29:10 +0200 Message-Id: <20230703202910.31142-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703202910.31142-1-jacopo.mondi@ideasonboard.com> References: <20230703202910.31142-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Document the suggested way to exposure controls for exposure and gain for camera sensor drivers. Signed-off-by: Jacopo Mondi --- .../driver-api/media/camera-sensor.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/driver-api/media/camera-sensor.rst b/Documentation/driver-api/media/camera-sensor.rst index ee4a7fe5f72a..dfe8f35aecea 100644 --- a/Documentation/driver-api/media/camera-sensor.rst +++ b/Documentation/driver-api/media/camera-sensor.rst @@ -189,3 +189,22 @@ the ``V4L2_CID_VFLIP`` and ``V4L2_CID_HFLIP`` controls with the a flip can potentially change the output buffer content layout. Flips should also be taken into account when enumerating and handling media bus formats on the camera sensor source pads. + +Exposure and Gain Control +------------------------- + +Camera sensor drivers that allows applications to control the image exposure +and gain should do so by exposing dedicated controls to applications. + +Exposure time is controlled by registering the ``V4L2_CID_EXPOSURE`` control. +The control definition does not specify a unit to allow maximum flexibility +for multiple device types, but when used for camera sensor driver it should be +expressed in unit of lines whenever possible. + +Camera sensor driver should try whenever possible to distinguish between the +analogue and digital gain control functions. Analogue gain is a multiplier +factor applied to all color channels on the pixel array before they get +converted in the digital domain. It should be be made controllable by +registering the ``V4L2_CID_ANALOGUE_GAIN`` control, expressed as a device +specific gain code. Digital gain control is optional and should be exposed to +applications by registering ``V4L2_CID_DIGITAL_GAIN``. Camera sensor drivers are