GP2X Got The Conexant Cx25874 Chip To Work


rlyeh

Certified Guru
Joined
Mar 25, 2003
Messages
277
Age
45
Location
49°9' East latitude, 126°43' South longitude: in y
Website
www.retrodev.info
Hello folks,

I've got the CX25784 encoder video chip to work while coding the minimal library 0.C
I can currently use the i2c, enable/disable tv out, center the screen and set/unset PAL/NTSC video modes, within my app and with no need of the gp2xmenu help at all ]:)

As soon as I get my library fully working I'll paste the code here (it has some small issues at the moment).
(I'm trying to support my own custom tv video modes right now. Wish me luck!)

Greetings from the darkness...


PS: I'll see if I can retrieve the GP2X ID through the i2c too. Not sure about this yet.
 
great news, one step closer to vga/rgb output.
Have you found out how to set the res/overscan and other interesting stuff?
Does someone know which legs of the chip you would need to solder rgb to?
 
Last edited by a moderator:
Yes it will be nice to have an update to minimal lib :)! Great stuff.

current changes :)

Code:
  What's new:
  ===========
 
  0.C: added full 64mb support finally! :)
	   added optimized RAM timings (thanks god_at_hell & craigix)
	   added overclocking support (thanks RobBrown, sasq & whizzbang)
	   added preliminary gp2x hardware blitter support (thanks Paeryn, Reesy & Squidge)
	   added TV out support by using CX24785 encoder directly
	   added I2C (CX24785) support
	   added battery check support (thanks Squidge)
	   added leds support (thanks K-teto & RobBrown)
	   added BMP file image handling
	   added TGA file image handling
	   added default 200 MHz clock setting when initializing your program
	   added default leds when initializing your program
	   added low battery led when initializing your program
	   added gunzip library by Pasi Ojala
	   added hFILE library (HPL subset library for file, network & device handling)
	   added stereo/mono sound support
	   added 3D DAC boost support
	   added 6db pre-DAC attenuation support
	   added bass/treble intensity support
	   added headphones detection support
	   added memory card detection support
	   added flushing cache support
	   fixed white LCD bug when using TV out (thanks THB for the report)
	   fixed hsync/vsync polarity for firmware 2.0.0 (thanks K-teto)
	   fixed YUV aspect ratio (thanks Puck2099)
	   fixed dualcore support again (broken in 0.B)
	   fixed two stupid typos in sound.c tutorial (thanks Nawa for the report)
	   changed video buffering for 16bits mode (triple now)
	   changed video buffering for 8bits mode (sextuple now!)
	   changed YUV/RGB/dualcore/cursor memory mappings
	   changed whole memory mapping to a better layout featuring a free, big and contiguous memory block of 31 Mb.
	   changed dualcore initialization method
	   changed dualcore memory mapping method
	   changed dualcore shared area usage through gp2x_dualcore_data() macro (easier to use now)
	   changed dualcore stack area to a bigger and safer one (using 64kb now)
	   changed dualcore 940t icache/dcache settings (should be faster now)
	   changed dualcore 940t binary limit from 10Mb to 31Mb
	   changed rgb region initialization method
	   changed joystick read handling. You can check also for absolute values now.
 
	   added functions:
	   - gp2x_image_bmp() 
	   - gp2x_image_tga() 
	   - gp2x_unimage()
	   - gp2x_dualcore_clock()
	   - gp2x_timer_raw()
	   - gp2x_timer_raw_to_ticks()
	   - gp2x_timer_raw_one_second()
	   - gp2x_misc_led()
	   - gp2x_misc_lcd()
	   - gp2x_misc_battery()
	   - gp2x_misc_flushcache()
	   - gp2x_misc_headphones()
	   - gp2x_misc_memcard()
	   - gp2x_sound_stereo()
	   - gp2x_sound_3Dboost()
	   - gp2x_sound_attenuation()
	   - gp2x_sound_setintensity()
	   - gp2x_i2c_read()
	   - gp2x_i2c_write()
	   - gp2x_tv_setmode()
	   - gp2x_tv_adjust()
 
	   modified variables:
	   - *gp2x_dualcore_ram
 
	   modified structs:
	   - deleted { *screen8, *screen16, *screen32 } pointers in gp2x_video_YUV[0,1,2,3].
	   - deleted { *screen8, *screen16, *screen32 } pointers in gp2x_video_RGB[0].
	   - added { void *screen } pointer into gp2x_video_YUV[0,1,2,3]
	   - added { void *screen } pointer into gp2x_video_RGB[0]
 
Last edited by a moderator:
changed dualcore initialization method
changed dualcore memory mapping method
changed dualcore shared area usage through gp2x_dualcore_data() macro (easier to use now)
changed dualcore stack area to a bigger and safer one (using 64kb now)
changed dualcore 940t icache/dcache settings (should be faster now)
changed dualcore 940t binary limit from 10Mb to 31Mb

:eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek:

RLYEH = GOD OF GP2X
 
enable/disable tv out : 0x2800
set/unset PAL/NTSC video modes: 0x2818

center the screen: which register do you use here?

Those registers won't work at all and you can't adjust TV that way.

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:
Code:
int handle;

//this is your program. i'm working with LCD...
...

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

//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 CX25784 chip directly through the I2C chip.

Some code following:
Code:
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 CX25784 chipset before using those i2c functions (just in the odd case you need 'em really).
//I'm currently managing to get hsync, vsync, external clock, timings, etc to work. It's a hell, but I'm getting some success (got my first 720x576I mode to work directly using the autoconfiguration encoder settings :-)

Have you found out how to set the res/overscan and other interesting stuff?

Yep, although timing CRTs is a mad nightmare.
PS: No idea about the RGB pins you mentioned before.

:eek: Dodgy TV-out is one of the only things left that's wrong with the GP2X IMO.
Good luck with this rlyeh & I hope it goes well :)

p.s. Would this help to fix ryo's problems with TV-out on gmenu2x?

Yeah, trying to get a native 320x240 tv out mode right now (no more squeezing :)
Btw, what are ryo's problems?
 
Last edited by a moderator:
...

Code:
//I'd suggest you to read the CX25784 chipset before using those i2c functions (just in the odd case you need 'em really).
//I'm currently managing to get hsync, vsync, external clock, timings, etc to work. It's a hell, but I'm getting some success (got my first 720x576I mode to work directly using the autoconfiguration encoder settings :-)

...

Yep, although timing CRTs is a mad nightmare.

i remembered reading these somewhere and found this thread;
Ac97 Codec Registers

Hmm, looked at the code for /dev/cx25874, just has the one command to switch modes... At least it gives the values that they use to program the video modes.
I've now got the tech docs for the LCD so I'm going to check the timings, though if the CX is processing the signal first it may be the CX's fault.
Dignsys' i2c code is very suspect - it has a software delay loop! That'll make things interesting when people adjust the clockspeed.
 
Last edited by a moderator:
Btw, what are ryo's problems?

Basically it didn't want to start the TV-out properly when starting GMenu2x. You only got half a screen of display (but it's not squashed). I remember it being mentioned that was related to the autorun feature... but don't quote me.
 
Last edited by a moderator:
That is a truly impressive list of features and support. Hats off to that shit :)
 
Back
Top