public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Cc: linux-media@vger.kernel.org, alain.volmat@foss.st.com,
	hugues.fruchet@foss.st.com, sylvain.petinot@foss.st.com,
	dave.stevenson@raspberrypi.com, sakari.ailus@linux.intel.com,
	kieran.bingham@ideasonboard.com
Subject: Re: [PATCH v2 2/5] media: v4l: ctrls: Add a control for temperature
Date: Fri, 15 Apr 2022 17:37:20 +0300	[thread overview]
Message-ID: <YlmDIHNQub7eqskK@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220415111845.27130-3-benjamin.mugnier@foss.st.com>

Hi Benjamin,

Thank you for the patch.

On Fri, Apr 15, 2022 at 01:18:42PM +0200, Benjamin Mugnier wrote:
> 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 <benjamin.mugnier@foss.st.com>
> ---
>  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.

I've seen sensors where the temperature sensor has a 1/10th degree
precision. Should we standardize on that ? Anything more precise is
likely overkill.

There are also sensors with multiple temperature sensors. If there are
too many of them I suppose the temperature would be reported in embedded
data, but perhaps not always. How can we prepare for this ?

There are also a few details that I think should be documented. Is the
temperature always read on-demand when reading the control, or updated
periodically ? I would assume most drivers would implement the former,
which means no control notification events will be generated. This
should be documented. Furthermore, do drivers need to support reading
the temperature when the sensor isn't streaming ? If not, when should a
control read ioctl return, the last value, or an error ?

> 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)

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-04-15 14:37 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15 11:18 [PATCH v2 0/5] media: Add ST VGXY61 camera sensor driver Benjamin Mugnier
2022-04-15 11:18 ` [PATCH v2 1/5] media: v4l: Add 1X16 16-bit greyscale media bus code definition Benjamin Mugnier
2022-04-15 14:47   ` Laurent Pinchart
2022-04-15 11:18 ` [PATCH v2 2/5] media: v4l: ctrls: Add a control for temperature Benjamin Mugnier
2022-04-15 14:37   ` Laurent Pinchart [this message]
2022-04-20 13:01     ` Benjamin Mugnier
2022-04-19  7:03   ` Hans Verkuil
2022-04-20 13:01     ` Benjamin Mugnier
2022-04-19 18:24   ` Nicolas Dufresne
2022-04-19 19:28     ` Guenter Roeck
2022-04-19 21:01       ` Laurent Pinchart
2022-04-19 22:04         ` Guenter Roeck
2022-04-20 13:01           ` Benjamin Mugnier
2022-04-20 13:21             ` Laurent Pinchart
2022-04-20 13:58               ` Guenter Roeck
2022-04-20 14:23                 ` Laurent Pinchart
2022-04-20 15:19                   ` Benjamin Mugnier
2022-04-20 16:19                     ` Guenter Roeck
2022-04-20 16:51                       ` Laurent Pinchart
2022-04-15 11:18 ` [PATCH v2 3/5] media: v4l: ctrls: Add user control base for st-vgxy61 controls Benjamin Mugnier
2022-04-15 14:51   ` Laurent Pinchart
2022-04-15 11:18 ` [PATCH v2 4/5] media: dt-bindings: media: i2c: Add ST VGXY61 camera sensor binding Benjamin Mugnier
2022-04-15 14:59   ` Laurent Pinchart
2022-04-20 13:01     ` Benjamin Mugnier
2022-04-15 11:18 ` [PATCH v2 5/5] media: i2c: Add driver for ST VGXY61 camera sensor Benjamin Mugnier
2022-04-15 15:39   ` Laurent Pinchart
2022-04-20 13:01     ` Benjamin Mugnier
2022-04-20 16:48       ` Laurent Pinchart
2022-04-22  8:44         ` Benjamin Mugnier
2022-04-22 13:29           ` Laurent Pinchart
2022-04-22 14:40             ` Benjamin Mugnier
2022-04-24 16:34               ` Laurent Pinchart
2022-04-27 14:27                 ` Benjamin Mugnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YlmDIHNQub7eqskK@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=alain.volmat@foss.st.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=hugues.fruchet@foss.st.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sylvain.petinot@foss.st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox