Author Topic: Iodata Cfxga Card Under Pdaxrom  (Read 2541 times)

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« on: October 10, 2006, 08:07:54 am »
Hello,

does anyone use the IODATA CF-XGA card successfully under pdaXrom 1.1.0beta3?
Anyone willing to help to make it work?
I tried with different versions of the cfxga-mirror tool available on the Internet but to no avail.

The "cfxga-mirror" tool which is shipped with pdaXrom 1.1.0beta3 and installed under /usr/bin generates a disturbed
image on the external monitor (rotated by 90 degrees, ghosted four times and interlaced).
I have not found the sources for that. Does anyone have them?

So I downloaded the "cfxgamirror" and "cfxgamirror2" sources, the first one from trisoft, the other one from a Japanese page.

cfxgamirror needed a little change in order to generate a good image on the monitor. Otherwise it generated also a disturbed image, but different than
"cfxga-mirror".
cfxgamirror2 did it fine without the change.

BUT: Both of these versions crash the Zaurus after some seconds if used under X.
If used under console without X (i.e. directly after booting) they work fine.
The pre-installed "cfxga-mirror" does not crash, at least not as fast as the others.

Also, if I start them under console without X, then terminate them, and then want to start X, I get this error and X doesn't start until I reboot:

Code: [Select]
#startx
Loading /etc/sysconfig/keyboard/kernel.map

_XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
_XSERVTransOpen: transport open failed for inet6/zaurus:0
_XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6
XIO:  fatal IO error 104 (Conection reset by peer) on X server ":0.0"
 Â     after 0 requests (0 known processed) with 0 events remaining.

Below is the source code of cfxgamirror2.c which causes that problems.

Does anyone have a clue why:

1. the tool crashes the Zaurus
2. ...only when in X
3. startx cannot be executed after the tool ran under console
(even ejecting the card and/or unloading memory_cs.o does not help for startx)
4. how I can make this card work well under pdaXrom?

Currently I am trying to track down the position in the source where the zaurus crashes using printf commands.
Will update this thread on each result.

Any help or hint greatly appreciated!

Thanks a lot!
daniel


here comes cfxgamirror2.c:

Code: [Select]
#include
#include
#include
#include
#include
#include
#include
#include "cfxga.h"

#define SCREEN_WIDTH    640
#define SCREEN_HEIGHT   480

int main(int argc, char *argv[])
{
 Â   unsigned short *scrnbuf, *sb2;
 Â   unsigned long rez;
 Â   int fd, fbfd, center=0;
 Â   struct cfxgaset desc = { 0, 0, 640, 480, 16, 1280, NULL };
 Â   struct cfxgaget info;


 Â   fd = open("/dev/cfxga0a", O_RDWR);
 Â   if(fd < 0)
 Â   {
    printf("No CFXGA card\n");
    return -1;
 Â   }

 Â   if(argc == 1 || argc>3 ||
 Â      (!isdigit(argv[1][0])&&!isdigit(argv[argc-1][0])))
 Â   {
    int i;
    
    printf("usage: cfxgamirror [-c] \n Available modes:\n");
    // display data for all modes
    ioctl(fd, CFXGANUMMODES, &rez);
    for(i = 0; i < rez; i++)
    {
 Â    info.mode = i;
 Â    ioctl(fd, CFXGAGETMODE, &info);
 Â    printf("%2ld: W=%ld H=%ld vf=%-2ld d=%ld hf=%ld vid=%02lx\n", info.mode, info.width, info.height, info.vfreq,
 Â      info.depth, info.hfreq, info.appl);
    }
    printf("must assign mode number\n");
    printf("-c  :  display to center and no scaling\n");
    close(fd);
    return 1;
 Â   }
 Â   if (argv[1][0]=='-'&&argv[1][1]=='c')
 Â       center = 1;
 Â   
 Â   
 Â   rez = atoi(argv[argc-1]);
 Â   // get mode stats
 Â   info.mode = rez;
 Â   ioctl(fd, CFXGAGETMODE, &info);

 Â   // display mode specs
 Â   printf("%2ld: W=%ld H=%ld vf=%-2ld d=%ld hf=%ld vid=%02lx\n", info.mode, info.width, info.height, info.vfreq, info.depth,
 Â         info.hfreq, info.appl);
 Â   if (center==0)
 Â   {
 Â       desc.height = info.height;
 Â       desc.width = info.width;
 Â   }
 Â   else
 Â   {
 Â       desc.left = (info.width - desc.width) / 2;
 Â       desc.top = (info.height - desc.height) / 2;
 Â       desc.height = SCREEN_HEIGHT;
 Â       desc.width = SCREEN_WIDTH;
 Â   }
 Â   desc.stride = desc.width*2;
 Â   // set mode
 Â   ioctl(fd, CFXGASETMODE, &rez);
 Â   // clear screen
 Â   ioctl(fd, CFXGACLEAR, NULL);
 Â   // map screen buffer
 Â   fbfd = open("/dev/fb0", O_RDONLY);    // I'm not sure when I can close this
 Â   sb2 = mmap(0, SCREEN_WIDTH * SCREEN_HEIGHT * 2, PROT_READ, MAP_PRIVATE, fbfd, 0);
 Â   
 Â   // close(fbfd);  /* comment by daniel3000: I tried this here, but it does not make a difference at all. */
 Â   
 Â   // a normal malloc or global may work, but to be safe...
 Â   scrnbuf = mmap(0, desc.width * desc.height * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 Â   desc.image = scrnbuf;

 Â   // update the image a little slower than every second
 Â   for(;;)
 Â   {
 Â       static int sum;
 Â       int i,j,x,y,dx,dy,cx,cy,cksum;
    unsigned short *dst,*src;
 Â       
 Â       dx = desc.width - SCREEN_WIDTH;
 Â       dy = desc.height - SCREEN_HEIGHT;        
 Â       cksum = 0;
 Â       dst = scrnbuf;
 Â       y = SCREEN_HEIGHT-1;
 Â       for(cy=i=0;i Â       {
 Â           src = sb2+y;
 Â           for(x=cx=j=0;j Â           {
 Â               cksum+=(*dst=src[x]);
 Â               cx += dx;
 Â               if (cx>=desc.width)
 Â               {
 Â                   cx -= desc.width;
 Â                   x -= SCREEN_HEIGHT;
 Â               }
 Â               x += SCREEN_HEIGHT;
 Â           }
 Â           cy += dy;
 Â           if (cy>=desc.height)
 Â           {
 Â               cy-=desc.height;
 Â               y++;
 Â           }
 Â       }
    // send to VGA chip
    if (sum!=cksum)
    {
 Â                 ioctl(fd, CFXGAWRITERECT, &desc);
 Â                 sum = cksum;
 Â               }
    sleep(1);
 Â   }
}
« Last Edit: October 10, 2006, 02:10:50 pm by daniel3000 »
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« Reply #1 on: October 10, 2006, 09:03:50 am »
Update:
Found the sources of "cfxga-mirror" which is preinstalled in pdaXrom under:
http://mail.pdaxrom.org/download/1.1.0beta3/src/

However, I cannot compile them using make becasue the cfxga_cs.o module is to be conpiled too which need kernel sources.

However, I can compile the cfxga-mirror.cpp source file seperately.
Will try around with that one.

Question:
What's this cfxga_cs.o module?
It is also available under pdaXrom and loadable using modprobe, but the card is always recognized as "anonymous memory" which is bound to "memory_cs.o".
I tried modifying /etc/pcmcia/config so that Anonymous memory is bound to cfxga_cs instead, but this does not work.

Do I need this module?
How do I load it then?

Thanks
daniel
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« Reply #2 on: October 10, 2006, 01:48:32 pm »
Now I seem to be at a dead end with my limited low-level programming knowledge and definitely need some help!

I have one program which generates a good image but crashes (cfxgamirror(2).c).

And I have one program which is stable but generates a garbled image (cfxga-mirror.cpp).


The difference is that the C programs use ioctl write function 5 (write from memory, i.e. framebuffer data is first copied to memory and then to the memory of the card),
and the CPP program uses function 6, which is direct copying the data from /dev/fb0 to the card memory:

Code: [Select]
[API List]
 1. CFXGA_GET_STATUS    Get a status of CFXGA. Check the physical card and a driver version.
 2. CFXGA_GET_RESONUM    Return supported resolution numbers.
 3. CFXGA_GET_RESOINFO    List up suppoted resolutions info.
 4. CFXGA_SET_RESO  Set up a resolution
 5. CFXGA_COPY_FB  Copy data from memory to frame buffer
 6. CFXGA_COPY_FB2  Copy data from assigned physical address to frame buffer
 7. CFXGA_CLEAR_SCREEN@    Display clear
 8. CFXGA_SCREEN_OFF    Display off


CPP (source see below appended to this posting):
I have tried to adjust a lot of parameters (UseFB0Copy.*) for function 6 in the cpp program, but to no avail.
The only things I have not touched are the physical address and offset, as I don't know how they are handled at all and what they exactly mean. So they could still be the reason for the display problems.

C (source see above in first posting):
I have tried to pin down the position where the program crashes the Zaurus.
It crashes it only if X is running, not on console. And it crashes at many different positions, mostly within the last for(;;) loop. So I assume the reason for the total system crash is one of the ioctl calls, which may need some variable time so the crash does not happen always at the same position within the program.
It is very probably that if it is a ioctl call, it is the one which copies the data to the card memory, because this is the only one which is called periodically once the program is running. And sometimes the crash happens only after the screen has been updated quite a lot of times.

I think one way to pin down the reason for crashing could be to find out what the X server error messages mean which I gave in Post #1. Any clue?
I think the critical error message is the XIO:  fatal IO error 104. The others should not do any harm and I think I have seen them before.

Or maybe combining the two programs may help, i.e. taking the CPP program and modifying it to use function 5 instead of 6. However, I have almost no C++ skills so this would be a major task for me probably.

I would be willing to pay for help, if the result is satisfactory.
Anyone interested in assisting me?
I need a working solution until Friday!  

I have attached the two source trees, one includes the API description:
 [ Invalid Attachment ]

(don't worry about the cfxga_cs module in one of the directories. Simply compile with
g++ -o testbin cfxga-mirror.cpp
make will give errors if pcmcia sources are not installed)

Thanks for any help!

daniel
« Last Edit: October 10, 2006, 02:07:54 pm by daniel3000 »
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« Reply #3 on: October 10, 2006, 02:36:58 pm »
Found the data sheet of the used chip here
(it is the S1D13806 chip).
« Last Edit: October 10, 2006, 02:38:09 pm by daniel3000 »
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« Reply #4 on: October 10, 2006, 06:11:21 pm »
and here are "screen-shots" of the stable version(taken with camera from computer monitor).

The first one is how the original version of cfxga-mirror.cpp (pre-installed version) produces the image and the second shot is with UseFBOCopy.swivel = 1 instead.

The three / four "ghosted" images are not identical to each other. If they were stacked, they would probably add up to a complete image. You can see it when you have a look at the red and blue console icons in the upper right window corner.

Maybe from that pattern someone can see what parameter is wrong?  

[img]http://www.daniel-hertrich.de/zaurus/share/IMG_2318.JPG\" border=\"0\" class=\"linked-image\" /]

[img]http://www.daniel-hertrich.de/zaurus/share/IMG_2316.JPG\" border=\"0\" class=\"linked-image\" /]
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

Hrw

  • Hero Member
  • *****
  • Posts: 1366
    • View Profile
Iodata Cfxga Card Under Pdaxrom
« Reply #5 on: October 11, 2006, 03:28:37 am »
Months ago I tried to write something working for that card. It was hard to debug because user of card was in US and lack camera but I got only 480x480 output from his Tosa (SL-6000). My program used CFXGA_COPY_FB2.

BTW - with USB host machine I would serach for USB VGA card rather.
« Last Edit: October 11, 2006, 03:29:32 am by Hrw »
OpenZaurus 3.5.4x Release Manager
OpenEmbedded, Ångström, Poky developer
My website

Misc embedded hardware.

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« Reply #6 on: October 11, 2006, 04:41:57 am »
Hi Hrw,

thanks for the info.
Due to lack of supply for the IODATA cards I also would rather like to find a good and working USB solution.

Is there any known solution with a linux tool available?
Maybe even tested on Zaurus already?

Bandwidth should not be the problem, if only used for presentations or slide shows. However, if it should allow a "larger screen" for work or even video, bandwidth is probably a big issue.
For me, low bandwidth would be enough.

However, could I have a look at what you wrote for 480x480?
That would be better than nothing and maybe lead to another solution.

Thanks a lot
Daniel
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Iodata Cfxga Card Under Pdaxrom
« Reply #7 on: October 11, 2006, 07:36:28 am »
Quote
Hi Hrw,

thanks for the info.
Due to lack of supply for the IODATA cards I also would rather like to find a good and working USB solution.

Is there any known solution with a linux tool available?
Maybe even tested on Zaurus already?

Bandwidth should not be the problem, if only used for presentations or slide shows. However, if it should allow a "larger screen" for work or even video, bandwidth is probably a big issue.
For me, low bandwidth would be enough.

However, could I have a look at what you wrote for 480x480?
That would be better than nothing and maybe lead to another solution.

Thanks a lot
Daniel
[div align=\"right\"][a href=\"index.php?act=findpost&pid=143710\"][{POST_SNAPBACK}][/a][/div]

I got a USB to VGA dongle and it basically works on my Zaurus for short presentations. However, it suffers from instability which I am sure if I had the time and was a bit more motivated I could debug and fix it since the source for the application and the driver is freely available.
It currently is compiled for Sharp ROM so it could probably be easily ported to OPIE.
I am sure that there would be an app for X11 out there as well that could be used for pdaXrom. The important thing is to get the driver debugged and stable.
« Last Edit: October 11, 2006, 07:39:04 am by Meanie »
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Iodata Cfxga Card Under Pdaxrom
« Reply #8 on: October 11, 2006, 09:38:35 am »
Quote
I got a USB to VGA dongle and it basically works on my Zaurus for short presentations. However, it suffers from instability which I am sure if I had the time and was a bit more motivated I could debug and fix it since the source for the application and the driver is freely available.
It currently is compiled for Sharp ROM so it could probably be easily ported to OPIE.
I am sure that there would be an app for X11 out there as well that could be used for pdaXrom. The important thing is to get the driver debugged and stable.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=143719\"][{POST_SNAPBACK}][/a][/div]

Hi Meanie,

which model of USB VGA adapter is it? Is it still available and will be in the future?
How can I motivate you to debug it?  

daniel
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

Reaper

  • Full Member
  • ***
  • Posts: 126
    • View Profile
Iodata Cfxga Card Under Pdaxrom
« Reply #9 on: October 13, 2006, 10:28:36 am »
Well, I can't help much, but maybe you'll find it useful. I have Pretec CompactPresenter card and once I've been able to use it with Cacko. I'd had to do several things before I got it worked because of its partial incompatibility with CFXGA. What I did:

1) Downloaded memory_cs.o from I-O-Data and put it into /lib/modules/2.4.18-rmk7-pxa3/embedix/pcmcia;

2) Corrected video mode (the problem you had with distortion - that's it, very high refresh rate, check your monitor's rate counter) by editing /home/QtPalmtop/bin/mirror.sh symlink from /usr/QtPalmtop.rom/bin/mirror.sh to /home/root/mirror.sh (you should copy file from /home/QtPalmtop/bin/ to /home/root and edit it - just replace "cfxgamirror 0" with "cfxgamirror 1").

3) Presentation used its own porgramming of VGA card, so after starting it I had to set its video output to anywhere else but VGA (composite or S-video), set mode 640x480 and run mirror program again.

I'd be very glad to try any solutions suggested because I'd like very much to use my C3000 with CompactPresenter under pdaX.