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

5.10 hdmi cec rework #3999

Merged
merged 30 commits into from
Feb 5, 2021
Merged

Conversation

popcornmix
Copy link
Collaborator

This switches our CEC support to the version @mripard has cleaned up for upstreaming.
In testing it worked for me using kms on Pi3 and Pi4 in a range of HDMI modes.

@popcornmix
Copy link
Collaborator Author

@pelwell I've attempted to disable by default and enable in the overlay but it's not working.
I think target should reference interrupt-controller but that's not working.

@popcornmix popcornmix force-pushed the 5.10-hdmi-cec-rework branch 2 times, most recently from e8ebd66 to 3eda551 Compare December 9, 2020 17:54
@pelwell
Copy link
Contributor

pelwell commented Dec 9, 2020

Does the overlay now successfully enable the interrupt controllers?

Copy link
Contributor

@mripard mripard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably not merge 961cd2f, or introduce it back.

It was meant to ease the rebasing of my branch, but it still looks useful

@popcornmix
Copy link
Collaborator Author

Added "drm/vc4: Reading the hotplug register is only valid if no GPIO defined" back.

Yes, overlay changes appear successful.
We mask CEC interrupt on firmware and interrupts work on arm when vc4 overlay is enabled.
We do not mask CEC interrupt on firmware when vc4 overlay is not enabled and firmware cec works.

@popcornmix popcornmix force-pushed the rpi-5.10.y branch 2 times, most recently from 8cb2e66 to 967d45b Compare December 18, 2020 18:55
@popcornmix popcornmix force-pushed the rpi-5.10.y branch 2 times, most recently from b1f4757 to 31fbc18 Compare December 27, 2020 13:53
@popcornmix popcornmix force-pushed the 5.10-hdmi-cec-rework branch 2 times, most recently from 30400fd to 7a903f9 Compare January 7, 2021 17:41
@popcornmix popcornmix force-pushed the rpi-5.10.y branch 2 times, most recently from 3403b48 to ab9e2a6 Compare January 11, 2021 14:55
@popcornmix popcornmix changed the title WIP: 5.10 hdmi cec rework 5.10 hdmi cec rework Jan 11, 2021
@popcornmix
Copy link
Collaborator Author

Updated to v2 of patches. cec now works on second hdmi port. Removed WIP.

popcornmix and others added 16 commits January 29, 2021 17:57
The code prior to 311e305 ("drm/vc4: hdmi: Implement a register
layout abstraction") was relying on the fact that the register offset
was incremented by 4 for each readl call. That worked since the register
width is 4 bytes.

However, since that commit the HDMI_READ macro is now taking an enum,
and the offset doesn't increment by 4 but 1 now. Divide the index by 4
to fix this.

Fixes: 311e305 ("drm/vc4: hdmi: Implement a register layout abstraction")
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
The commit 311e305 ("drm/vc4: hdmi: Implement a register layout
abstraction") forgot one CEC register, and made a copy and paste mistake
for another one. Fix those mistakes.

Fixes: 311e305 ("drm/vc4: hdmi: Implement a register layout abstraction")
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Currently we call cec_phys_addr_invalidate on a hotplug deassert.
That may be due to a TV power cycling, or an AVR being switched
on (and switching edid).

This makes CEC unusable since our controller wouldn't have a physical
address anymore.

Set it back up again on the hotplug assert.

Fixes: 15b4511 ("drm/vc4: add HDMI CEC support")
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The CEC clock divider needs to output a frequency of 40kHz from the HSM
rate on the BCM2835. The driver used to have a fixed frequency for it,
but that changed for the BCM2711 and we now need to compute it
dynamically to maintain the proper rate.

Fixes: cd4cb49 ("drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate")
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
As part of the enable sequence we might change the HSM clock rate if the
pixel rate is different than the one we were already dealing with.

On the BCM2835 however, the CEC clock derives from the HSM clock so any
rate change will need to be reflected in the CEC clock divider to output
40kHz.

Fixes: cd4cb49 ("drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate")
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
While the BCM2835 had the CEC clock derived from the HSM clock, the
BCM2711 has a dedicated parent clock for it.

Let's introduce a separate clock for it so that we can handle both
cases.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
The BCM2711 has two different interrupt sources to transmit and receive
CEC messages, provided through an external interrupt chip shared between
the two HDMI interrupt controllers.

The rest of the CEC controller is identical though so we need to change
a bit the code organisation to share the code as much as possible, yet
still allowing to register independant handlers.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The HDMI controller found in the BCM2711 has an external interrupt
controller for the CEC and hotplug interrupt shared between the two
instances.

Let's add a variant flag to register a single interrupt handler and
deals with the interrupt handler setup, or two interrupt handlers
relying on an external irqchip.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Now that our HDMI controller supports CEC for the BCM2711, let's remove
that flag.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
We introduced the BCM2711 support to the vc4 HDMI controller with 5.10,
but this was lacking any of the interrupts of the CEC controller so we
have to deal with the backward compatibility.

Do so by simply ignoring the CEC setup if the DT doesn't have the
interrupts property.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
The CEC and hotplug interrupts were missing when that binding was
introduced, let's add them in now that we've figured out how it works.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The BSC controllers used for the HDMI DDC have an interrupt controller
shared between both instances. Let's add it to avoid polling.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
The CEC and hotplug interrupts go through an interrupt controller shared
between the two HDMI controllers.

Let's add that interrupt controller and the interrupts for both HDMI
controllers

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Unlike the previous generations, the HSM clock limitation is way above
what we can reach without scrambling, so let's move the maximum
frequency we support to the maximum clock frequency without scrambling.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Now handled through aon_intr

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
@popcornmix
Copy link
Collaborator Author

popcornmix commented Jan 29, 2021

[edit] ignore that - I'm on an older firmware that doesn't disable its handling of cec interrupts

@popcornmix
Copy link
Collaborator Author

I think this is good. I believe it's been accepted upstream and testing on Pi3 and Pi4 with kms worked.

@popcornmix
Copy link
Collaborator Author

@pelwell okay to merge?

@pelwell pelwell merged commit 34263dc into raspberrypi:rpi-5.10.y Feb 5, 2021
@popcornmix popcornmix deleted the 5.10-hdmi-cec-rework branch February 5, 2021 15:49
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Feb 8, 2021
kernel: media: i2c: imx290: Support V4L2_CID_ANALOGUE_GAIN as well as V4L2_CID_GAIN
See: raspberrypi/linux#4119

kernel: i2c: bcm2835: Handle untimely DONE signal
See: raspberrypi/linux#3064

kernel: 5.10 hdmi cec rework
See: raspberrypi/linux#3999

kernel: w1: w1_therm: Fix conversion result for negative temperatures
See: raspberrypi/linux#4124

kernel: staging:bcm2835-camera: Fix the cherry-pick of AWB Greyworld
See: raspberrypi/linux#4131
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Feb 8, 2021
kernel: media: i2c: imx290: Support V4L2_CID_ANALOGUE_GAIN as well as V4L2_CID_GAIN
See: raspberrypi/linux#4119

kernel: i2c: bcm2835: Handle untimely DONE signal
See: raspberrypi/linux#3064

kernel: 5.10 hdmi cec rework
See: raspberrypi/linux#3999

kernel: w1: w1_therm: Fix conversion result for negative temperatures
See: raspberrypi/linux#4124

kernel: staging:bcm2835-camera: Fix the cherry-pick of AWB Greyworld
See: raspberrypi/linux#4131
@6by9
Copy link
Contributor

6by9 commented Feb 8, 2021

I rebased my tree this morning (still 5.10.13) and I appear to not be able to enable i2c_vc or i2c_arm successfully

[    6.153644] i2c-bcm2835 fe804000.i2c: Could not request IRQ

This is the main DT change going, but I can't immediately see any issue with it.

I'm doing a quick roll-back to try and confirm. Whilst that's building I'll do an rpi-update to check 5.10.14 out.

@6by9
Copy link
Contributor

6by9 commented Feb 8, 2021

Sorry, I should add that it was when vc4-kms-v3d was loaded as well.

@6by9
Copy link
Contributor

6by9 commented Feb 8, 2021

5.10.14-v7l from rpi-update files also fail with Could not request IRQ.
I get /dev/i2c-11 and /dev/i2c-12 for the HDMI devices, but not /dev/i2c-1.
Remove dtoverlay=vc4-kms-v3d from config.txt and /dev/i2c-1 returns.

@6by9
Copy link
Contributor

6by9 commented Feb 8, 2021

98a2669 (with a couple of WIP patches on top) is good.

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