PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

DPI and hdmi

Thu Jul 09, 2020 3:20 pm

I'm trying to test framebuffer with DPI and HDMI any starting point ?
only HDMI work ok with bzt examples, thanks bzt

cleverca22
Posts: 941
Joined: Sat Aug 18, 2012 2:33 pm

Re: DPI and hdmi

Thu Jul 09, 2020 3:32 pm

i think setting `display_default_lcd=1` in `config.txt` will force the main framebuffer to be over DPI, then you can just use the old framebuffer mailbox stuff to interface with it as always?

if you want more direct control, you would move on to the HVS stuff: https://blog.benjdoherty.com/2019/05/21 ... pberry-Pi/

basically, the firmware will configure an output to use a given HVS channel, and then you can freely change the HVS config whenever you want (though that will have some tearing artifacts)

there are 3 HVS channels, and 3 registers pointing to the start of the displaylist within the HVS config memory

https://github.com/librerpi/rpi-open-fi ... #L159-L190

and this is some code i wrote to try and understand the HVS, it will spy on the current state via /dev/mem while under linux, and try to pretty-print whatever is being drawn currently

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Sun Jul 19, 2020 1:31 pm

I'm trying to configure PixelValve and I can't
I write the value at address PV_C and write only one byte not dword

Code: Select all

#define PV_C					*((volatile uint32_t*)(MMIO_BASE + 0x00206000))
PV_C = 0x00177005;
result 0x70697805 write only 0x05(byte)
any idea ?
must password ?

cleverca22
Posts: 941
Joined: Sat Aug 18, 2012 2:33 pm

Re: DPI and hdmi

Sun Jul 19, 2020 1:51 pm

PiCS wrote:
Sun Jul 19, 2020 1:31 pm
I'm trying to configure PixelValve and I can't
I write the value at address PV_C and write only one byte not dword

Code: Select all

#define PV_C					*((volatile uint32_t*)(MMIO_BASE + 0x00206000))
PV_C = 0x00177005;
result 0x70697805 write only 0x05(byte)
any idea ?
must password ?
thats weird
i dont see any signs of passwords when i disassemble the firmware, and ive not seen any trace of it in the linux source either

can you post more of your code, and maybe the disassembly of your code after its compiled?

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Sun Jul 26, 2020 1:30 pm

I tried to set hvs for DPI and I don't understand how to do it

hvs has 3 channels
one can be set for hdmi, dpi, dsi etc. but I don't understand how

I read it twice
https://blog.benjdoherty.com/2019/05/21 ... pberry-Pi/
https://github.com/torvalds/linux/blob/ ... /vc4_hvs.c

any help ?

cleverca22
Posts: 941
Joined: Sat Aug 18, 2012 2:33 pm

Re: DPI and hdmi

Sun Jul 26, 2020 3:15 pm

can you paste the code you tried using?
which model of pi?

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Mon Jul 27, 2020 2:47 pm

raspberry pi CM3L
build with gcc aarch64-elf
read value from buster and put on register, work little, but I don't understand how
souce code, I don't know how to attach the project here
send me PM with email

cleverca22
Posts: 941
Joined: Sat Aug 18, 2012 2:33 pm

Re: DPI and hdmi

Mon Jul 27, 2020 7:29 pm

either use [ code] tags, or post some code to github or gist and paste the link


LdB
Posts: 1593
Joined: Wed Dec 07, 2016 2:29 pm

Re: DPI and hdmi

Tue Jul 28, 2020 8:54 am

For a start your linker file is wrong map the output with something like this in the makefile

Code: Select all

$(ARMGNU)-nm -n $(BUILD_DIR)/kernel8.elf > kernel8.map

You get this ... the CPU starts at 0x80000 unless you use config.sys to force a 0x0 start
You don't discuss anything about special config.sys settings you are using (if you do you need to show us it)
It almost looks like its setup for QEMU to me which wont work on actual hardware and crashes and burns

Code: Select all

0000000000000000 T _start
0000000000000010 t proc_hang
0000000000000014 t master
0000000000000030 t write_plane
0000000000000250 T write_display_list
0000000000000358 T kernel_main
0000000000000aa0 T debug_print_registers
0000000000000ae4 T debug_print_memory
0000000000000b78 T setup_dpi_pixel_valve
0000000000000f4c T setup_HVS_DPI
00000000000010f8 T setup_HVS
00000000000015fc t write_plane
000000000000181c T write_plane_DPI
0000000000001928 T Gpio_Setup
0000000000001c20 T Gpio_Output
0000000000001cd0 T Gpio_Input
0000000000001d4c T Gpio_Resistor
0000000000001e20 T uart_send
0000000000001e6c T uart_recv
0000000000001eac T uart_init
0000000000001fe8 T putc
000000000000200c t scanline
00000000000020bc t mirrored_scanlines
0000000000002190 T draw_circle_16
0000000000002324 T draw_rectangle_16
00000000000023ec T draw_rectangle_32
00000000000024b0 T clear_plane_16
000000000000251c T clear_plane_32
0000000000002584 t ui2a
00000000000026ac t i2a
0000000000002708 t a2d
0000000000002788 t a2i
0000000000002834 t putchw
0000000000002910 T tfp_format
0000000000002d58 T init_printf
0000000000002d90 T tfp_printf
0000000000002e54 t putcp
0000000000002e88 T tfp_sprintf
0000000000002f44 T get_el
0000000000002f50 T put32
0000000000002f58 T get32
0000000000002f60 T delay
0000000000002f6c T memzero
0000000000002f80 r dlist_buffer_count
0000000000002f88 r dlist_offsets
0000000000003138 r dlist_buffer_count
0000000000003140 r dlist_offsets
0000000000003148 d dlist_memory
0000000000003150 d dlist_memory
0000000000003158 B bss_begin
0000000000003158 b next_dlist_buffer
000000000000315a b next_dlist_buffer
0000000000003160 b stdout_putf
0000000000003168 b stdout_putp
0000000000003170 B fb_three
0000000000003178 B fb_two
0000000000003180 B fb_four
0000000000003188 B fb_one
0000000000003190 B bss_end

Okay for stock standard 0x80000 boot try this for the linker file ... can you check the SP address setup (perhaps just set to 0x80000 for now)
Seems to at least start now

Code: Select all

SECTIONS
{
	.text.boot 0x80000: { KEEP(*(.text.boot)) }
	.text : { *(.text .text.*) }
	.rodata : { *(.rodata .rodata.*) }
	.data : { *(.data .data.*) }
	. = ALIGN(0x8);
	bss_begin = .;
	.bss : { *(.bss .bss.*) } 
	bss_end = .;
}

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Tue Jul 28, 2020 11:35 am

thanks LdB
any info for DPI and HVS ?

LdB
Posts: 1593
Joined: Wed Dec 07, 2016 2:29 pm

Re: DPI and hdmi

Tue Jul 28, 2020 1:02 pm

Nope your code crashes and burns for me at setup_HVS_DPI & setup_HVS

But I haven't had time to look where you got these addresses and values you are setting and what it supposedly does

Code: Select all

ptrMem = (volatile uint32_t*)(PBASE + 0x00400334);
and

Code: Select all

ptrMem = (uint32_t*)(PBASE + 0x00400000);

On the other hand the code you linked works correctly when I run it on a baremetal stub
https://github.com/bejado/raspberry-pi- ... rc/hvs/src
I get exactly what he shows in the youtube video
Image

However I did have to change your makefile compiler options as it was throwing alignment errors because the code is a bit rough

Code: Select all

COPS = -Wall -O3 -nostdlib -nostartfiles -ffreestanding -Iinclude -march=armv8-a+crc -mcpu=cortex-a53+fp+simd -mstrict-align -fno-tree-loop-vectorize -fno-tree-slp-vectorize

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Tue Jul 28, 2020 2:50 pm

Code: Select all

ptrMem = (uint32_t*)(PBASE + 0x00400334);
ptrMem = (uint32_t*)(PBASE + 0x00400000);
start buster with DPI and HDMI,
read these values from buster and put register for me, work little, but I don't understand how
original code is https://github.com/bejado/raspberry-pi- ... er/src/hvs

LdB
Posts: 1593
Joined: Wed Dec 07, 2016 2:29 pm

Re: DPI and hdmi

Tue Jul 28, 2020 4:05 pm

You lost me ... those addresses don't appear anywhere in the code linked ?????
I get you are reading the values in buster but why those addresses?????

You had to get those addresses from somewhere so can you please show me exactly where?
I know you didn't randomly make up an offset like 0x00400334 :-)

My problem is I thought you just turned on the DPI port and it was automatically mirrored, I don't have a DPI screen to see.
My view is backed up by
https://www.raspberrypi.org/documentati ... /README.md
As previously mentioned, the GPU is responsible for driving the DPI display. Hence there is no Linux driver; the overlay simply sets the GPIO alt functions correctly.

So I don't understand what registers you think you are reading/writing at those addresses.
I thought what you do in setup_dpi_pixel_valve where you change all the GPIO ports was all you had to do?

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Tue Jul 28, 2020 8:03 pm

those addresses are from the scaler(hvs)
https://paulwratt.github.io/rpi-interna ... CALER.html
HVS = (PBASE + 0x00400000);
I read those addresses in the buster trying to set hvs and dpi as well
because I don't know how to set hvs for dpi

in order for DPI to work, you must set the ports and DPI register
https://paulwratt.github.io/rpi-interna ... n_DPI.html
then you have to set pixelvalve0 register
https://paulwratt.github.io/rpi-interna ... ALVE0.html
and finally hvs
here I do not know how to set hvs

LdB
Posts: 1593
Joined: Wed Dec 07, 2016 2:29 pm

Re: DPI and hdmi

Wed Jul 29, 2020 12:58 am

Still doesn't help me there is no such offset of 0x00400334 in any of those documents in fact there isn't even 334 in any of them. So I am still perplexed how did you get that number. Above you reference 0x00400000 but that does help where the 334 at the end comes from.

So I have no idea what this code below does other than write random values to a random address that crashes the VC4 and I can't help any further.

Code: Select all

void setup_HVS_DPI(void) {
	uint32_t *ptrMem;
	ptrMem = (uint32_t*)(PBASE + 0x00400334);
	*ptrMem++ = 0x00000664;
	*ptrMem++ = 0x00000000;
	*ptrMem++ = 0x64647276;
	*ptrMem++ = 0x801E0110;
	*ptrMem++ = 0x81000000;
	*ptrMem++ = 0xA19920C8;
	*ptrMem++ = 0x50FF3C90;
	*ptrMem++ = 0x80500400;
	*ptrMem++ = 0x81000000;
	*ptrMem++ = 0xA0A2B3EE;
	*ptrMem++ = 0x3C8F0800;
	*ptrMem++ = 0x00000000;
	*ptrMem++ = 0x00000000;
	*ptrMem++ = 0x10000000;
	*ptrMem++ = 0x07FF0000;
	*ptrMem++ = 0x000000FF;
	*ptrMem++ = 0x64647276;
	*ptrMem++ = 0x00000000;
	*ptrMem++ = 0x64647276;
}

cleverca22
Posts: 941
Joined: Sat Aug 18, 2012 2:33 pm

Re: DPI and hdmi

Wed Jul 29, 2020 1:49 am

i'm also confused as to where 0x00400334 came from, its not in any of my notes or docs

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Wed Jul 29, 2020 7:18 am

yes it is not found in the documentation
my buster set displaylist0(0x7e400020) with value 0x00000334 and displaylist1(0x7e400024) with value 0x00000664
and I deduced that the values ​​from (0x00000334 + 0x7E400000) are for hvs_dpi and those from (0x00000664 + 0x7E400000) are from hvs_hdmi
yes it's not good but how do i set HVS for DPI, VHS for HDMI i understand
thanks

cleverca22
Posts: 941
Joined: Sat Aug 18, 2012 2:33 pm

Re: DPI and hdmi

Wed Jul 29, 2020 8:37 am

PiCS wrote:
Wed Jul 29, 2020 7:18 am
yes it is not found in the documentation
my buster set displaylist0(0x7e400020) with value 0x00000334 and displaylist1(0x7e400024) with value 0x00000664
and I deduced that the values ​​from (0x00000334 + 0x7E400000) are for hvs_dpi and those from (0x00000664 + 0x7E400000) are from hvs_hdmi
yes it's not good but how do i set HVS for DPI, VHS for HDMI i understand
thanks
thats not fully how it works

you must pick an address within 0x7e40_2000 (not sure on the exact range), and put your display list at that address
you must then put the offset into that list, into SCALER_DISPLIST0 yourself, and the offset is going to be the addr/4, so if your list starts at 0x7e40_2334, then you put 0x334/4 into SCALER_DISPLIST0

SCALER_DISPLIST0 is telling the hardware where to look in the display list memory, and you update the display lists, then change SCALER_DISPLIST0 to swap the whole list out

LdB
Posts: 1593
Joined: Wed Dec 07, 2016 2:29 pm

Re: DPI and hdmi

Wed Jul 29, 2020 2:06 pm

Can I ask you to do a simple test on that sample code above that guy did
https://github.com/bejado/raspberry-pi- ... rc/hvs/src

copy and Insert your call "setup_dpi_pixel_valve();" just after "init_printf(0, putc);"

I would have thought that was all that was required and it doesn't crash my VC anymore but without a DPI screen I can't see what it's doing.

PiCS
Posts: 14
Joined: Sat Jun 20, 2020 3:51 pm

Re: DPI and hdmi

Sat Aug 08, 2020 8:03 pm

update source code
https://github.com/Sofian8954/rpi_hdmi_dpi
work more better HDMI and DPI
without function below not work ???

Code: Select all

void setup_HVS_DPI(void) {

	uint32_t *ptrMem;

	ptrMem = (uint32_t*)(PBASE + 0x00400334);
	*ptrMem++ = 0x00000664;
	*ptrMem++ = 0x00000000;
	*ptrMem++ = 0x64647276;

	*ptrMem++ = 0x801E0110;				// (480 << 12) + 272
	*ptrMem++ = 0x81000000;

}

Return to “Bare metal, Assembly language”