drivers: video: Add get_volatile_ctrl driver's API
Add get_volatile_ctrl() driver's API to retrieve the current value of a control marked as volatile, e.g. gain, exposure. This function triggers a hardware register reading instead of returning a cached value to ensure that users always get a fresh value which is constantly updated by the HW. Note that the driver is responsible for marking a control as volatile by setting VIDEO_CTRL_FLAG_VOLATILE when registering a control because not all hardwares work the same way for the same control. Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
This commit is contained in:
parent
f363bd6e36
commit
cbf104f3d0
2 changed files with 17 additions and 5 deletions
|
@ -151,6 +151,17 @@ int video_get_ctrl(const struct device *dev, struct video_control *control)
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctrl->flags & VIDEO_CTRL_FLAG_VOLATILE) {
|
||||||
|
if (DEVICE_API_GET(video, ctrl->vdev->dev)->get_volatile_ctrl == NULL) {
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call driver's get_volatile_ctrl */
|
||||||
|
return DEVICE_API_GET(video, ctrl->vdev->dev)
|
||||||
|
->get_volatile_ctrl(ctrl->vdev->dev, control);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read control value in cache memory */
|
||||||
if (ctrl->type == VIDEO_CTRL_TYPE_INTEGER64) {
|
if (ctrl->type == VIDEO_CTRL_TYPE_INTEGER64) {
|
||||||
control->val64 = ctrl->val64;
|
control->val64 = ctrl->val64;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -318,12 +318,12 @@ typedef int (*video_api_flush_t)(const struct device *dev, enum video_endpoint_i
|
||||||
typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable);
|
typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef video_api_set_ctrl_t
|
* @typedef video_api_ctrl_t
|
||||||
* @brief Set a video control value.
|
* @brief Set/Get a video control value.
|
||||||
*
|
*
|
||||||
* See video_set_ctrl() for argument descriptions.
|
* See video_set_ctrl() or video_get_ctrl() for argument descriptions.
|
||||||
*/
|
*/
|
||||||
typedef int (*video_api_set_ctrl_t)(const struct device *dev, struct video_control *ctrl);
|
typedef int (*video_api_ctrl_t)(const struct device *dev, struct video_control *ctrl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef video_api_get_caps_t
|
* @typedef video_api_get_caps_t
|
||||||
|
@ -353,7 +353,8 @@ __subsystem struct video_driver_api {
|
||||||
video_api_enqueue_t enqueue;
|
video_api_enqueue_t enqueue;
|
||||||
video_api_dequeue_t dequeue;
|
video_api_dequeue_t dequeue;
|
||||||
video_api_flush_t flush;
|
video_api_flush_t flush;
|
||||||
video_api_set_ctrl_t set_ctrl;
|
video_api_ctrl_t set_ctrl;
|
||||||
|
video_api_ctrl_t get_volatile_ctrl;
|
||||||
video_api_set_signal_t set_signal;
|
video_api_set_signal_t set_signal;
|
||||||
video_api_set_frmival_t set_frmival;
|
video_api_set_frmival_t set_frmival;
|
||||||
video_api_get_frmival_t get_frmival;
|
video_api_get_frmival_t get_frmival;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue