Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

请教一个有关LCD驱动的比较困惑的问题

0 views
Skip to first unread message

silentgg

unread,
Jan 27, 2010, 1:54:08 AM1/27/10
to
1.硬锟斤拷平台锟斤拷AT91SAM9263锟斤拷锟斤拷锟斤拷系统锟斤拷Linux2.6.27锟斤拷TFT LCD 480*272(锟斤拷锟斤拷锟斤拷)
2.锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷目锟斤拷锟截点,锟斤拷要锟斤拷写一锟斤拷锟斤拷锟斤拷颍锟斤拷应锟矫层传锟斤拷锟斤拷锟斤拷锟斤拷荩锟斤拷锟斤拷锟斤拷锟姐动锟斤拷锟斤拷锟斤拷锟斤拷锟角革拷锟斤拷锟捷o拷锟斤拷LCD锟斤拷锟斤拷示锟斤拷应锟斤拷锟斤拷锟截o拷锟斤拷
为锟斤拷实锟斤拷锟斤拷锟斤拷锟斤拷埽锟斤拷业锟斤拷锟斤拷锟斤拷牵锟斤拷锟叫匆伙拷锟斤拷址锟斤拷璞革拷锟斤拷锟侥o拷锟斤拷始锟斤拷时锟斤拷锟斤拷取锟节猴拷映锟斤拷玫姆锟斤拷锟斤拷LCD锟斤拷锟节达拷占洌╢ramebuffer锟斤拷锟节达拷占洌╋拷锟饺伙拷锟斤拷锟接︼拷貌愦拷锟斤拷锟斤拷锟斤拷锟捷斤拷锟斤拷锟斤拷悖拷锟斤拷姆锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟节达拷占锟斤拷锟斤拷锟捷★拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷牵锟斤拷锟斤拷锟斤拷锟斤拷蚨己锟斤拷锟饺凤拷锟姐,锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷幕锟较碉拷图锟斤拷只要锟斤拷一些锟斤拷锟酵伙拷锟斤拷锟皆感撅拷锟斤拷一锟斤拷锟斤拷幕锟斤拷锟斤拷示锟斤拷锟斤拷锟斤拷锟斤拷锟皆感撅拷锟斤拷CPU锟节伙拷锟竭★拷锟斤拷
锟斤拷锟角o拷锟斤拷uboot锟铰o拷锟斤拷示一锟斤拷锟斤拷色图片锟斤拷锟斤拷锟叫撅拷锟饺较快。锟斤拷锟斤拷
锟斤拷锟斤拷为什么锟斤拷???锟斤拷锟斤拷锟斤拷锟解方锟芥工锟斤拷锟侥达拷锟斤拷指锟斤拷一锟铰★拷锟斤拷锟斤拷什么锟斤拷锟斤拷锟斤拷锟斤拷使锟斤拷刷锟斤拷锟斤拷锟劫度匡拷一些锟斤拷锟斤拷

锟斤拷锟街达拷锟斤拷锟斤拷锟铰o拷

static struct file_operations Fops_lcd =
{
.owner = THIS_MODULE,
.open = lcd_device_open,
.release= lcd_device_release,
.read = lcd_device_read,
.write = lcd_device_write,
.ioctl = NULL,
};

static struct fb_fix_screeninfo fix;
static struct fb_var_screeninfo var;
static int bytes_per_pixel;

static struct fb_info *atmel_fb=NULL; /*锟斤拷要锟斤拷锟斤拷锟斤拷LCD锟斤拷锟斤拷锟斤拷锟斤拷应锟斤拷FB锟借备锟结构锟斤拷*/
static unsigned char *line_addr;


static void lcdport_write(unsigned int addr, char data)
{
unsigned int x,y;
int kk,bits;

bits = data;

y = addr / 40;
x = (addr%40)锟斤拷8

#if LINE_SCAN_MODE == 1
for(kk=0;kk<8;kk++,bits <<=1)
{
if(bits & 0x80)
pixel(x+kk,y,COLOR_INDEX);
}
#elif LINE_SCAN_MODE == 2
for(kk=0;kk<8;kk++,bits <<=1)
{
if(bits & 0x80)
pixel(x+8-kk,y,COLOR_INDEX);
}

#elif LINE_SCAN_MODE == 3
for(kk=0;kk<8;kk++,bits <<=1)
{
if(bits & 0x80)
pixel(x,y+kk,COLOR_INDEX);
}

#elif LINE_SCAN_MODE == 4
for(kk=0;kk<8;kk++,bits <<=1)
{
if(bits & 0x80)
pixel(x,y+8-kk,COLOR_INDEX);
}
#endif

}


static inline void __setpixel (union multiptr loc, unsigned xormode, unsigned color)
{
switch(bytes_per_pixel) {
case 1:
default:
if (xormode) //transparent
*loc.p8 ^= color;
else
*loc.p8 = color;
break;
case 2:
if (xormode)
*loc.p16 ^= color;
else
*loc.p16 = color;
break;
case 3:
if (xormode)
*loc.p32 ^= color;
else
*loc.p32 = color;
break;
case 4:
if (xormode)
*loc.p32 ^= color;
else
*loc.p32 = color;
break;
}
}

static void pixel (int x, int y, unsigned colidx)
{
unsigned xormode;
union multiptr loc;

if ((x < 0) || ((__u32)x >= var.xres_virtual) ||
(y < 0) || ((__u32)y >= var.yres_virtual))
return;

xormode = colidx & XORMODE;
colidx &= ~XORMODE;

loc.p8 = line_addr + y*fix.line_length + x * bytes_per_pixel;
//__setpixel (loc, xormode, colormap [colidx]);
__setpixel (loc, xormode, 255);
}

static int __init lcd_device_init (void)
{
int ret;
int i;
char *fbp;

/* Register the character device */
if ((ret = register_chrdev(DEVICE_MAJOR, DEVICE_NAME, &Fops_lcd)) < 0)
{
printk ("LCD Device failed with %d\n", ret);
return (ret);
}

/*PRINT_TRACE(Debug)("%s the major is %d.\n",lcd_device_driver_ver,DEVICE_MAJOR);*/
for(i = 0;i < num_registered_fb; i++)
{
/*printk("*******%s******\n",registered_fb->monspecs.manufacturer);*/
if(memcmp(registered_fb->monspecs.manufacturer,"HIT",4)==0)
{
atmel_fb = registered_fb;
break;
}
}
if(atmel_fb==NULL)
goto no_lcd;

fix = atmel_fb->fix;
var = atmel_fb->var;
bytes_per_pixel = var.bits_per_pixel / 8;
line_addr = atmel_fb->screen_base;

printk("LCD Paramres=%d,yres=%d,bytes_per_pixel=%d\n",var.xres,var.yres,bytes_per_pixel);
printk("******screen_base:0x%X\n",atmel_fb->screen_base);
printk("******screen_size:0x%X\n",atmel_fb->screen_size);
printk("******smem_start:0x%X\n",fix.smem_start);
printk("******smem_len:0x%X\n",fix.smem_len);
/*printk("*******%s******\n",atmel_fb->monspecs.manufacturer);*/
printk("LCD driver:Find specified LCD device!\n";
return 0;

no_lcd:
printk("LCD driver:Not find specified LCD device!\n";
return (0);
}

module_init (lcd_device_init);

--

[m [37m锟斤拷 锟斤拷源:锟斤拷水木锟斤拷锟斤拷 http://newsmth.net锟斤拷[FROM: 113.98.195.*] [m

:(){ :|: &}; :

unread,
Jan 27, 2010, 2:28:43 AM1/27/10
to
��˵Ϊɶ��ֱ����Ӧ�ó���mmap framebufferȻ��ֱ�Ӳ���֮
�����Ҫ����һ�����������򰡡�

�� �� silentgg (silentgg) �Ĵ������ᵽ: ��
: 1.Ӳ��ƽ̨��AT91SAM9263������ϵͳ��Linux2.6.27��TFT LCD 480*272(������)
: 2.����������������Ŀ���ص㣬��Ҫ��дһ������򣬸��Ӧ�ò㴫��������ݣ�������㶯���������Ǹ����ݣ���LCD����ʾ��Ӧ�����أ���
: Ϊ��ʵ��������ܣ��ҵ������ǣ���дһ���ַ��豸����ģ���ʼ��ʱ����ȡ�ں�ӳ��õķ����LCD���ڴ�ռ䣨framebuffer���ڴ�ռ䣩��Ȼ����Ӧ�ò㴫��������ݽ�����㣬���ķ�������������ڴ�ռ�����ݡ���
: ...................

--

[m [1;31m�� ��Դ:��ˮľ���� newsmth.net��[FROM: 114.246.162.*] [m

silentgg

unread,
Jan 27, 2010, 3:22:29 AM1/27/10
to
��Ϊ֮ǰ�Ѿ�д����һ���ϲ�Ӧ�õĿ⺯��,������ֲ������ƽ̨��,��һ�������ṩһ��ӿڵ������,����ȽϷ���...��ʲô���������������?��ɻ��߱Ƚ����ԭ����ʲô??
�� �� minux (:(){ :|: &}; :) �Ĵ������ᵽ: ��
: ��˵Ϊɶ��ֱ����Ӧ�ó���mmap framebufferȻ��ֱ�Ӳ���֮
: �����Ҫ����һ�����������򰡡�

--

[m [37m�� ��Դ:��ˮľ���� http://newsmth.net��[FROM: 113.98.195.*] [m

:(){ :|: &}; :

unread,
Jan 27, 2010, 3:44:58 AM1/27/10
to

�� �� silentgg (silentgg) �Ĵ������ᵽ: ��
: ��Ϊ֮ǰ�Ѿ�д����һ���ϲ�Ӧ�õĿ⺯��,������ֲ������ƽ̨��,��һ�������ṩһ��ӿڵ������,����ȽϷ���...��ʲô���������������?��ɻ��߱Ƚ����ԭ����ʲô??
��ô����������Ҫ������ݶ��ٴΣ���mmapֻ����һ����ȣ������ܲ���ô����
�ټ����ּ�һ�����н������̬��ʱ�䡣

�Ͳ��ܸĸ��Ǹ��⺯��ô���Ѷ�������д�ijɶ�mmap()ed framebuffer��д��

silentgg

unread,
Jan 27, 2010, 4:31:29 AM1/27/10
to
�⺯�����Ƚ϶�,���ұ����������ʹ��,����Խ��Խ��,����ķ��������޸������,����Ͳ����޸��˿⺯����..
������д���Ǹ�������,line_addr = atmel_fb->screen_base;��ʵ��ȡ�ĵ�ַ����framebuffer�������ַ.�ҿ�����fbmem.c������,fb_write��fb_readҲ����ʹ��screen_base�����ַ����ȡ��ݵ�.����,�������dd if=fbfile of=/dev/fb0
(fbfileΪһ��LCD����ʾ�ļ�)���������������LCD��ʾ��ͼƬ�ͺܿ졣��

�� �� minux (:(){ :|: &}; :) �Ĵ������ᵽ: ��
: ��ô����������Ҫ������ݶ��ٴΣ���mmapֻ����һ����ȣ������ܲ���ô����

: �ټ����ּ�һ�����н������̬��ʱ�䡣
: �Ͳ��ܸĸ��Ǹ��⺯��ô���Ѷ�������д�ijɶ�mmap()ed framebuffer��д��

--

[m [37m�� ��Դ:��ˮľ���� http://newsmth.net��[FROM: 113.98.195.*] [m

:(){ :|: &}; :

unread,
Jan 27, 2010, 7:30:53 AM1/27/10
to
����ϸ������������Ҫ���ٴ��ڴ濽���ɡ���
ǰ��˵���ȿ�������ķ������У�������ij�����Ҫ��һ����ʽ�ĸ���LCD�IJ�������

�� �� silentgg (silentgg) �Ĵ������ᵽ: ��
: �⺯�����Ƚ϶�,���ұ����������ʹ��,����Խ��Խ��,����ķ��������޸������,����Ͳ����޸��˿⺯����..


: ������д���Ǹ�������,line_addr = atmel_fb->screen_base;��ʵ��ȡ�ĵ�ַ����framebuffer�������ַ.�ҿ�����fbmem.c������,fb_write��fb_readҲ����ʹ��screen_base�����ַ����ȡ��ݵ�.����,�������dd if=fbfile of=/dev/fb0
: (fbfileΪһ��LCD����ʾ�ļ�)���������������LCD��ʾ��ͼƬ�ͺܿ졣��

: ...................

silentgg

unread,
Jan 31, 2010, 10:58:53 PM1/31/10
to
�����������Ľ��ͣ�
1.��֤��LCD��ʾͼƬ�Ƚ����ԭ���������Ŀ��lib��Ĵ���ԭ��������ʾͼ��ʱ��
lib��ĺ���ͨ��writeϵͳ���ð���ݴ�����㣬���ԭ�������Lib�����write��
��̫Ƶ���ˣ�����һ�ε���write�������������̫���ˣ�����ֱ��ʱ��ÿ��
��һ���ֽ���ݣ������Ե�����ͼ����ʾ̫���ˡ�
2.��Linux��framebuffer���У��Ѿ��ṩ��һ������DMAӳ��������ַ�ռ�
��fb_info�ij�Աscreen_base����ֱ���������ַ�ռ�����ݣ����ܹ�����Ļ����ʾ��
Ӧ��ͼ�񡣶���Linuxϵͳ���Զ��������ַ����ݣ��ᵽLCD����ʾ�ڴ��С���ΰ᣿
û��ʱ��ȥ�˽⡣��

�� �� silentgg (silentgg) �Ĵ������ᵽ: ��
: 1.Ӳ��ƽ̨��AT91SAM9263������ϵͳ��Linux2.6.27��TFT LCD 480*272(������)
: 2.����������������Ŀ���ص㣬��Ҫ��дһ������򣬸��Ӧ�ò㴫��������ݣ�
������㶯���������Ǹ����ݣ���LCD����ʾ��Ӧ�����أ���

: Ϊ��ʵ��������ܣ��ҵ������ǣ���дһ���ַ��豸����ģ���ʼ��ʱ����ȡ��
��ӳ��õķ����LCD���ڴ�ռ䣨framebuffer���ڴ�ռ䣩��Ȼ����Ӧ�ò㴫����


����ݽ�����㣬���ķ�������������ڴ�ռ�����ݡ���
: ...................

--

[m [33m�� ��Դ:��ˮľ���� http://newsmth.net��[FROM: 113.98.195.*] [m

0 new messages