From patchwork Tue Aug 27 09:23:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B87CF14DE for ; Tue, 27 Aug 2019 09:22:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96B9D21872 for ; Tue, 27 Aug 2019 09:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728676AbfH0JW3 (ORCPT ); Tue, 27 Aug 2019 05:22:29 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:39317 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfH0JW3 (ORCPT ); Tue, 27 Aug 2019 05:22:29 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 629C61C000A; Tue, 27 Aug 2019 09:22:26 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, Rob Herring Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), devicetree@vger.kernel.org Subject: [PATCH v2 01/10] media: dt-bindings: Document 'location' property Date: Tue, 27 Aug 2019 11:23:27 +0200 Message-Id: <20190827092339.8858-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add the 'location' device property, used to specify the camera device mounting position. The property is particularly meaningful for mobile devices with a well defined usage orientation. Signed-off-by: Jacopo Mondi --- .../devicetree/bindings/media/video-interfaces.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.23.0 diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt index f884ada0bffc..865f4142f432 100644 --- a/Documentation/devicetree/bindings/media/video-interfaces.txt +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt @@ -89,6 +89,16 @@ Optional properties but a number of degrees counter clockwise. Typical values are 0 and 180 (upside down). +- location: The camera sensor mounting location, expressed as a position + relative to the usage orientation of the device the sensor is installed on. + Possible values are: + 0 - Front. The image sensor is mounted on the front facing side of the device. + For mobile devices such as smartphones, tablets and laptops the front side is + the user facing side of the device. + 1 - Back. The image sensor is mounted on the back side of the device, which is + defined as the opposite side of the front facing one. + 2 - External. The image sensor is connected to the device by extension cables, + and can be freely moved, regardless of the device position. Optional endpoint properties ---------------------------- From patchwork Tue Aug 27 09:23:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B11131395 for ; Tue, 27 Aug 2019 09:22:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A3EE21872 for ; Tue, 27 Aug 2019 09:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728989AbfH0JWc (ORCPT ); Tue, 27 Aug 2019 05:22:32 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:50885 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfH0JWb (ORCPT ); Tue, 27 Aug 2019 05:22:31 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 69D5D1C0003; Tue, 27 Aug 2019 09:22:28 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 02/10] media: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_LOCATION Date: Tue, 27 Aug 2019 11:23:28 +0200 Message-Id: <20190827092339.8858-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add documentation for the V4L2_CID_CAMERA_SENSOR_LOCATION camera control. The newly added read-only control reports the camera device mounting position. Signed-off-by: Jacopo Mondi --- .../media/uapi/v4l/ext-ctrls-camera.rst | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst index 51c1d5c9eb00..ecf151f3f0f4 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst @@ -510,6 +510,40 @@ enum v4l2_scene_mode - value down. A value of zero stops the motion if one is in progress and has no effect otherwise. +``V4L2_CID_CAMERA_SENSOR_LOCATION (integer)`` + This read-only control describes the camera sensor location by + reporting its mounting position on the device where the camera is + installed. The control value is constant and not modifiable by software + and its value is retrieved from the firmware interface by parsing the + 'location' property. This control is particularly meaningful for + devices which have a well defined orientation, such as phones, laptops + and portable devices as the camera location is expressed as a position + relative to the device intended usage orientation. In example, a camera + sensor installed on the user-facing side of a phone, a tablet or a + laptop device is said to be installed in the ``V4L2_LOCATION_FRONT`` + location while camera sensors installed on the side opposed to the + front one are said to be installed in the ``V4L2_LOCATION_BACK`` + location. Camera sensors connected to the device by extension cables + which are freely movable regardless of the device orientation, such as + webcams and digital cameras, are said to be have + ``V4L2_LOCATION_EXTERNAL`` location. + + + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_LOCATION_FRONT`` + - The camera sensor is located on the front side of the device. + * - ``V4L2_LOCATION_BACK`` + - The camera sensor is located on the back side of the device. + * - ``V4L2_LOCATION_EXTERNAL`` + - The camera sensor is connected by extension cables to the device and + it's freely movable. + + + .. [#f1] This control may be changed to a menu control in the future, if more options are required. From patchwork Tue Aug 27 09:23:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FAD114DE for ; Tue, 27 Aug 2019 09:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D47C21883 for ; Tue, 27 Aug 2019 09:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729167AbfH0JWd (ORCPT ); Tue, 27 Aug 2019 05:22:33 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:46809 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfH0JWd (ORCPT ); Tue, 27 Aug 2019 05:22:33 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 6EC041C0008; Tue, 27 Aug 2019 09:22:30 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 03/10] media: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_ROTATION Date: Tue, 27 Aug 2019 11:23:29 +0200 Message-Id: <20190827092339.8858-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add documentation for the V4L2_CID_CAMERA_SENSOR_ROTATION camera control. The newly added read-only control reports the camera device mounting rotation. Signed-off-by: Jacopo Mondi --- Documentation/media/uapi/v4l/ext-ctrls-camera.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst index ecf151f3f0f4..03d1c23d18f7 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst @@ -544,6 +544,15 @@ enum v4l2_scene_mode - +``V4L2_CID_CAMERA_SENSOR_ROTATION (integer)`` + This read-only control describes the camera sensor orientation by + reporting its mounting rotation in respect to the device intended usage + orientation, expressed in counter clockwise degrees. The control value is + constant and not modifiable by software and its value is retrieved from the + firmware interface by parsing the 'rotation' property. Typical values are 0 + degrees for upright mounted sensors and 180 degrees for sensors mounted + upside down. + .. [#f1] This control may be changed to a menu control in the future, if more options are required. From patchwork Tue Aug 27 09:23:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C838C14DE for ; Tue, 27 Aug 2019 09:22:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A96FB22CBB for ; Tue, 27 Aug 2019 09:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729277AbfH0JWf (ORCPT ); Tue, 27 Aug 2019 05:22:35 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:52563 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfH0JWf (ORCPT ); Tue, 27 Aug 2019 05:22:35 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 695431C000B; Tue, 27 Aug 2019 09:22:32 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 04/10] media: v4l2-ctrl: Add V4L2_CID_CAMERA_SENSOR_LOCATION Date: Tue, 27 Aug 2019 11:23:30 +0200 Message-Id: <20190827092339.8858-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for the newly defined V4L2_CID_CAMERA_SENSOR_LOCATION read-only control used to report the camera device mounting position. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ include/uapi/linux/v4l2-controls.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 1d8f38824631..db7124494530 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -994,6 +994,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_AUTO_FOCUS_RANGE: return "Auto Focus, Range"; case V4L2_CID_PAN_SPEED: return "Pan, Speed"; case V4L2_CID_TILT_SPEED: return "Tilt, Speed"; + case V4L2_CID_CAMERA_SENSOR_LOCATION: return "Camera Sensor Location"; /* FM Radio Modulator controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1318,6 +1319,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, break; case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: + case V4L2_CID_CAMERA_SENSOR_LOCATION: *type = V4L2_CTRL_TYPE_INTEGER; *flags |= V4L2_CTRL_FLAG_READ_ONLY; break; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index a2669b79b294..387c2c8553cb 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -912,6 +912,11 @@ enum v4l2_auto_focus_range { #define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32) #define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33) +#define V4L2_CID_CAMERA_SENSOR_LOCATION (V4L2_CID_CAMERA_CLASS_BASE+34) +#define V4L2_LOCATION_FRONT 0 +#define V4L2_LOCATION_BACK 1 +#define V4L2_LOCATION_EXTERNAL 2 + /* FM Modulator class control IDs */ #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) From patchwork Tue Aug 27 09:23:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6310514DE for ; Tue, 27 Aug 2019 09:22:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42B1921872 for ; Tue, 27 Aug 2019 09:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729292AbfH0JWj (ORCPT ); Tue, 27 Aug 2019 05:22:39 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35307 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfH0JWj (ORCPT ); Tue, 27 Aug 2019 05:22:39 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 32E1A1C000A; Tue, 27 Aug 2019 09:22:36 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 05/10] media: v4l2-ctrl: Add V4L2_CID_CAMERA_SENSOR_ROTATION Date: Tue, 27 Aug 2019 11:23:32 +0200 Message-Id: <20190827092339.8858-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for the newly defined V4L2_CID_CAMERA_SENSOR_ROTATION read-only control used to report the camera device mounting rotation. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++ include/uapi/linux/v4l2-controls.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index db7124494530..b7af47a25125 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -995,6 +995,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_PAN_SPEED: return "Pan, Speed"; case V4L2_CID_TILT_SPEED: return "Tilt, Speed"; case V4L2_CID_CAMERA_SENSOR_LOCATION: return "Camera Sensor Location"; + case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation"; /* FM Radio Modulator controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1320,6 +1321,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: case V4L2_CID_CAMERA_SENSOR_LOCATION: + case V4L2_CID_CAMERA_SENSOR_ROTATION: *type = V4L2_CTRL_TYPE_INTEGER; *flags |= V4L2_CTRL_FLAG_READ_ONLY; break; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 387c2c8553cb..f2be7a99818e 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -917,6 +917,8 @@ enum v4l2_auto_focus_range { #define V4L2_LOCATION_BACK 1 #define V4L2_LOCATION_EXTERNAL 2 +#define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35) + /* FM Modulator class control IDs */ #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) From patchwork Tue Aug 27 09:23:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 058DD1395 for ; Tue, 27 Aug 2019 09:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E406321872 for ; Tue, 27 Aug 2019 09:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729433AbfH0JWo (ORCPT ); Tue, 27 Aug 2019 05:22:44 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:47459 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfH0JWo (ORCPT ); Tue, 27 Aug 2019 05:22:44 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 3271E1C0003; Tue, 27 Aug 2019 09:22:40 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 06/10] media: v4l2-fwnode: Add helper to register controls from fw Date: Tue, 27 Aug 2019 11:23:34 +0200 Message-Id: <20190827092339.8858-9-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add the 'v4l2_fwnode_register_controls()' helper to v4l2-fwnode. The function parses the device node and endpoint firmware properties to which a v4l2 control is associated to and registers the control with the provided handler. Signed-off-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-fwnode.c | 57 +++++++++++++++++++++++++++ include/media/v4l2-fwnode.h | 30 ++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 3bd1888787eb..669801fceb64 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -595,6 +596,62 @@ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link) } EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link); +int v4l2_fwnode_register_controls(struct fwnode_handle *fwnode, + struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ctrl_ops) +{ + u32 val; + int ret; + + ret = fwnode_property_read_u32(fwnode, "location", &val); + if (!ret) { + switch (val) { + case V4L2_LOCATION_FRONT: + case V4L2_LOCATION_BACK: + case V4L2_LOCATION_EXTERNAL: + break; + default: + pr_warn("Unsupported location: %u\n", val); + return -EINVAL; + } + + if (v4l2_ctrl_find(hdl, V4L2_CID_CAMERA_SENSOR_LOCATION)) + pr_debug("Skip control '%s': already registered", + v4l2_ctrl_get_name( + V4L2_CID_CAMERA_SENSOR_LOCATION)); + else + v4l2_ctrl_new_std(hdl, ctrl_ops, + V4L2_CID_CAMERA_SENSOR_LOCATION, + val, val, 1, val); + } + + ret = fwnode_property_read_u32(fwnode, "rotation", &val); + if (!ret) { + if (val > 360) { + pr_warn("Unsupported rotation: %u\n", val); + return -EINVAL; + } + + if (v4l2_ctrl_find(hdl, V4L2_CID_CAMERA_SENSOR_ROTATION)) + pr_debug("Skip control '%s': already registered", + v4l2_ctrl_get_name( + V4L2_CID_CAMERA_SENSOR_ROTATION)); + else + v4l2_ctrl_new_std(hdl, ctrl_ops, + V4L2_CID_CAMERA_SENSOR_ROTATION, + val, val, 1, val); + } + + if (hdl->error) { + pr_warn("Failed to register controls from firmware: %d\n", + hdl->error); + return hdl->error; + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_fwnode_register_controls); + static int v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev, struct v4l2_async_notifier *notifier, diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f6a7bcd13197..0dad6968bde9 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -25,6 +25,8 @@ struct fwnode_handle; struct v4l2_async_notifier; struct v4l2_async_subdev; +struct v4l2_ctrl_handler; +struct v4l2_ctrl_ops; #define V4L2_FWNODE_CSI2_MAX_DATA_LANES 4 @@ -233,6 +235,34 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, */ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); +/** + * v4l2_fwnode_register_controls() - parse device and endpoint fwnode + * properties and register a v4l2 control + * for each of them + * @fwnode: pointer to the device fwnode handle + * @hdl: pointer to the v4l2 control handler to register controls with + * @ctrl_ops: pointer to the v4l2 control operations to register with the handler + * + * Parse the @fwnode device and endpoint properties to which a v4l2 control + * is associated and register them with the provided handler @hdl. + * Currently the following v4l2 controls are parsed and registered: + * - V4L2_CID_CAMERA_SENSOR_LOCATION; + * - V4L2_CID_CAMERA_SENSOR_ROTATION; + * + * Controls already registered by the caller with the @hdl control handler are + * not overwritten. Callers should register the controls they want to handle + * themselves before calling this function. + * + * NOTE: This function locks the @hdl control handler mutex, the caller shall + * not hold the lock when calling this function. + * + * Return: 0 on success, -EINVAL if the fwnode properties are not correctly + * specified. + */ +int v4l2_fwnode_register_controls(struct fwnode_handle *fwnode, + struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ctrl_ops); + /** * typedef parse_endpoint_func - Driver's callback function to be called on * each V4L2 fwnode endpoint. From patchwork Tue Aug 27 09:23:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E28E1395 for ; Tue, 27 Aug 2019 09:22:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D3DA21872 for ; Tue, 27 Aug 2019 09:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729434AbfH0JWp (ORCPT ); Tue, 27 Aug 2019 05:22:45 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:58235 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729357AbfH0JWp (ORCPT ); Tue, 27 Aug 2019 05:22:45 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 3C5E91C000A; Tue, 27 Aug 2019 09:22:42 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 07/10] media: i2c: ov5670: Register controls from firmware Date: Tue, 27 Aug 2019 11:23:35 +0200 Message-Id: <20190827092339.8858-10-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced helper to parse properties from firmware and register the associated v4l2 control. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/ov5670.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c index 041fcbb4eebd..2bc57e85f721 100644 --- a/drivers/media/i2c/ov5670.c +++ b/drivers/media/i2c/ov5670.c @@ -7,6 +7,7 @@ #include #include #include +#include #define OV5670_REG_CHIP_ID 0x300a #define OV5670_CHIP_ID 0x005670 @@ -2059,6 +2060,7 @@ static const struct v4l2_ctrl_ops ov5670_ctrl_ops = { /* Initialize control handlers */ static int ov5670_init_controls(struct ov5670 *ov5670) { + struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); struct v4l2_ctrl_handler *ctrl_hdlr; s64 vblank_max; s64 vblank_def; @@ -2129,6 +2131,11 @@ static int ov5670_init_controls(struct ov5670 *ov5670) goto error; } + ret = v4l2_fwnode_register_controls(dev_fwnode(&client->dev), + ctrl_hdlr, &ov5670_ctrl_ops); + if (ret) + goto error; + ov5670->sd.ctrl_handler = ctrl_hdlr; return 0; From patchwork Tue Aug 27 09:23:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACBED14DE for ; Tue, 27 Aug 2019 09:22:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9552F217F5 for ; Tue, 27 Aug 2019 09:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729439AbfH0JWr (ORCPT ); Tue, 27 Aug 2019 05:22:47 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:49075 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729357AbfH0JWq (ORCPT ); Tue, 27 Aug 2019 05:22:46 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id E9A311C0009; Tue, 27 Aug 2019 09:22:43 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 08/10] media: i2c: ov13858: Register controls from firmware Date: Tue, 27 Aug 2019 11:23:36 +0200 Message-Id: <20190827092339.8858-11-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the newly introduced helper to parse properties from firmware and register the associated v4l2 control. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/ov13858.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c index aac6f77afa0f..d06be9b1e8d5 100644 --- a/drivers/media/i2c/ov13858.c +++ b/drivers/media/i2c/ov13858.c @@ -7,6 +7,7 @@ #include #include #include +#include #define OV13858_REG_VALUE_08BIT 1 #define OV13858_REG_VALUE_16BIT 2 @@ -1666,6 +1667,11 @@ static int ov13858_init_controls(struct ov13858 *ov13858) goto error; } + ret = v4l2_fwnode_register_controls(dev_fwnode(&client->dev), + ctrl_hdlr, &ov13858_ctrl_ops); + if (ret) + goto error; + ov13858->sd.ctrl_handler = ctrl_hdlr; return 0; From patchwork Tue Aug 27 09:23:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E0DD14DE for ; Tue, 27 Aug 2019 09:22:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A2E2206BB for ; Tue, 27 Aug 2019 09:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729454AbfH0JWs (ORCPT ); Tue, 27 Aug 2019 05:22:48 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:46215 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729357AbfH0JWs (ORCPT ); Tue, 27 Aug 2019 05:22:48 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id AD2D21C000C; Tue, 27 Aug 2019 09:22:45 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 09/10] media: i2c: ov5670: Report native size and crop bounds Date: Tue, 27 Aug 2019 11:23:37 +0200 Message-Id: <20190827092339.8858-12-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Report the native pixel array size and the crop bounds for the ov5670 sensor driver. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/ov5670.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c index 2bc57e85f721..3e22fe9ccad1 100644 --- a/drivers/media/i2c/ov5670.c +++ b/drivers/media/i2c/ov5670.c @@ -2258,6 +2258,25 @@ static int ov5670_set_pad_format(struct v4l2_subdev *sd, return 0; } +static int ov5670_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = 2592; + sel->r.height = 1944; + break; + default: + return -EINVAL; + } + + return 0; +} + static int ov5670_get_skip_frames(struct v4l2_subdev *sd, u32 *frames) { *frames = OV5670_NUM_OF_SKIP_FRAMES; @@ -2425,6 +2444,7 @@ static const struct v4l2_subdev_pad_ops ov5670_pad_ops = { .enum_mbus_code = ov5670_enum_mbus_code, .get_fmt = ov5670_get_pad_format, .set_fmt = ov5670_set_pad_format, + .get_selection = ov5670_get_selection, .enum_frame_size = ov5670_enum_frame_size, }; From patchwork Tue Aug 27 09:23:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11116467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71BEC1395 for ; Tue, 27 Aug 2019 09:22:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5164321872 for ; Tue, 27 Aug 2019 09:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729493AbfH0JWu (ORCPT ); Tue, 27 Aug 2019 05:22:50 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:49909 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729357AbfH0JWu (ORCPT ); Tue, 27 Aug 2019 05:22:50 -0400 X-Originating-IP: 87.18.63.98 Received: from uno.homenet.telecomitalia.it (unknown [87.18.63.98]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 8A7531C000E; Tue, 27 Aug 2019 09:22:47 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v2 10/10] media: i2c: ov13858: Report native size and crop bounds Date: Tue, 27 Aug 2019 11:23:38 +0200 Message-Id: <20190827092339.8858-13-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827092339.8858-1-jacopo@jmondi.org> References: <20190827092339.8858-1-jacopo@jmondi.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Report the native pixel array size and the crop bounds for the ov13858 sensor driver. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/ov13858.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c index d06be9b1e8d5..81ebb38e6567 100644 --- a/drivers/media/i2c/ov13858.c +++ b/drivers/media/i2c/ov13858.c @@ -1402,6 +1402,30 @@ ov13858_set_pad_format(struct v4l2_subdev *sd, return 0; } +static int ov13858_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.left = 16; + sel->r.top = 16; + sel->r.width = 4224; + sel->r.height = 3136; + break; + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.left = 0; + sel->r.top = 0; + sel->r.width = 4256; + sel->r.height = 3168; + break; + default: + return -EINVAL; + } + + return 0; +} + static int ov13858_get_skip_frames(struct v4l2_subdev *sd, u32 *frames) { *frames = OV13858_NUM_OF_SKIP_FRAMES; @@ -1565,6 +1589,7 @@ static const struct v4l2_subdev_pad_ops ov13858_pad_ops = { .enum_mbus_code = ov13858_enum_mbus_code, .get_fmt = ov13858_get_pad_format, .set_fmt = ov13858_set_pad_format, + .get_selection = ov13858_get_selection, .enum_frame_size = ov13858_enum_frame_size, };