Skip to content

Add DPI mode 3 (rgb565-padhi) support to vc4-kms-dpi-generic #4882

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

Merged
merged 2 commits into from
Feb 10, 2022

Conversation

grigorig
Copy link
Contributor

@grigorig grigorig commented Feb 9, 2022

Adds support for DPI mode 3 (a different pin mapping) to the vc4-kms-dpi-generic overlay. This mode is used by some cheap DPI VGA adapters in particular, such as 'VGA565'. It can be used with these like this:

dtoverlay=vc4-kms-dpi-generic
dtparam=hactive=1024,hfp=24,hsync=136,hbp=160
dtparam=vactive=768,vfp=3,vsync=6,vbp=29
dtparam=clock-frequency=65000000
dtparam=rgb565-padhi

I noticed that the overrides weren't working, neither for bus format nor for the pin mapping overrides. I believe a recent refactoring broke this. I included a workaround, but I am not sure how correct it is. My Device Tree knowledge is very limited.

Apparently broken by commit 3c03397. Introduce new names to allow for
proper addressing of overrides.

Signed-off-by: Grigori Goronzy <[email protected]>
This mode is used by some DPI based display adapters, such as the
'VGA565' and 'VGA Zero' low-cost VGA adapters for the Raspberry Pi.

Signed-off-by: Grigori Goronzy <[email protected]>
@6by9
Copy link
Contributor

6by9 commented Feb 10, 2022

Adding rgb565-padhi looks fine.

I want to check out the other patch. I suspect it's an issue of application order - the overrides update <&panel> or <&dpi_node>, and then fragments 0 & 1 come along and overwrite them. In which case your patch is correct to update fragments 0 & 1 instead of the base nodes.
@pelwell will probably be able to confirm that one immediately to save me running that configuration.

@pelwell
Copy link
Contributor

pelwell commented Feb 10, 2022

Yes, the problem is one of application order. Overlay application is split into three phases - preparing the overlay fragments, applying intra-overlay fragments to other fragments, and applying the remaining fragments to the base dtb. In the case of runtime overlay application, the third phase is performed by the kernel.

Without the fixing patch provided here, the parameters are applied to fragment 100's panel node in phase 1, then they are overwritten by the defaults from fragment 0 in phase 2. This fix is one solution - applying the overrides to fragment 0 (and 1 - the same problem applies). The other would be to replace fragments 0 and 1 with code that directly patches the panel and dpi_node nodes:

&panel {
	compatible = "panel-dpi";

	width-mm = <154>;
	height-mm = <83>;
	bus-format = <0x1009>;

	timing: panel-timing {
		clock-frequency = <29500000>;
		hactive = <800>;
		hfront-porch = <24>;
		hsync-len = <72>;
		hback-porch = <96>;
		hsync-active = <1>;
		vactive = <480>;
		vfront-porch = <3>;
		vsync-len = <10>;
		vback-porch = <7>;
		vsync-active = <1>;

		de-active = <1>;
		pixelclk-active = <1>;
	};
};

&dpi_node {
	pinctrl-0 = <&dpi_18bit_gpio0>;
};

That is a large and unnecessary change, but it does reduce the amount of overlay magic needed, relying instead on the dtc compiler to combine chunks.

I did notice an asymmetry between the panel and dpi halves of the overlay. Fragment 0 targets the panel node in fragment 100, while fragment 1 targets the dpi node in the base dtb, which is also targeted by dpi_node in fragment 101. There is no overlay, and therefore no problem, but perhaps fragment 1 was intended to target dpi_node?

@grigorig
Copy link
Contributor Author

Thanks, I'm starting to understand what's going on. Maybe further cleanups (for better consistency) should be tackled in a separate PR though? I'm mostly a user and just want these features to work. 😅

@pelwell
Copy link
Contributor

pelwell commented Feb 10, 2022

I wasn't suggesting you make any changes to your PR. We'll take it as is, since it solves the immediate problem.

@pelwell pelwell merged commit 1f1a1f2 into raspberrypi:rpi-5.15.y Feb 10, 2022
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Feb 16, 2022
kernel: overlays: rpi-poe(-plus): Fix parameters
See: raspberrypi/linux#4877

kernel: i2c: bcm2835: Make clock-stretch timeout configurable
See: raspberrypi/linux#4855

kernel: Add DPI mode 3 (rgb565-padhi) support to vc4-kms-dpi-generic
See: raspberrypi/linux#4882

kernel: media: i2c: imx219: Scale the pixel clock rate for the 640x480 mode
See: raspberrypi/linux#4880

kernel: vc4_dpi fixes
See: raspberrypi/linux#4889

kernel: Change vc4 DSI to being a bridge
See: raspberrypi/linux#4878

kernel: sc16is7xx: Fix for incorrect data being transmitted
See: raspberrypi/linux#4885
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Feb 16, 2022
kernel: overlays: rpi-poe(-plus): Fix parameters
See: raspberrypi/linux#4877

kernel: i2c: bcm2835: Make clock-stretch timeout configurable
See: raspberrypi/linux#4855

kernel: Add DPI mode 3 (rgb565-padhi) support to vc4-kms-dpi-generic
See: raspberrypi/linux#4882

kernel: media: i2c: imx219: Scale the pixel clock rate for the 640x480 mode
See: raspberrypi/linux#4880

kernel: vc4_dpi fixes
See: raspberrypi/linux#4889

kernel: Change vc4 DSI to being a bridge
See: raspberrypi/linux#4878

kernel: sc16is7xx: Fix for incorrect data being transmitted
See: raspberrypi/linux#4885
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