User talk:Dfoisy

Interfacing an Optrex T51750GD065J-FW-AB to a Gumstix
This isn't much different than the other entries in the wiki regarding interfacing to LCDs but I've tried to include the source material...

Applicable documents

 * Daughterboard schematics []
 * Optrex T51750GD065J-FW-AB datasheet

Step-by-step instructions
1. By looking at the Intel PXA2555 Processor Design Guide chapter 3 and the T51750 documentation, you can see that Figure 3-6 (pg. 51) indicates how to interface the Gumstix to the LCD panel. Note that the T51750 has 6 bits per color but the gumstix only has 16 data lines for the LCD - I grounded the LSBs of the red and blue as suggested. Just make sure that the voltage levels are correct (i.e Vih min should be <= 2.4V but your mileage may vary).

2. Next, you have to change the buildroot to enable the framebuffer per Holly's instructions. The only change I had to make was to change the following line:

setenv bootargs console=ttyS0,115200n8 root=1f02 rootfstype=jffs2 reboot=cold,hard video=pxafb:mode:800x600-16,active

to

setenv bootargs console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard video=pxafb:mode:640x480-16,active

This also sets up the LCD DMA that copies the raw pixel values from RAM (frame buffer) to the LCD port.

3. By examining the LCD datasheet pages 7 and 8 and the documentation in chapter 7 of [http://www.intel.com/design/pca/applicationsprocessors/manuals/278693.htm Intel PXA255 Processor Developer's Manual], you can figure out that the four LCD registers should be set to (including equivalent timing spec references from the LCD datasheet):

LCCR0
 * OUM	1
 * BM	1
 * PDD	0
 * QDM	1
 * DIS	0
 * DPD	0
 * PAS	1	//active display
 * EFM	1
 * IUM	1
 * SFM	1
 * LDM	1
 * SDS	0	//must be 0 in active mode
 * CMS	0	//color mode
 * ENB	1	//enable LCD controller

LCCR1
 * BLW	0	//Thfp on page 7 of LCD datasheet in pixel clocks whose rate is set later in LCCR3
 * ELW	6	//Thbp
 * HSW	4	//Twhl
 * PPL	639	//number of pixels per line -1

LCCR2
 * BFW	20	//Tvfp (this is in line clocks which is generated automatically by the PXA255)
 * EFW	20	//Tvbp
 * VSW	2	//Twvl
 * LPP	479	//number of lines -1

LCCR3	
 * DPC	0
 * BPP	4	//16-bits per pixel
 * OEP	0	//active high: equivalent to the DENA line on page 8 of the LCD datasheet
 * PCP	1	//data lines sampled by LCD on the falling edge of DCLK
 * HSP	1	//HD is active low
 * VSP	1	//VD is active low
 * API 	0
 * ACB	0
 * PCD	1	//sets the pixel clock frequency PCD=( LCLK / (2 * PixelClock) ) - 1, where LCLK is 99.5MHz (or thereabouts)and PixelClock is Fclk from LCD datasheet = 25MHz

4a. From the prompt, you can poke these values directly into the appropriate registers:

pxaregs LCCR1 397951

pxaregs LCCR2 336857567

pxaregs LCCR3 74448897

pxaregs LCCR0 3148025		//have to do it in this order to make sure all the other registers have valid values before enabling the LCD

I found that I had to also issue the following commands: modprobe pxafb options=mode:640x480-16,active

and that sometimes I would get some "static" in the image so reissuing: pxaregs LCCR3 74448897

would solve the problem.

4b. Alternatively, you can run this from the root prompt (or the equivalent at the u-boot prompt) ''modprobe pxafb options=mode:640x480-16,active,color,left:1,right:7,hsynclen:5,upper:20,lower:20,vsynclen:3,hsync:0,vsync:0,dpc:0,outputen:1,pixclockpol:0,pixclock:40000 '' 5. This leaves you with a blank screen. To see if it's working, you can perform the following: cp [some file, doesn't matter what] /dev/fb0

This simply copies whatever is in the file into the framebuffer for display. You'll get some amount of garbage but the number of pixels of garbage will be equal to the filesize/2 (because there's 16 bits per pixel).

6. To display an image, I wrote a simple utility that takes an image file and creates a binary file in the appropriate format for copying to the framebuffer using the same process in step 5. It's written in MFC. The source code of the relavent routine is as follows:

<void CpictureDlg::OnBnClickedGenerate {
 * CString filename;
 * GetDlgItemText(IDC_FILENAME,filename);
 * CImage image;
 * image.Load(filename);
 * ASSERT(image.GetWidth==640);
 * ASSERT(image.GetHeight==480);


 * int i=filename.ReverseFind('.');
 * CString name;
 * if(i==-1)
 * filename+=".bin";
 * }
 * else
 * filename=filename.Left(i)+".bin";
 * }
 * filename=filename.Left(i)+".bin";
 * }


 * FILE *fp=fopen(filename,"wb");


 * for(int y=0;y> 3;
 * DWORD green=GetGValue(col) >> 2;
 * DWORD blue=GetBValue(col) >> 3;
 * DWORD green=GetGValue(col) >> 2;
 * DWORD blue=GetBValue(col) >> 3;


 * USHORT val;
 * val=(red<<11) | (green<<5) | blue;
 * fwrite(&val,2,1,fp);
 * }


 * }


 * fclose(fp);

} void CpictureDlg::OnBnClickedBrowse {
 * CFileDialog cf(TRUE,"BMP",NULL,0,"Graphics files (*.jpg,*.jpeg,*.gif,*.bmp)|*.jpg;*.jpeg;*.gif;*.bmp|All files (*.*)|*.*||");
 * if(cf.DoModal==IDOK)
 * SetDlgItemText(IDC_FILENAME,cf.GetPathName);

} 