Page 1 of 1

set_overscan.sh

Posted: Fri Mar 08, 2013 9:45 pm
by ukscone
one of my major peeves with config.txt is that you need to reboot after making changes and that's a right PITA when needing to change the overscan values because you've moved your raspberry pi from one place to another and using a different monitor. So just before Christmas I asked Dom if he had an example of how to talk to the GPU (and where the settings in config.txt are store after booting) so I could write something to modify the overscan settings on the fly. He kindly sent me the code to do exactly what I wanted and i wrote a quick & dirty bash script to wrap his program in. I've been using it for a couple of months and yesterday I decided to tidy it up a bit and release it as my itch is well and truly scratched.

So I present to you set_overscan :) https://github.com/ukscone/set_overscan

It's still a pretty naff script but it does it's job and I am working on making it a bit nicer. The script is licensed under the same license that is in Dom's code which seems to be some form of BSD (but read it yourself as I maybe wrong) although personally I don't care what you do with the script as long as i am not blamed for anything that happens if you use it.

Re: set_overscan.sh

Posted: Fri Apr 05, 2013 9:32 pm
by magno23
can explain how to use/install this?

Re: set_overscan.sh

Posted: Tue Nov 05, 2013 7:09 pm
by wdehoog
Thanks for this.

First I thought it only worked for the console and for X (the thing that appears after startx) but not for SDL games. However that was when I started the game from remote login (ssh). When the game is started on the PI itself setting the overscan does work. (I used it to get gpsp displayed correctly.)

I copied from your script to create a small script to get and/or set the overscan without modifying /boot/config.txt.

Code: Select all

# Check for mailbox & if not existing create it.
if [ ! -c mailbox ]; then
       mknod mailbox c 100 0
fi

print_overscan() {
  # Get current overscan values from GPU
  TEMP=`./overscan`
  GPU_OVERSCAN_TOP=`echo $TEMP | awk -F ' ' '{print $1}'`
  GPU_OVERSCAN_BOTTOM=`echo $TEMP | awk -F ' ' '{print $2}'`
  GPU_OVERSCAN_LEFT=`echo $TEMP | awk -F ' ' '{print $3}'`
  GPU_OVERSCAN_RIGHT=`echo $TEMP | awk -F ' ' '{print $4}'`
  echo $1 top=$GPU_OVERSCAN_TOP, bottom=$GPU_OVERSCAN_BOTTOM, left=$GPU_OVERSCAN_LEFT, right=$GPU_OVERSCAN_RIGHT
}

print_overscan current
if [ $# -ne 0 ]
then
  ./overscan [email protected]
  print_overscan new
fi

rm -f mailbox
Oh I am using raspian and the composite AV.

Re: set_overscan.sh

Posted: Fri Jun 27, 2014 4:21 pm
by allenhuffman
Thanks for posting this. overscan.c was exactly what I was looking for. Having to reboot a machine all the time to make simple changes is very frustrating (I was spoiled by the old OS-9 operating system which could dynamically load, init and term device drivers and such without a reboot).

I note you made modifications to the .c for your script -- is the original overscan.c somewhere? I see it does not work on it's own (without manually creating "mailbox" ahead of time).

Re: set_overscan.sh

Posted: Fri Jul 04, 2014 5:57 pm
by ukscone
I just renamed the file to overscan.c and iirc added/modded the functions at the end. I don't have the original file as far as i know but i think the original file is in the raspberry pi github

Re: set_overscan.sh

Posted: Sat Jan 31, 2015 6:46 pm
by Nitrogen
Thanks for this tool, but let me also report a problem i had with it. I don't know whether it was the case as of time this was designed, but it turns out once you have overscan enabled Pi automatically adds 32px overscan on each side of the screen. And that is regardless of overscan values you might have set in /boot/config.txt. Logically, after you used set_overscan.sh to get desirable values of overscan and those are saved into /boot/config.txt, Pi adds own 32px mentioned, right on the next boot. This leads to a result one haven't expected. But even after i tried to take those 32 into account by substracting from each overscan value in /boot/config.txt it still didn't looked like what we get with set_overscan.sh tool. Contrary, when i used overscan.c directly to set EXACTLY same values i got thru set_overscan.sh tool previously, it all looked perfect. So currently i'm very confused about what is going on there. I'm guessing there might be another layer of technology between, which i'm unaware of.

Essentially i ended up doing same thing wdehoog did.

I'm running my Pi hooked up to SD TV-set (PAL, thus sdtv_mode=2). Latest Raspbian onboard.

Re: set_overscan.sh

Posted: Mon Feb 16, 2015 12:40 pm
by pbosman
Thanks for the tool - now I know that my HDMI to VGA connector can get a good result with my old monitor, with a bit of tweaking.

I've experienced the same issue as Nitrogen. (I was able to get a perfect picture using the utility, but when applying the values to config.txt, they don't match the positions set in the utility.).
I tried manually setting the overscan for 'right' via config.txt, however as I increased the negative value, (and after numerous reboots), it seemed to make no difference to the picture. So, I don't think it's possible to achive the desired results using the overscan settings in config.txt.

I'll probably use wdehoog's solution, or extend the overscan.c to create the mailbox too, and then will see if it's possible to run it at startup.

Also, I might try and learn more about why the overscan settings don't match up with those set in the utility.

Re: set_overscan.sh

Posted: Mon Feb 16, 2015 1:04 pm
by dom
Does adding:

Code: Select all

disable_overscan=1
to config.txt help?

Re: set_overscan.sh

Posted: Mon Feb 16, 2015 2:07 pm
by pbosman
I tried setting disable_overscan=1.
This resulted in the top, left and bottom being aligned properly, but the right still had a large black border.

Re: set_overscan.sh

Posted: Mon Feb 16, 2015 3:49 pm
by dom
I've had a play with the set_overscan.sh code. Can you try using my updated version:
https://github.com/popcornmix/set_overscan

Re: set_overscan.sh

Posted: Mon Feb 16, 2015 10:33 pm
by KONEY
Simply amazing ;)

Re: set_overscan.sh

Posted: Tue Feb 17, 2015 7:20 pm
by pbosman
I tried using your new updated version Dom. Thanks very much, it now works perfectly.

I think one thing I misunderstood was that you have to have disable_overscan=1 while at the same time providing values for the overscan. I assumed that the overscan settings would get ignored when the overscan is disabled.

Re: set_overscan.sh

Posted: Sun Apr 12, 2015 7:24 am
by ric96
why arn't the settings saved ?? once i reboot every thing looks like a mess???

Re: set_overscan.sh

Posted: Sun Apr 12, 2015 7:57 am
by rpdom
ric96 wrote:why arn't the settings saved ?? once i reboot every thing looks like a mess???
Are you saying that you used set_overscan.sh to find your best overscan settings but because you didn't then put those settings into config.txt they didn't stay over a reboot?

set_overscan.sh is a way of changing the settings dynamically. It isn't for permanent settings. Those go in config.txt.

Re: set_overscan.sh

Posted: Sun Apr 12, 2015 8:57 am
by ric96
rpdom wrote:
ric96 wrote:why arn't the settings saved ?? once i reboot every thing looks like a mess???
Are you saying that you used set_overscan.sh to find your best overscan settings but because you didn't then put those settings into config.txt they didn't stay over a reboot?

set_overscan.sh is a way of changing the settings dynamically. It isn't for permanent settings. Those go in config.txt.
i did save but the number it shows are highly inacurate!!! after a reboot i actually get larger borders than before !!!

Re: set_overscan.sh

Posted: Sun Apr 12, 2015 9:21 am
by rpdom
ric96 wrote:i did save but the number it shows are highly inacurate!!! after a reboot i actually get larger borders than before !!!
Hmm, that's strange. Something wrong. I used that program to get my overscan settings set correctly (My early B can't read EDID data for some reason so I have to set it manually in config.txt. It's annoying when I change screens)

Re: set_overscan.sh

Posted: Mon Apr 13, 2015 5:25 pm
by expandables
I got an error does anyone know whats the problem? I ran the script with sudo sh set_overscan.sh

Code: Select all

set_overscan.sh: 41: set_overscan.sh: [[: not found
set_overscan.sh: 57: set_overscan.sh: function: not found
:mrgreen:

Re: set_overscan.sh

Posted: Mon Apr 13, 2015 6:20 pm
by rpdom
expandables wrote:I got an error does anyone know whats the problem?
Yes.
I ran the script with sudo sh set_overscan.sh
That is the problem. Well, the "sh" is the problem. The program is a bash script and you are running it using sh instead which doesn't support the "[[ ]]" method.

The first line of set_overscan.sh should be "#!/bin/bash", if it is then run it without the "sh" in there. If it isn't then put "bash" instead of "sh".

Re: set_overscan.sh

Posted: Mon Apr 13, 2015 7:02 pm
by expandables
OK thanks i was able to run the script but i got another error

Code: Select all

Line 152: ./overscan: no such file or directory

Re: set_overscan.sh

Posted: Mon Apr 13, 2015 9:00 pm
by ric96
expandables wrote:OK thanks i was able to run the script but i got another error

Code: Select all

Line 152: ./overscan: no such file or directory
First run

Code: Select all

sudo make
Then run

Code: Select all

sudo ./set_overscan.sh

Re: set_overscan.sh

Posted: Thu May 28, 2015 11:34 pm
by PismoPi
ukscone: Worked brilliantly!

:D

Re: set_overscan.sh

Posted: Sat Apr 20, 2019 10:20 pm
by Taupe
Thought I’d share my process created from config editing frustration. No additional scripts needed.

Comment out disable_overscan=1, add overscan_scale =1 if not present, and add all four axis as described in many tutorials.

Overscan_left=-50
Overacan_right=-50
Overscan_top=-50
Overscan_bottom=-50

I set the numbers larger than most screens to get it past the edge. Save and reboot.

I then use the screen size optimization tool in the Kodi settings section (I use OSMC).

I write down the number for each axis that brings the arrow to the side of the screen.

I then add that number back to the -50. Example: it took 14 clicks to get the arrow back into correct position (-50 + 14 = -36).

Went back into the boot/config and put the new numbers into the config file, saved and rebooted and everything lines up perfectly.

I only did this because my tv has no options to disable overscan.

Oddly, none of the numbers are even close to what I’ve seen others list.

Panasonic p42x1

Left -12
Right -20
Top -31
Bottom -38

Re: set_overscan.sh

Posted: Sun Apr 21, 2019 4:04 pm
by jamesh
You have replied to a 4 year old post...