Thursday, June 26, 2014

Raspberry Pi Video Output Configuration

In case you read my tutorial HERE on RPi first boot, and you still not getting the best display out of your TV. You come to the right place. Continue read for more information on setting your RPi video output.


When i was booting my RPi (with Raspbian) for the first time, i thought RPi is able to determine which video output it should turn on automatically based on the connected device. Apparently i was wrong =P

It still need user to tell which output it needs to turn on, and which resolution it should use in order to display the desktop correctly. Now i will cover for the details config of Raspberry Pi video output for HDMI and RCA.

We need to access configuration file that RPi reads when it boot up the system. One of the functions in that configuration file is to set the display parameters / property for RPi, so that the RPi will display the desktop properly on your monitor / TV. The configuration file is located in "boot" folder in RPi's root. Here is the full path on RPi "/boot/config.txt"

You can access it by double click the "LXTerminal" icon on your desktop. You should see the similar window on Figure 1. Follow the instruction below

1. Type in "cd /" and enter to access root folder of your RPi.
2. Type in "cd boot" to access "boot" folder.
3. Type in "ls" to list out all the files in "boot" folder. You should see a  "config.txt" file
4. Type in "nano config.txt" to view the content of the file.

Figure1: Locating Config.txt File

For your info, nano is a text editor for linux. I didn't ask you to put "sudo" in front yet because this will only give you read only permission just in case you accidentally edit the file. Here are the documentations you need to read for more understanding on how to use the config file before you edit any content inside it. Figure2 shows you how the file looks like on the terminal.

Documentation
R-Pi_ConfigurationFile - Click HERE
RPi_config property and values - Click HERE

Figure2: Config.txt file open in nano program

Here is how the entire config.txt file look like:

# 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=7
#overscan_right=-9
#overscan_top=-11
#overscan_bottom=-10

# 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=4

# 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
#sdtv_aspect=3

#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=1

Once you have an overview of the file that you are going to edit later. Press Ctrl + X to exit the nano program. Time to get ready for editing the text file =)

I'll divide the detail configuration for HDMI and RCA into two sections. Please follow the instruction carefully.


RCA Configuration

If your current directory is still under /boot/, you may enter command "sudo nano config.txt" to open the config.txt file. If you are in root folder, you can enter command "sudo nano /boot/config.txt". Refer to Figure3 below:

Figure3: Command to open config.txt


Use keyboard arrow key to navigate around the text file. Add hash tag or "#" in front of the lines that contains "hdmi" property so that RPi won't read them. You need to enable "sdtv_mode", "sdtv_aspect", "overscan_left", "overscan_right", "overscan_top" and "overscan_bottom" property in text file by simply remove the "#" character at that line and finally set "disable_overscan" property to 0.

Refer to the code below for the edited config.txt file. Pay attention to the yellow lines for required property.

# 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=7
#overscan_right=-9
#overscan_top=-11
#overscan_bottom=-10

# 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=4

# 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
sdtv_aspect=3

#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


Here are the explanation for each line added into config.txt

1. sdtv_mode - set RPi to display video on RCA port in PAL or NTSC mode, value can set from 0 to 3. You can try out different value to get the best display from your TV. Refer to detail description below for each value. Info available in the documentation link i provided earlier.
sdtv_mode=0    Normal NTSC
sdtv_mode=1    Japanese version of NTSC – no pedestal
sdtv_mode=2    Normal PAL
sdtv_mode=3    Brazilian version of PAL – 525/60 rather than 625/50, different subcarrier
2. sdtv_aspect - set RPi display aspect ratio. value can set from 1 to 3. Refer to detail description below and set the value for your TV.
sdtv_aspect=1  4:3
sdtv_aspect=2  14:9
sdtv_aspect=3  16:9

3. disable_overscan - tell RPi to disable the overscan property or not. Set 1 to disable overscan, set 0 to enable oversan.

4. overscan_top/bottom/left/right - set RPi to adjust the display to fit your TV screen size. Most of the time RPi need these value to fit the desktop to your TV screen size, otherwise you might see your TV displaying partial of your desktop only. If you don't know the correct value for your TV, i will suggest you put a large positive value first and then adjust the value until you fit the desktop to your TV screen. Refer to Figure4 below to get an idea on how the screen will react to the value you set on the config.txt file.

Figure4: Overscan Property vs Screen Size


HDMI Configuration

RPi's HDMI configuration is pretty straight forward. Most of the time RPi will auto detect your TV and configure accordingly. If you want to know more detail on the HDMI properties available. Please refer to the link above under documentation.

You need to enable property "hdmi_group", "hdmi_mode" and "hdmi_force_hotplug". Just like what i mentioned in RCA section, you just need remove the "#" character in front of the line to enable that property.

Remember to add "#" in front of "sdtv" and "overscan" properties, and disable overscan by change the value to "disable_overscan=1". Otherwise it will interfere with the screen size if you enable them both.

"hdmi_safe" is optional, in case you are using HDMI to VGA converter, you might need to set "hdmi_safe=1" just in case the desktop does not display correctly.

Here is what you need to edit in config.txt file. Refer to yellow line.

# 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=7
#overscan_right=-9
#overscan_top=-11
#overscan_bottom=-10

# 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=4


# 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
#sdtv_aspect=3

#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=1

Here are the explanation for each line added into config.txt

1. hdmi_safe - Optional. Set value to 1 if  HDMI not display correctly.

2. hdmi_group - Specify HDMI group. For HDMI TV, usually they belong to CEA group, so you need to set value to 1. If your TV supports DMT, set the value to 2. If you not sure, set it to 0, RPi will choose preferred group based on your TV.

3. hdmi_mode - Specify the screen resolution RPi need to output. If your TV support 720p, you should set the value to 4. Set value to 5 if your TV can support 1080i. Refer to the list of resolution table RPi can support HERE.

4. hdmi_force_hotplug - Force RPi to turn on HDMI port even no HDMI connected. Set value to 1 to enable this property.


Once you done type in the properties and values, press Ctrl + O and then press enter to save the config.txt file. Remember do not rename the file! Once saved, press Ctrl + X to exit the nano text editor.

You will need to reboot your RPi for the changes to take effect. Just type in "sudo shutdown -r now" in LXTerminal and hit enter to reboot your RPi. See the screen changes according to the value you put in!

I hope this post will help you to solve your problem in case you encounter TV screen size / resolution issue. Have fun tweaking your RPi!





Disclaimer: Please use this tutorial at your own risk. I am not responsible for any damage to your RPi or you. Cheers =)

Reference:
http://elinux.org/R-Pi_ConfigurationFile
http://elinux.org/RPi_config.txt

No comments:

Post a Comment