📄 sa1100fb.c
字号:
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 = get_cclk_frequency() * 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); sa1100fb_check_shadow(&new_regs, var, 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}/* * 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}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#ifdef CONFIG_SA1100_H3600 if (machine_is_h3600()) { set_h3600_egpio(EGPIO_H3600_LCD_ON | EGPIO_H3600_LCD_PCI | EGPIO_H3600_LCD_5V_ON | EGPIO_H3600_LVDD_ON); }#endif#ifdef CONFIG_SA1100_STORK if (machine_is_stork()) { storkSetLCDCPLD(0, 1); storkSetLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON); }#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#ifdef CONFIG_SA1100_H3600 if (machine_is_h3600()) { clr_h3600_egpio(EGPIO_H3600_LCD_ON | EGPIO_H3600_LCD_PCI | EGPIO_H3600_LCD_5V_ON | EGPIO_H3600_LVDD_ON); }#endif#ifdef CONFIG_SA1100_STORK if (machine_is_stork()) { storkSetLCDCPLD(0, 0); storkClearLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON); }#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 * the mask value for a colour dual display... * * I therefore conclude that the code below is redundant, and will * be killed at the start of November 2001. */ /* FIXME: why is this? The Cerf's display doesn't seem * to be dual scan or active. I just leave it here, * but in my opinion this is definitively wrong. * -- Erik <J.A.K.Mouw@its.tudelft.nl> */ /* REPLY: Umm.. Well to be honest, the 5.7" LCD which * this was used for does not use these pins, but * apparently all hell breaks loose if they are not * set on the Cerf, so we decided to leave them in ;) * -- Daniel Chemko <dchemko@intrinsyc.com> */ /* color {dual/single} passive */ mask |= GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 | GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9 | GPIO_LDD8;#endif } if (mask) { GPDR |= mask; GAFR |= mask; }}static void sa1100fb_enable_controller(struct sa1100fb_info *fbi){ DPRINTK("Enabling LCD controller\n"); /* * Make sure the mode bits are present in the first palette entry */ fbi->palette_cpu[0] &= 0xcfff; fbi->palette_cpu[0] |= palette_pbs(&fbi->fb.var); /* Sequence from 11.7.10 */ LCCR3 = fbi->reg_lccr3; LCCR2 = fbi->reg_lccr2; LCCR1 = fbi->reg_lccr1; LCCR0 = fbi->reg_lccr0 & ~LCCR0_LEN; DBAR1 = fbi->dbar1; DBAR2 = fbi->dbar2; LCCR0 |= LCCR0_LEN;#ifdef CONFIG_SA1100_GRAPHICSCLIENT#error Where is GPIO24 set as an output? Can we fit this in somewhere else? if (machine_is_graphicsclient()) { // From ADS doc again...same as disable set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(20 * HZ / 1000); GPSR |= GPIO_GPIO24; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -