riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

How to disable video scaling

Mon Dec 17, 2018 11:58 pm

Hi guys. I am trying to develop a low resolution game in PI 3 B but the image always seems blurry because it is scaled to monitor height.

I have changed the config.txt including:

Code: Select all

hdmi_group=1
hdmi_mode=1
but the image continues being scaled.

Is there any way to disable this feature?

José Luiz

Memotech Bill
Posts: 25
Joined: Sun Nov 18, 2018 9:23 am

Re: How to disable video scaling

Wed Dec 19, 2018 7:17 pm

Yes, it can be done. For some options see https://github.com/raspberrypi/firmware/issues/104.

For my own application I did it with code (slightly abreviated):

Code: Select all

#include <bcm_host.h>
#include <interface/vmcs_host/vc_vchi_gencmd.h>
static char sSclKer[1024];				//	Remember previous scaling kernel

void no_scaling (void)
{
static const char sNoInt[] = "scaling_kernel 0 0 0 0 0 0 0 0 1 1 1 1 255 255 255 255 255 255 255 255 1 1 1 1 0 0 0 0 0 0 0 0   1";
VCHI_INSTANCE_T vchi_instance;
VCHI_CONNECTION_T *vchi_connection = NULL;
char buffer[1024];

vcos_init ();

if ( vchi_initialise (&vchi_instance) != 0 )
        fatal ("VCHI initialization failed");

//create a vchi connection
if ( vchi_connect (NULL, 0, vchi_instance) != 0 )
        fatal ("VCHI connection failed");

vc_vchi_gencmd_init (vchi_instance, &vchi_connection, 1);

//	Get previous scaling kernel
if ( vc_gencmd (sSclKer, sizeof (sSclKer), "scaling_kernel") != 0 )
	fatal ("Failed to fetch old scaling kernel");

if ( vc_gencmd (buffer, sizeof (buffer), sNoInt) != 0 )
	fatal ("Failed to set non-interpolation scaling kernel");

    vc_gencmd_stop ();

    //close the vchi connection
    if ( vchi_disconnect (vchi_instance) != 0 )
        fatal ("VCHI disconnect failed");
}

void restore_scaling (void)
{
VCHI_INSTANCE_T vchi_instance;
VCHI_CONNECTION_T *vchi_connection = NULL;
char buffer[1024];

if ( vchi_initialise (&vchi_instance) != 0 )
        fatal ("VCHI initialization failed");

//create a vchi connection
if ( vchi_connect (NULL, 0, vchi_instance) != 0 )
        fatal ("VCHI connection failed");

vc_vchi_gencmd_init (vchi_instance, &vchi_connection, 1);

if ( vc_gencmd (buffer, sizeof (buffer), sSclKer) != 0 )
	fatal ("Failed to restore scaling kernel");

    vc_gencmd_stop ();

//close the vchi connection
if ( vchi_disconnect (vchi_instance) != 0 )
        fatal ("VCHI disconnect failed");
}

riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

Re: How to disable video scaling

Wed Dec 19, 2018 11:24 pm

Thanks for your answer. It seems that your code is for Linux environment.

I am building my game as a bare metal one.

Is your solution possible for a bare metal one?

José Luiz

Memotech Bill
Posts: 25
Joined: Sun Nov 18, 2018 9:23 am

Re: How to disable video scaling

Thu Dec 20, 2018 10:49 am

From the link I posted:
popcornmix wrote: Not tested, but I've added a config.txt parameter:
scaling_kernel=
Where n is:
SCALERLIB_KERNELS_TYPES_SINC=1,
SCALERLIB_KERNELS_TYPES_SINC_BLACKMAN=2,
SCALERLIB_KERNELS_TYPES_SINC_NO_SIDE_LOBES=3,
SCALERLIB_KERNELS_TYPES_SINC_HALF_FIRST_SIDE_LOBE=4,
SCALERLIB_KERNELS_TYPES_SINC_HAMMING=5,
SCALERLIB_KERNELS_TYPES_SINC_HAMMING_3PI=6,
SCALERLIB_KERNELS_TYPES_SINC_HAMMING_2_5PI=7,
SCALERLIB_KERNELS_TYPES_NEAREST_NEIGHBOUR=8,

(we normally use 6). 8 might be what you want.

I believe the mailbox interface already allows you to force integral scale factors.

riverajl
Posts: 10
Joined: Thu Dec 06, 2018 10:03 am

Re: How to disable video scaling

Thu Dec 20, 2018 11:05 pm

Thank you. It worked with scaling_kernel=8.

Is there some documentation about it or only in the Linux code?

Thanks.

José Luiz

Memotech Bill
Posts: 25
Joined: Sun Nov 18, 2018 9:23 am

Re: How to disable video scaling

Fri Dec 21, 2018 12:55 pm

The documentation is on the GitHub Issue Tracker for the RPi firmware, not in the Linux code. I think it is also documented in the Forums somewhere, although I failed to find it in a quick search when I first saw your question.

Unfortunately, it seems to be missing from the documentation at https://www.raspberrypi.org/documentati ... /README.md. I think not the only command not documented there.

Return to “Bare metal, Assembly language”