LCD Driver (I)

Publisher:RadiantBreezeLatest update time:2024-07-18 Source: cnblogsKeywords:LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

LCD display principle:

To make LCD display on JZ2440, several parts are needed: 1. LCD hardware 2. LCD controller on the development board 3. SDRAM memory to store data FramBuffer 4. A palette may also be needed (actually a piece of memory, in which data can form various colors)

Display principle: Operate the LCD controller on the development board so that the development board removes data from the SDRAM memory and sends it to the LCD screen through the LCD data pin.

Specific hardware operation steps:

1. Connection of LCD pins, configure the pins according to the LCD schematic diagram

2. Set up the LCD controller according to the LCD controller manual

3. Allocate video memory and tell the LCD controller the address

Situations where a palette is needed: LCD data lines are few, for example, 16-bit data lines cannot display all color components and can only be used as an index to point to the actual address color space on the palette

LCD display principle:

You can imagine that there is an electron gun behind the LCD. The function of the electron gun is to print the colors obtained from the FramBuffer memory to the LCD screen one by one. How to print? The order is:

Start from the upper left corner of the LCD screen, and start from left to right, one color dot at a time. When there is no more space, start to wrap and start from left to right again. It is like you open a notepad and press a character or symbol that you don't understand.

It will continuously output letters on the notepad, and when it reaches the boundary, it will start to wrap the output until it is finished. Of course, the space on the LCD screen is limited, and the speed of printing is very fast, so you feel that the image appears suddenly in front of you.

The same as before.

------------------------------------------------------------------------------------------------------------------------------------

LCD driver framework

A framework that meets the needs of character device drivers

1. The application enters the kernel through open, read, write and other functions and then calls dri_open, dri_read, dir_write and other functions to find the registration ID of the LCD driver through the device.

Enter the File_operation structure function of the driver function and operate the hardware. The main framework is shown in the figure.


LCD Driver

Assume
app: open("/dev/fb0", ...) Major device number: 29, Minor device number: 0
--------------------------------------------------------------
kernel:
fb_open
int fbidx = iminor(inode);
struct fb_info *info == registered_fb[0];

app: read()
---------------------------------------------------------------
kernel:
fb_read
int fbidx = iminor(inode);
struct fb_info *info = registered_fb[fbidx];
if (info->fbops->fb_read)
return info->fbops->fb_read(info, buf, count, ppos);

src = (u32 __iomem *) (info->screen_base + p);
dst = buffer;
*dst++ = fb_readl(src++);
copy_to_user(buf, buffer, c)

Q1. Where is registered_fb set?
A1. register_framebuffer

How to write an LCD driver?
1. Allocate an fb_info structure: framebuffer_alloc
2. Set
3. Register: register_framebuffer
4. Hardware-related operations

----------------------------------------------------------------------------------------------------------------

Initialize LCD: What to do in the main entry function

1. Allocate an fb_info structure: framebuffer_alloc

struct fb_info {

........

struct fb_var_screeninfo var; /* Current var variable parameter*/
struct fb_fix_screeninfo fix; /* Current fix fixed parameter*/

........

}

/* 1. Allocate a fb_info */
s3c_lcd = framebuffer_alloc(0, NULL);

2. Setup

/* 2. Setting*/
/* 2.1 Setting fixed parameters Current fix*/

struct fb_fix_screeninfo {
char id[16]; /* identification string eg "TT Builtin" */
unsigned long smem_start; /* Start of frame buffer mem */
/* (physical address) */
__u32 smem_len; /* Length of frame buffer mem */
__u32 type; /* see FB_TYPE_* */
__u32 type_aux; /* Interleave for interleaved Planes */
__u32 visual; /* see FB_VISUAL_* */
__u16 xpanstep; /* zero if no hardware panning */
__u16 ypanstep; /* zero if no hardware panning */
__u16 ywrapstep; /* zero if no hardware ywrap */
__u32 line_length; /* length of a line in bytes */
unsigned long mmio_start; /* Start of Memory Mapped I/O */
/* (physical address) */
__u32 mmio_len; /* Length of Memory Mapped I/O */
__u32 accel; /* Indicate to driver which */
/* specific chip/card we have */
__u16 reserved[3]; /* Reserved for future compatibility */
};

strcpy(s3c_lcd->fix.id, "mylcd");
s3c_lcd->fix.smem_len = 240*320*16/8;
s3c_lcd->fix.type = FB_TYPE_PACKED_PIXELS;
s3c_lcd->fix.visual = FB_VISUAL_TRUECOLOR; /* TFT */
s3c_lcd->fix.line_length = 240*2;


/* 2.2 Set variable parameter Current var */

struct fb_var_screeninfo {
__u32 xres; /* visible resolution */
__u32 yres;
__u32 xres_virtual; /* virtual resolution */
__u32 yres_virtual;
__u32 xoffset; /* offset from virtual to visible */
__u32 yoffset; /* resolution */

__u32 bits_per_pixel; /* guess what */
__u32 grayscale; /* != 0 Graylevels instead of colors */

struct fb_bitfield red; /* bitfield in fb mem if true color, */
struct fb_bitfield green; /* else only length is significant */
struct fb_bitfield blue;
struct fb_bitfield transp; /* transparency */

__u32 nonstd; /* != 0 Non standard pixel format */

__u32 activate; /* see FB_ACTIVATE_* */

__u32 height; /* height of picture in mm */
__u32 width; /* width of picture in mm */

__u32 accel_flags; /* (OBSOLETE) see fb_info.flags */

/* Timing: All values in pixclocks, except pixclock (of course) */
__u32 pixclock; /* pixel clock in ps (pico seconds) */
__u32 left_margin; /* time from sync to picture */
__u32 right_margin; /* time from picture to sync */
__u32 upper_margin; /* time from sync to picture */
__u32 lower_margin;
__u32 hsync_len; /* length of horizontal sync */
__u32 vsync_len; /* length of vertical sync */
__u32 sync; /* see FB_SYNC_* */
__u32 vmode; /* see FB_VMODE_* */
__u32 rotate; /* angle we rotate counter clockwise */
__u32 reserved[5]; /* Reserved for future compatibility */
};

s3c_lcd->var.xres = 240;
s3c_lcd->var.yres = 320;
s3c_lcd->var.xres_virtual = 240;
s3c_lcd->var.yres_virtual = 320;
s3c_lcd->var.bits_per_pixel = 16;

/* RGB:565 */
s3c_lcd->var.red.offset = 11;
s3c_lcd->var.red.length = 5;

s3c_lcd->var.green.offset = 5;
s3c_lcd->var.green.length = 6;

s3c_lcd->var.blue.offset = 0;
s3c_lcd->var.blue.length = 5;

s3c_lcd->var.activate = FB_ACTIVATE_NOW;


/* 2.3 Setting operation function*/

s3c_lcd->fbops = &s3c_lcdfb_ops;
/* 2.4 Other settings*/

s3c_lcd->screen_size   = 240*324*16/8;

3. Hardware-related operations

/* 3.1 Configure GPIO for LCD */
/* 3.2 Set up LCD controller according to LCD manual, such as VCLK frequency, etc. */
/* 3.3 Allocate video memory (framebuffer), and tell the address to LCD controller */


4. Registration: register_framebuffer

/* 4. Register */
register_framebuffer(s3c_lcd);


Keywords:LCD Reference address:LCD Driver (I)

Previous article:I2C Driver Detailed Explanation
Next article:LCD Driver(II)

Recommended ReadingLatest update time:2024-11-16 09:34

mini2440 button-driven POLL mechanism experiment
Makefile KERN_DIR = /home/grh/kernel_source_code/linux-2.6.32.2 all :  make -C $(KERN_DIR) M=`pwd` modules arm-linux-gcc key_interrupt_app.c -o key_interrupt_app clean : make -C $(KERN_DIR) M=`pwd` modules clean rm -rf modules.order obj-m += test_driver.o obj-m += key_poll.o obj-m += key_interrupt.o copy : 
[Microcontroller]
mini2440 button-driven POLL mechanism experiment
Comparison of portable oscilloscope and desktop oscilloscope in measuring the driver chip of switching power supply
A set of tests were conducted using a portable oscilloscope and a desktop oscilloscope to measure the driving waveform of a flyback switching power supply driver chip. The DSO112A portable oscilloscope was used first. Since the reference of the DSO112A portable oscilloscope is isolated from the mains ground, the test
[Test Measurement]
Comparison of portable oscilloscope and desktop oscilloscope in measuring the driver chip of switching power supply
51 single chip PCF8591 four-channel AD numerical LCD1602 screen display source code
MCU source program: /**********************BST-V51 experimental development board routine************************ * Platform: BST-V51 + Keil U3 + STC89C52 * Name: Four-channel AD value LCD1602 screen display * Company: Shenzhen Yabo Software Development Co., Ltd. * Crystal oscillator: 11.0592MHZ **********************
[Microcontroller]
PI SCALE-iFlex series adds a new family, XLT drive modules continue to challenge the power density limit
Power Integration (PI) recently announced the launch of the SCALE-iFlex XLT series of dual-channel plug-and-play gate drivers, which are suitable for single LV100 (Mitsubishi), XHP 2 (Infineon), HPnC (Fuji Electric) and equivalent semiconductor power modules with a withstand voltage of up to 2300V. The module is sui
[Power Management]
PI SCALE-iFlex series adds a new family, XLT drive modules continue to challenge the power density limit
The structure and working principle of dual motor drive
Dual motor drive provides two control modes for one axis, tandem control and synchronous control. Tandem control performs position control only on the main motor axis and torque control only on the auxiliary motor axis, so this control is also called torque tandem control. (Simplified) Synchronous control uses the N
[Embedded]
Design of LED driver with constant illumination dimming
introduction Under the environment of increasing environmental pressure and increasingly tight global energy, energy conservation and emission reduction have become the main development direction of the world economy. As a new type of solid lighting source, LED light source has the advantages of high luminous e
[Embedded]
Design of LED driver with constant illumination dimming
Melexis launches smaller, fully integrated LIN driver chip to drive relay-controlled window regulators
Melexis, a global microelectronics engineering company, today announced the launch of a new LIN pre-driver chip MLX81160 for relay-controlled DC motor applications. This chip is the latest member of Melexis' third-generation compatible embedded motor driver chip series, which combines the advantages of high power, com
[Automotive Electronics]
Melexis launches smaller, fully integrated LIN driver chip to drive relay-controlled window regulators
STM32L0 Development Notes 4: Solve the error problem of using --CPP11 to compile USB driver
    The project hopes to use C++ language for programming. I have already introduced the method of using C++ language in Keil in Using C++ for Programming in Keil . However, when compiling the STM32L0XX related files generated by STM32CubeMX, the error shown in the figure below is prompted.     A careful analysis sh
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号