phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Detecting if HDMI present

Mon Sep 24, 2012 10:21 am

I need to detect if an HDMI or a composit monitor is connected to PI.
I need to init the video in definition according to the monitor and select the right font.
Some idea ?

User avatar
RaTTuS
Posts: 10826
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Detecting if HDMI present

Mon Sep 24, 2012 10:34 am

tvservice -s
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: Detecting if HDMI present

Mon Sep 24, 2012 11:51 am

thanks, but I'm not using linux ...
I need this status by program...

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm

Re: Detecting if HDMI present

Mon Sep 24, 2012 3:28 pm

I am not sure you can, but your best bet is use these
https://github.com/raspberrypi/firmware ... -interface
There maybe things that are supported with HDMI hardware, but not by composit etc.

Maybe something like:
Test physical (display) width/height
Batteries not included, Some assembly required.

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: Detecting if HDMI present

Mon Sep 24, 2012 3:44 pm

Thanks, I wiil test it.

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: Detecting if HDMI present

Wed Sep 26, 2012 1:24 pm

DexOS wrote:I am not sure you can, but your best bet is use these
https://github.com/raspberrypi/firmware ... -interface
There maybe things that are supported with HDMI hardware, but not by composit etc.

Maybe something like:
Test physical (display) width/height
@DexOS
That was the good idea !
I get the physicall display width / height (before initialising video !!!)
Without HDMI monitor, the physical size is 0x290 X 0x200 (656 X 512)
With HDMI connected, the physical size is much more (0x640 X 0x4B0 in my case).
Many thanks, problem solved.
Philippe

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm

Re: Detecting if HDMI present

Wed Sep 26, 2012 3:33 pm

phil95 wrote:
DexOS wrote:I am not sure you can, but your best bet is use these
https://github.com/raspberrypi/firmware ... -interface
There maybe things that are supported with HDMI hardware, but not by composit etc.

Maybe something like:
Test physical (display) width/height
@DexOS
That was the good idea !
I get the physicall display width / height (before initialising video !!!)
Without HDMI monitor, the physical size is 0x290 X 0x200 (656 X 512)
With HDMI connected, the physical size is much more (0x640 X 0x4B0 in my case).
Many thanks, problem solved.
Philippe
Glad it works and thanks to your help, i can read from my SD card 8-) .
So thank you.
Batteries not included, Some assembly required.

mvdhoning
Posts: 18
Joined: Fri Sep 14, 2012 2:47 pm

Re: Detecting if HDMI present

Sat Sep 29, 2012 3:15 pm

could you post some example code on this? (that is on reading display info, not on sdcard)

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm

Re: Detecting if HDMI present

Sat Sep 29, 2012 6:22 pm

mvdhoning wrote:could you post some example code on this? (that is on reading display info, not on sdcard)
This is how to get all the info from those mailboxs
http://www.raspberrypi.org/phpBB3/viewt ... 77#p176977

You will need your own function to display what you get returned from the call to mailbox.
Batteries not included, Some assembly required.

mvdhoning
Posts: 18
Joined: Fri Sep 14, 2012 2:47 pm

Re: Detecting if HDMI present

Sun Sep 30, 2012 6:56 pm

Thanks for saying i should write a function to write out what is returned from the mailbox as that triggered me to recheck that code on errors and i found a big error in my unsigned int to hex function.

Thanks for pointing me there. That confirms i was going in the right direction. Although i could not read anything back other than 0.

Next i discovered brian widdas github: https://github.com/brianwiddas/pi-baremetal
what i noticed there that instead of an record he uses an array of unsigned ints and that he points that array to a specific place in memory (0x1000)

Now with my FreePascal code i now also use an array (of longword) instead of an record and point that to $1000 and i can read back actual values no more 0 :-)

Somehow i have the feeling the FreePascal compiler is not treating the align properly when stated in the sourcecode.

I am not yet sure on how or why pointing the the variable to 0x1000 makes it work.

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm

Re: Detecting if HDMI present

Sun Sep 30, 2012 7:18 pm

Was the address 16 byte a aligned, as you can not use the first 4 bits of the address.
The buffer itself is 16-byte aligned as only the upper 28 bits of the address can be passed via the mailbox
Batteries not included, Some assembly required.

ultrabizz
Posts: 4
Joined: Wed Mar 16, 2016 2:07 am

Re: Detecting if HDMI present

Wed Mar 16, 2016 2:12 am

You can read GPIO 46 as it is connected to pin 19 of the HDMI socket which is the hotplug detect pin.

Using wiringpi, the following works like a charm

Code: Select all

#define HDMI_HOTPLUG 46
pullUpDnControl(HDMI_HOTPLUG,PUD_UP);
pinMode(HDMI_HOTPLUG,INPUT);
if(digitalRead(HDMI_HOTPLUG) == 0 )
  printf("HDMI Attached\n");
else 
  printf("HDMI unplugged\n");

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13261
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Detecting if HDMI present

Sat Mar 19, 2016 6:50 pm

ultrabizz wrote:You can read GPIO 46 as it is connected to pin 19 of the HDMI socket which is the hotplug detect pin.
Not true on a Pi3 or Compute Module.

On the Compute Module it appears not to be present. On Pi3 it is on a GPIO expander controlled by the VPU. There's a mailbox service that should allow you to control it - https://github.com/raspberrypi/linux/co ... 3bf519efc6 HDMI hotplug should be on input 4 of the expander.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
Akane
Posts: 59
Joined: Tue May 27, 2014 1:20 pm
Location: Tsukuba, Japan

Re: Detecting if HDMI present

Sun Mar 20, 2016 3:23 am

6by9 wrote:
ultrabizz wrote:You can read GPIO 46 as it is connected to pin 19 of the HDMI socket which is the hotplug detect pin.
Not true on a Pi3 or Compute Module.

On the Compute Module it appears not to be present. On Pi3 it is on a GPIO expander controlled by the VPU. There's a mailbox service that should allow you to control it - https://github.com/raspberrypi/linux/co ... 3bf519efc6 HDMI hotplug should be on input 4 of the expander.
Can I see the list of the output pins of the GPIO expander? And what is the product name of the chip (FXL6408)?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13261
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Detecting if HDMI present

Sun Mar 20, 2016 4:37 pm

Akane wrote:Can I see the list of the output pins of the GPIO expander? And what is the product name of the chip (FXL6408)?
Refer to the GPU dt-blob - https://github.com/raspberrypi/firmware ... t-blob.dts
Any signal referred to as "external" is on the GPIO expander. I don't know what signals are connected to any other lines not documented in the blob as I don't have schematics.
I'd suggest you avoid trying to directly talk to the chip - it's the sort of thing that could change, and that can easily be hidden behind the GPU mailbox service. The GPU will also be trying to talk to it, so you'll have resource contention if you do it directly.

edit: looks like others have already sorted getting the virtual GPIO driver working - viewtopic.php?f=72&t=139753
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
Akane
Posts: 59
Joined: Tue May 27, 2014 1:20 pm
Location: Tsukuba, Japan

Re: Detecting if HDMI present

Mon Mar 21, 2016 3:12 am

6by9 wrote:Refer to the GPU dt-blob - https://github.com/raspberrypi/firmware ... t-blob.dts
Any signal referred to as "external" is on the GPIO expander. I don't know what signals are connected to any other lines not documented in the blob as I don't have schematics.
I'd suggest you avoid trying to directly talk to the chip - it's the sort of thing that could change, and that can easily be hidden behind the GPU mailbox service. The GPU will also be trying to talk to it, so you'll have resource contention if you do it directly.

edit: looks like others have already sorted getting the virtual GPIO driver working - viewtopic.php?f=72&t=139753
Thank you for your information! I hope the schematics of RPi3 will be available publicly.
Yes. I know even accessing i2c_vc directly from CPU would conflict with VPU.

thisisnikos
Posts: 5
Joined: Tue Nov 19, 2013 9:53 am

Re: Detecting if HDMI present

Mon Jun 24, 2019 4:01 pm

Any updates regarding the new RPi 4? The latest dts is not yet available https://github.com/raspberrypi/firmware ... t-blob.dts

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 13261
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Detecting if HDMI present

Mon Jun 24, 2019 6:46 pm

thisisnikos wrote:
Mon Jun 24, 2019 4:01 pm
Any updates regarding the new RPi 4? The latest dts is not yet available https://github.com/raspberrypi/firmware ... t-blob.dts
On the Pi4 the hotplug line is a dedicated GPIO going into the HDMI block. Currently there is no way to read it directly, but it's likely to be added as I want to investigate proper hotplug support through FKMS.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

thisisnikos
Posts: 5
Joined: Tue Nov 19, 2013 9:53 am

Re: Detecting if HDMI present

Wed Jul 01, 2020 9:35 am

Any updates on this? Is it possible to read the hotplug pin on Pi 4?

Return to “Bare metal, Assembly language”