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

drm/vc4: Set TV margins on the composite connector state #5720

Merged
merged 1 commit into from
Nov 24, 2023
Merged

drm/vc4: Set TV margins on the composite connector state #5720

merged 1 commit into from
Nov 24, 2023

Conversation

strobo5
Copy link

@strobo5 strobo5 commented Nov 19, 2023

The overscan_* settings in the config.txt do not work on the composite video output with the VC4 KMS driver. This patch fixes it (tested on a Raspberry Pi 4). See the commit message for a more detailed description.

Here are some forum entries that I collected where people are reporting this issue:
https://forums.raspberrypi.com/viewtopic.php?t=330579
https://forums.raspberrypi.com/viewtopic.php?t=330924
https://forums.raspberrypi.com/viewtopic.php?t=342062

I did not test this with an upstream kernel, but it already does the necessary drm_atomic_helper_connector_tv_reset() in the conncetor reset function. On the other hand it does not call drm_connector_attach_tv_margin_properties() in the connector init function, which I think is necessary?!

What is the correct approach here: patch the raspberrypi kernel, then try to send a similar patch upstream?

@6by9
Copy link
Contributor

6by9 commented Nov 20, 2023

This partly looks to have been fixed in mainline since 6.3 with torvalds/linux@c104b23, however I think that has missed the call to drm_connector_attach_tv_margin_properties.

Downstream has gained 745e078 in the meantime which allows the TV standard to be set via a module parameter.

I'll try to test it tomorrow to see what the state of play is in both cases. I'm happy to have a patch for it on this 6.1 branch, and we'll look at fixing mainline another day (I have a BIG pile of patches to send for Pi5 support)

@strobo5
Copy link
Author

strobo5 commented Nov 21, 2023

That sounds like a good approach to me. Thanks for looking into this. Let me know if I can help out with testing.

The margins seem to be different from the TV standard in that the comma-separated options in video= more or less directly translate into the numbers in the connector state. So my guess is that a new module parameter would not make sense here?

I'll push the commit again with my sign-off message.

@strobo5
Copy link
Author

strobo5 commented Nov 22, 2023

I couldn't stop myself from setting up a Raspberry Pi 1 with an upstream linux-6.6.2, and getting PAL output to work.

The trick was to manually set PAL mode with one of these:

modetest -M vc4 -w 50:"mode":2
modetest -M vc4 -w 50:"TV mode":3

The margins from the kernel cmdline are getting applied without further changes, thanks to drm_atomic_helper_connector_tv_reset() being called.

When I modify vc4_vec_connector_init() to do drm_connector_attach_tv_margin_properties(), the margin properties are also available to libdrm's drmModeObjectGetProperties() and can be changed with e.g.

modetest -M vc4 -w 50:"left margin":100

The Raspberry Pi bootloader can pass a set of margin values to the
kernel cmdline as part of the video= option. These should result in
black borders on the output to compensate for TVs where the visible area
on the screen is smaller than the full extents of the video image.

With the VC4 driver this currently works on an HDMI connector, but not
on a composite video connector.

The TV margins from the kernel cmdline are available in the
drm_cmdline_mode structure of the composite video connector. Apply them
to the connector state in the connector reset function. This is how it
is implemented for the VC4 HDMI connector.

Signed-off-by: Michael Büchler <[email protected]>
@6by9
Copy link
Contributor

6by9 commented Nov 24, 2023

Sorry for the delay in testing this.
All looks good for this patching 6.1.

I'll sort out the patch to add drm_connector_attach_tv_margin_properties to the 6.6 kernel, and will upstream it in due course.

@6by9
Copy link
Contributor

6by9 commented Nov 24, 2023

#5745 for the 6.6 fix.

6.2 to 6.5 are unlikely to get updated as they've been superceded by 6.6.

@6by9
Copy link
Contributor

6by9 commented Nov 24, 2023

@popcornmix Could you cast an extra set of eyes over this one.

Upstream 6.3 gained some changes in this area, hence 6.6 needing fewer changes.

@pelwell pelwell merged commit bc76ab2 into raspberrypi:rpi-6.1.y Nov 24, 2023
12 checks passed
@strobo5
Copy link
Author

strobo5 commented Nov 25, 2023

Perfect, thank you!

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.

3 participants