-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[media][imx219] selection API #5607
Conversation
7fabe61
to
191267a
Compare
Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
previously on mode change, the vblank is reset to the default of the mode. Now it uses the previous vblank to the new mode. Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
191267a
to
3cbc4a0
Compare
Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
3cbc4a0
to
e51565c
Compare
Sorry I'm going to have to direct this one upstream to the linux-media mailing list. There is already at least one significant patch set on there (https://patchwork.linuxtv.org/project/linux-media/list/?series=11202), and accepting something like this downstream is going to lead to major merge conflicts when that hits (all have a Reviewed-by tag, so should be in the next merge cycle). The other issue is that adding support for selection API on top of a mode based sensor driver was discussed within the linux-media community last September (https://www.spinics.net/lists/linux-media/msg219442.html). A basic route forward was proposed, but no implementation has been forthcoming since. We have defined modes. Those can not be dropped as it would be considered a regression in stopping existing applications working. One approach would be that setting the format is allowed to update the selections, thereby allowing you to retain enumeration and selection of the current modes, but also amend them afterwards via the selection API. Implementing something like that will require buy in from the linux-media maintainers though. I haven't followed through the complete details of your patch set to see if that is what you've implemented. |
Thanks for the quick response @6by9, replying inline -
Ah too bad! Looking at the changes in the patch set you shared, I think there shouldn't be too many major conflicts. I'll pull in those commits to my tree and try rebasing my changes on top of the same.
"Another alternative is a new API to cover freely configurable and mode-based
That is indeed how I have implemented it. The enumerated formats are retained and the S_FMT allows only one of the enumerated modes to be set, maintaining backwards compatibility with existing users. This means, as you mentioned, that the set_pad_fmt is allowed to override the crop and compose targets. The expectation is that users of the selection API first set the format and then change the selection targets as required. |
The rpi-6.5.y branch should be working if you want to be closer to linux-media. There are a couple of fixups required for imx219 on rpi-6.6.y at present which should be sorted in the next few days.
@jmondi You were the one who raised the subject of sensor mode configuration and selection API in Dublin last year. I'm guessing it's not gone anywhere as yet.
It's these holes that mean that the current APIs don't fully work, and why the CCS becomes so much more complex with multiple subdevs (and AFAIK nothing uses it). There's also no way to select between binning and skipping. |
While testing this patch I also came across an issue that I do not yet know how to handle. I added it in this thread since it's related to the PR here, please let me know if I should move this elsewhere.
Running this (results attached), between the compose height 480 and 256, the vblank of 32 works well. From there till 128, the minimum vblank is not working as intended but increases to 156. From 128 then all the way to the height of 4 the minimum vblank reduces till it reaches 32 again. In the logs, I can see
In the unicam driver, in the ISR there is a comment concerning this case
However, I do not understand these results and how they are affected by vblanking and specifically how there seems to be a point of inflexion at the height of 128. |
Welcome to the wonderful world of image sensors. They don't always behave in the logical way one might expect, hence your issue #5493 and subsequent PR #5498. Sensor vendors generally provide the tables of validated mode registers for specific modes, and that is what they support. There are often niggles when you try and generalise them. |
Signed-off-by: Vinay Varma <[email protected]>
previously, whenever format or framesize is changed, the FPS was reset to the default of the mode. With the selection API it is no longer possible to ascertain what mode is in use at all times. So we try to maintain the FPS across selection api changes while preventing underflows by checking against the minimum values of vblank. Signed-off-by: Vinay Varma <[email protected]>
Signed-off-by: Vinay Varma <[email protected]>
The above issues were due to a bug in the code. Closing this PR for now as discussed. |
@6by9 I believe the patchset linked above has been merged into the rpi-6.7.7 branch, hence, I plan to redo the above PR. Based on the newer changes, I think it should be a fairly small PR. Please let me know if you have any suggestions for me going into the change set and whether I should be on the lookout for any other conflicting changes that you may be aware of. |
This change primarily adds the set_selection APIs (crop and compose). While the hardware supports other binning ratios, only the
BINNING_NONE
,BINNING_2x2
andBINNING_2x2_ANALOG
are supported. The rule to use the "special binning" is based on the frame size and whether it is an 8-bit format. At the same time with this change, the driver allows binning on x or y dimensions or both based on the crop and compose fields.The biggest change in terms of the implementation is to reduce the scope of
imx219->mode
. Instead, thecrop
andcompose
are stored in theimx219
struct. All the usages ofimx219->mode
have been transitioned to use these fields instead except in theimx219_init_controls
to set defaults. Thesupported_modes
continues to be used forS_FMT
operations.One change in the API is that the v_blank value is not set to the default of the mode selected on
S_FMT
but is based on whatever the user set last. It should be possible to avoid this if not maintaining thev_blanking
in theS_FMT
op is a required feature.Note
The commits are separated out in order to help review the code. I plan to squash all of them into 1 or 2 commits if and when it's close to getting approval unless the reviewers prefer I squash it right away.
Links