📄 xxxfb.c
字号:
#include <linux/config.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/interrupt.h>#include <linux/slab.h>#include <linux/fb.h>#include <linux/delay.h>#include <linux/pm.h>#include <linux/init.h>#include <asm/hardware.h>#include <asm/io.h>#include <asm/irq.h>#include <asm/mach-types.h>#include <asm/uaccess.h>#include <video/fbcon.h>#include <video/fbcon-mfb.h>#include <video/fbcon-cfb4.h>#include <video/fbcon-cfb8.h>#include <video/fbcon-cfb16.h>#include "xxxfb.h"void (*xxxfb_blank_helper) (int blank);EXPORT_SYMBOL (xxxfb_blank_helper);static struct xxxfb_rgb rgb_8 = { red: {offset: 0, length:4,}, green: {offset: 0, length:4,}, blue: {offset: 0, length:4,}, transp: {offset: 0, length:0,},};static struct xxxfb_rgb def_rgb_16 = { red: {offset: 11, length:5,}, green: {offset: 5, length:6,}, blue: {offset: 0, length:5,}, transp: {offset: 0, length:0,},};static struct xxxfb_rgb xxx_tft_rgb_16 = { red: {offset: 11, length:5,}, green: {offset: 5, length:6,}, blue: {offset: 0, length:5,}, transp: {offset: 0, length:0,},};static struct xxxfb_mach_info xxx_stn_info __initdata = { pixclock: 174757, bpp:16, xres:240, yres:320, hsync_len: 5, vsync_len:1, left_margin: 7, upper_margin:1, right_margin: 3, lower_margin:3, sync: 0, cmap_static:1, reg:{ lcdcon1:LCD1_BPP_16T | LCD1_PNR_TFT | LCD1_CLKVAL (7), lcdcon2:LCD2_VBPD (1) | LCD2_VFPD (2) | LCD2_VSPW (1), lcdcon3:LCD3_HBPD (6) | LCD3_HFPD (2), lcdcon4:LCD4_HSPW (4) | LCD4_MVAL (13), lcdcon5:LCD5_FRM565 | LCD5_INVVLINE | LCD5_INVVFRAME | LCD5_HWSWP | LCD5_PWREN, },};static inline u_intchan_to_field (u_int chan, struct fb_bitfield *bf){ chan &= 0xffff; chan >>= 16 - bf->length; return chan << bf->offset;}/* * Convert bits-per-pixel to a hardware palette PBS value. */static inline u_intpalette_pbs (struct fb_var_screeninfo *var){ int ret = 0; switch (var->bits_per_pixel) {#ifdef FBCON_HAS_CFB4 case 4: ret = 0 << 12; break;#endif#ifdef FBCON_HAS_CFB8 case 8: ret = 1 << 12; break;#endif#ifdef FBCON_HAS_CFB16 case 16: ret = 2 << 12; break;#endif } return ret;}static struct xxxfb_mach_info *__initxxxfb_get_machine_info (struct xxxfb_info *fbi){ struct xxxfb_mach_info *inf = NULL; inf = &xxx_stn_info; fbi->reg = inf->reg; fbi->rgb[RGB_16] = &xxx_tft_rgb_16; return inf;}static inline struct fb_var_screeninfo *get_con_var (struct fb_info *info, int con){ struct xxxfb_info *fbi = (struct xxxfb_info *) info; return (con == fbi->currcon || con == -1) ? &fbi->fb.var : &fb_display[con].var;}static inline struct fb_cmap *get_con_cmap (struct fb_info *info, int con){ struct xxxfb_info *fbi = (struct xxxfb_info *) info; return (con == fbi->currcon || con == -1) ? &fbi->fb.cmap : &fb_display[con].cmap;}static inline struct display *get_con_display (struct fb_info *info, int con){ struct xxxfb_info *fbi = (struct xxxfb_info *) info; return (con < 0) ? (fbi->fb.disp) : &(fb_display[con]);}static intxxxfb_validate_var (struct fb_var_screeninfo *var, struct xxxfb_info *fbi){ int ret = -EINVAL; if (var->xres < MIN_XRES) var->xres = MIN_XRES; if (var->yres < MIN_YRES) var->yres = MIN_YRES; if (var->xres > fbi->max_xres) var->xres = fbi->max_xres; if (var->yres > fbi->max_yres) var->yres = fbi->max_yres; var->xres_virtual = var->xres_virtual < var->xres ? var->xres : var->xres_virtual; var->yres_virtual = var->yres_virtual < var->yres ? var->yres : var->yres_virtual; switch (var->bits_per_pixel) {#ifdef FBCON_HAS_CFB4 case 4: ret = 0; break;#endif#ifdef FBCON_HAS_CFB8 case 8: ret = 0; break;#endif#ifdef FBCON_HAS_CFB16 case 16: ret = 0; break;#endif default: break; } return ret;}static intxxxfb_setpalettereg (u_int regno, u_int red, u_int green, u_int blue, u_int trans, struct fb_info *info){ struct xxxfb_info *fbi = (struct xxxfb_info *) info; u_int val, ret = 1; if (regno < fbi->palette_size) {#ifndef CONFIG_S3C2400_GAMEPARK val = ((red >> 4) & 0xf00); val |= ((green >> 8) & 0x0f0); val |= ((blue >> 12) & 0x00f);#else val = ((blue >> 16) & 0x001f); val |= ((green >> 11) & 0x07e0); val |= ((red >> 5) & 0x0f800); val |= 1; /* intensity bit */#endif if (regno == 0) val |= palette_pbs (&fbi->fb.var); fbi->palette_cpu[regno] = val; ret = 0; } return ret;}static intxxxfb_setcolreg (u_int regno, u_int red, u_int green, u_int blue, u_int trans, struct fb_info *info){ struct xxxfb_info *fbi = (struct xxxfb_info *) info; struct display *disp = get_con_display (info, fbi->currcon); u_int var; int ret = 1; if (disp->inverse) { red = 0xffff - red; green = 0xffff - green; blue = 0xffff - blue; } if (fbi->fb.var.grayscale) red = green = blue = (19595 * red + 38470 * green + 7471 * blue) >> 16; switch (fbi->fb.disp->visual) { case FB_VISUAL_TRUECOLOR: if (regno < 16) { u16 *pal = fbi->fb.pseudo_palette; var = chan_to_field (red, &fbi->fb.var.red); var |= chan_to_field (green, &fbi->fb.var.green); var |= chan_to_field (blue, &fbi->fb.var.blue); pal[regno] = var; ret = 0; } break; case FB_VISUAL_STATIC_PSEUDOCOLOR: case FB_VISUAL_PSEUDOCOLOR: ret = xxxfb_setpalettereg (regno, red, green, blue, trans, info); break; } return ret;}static intxxxfb_activate_var (struct fb_var_screeninfo *var, struct xxxfb_info *fbi){ struct xxxfb_lcd_reg new_regs; u_int half_screen_size, yres; u_long flags; return 0;}static inline voidxxxfb_set_truecolor (u_int is_true_color){ if (is_true_color) { } else { }}static voidxxxfb_hw_set_var (struct fb_var_screeninfo *var, struct xxxfb_info *fbi){ u_long palette_mem_size; fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16; palette_mem_size = fbi->palette_size * sizeof (u16); fbi->palette_cpu = (u16 *) (fbi->map_cpu + PAGE_SIZE - palette_mem_size); fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size; fb_set_cmap (&fbi->fb.cmap, 1, xxxfb_setcolreg, &fbi->fb); xxxfb_set_truecolor (var->bits_per_pixel >= 16); xxxfb_activate_var (var, fbi); fbi->palette_cpu[0] = (fbi->palette_cpu[0] & 0xcfff) | palette_pbs (var);}static intxxxfb_set_var (struct fb_var_screeninfo *var, int con, struct fb_info *info){ struct xxxfb_info *fbi = (struct xxxfb_info *) info; struct fb_var_screeninfo *dvar = get_con_var (&fbi->fb, con); struct display *display = get_con_display (&fbi->fb, con); int err, chgvar = 0, rgbidx; err = xxxfb_validate_var (var, fbi); if (err) return err; if (var->activate & FB_ACTIVATE_TEST) return 0; if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) return -EINVAL; if (dvar->xres != var->xres) chgvar = 1; if (dvar->yres != var->yres) chgvar = 1; if (dvar->xres_virtual != var->xres_virtual) chgvar = 1; if (dvar->yres_virtual != var->yres_virtual) chgvar = 1; if (dvar->bits_per_pixel != var->bits_per_pixel) chgvar = 1; if (con < 0) chgvar = 0; switch (var->bits_per_pixel) {#ifdef FBCON_HAS_CFB4 case 4: if (fbi->cmap_static) display->visual = FB_VISUAL_STATIC_PSEUDOCOLOR; else display->visual = FB_VISUAL_PSEUDOCOLOR; display->line_length = var->xres / 2; display->dispsw = &fbcon_cfb4; rgbidx = RGB_8; break;#endif#ifdef FBCON_HAS_CFB8 case 8: if (fbi->cmap_static) display->visual = FB_VISUAL_STATIC_PSEUDOCOLOR; else display->visual = FB_VISUAL_PSEUDOCOLOR; display->line_length = var->xres; display->dispsw = &fbcon_cfb8;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -