📄 sa1100fb.c
字号:
*dvar = *var; dvar->activate &= ~FB_ACTIVATE_ALL; /* * 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; sa1100fb_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 sa1100fb_info *fbi = (struct sa1100fb_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, sa1100fb_setcolreg, info); if (!err) fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1); return err;}static intsa1100fb_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 || disp->visual == FB_VISUAL_STATIC_PSEUDOCOLOR) return -EINVAL; return __do_set_cmap(cmap, kspc, con, info);}static intsa1100fb_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 intsa1100fb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info){ *var = *get_con_var(info, con); return 0;}static intsa1100fb_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 sa1100fb_ops = { owner: THIS_MODULE, fb_get_fix: sa1100fb_get_fix, fb_get_var: sa1100fb_get_var, fb_set_var: sa1100fb_set_var, fb_get_cmap: sa1100fb_get_cmap, fb_set_cmap: sa1100fb_set_cmap,};/* * sa1100fb_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 sa1100fb_switch(int con, struct fb_info *info){ struct sa1100fb_info *fbi = (struct sa1100fb_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; sa1100fb_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. *//* * sa1100fb_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 sa1100fb_blank(int blank, struct fb_info *info){ struct sa1100fb_info *fbi = (struct sa1100fb_info *)info; int i; DPRINTK("sa1100fb_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++) sa1100fb_setpalettereg(i, 0, 0, 0, 0, info); sa1100fb_schedule_task(fbi, C_DISABLE); if (sa1100fb_blank_helper) sa1100fb_blank_helper(blank); break; case VESA_NO_BLANKING: if (sa1100fb_blank_helper) sa1100fb_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, sa1100fb_setcolreg, info); sa1100fb_schedule_task(fbi, C_ENABLE); }}static int sa1100fb_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 = cpufreq_get(0) / 100; pcd *= pixclock; pcd /= 10000000; pcd += 1; /* make up for integer math truncations */ } else { /* * People seem to be missing this message. Make it big. * Make it stand out. Make sure people see it. */ printk(KERN_WARNING "******************************************************\n"); printk(KERN_WARNING "** ZERO PIXEL CLOCK DETECTED **\n"); printk(KERN_WARNING "** You are using a zero pixclock. This means that **\n"); printk(KERN_WARNING "** clock scaling will not be able to adjust your **\n"); printk(KERN_WARNING "** your timing parameters appropriately, and the **\n"); printk(KERN_WARNING "** bandwidth calculations will fail to work. This **\n"); printk(KERN_WARNING "** will shortly become an error condition, which **\n"); printk(KERN_WARNING "** will prevent your LCD display working. Please **\n"); printk(KERN_WARNING "** send your patches in as soon as possible to shut **\n"); printk(KERN_WARNING "** this message up. **\n"); printk(KERN_WARNING "******************************************************\n"); pcd = 0; } return pcd;}/* * sa1100fb_activate_var(): * Configures LCD Controller based on entries in var parameter. Settings are * only written to the controller if changes were made. */static int sa1100fb_activate_var(struct fb_var_screeninfo *var, struct sa1100fb_info *fbi){ struct sa1100fb_lcd_reg new_regs; u_int half_screen_size, yres, pcd = get_pcd(var->pixclock); u_long flags; DPRINTK("Configuring SA1100 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 | LCCR0_LEN | LCCR0_LDM | LCCR0_BAM | LCCR0_ERM | LCCR0_LtlEnd | LCCR0_DMADel(0); new_regs.lccr1 = LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(var->hsync_len) + LCCR1_BegLnDel(var->left_margin) + LCCR1_EndLnDel(var->right_margin); /* * If we have a dual scan LCD, then we need to halve * the YRES parameter. */ yres = var->yres; if (fbi->lccr0 & LCCR0_Dual) yres /= 2; new_regs.lccr2 = LCCR2_DisHght(yres) + 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) | LCCR3_ACBsCntOff; 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); half_screen_size = var->bits_per_pixel; half_screen_size = half_screen_size * var->xres * var->yres / 16; /* Update shadow copy atomically */ local_irq_save(flags); fbi->dbar1 = fbi->palette_dma; fbi->dbar2 = fbi->screen_dma + half_screen_size; fbi->reg_lccr0 = new_regs.lccr0; fbi->reg_lccr1 = new_regs.lccr1; fbi->reg_lccr2 = new_regs.lccr2; fbi->reg_lccr3 = new_regs.lccr3; 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) || (DBAR1 != fbi->dbar1) || (DBAR2 != fbi->dbar2)) sa1100fb_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 sa1100fb_power_up_lcd() * Also, I'm expecting that the backlight stuff should * be handled differently. */static void sa1100fb_backlight_on(struct sa1100fb_info *fbi){ DPRINTK("backlight on\n");#ifdef CONFIG_SA1100_FREEBIRD#error FIXME if (machine_is_freebird()) { BCR_set(BCR_FREEBIRD_LCD_PWR | BCR_FREEBIRD_LCD_DISP); }#endif#ifdef CONFIG_SA1100_FREEBIRD if (machine_is_freebird()) { /* Turn on backlight ,Chester */ BCR_set(BCR_FREEBIRD_LCD_BACKLIGHT); }#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL#error FIXME if (machine_is_huw_webpanel()) { BCR_set(BCR_CCFL_POW + BCR_PWM_BACKLIGHT); set_current_state(TASK_UNINTERRUPTIBLE); schedule_task(200 * HZ / 1000); BCR_set(BCR_TFT_ENA); }#endif#ifdef CONFIG_SA1100_OMNIMETER if (machine_is_omnimeter()) LEDBacklightOn();#endif#ifdef CONFIG_SA1100_FRODO if (machine_is_frodo()) FRODO_CPLD_GENERAL |= FRODO_LCD_BACKLIGHT;#endif}/* * FIXME: move LCD power stuf into sa1100fb_power_down_lcd() * Also, I'm expecting that the backlight stuff should * be handled differently. */static void sa1100fb_backlight_off(struct sa1100fb_info *fbi){ DPRINTK("backlight off\n");#ifdef CONFIG_SA1100_FREEBIRD#error FIXME if (machine_is_freebird()) { BCR_clear(BCR_FREEBIRD_LCD_PWR | BCR_FREEBIRD_LCD_DISP /*| BCR_FREEBIRD_LCD_BACKLIGHT */ ); }#endif#ifdef CONFIG_SA1100_OMNIMETER if (machine_is_omnimeter()) LEDBacklightOff();#endif#ifdef CONFIG_SA1100_FRODO if (machine_is_frodo()) FRODO_CPLD_GENERAL &= ~FRODO_LCD_BACKLIGHT;#endif}static void sa1100fb_power_up_lcd(struct sa1100fb_info *fbi){ DPRINTK("LCD power on\n");#ifndef ASSABET_PAL_VIDEO if (machine_is_assabet()) ASSABET_BCR_set(ASSABET_BCR_LCD_ON);#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL if (machine_is_huw_webpanel()) BCR_clear(BCR_TFT_NPWR);#endif#ifdef CONFIG_SA1100_OMNIMETER if (machine_is_omnimeter()) LCDPowerOn();#endif if (machine_is_h3xxx()) set_h3600_egpio( IPAQ_EGPIO_LCD_ON ); /* Turn on power to the LCD */#ifdef CONFIG_SA1100_STORK if (machine_is_stork()) { storkSetLCDCPLD(0, 1); storkSetLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON); }#endif#ifdef CONFIG_SA1100_FRODO if (machine_is_frodo()) sa1100fb_backlight_on(fbi);#endif}static void sa1100fb_power_down_lcd(struct sa1100fb_info *fbi){ DPRINTK("LCD power off\n");#ifndef ASSABET_PAL_VIDEO if (machine_is_assabet()) ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL // dont forget to set the control lines to zero (?) if (machine_is_huw_webpanel()) BCR_set(BCR_TFT_NPWR);#endif if (machine_is_h3xxx()) clr_h3600_egpio( IPAQ_EGPIO_LCD_ON );#ifdef CONFIG_SA1100_STORK if (machine_is_stork()) { storkSetLCDCPLD(0, 0); storkClearLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON); }#endif#ifdef CONFIG_SA1100_FRODO if (machine_is_frodo()) sa1100fb_backlight_off(fbi);#endif}static void sa1100fb_setup_gpio(struct sa1100fb_info *fbi){ u_int mask = 0; /* * Enable GPIO<9:2> for LCD use if: * 1. Active display, or * 2. Color Dual Passive display * * see table 11.8 on page 11-27 in the SA1100 manual * -- Erik. * * SA1110 spec update nr. 25 says we can and should * clear LDD15 to 12 for 4 or 8bpp modes with active * panels. */ if ((fbi->reg_lccr0 & LCCR0_CMS) == LCCR0_Color && (fbi->reg_lccr0 & (LCCR0_Dual|LCCR0_Act)) != 0) { mask = GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9 | GPIO_LDD8; if (fbi->fb.var.bits_per_pixel > 8 || (fbi->reg_lccr0 & (LCCR0_Dual|LCCR0_Act)) == LCCR0_Dual) mask |= GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12; }#ifdef CONFIG_SA1100_FREEBIRD#error Please contact <rmk@arm.linux.org.uk> about this if (machine_is_freebird()) { /* Color single passive */ mask |= GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 | GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9 | GPIO_LDD8; }#endif if (machine_is_cerf()) { /* GPIO15 is used as a bypass for 3.8" displays */ mask |= GPIO_GPIO15;#ifdef CONFIG_SA1100_CERF#warning Read Me Now!#endif#if 0 /* if this causes you problems, mail <rmk@arm.linux.org.uk> please. */ /* * This was enabled for the 72_A version only, which is a _color_ * _dual_ LCD. Now look at the generic test above, and calculate
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -