From patchwork Fri Apr 15 11:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Benjamin Mugnier X-Patchwork-Id: 562753 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 D6F9EC433EF for ; Fri, 15 Apr 2022 11:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352650AbiDOLVj (ORCPT ); Fri, 15 Apr 2022 07:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236730AbiDOLVg (ORCPT ); Fri, 15 Apr 2022 07:21:36 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5605E8E183 for ; Fri, 15 Apr 2022 04:19:08 -0700 (PDT) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23F8f3G2008376; Fri, 15 Apr 2022 13:19:02 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=selector1; bh=UEMI6h3qFP72dxuPaPvAsrCYMY5yhx0ox95axXh/NZ0=; b=UgNfJkTW2bB5/KaipAuRvHCTFvNW7AvOlc45rVWbHBSi8mdrmZ6+e3opa16hBKItPc1c 7Zmu/veT4M4IBvu4GJxvog9r34nZnoY7ZbrJIqwDTUboC5QQhXjqADsyT/PdCau9Rznw hns0YXwIBCKj8DxUXy0facHM5n1+7HyqCDqI4xEKSM6/kHIXT2//M0yuB2g/hZDM4Bzx taC0d134qyFxPvMlp/TeMkGF1NBk2rE67XsNTY3kiDpz/CzuIijrVQE2Lorcp5YyHMFA +lHNna7mSSjKaJTVQ8WD5RIRTYSZoRl92KuB78oRlqSQFtdFg57A76btmVxalFoUzYUE 2Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3fdvj5n8eh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Apr 2022 13:19:02 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0DC2410002A; Fri, 15 Apr 2022 13:19:02 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node1.st.com [10.75.127.4]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0686A21E674; Fri, 15 Apr 2022 13:19:02 +0200 (CEST) Received: from localhost (10.75.127.50) by SFHDAG2NODE1.st.com (10.75.127.4) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Fri, 15 Apr 2022 13:19:01 +0200 From: Benjamin Mugnier To: CC: , , , , , , , Benjamin Mugnier Subject: [PATCH v2 2/5] media: v4l: ctrls: Add a control for temperature Date: Fri, 15 Apr 2022 13:18:42 +0200 Message-ID: <20220415111845.27130-3-benjamin.mugnier@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220415111845.27130-1-benjamin.mugnier@foss.st.com> References: <20220415111845.27130-1-benjamin.mugnier@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE1.st.com (10.75.127.4) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-15_04,2022-04-15_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add V4L2_CID_TEMPERATURE control to get temperature from sensor in celsius as a volatile and read-only control, and its documentation. Useful to monitor thermals from v4l controls for sensors that support this. Signed-off-by: Benjamin Mugnier --- Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst | 3 +++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 4 ++++ include/uapi/linux/v4l2-controls.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst index 4c5061aa9cd4..26fa21f5c45a 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst @@ -661,3 +661,6 @@ enum v4l2_scene_mode - .. [#f1] This control may be changed to a menu control in the future, if more options are required. + +``V4L2_CID_TEMPERATURE (integer)`` + The temperature of the sensor in celsius. This is a read-only control. diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 54ca4e6b820b..45ad3edd59e0 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -1042,6 +1042,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_UNIT_CELL_SIZE: return "Unit Cell Size"; case V4L2_CID_CAMERA_ORIENTATION: return "Camera Orientation"; case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation"; + case V4L2_CID_TEMPERATURE: return "Temperature in °C"; /* FM Radio Modulator controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1597,6 +1598,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_RF_TUNER_PLL_LOCK: *flags |= V4L2_CTRL_FLAG_VOLATILE; break; + case V4L2_CID_TEMPERATURE: + *flags |= V4L2_CTRL_FLAG_READ_ONLY | + V4L2_CTRL_FLAG_VOLATILE; } } EXPORT_SYMBOL(v4l2_ctrl_fill); diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index bb40129446d4..705b4043c2de 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1008,6 +1008,8 @@ enum v4l2_auto_focus_range { #define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35) +#define V4L2_CID_TEMPERATURE (V4L2_CID_CAMERA_CLASS_BASE+36) + /* FM Modulator class control IDs */ #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)