Cx25874

From wiki.gp2x.org

The cx25874 is the video encoding chip for the gp2x - it is used for TVOut mainly, and TV/LCD settings.

Quote: Rlyeh

Here you have a quick guide done from my own research, although it is not the final code I promised. Stay tuned for that. All sources will be in my minimal 0.c library.

Let's go:

int handle; 

//this is your program. i'm working with LCD at the moment...
//...
 
//now activate TV out by opening this device
handle=open("/dev/cx25874",O_RDWR); 

//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.
ioctl(handle, _IOW('v', 0x02, unsigned char), mode);
 
//this optional call adjusts 1 pixel the screen position (position: 0 left, 1 right, 2 up, 3 down)
//you can call this until your image gets centered
ioctl(handle, _IOW('v', 0x0A, unsigned char), position);

//now working with TV... please do not close handle until you're done with all  your tv usage
//...
 
//back to LCD...
close(handle);


That was a really quick guide. In order to enable the missing 46 video modes, and other nice stuff you'll have to talk the CX25874 chip directly through the I2C chip.

Some code following:

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);
}

I'd suggest you to read the CX25874 chipset documentation before using those i2c functions (just in the odd case you need 'em really).

More Resources

Personal tools