-
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
IMX477 improvements #6208
base: rpi-6.6.y
Are you sure you want to change the base?
IMX477 improvements #6208
Conversation
Added a 16:9 cropped mode, and option of 10 or 12 readout for all modes.
It does currently need a manual I have seen coloured sparkles on some images, particularly when dark, however I'm not certain it's not my HDMI->DVI lead at fault. Testing needed on a known good setup. There is an open question as to whether we accept 1.8Gbit/s even though that is out of spec for RP1, or scale it back to 1.5Gbit/s. And do we need to look at EMC implications? |
3107f42
to
2bafdbc
Compare
Perhaps we could enable the out-of-spec modes using a module or DT parameter? It should be disabled by default to make it clear they are not generally supported. (Unsupported because that they might work on some devices and not others; or might stop working on a new board revision; or work with certain type or length of camera cable; or have EMC issues...) |
It is already - you have to enable it with |
Ah. I didn't spot that. Though possibly it needs a scarier name... |
Name open to debate. I'll drop SM and DP an email to get guidance on EMC for this change. If it's feasible to make this the default for Pi5 then I don't see why we shouldn't, but it needs some more extensive testing first. |
I had a brief discussion with both SM and DP. Suggestion of hacking the driver to increase the clock by 10% (easy to do) and then stick it in the environmental test chamber to test it when both hot and cold. If that is solid, then we can have reasonable confidence that it'll work on the vast majority of boards. We are going to have to test with the various lengths of official camera cables. Those who use non-impedance matched FFCs can be advised to use better cables or drop the override. |
D-PHY driver will currently log an error, and pin its timings (for e.g. clock recovery and entry/exit detection) for the 1350-1500 Mbps range. With 10bpp and cropping can we not achieve 4kp30 at <= 1.5GHz? |
We could (32.39fps for cropped 10bit, 26.99fps in 12bit), but I just went for the simple option of reducing IOP_SYCK_DIV from 2 to 1 which doubles the CSI clock. |
Issue reported with the 2028x1080 and 2028x1520 modes with 10 bit readout - we get totally white frames. It's only true at the new 1.8Gbit/s link frequency, so it's likely a duplicated register setting in the mode table vs programmatic configuration. |
Discussion with GSH says to keep to the 1.5Gbit/s spec of RP1, so this will want a littler rework to allow alternate PLL multipliers in the MIPI clock path. We may as well make it more generic so that MPP_IOP is computed based on the link frequency so any multiple of 12MHz can be used |
Don't know if it helps to narrow down the issue, but on looking at these two modes again, the metadata is showing a fixed 94 microseconds ExposureTime, and a fixed AnalogueGain of 1.0 while the white frames are being generated. Separately, there looks to be an inconsistency in the /* Mode configs */ structure definition for imx477_mode supported_modes[]. |
Sadly not. It'll just be that the AE/AGC algorithms will have tried turning everything down as far as it can go because the statistics are seeing a saturated image.
I believe you're right, but in reality it is going to have limited effect. Due to other time pressures I don't know when I'll get back to looking at this. |
Following up on the inquiry made here: https://forums.raspberrypi.com/viewtopic.php?p=2227965#p2227965 I'm attempting to get a 4000x3000 12-bit sensor mode to reach a minimum of 24fps. ( Ideally I'd love to use the full readout, but the next largest 4:3 pixel area is my target. ) I've tried to make the most sense out of which registers control crop based on the diff between the full readout and 2160 crop mode. as such I've made some educated guesses on the what the controls do:
and adjusting the mode and tightening up the line length just enough that I may reach just a touch over 24fps.
It "almost" works, but clearly the crop is not functioning as it should as it is removing what appears to be the bottom 20-40 rows of pixels ( I haven't actually counted ), and after some hours of tinkering I cannot get it working properly. Any further insights into getting something like this to work would be excellent! |
I haven't time to investigate this further at the moment. As per #6208 (comment), the update is likely to be reducing the link rate to 1.5Gbit/s, so moving further away from your target. If I can easily make it generic, then I will. Simplest answer then is to go higher than 1.8Gbit/s and you will be able to get full res at 24fps. I can't see anything obviously wrong with your register settings, however the datasheet does include a couple of restrictions on the start and end values for cropping. For no binning:
0x0408 to 0x040f are the digital cropping registers (X offset, Y offset, width, height), so you may be able to leave the mode registers alone and digitally crop to get your desired result. |
A moderate bump up to 1.9-2Gbits would be great... to get even a vague idea of registers requiring change and to the what values would be awesome! ; ) |
Hi, I'm trying to pull this PR, but it fails with a 404 error. Is there another way to try this branch, and could you clarify why it fails? |
The build artifacts are only retained for 90 days, and this is an old PR. I've rebased it now which has kicked off another build - try again in 45 minutes. |
Registers 0x0342 / 0x0343 are set via IMX477_REG_LINE_LENGTH as V4L2_CID_HBLANK, so shouldn't be in the register tables. Registers 0x0340 / 0x0341 are set via IMX477_REG_FRAME_LENGTH as V4L2_CID_VBLANK so shouldn't be in the register tables. Registers 0x0112 and 0x0113 set the bit depth, so should be per mode rather than in the common table and overridden for the 10bit mode(s). Signed-off-by: Dave Stevenson <[email protected]>
There are a fair number of registers duplicated in all the mode tables, so move those into the common table. Signed-off-by: Dave Stevenson <[email protected]>
The driver was using a struct v4l2_fract for the min frame time to determine the range for V4L2_CID_VBLANK, and a second to set the default VBLANK value for each mode. However actually the sensor will accept any VBLANK value down to 1 line, and using a struct v4l2_fract to hold the default framerate (which is an integer in all cases) is rather overkill. Drop the minimum frame time, and use a simple integer to set the default. This actually increases the max frame rate in all modes slightly. Signed-off-by: Dave Stevenson <[email protected]>
The register set was always selecting continuous clock mode, even though all our overlays were saying it should be non-continuous. Read the configuration from fwnode and configure the sensor accordingly. Signed-off-by: Dave Stevenson <[email protected]>
Pi5 can support higher CSI2 link frequencies than Pi 0-4, and hence higher framerates. The simplest change is to change the DIV_IOP_PX divider from the current value of 2 to 1 to double the frequency. This is slightly outside the max rate nominally supported by RP1, but seems reliable. Signed-off-by: Dave Stevenson <[email protected]>
The driver can now support a link freq of 900MHz (1.8Gbit/s/lane) for higher frame rates. Add an override for "pi5" that changes this link frequency. Signed-off-by: Dave Stevenson <[email protected]>
For 4k30 recording we want 16:9 output, so add a cropped mode to achieve this. Signed-off-by: Dave Stevenson <[email protected]>
FIXME: Dropping the default frame rate needs to be separated out. Switching between 10 and 12 bit mode only requires a couple of registers to change, and an associated change to the minimum HBLANK that can be supported in the mode based on how long it takes the CSI2 block to send each line of the image. Add suitable switching between the 2 for all modes.
3db4854
to
e50416c
Compare
Pushing for backup and @naushir 's reference
Dropping min VBLANK to 1 improves max frame times slightly.
Now working on doubling the link frequency. That won't quite get us 4k30, but adding a cropped mode would (just going down to 16:9 aspect may be sufficient).
I've also sussed the runes to switch any mode from between 10 and 12 bit. Computing the min HBLANK in each case is going to be tricky, so they may end up being 2 hardcoded values.
(I'm assuming libcamera will choose the higher bit depth if it can achieve the frame rate desired, so offering either depth is reasonable)