⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flcd.c

📁 GM8120 linux driver.
💻 C
📖 第 1 页 / 共 4 页
字号:
// -----------------------------------------------------------------------------// 	Copyright  Faraday Technology Corp 2004-2006.  All rights reserved.// -----------------------------------------------------------------------------// FILENAME:  flcd.c// DEPARTMENT :CTD/SSD// VERSION: Revision:1.0// -----------------------------------------------------------------------------// MAJOR REVISION HISTORY// DATE        	AUTHOR       	DESCRIPTION// 2004/3/25    Rockey          1. RGB   v.s byte and pixel enidan//                              2. YcbCr vs  byte endian//                              3. Interrupt Test//                              4. OSD Test// -----------------------------------------------------------------------------#include <stdio.h>#include <string.h>#include <stdlib.h> #include "flcd.h"#define LCD_TRUE	1#define LCD_FALSE   0typedef struct LcdMTypeTag{  int Valid;  unsigned char Descriptor[20];  unsigned int Timing0;  unsigned int Timing1;  unsigned int Timing2;  unsigned int Control;  int Width;  int Height;} LCDMTYPE_T;/*******************************************************************************  Declare 3(Valid) & 1(Null) ModuleType*  0. Sharp LQ084C1DG21: Color TFT 16bpp 640x480*  1. Ampire mono stn 8bit-i/f 320x240*  2. Ampire color stn 8bit-i/f 320x240 16bpp*  3. Null******************************************************************************/               LCDMTYPE_T FLcdModule[] = { /*  { // Valid,	Descriptor    LCD_TRUE,	"Sharp LQ057Q3DC02xxx",    // Timing0     ((2			- 1) << 24) //Horizontal back porch	|((48			- 1) << 16)	//Horizontal front porch	|((70			- 1) << 8 )	//Horizontal Sync. pulse width//	|(((320 >> 4)	- 1) << 2 ),//pixels-per-line = 16(PPL+1)	|(((640 >> 4)	- 1) << 2 ),//pixels-per-line = 16(PPL+1)	//Timing1	 (7 		<< 24)			//Vertical back porch	|(15		<< 16) 			//Vertical front porch	|((1 - 1)	<< 10) 			//Vertical Sync. pulse width	|((240 - 1)		 ),			//lines-per-panel = LPP+1	//Timing2	 (LCD_FALSE	<< 26) 			//Bypass pixel clock divider//	|((320 - 1)	<< 16) 			//Clock per line	|((640 - 1)	<< 16) 			//Clock per line		|(LCD_FALSE	<< 14) 			//invert output enable	|(LCD_FALSE	<< 13) 			//invert panel clock	|(LCD_TRUE	<< 12) 			//invert horizontal sync.	|(LCD_TRUE	<< 11) 			//invert vertical sync	|((32 - 1)	<<  6) 			//ac bias	|(LCD_FALSE	<<  5) 			//clock select	|(4 - 2			 ),			//panel clock divdsor	//Control	 (LCD_FALSE	<< 16) 			//LCD DMA FIFO watermark level	|(LCD_FALSE	<< 15) 			//LCD DMA FIFO test mode enable	|(0			<< 12) 			//LcdVComp, when to generate interrupt	|(LCD_FALSE	<< 11) 			//LCD power enable	|(LCD_FALSE	<< 10) 			//Big-endian pixel ordering//	|(LCD_TRUE	<< 10) 			//Big-endian pixel ordering	|(LCD_FALSE	<<  9) 			//Big-endian Byte ordering	|(LCD_FALSE	<<  8) 			//BGR	|(LCD_FALSE	<<  7) 			//LcdDual	|(LCD_FALSE	<<  6) 			//LcdMono8	|(LCD_TRUE	<<  5) 			//LcdTFT	|(LCD_FALSE	<<  4) 			//LcdBW	|(4			<<  1) 			//LCD bits per pixel: 16bpp	|(LCD_FALSE		 ),			//LCD controller enable	//Width//	320,	640,	//Height	480  },  */    {    LCD_TRUE,	"Albert's Para",     0x2B135F9C,    0x101045DF,    0x00003806,    0x00013a29,    320,    240,      },        {    LCD_TRUE,	"Albert's Parameter",     0x1010104c,    0x070F00EF,    0x013F37c2,    0x00043a29,    320,    240,      },    // Sharp LQ084C1DG21 ***********************************************  { // Valid,	Descriptor    LCD_TRUE,	"Sharp LQ084C1DG21",    // Timing0     ((44			- 1) << 24) //Horizontal back porch	|((20			- 1) << 16)	//Horizontal front porch	|((96			- 1) << 8 )	//Horizontal Sync. pulse width	|(((640 >> 4)	- 1) << 2 ),//pixels-per-line = 16(PPL+1)	//Timing1	 (34		<< 24)			//Vertical back porch	|(10		<< 16) 			//Vertical front porch	|((1 - 1)	<< 10) 			//Vertical Sync. pulse width	|((480 - 1)		 ),			//lines-per-panel = LPP+1	//Timing2	 (LCD_FALSE	<< 26) 			//Bypass pixel clock divider	|((640 - 1)	<< 16) 			//Clock per line	|(LCD_FALSE	<< 14) 			//invert output enable	|(LCD_FALSE	<< 13) 			//invert panel clock	|(LCD_TRUE	<< 12) 			//invert horizontal sync.	|(LCD_TRUE	<< 11) 			//invert vertical sync	|((32 - 1)	<<  6) 			//ac bias	|(LCD_FALSE	<<  5) 			//clock select	|(8 - 2			 ),			//panel clock divdsor	//Control	 (LCD_FALSE	<< 16) 			//LCD DMA FIFO watermark level	|(LCD_FALSE	<< 15) 			//LCD DMA FIFO test mode enable	|(0			<< 12) 			//LcdVComp, when to generate interrupt	|(LCD_FALSE	<< 11) 			//LCD power enable	|(LCD_FALSE	<< 10) 			//Big-endian pixel ordering//	|(LCD_TRUE	<< 10) 			//Big-endian pixel ordering	|(LCD_FALSE	<<  9) 			//Big-endian Byte ordering	|(LCD_FALSE	<<  8) 			//BGR	|(LCD_FALSE	<<  7) 			//LcdDual	|(LCD_FALSE	<<  6) 			//LcdMono8	|(LCD_TRUE	<<  5) 			//LcdTFT	|(LCD_FALSE	<<  4) 			//LcdBW	|(4			<<  1) 			//LCD bits per pixel: 16bpp	|(LCD_FALSE		 ),			//LCD controller enable	//Width	640,	//Height	480  },  // Ampire mono stn 8bit 320x240**************************************  { // Valid,	Descriptor,    LCD_TRUE,	"Ampire Mono320x240",    // Timing0     ((1			- 1) << 24) //Horizontal back porch	|((1			- 1) << 16)	//Horizontal front porch	|((1			- 1) << 8 )	//Horizontal Sync. pulse width	|(((320 >> 4)	- 1) << 2 ),//pixels-per-line = 16(PPL+1)	//Timing1	 (0			<< 24)			//Vertical back porch	|(0			<< 16) 			//Vertical front porch	|((1 - 1)	<< 10) 			//Vertical Sync. pulse width	|((240 - 1)		 ),			//lines-per-panel = LPP+1	//Timing2	 (LCD_FALSE	<< 26) 			//Bypass pixel clock divider	|((40 - 1)	<< 16) 			//Clock per line	|(LCD_FALSE	<< 14) 			//invert output enable	|(LCD_FALSE	<< 13) 			//invert panel clock	|(LCD_FALSE	<< 12) 			//invert horizontal sync.	|(LCD_FALSE	<< 11) 			//invert vertical sync	|((32 - 1)	<<  6) 			//ac bias	|(LCD_FALSE	<<  5) 			//clock select	|(8 - 2			 ),			//panel clock divdsor	//Control	 (LCD_FALSE	<< 16) 			//LCD DMA FIFO watermark level	|(LCD_FALSE	<< 15) 			//LCD DMA FIFO test mode enable	|(0			<< 12) 			//LcdVComp, when to generate interrupt	|(LCD_FALSE	<< 11) 			//LCD power enable	|(LCD_TRUE	<< 10) 			//Big-endian pixel ordering	|(LCD_FALSE	<<  9) 			//Big-endian Byte ordering	|(LCD_FALSE	<<  8) 			//BGR	|(LCD_FALSE	<<  7) 			//LcdDual	|(LCD_TRUE	<<  6) 			//LcdMono8	|(LCD_FALSE	<<  5) 			//LcdTFT	|(LCD_TRUE	<<  4) 			//LcdBW	|(0			<<  1) 			//LCD bits per pixel: 1bpp	|(LCD_FALSE		 ),			//LCD controller enable	//Width	320,	//Height	240  },    // Ampire color stn 8bit 320x240**************************************  { // Valid,	Descriptor,    LCD_TRUE,	"Ampire Color320x240",    // Timing0     ((16			- 1) << 24) //Horizontal back porch	|((1			- 1) << 16)	//Horizontal front porch	|((4			- 1) << 8 )	//Horizontal Sync. pulse width	|(((320 >> 4)	- 1) << 2 ),//pixels-per-line = 16(PPL+1)	//Timing1	 (14		<< 24)			//Vertical back porch	|(0			<< 16) 			//Vertical front porch	|((2 - 1)	<< 10) 			//Vertical Sync. pulse width	|((240 - 1)		 ),			//lines-per-panel = LPP+1	//Timing2	 (LCD_FALSE	<< 26) 			//Bypass pixel clock divider	|((240 - 1)	<< 16) 			//Clock per line	|(LCD_FALSE	<< 14) 			//invert output enable	|(LCD_TRUE	<< 13) 			//invert panel clock	|(LCD_TRUE	<< 12) 			//invert horizontal sync.	|(LCD_TRUE	<< 11) 			//invert vertical sync	|((32 - 1)	<<  6) 			//ac bias	|(LCD_FALSE	<<  5) 			//clock select	|(2 - 2			 ),			//panel clock divdsor	//Control	 (LCD_FALSE	<< 16) 			//LCD DMA FIFO watermark level	|(LCD_FALSE	<< 15) 			//LCD DMA FIFO test mode enable	|(0			<< 12) 			//LcdVComp, when to generate interrupt	|(LCD_FALSE	<< 11) 			//LCD power enable	|(LCD_TRUE	<< 10) 			//Big-endian pixel ordering	|(LCD_FALSE	<<  9) 			//Big-endian Byte ordering	|(LCD_FALSE	<<  8) 			//BGR	|(LCD_FALSE	<<  7) 			//LcdDual	|(LCD_FALSE	<<  6) 			//LcdMono8	|(LCD_TRUE	<<  5) 			//LcdTFT	|(LCD_FALSE	<<  4) 			//LcdBW	|(4			<<  1) 			//LCD bits per pixel: 16bpp	|(LCD_FALSE		 ),			//LCD controller enable	//Width	320,	//Height	240  },  // Null ***********************************************   //  Valid,	Descriptor, Timing1, Timing2, Timing2, Control,	Width, Height     {LCD_FALSE,	"",			0,		 0,		  0,	   0,		0,     0, },    };unsigned int LCD_IO_Base;/*typedef struct{UINT32 HBP:8;          //Horizontal back porch	UINT32 HFP:8;          //Horizontal front porch	UINT32 HW: 8;           //horizontal synchronization pulse width	UINT32 Reserved:2;	UINT32 PL: 6;           //pizels-per-line}LCD_Horizontal_Timing;*/#define LCD_PANEL_TYPE  0x1#define LCD_IO_BASE     0x96500000//#define LCD_IO_BASE     0x90600000#define INTC_BASE       0x98800000void OSD_Off( unsigned int  base );void SetFrameBase( unsigned char *base );void SetBPP( unsigned char bpp);void SetEndian( unsigned char endian);void SetYCbCr( int type );void rgb2ycbcr( unsigned char *r, unsigned char *g, unsigned char *b);void Init_LCD( volatile unsigned int LCD_BASE,  volatile LCDMTYPE_T *pLCDC, unsigned int lcd_type, unsigned char bpp );void ColorBar_RGB( unsigned char bpp, unsigned char endian, unsigned char *pFrameBuffer, int width, int height, int int_test );void ColorBar_YCbCr_422( unsigned char endian, unsigned char *pFrameBuffer, int width, int height, int int_test);void ColorBar_YCbCr_420( unsigned char endian, unsigned char *pFrameBuffer, int width, int height, int int_test);enum { LBLP, BBBP, LBBP};#include <math.h>#include "fLib.h"/*__irq  LCD_Interrupt(){}*/void set_lcdc_default()   { *(volatile unsigned int *) ( LCD_IO_Base )= 0x2B135F9C; *(volatile unsigned int *) ( LCD_IO_Base + 0x4   )= 0x101045DF; *(volatile unsigned int *) ( LCD_IO_Base + 0x8   )= 0x00009803; *(volatile unsigned int *) ( LCD_IO_Base + 0x10  )= 0x10100020; *(volatile unsigned int *) ( LCD_IO_Base + 0x1c  )= 0x00013a29; *(volatile unsigned int *) ( LCD_IO_Base + 0x18  )= 0x0000001e;}void draw_6448(unsigned int xpos, unsigned int ypos, unsigned int color){unsigned int img_base,offset,value;   offset = ypos*1280 + xpos*2 ;   if((offset&0x00000002) !=0x00000000) value = color;   else value = ( color << 16 );   img_base = ( *(volatile unsigned int *) (LCD_IO_Base + 0x10) );   img_base = img_base + (offset)&0xfffffffc;   *(unsigned int *) img_base = value;}void clear_screen(){unsigned int i,img_base;  img_base = ( *(volatile unsigned int *) (LCD_IO_Base + 0x10) );  for( i=img_base; i<(img_base+0x01c0000); i+=4 ) *(unsigned int *) i = 0x00000000;}  void saving_mode_burnning(){unsigned int xpos,ypos,signx,signy,cnt,color;  clear_screen();  cnt=0;  color=0xffff;  xpos=123;  ypos=257;  signx = 1;  signy = 1;  while(1){    xpos=xpos+signx;    ypos=ypos+signy;    if(xpos>=640||xpos==0xffffffff){      if(signx==1) signx = 0xffffffff ; else signx = 1;      xpos = xpos + signx + signx;    }    if(ypos>=480||ypos==0xffffffff){      if(signy==1) signy = 0xffffffff ; else signy = 1;      ypos = ypos + signy + signy;    }       draw_6448(xpos,ypos,color);    cnt++;    if(cnt==0x1000){      cnt=0;      color = (color + 0x0821) & 0x0000ffff;    }   }}  void page_mode_burnning() { unsigned int i;     while(1){   for( i=0x10100000; i<0x10160000; i+=4 ) *(unsigned int *) i = 0xffffffff;   for( i=0x10160000; i<0x101c0000; i+=4 ) *(unsigned int *) i = 0x00000000;   *(volatile unsigned int *) ( LCD_IO_Base + 0x10 )= 0x10100020;   for( i=0x10200000; i<0x10260000; i+=4 ) *(unsigned int *) i = 0x00000000;   for( i=0x10260000; i<0x102c0000; i+=4 ) *(unsigned int *) i = 0xffffffff;   *(volatile unsigned int *) ( LCD_IO_Base +0x10  )= 0x10200020;   for( i=0x10300000; i<0x10360000; i+=4 ) *(unsigned int *) i = 0xf800f800;   for( i=0x10360000; i<0x103c0000; i+=4 ) *(unsigned int *) i = 0x07ff07ff;   *(volatile unsigned int *) ( LCD_IO_Base +0x10 )= 0x10300020;   for( i=0x10400000; i<0x10460000; i+=4 ) *(unsigned int *) i = 0x07e007e0;   for( i=0x10460000; i<0x104c0000; i+=4 ) *(unsigned int *) i = 0xf81ff81f;   *(volatile unsigned int *) ( LCD_IO_Base +0x10 )= 0x10400020;   for( i=0x10500000; i<0x10560000; i+=4 ) *(unsigned int *) i = 0x001f001f;   for( i=0x10560000; i<0x105c0000; i+=4 ) *(unsigned int *) i = 0xffe0ffe0;   *(volatile unsigned int *) ( LCD_IO_Base +0x10 )= 0x10500020;  }}    unsigned char VerticalInt=0;void LCD_Handler(){  *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000000;   //disable all LCD interrupt  * (unsigned char *) (LCD_IO_Base + 0x20)  = 0x08;  if( ( * (unsigned char *) (LCD_IO_Base + 0x24) ) & 0x08 )             * (unsigned char *) (LCD_IO_Base + 0x20)  = 0x08;         VerticalInt = 1;       MaskFIQ(2);  DisableFIQ();   }unsigned char BaseUpdateInt=0;void FrameBaseUpdate(){  *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000000;  * (unsigned char *) (LCD_IO_Base + 0x20)  = 0x04;  if( ( * (unsigned char *) (LCD_IO_Base + 0x24) ) & 0x04 )             * (unsigned char *) (LCD_IO_Base + 0x20)  = 0x04;  BaseUpdateInt = 1;  MaskFIQ(2);  DisableFIQ();             }int animation_frame;void animation(){    * (unsigned char *) (LCD_IO_Base + 0x20)  = 0x04;  animation_frame++;   MaskFIQ(2);  DisableFIQ();        }void Vertical_Int_Test( int int_num){   int i;  // fLib_ConnectInt(34, LCD_Handler);	//it only can be     fLib_ConnectInt(32 + int_num, LCD_Handler);    EnableFIQ();				//It enables ARM's IRQ in the Boot.s	     VerticalInt = 0;  *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;//  UnmaskFIQ(2);  UnmaskFIQ(int_num);  SetFIQmode(int_num,LEVEL);  *(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;    *(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00000000;  //generate interrupt @ start of vertical back porch    if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical sync  OK\n");	  else   printf("Interrupt testing: start of vertical sync  fail!!!\n");  if(  * (unsigned char *) (LCD_IO_Base + 0x24) ) printf("Interrupt status bit clear fail\n");  else  printf("Interrupt status bit clear OK\n");          VerticalInt = 0;  *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;//  UnmaskFIQ(2);  UnmaskFIQ(int_num);  SetFIQmode(int_num,LEVEL);  *(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;    *(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00001000;  //generate interrupt @ start of vertical back porch  EnableFIQ();        if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical porch  OK\n");	  else   printf("Interrupt testing: start of vertical porch  fail!!!\n");  if( * (unsigned char *) (LCD_IO_Base + 0x24) ) printf("Interrupt status bit clear fail\n");  else  printf("Interrupt status bit clear OK\n");        VerticalInt = 0;  *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;  //UnmaskFIQ(2);  UnmaskFIQ(int_num);  SetFIQmode(int_num,LEVEL);  *(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;    *(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00002000;  //generate interrupt @ start of active image  EnableFIQ();       if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical active image  OK\n");	  else   printf("Interrupt testing: start of vertical active image fail!!!\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -