Skip to content

video: Improve control framework#96393

Open
ngphibang wants to merge 6 commits intozephyrproject-rtos:mainfrom
nxp-upstream:enhance_control_framework
Open

video: Improve control framework#96393
ngphibang wants to merge 6 commits intozephyrproject-rtos:mainfrom
nxp-upstream:enhance_control_framework

Conversation

@ngphibang
Copy link
Contributor

@ngphibang ngphibang commented Sep 22, 2025

  • Currently, control initialization is done in an unconsistent way, i.e. drivers need to pass some field values to video_init_ctrl() but still needs to set some other fields directly (type, flags, name, etc.). Refactor video_init_ctrl() to make it more consistent, i.e. initializing all kinds of control (standard, menu, integer menu, custom) is now done by setting directly the video_ctrl's fields and using the same API.
  • Add VIDEO_CTRL_FLAG_EXECUTE_ON_WRITE
  • Add VIDEO_CTRL_TYPE_BUTTON
  • Add name field to video_ctrl struct

Changes are for now applied on ov5640 and gc2145.
TODO: Apply changes on other camera sensor drivers

Currently, control initialization is done in an unconsistent way, i.e.
drivers need to pass some field values to video_init_ctrl() but still
needs to set some other fields directly.

Refactor video_init_ctrl() to make it more consistent, i.e. initializing
all kinds of control (standard, menu, integer menu, custom) is now done
by setting directly the video_ctrl's fields and using the same API.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Add VIDEO_CTRL_FLAG_EXECUTE_ON_WRITE flag.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Add VIDEO_CTRL_TYPE_BUTTON to support command-like controls.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Add a name field to the video_ctrl struct to allow naming custom
controls.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Signed-off-by: Armin Kessler <ake@espros.com>
The video_init_ctrl() function signature has been changed.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Drop video_init_menu_ctrl() and video_init_int_menu_ctrl()

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes video control declaration quite trivial/intuitive, and still offer to change the definition at runtime before calling video_init_ctrl().

+1 from me for the new organization.

Comment on lines +1256 to 1261
for (uint8_t i = 0; i < ARRAY_SIZE(ctrls); i++) {
ret = video_init_ctrl(ctrls[i], dev);
if (ret) {
return ret;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems possible to do ctrls = (struct video_ctrl *)&data->ctrls and then loop like this:

	for (uint8_t i = 0; i < sizeof(data->ctrls) / sizeof(*ctrls); i++) {
		ret = video_init_ctrl(ctrls[i], dev);
		if (ret) {
			return ret;
		}
	}
@ngphibang
Copy link
Contributor Author

In the next round, maybe I will change the function name video_init_ctrl() to video_register_ctrl() as it seems more intuitive (we register the ctrl with the framework, the control fields has been already initialized at compile time).


int video_init_int_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint32_t id,
uint8_t def, const int64_t menu[], size_t menu_len);
int video_init_ctrl(struct video_ctrl *ctrl, const struct device *const dev);
Copy link
Contributor

@josuah josuah Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be useful to add a size_t sz parameter that behaves like video_cluster_ctrl()?
This way, driver only have to make a single call:

return video_init_ctrl(&data->ctrls, sizeof(data->ctrls) / sizeof(struct video_ctrl), dev);
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Dec 14, 2025
@github-actions github-actions bot closed this Dec 28, 2025
@josuah josuah reopened this Dec 28, 2025
@github-actions github-actions bot removed the Stale label Dec 29, 2025
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Feb 27, 2026
@josuah josuah removed the Stale label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Video Video subsystem Release Notes To be mentioned in the release notes

3 participants