📄 ep93xxfb.c
字号:
} if (line->flags & LINE_PRECISE) { count = isqrt(((dy * dy) + (dx * dx)) * 4096); xinc = (4095 * 64 * dx) / count; yinc = (4095 * 64 * dy) / count; xval = 2048; yval = 2048; count = 0; while (dx || dy) { incr = 0; xval -= xinc; if (xval <= 0) { xval += 4096; dx--; incr = 1; } yval -= yinc; if (yval <= 0) { yval += 4096; dy--; incr = 1; } count += incr; } } else { if (dx == dy) { xinc = 4095; yinc = 4095; count = dx; } else if (dx < dy) { xinc = (dx * 4095) / dy; yinc = 4095; count = dy; } else { xinc = 4095; yinc = (dy * 4095) / dx; count = dx; } } outl(0x08000800, LINEINIT); if (line->flags & LINE_PATTERN) outl(line->pattern, LINEPATTRN); else outl(0x000fffff, LINEPATTRN); outl(mypar.p_screen_base + (line->y1 * BYTES_PER_LINE) + ((line->x1 * BYTES_PER_PIXEL) & ~PIXEL_MASK), BLKDSTSTRT); outl(((line->x1 & PIXEL_MASK) * BITS_PER_PIXEL) | ((((line->x1 + dx - 1) & PIXEL_MASK) * BITS_PER_PIXEL) << 16), DESTPIXELSTRT); outl(BYTES_PER_LINE / 4, DESTLINELENGTH); outl(line->fgcolor, BLOCKMASK); outl(line->bgcolor, BACKGROUND); outl((yinc << 16) | xinc, LINEINC); outl(count & 0xfff, BLKDESTWIDTH); outl(0, BLKDESTHEIGHT); value |= (line->flags & LINE_BACKGROUND) ? 0x00004000 : 0; outl(value | PIXEL_FORMAT | 0x00000013, BLOCKCTRL); ep93xxfb_wait(); return 0;}#endifstatic intep93xxfb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, int con, struct fb_info *info){ struct ep93xx_cursor cursor; struct ep93xx_blit blit; struct ep93xx_fill fill; struct ep93xx_line line; unsigned long caps; switch (cmd) { case FBIO_EP93XX_GET_CAPS: caps = EP93XX_CAP_CURSOR;#ifdef CONFIG_EP93XX_GRAPHICS caps |= EP93XX_CAP_LINE | EP93XX_CAP_FILL | EP93XX_CAP_BLIT;#endif copy_to_user((void *)arg, &caps, sizeof(unsigned long)); return 0; case FBIO_EP93XX_CURSOR: copy_from_user(&cursor, (void *)arg, sizeof(struct ep93xx_cursor)); ep93xxfb_cursor(&cursor); return 0;#ifdef CONFIG_EP93XX_GRAPHICS case FBIO_EP93XX_LINE: copy_from_user(&line, (void *)arg, sizeof(struct ep93xx_line)); return ep93xxfb_line(&line); case FBIO_EP93XX_FILL: copy_from_user(&fill, (void *)arg, sizeof(struct ep93xx_fill)); return ep93xxfb_fill(&fill); case FBIO_EP93XX_BLIT: copy_from_user(&blit, (void *)arg, sizeof(struct ep93xx_blit)); return ep93xxfb_blit(&blit);#endif default: return -EFAULT; }}//=============================================================================// CheckAdjustVar//=============================================================================// Check and adjust the video params in 'var'. If a value doesn't fit, round it// up, if it's too big, return -EINVAL.//// Suggestion: Round up in the following order: bits_per_pixel, xres, yres,// xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields,// horizontal timing, vertical timing.//// Note: This is similar to generic fb call sequence// (decode_var, set_par, decode_var)// in that var gets fixed if fixable and error if not. The translating// to parameter settings is handled inside activate_var below.//=============================================================================static int CheckAdjustVar(struct fb_var_screeninfo *var){ DPRINTK("Entering\n"); // // Just set virtual to actual resolution. // var->xres_virtual = mypar.xres; var->yres_virtual = mypar.yres; DPRINTK("check: var->bpp=%d\n", var->bits_per_pixel); switch (var->bits_per_pixel) {#ifdef FBCON_HAS_CFB4 case 4: //TBD need to adjust var break;#endif#ifdef FBCON_HAS_CFB8 case 8: /* through palette */ var->red.length = 4; //TBD is this used? should be 8? //TBD what about offset? var->green = var->red; var->blue = var->red; var->transp.length = 0; break;#endif#ifdef FBCON_HAS_CFB16 case 16: /* RGB 565 */ var->red.length = 5; var->blue.length = 5; var->green.length = 6; var->transp.length = 0; var->red.offset = 11; var->green.offset = 5; var->blue.offset = 0; var->transp.offset = 0; break;#endif default: DPRINTK("Invalid var->bits_per_pixel = %d\n",var->bits_per_pixel); return -EINVAL; } return 0;}//// Entry: con valid console number// or -1 to indicate current console// (note: current console maybe default initially)//// var pointer to var structure already allocated by caller.//// Action: Set pointed at var structure to fb_display[con].var or current.//// Exit: none//// Note: This function called by fb_mem.c,static intep93xxfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info){ //TBD I do not expect call with con=-1 //TBD Maybe I do not really need to support this?? if (con == -1) DPRINTK("get_var called with con=-1\n"); DPRINTK("con=%d\n", con); if (con == -1) { //TBD need to set var with current settings. //TBD why can't we just take copy it from info?? //ep93xxfb_get_par(&par); //ep93xxfb_encode_var(var, &par); //TBD for now current settings is always equal to //TBD default display settings //TBD Is this really complete? *var = global_disp.var; // copies structure } else *var = fb_display[con].var; // copies structure return 0;}/* * ep93xxfb_set_var(): * * Entry: con -1 means set default display * else set fb_display[con] * * var static var structure to define video mode * * Action: Settings are tweaked to get a usable display mode. * Set console display values for specified console, * if console valid. Else set default display values. * * Exit: Returns error if cannot tweak settings to usable mode. */static intep93xxfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info){ struct display *display; int err, chgvar = 0; if (con == -1) DPRINTK("called with con=-1\n"); // // Display is not passed in, but we alter as side-effect // if (con >= 0) // // Display settings for console // display = &fb_display[con]; else // // Set default display settings // display = &global_disp; // // Check and adjust var if need be to get usable display mode, else return // error if impossible to adjust // if ((err = CheckAdjustVar(var))) return err; // Update parameters DPRINTK("check: var->bpp=%d\n", var->bits_per_pixel); switch (var->bits_per_pixel) {#ifdef FBCON_HAS_CFB4 case 4: mypar.visual = FB_VISUAL_PSEUDOCOLOR; mypar.palette_size = 16; break;#endif#ifdef FBCON_HAS_CFB8 case 8: mypar.visual = FB_VISUAL_PSEUDOCOLOR; mypar.palette_size = 256; break;#endif#ifdef FBCON_HAS_CFB16 case 16: mypar.visual = FB_VISUAL_TRUECOLOR; mypar.palette_size = 16; break;#endif default: DPRINTK("ERROR! Bad bpp %d\n", var->bits_per_pixel); return -EINVAL; } if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST) return 0; else if (((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) && ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NXTOPEN)) return -EINVAL; if (con >= 0) if ((display->var.xres != var->xres) || (display->var.yres != var->yres) || (display->var.xres_virtual != var->xres_virtual) || (display->var.yres_virtual != var->yres_virtual) || (display->var.sync != var->sync) || (display->var.bits_per_pixel != var->bits_per_pixel) || (memcmp(&display->var.red, &var->red, sizeof(var->red))) || (memcmp(&display->var.green, &var->green, sizeof(var->green))) || (memcmp(&display->var.blue, &var->blue, sizeof(var->blue)))) chgvar = 1; DPRINTK("display->var.xres %d\n",display->var.xres); DPRINTK("display->var.yres %d\n",display->var.yres); DPRINTK("display->var.xres_virtual %d\n",display->var.xres_virtual); DPRINTK("display->var.yres_virtual %d\n",display->var.yres_virtual); //TBD is this complete? display->var = *var; // copies structure display->screen_base = mypar.v_screen_base; display->visual = mypar.visual; display->type = FB_TYPE_PACKED_PIXELS; display->type_aux = 0; display->ypanstep = 0; display->ywrapstep = 0; display->line_length = display->next_line = (var->xres * var->bits_per_pixel) / 8; display->can_soft_blank = 1; display->inverse = 0; switch (display->var.bits_per_pixel) {#ifdef FBCON_HAS_CFB4 case 4: display->dispsw = &fbcon_cfb4; break;#endif#ifdef FBCON_HAS_CFB8 case 8: display->dispsw = &fbcon_cfb8; break;#endif#ifdef FBCON_HAS_CFB16 case 16: display->dispsw = &fbcon_cfb16; display->dispsw_data = info->pseudo_palette; break;#endif default: display->dispsw = &fbcon_dummy; break; } /* If the console has changed and the console has defined */ /* a changevar function, call that function. */ if (chgvar && info && info->changevar) info->changevar(con); /* If the current console is selected and it's not truecolor, * update the palette */ if ((con == mypar.currcon) && (mypar.visual != FB_VISUAL_TRUECOLOR)) { struct fb_cmap *cmap; //TBD what is the juggling of par about? //mypar = par; if (display->cmap.len) cmap = &display->cmap; else cmap = fb_default_cmap(mypar.palette_size); //TBD when is cmap.len set? fb_set_cmap(cmap, 1, ep93xxfb_setcolreg, info); } // // If the current console is selected, activate the new var. // if (con == mypar.currcon) ConfigureRaster(var, info->par); return 0;}//TBD why have this if it does nothing?static intep93xxfb_updatevar(int con, struct fb_info *info){ DPRINTK("entered\n"); return 0;}//TBD what is relation between fix data in info and getting fix here?static intep93xxfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info){ struct display *display; memset(fix, 0, sizeof(struct fb_fix_screeninfo)); strcpy(fix->id, EP93XX_NAME); if (con >= 0) { DPRINTK("Using console specific display for con=%d\n",con); display = &fb_display[con]; /* Display settings for console */ } else display = &global_disp; /* Default display settings */ //TBD global_disp is only valid after set_var called with -1 fix->smem_start = (unsigned long)mypar.p_screen_base; fix->smem_len = mypar.screen_size; fix->mmio_start = RASTER_BASE - IO_BASE_VIRT + IO_BASE_PHYS;#ifdef CONFIG_EP93XX_GRAPHICS fix->mmio_len = 0x00020000;#else fix->mmio_len = 0x00010000;#endif fix->type = display->type; fix->type_aux = display->type_aux; fix->xpanstep = 0; fix->ypanstep = display->ypanstep; fix->ywrapstep = display->ywrapstep; fix->visual = display->visual; fix->line_length = display->line_length; fix->accel = FB_ACCEL_NONE; return 0;}static void__init ep93xxfb_init_fbinfo(void){ DPRINTK("Entering."); // // Set up the display name and default font. // strcpy(fb_info.modename, TimingValues[mode].Name); strcpy(fb_info.fontname, default_font); fb_info.node = -1; fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.open = 0; // // Set up initial parameters // fb_info.var.xres = TimingValues[mode].HRes; fb_info.var.yres = TimingValues[mode].VRes; // // Virtual display not supported // fb_info.var.xres_virtual = fb_info.var.xres; fb_info.var.yres_virtual = fb_info.var.yres;#ifdef CONFIG_FB_EP93XX_8BPP DPRINTK("Default framebuffer is 8bpp."); fb_info.var.bits_per_pixel = 8; fb_info.var.red.length = 8; fb_info.var.green.length = 8; fb_info.var.blue.length = 8; fb_info.fix.visual = FB_VISUAL_PSEUDOCOLOR; mypar.bits_per_pixel = 8;#endif // CONFIG_FB_EP93XX_8BPP#ifdef CONFIG_FB_EP93XX_16BPP_565
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -