-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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: media: imx708: Tweak broken line correction parameter #5701
Conversation
Sony don't specify definitive values for these QBC parameters. I also experimented with QBC Re-mosaic noise-reduction and false-colour curves but those had a less obvious effect, so have left them at the defaults (for minimal filtering). |
No particularly strong views from me. |
Hmm. The register name |
If you assign specific values rather than allowing the user to write any arbitrary rubbish, then you can describe what those values are in the parameter text, eg
https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/drm_print.c#L45 |
c2d22e6
to
ae1547c
Compare
|
@@ -1515,6 +1521,10 @@ static int imx708_start_streaming(struct imx708 *imx708) | |||
return ret; | |||
} | |||
|
|||
/* Quad Bayer re-mosaic adjustments (for full-resolution mode only) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does the sensor handle this only affecting full res mode? The registers were in imx708_reg mode_4608x2592_regs so inherently only affected full res mode, but now this is common for all modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presumed there were no side-effects from redundantly writing them, so it seemed unnecessary to spend a line of code checking the mode.
Previously they would have been left unchanged when switching from full-res to another mode (not that that happened often). More commonly they would keep their reset values (0x01,0x01). Yes I suppose it would make sense to explicitly set the "disable" flag in other modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously they would have been left unchanged when switching from full-res to another mode (not that that happened often).
Did they actually persist? imx708_set_stream calls pm_runtime_get_sync on enable and pm_runtime_put on disable, which in theory enables and disables regulators (may be delayed, I've never checked). This is why Laurent is pushing for using pm_runtime_set_autosuspend_delay
/ pm_runtime_use_autosuspend
/ pm_runtime_put_autosuspend
to definitely avoid dropping regulators on a mode switch.
If tested then I'm happy for it to remain unconditional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A running switch can happen in libcamera-still when taking a timelapse, or some Python cases -- not common ones. Anyway, it now sets the enable conditionally.
Yes, tested. I'd forgotten about HDR mode but have now tested that too.
(I swapped the order of the writes in the hope it might do a tail merge and save a few bytes of code...)
drivers/media/i2c/imx708.c
Outdated
@@ -1515,6 +1521,10 @@ static int imx708_start_streaming(struct imx708 *imx708) | |||
return ret; | |||
} | |||
|
|||
/* Quad Bayer re-mosaic adjustments (for full-resolution mode only) */ | |||
imx708_write_reg(imx708, 0xC428, IMX708_REG_VALUE_08BIT, !qbc_adjust); | |||
imx708_write_reg(imx708, 0xC429, IMX708_REG_VALUE_08BIT, qbc_adjust); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0xc428 is an enable and 0xc429 is a strength?
Checking datasheet it is, but with 0xc428 = 0 being enabled, and = 1 being disabled. Quirky!
I'd be tempted to use qbc_adjust ? 0x01 : 0x00
instead of !qbc_adjust
to make it more obvious the values being programmed, otherwise you end up checking the C specification to confirm that !0 = 1. Even better would be macros defining the bits in the register.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen many examples of ! and !! for this elsewhere but I agree ?: is clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make sure you get them the right way round....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now reworked and hopefully clearer, if a bit less terse.
In full-resolution mode, the LPF_INTENSITY_EN and LPF_INTENSITY registers control Quad Bayer Re-mosaic broken line correction. Expose this as a module parameter "qbc_adjust": zero disables the correction and values in the range 2 to 5 set its strength. There is a trade-off between coloured and monochrome patterns. The previous fixed value 4 could produce ladder/spots artefacts in coloured textures. The new default value 2 may suit a wider range of scenes. Signed-off-by: Nick Hollinghurst <[email protected]>
ae1547c
to
5cae9cc
Compare
LGTM (I'll ignore the unrelated whitespace change). |
LGTM |
kernel: KMS stale dlist alloc changes See: raspberrypi/linux#5684 kernel: drm/vc4: crtc: Support odd horizontal timings on BCM2712 See: raspberrypi/linux#5679 kernel: spi: dw-dma: Get the last DMA scoop out of the FIFO See: raspberrypi/linux#5699 kernel: defconfigs: Drop FB_UDL from all Pi defconfigs See: raspberrypi/linux#5702 kernel: RP1 GPIO header SDIO support See: raspberrypi/linux#5704 kernel: ASoC: bcm: audioinjector_octo: Add soundcard owner See: raspberrypi/linux#5705 kernel: drivers: media: imx708: Tweak broken line correction parameter See: raspberrypi/linux#5701
kernel: KMS stale dlist alloc changes See: raspberrypi/linux#5684 kernel: drm/vc4: crtc: Support odd horizontal timings on BCM2712 See: raspberrypi/linux#5679 kernel: spi: dw-dma: Get the last DMA scoop out of the FIFO See: raspberrypi/linux#5699 kernel: defconfigs: Drop FB_UDL from all Pi defconfigs See: raspberrypi/linux#5702 kernel: RP1 GPIO header SDIO support See: raspberrypi/linux#5704 kernel: ASoC: bcm: audioinjector_octo: Add soundcard owner See: raspberrypi/linux#5705 kernel: drivers: media: imx708: Tweak broken line correction parameter See: raspberrypi/linux#5701
In QBC full-resolution mode, reduce QBC_LPF_INTENSITY parameter to reduce the occurrence of re-mosaic artefacts in colourful scenes, at the slight expense of black-and-white ones.
See IMX708_IQ_Tuning_Operation_Manual_v1.0.0 section 4.
Higher values reduce broken-line artifacts in black-and-white gratings with perfect white balance gains, but can introduce "ladder" artefacts in coloured gratings and textures. It is a trade-off, but existing test images and user feedback suggest the latter are more important. Reducing the register value reduces the frequency (but not the severity) of these artifacts in many cases.