Boot Gp2X/open2X With Tv Out On By Default?


dgame

Active Member
Joined
Oct 1, 2006
Messages
945
Is it possible to boot the gp2x/open2x with TV out on by default.

Or after it boots turn on TV out through a script or something?

I am planning a mini-arcade cabinet using the gp2x.

I won’t have easy access to the gp2x inside the cabinet so it needs to go into TV mode by itself.

Can this be done in open2x (or original firmware) yet?

Thanks!
 
I'm fairly certain there used to be a script floating around for this...

http://dl.openhandhelds.org/cgi-bin/gp2x.cgi?0,0,0,0,8,2096

That should work... I recommend setting up joyd (or whatever it's called in the open2x settings) so that your usb joystick is instantly treated like your GP2X controls ;)
 
It is also possible to recompile the kernel to automatically switch to TV-out mode from the second it loads, but you'd have to do that yourself and it might work out too much of a pain to make it worthwhile.
 
Orkie said:
It is also possible to recompile the kernel to automatically switch to TV-out mode from the second it loads, but you'd have to do that yourself and it might work out too much of a pain to make it worthwhile.

Which file(s) would need to be modified?

I read up on compiling the kernel and I should be able to handle that.

Would I be able to cancel the TV out during boot if needed?

The TV On app posted above by Hooka is for the stock firmware as it calls gp2xmenu from the application itself.

Can this code be modified for open2x:
Code:
/*

usage tvon -tvmode 3
tvmode defaults to 4 (PAL). 3 is NTSC. 

This should be run from a script -

#!/bin/sh
./tvon
cd /usr/gp2x/
./gp2xmenu

.gp2xmenu is actually executed after a tvoff script is executed as tvon.gpe will automatically run gp2xmenu and keep this process open. The tvoff script just needs to contain #!/bin/sh as it's purpose is to exit (and close this process, which will close the tv handle) and allow the tvon script to continue.

Bit of a hack, but at least it works :) 

Woogal.

*/

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include "SDL.h"
#include <sys/mman.h>
#include "mmsp2_regs.h"

int		com_argc;
#define MAX_NUM_ARGVS 20
static char     *com_argv[MAX_NUM_ARGVS];
#define CMDLINE_LENGTH	256
char	com_cmdline[CMDLINE_LENGTH];

int handle;

typedef struct { unsigned char id,addr,data;} i2cw;
typedef struct { unsigned char id,addr,*pdata;} i2cr;

void gp2x_i2c_write(unsigned char addr, unsigned char data)
{
i2cw a = {.id = 0x8A, .addr = addr, .data = data};
ioctl(handle, _IOW('v', 0x00, i2cw), &a);
}

unsigned char gp2x_i2c_read(unsigned char addr)
{
unsigned char temp;
i2cr a = {.id = 0x8A, .addr = addr, .pdata = &temp };
ioctl(handle, _IOW('v', 0x01, i2cr), &a);
return (*a.pdata);
}

void COM_InitArgv (int argc, char **argv)
{
	int             i, j, n;

// reconstitute the command line for the cmdline externally visible cvar
	n = 0;

	for (j=0 ; (j<MAX_NUM_ARGVS) && (j< argc) ; j++)
	{
		i = 0;

		while ((n < (CMDLINE_LENGTH - 1)) && argv[j][i])
		{
			com_cmdline[n++] = argv[j][i++];
		}

		if (n < (CMDLINE_LENGTH - 1))
			com_cmdline[n++] = ' ';
		else
			break;
	}

	com_cmdline[n] = 0;

	for (com_argc=0 ; (com_argc<MAX_NUM_ARGVS) && (com_argc < argc) ;
		 com_argc++)
	{
		com_argv[com_argc] = argv[com_argc];
	}

}

int COM_CheckParm (char *parm)
{
	int             i;
	
	for (i=1 ; i<com_argc ; i++)
	{
		if (!com_argv[i])
			continue;            

		if (!strcmp (parm,com_argv[i]))
			return i;
	}
		
	return 0;
}

int main(int argc, char *argv[]) 
{
int i;

  COM_InitArgv (argc, argv);
  FILE *fh;
  //this is your program. i'm working with LCD at the moment...
  //...

  int Uppermemfd;
  unsigned char* UpperMem;
  Uppermemfd = open("/dev/mem", O_RDWR); //Open the memory for reading/writing
  UpperMem = (unsigned char*)mmap(0, 0x2000000, PROT_READ | PROT_WRITE, MAP_SHARED, Uppermemfd, 0x2000000); //mmap the upper 32MB.

  int memory_fd;
  unsigned short volatile *io;
  memory_fd = open("/dev/mem", O_RDWR, 0);
  io=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE,MAP_SHARED, memory_fd, 0xc0000000); 

  printf("width: %d\n",io[DPC_X_MAX]+1);
  if (io[DPC_X_MAX] + 1==320) { // we're using the lcd (unless someone has got a 320x240 tv mode working)
    
    //now activate TV out by opening this device
    UpperMem[0]=open("/dev/cx25874",O_RDWR); // use a fixed area of memory for the handle so we can switch between PAL and NTSC later if we want
    
    //set TV video mode (mode 3 is 720x480Ix16_30Hz NTSC; mode 4 is 720x576Ix16_50Hz PAL)
    //note: there are other video modes supported by the module driver (modes 0,1 and 5) but they do not work at all in our gp2xs/tvs. trust me.
    
    int tvmode=4;  // default to PAL
    
    i = COM_CheckParm ("-tvmode");
    if (i && i < com_argc-1)
      {
	tvmode=atoi(com_argv[i+1]);
      }
    
    ioctl(UpperMem[0], _IOW('v', 0x02, unsigned char), tvmode); // activate the mode
  }
  close(memory_fd); // don't need this anymore, but make sure the tv handle isn't closed!
  chdir ("/usr/gp2x");
  execl("/usr/gp2x/gp2xmenu","gp2xmenu","--disable-autorun",0); // run the menu skipping autorun
}
 
Last edited by a moderator:
It is just an option in the kernel config somewhere. I've never tried it, but I can't imagine you could cancel on boot - it was added to hook the GP2X up to monitors for demonstration at exhibitions without having to set them all up manually.

If that code runs on the stock firmware, it should run on Open2x.
 
Back
Top