QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1607|回复: 0

如何驱动s3c2410 STN LCD?

[复制链接]
发表于 2006-7-22 14:55:22 | 显示全部楼层 |阅读模式
Hi,all.I am working s3c2410,My lcd driver is ok for TFT LCD,But I will want to driver STN LCD.
    STN LCD argument:160x160,4 bit single scan,homochromy.
    My driver can driver STN LCD,But it will work not normal,that is also,It cannot normal display
character and picture which is lose data;
    the flowing is my driver's part code:
    in s3c241fb.h:
#define LCD_XSIZE_STN   (160)
#define LCD_YSIZE_STN   (160)

//STN
#define SCR_XSIZE_STN   (LCD_XSIZE_STN*2)   //for virtual screen
#define SCR_YSIZE_STN   (LCD_YSIZE_STN*2)
//STN
#define HOZVAL_STN              (LCD_XSIZE_STN/4-1)     // Valid VD data line number is 4.
//#define HOZVAL_STN                (159)
#define LINEVAL_STN             (LCD_YSIZE_STN-1)
                                                                                          
//STN
#define WLH_STN                 (1)
#define WDLY_STN                (1)

//#define LINEBLANK_MONO                (10)
#define LINEBLANK_MONO          (1 &0xff) // MONO timing parameter for CPT CLS-040S-C3M(CHUNGHWA)
#define LINEBLANK_GRAY          (13 &0xff)// GRAY timing parameter for CPT CLS-040S-C3M(CHUNGHWA)
#define CLKVAL_STN_MONO         (30)
#define CLKVAL_STN_GRAY         (10)
#define MVAL         (13)
#define MVAL_USED    (1)
#define M5D(n) ((n) & 0x1fffff)      // To get lower 21bits
#define S3C2410_OFFSIZE(x)      ((x) << 11)
#define S3C2410_PAGEWIDTH(x)    (x)
#define S3C2410_LCDCON2_LINEVAL(x)  ((x) << 14)
#define S3C2410_LCDCON3_HOZVAL(x)   ((x) <<

in s3c2410fb.c:
ifdef CONFIG_S3C2410_SMDK
static struct s3c2410fb_mach_info xxx_stn_info __initdata = {
        pixclock:       174757,              bpp:            1,
        xres:           160,
        yres:           160,
                                       
        hsync_len   :  5,    vsync_len    :  1,
        left_margin :  7,    upper_margin :  1,
        right_margin:  3,    lower_margin :  3,
                                                                                          
        sync:   FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, cmap_static:    1,
        reg : {
                lcdcon1 CLKVAL_STN_MONO<<|(MVAL_USED<<7)|(1<<5)|(0<<1)|0,
                lcdcon2 0<<24)|(LINEVAL_STN<<14)|(0<<6)|(0<<0),
                lcdcon3 : (WDLY_STN<<19)|(LINEBLANK_MONO<<0),
                lcdcon4 : (MVAL<<|(WLH_STN<<0),
               lcdcon5 : LCD5_PWREN|LCD5_HWSWP,
                                                                                          
        },
};
#endif


static int s3c2410fb_activate_var(struct fb_var_screeninfo *var, struct s3c2410fb_info *fbi)
{
    struct s3c2410fb_lcd_reg new_regs;
    u_int  yres;
    u_long flags;

   // unsigned long VideoPhysicalTemp = fbi->screen_dma;
    unsigned long VideoPhysicalTemp=fbi->fb.fix.smem_start;
    save_flags_cli(flags);

   new_regs.lcdcon1=fbi->reg.lcdcon1&~LCD1_ENVID;
   new_regs.lcdcon1|=LCD1_BPP_1S|LCD1_PNR_4S;
   new_regs.lcdcon2 &= ~S3C2410_LCDCON2_LINEVAL(0x3ff);
   new_regs.lcdcon2  =S3C2410_LCDCON2_LINEVAL(var->yres- 1);
   new_regs.lcdcon3  =fbi->reg.lcdcon3&~S3C2410_LCDCON3_HOZVAL(0x7ff);
   new_regs.lcdcon3  |= S3C2410_LCDCON3_HOZVAL(var->xres/4-1);
   
  //new_regs.lcdcon3  = fbi->reg.lcdcon3;
   new_regs.lcdcon4 = fbi->reg.lcdcon4;
   new_regs.lcdcon5 = fbi->reg.lcdcon5;
  


new_regs.lcdsaddr1=LCDADDR_BANK(((unsigned long)VideoPhysicalTemp >> 22)<<21)
              | LCDADDR_BASEU(((unsigned long)VideoPhysicalTemp >> 1));

new_regs.lcdsaddr2=M5D(((VideoPhysicalTemp+fbi->fb.fix.smem_len)>>1));
//new_regs.lcdsaddr2=M5D((VideoPhysicalTemp+(var->xres+var->yres+var->xres*var->yres)/>>1);
new_regs.lcdsaddr3=S3C2410_OFFSIZE(0) |S3C2410_PAGEWIDTH(var->xres-1);

// new_regs.lcdsaddr2 =((unsigned long)VideoPhysicalTemp+(LCD_XSIZE_STN*LCD_YSIZE_STN/)>>1 ;
//new_regs.lcdsaddr3 =(((SCR_XSIZE_STN-LCD_XSIZE_STN)/16)<<11)|(LCD_XSIZE_STN/16);
// new_regs.lcdsaddr1=(((unsigned long)VideoPhysicalTemp>>22)<<21)|M5D((unsigned long)VideoPhysicalTemp>>1);
//new_regs.lcdsaddr2=M5D(((unsigned long)VideoPhysicalTemp+(SCR_XSIZE_STN*LCD_YSIZE_STN/)>>1);
// new_regs.lcdsaddr3 =(((SCR_XSIZE_STN-LCD_XSIZE_STN)/16)<<11)|(LCD_XSIZE_STN/16);

        fbi->reg.lcdcon1 = new_regs.lcdcon1;
        fbi->reg.lcdcon2 = new_regs.lcdcon2;
        fbi->reg.lcdcon3 = new_regs.lcdcon3;
        fbi->reg.lcdcon4 = new_regs.lcdcon4;
        fbi->reg.lcdcon5 = new_regs.lcdcon5;
        fbi->reg.lcdsaddr1 = new_regs.lcdsaddr1;
        fbi->reg.lcdsaddr2 = new_regs.lcdsaddr2;
        fbi->reg.lcdsaddr3 = new_regs.lcdsaddr3;

    LCDCON1 = fbi->reg.lcdcon1;
    LCDCON2 = fbi->reg.lcdcon2;
    LCDCON3 = fbi->reg.lcdcon3;
    LCDCON4 = fbi->reg.lcdcon4;
    LCDCON5 = fbi->reg.lcdcon5;
   
    printk(KERN_INFO"set LCDADD argument\n");
    //printk(KERN_INFO"");
    //printk(KERN_INFO"");
    printk(KERN_INFO"OFFSIZE:0x%08lX\nPAGEWIDTH:0x%08lX\n",LCDADDR3&0x7FF8,LCDADDR3&0x7FF);
    LCDADDR1 = fbi->reg.lcdsaddr1;
    LCDADDR2 = fbi->reg.lcdsaddr2;
    LCDADDR3 = fbi->reg.lcdsaddr3;
/*
#if defined(CONFIG_S3C2410_SMDK) && !defined(CONFIG_SMDK_AIJI)
    LCDLPCSEL = 0x2;       
#elif defined(CONFIG_S3C2410_SMDK) && defined(CONFIG_SMDK_AIJI)
    LCDLPCSEL = 0x7;
#endif
  */
    LCDLPCSEL=0x4;
    {
     int loop=7;
        LCDCON5&=~(1<<3);
        while(loop)
        {
        LCDCON1|=1;
        LCDCON1&=0x3fffe;
        loop--;
        }
        LCDCON5|=(1<<3);
        }
    LCDCON1 |= LCD1_ENVID;

#if 1
        {
        printk("con1 = 0x%08lX\n", LCDCON1);
        printk("con2 = 0x%08lX\n", LCDCON2);

        printk("con3 = 0x%08lX\n", LCDCON3);
        printk("con4 = 0x%08lX\n", LCDCON4);
        printk("con5 = 0x%08lX\n", LCDCON5);
        printk("addr1 = 0x%08lX\n", LCDADDR1);
        printk("addr2 = 0x%08lX\n", LCDADDR2);
        printk("addr3 = 0x%08lX\n", LCDADDR3);
        }
#endif

    restore_flags(flags);

    return 0;
}

if you any suggest,please tell me!
Thank you a lots and good luck for you and me!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-2 14:22 , Processed in 0.037761 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表