-
Notifications
You must be signed in to change notification settings - Fork 7.7k
drivers: video: bugfixes for CID queries #91228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: video: bugfixes for CID queries #91228
Conversation
Thank you for the bug fix in the searching strategy of
Suggestion: drivers: video: Fix skipping CIDs in video_query_ctrl The other two commits seems not related to the fix could be better put in another PR but not a problem to me. |
BTW, I am curious about the usecase that we have more than one devices having controls in a pipeline that help you to detect the bug ? |
In video_query_ctrl(), controls are enumerated in ascending order within each device before moving to the next. This causes it to skip valid controls that exist in other devices but have lower IDs than those already checked. Fix this by searching CIDs globally across all devices of the pipeline. Signed-off-by: Josuah Demangeon <me@josuah.net>
|
Force-push:
Much more clear, I could not word it properly so I made a drawing... ^_^'
I was testing the controls for IMX219 on the tinyCLUXN33
Very small drivers used just for control APIs, all the I/O is on the hardware. The UVC implemntation queries the top level device: So I wanted to check how the controls were looking like at each level to see if they were properly propagated, and the Zephyr shell use your APIs and that works well:
Here we see the different test patterns depending on where we query in the chain, as expected... Handy! |
If I understand well, your uvcmanager and imx219 both expose the test_pattern control. Although I don't know why the uvcmanager has a test pattern control on its own but this scenario is rather common in practice, i.e. the bridge driver and the sensor driver both have a test pattern module. So, in the scenario where parent and child devices expose the same controls, I think we need to show all the controls of each device when we query the parent device. I made another version as below where we show all the controls of a device before moving to the next device in the hierachy (same as the old code) but fixing the skipped CIDs by resetting the cq->id and keeping track of the vdev (by memorizing a vdev in the query structure). This scenario also reveals the question "How do we set/get a control when it presents in multiple hierachical devices ?" I made a draft version to illustrate this here : #91265 What do you think ?
|
This is to have an image as low level as possible in the chain. Having a basic increasing counter pattern generator straight in the UVC handler makes the this difficult part a lot less complex.
IIRC your original idea was that this would be a rare situation and the test pattern is seems like a non-problem as typically an user wanting to debug a system wants to enable a test pattern for a particular device, like down in the shell today.
It seems still possible to do by pointing at the lower-level device, so is still possible to do today:
Is this good enough?
I will continue on #91265 to avoid going off-topic. Thanks for the implementation! |
Yes, that's right. Apart from the test pattern, I don't see other controls that could be present in both bridge and sensor drivers. When enumerating the controls on the parent device, it currently enumerate all the controls of the parent and its children. So if a control is present on both, we should show it two times for consistency I think ? |
One interesting use-case: A video device with two image sensor as source, stacked vertically (video output twice taller). This means two This could be interesting to aggregate all controls... It can be confusing, though, that a Maybe this would be an easier model to understand once a high-level structure like "video pipeline" or "video interface" is introduced though. Then if "query controls of that interface" returns all controls of all devices of the pipeline behind that interface... it stays very logical. In preparation of that, it makes sense to prepare the implementation, which also fixes a bug. |
Adding DNM flag to give time for discussion in case an alternative fix is chosen. |
Comment imported from #91265 (comment) This sounds like a very good idea! However, I would consider switching zephyr/include/zephyr/device.h Lines 1270 to 1293 in 98ba754
This permits to manually define a device and its dependencies with the And then we can walk the tree of dependencies, including only the video devices (those manually "injected") with: zephyr/include/zephyr/device.h Lines 658 to 677 in 98ba754
That way, it becomes possible to use native Zephyr APIs instead of I can propose an implementation as soon as I am done with IMX219 (#88011) but feel free to also modify the current PR if you do not want to wait. A shell command to print the tree of video devices would be some nice feature to encourage users to buy-in the complexity of the video APIs inherited from Linux. |
Yes, this is another usecase which is different than the one discussed here. This falls into the support of multiple-sensors at a time or a sensor at a time but can be switched or virtual channel categories. Here, the usecase is simpler where we have the bridge driver containing the same control with the sensor ...
My first implementation of the control framework is aggregating the controls as done in Linux but than I realized that it's more complicated and may require subdev, main dev and video dev concepts ... |
BTW, injecting the dependent devices to Another point of injecting devices dependency is that it imposes constraint on the init order of the device and its dependencies what we want to avoid, e.g. a bridge driver (like CSI in rt1064) "depend on" the sensor dev but needs to be initialized before the sensor dev to provide the master clock to the sensor. |
To focus only on fixing the skipped CIDS of the parent devices of What do you think ? |
The
There are also iterable sections for all devices, and is possible to test whether a device is having a video API or not. In theory it would be possible to use Zephyr native APIs, but that sounds a lot less straightforward to do so, agreed.
Clearly a blocking point, injected dependencies cannot work for this reason. Thank you for describing the alternatives, this helps identifying the real need. |
It seems like the best way to go. Maybe in the future users do not have to deal with the
Since the controls are listed device by device, an alternative output could be:
|
Yes, this is what I wanted to do but it's not easy at first quick implementation :-) (to know when we finish with a device, maybe need to use a temporary variable to compare the device's name ...). I will retry later. |
Reworked #91265 so that |
This was superseded by #91265 which is merged. All good! |
This groups two small bugfixes for the controls.
One programming typo on the shell.
One slightly more subtile bug with the way controls are searched across all devices.
Before: the search is in breadth first, and in depth after: some controls are skipped.
After: the search is in depth first, and in breadth after: exhaustive search but controls are not skipped.
(dots = controls, lines = search path)
[EDIT: it should have been dev1, dev2, dev3, dev4 rather than dev1, dev1, dev1, dev1]