User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4044
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

set_overscan.sh

Fri Mar 08, 2013 9:45 pm

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.

magno23
Posts: 136
Joined: Sun Aug 12, 2012 4:11 pm
Location: Penafiel, Portugal

Re: set_overscan.sh

Fri Apr 05, 2013 9:32 pm

can explain how to use/install this?

wdehoog
Posts: 2
Joined: Mon Oct 28, 2013 7:04 pm

Re: set_overscan.sh

Tue Nov 05, 2013 7:09 pm

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.

allenhuffman
Posts: 12
Joined: Wed Jun 25, 2014 2:07 pm

Re: set_overscan.sh

Fri Jun 27, 2014 4:21 pm

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).

User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4044
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: set_overscan.sh

Fri Jul 04, 2014 5:57 pm

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

User avatar
Nitrogen
Posts: 7
Joined: Mon Jul 09, 2012 9:18 am
Location: Ukraine, Kryvyi Rih

Re: set_overscan.sh

Sat Jan 31, 2015 6:46 pm

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.
Raspberry Pi Model B
Linux raspberrypi 3.18.4+ #743 PREEMPT Wed Jan 28 17:14:53 GMT 2015 armv6l GNU/Linux

pbosman
Posts: 3
Joined: Mon Feb 16, 2015 12:19 pm

Re: set_overscan.sh

Mon Feb 16, 2015 12:40 pm

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.

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

Re: set_overscan.sh

Mon Feb 16, 2015 1:04 pm

Does adding:

Code: Select all

disable_overscan=1
to config.txt help?

pbosman
Posts: 3
Joined: Mon Feb 16, 2015 12:19 pm

Re: set_overscan.sh

Mon Feb 16, 2015 2:07 pm

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.

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

Re: set_overscan.sh

Mon Feb 16, 2015 3:49 pm

I've had a play with the set_overscan.sh code. Can you try using my updated version:
https://github.com/popcornmix/set_overscan

User avatar
KONEY
Posts: 6
Joined: Wed Aug 15, 2012 10:12 am
Location: Venice, Italy
Contact: Website Facebook

Re: set_overscan.sh

Mon Feb 16, 2015 10:33 pm

Simply amazing ;)
--
Regards
KONEY

pbosman
Posts: 3
Joined: Mon Feb 16, 2015 12:19 pm

Re: set_overscan.sh

Tue Feb 17, 2015 7:20 pm

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.

User avatar
ric96
Posts: 1253
Joined: Sun Mar 17, 2013 6:03 am
Location: NOIDA, India
Contact: Website

Re: set_overscan.sh

Sun Apr 12, 2015 7:24 am

why arn't the settings saved ?? once i reboot every thing looks like a mess???
My apologies for shameless YouTube Plugs...
youtube.com/sahajsarup
twitter @sahajsarup
skype srics1996
e-mail: [email protected]
Blog: http://www.geektillithertz.com/wordpress
Web: http://www.geektillithertz.com

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

Re: set_overscan.sh

Sun Apr 12, 2015 7:57 am

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.

User avatar
ric96
Posts: 1253
Joined: Sun Mar 17, 2013 6:03 am
Location: NOIDA, India
Contact: Website

Re: set_overscan.sh

Sun Apr 12, 2015 8:57 am

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 !!!
My apologies for shameless YouTube Plugs...
youtube.com/sahajsarup
twitter @sahajsarup
skype srics1996
e-mail: [email protected]
Blog: http://www.geektillithertz.com/wordpress
Web: http://www.geektillithertz.com

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

Re: set_overscan.sh

Sun Apr 12, 2015 9:21 am

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)

User avatar
expandables
Posts: 654
Joined: Fri Jun 27, 2014 7:34 pm
Location: Neverland with Michael Jackson

Re: set_overscan.sh

Mon Apr 13, 2015 5:25 pm

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:
By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.

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

Re: set_overscan.sh

Mon Apr 13, 2015 6:20 pm

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".

User avatar
expandables
Posts: 654
Joined: Fri Jun 27, 2014 7:34 pm
Location: Neverland with Michael Jackson

Re: set_overscan.sh

Mon Apr 13, 2015 7:02 pm

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
By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.

User avatar
ric96
Posts: 1253
Joined: Sun Mar 17, 2013 6:03 am
Location: NOIDA, India
Contact: Website

Re: set_overscan.sh

Mon Apr 13, 2015 9:00 pm

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
My apologies for shameless YouTube Plugs...
youtube.com/sahajsarup
twitter @sahajsarup
skype srics1996
e-mail: [email protected]
Blog: http://www.geektillithertz.com/wordpress
Web: http://www.geektillithertz.com

PismoPi
Posts: 1
Joined: Thu May 28, 2015 11:30 pm

Re: set_overscan.sh

Thu May 28, 2015 11:34 pm

ukscone: Worked brilliantly!

:D

Taupe
Posts: 1
Joined: Sat Apr 20, 2019 10:06 pm

Re: set_overscan.sh

Sat Apr 20, 2019 10:20 pm

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

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

Re: set_overscan.sh

Sun Apr 21, 2019 4:04 pm

You have replied to a 4 year old post...
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Return to “Other projects”