[Conversion] LCD palette

Source: Internet
Author: User

For a display device, the data update rate is proportional to the product of the number of frames and the color depth. In an embedded Linux system, the CPU resource configuration and computing capability are restricted. When large resolution is used for display (for example, on some terminals with large screen sizes, usually 640 × 480 or more), to reduce the color depth of the display. Otherwise, image jitter and inconsistency may occur due to excessive data processing workload. In this case, the color palette technology will play an important role. The S3C2410 kernel is widely used in the embedded field in China. It has an LCD controller in the chip and supports LCD Display output with multiple resolutions and colors. Here, we will analyze the color palette Technology of S3C2410 and the implementation method of color palette display in the embedded Linux system.

 

1 S3C2410 palette technology Overview
1.1 concept of color palette
 
In computer image technology, the color of a pixel is represented by its R, G, and B components, and each component is quantified, the total quantization level of a pixel is the color depth of the display system. The higher the quantization level, the more colors it can represent, and the more realistic the final image will be. It is called true color when the quantization level is more than 16 bits. However, the higher the quantization level, the higher the data width, and the heavier the burden on the processor. When the quantization level is less than 8 bits, there are too few colors to express, cannot meet specific user needs.
To solve this problem, we can adopt the color palette technology. The so-called color palette is a linear table that establishes a ing between a limited pixel value and an RGB color in Low-color depth mode. For example, a certain number of colors are extracted from all 16-bit colors and indexed. When you need to use a certain color, you do not need to describe the RGB components of the color, you only need to reference its index number, you can select your desired color. The encoding length of the index number is much smaller than the encoding length of the RGB component. Therefore, the color display greatly reduces the burden on the system.
Take the 256 color palette as an example. The color palette stores the RGB values of 256 colors. The RGB values of each color are 16 bits. When indexing with the 256 colors ~ FFH only requires 8-bit data width, and the color corresponding to each index is the color information of 16-bit width. In some scenarios with low requirements on color types, such as instrument terminals and information terminals, the color palette technology cleverly solves the contradiction between data width and color depth.

1.2 color palette in S3C2410 
The S3C2410 chip of the arm9-core can be controlled by a built-in LCD controller. Taking tft LCD as an example, the LCD controller of S3C2410 chip can provide one-bit, two-bit, four-bit, eight-bit color display and 16-bit, 24-bit real color display for tft LCD, it also supports multiple screen sizes.
The color palette of S3C2410 is actually 256 16-bit storage units, each of which stores 16-bit color values. The color palette can also be set to (r: G: B) and 5: 5: 5: 1 (R: G: b: 1) Two formats. When the format is (r: G: B), its palette is shown in table 1.
 
In table 1, the first column is the color index, and the three middle columns are the data bits corresponding to the three color components R, G, and B, which are 5 bits, 6 bits, and 5 bits, respectively, the last column is the physical address of the corresponding color entries. When the format is 5: 5: 5: 1 (R: G: B: 1), the data bit lengths of the three color components R, G, and B are 5 bits, the bitwise is 1.
During User Programming, the color palette should be initialized first (which can be completed by the driver provided by the operating system), and the corresponding color value of the 256 color palette should be granted; during image programming, you can assign the image object the required color index value. When the program is running, the LCD controller of the chip looks for the color palette and outputs it according to the corresponding values. The output port VD [23: O] of the image data of the S3C2410 chip has 24 bits. When different color depths are used, these 24 bits can represent the color information of one or more vertices.

1. 3. Color Selection 
The selection of colors in the palette can be defined by the user at will, but for programming convenience, the selection of colors should follow certain rules. For example, in Windows programming, the system retains 20 colors. In addition, in Web programming, 216 Web security colors are also defined, which can be kept as much as possible. When the 2s3c2410 palette is used in an embedded Linux system to display images, the LCD controller transmits the video buffer content and various control signals in the storage system to the external LCD driver, then, the LCD Driver displays the image data. In practical applications, registers and color palette are usually configured by the operating system through the driver. Taking the Linux 2.4 kernel as an example, the color palette configuration is completed in the driver s3c2410fb. C.

 2.The color palette is not configured in the s3c2410fb. c file of the Linux source package of some companies. Therefore, the color palette is displayed below 8 bits. The LCD does not work properly. To use a color palette, you must modify this file.
2.1 driver Modification 
Check the S3C2410 Data Manual. The physical starting address of the color palette is 0x4d000400. Map the physical address of the color palette to the virtual address in the kernel and assign values to it. The procedure is as follows:

(1) Add:

# Define mypal (NB) _ reg (ox4d000400 + (NB) * 4)

It maps physical addresses to virtual addresses.

(2) In the s3c24lofb. h file, use the following statement to define the 256 colors.

Static const u_short my_color [256] = {0 x average, 0x8000 ,...} :

Each 16-bit binary number in the array represents a color. The RGB component uses the format.

(3) In the s3c2410fb. c file of the S3C2410fb-activate_var (...) In the function, assign values to the 256 color palette using the following statements.

(4) In addition, change the bppmode value of the LCD control register lcdcon1 to the desired color depth.

(5) recompile and burn the kernel.

2.2 write an application 
WhenS3C2410When used in an embedded Linux operating system, its graphics function is generally implemented by frame buffer. Each point on the screen is mapped to a linear memory space. You can change the color of the screen by changing the memory value through the application. When the color depth is greater than 16 bits, the user directly specifies the RGB weight of the color. When the color depth is less than 8 bits, the user should specify the index value of the color in the color palette.

When using embedded graphics systems such as MiniGUI, you only need to set the color value of the interface element to the index value of the desired color. For example:
Winelementcolors [I] = 142;
That is, set the color of winelementcolors [I] to the color palette with index 142.

[Conversion] LCD palette

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.