Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

switch HDMI resolution mode without reboot

Sat Oct 15, 2016 8:55 am

hello,
I am using 2 different HDMI monitors for my Pi, 1 big one on my desktop (1920x1080) and a small 7" (1024x600) optionally for to go. Unfortunately the 7" is not correctly detected by the Pi, it is always automatically initialized to 800x480.
Although I know how to patch /boot/config.txt to force 1024x600, this patching is very complicated and afterwards one has to reboot, and it happened to me that I once had a typo and then the screen kept black, on either display or monitor. Only a backup SD card could help me out then.
As this is extremely shaky, it would be better to change the resolution while Linux is running, and switch from one to another optionally, and automatically switching back to defaults if things go wrong (like it works on Windows PCs).

Is something like this possible also for the Pi, without rebooting ?

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Sun Oct 16, 2016 5:25 pm

so as there has no solution been posted yet -
why is it a problem for Raspbian to change the screen resolution while the system is running, why has it to be rebooted each time?
Is it possible to change this drawback in one of the next Raspbian updates/upgrades ?

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5581
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: switch HDMI resolution mode without reboot

Sun Oct 16, 2016 6:05 pm

You may be able to do so with careful use of tvservice commands (in a script), however it's more commonly used/useful to determine "optimum" settings for a given display device (well that's what I've used it for** ;) )
Trev.
** as shown here:
http://www.cpmspectrepi.uk/raspberry_pi ... tings.html
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Sun Oct 16, 2016 6:31 pm

thank you, but tbh, that looks a little complicated.
I actually was hoping there once would be sort of graphical resolution menu available like on Windows some day ;)
but FTM, the easiest way would be to be able to execute the current setting in a bash script .

in fact, my 1920x1080 HDMI is actually a DVI with a HDMI converter cable, and my Raspbian setting is the NOOBS auto setting:

Code: Select all

# 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
the 7" 1024x600 forced setting is this instead:

Code: Select all

# 1024x600 forced setting:
hdmi_force_hotplug=1
config_hdmi_boost=0
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
disable_overscan=0
hdmi_cvt=1024 600 60 6 ##
framebuffer_width=1024 ## 
framebuffer_height=600 ##  
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
start_file=start_x.elf
fixup_file=fixup_x.elf
gpu_mem=128
what would the tvservice parameters look like then to switch there and back on either screen?

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5581
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: switch HDMI resolution mode without reboot

Sun Oct 16, 2016 6:42 pm

Stiller wrote:thank you, but tbh, that looks a little complicated (I actually was hoping there once would be sort of graphical resolution menu available like on Windows some day ;) )

in fact, my 1920x1080 HDMI is actually a DVI with a HDMI converter cable, and my Raspbian setting is the NOOBS auto setting:

Code: Select all

# 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
the 7" 1024 forced setting is this instead:

Code: Select all

# 1024x600 forced setting:
hdmi_force_hotplug=1
config_hdmi_boost=0
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
disable_overscan=0
hdmi_cvt=1024 600 60 6 ##
framebuffer_width=1024 ## 
framebuffer_height=600 ##  
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
start_file=start_x.elf
fixup_file=fixup_x.elf
gpu_mem=128
what would the tvservice parameters look like then to switch there and back on either screen?
Well I'm not going to guess (and the "tricky bit" is the framebuffer settings) but running tvservice -s for each case and logging the output (eg. 1) tvservice -s > monitor.txt, 2) tvservice -s > 7indisplay.txt) may provide enough info. (I suspect that the start..., fixup... and gpu... settings are not specific to the 7" display) It may also be worth checking, via tvservice -m, if your monitor supports the same resolution setting as the 7" display, thus avoiding changes when appropriate.
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Sun Oct 16, 2016 7:44 pm

thank you,
It took quite a while because I accidentally again messed things up when switching there and back :evil:

for the big fullHD I get
state 0x120006 [DVI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive

and for the small 7":
state 0x120006 [DVI DMT (87) RGB full 15:9], 1024x600 @ 60.00Hz, progressive

what does that mean now for tvservice parameters?

User avatar
rpdom
Posts: 16983
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: switch HDMI resolution mode without reboot

Mon Oct 17, 2016 5:31 am

Stiller wrote:what does that mean now for tvservice parameters?
state 0x120006 [DVI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive

Code: Select all

tvservice -e "DMT 82"
You may also need to use something like

Code: Select all

fbset -g 1920 1080 1920 1080 16
xrefresh
state 0x120006 [DVI DMT (87) RGB full 15:9], 1024x600 @ 60.00Hz, progressive

Code: Select all

tvservice -e "DMT 87"
and

Code: Select all

fbset -g 1024 600 1024 600 16
xrefresh

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Mon Oct 17, 2016 6:16 am

i wrote a bash script

Code: Select all

# tvservice_1920x1080.sh   
tvservice -e "DMT 82"
fbset -g 1920 1080 1920 1080 16
xrefresh
echo "press enter"
read reply
and started it with my 1920x1080 monitor just to see if with the current screen out all things will remain the same.
But I immediately got a totally black screen, no Terminal visable, no reboot or shutdown possible, I had to pull the USB cable while Linux was running for a brute force shut down. I hope I didn't create too much file crap then by this ugly procedure :|

so what's the correct way to do it?

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Tue Oct 18, 2016 7:36 am

there is no solution available yet, is it?

User avatar
procount
Posts: 2204
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: switch HDMI resolution mode without reboot

Tue Oct 18, 2016 7:41 am

After changing modes with tvservice use

Code: Select all

fbset -depth 8; fbset -depth 16
To reset the framebuffer
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Tue Oct 18, 2016 8:08 am

fbset -depth 8;
for the 7"
and
fbset -depth 16:
for the fullHD ?

User avatar
procount
Posts: 2204
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: switch HDMI resolution mode without reboot

Tue Oct 18, 2016 8:36 am

Normally you type both commands on the one line (for both screens). if one doesn't work the other usually does.
I normally do this outside of the X-windwos desktop in the command shell. I've not done it in an X-windows terminal where you probably need the xrefresh stuff aswell to refresh the X windows system with the new parameters.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Tue Oct 18, 2016 8:56 am

I always use the LX terminal on top of the GUI, nothing else for a terminal.
All commands have to be put into a bash script to resize the actual screen by a double click from the desktop, to quickly switch from one to another resolution.

what would the whole procedure look like then for the Full HD screen?
this?

Code: Select all

# tvservice_1920x1080.sh   
tvservice -e "DMT 82"
fbset -g 1920 1080 1920 1080 16
fbset -depth 8; 
fbset -depth 16;
xrefresh
echo "press enter"
read reply

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Wed Oct 19, 2016 8:30 am

as there was no positive reply yet:
does that mean that there is no solution available, regrettably?

User avatar
procount
Posts: 2204
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: switch HDMI resolution mode without reboot

Wed Oct 19, 2016 9:00 am

Sorry, I was busy... Have you tried it yet? Part of the fun of the Pi is trying things out.
If you are separating the fbset commands onto separate lines, you don't need the trailing semicolons. They are used to separate commands on the same line
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
rpdom
Posts: 16983
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: switch HDMI resolution mode without reboot

Wed Oct 19, 2016 9:15 am

When testing things like this, I always try to do it via a remote login like SSH, as then I won't be forced to pull the power to reset the Pi if the screen isn't displayed.

In the past I've always found that setting the frame buffer depth to one value then another, using fbset has fixed the framebuffer resolution, and then xrefresh has been enough to fix the desktop GUI. I don't know if that works with the new PIXEL desktop.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Wed Oct 19, 2016 10:52 am

no I had not tried it again because I don't know which way it is to do it correctly from a bash script.
And I never use ssh, btw.

So which is a correctly working bash sript to be started from the desktop?
Stiller wrote:I always use the LX terminal on top of the GUI, nothing else for a terminal.
All commands have to be put into a bash script to resize the actual screen by a double click from the desktop, to quickly switch from one to another resolution.

what would the whole procedure look like then for the Full HD screen?
this?

Code: Select all

# tvservice_1920x1080.sh   
tvservice -e "DMT 82"
fbset -g 1920 1080 1920 1080 16
fbset -depth 8; 
fbset -depth 16;
xrefresh
echo "press enter"
read reply

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Wed Oct 19, 2016 7:23 pm

still no solution for a bash script available which really works?

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 8:27 am

I again tried this script and started it with my 1920x1080 monitor just to see if with the current screen-out all things will remain the same.

Code: Select all

# tvservice_1920x1080.sh   
tvservice -e "DMT 82"
fbset -g 1920 1080 1920 1080 16
fbset -depth 8;
fbset -depth 16;
xrefresh
Again, just like before, I immediately got a totally black screen, no Terminal visable, no reboot or shutdown possible, I had to pull the USB cable while Linux was running for a brute force shut down.

So which is a correctly working bash sript for changing the screen resolution to be started from the desktop?

User avatar
procount
Posts: 2204
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 10:23 am

Try putting a

Code: Select all

sleep 1
command between each command in your bash script.

Also you could try typing the commands one by one in the terminal (carefully as you may not be able to see the screen!) before committing to a bash script, so that you can see the effect of each one.

BTW - the xrefresh command will only work on a terminal that is using the X display (i.e. a phyiscally attached keyboard). It won't work using SSH because that terminal has no X display associated with it. (But having an SSH terminal open at the same time is good because you can do a 'sudo reboot' instead of pulling the plug when your display disappears).

Have you also seen the documentation page https://www.raspberrypi.org/documentati ... fig-txt.md about config.txt, especially the Conditional filters at the very bottom?
Using those you can set different screen resolutions depending on which monitor is attached.
Since your smaller HDMI screen is not detected correctly you might have to get a bit creative by setting those screen parameters as a default and switching to the other set when your other HDMI screen is detected.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 10:42 am

thank you for your hints!
As I already wrote, in config.txt everything is configured correctly and everything works fine.
As I also already wrote, I'm working locally on the Pi which means that I have a screen, a keyboard, and a mouse locally, and that I never use ssh.
but I will try the step by step approach, entering 1 command after the other in a LXterminal and I will report soon what's happening.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 10:48 am

ok, that went quick.

entering in the terminal
tvservice -e "DMT 82"
the screen immediately is again completely black and the Pi does not respond to anything and I can't see what is happening at all any more.
I again had to pulll the USB cable for a brute force shut down.
I hate it, tbh.

So if some one is giving hints I would really appreciate that he/she might have tested and approved that on his own Pi before , in order to ensure that it wouldn't be completely failing and misleading, at least by his/her own experience on his/her own local Pi.

User avatar
procount
Posts: 2204
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 11:31 am

thank you for your hints!
You're welcome
As I already wrote, in config.txt everything is configured correctly and everything works fine.
Your config.txt does not show any indication of using conditional filtering [edid=....] - they could be 2 different config.txt files for all I know that you manually copy depending on which monitor is attached.
As I also already wrote, I'm working locally on the Pi which means that I have a screen, a keyboard, and a mouse locally, and that I never use ssh.
It was with reference to rpdom's suggestion to use ssh to try it out. I was just pointing out (for you or anyone else following this thread) that xrefresh needs to be done locally.
entering in the terminal
tvservice -e "DMT 82"
the screen immediately is again completely black and the Pi does not respond to anything an I can't see what is happening at all any more.
Yes, it does that. That's why I said "typing the commands one by one in the terminal (carefully as you may not be able to see the screen!)" You have to keep typing the commands, not just stop as soon as the screen goes blank.
I again had to pulll the USB cable for a brute force shut down.
No, you have to keep typing the commands, especially 'fbset -depth 8; fbset -depth16' to restore the screen from its blackness
So I would really appreciate if some one is giving hints that he/she might have tested and approved that on his own Pi before , in order to ensure that it wouldn't be completely failing and misleading, at least oh his/her own local Pi.
Let me take a day off work and do it all for you!
I actually tried those, but as I currently only have a VGA666 adaptor to see my screen, the tvservice bit isn't working for me, so I can't test it fully. But the rest seemed ok.
I thought it was clear from my posts that these are hints/suggestions only. They are not guaranteed. But if you don't appreciate suggestions or can't follow them, then I won't bother making any more.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 11:41 am

As I already wrote, in config.txt everything is configured correctly and everything works fine.
Your config.txt does not show any indication of using conditional filtering [edid=....] - they could be 2 different config.txt files for all I know that you manually copy depending on which monitor is attached.
I don't want to make changes by conditional things in the config.txt, I want to change things while the Pi is running, without rebooting.
Following FTrevorGowen's advice
FTrevorGowen wrote:You may be able to do so with careful use of tvservice commands (in a script),..
I preferred the bash script solution, especially if intermediately there wasn't a visible screen, then at least the following commands are supposed to be executed then nevertheless and might rearrange some faulty intermediate settings then during the next steps.

So a working bash script would be highly appreciated.

If not possible for the moment to provide something working in order to change the screen resolution while Linux is running (like possible e.g., for Windows), this would be a suggestion for improvement to the Pi and Raspbian developers.

User avatar
procount
Posts: 2204
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: switch HDMI resolution mode without reboot

Thu Oct 20, 2016 12:43 pm

You will not find a script to do this in a desktop terminal, because the Raspbian desktop does not support resolution changing (xrefresh only redraws the screen and xrandr does not seem to be fully implemented).
You can do it from the cmdline using a script like this:

Code: Select all

#!/bin/sh
tvservice -e "CEA 16"
sleep 1
fbset -depth 8
fbset -depth 16
fbset -g 1920 1080 1920 1080 16
So you will need to use raspi-config to boot to the command line on startup then use startx to start the desktop manually (or via a script).
When you want to change resolution, exit from the desktop to the command line, run your script, then type startx to restart your desktop.
As you also need to change your overscan values, you will need to find a program to do that for you.
(And YES, I did test this works)
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Return to “Beginners”