1. Video off-the-shelf example only contains the tq2440 pair of 4.3-inch LCD driver code.However, I have a tq2440 7.0-inch LCD screen in my hand, so I checked the 7.0 screen manual and changed the parameters to be usable.
If tq2440 is used, you can set the LCD parameters in the 7.0-inch screen driver example.
The following two settings can be used.
# Include <Linux/module. h> # include <Linux/kernel. h> # include <Linux/errno. h> # include <Linux/string. h> # include <Linux/mm. h> # include <Linux/slab. h> # include <Linux/delay. h> # include <Linux/FB. h> # include <Linux/init. h> # include <Linux/dma-mapping.h> # include <Linux/interrupt. h> # include <Linux/workqueue. h> # include <Linux/Wait. h >#include <Linux/platform_device.h> # include <Linux/CLK. h> # include <ASM/Io. h> # inclu De <ASM/uaccess. h> # include <ASM/div64.h> # include <ASM/Mach/map. h> # include <ASM/ARCH/regs-lcd.h> # include <ASM/ARCH/regs-gpio.h> # include <ASM/ARCH/FB. h> static int maid (unsigned int Regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info * info); struct LCD _regs {unsigned long lcdcon1; unsigned long lcdcon2; unsigned long lcdcon3; unsigned long LC Dcon4; unsigned long lcdcon5; unsigned long commit; unsigned long lcdsaddr2; unsigned long commit; unsigned long redlut; unsigned long greenlut; unsigned long bluelut; unsigned long reserved [9]; unsigned long dithmode; unsigned long tpal; unsigned long lcdintpnd; unsigned long lcdsrcpnd; unsigned long lcdintmsk; unsigned long lpcsel;}; static struct fb_ops initi_lcdfb_ops = {. owner = this_module ,. Fb_setcolreg = maid ,. fb_fillrect = cfb_fillrect ,. fb_copyarea = cfb_copyarea ,. statistics = statistics,}; static struct fb_info * initi_ LCD; static volatile unsigned long * gpbcon; static volatile unsigned long * gpbdat; static volatile unsigned long * gpccon; static volatile unsigned long * gpdcon; static volatile unsigned long * gpgcon; static volatile struct LCD _regs * LCD _regs; static u32 P Seudo_palette [16];/* From pxafb. C */static inline unsigned int chan_to_field (unsigned int Chan, struct fb_bitfield * BF) {Chan & = 0 xFFFF; Chan >>= 16-BF-> length; return Chan <BF-> offset;} static int initi_lcdfb_setcolreg (unsigned int Regno, unsigned int red, unsigned int green, unsigned int blue, unsigned int transp, struct fb_info * info) {unsigned int val; If (Regno> 16) return 1;/* use red, green, and blue primary colors Create Val */val = chan_to_field (red, & info-> var. red); Val | = chan_to_field (Green, & info-> var. green); Val | = chan_to_field (Blue, & info-> var. blue); // (u32 *) (Info-> pseudo do_palette) [Regno] = val; pseudo do_palette [Regno] = val; return 0;} static int LCD _init (void) {/* 1. allocate a fb_info */89c_ LCD = framebuffer_alloc (0, null);/* 2. set * // * 2.1 to set a fixed parameter */strcpy (initi_ LCD-> fix. ID, "mylcd"); // initiation_ LCD-> fix. smem_len = 480*272 * 32/8;/* the LCD Bit Width of tq2440 is 24, but 4 bytes are allocated in 2440, that is, 32 bits (1 byte waste) */initi_ LCD-> fix. smem_len = 800*480*32/8; initi_ LCD-> fix. type = fb_type_packed_pixels; initi_ LCD-> fix. visual = fb_visual_truecolor;/* TFT * // initiation_ LCD-> fix. line_length = 480*4; s3c24_ LCD-> fix. line_length = 800*4;/* 2.2 set the variable parameter * // initiation_ LCD-> var. xres = 480; initi_ LCD-> var. xres = 800; // initiation_ LCD-> var. yres = 272; cloud_ LCD-> var. yres = 480; // cloud_ LCD-> var. xres_virtual = 4 80; cloud_ LCD-> var. xres_virtual = 800; // initiation_ LCD-> var. yres_virtual = 272; cloud_ LCD-> var. yres_virtual = 480; // initiation_ LCD-> var. bits_per_pixel = 32; initi_ LCD-> var. bits_per_pixel = 32;/* RGB: 565 */initi_ LCD-> var. red. offset = 16; initi_ LCD-> var. red. length = 8; initi_ LCD-> var. green. offset = 8; initi_ LCD-> var. green. length = 8; initi_ LCD-> var. blue. offset = 0; initi_ LCD-> var. blue. length = 8; initi_ LCD-> var. activate = fb_activate_now ;/* 2.3 set the operation function */initi_ LCD-> fbops = & unc_fb_ops;/* 2.4 Other settings */cloud_ LCD-> pseudo do_palette = pseudo do_palette; // choose> screen_base =; /* the virtual address of the video memory * // initi_ LCD-> screen_size = 480*272*32/8; initi_ LCD-> screen_size = 800*480*32/8;/* 3. hardware-related operations * // * 3.1 configure gpio for LCD */gpbcon = ioremap (0x56000010, 8); gpbdat = gpbcon + 1; gpccon = ioremap (0x56000020, 4); gpdcon = ioremap (0x56000030, 4); gpgcon = ioremap (0x56000060, 4 ); * Gpccon = 0 xaaaaaaaa;/* gpio pins are used for VD [], lcdvf [], Vm, vframe, vline, vclk, lend */* gpdcon = 0 xaaaaaaaaaa; /* gpio pin for VD [] * // * gpbcon & = ~ (3);/* gpb0 is set to the output pin * // * gpbcon | = 1; // * gpbdat & = ~ 1;/* output low level */* gpgcon | = (3 <8);/* gpg4 is used as the LCD _pwren * // * 3.2 set the LCD controller according to the LCD manual, for example, the vclk frequency */LCD _regs = ioremap (0x4d000000, sizeof (struct LCD _regs )); /** tq2440 4.3 inch LCD wxcat43-tg60000000000v1.0.pdf 22nd, 23 pages ** LCD manual and 2440 manual "Figure 15-6. tft LCD timing example "one-to-one ratio will know the parameter meanings * // * bit []: vclk = hclk/[(clkval + 1) x 2], LCD manual P22 (DCLK = 9 MHz ~ 15 MHz) * 10 MHz (100ns) = 100 MHz/[(clkval + 1) x 2] * clkval = 4 * bit []: 0b11, tft LCD * bit []: 0b1101, 24 BPP for TFT * bit [0]: 0 = Disable the video output and the LCD control signal. * // LCD _regs-> lcdcon1 = (4 <8) | (3 <5) | (0x0c <1 ); // For the parameter settings in the tq2440 7.0-inch LCD manual, LCD _regs-> lcdcon1 = (2 <8) | (3 <5) | (0x0d <1 ); // set the tq2440 7.0 LCD program. the two settings can be used. /* vertical time parameter * bit [31: 24]: vbpd. How long will it take after vsync? Issue 1st rows of Data * LCD manual TVB = 2 (29) * vbpd = 1 * bit []: How many rows, 272 (480 ), so lineval = 272-1 = 271 * bit []: vfpd. How long will it take to issue the vsync * LCD manual tvf = 2 (13) after the last line of data is sent ), therefore, vfpd = 2-1 = 1 * bit []: vspw, pulse width of the vsync signal, LCD manual TVP = 10 (3 ), therefore, vspw = 10-1 = 9 * // LCD _regs-> lcdcon2 = (28 <24) | (479 <14) | (12 <6) | (2 <0); // For the parameter settings of the tq2440 7.0-inch LCD manual, LCD _regs-> lcdcon2 = (4 <24) | (479 <14) | (2 <6) | (2 <0); // set the tq2440 7.0 inch LCD program. If you have any doubts Both settings can be used. /* time parameter in the horizontal direction * bit [25:19]: hbpd. How long will it take after vsync to issue 1st rows of Data * LCD manual THB = 2 (40 )) * hbpd = 1 * bit []: How many columns, 480, so hozval = 480-1 = 479 (480) * bit []: hfpd, how long will it take to issue hsync * LCD manual THF = 2 after the last pixel data in the last row is sent, so hfpd = 2-1 = 1 (40 )) * // LCD _regs-> lcdcon3 = (1 <19) | (479 <8) | (1 <0 ); // LCD _regs-> lcdcon3 = (39 <19) | (799 <8) | (39 <0 ); // LCD _regs-> lcdcon3 = (27 <19) | (7.0 <8) | (14 <0); // tq2440 7.0-inch LCD program settings. If you have doubts, these two settings can be used. /* horizontal synchronous signal * bit []: the pulse width of the hsync signal, THP of the LCD manual = 41, so the heat map = 41-1 = 40 (48 )) * // LCD _regs-> lcdcon4 = 40; // LCD _regs-> lcdcon4 = 8 for parameters in the tq2440 7.0-inch LCD manual; // tq2440 7.0-inch LCD program settings. If you have doubts, both settings can be used. /* polarity of the signal * bit [11]: 1 = 565 format. For 24bpp, do not set * bit [10]: 0 = the video data is fetched at vclk falling edge * bit [9]: 1 = The hsync signal needs to be reversed, that is, the low level is valid * bit [8]: 1 = The vsync signal needs to be reversed Turn, that is, low-level valid * bit [6]: 0 = vden do not need to reverse * bit [3]: 0 = pwren output 0 ** bswp = 0, hwswp = 0, bpp24bl = 0: When bpp = 24, 2440 will allocate 32-bit (4-byte) to each pixel. Which byte is not used? See the 2440 manual p412 * bit [12]: 0, LSB valid, that is, the maximum byte does not use * bit [1]: 0 = bswp * bit [0]: 0 = hwswp */LCD _regs-> lcdcon5 = (0 <10) | (1 <9) | (1 <8) | (0 <12) | (0 <1) | (0 <0);/* 3.3 allocate a video memory (framebuffer ), then, the address is sent to the LCD controller */cloud_ LCD-> screen_base = dma_alloc_writecombine (null, cloud_ LCD-> fix. smem_len, & cloud_ LCD-> fix. smem_start, gfp_kernel); LCD _regs-> lcdsaddr1 = (initi_ LCD-> fix. smem_start> 1 )&~ (3 <30); LCD _regs-> lcdsaddr2 = (initi_ LCD-> fix. smem_start + cloud_ LCD-> fix. smem_len)> 1) & 0x1fffff; // LCD _regs-> lcdsaddr3 = (480*32/16);/* the length of a row (unit: 2 bytes) */LCD _regs-> lcdsaddr3 = (800*32/16);/* the length of a row (unit: 2 bytes) * // initi_ LCD-> fix. smem_start = xxx;/* physical address of the video memory * // * Start the LCD */LCD _regs-> lcdcon1 | = (1 <0 ); /* enable LCD controller */LCD _regs-> lcdcon5 | = (1 <3);/* enable LCD itself: LCD _pwren * // * gpbdat | = 1; /* output high level, enabling backlight, tq244 The 0 backlight circuit is also controlled by LCD _pwren * // * 4. register */register_framebuffer (cloud_ LCD); Return 0;} static void LCD _exit (void) {unregister_framebuffer (cloud_ LCD); LCD _regs-> lcdcon1 & = ~ (1 <0);/* Turn off the LCD controller */LCD _regs-> lcdcon1 & = ~ (1 <3);/* close the LCD itself * // * gpbdat & = ~ 1;/* Turn off the backlight */dma_free_writecombine (null, initi_ LCD-> fix. smem_len, cloud_ LCD-> screen_base, cloud_ LCD-> fix. smem_start); iounmap (LCD _regs); iounmap (gpbcon); iounmap (gpccon); iounmap (gpdcon); iounmap ); module_exit (LCD _exit); module_license ("GPL ");