hawkerpl
Posts: 5
Joined: Wed Jul 02, 2014 12:05 pm

tvservice -s is giving wrong resolution

Wed Jul 02, 2014 12:17 pm

Hi, i have problem with detecting resolution of plugged in monitor (i am trying to detect whether monitor is plugged at all to use it in my app in python), i have tried

Code: Select all

tvservice -s
which is giving me wrong answers:
when hdmi is unplugged at booting:

Code: Select all

state 0x120016 [DVI DMT (4) RGB full 4:3], 640x480 @ 60.00Hz, progressive
when hdmi is plugged after that:

Code: Select all

state 0x120016 [DVI DMT (4) RGB full 4:3], 640x480 @ 60.00Hz, progressive

(i was expecting some information about hdmi not being plugged)

when hdmi is plugged at booting:

Code: Select all

state 0x120016 [DVI DMT (58) RGB full 16:10], 1680x1050 @ 60.00Hz, progressive
when hdmi is unplugged after that

Code: Select all

state 0x120016 [DVI DMT (58) RGB full 16:10], 1680x1050 @ 60.00Hz, progressive
my main goal is to check whether hdmi monitor is plugged

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26659
Joined: Sat Jul 30, 2011 7:41 pm

Re: tvservice -s is giving wrong resolution

Wed Jul 02, 2014 1:45 pm

If nothing is detected on the HDMI port at boot, it defaults to VGA. So that matches what you are seeing.

Can you not just extract the resolution from tvservice using awk or similar? And if it 640x480, assume it's not connected?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5537
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: tvservice -s is giving wrong resolution

Wed Jul 02, 2014 3:27 pm

@hawkerpi
I'm guessing you have added hdmi_force_hotplug=1 (or booting without hdmi plugged in would have defaulted to composite).

You'll have to remove that if you want to detect the real hotplug value.

With that removed the "state 0x120016" will change when hdmi cable is removed.

hawkerpl
Posts: 5
Joined: Wed Jul 02, 2014 12:05 pm

Re: tvservice -s is giving wrong resolution

Thu Jul 03, 2014 8:27 am

@dom yes, it was set to 1 but if i tried to change it to 0 or delte that setting from config, nothing changed.
What is more "tvservice -M" is not detecting whether i am pluging or unplugging hdmi.
My config.txt:

Code: Select all

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# for more options see http://elinux.org/RPi_config.txt

# NOOBS Auto-generated Settings:
hdmi_force_hotplug=1
config_hdmi_boost=4
overscan_left=24
overscan_right=24
overscan_top=16
overscan_bottom=16
disable_overscan=0
@jamesh
I'd do that in the end, but i rather wanted to detect whether it is unplugged during running time, not only at boot.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5537
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: tvservice -s is giving wrong resolution

Thu Jul 03, 2014 12:56 pm

hawkerpl wrote:@dom yes, it was set to 1 but if i tried to change it to 0 or delte that setting from config, nothing changed.
What is more "tvservice -M" is not detecting whether i am pluging or unplugging hdmi.
My config.txt:
Note that config listed is the NOOBS config, not the raspbian config.
Edit the config from within raspbian using "sudo nano /boot/config.txt", or using the NOOBS config.txt editor.

hawkerpl
Posts: 5
Joined: Wed Jul 02, 2014 12:05 pm

Re: tvservice -s is giving wrong resolution

Thu Jul 03, 2014 1:41 pm

@dom
as i said before, i did that and nothing has changed

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: tvservice -s is giving wrong resolution

Thu Jul 03, 2014 1:59 pm

@hawkerpi Looks like you've commented out the first occurrence of hdmi_force_hotplug but there's actually a second occurrence of this setting near the bottom of your config.txt which hasn't been commented out.

@dom By default NOOBS doesn't have a config.txt, but it does pre-configure the config.txt of the OSes it installs to set them up to the same display-mode that NOOBS was running in. That's what the "# NOOBS Auto-generated Settings" is about - this behaviour will probably be changing in a future version of NOOBS.

hawkerpl
Posts: 5
Joined: Wed Jul 02, 2014 12:05 pm

Re: tvservice -s is giving wrong resolution

Wed Jul 09, 2014 10:53 am

@AndrewS thanks, that worked

Return to “Troubleshooting”