Skip to content
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

HVS Gamma LUT support for the RPi4 #4435

Merged
merged 3 commits into from
Oct 27, 2021

Conversation

mripard
Copy link
Contributor

@mripard mripard commented Jul 6, 2021

Hi,

Here's a PR to implement the gamma lut property on the rpi4. This is work that has mostly been done by @6by9 and Juerg Haefliger from Canonical.

Maxime

@juergh
Copy link
Contributor

juergh commented Jul 6, 2021

Patch #1 and #2 should really be authored by @6by9 since they're mostly his work. Also, we should drop the register write retries since they are no longer necessary thanks to patch #3. I think. I'll do some testing to verify that.

@mripard mripard force-pushed the rpi/5.10-gamma-lut branch 2 times, most recently from d34c788 to 7ee54bf Compare July 15, 2021 11:47
@mripard
Copy link
Contributor Author

mripard commented Jul 15, 2021

I've changed the authorship to have @6by9 and you as the main author, and removed the register write retries.

@juergh
Copy link
Contributor

juergh commented Oct 22, 2021

I have tested this patchset successfully on top of the current rpi-5.10.y branch (commit 03ab887). I also verified that LUT register rewrites are indeed no longer necessary and writes always seem to stick. What's a little concerning though is that the screen blanks for ~2 secs for each update of the LUT (96 register writes). FWIW, doing 100 subsequent LUT updates blanks the screen for ~7 secs. I don't know how GNOME or other tools implement the nightlight feature and how many LUT updates at what intervals are performed but it could result in a significant disturbance. As I understand it, this is a HW limitation and IMO it will trigger bug reports.

@6by9
Copy link
Contributor

6by9 commented Oct 22, 2021

Sorry, I totally missed @mripard's update.

Slightly weird wording in commit 3's commit text

Since the pixelvalve cannot have its assigned channel without stalling
unless it's disabled as well, in our case that means forcing a full
disable / enable cycle on the pipeline.

Missing the word "changed", or "halted"?

Other than that, the patches look fine.

FWIW, doing 100 subsequent LUT updates blanks the screen for ~7 secs. I don't know how GNOME or other tools implement the nightlight feature and how many LUT updates at what intervals are performed but it could result in a significant disturbance. As I understand it, this is a HW limitation and IMO it will trigger bug reports.

It is a hardware limitation, so it's the choice of either blanking, or not supporting the gamma controls.

@juergh
Copy link
Contributor

juergh commented Oct 22, 2021

Ok. Then I'd rather have support and let the user choose (and deal with the consequences :-)).

6by9 and others added 3 commits October 27, 2021 10:52
BCM2711 changes from a 256 entry lookup table to a 16 point
piecewise linear function as the pipeline bitdepth has increased
to make a LUT unwieldy.

Implement a simple conversion from a 256 entry LUT that userspace
is likely to expect to 16 evenly spread points in the PWL. This
could be improved with curve fitting at a later date.

Co-developed-by: Juerg Haefliger <[email protected]>
Signed-off-by: Juerg Haefliger <[email protected]>
Signed-off-by: Dave Stevenson <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
This helps with debugging the conversion from a 256 point gamma LUT to
16 point PWL entries as used by the BCM2711.

Co-developed-by: Juerg Haefliger <[email protected]>
Signed-off-by: Juerg Haefliger <[email protected]>
Signed-off-by: Dave Stevenson <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
The HVS Gamma block can only be updated when idle, so we need to disable
the HVS channel when the gamma property is set in an atomic commit.

Since the pixelvalve cannot have its assigned channel halted without
stalling unless it's disabled as well, in our case that means forcing a
full disable / enable cycle on the pipeline.

Signed-off-by: Maxime Ripard <[email protected]>
@mripard mripard force-pushed the rpi/5.10-gamma-lut branch from 7ee54bf to 583454a Compare October 27, 2021 08:52
@mripard
Copy link
Contributor Author

mripard commented Oct 27, 2021

I've just pushed a new version with the commit log changed like you suggested (and rebased on the current branch)

@6by9
Copy link
Contributor

6by9 commented Oct 27, 2021

LGTM

@mripard can I ask you to upstream that if you're happy with it?

@mripard
Copy link
Contributor Author

mripard commented Oct 27, 2021

Yep, sure

@pelwell pelwell merged commit e6d7aea into raspberrypi:rpi-5.10.y Oct 27, 2021
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Oct 28, 2021
kernel: clk: Move vec clock to clk-raspberrypi
See: raspberrypi/linux#4639

kernel: ARM: v7: get rid of boot time mini stack
See: raspberrypi/linux#4591

kernel: HVS Gamma LUT support for the RPi4
See: raspberrypi/linux#4435

kernel: ARM: dts: Add Pi Zero 2 support

firmware: arm_loader: Allow VEC clock to be controlled by arm
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Oct 28, 2021
kernel: clk: Move vec clock to clk-raspberrypi
See: raspberrypi/linux#4639

kernel: ARM: v7: get rid of boot time mini stack
See: raspberrypi/linux#4591

kernel: HVS Gamma LUT support for the RPi4
See: raspberrypi/linux#4435

kernel: ARM: dts: Add Pi Zero 2 support

firmware: arm_loader: Allow VEC clock to be controlled by arm
@6by9
Copy link
Contributor

6by9 commented Nov 2, 2021

So X seems to throw a load of calls through drm_crtc_legacy_gamma_set which always replaces the gamma property blob.

I'm just seeing if there is a quick way to do a memcmp before the replace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants