From patchwork Mon Oct 7 16:29:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178057 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 4DDC5139A for ; Mon, 7 Oct 2019 16:27:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D3D721721 for ; Mon, 7 Oct 2019 16:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728860AbfJGQ1l (ORCPT ); Mon, 7 Oct 2019 12:27:41 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:33923 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728429AbfJGQ1l (ORCPT ); Mon, 7 Oct 2019 12:27:41 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 3B2C4240007; Mon, 7 Oct 2019 16:27:39 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 01/11] dt-bindings: video-interfaces: Document 'location' property Date: Mon, 7 Oct 2019 18:29:03 +0200 Message-Id: <20191007162913.250743-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 a 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt index f884ada0bffc..1211bdf80722 100644 --- a/Documentation/devicetree/bindings/media/video-interfaces.txt +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt @@ -89,6 +89,17 @@ Optional properties but a number of degrees counter clockwise. Typical values are 0 and 180 (upside down). +- location: The mount location of a device (typically an image sensor or a flash + LED) expressed as a position relative to the usage orientation of the system + where the device is installed on. + Possible values are: + 0 - Front. The device is mounted on the front facing side of the system. + For mobile devices such as smartphones, tablets and laptops the front side is + the user facing side. + 1 - Back. The device is mounted on the back side of the system, which is + defined as the opposite side of the front facing one. + 2 - External. The device is not attached directly to the system but is + attached in a way that allows it to move freely. Optional endpoint properties ---------------------------- From patchwork Mon Oct 7 16:29:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178059 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 203BF1599 for ; Mon, 7 Oct 2019 16:27:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0810D20700 for ; Mon, 7 Oct 2019 16:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728864AbfJGQ1n (ORCPT ); Mon, 7 Oct 2019 12:27:43 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:55907 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbfJGQ1n (ORCPT ); Mon, 7 Oct 2019 12:27:43 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id CCD70240006; Mon, 7 Oct 2019 16:27:40 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 02/11] media: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_LOCATION Date: Mon, 7 Oct 2019 18:29:04 +0200 Message-Id: <20191007162913.250743-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst index 51c1d5c9eb00..b151c016256c 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst @@ -510,6 +510,38 @@ 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. This control is + particularly meaningful for devices which have a well defined orientation, + such as phones, laptops and portable devices since the camera location is + expressed as a position relative to the device's intended usage orientation. + For 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 + opposite the front one are said to be installed in the + ``V4L2_LOCATION_BACK`` location. Camera sensors not directly attached to + the device or attached in a way that allows them to move freely, such as + webcams and digital cameras, are said to have the ``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 not directly attached to the device and is + freely movable. + + + .. [#f1] This control may be changed to a menu control in the future, if more options are required. From patchwork Mon Oct 7 16:29:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178061 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 1A4EC1599 for ; Mon, 7 Oct 2019 16:27:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECFBB206C0 for ; Mon, 7 Oct 2019 16:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728882AbfJGQ1p (ORCPT ); Mon, 7 Oct 2019 12:27:45 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:41289 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfJGQ1o (ORCPT ); Mon, 7 Oct 2019 12:27:44 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 6644E24000C; Mon, 7 Oct 2019 16:27:42 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 03/11] dt-bindings: video-interface: Expand rotation description Date: Mon, 7 Oct 2019 18:29:05 +0200 Message-Id: <20191007162913.250743-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 Expand the 'rotation' property description to define the direction and orientation of the axis around which the device mounting rotation is expressed. Signed-off-by: Jacopo Mondi --- .../devicetree/bindings/media/video-interfaces.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt index 1211bdf80722..58b87a3f1fa4 100644 --- a/Documentation/devicetree/bindings/media/video-interfaces.txt +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt @@ -85,9 +85,11 @@ Optional properties - lens-focus: A phandle to the node of the focus lens controller. -- rotation: The device, typically an image sensor, is not mounted upright, - but a number of degrees counter clockwise. Typical values are 0 and 180 - (upside down). +- rotation: The mount rotation of the device (typically an image sensor) + expressed as counterclockwise rotation degrees along the axis perpendicular to + the device mounting surface directed away from it. Typical values are 0 + degrees for upright mounted devices and 180 degrees for devices mounted upside + down. - location: The mount location of a device (typically an image sensor or a flash LED) expressed as a position relative to the usage orientation of the system From patchwork Mon Oct 7 16:29:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178063 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 61B371599 for ; Mon, 7 Oct 2019 16:27:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A319206C0 for ; Mon, 7 Oct 2019 16:27:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728901AbfJGQ1r (ORCPT ); Mon, 7 Oct 2019 12:27:47 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:45827 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbfJGQ1r (ORCPT ); Mon, 7 Oct 2019 12:27:47 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 1CA6C240010; Mon, 7 Oct 2019 16:27:43 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 04/11] media: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_ROTATION Date: Mon, 7 Oct 2019 18:29:06 +0200 Message-Id: <20191007162913.250743-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 --- .../media/uapi/v4l/ext-ctrls-camera.rst | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst index b151c016256c..e1fee4814e5b 100644 --- a/Documentation/media/uapi/v4l/ext-ctrls-camera.rst +++ b/Documentation/media/uapi/v4l/ext-ctrls-camera.rst @@ -542,6 +542,122 @@ enum v4l2_scene_mode - +``V4L2_CID_CAMERA_SENSOR_ROTATION (integer)`` + This read-only control describes the sensor orientation expressed as + rotation in counterclockwise degrees along the axis perpendicular to the + device mounting plane, and directed away from the sensor lens. Possible + values for the control are 90, 180 and 270 degrees. To compensate for the + device mounting rotation on the captured images, a rotation of the same + amount of degrees, in the same counterclockwise rotation direction should be + applied along the axis directed from the observer to the captured image when + displayed on a screen. + + To better understand the effect of the sensor rotation on the acquired + images when displayed on a screen, it is helpful to consider a fictional + scan-out sequence of the sensor's pixels, assuming the pixel array having + its top-left pixel at position (0, 0) with values on the 'x' axis increasing + towards the right direction, and values on the 'y' axis increasing towards + the bottom. The effect of sensor rotation could be easily visualized + considering the sequence of captured pixels. + + Assuming the following scene has to be captured:: + + o + -|- + / \ + + An upright mounted sensor has its pixel array displaced as follow:: + + x + (0,0)-------------------> + ! 0,0 0,1 0,2 ... (0,num-col) + ! 1,0 1,1 1,2 ... + ! ... + ! ... + ! (num-lines,0)...(num-col,num-lines) + y V + + + Assuming pixels are scanned out from (0,0) to (num-lines,num-col) + progressively:: + + (0,0) ---->-------------> (0,num-col) + (1,0) ---->-------------> (1,num-col) + ( .... )-->-------------> ( .... ) + (num-lines,0)----------->(num-lines,num-col) + + + If a rotation of 90 degrees counterclockwise along the axis perpendicular to + the sensor's lens and directed towards the scene to be captured is applied + to the sensor, the pixel array would then be rotated as follows:: + + x ^ (0,num-col) ... ... (num-lines,num-col) + ! .... + ! 0,2 1,2 ... ... + ! 0,1 1,1 ... ... + ! 0,0 1,0 ... (num-lines,0) + (0,0)------------------------------------> + y + + And the pixel scan-out sequence would then proceed as follows starting + from pixel (0,0):: + + (0,num-col) (num-lines,num-col) + ^ ^ ^ ^ ^ + ! ! ! ! ! + ! ! ! ! ! + ! ! ! ! ! + ! ! ! ! ! + (0,0) (1,0).... (num-lines,0) + + Which when applied to the capture scene gives:: + + (0,num-col) (num-lines,num-col) + ^ ^ ^ ^ ^ + ! ! 0 ! ! + ! ! -|- ! ! + ! ! /!\ ! ! + ! ! ! ! ! + (0,0) (1,0).... (num-lines,0) + + Producing the following image once captured to memory and + displayed to the user:: + + \ ! + --0 + / ! + + Which has a rotation of the same amount of degrees applied on the opposite + rotation direction along the axis that goes from the observer to the + image when displayed on the screen. + + In order to compensate the sensor mounting rotation, when expressed + as counterclockwise rotation along the axis directed from the sensor to + the captured scene, a rotation of the same amount of degrees in the + same counterclockwise rotation direction but applied along the axis + directed from the observer to the captured image, has to be applied:: + + +------+ 90 degree counterclockwise + | o | mounting rotation applied + | -|- | along the axis directed + | / \ | away from the sensor lens + +------+ + | + V + +------+ + | \ ! | Resulting captured + | --0 | image when displayed + | / ! | on screen + +------+ + | + V + +------+ + | o | Rotation compensation + | -|- | is 90 degrees counterclockwise + | / \ | along the axis directed to the + +------+ displayed image + + .. [#f1] This control may be changed to a menu control in the future, if more options are required. From patchwork Mon Oct 7 16:29:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178065 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 BCAA61599 for ; Mon, 7 Oct 2019 16:27:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B3D02084D for ; Mon, 7 Oct 2019 16:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728923AbfJGQ1t (ORCPT ); Mon, 7 Oct 2019 12:27:49 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:55271 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbfJGQ1s (ORCPT ); Mon, 7 Oct 2019 12:27:48 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id B7274240006; Mon, 7 Oct 2019 16:27:45 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 05/11] media: v4l2-ctrls: Add camera location and rotation Date: Mon, 7 Oct 2019 18:29:07 +0200 Message-Id: <20191007162913.250743-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 and V4L2_CID_CAMERA_SENSOR_ROTATION read-only controls used to report the camera device mounting position and orientation respectively. Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++++ include/uapi/linux/v4l2-controls.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 1d8f38824631..b7af47a25125 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -994,6 +994,8 @@ 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"; + 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! */ @@ -1318,6 +1320,8 @@ 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: + 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 a2669b79b294..f2be7a99818e 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -912,6 +912,13 @@ 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 + +#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 Mon Oct 7 16:29:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178067 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 A9C0C139A for ; Mon, 7 Oct 2019 16:27:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 932FA2133F for ; Mon, 7 Oct 2019 16:27:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728888AbfJGQ1v (ORCPT ); Mon, 7 Oct 2019 12:27:51 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:36853 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728891AbfJGQ1u (ORCPT ); Mon, 7 Oct 2019 12:27:50 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 5CE84240012; Mon, 7 Oct 2019 16:27:47 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 06/11] media: v4l2-fwnode: Add helper to parse device properties Date: Mon, 7 Oct 2019 18:29:08 +0200 Message-Id: <20191007162913.250743-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 an helper function to parse common device properties in the same way as v4l2_fwnode_endpoint_parse() parses common endpoint properties. Parse the 'rotation' and 'location' properties from the firmware interface. Signed-off-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-fwnode.c | 42 +++++++++++++++++++++++ include/media/v4l2-fwnode.h | 48 +++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 192cac076761..8af4174a2bbf 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -596,6 +596,48 @@ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link) } EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link); +int v4l2_fwnode_device_parse(struct device *dev, + struct v4l2_fwnode_device_properties *props) +{ + struct fwnode_handle *fwnode = dev_fwnode(dev); + u32 val; + int ret; + + memset(props, 0, sizeof(*props)); + + props->location = V4L2_FWNODE_PROPERTY_UNSET; + ret = fwnode_property_read_u32(fwnode, "location", &val); + if (!ret) { + switch (val) { + case V4L2_FWNODE_LOCATION_FRONT: + case V4L2_FWNODE_LOCATION_BACK: + case V4L2_FWNODE_LOCATION_EXTERNAL: + break; + default: + dev_warn(dev, "Unsupported device location: %u\n", val); + return -EINVAL; + } + + props->location = val; + dev_dbg(dev, "device location: %u\n", val); + } + + props->rotation = V4L2_FWNODE_PROPERTY_UNSET; + ret = fwnode_property_read_u32(fwnode, "rotation", &val); + if (!ret) { + if (val >= 360 || val % 90) { + dev_warn(dev, "Unsupported device rotation: %u\n", val); + return -EINVAL; + } + + props->rotation = val; + dev_dbg(dev, "device rotation: %u\n", val); + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_fwnode_device_parse); + 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..6d46d6fc3007 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -109,6 +109,36 @@ struct v4l2_fwnode_endpoint { unsigned int nr_of_link_frequencies; }; +/** + * v4l2_fwnode_location - identify a non initialized property. + * + * All properties in &struct v4l2_fwnode_device_properties are initialized + * to this value. + */ +#define V4L2_FWNODE_PROPERTY_UNSET (-1U) + +/** + * enum v4l2_fwnode_location - possible device locations + * @V4L2_FWNODE_LOCATION_FRONT: device installed on the front side + * @V4L2_FWNODE_LOCATION_BACK: device installed on the back side + * @V4L2_FWNODE_LOCATION_EXTERNAL: device externally located + */ +enum v4l2_fwnode_location { + V4L2_FWNODE_LOCATION_FRONT, + V4L2_FWNODE_LOCATION_BACK, + V4L2_FWNODE_LOCATION_EXTERNAL +}; + +/** + * struct v4l2_fwnode_device_properties - fwnode device properties + * @location: device location. See &enum v4l2_fwnode_location + * @rotation: device rotation + */ +struct v4l2_fwnode_device_properties { + enum v4l2_fwnode_location location; + unsigned int rotation; +}; + /** * struct v4l2_fwnode_link - a link between two endpoints * @local_node: pointer to device_node of this endpoint @@ -233,6 +263,24 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, */ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); +/** + * v4l2_fwnode_device_parse() - parse fwnode device properties + * @dev: pointer to &struct device + * @props: pointer to &struct v4l2_fwnode_device_properties where to store the + * parsed properties values + * + * This function parses and validates the V4L2 fwnode device properties from + * the firmware interface. It is responsibility of the caller to allocate a + * valid @struct v4l2_fwnode_device_properties structure and provide a pointer + * to it in the @props parameter. + * + * Return: + * % 0 on success + * %-EINVAL if a parsed property value is not valid + */ +int v4l2_fwnode_device_parse(struct device *dev, + struct v4l2_fwnode_device_properties *props); + /** * typedef parse_endpoint_func - Driver's callback function to be called on * each V4L2 fwnode endpoint. From patchwork Mon Oct 7 16:29:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178069 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 B6DEA139A for ; Mon, 7 Oct 2019 16:27:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A002C2133F for ; Mon, 7 Oct 2019 16:27:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbfJGQ1w (ORCPT ); Mon, 7 Oct 2019 12:27:52 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:54019 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbfJGQ1v (ORCPT ); Mon, 7 Oct 2019 12:27:51 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 12492240007; Mon, 7 Oct 2019 16:27:48 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 07/11] include: v4l2-ctrl: Sort forward declarations Date: Mon, 7 Oct 2019 18:29:09 +0200 Message-Id: <20191007162913.250743-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 Before adding a new forward declaration to the v4l2-ctrls.h header file, sort the existing ones alphabetically. Signed-off-by: Jacopo Mondi --- include/media/v4l2-ctrls.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 570ff4b0205a..95b4fa6243d1 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -24,14 +24,14 @@ /* forward references */ struct file; +struct poll_table_struct; +struct v4l2_ctrl; struct v4l2_ctrl_handler; struct v4l2_ctrl_helper; -struct v4l2_ctrl; -struct video_device; +struct v4l2_fh; struct v4l2_subdev; struct v4l2_subscribed_event; -struct v4l2_fh; -struct poll_table_struct; +struct video_device; /** * union v4l2_ctrl_ptr - A pointer to a control value. From patchwork Mon Oct 7 16:29:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178071 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 D67BA139A for ; Mon, 7 Oct 2019 16:27:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B52B520700 for ; Mon, 7 Oct 2019 16:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728941AbfJGQ1y (ORCPT ); Mon, 7 Oct 2019 12:27:54 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:37461 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbfJGQ1y (ORCPT ); Mon, 7 Oct 2019 12:27:54 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id A9909240008; Mon, 7 Oct 2019 16:27:50 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 08/11] media: v4l2-ctrls: Sort includes alphabetically Date: Mon, 7 Oct 2019 18:29:10 +0200 Message-Id: <20191007162913.250743-9-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 Before adding a new include directive, sort the existing ones in alphabetical order. Signed-off-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-ctrls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index b7af47a25125..6fb94968a98d 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -9,14 +9,14 @@ #define pr_fmt(fmt) "v4l2-ctrls: " fmt #include +#include #include #include -#include -#include -#include #include -#include #include +#include +#include +#include #define dprintk(vdev, fmt, arg...) do { \ if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \ From patchwork Mon Oct 7 16:29:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178073 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 017B2139A for ; Mon, 7 Oct 2019 16:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE8442133F for ; Mon, 7 Oct 2019 16:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728273AbfJGQ1z (ORCPT ); Mon, 7 Oct 2019 12:27:55 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:55017 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728930AbfJGQ1z (ORCPT ); Mon, 7 Oct 2019 12:27:55 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4C3FC240011; Mon, 7 Oct 2019 16:27:52 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 09/11] media: v4l2-ctrls: Add helper to register properties Date: Mon, 7 Oct 2019 18:29:11 +0200 Message-Id: <20191007162913.250743-10-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 an helper function to v4l2-ctrls to register controls associated with a device property. Signed-off-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-ctrls.c | 40 ++++++++++++++++++++++++++++ include/media/v4l2-ctrls.h | 26 ++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 6fb94968a98d..50e9daa7a75a 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #define dprintk(vdev, fmt, arg...) do { \ @@ -4417,3 +4418,42 @@ __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait) return 0; } EXPORT_SYMBOL(v4l2_ctrl_poll); + +int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ctrl_ops, + const struct v4l2_fwnode_device_properties *p) +{ + if (p->location != V4L2_FWNODE_PROPERTY_UNSET) { + u32 location_ctrl; + + switch (p->location) { + case V4L2_FWNODE_LOCATION_FRONT: + location_ctrl = V4L2_LOCATION_FRONT; + break; + case V4L2_FWNODE_LOCATION_BACK: + location_ctrl = V4L2_LOCATION_BACK; + break; + case V4L2_FWNODE_LOCATION_EXTERNAL: + location_ctrl = V4L2_LOCATION_EXTERNAL; + break; + default: + return -EINVAL; + } + if (!v4l2_ctrl_new_std(hdl, ctrl_ops, + V4L2_CID_CAMERA_SENSOR_LOCATION, + location_ctrl, location_ctrl, 1, + location_ctrl)) + return hdl->error; + } + + if (p->rotation != V4L2_FWNODE_PROPERTY_UNSET) { + if (!v4l2_ctrl_new_std(hdl, ctrl_ops, + V4L2_CID_CAMERA_SENSOR_ROTATION, + p->rotation, p->rotation, 1, + p->rotation)) + return hdl->error; + } + + return 0; +} +EXPORT_SYMBOL(v4l2_ctrl_new_fwnode_properties); diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 95b4fa6243d1..6bf8c304c431 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -29,6 +29,7 @@ struct v4l2_ctrl; struct v4l2_ctrl_handler; struct v4l2_ctrl_helper; struct v4l2_fh; +struct v4l2_fwnode_device_properties; struct v4l2_subdev; struct v4l2_subscribed_event; struct video_device; @@ -1330,4 +1331,29 @@ int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, */ int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd); +/** + * v4l2_ctrl_new_fwnode_properties() - Register controls for the device + * properties + * + * @hdl: pointer to &struct v4l2_ctrl_handler to register controls on + * @ctrl_ops: pointer to &struct v4l2_ctrl_ops to register controls with + * @p: pointer to &struct v4l2_fwnode_device_properties + * + * This function registers controls associated to device properties, using the + * property values contained in @p parameter, if the property has been set to + * a value. + * + * 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. + * + * Return: 0 on success, a negative error code on failure. + */ +int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, + const struct v4l2_ctrl_ops *ctrl_ops, + const struct v4l2_fwnode_device_properties *p); #endif From patchwork Mon Oct 7 16:29:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178075 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 A3489139A for ; Mon, 7 Oct 2019 16:27:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8BC812084D for ; Mon, 7 Oct 2019 16:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728930AbfJGQ15 (ORCPT ); Mon, 7 Oct 2019 12:27:57 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:47029 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728429AbfJGQ14 (ORCPT ); Mon, 7 Oct 2019 12:27:56 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id D641024000A; Mon, 7 Oct 2019 16:27:53 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 10/11] media: i2c: ov5670: Parse and register properties Date: Mon, 7 Oct 2019 18:29:12 +0200 Message-Id: <20191007162913.250743-11-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 Parse device properties and register controls for them using the newly introduced helpers. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/ov5670.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c index 041fcbb4eebd..f118d44b0889 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,8 @@ 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_fwnode_device_properties props; struct v4l2_ctrl_handler *ctrl_hdlr; s64 vblank_max; s64 vblank_def; @@ -2129,6 +2132,15 @@ static int ov5670_init_controls(struct ov5670 *ov5670) goto error; } + ret = v4l2_fwnode_device_parse(&client->dev, &props); + if (ret) + return ret; + + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov5670_ctrl_ops, + &props); + if (ret) + return ret; + ov5670->sd.ctrl_handler = ctrl_hdlr; return 0; From patchwork Mon Oct 7 16:29:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11178077 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 5388D1599 for ; Mon, 7 Oct 2019 16:27:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CE592084D for ; Mon, 7 Oct 2019 16:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728956AbfJGQ16 (ORCPT ); Mon, 7 Oct 2019 12:27:58 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:32875 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728429AbfJGQ16 (ORCPT ); Mon, 7 Oct 2019 12:27:58 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id B59AA240013; Mon, 7 Oct 2019 16:27:55 +0000 (UTC) From: Jacopo Mondi To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , tfiga@google.com, pavel@ucw.cz Cc: Jacopo Mondi , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)) Subject: [PATCH v4 11/11] media: i2c: ov13858: Parse and register properties Date: Mon, 7 Oct 2019 18:29:13 +0200 Message-Id: <20191007162913.250743-12-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007162913.250743-1-jacopo@jmondi.org> References: <20191007162913.250743-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 Parse device properties and register controls for them using the newly introduced helpers. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/ov13858.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c index aac6f77afa0f..2ef5fb5cf519 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 @@ -1589,6 +1590,7 @@ static const struct v4l2_subdev_internal_ops ov13858_internal_ops = { static int ov13858_init_controls(struct ov13858 *ov13858) { struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd); + struct v4l2_fwnode_device_properties props; struct v4l2_ctrl_handler *ctrl_hdlr; s64 exposure_max; s64 vblank_def; @@ -1666,6 +1668,15 @@ static int ov13858_init_controls(struct ov13858 *ov13858) goto error; } + ret = v4l2_fwnode_device_parse(&client->dev, &props); + if (ret) + return ret; + + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov13858_ctrl_ops, + &props); + if (ret) + return ret; + ov13858->sd.ctrl_handler = ctrl_hdlr; return 0;