📄 pxafb.c
字号:
/* * Copy the RGB parameters for this display * from the machine specific parameters. */ dvar->red = fbi->rgb[rgbidx]->red; dvar->green = fbi->rgb[rgbidx]->green; dvar->blue = fbi->rgb[rgbidx]->blue; dvar->transp = fbi->rgb[rgbidx]->transp; DPRINTK("RGBT length = %d:%d:%d:%d\n", dvar->red.length, dvar->green.length, dvar->blue.length, dvar->transp.length); DPRINTK("RGBT offset = %d:%d:%d:%d\n", dvar->red.offset, dvar->green.offset, dvar->blue.offset, dvar->transp.offset); /* * Update the old var. The fbcon drivers still use this. * Once they are using fbi->fb.var, this can be dropped. */ display->var = *dvar; /* * If we are setting all the virtual consoles, also set the * defaults used to create new consoles. */ if (var->activate & FB_ACTIVATE_ALL) fbi->fb.disp->var = *dvar; /* * If the console has changed and the console has defined * a changevar function, call that function. */ if (chgvar && info && fbi->fb.changevar) fbi->fb.changevar(con); /* If the current console is selected, activate the new var. */ if (con != fbi->currcon) return 0; pxafb_hw_set_var(dvar, fbi); return 0;}static int__do_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ struct pxafb_info *fbi = (struct pxafb_info *)info; struct fb_cmap *dcmap = get_con_cmap(info, con); int err = 0; if (con == -1) con = fbi->currcon; /* no colormap allocated? (we always have "this" colour map allocated) */ if (con >= 0) err = fb_alloc_cmap(&fb_display[con].cmap, fbi->palette_size, 0); if (!err && con == fbi->currcon) err = fb_set_cmap(cmap, kspc, pxafb_setcolreg, info); if (!err) fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1); return err;}static intpxafb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ struct display *disp = get_con_display(info, con); if (disp->visual == FB_VISUAL_TRUECOLOR) return -EINVAL; return __do_set_cmap(cmap, kspc, con, info);}static intpxafb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info){ struct display *display = get_con_display(info, con); *fix = info->fix; fix->line_length = display->line_length; fix->visual = display->visual; return 0;}static intpxafb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info){ *var = *get_con_var(info, con); return 0;}static intpxafb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ struct fb_cmap *dcmap = get_con_cmap(info, con); fb_copy_cmap(dcmap, cmap, kspc ? 0 : 2); return 0;}static struct fb_ops pxafb_ops = { owner: THIS_MODULE, fb_get_fix: pxafb_get_fix, fb_get_var: pxafb_get_var, fb_set_var: pxafb_set_var, fb_get_cmap: pxafb_get_cmap, fb_set_cmap: pxafb_set_cmap,};/* * pxafb_switch(): * Change to the specified console. Palette and video mode * are changed to the console's stored parameters. * * Uh oh, this can be called from a tasklet (IRQ) */static int pxafb_switch(int con, struct fb_info *info){ struct pxafb_info *fbi = (struct pxafb_info *)info; struct display *disp; struct fb_cmap *cmap; DPRINTK("con=%d info->modename=%s\n", con, fbi->fb.modename); if (con == fbi->currcon) return 0; if (fbi->currcon >= 0) { disp = fb_display + fbi->currcon; /* * Save the old colormap and video mode. */ disp->var = fbi->fb.var; if (disp->cmap.len) fb_copy_cmap(&fbi->fb.cmap, &disp->cmap, 0); } fbi->currcon = con; disp = fb_display + con; /* * Make sure that our colourmap contains 256 entries. */ fb_alloc_cmap(&fbi->fb.cmap, 256, 0); if (disp->cmap.len) cmap = &disp->cmap; else cmap = fb_default_cmap(1 << disp->var.bits_per_pixel); fb_copy_cmap(cmap, &fbi->fb.cmap, 0); fbi->fb.var = disp->var; fbi->fb.var.activate = FB_ACTIVATE_NOW; pxafb_set_var(&fbi->fb.var, con, info); return 0;}/* * Formal definition of the VESA spec: * On * This refers to the state of the display when it is in full operation * Stand-By * This defines an optional operating state of minimal power reduction with * the shortest recovery time * Suspend * This refers to a level of power management in which substantial power * reduction is achieved by the display. The display can have a longer * recovery time from this state than from the Stand-by state * Off * This indicates that the display is consuming the lowest level of power * and is non-operational. Recovery from this state may optionally require * the user to manually power on the monitor * * Now, the fbdev driver adds an additional state, (blank), where they * turn off the video (maybe by colormap tricks), but don't mess with the * video itself: think of it semantically between on and Stand-By. * * So here's what we should do in our fbdev blank routine: * * VESA_NO_BLANKING (mode 0) Video on, front/back light on * VESA_VSYNC_SUSPEND (mode 1) Video on, front/back light off * VESA_HSYNC_SUSPEND (mode 2) Video on, front/back light off * VESA_POWERDOWN (mode 3) Video off, front/back light off * * This will match the matrox implementation. *//* * pxafb_blank(): * Blank the display by setting all palette values to zero. Note, the * 12 and 16 bpp modes don't really use the palette, so this will not * blank the display in all modes. */static void pxafb_blank(int blank, struct fb_info *info){ struct pxafb_info *fbi = (struct pxafb_info *)info; int i; DPRINTK("pxafb_blank: blank=%d info->modename=%s\n", blank, fbi->fb.modename); switch (blank) { case VESA_POWERDOWN: case VESA_VSYNC_SUSPEND: case VESA_HSYNC_SUSPEND: if (fbi->fb.disp->visual == FB_VISUAL_PSEUDOCOLOR || fbi->fb.disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR) for (i = 0; i < fbi->palette_size; i++) pxafb_setpalettereg(i, 0, 0, 0, 0, info); pxafb_schedule_task(fbi, C_DISABLE); if (pxafb_blank_helper) pxafb_blank_helper(blank); break; case VESA_NO_BLANKING: if (pxafb_blank_helper) pxafb_blank_helper(blank); if (fbi->fb.disp->visual == FB_VISUAL_PSEUDOCOLOR || fbi->fb.disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR) fb_set_cmap(&fbi->fb.cmap, 1, pxafb_setcolreg, info); pxafb_schedule_task(fbi, C_ENABLE); }}static int pxafb_updatevar(int con, struct fb_info *info){ DPRINTK("entered\n"); return 0;}/* * Calculate the PCD value from the clock rate (in picoseconds). * We take account of the PPCR clock setting. */static inline int get_pcd(unsigned int pixclock){ unsigned int pcd; if (pixclock) { pcd = get_lclk_frequency_10khz() * pixclock; pcd /= 100000000; pcd += 1; /* make up for integer math truncations */ } else { printk(KERN_WARNING "Please convert me to use the PCD calculations\n"); pcd = 0; } return pcd;}/* * pxafb_activate_var(): * Configures LCD Controller based on entries in var parameter. Settings are * only written to the controller if changes were made. */static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *fbi){ struct pxafb_lcd_reg new_regs;// u_int pcd = get_pcd(var->pixclock); u_long flags; DPRINTK("Configuring PXA LCD\n"); DPRINTK("var: xres=%d hslen=%d lm=%d rm=%d\n", var->xres, var->hsync_len, var->left_margin, var->right_margin); DPRINTK("var: yres=%d vslen=%d um=%d bm=%d\n", var->yres, var->vsync_len, var->upper_margin, var->lower_margin);#if DEBUG_VAR if (var->xres < 16 || var->xres > 1024) printk(KERN_ERR "%s: invalid xres %d\n", fbi->fb.fix.id, var->xres); if (var->hsync_len < 1 || var->hsync_len > 64) printk(KERN_ERR "%s: invalid hsync_len %d\n", fbi->fb.fix.id, var->hsync_len); if (var->left_margin < 1 || var->left_margin > 255) printk(KERN_ERR "%s: invalid left_margin %d\n", fbi->fb.fix.id, var->left_margin); if (var->right_margin < 1 || var->right_margin > 255) printk(KERN_ERR "%s: invalid right_margin %d\n", fbi->fb.fix.id, var->right_margin); if (var->yres < 1 || var->yres > 1024) printk(KERN_ERR "%s: invalid yres %d\n", fbi->fb.fix.id, var->yres); if (var->vsync_len < 1 || var->vsync_len > 64) printk(KERN_ERR "%s: invalid vsync_len %d\n", fbi->fb.fix.id, var->vsync_len); if (var->upper_margin < 0 || var->upper_margin > 255) printk(KERN_ERR "%s: invalid upper_margin %d\n", fbi->fb.fix.id, var->upper_margin); if (var->lower_margin < 0 || var->lower_margin > 255) printk(KERN_ERR "%s: invalid lower_margin %d\n", fbi->fb.fix.id, var->lower_margin);#endif new_regs.lccr0 = fbi->lccr0; new_regs.lccr1 = LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(var->hsync_len) + LCCR1_BegLnDel(var->left_margin) + LCCR1_EndLnDel(var->right_margin); new_regs.lccr2 = LCCR2_DisHght((fbi->lccr0 & LCCR0_SDS) ? var->yres/2 : var->yres) + /* edited by zjx */ LCCR2_VrtSnchWdth(var->vsync_len) + LCCR2_BegFrmDel(var->upper_margin) + LCCR2_EndFrmDel(var->lower_margin); new_regs.lccr3 = fbi->lccr3 | (var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) | (var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL);// if (pcd)// new_regs.lccr3 |= LCCR3_PixClkDiv(pcd); DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0); DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1); DPRINTK("nlccr2 = 0x%08x\n", new_regs.lccr2); DPRINTK("nlccr3 = 0x%08x\n", new_regs.lccr3); /* Update shadow copy atomically */ local_irq_save(flags); /* setup dma descriptors */ fbi->dmadesc_fblow_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 3*16); fbi->dmadesc_fbhigh_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 2*16); fbi->dmadesc_palette_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 1*16); fbi->dmadesc_fblow_dma = fbi->palette_dma - 3*16; fbi->dmadesc_fbhigh_dma = fbi->palette_dma - 2*16; fbi->dmadesc_palette_dma = fbi->palette_dma - 1*16; #define BYTES_PER_PANEL ((fbi->lccr0 & LCCR0_SDS) ? (var->xres * var->yres * var->bits_per_pixel / 8 / 2) : \ (var->xres * var->yres * var->bits_per_pixel / 8)) /* populate descriptors */ fbi->dmadesc_fblow_cpu->fdadr = fbi->dmadesc_fblow_dma; fbi->dmadesc_fblow_cpu->fsadr = fbi->screen_dma + BYTES_PER_PANEL; fbi->dmadesc_fblow_cpu->fidr = 0; fbi->dmadesc_fblow_cpu->ldcmd = BYTES_PER_PANEL; fbi->fdadr1 = fbi->dmadesc_fblow_dma; /* only used in dual-panel mode */ fbi->dmadesc_fbhigh_cpu->fsadr = fbi->screen_dma; fbi->dmadesc_fbhigh_cpu->fidr = 0; fbi->dmadesc_fbhigh_cpu->ldcmd = BYTES_PER_PANEL; fbi->dmadesc_palette_cpu->fsadr = fbi->palette_dma; fbi->dmadesc_palette_cpu->fidr = 0; fbi->dmadesc_palette_cpu->ldcmd = (fbi->palette_size * 2) | LDCMD_PAL; if( var->bits_per_pixel < 12) { /* assume any mode with <12 bpp is palette driven */ fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_fbhigh_dma; fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_palette_dma; fbi->fdadr0 = fbi->dmadesc_palette_dma; /* flips back and forth between pal and fbhigh */ } else { /* palette shouldn't be loaded in true-color mode */ fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_fbhigh_dma; fbi->fdadr0 = fbi->dmadesc_fbhigh_dma; /* no pal just fbhigh */ } DPRINTK("fbi->dmadesc_fblow_cpu = 0x%x\n", fbi->dmadesc_fblow_cpu); DPRINTK("fbi->dmadesc_fbhigh_cpu = 0x%x\n", fbi->dmadesc_fbhigh_cpu); DPRINTK("fbi->dmadesc_palette_cpu = 0x%x\n", fbi->dmadesc_palette_cpu); DPRINTK("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma); DPRINTK("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma); DPRINTK("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma); DPRINTK("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr); DPRINTK("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr); DPRINTK("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr); DPRINTK("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr); DPRINTK("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr); DPRINTK("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr); DPRINTK("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd); DPRINTK("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd); DPRINTK("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd); fbi->reg_lccr0 = new_regs.lccr0; fbi->reg_lccr1 = new_regs.lccr1; fbi->reg_lccr2 = new_regs.lccr2; fbi->reg_lccr3 = new_regs.lccr3; fbi->reg_tmedrgbr = TMEDRGBR_RedSeed(0x00) | TMEDRGBR_GreenSeed(0x55) | TMEDRGBR_BlueSeed(0xAA); fbi->reg_tmedcr = TMEDCR_COAM | TMEDCR_FNAM | TMEDCR_COAE | TMEDCR_FNAME | TMEDCR_VBSuppression(0x04) | TMEDCR_HBSuppression(0x05) | (0x03 << 12) | TMEDCR_TED; /* add by zjx */ local_irq_restore(flags); /* * Only update the registers if the controller is enabled * and something has changed. */ if ((LCCR0 != fbi->reg_lccr0) || (LCCR1 != fbi->reg_lccr1) || (LCCR2 != fbi->reg_lccr2) || (LCCR3 != fbi->reg_lccr3) || (FDADR0 != fbi->fdadr0) || (FDADR1 != fbi->fdadr1)) pxafb_schedule_task(fbi, C_REENABLE); return 0;}/* * NOTE! The following functions are purely helpers for set_ctrlr_state. * Do not call them directly; set_ctrlr_state does the correct serialisation * to ensure that things happen in the right way 100% of time time. * -- rmk *//* * FIXME: move LCD power stuff into pxafb_power_up_lcd() * Also, I'm expecting that the backlight stuff should * be handled differently. */static void pxafb_backlight_on(struct pxafb_info *fbi){ DPRINTK("backlight on\n");#ifdef CONFIG_ARCH_PXA_IDP if(machine_is_pxa_idp()) { FB_BACKLIGHT_ON(); }#endif}/* * FIXME: move LCD power stuf into pxafb_power_down_lcd() * Also, I'm expecting that the backlight stuff should * be handled differently. */static void pxafb_backlight_off(struct pxafb_info *fbi){ DPRINTK("backlight off\n");#ifdef CONFIG_ARCH_PXA_IDP if(machine_is_pxa_idp()) { FB_BACKLIGHT_OFF(); }#endif }static void pxafb_power_up_lcd(struct pxafb_info *fbi){ DPRINTK("LCD power on\n"); CKEN |= CKEN16_LCD; if(machine_is_pxa_cerf()) { lcdctrl_enable(); }#if CONFIG_ARCH_PXA_IDP /* set GPIOs, etc */ if(machine_is_pxa_idp()) { // FIXME need to add proper delays FB_PWR_ON(); FB_VLCD_ON(); // FIXME this should be after scanning starts }#endif}static void pxafb_power_down_lcd(struct pxafb_info *fbi){ DPRINTK("LCD power off\n"); CKEN &= ~CKEN16_LCD; if(machine_is_pxa_cerf()) { lcdctrl_disable(); } /* set GPIOs, etc */#if CONFIG_ARCH_PXA_IDP if(machine_is_pxa_idp()) { // FIXME need to add proper delays FB_PWR_OFF(); FB_VLCD_OFF(); // FIXME this should be before scanning stops }#endif}static void pxafb_setup_gpio(struct pxafb_info *fbi){ unsigned int lccr0; /* * setup is based on type of panel supported */ lccr0 = fbi->lccr0; /* 4 bit interface */ if ((lccr0 & LCCR0_CMS) && (lccr0 & LCCR0_SDS) && !(lccr0 & LCCR0_DPD)) { // bits 58-61 GPDR1 |= (0xf << 26);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -