📄 68328fb.c
字号:
{ curx += (width - 1); destx += (width - 1); }if (cury > desty) blitcmd |= 0x0080; /* Drawing direction +Y */else { cury += (height - 1); desty += (height - 1); }mc68328_WaitQueue (0x8000);*((u_short volatile *)(mc68328Regs + S3_PIXEL_CNTL)) = 0xa000;*((u_short volatile *)(mc68328Regs + S3_FRGD_MIX)) = (0x0060 | mode);*((u_short volatile *)(mc68328Regs + S3_CUR_X)) = curx;*((u_short volatile *)(mc68328Regs + S3_CUR_Y)) = cury;*((u_short volatile *)(mc68328Regs + S3_DESTX_DIASTP)) = destx;*((u_short volatile *)(mc68328Regs + S3_DESTY_AXSTP)) = desty;*((u_short volatile *)(mc68328Regs + S3_MIN_AXIS_PCNT)) = height - 1;*((u_short volatile *)(mc68328Regs + S3_MAJ_AXIS_PCNT)) = width - 1;*((u_short volatile *)(mc68328Regs + S3_CMD)) = blitcmd;#endif}/************************************************************** * Rectangle Fill Solid */void mc68328_RectFill (u_short x, u_short y, u_short width, u_short height, u_short mode, u_short color){#if 0u_short blitcmd = S3_FILLEDRECT;mc68328_WaitQueue (0x8000);*((u_short volatile *)(mc68328Regs + S3_PIXEL_CNTL)) = 0xa000;*((u_short volatile *)(mc68328Regs + S3_FRGD_MIX)) = (0x0020 | mode);*((u_short volatile *)(mc68328Regs + S3_MULT_MISC)) = 0xe000;*((u_short volatile *)(mc68328Regs + S3_FRGD_COLOR)) = color;*((u_short volatile *)(mc68328Regs + S3_CUR_X)) = x;*((u_short volatile *)(mc68328Regs + S3_CUR_Y)) = y;*((u_short volatile *)(mc68328Regs + S3_MIN_AXIS_PCNT)) = height - 1;*((u_short volatile *)(mc68328Regs + S3_MAJ_AXIS_PCNT)) = width - 1;*((u_short volatile *)(mc68328Regs + S3_CMD)) = blitcmd;#endif}/************************************************************** * Move cursor to x, y */void mc68328_MoveCursor (u_short x, u_short y){ (*(volatile unsigned short*)0xFFFFFA18) = (mc68328fbCursorMode << 14) | x; (*(volatile unsigned short*)0xFFFFFA1A) = y;#if 0*(mc68328Regs + S3_CRTC_ADR) = 0x39;*(mc68328Regs + S3_CRTC_DATA) = 0xa0;*(mc68328Regs + S3_CRTC_ADR) = S3_HWGC_ORGX_H;*(mc68328Regs + S3_CRTC_DATA) = (char)((x & 0x0700) >> 8);*(mc68328Regs + S3_CRTC_ADR) = S3_HWGC_ORGX_L;*(mc68328Regs + S3_CRTC_DATA) = (char)(x & 0x00ff);*(mc68328Regs + S3_CRTC_ADR) = S3_HWGC_ORGY_H;*(mc68328Regs + S3_CRTC_DATA) = (char)((y & 0x0700) >> 8);*(mc68328Regs + S3_CRTC_ADR) = S3_HWGC_ORGY_L;*(mc68328Regs + S3_CRTC_DATA) = (char)(y & 0x00ff);#endif}/* -------------------- Interfaces to hardware functions -------------------- */static struct fb_hwswitch mc68328_switch = { mc68328_init, mc68328_encode_fix, mc68328_decode_var, mc68328_encode_var, mc68328_getcolreg, mc68328_setcolreg, mc68328_blank};/* -------------------- Generic routines ------------------------------------ */ /* * Fill the hardware's `par' structure. */static void mc68328_fb_get_par(struct mc68328_fb_par *par){ if (current_par_valid) *par = current_par; else fbhw->decode_var(&mc68328_fb_predefined[mc68328fb_mode], par);}static void mc68328_fb_set_par(struct mc68328_fb_par *par){ current_par = *par; current_par_valid = 1;}static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive){ int err, activate; struct mc68328_fb_par par; if ((err = fbhw->decode_var(var, &par))) return(err); activate = var->activate; if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW && isactive) mc68328_fb_set_par(&par); fbhw->encode_var(var, &par); var->activate = activate; return(0);} /* * Default Colormaps */static u_short red16[] = { 0xc000, 0x0000, 0x0000, 0x0000, 0xc000, 0xc000, 0xc000, 0x0000, 0x8000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff};static u_short green16[] = { 0xc000, 0x0000, 0xc000, 0xc000, 0x0000, 0x0000, 0xc000, 0x0000, 0x8000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff};static u_short blue16[] = { 0xc000, 0x0000, 0x0000, 0xc000, 0x0000, 0xc000, 0x0000, 0x0000, 0x8000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff};static struct fb_cmap default_16_colors = { 0, 16, red16, green16, blue16, NULL };static struct fb_cmap *get_default_colormap(int bpp){ return(&default_16_colors);}#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7fff-(val))>>16)#define CNVT_FROMHW(val,width) (((width) ? ((((val)<<16)-(val)) / \ ((1<<(width))-1)) : 0))static int do_fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var, int kspc){ int i, start; u_short *red, *green, *blue, *transp; u_int hred, hgreen, hblue, htransp; red = cmap->red; green = cmap->green; blue = cmap->blue; transp = cmap->transp; start = cmap->start; if (start < 0) return(-EINVAL); for (i = 0; i < cmap->len; i++) { if (fbhw->getcolreg(start++, &hred, &hgreen, &hblue, &htransp)) return(0); hred = CNVT_FROMHW(hred, var->red.length); hgreen = CNVT_FROMHW(hgreen, var->green.length); hblue = CNVT_FROMHW(hblue, var->blue.length); htransp = CNVT_FROMHW(htransp, var->transp.length); if (kspc) { *red = hred; *green = hgreen; *blue = hblue; if (transp) *transp = htransp; } else { put_fs_word(hred, red); put_fs_word(hgreen, green); put_fs_word(hblue, blue); if (transp) put_fs_word(htransp, transp); } red++; green++; blue++; if (transp) transp++; } return(0);}static int do_fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var, int kspc){ int i, start; u_short *red, *green, *blue, *transp; u_int hred, hgreen, hblue, htransp; red = cmap->red; green = cmap->green; blue = cmap->blue; transp = cmap->transp; start = cmap->start; if (start < 0) return(-EINVAL); for (i = 0; i < cmap->len; i++) { if (kspc) { hred = *red; hgreen = *green; hblue = *blue; htransp = transp ? *transp : 0; } else { hred = get_fs_word(red); hgreen = get_fs_word(green); hblue = get_fs_word(blue); htransp = transp ? get_fs_word(transp) : 0; } hred = CNVT_TOHW(hred, var->red.length); hgreen = CNVT_TOHW(hgreen, var->green.length); hblue = CNVT_TOHW(hblue, var->blue.length); htransp = CNVT_TOHW(htransp, var->transp.length); red++; green++; blue++; if (transp) transp++; if (fbhw->setcolreg(start++, hred, hgreen, hblue, htransp)) return(0); } return(0);}static void do_install_cmap(int con){ if (con != currcon) return; if (disp[con].cmap.len) do_fb_set_cmap(&disp[con].cmap, &disp[con].var, 1); else do_fb_set_cmap(get_default_colormap(disp[con].var.bits_per_pixel), &disp[con].var, 1);}static void memcpy_fs(int fsfromto, void *to, void *from, int len){ switch (fsfromto) { case 0: memcpy(to, from, len); return; case 1: memcpy_fromfs(to, from, len); return; case 2: memcpy_tofs(to, from, len); return; }}static void copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto){ int size; int tooff = 0, fromoff = 0; if (to->start > from->start) fromoff = to->start-from->start; else tooff = from->start-to->start; size = to->len-tooff; if (size > from->len-fromoff) size = from->len-fromoff; if (size < 0) return; size *= sizeof(u_short); memcpy_fs(fsfromto, to->red+tooff, from->red+fromoff, size); memcpy_fs(fsfromto, to->green+tooff, from->green+fromoff, size); memcpy_fs(fsfromto, to->blue+tooff, from->blue+fromoff, size); if (from->transp && to->transp) memcpy_fs(fsfromto, to->transp+tooff, from->transp+fromoff, size);}static int alloc_cmap(struct fb_cmap *cmap, int len, int transp){ int size = len*sizeof(u_short); if (cmap->len != len) { if (cmap->red) kfree(cmap->red); if (cmap->green) kfree(cmap->green); if (cmap->blue) kfree(cmap->blue); if (cmap->transp) kfree(cmap->transp); cmap->red = cmap->green = cmap->blue = cmap->transp = NULL; cmap->len = 0; if (!len) return(0); if (!(cmap->red = kmalloc(size, GFP_ATOMIC))) return(-1); if (!(cmap->green = kmalloc(size, GFP_ATOMIC))) return(-1); if (!(cmap->blue = kmalloc(size, GFP_ATOMIC))) return(-1); if (transp) { if (!(cmap->transp = kmalloc(size, GFP_ATOMIC))) return(-1); } else cmap->transp = NULL; } cmap->start = 0; cmap->len = len; copy_cmap(get_default_colormap(len), cmap, 0); return(0);} /* * Get the Fixed Part of the Display */static int mc68328_fb_get_fix(struct fb_fix_screeninfo *fix, int con){ struct mc68328_fb_par par; int error = 0; if (con == -1) mc68328_fb_get_par(&par); else error = fbhw->decode_var(&disp[con].var, &par); return(error ? error : fbhw->encode_fix(fix, &par));} /* * Get the User Defined Part of the Display */static int mc68328_fb_get_var(struct fb_var_screeninfo *var, int con){ struct mc68328_fb_par par; int error = 0; if (con == -1) { mc68328_fb_get_par(&par); error = fbhw->encode_var(var, &par); } else *var = disp[con].var; return(error);}static void mc68328_fb_set_disp(int con){ struct fb_fix_screeninfo fix; mc68328_fb_get_fix(&fix, con); if (con == -1) con = 0; disp[con].screen_base = (u_char *)fix.smem_start; disp[con].visual = fix.visual; disp[con].type = fix.type; disp[con].type_aux = fix.type_aux; disp[con].ypanstep = fix.ypanstep; disp[con].ywrapstep = fix.ywrapstep; disp[con].can_soft_blank = 1; disp[con].inverse = mc68328fb_inverse;} /* * Set the User Defined Part of the Display */static int mc68328_fb_set_var(struct fb_var_screeninfo *var, int con){ int err, oldxres, oldyres, oldvxres, oldvyres, oldbpp; if ((err = do_fb_set_var(var, con == currcon))) return(err); if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { oldxres = disp[con].var.xres; oldyres = disp[con].var.yres; oldvxres = disp[con].var.xres_virtual; oldvyres = disp[con].var.yres_virtual; oldbpp = disp[con].var.bits_per_pixel; disp[con].var = *var; if (oldxres != var->xres || oldyres != var->yres || oldvxres != var->xres_virtual || oldvyres != var->yres_virtual || oldbpp != var->bits_per_pixel) { mc68328_fb_set_disp(con); (*fb_info.changevar)(con); alloc_cmap(&disp[con].cmap, 0, 0); do_install_cmap(con); } } var->activate = 0; return(0);} /* * Get the Colormap */static int mc68328_fb_get_cmap(struct fb_cmap *cmap, int kspc, int con){ if (con == currcon) /* current console? */ return(do_fb_get_cmap(cmap, &disp[con].var, kspc)); else if (disp[con].cmap.len) /* non default colormap? */ copy_cmap(&disp[con].cmap, cmap, kspc ? 0 : 2); else copy_cmap(get_default_colormap(disp[con].var.bits_per_pixel), cmap, kspc ? 0 : 2); return(0);} /* * Set the Colormap */static int mc68328_fb_set_cmap(struct fb_cmap *cmap, int kspc, int con){ int err; if (!disp[con].cmap.len) { /* no colormap allocated? */ if ((err = alloc_cmap(&disp[con].cmap, 1<<disp[con].var.bits_per_pixel, 0))) return(err); } if (con == currcon) /* current console? */ return(do_fb_set_cmap(cmap, &disp[con].var, kspc)); else copy_cmap(cmap, &disp[con].cmap, kspc ? 0 : 1); return(0);} /* * Pan or Wrap the Display * * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag */static int mc68328_fb_pan_display(struct fb_var_screeninfo *var, int con){ return(-EINVAL);} /* * mc68328 Frame Buffer Specific ioctls */static int mc68328_fb_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg, int con){ return(-EINVAL);}static struct fb_ops mc68328_fb_ops = { mc68328_fb_get_fix, mc68328_fb_get_var, mc68328_fb_set_var, mc68328_fb_get_cmap, mc68328_fb_set_cmap, mc68328_fb_pan_display, mc68328_fb_ioctl};void mc68328_video_setup(char *options, int *ints){ char *this_opt; int i; fb_info.fontname[0] = '\0'; if (!options || !*options) return; for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, ",")) if (!strcmp(this_opt, "inverse")) { mc68328fb_inverse = 1; for (i = 0; i < 16; i++) { red16[i] = ~red16[i]; green16[i] = ~green16[i]; blue16[i] = ~blue16[i]; } } else if (!strncmp(this_opt, "font:", 5)) strcpy(fb_info.fontname, this_opt+5); else mc68328fb_mode = get_video_mode(this_opt);} /* * Initialization */struct fb_info *mc68328_fb_init(long *mem_start){ int err; struct mc68328_fb_par par; memstart = mem_start; fbhw = &mc68328_switch; err = register_framebuffer(mc68328_fb_name, &node, &mc68328_fb_ops, NUM_TOTAL_MODES, mc68328_fb_predefined); if (err < 0) panic("Cannot register frame buffer\n"); fbhw->init(); fbhw->decode_var(&mc68328_fb_predefined[mc68328fb_mode], &par); fbhw->encode_var(&mc68328_fb_predefined[0], &par); strcpy(fb_info.modename, mc68328_fb_name); fb_info.disp = disp; fb_info.switch_con = &mc68328fb_switch; fb_info.updatevar = &mc68328fb_updatevar; fb_info.blank = &mc68328fb_blank; do_fb_set_var(&mc68328_fb_predefined[0], 1); mc68328_fb_get_var(&disp[0].var, -1); mc68328_fb_set_disp(-1); do_install_cmap(0); return(&fb_info);}static int mc68328fb_switch(int con){ /* Do we have to save the colormap? */ if (disp[currcon].cmap.len) do_fb_get_cmap(&disp[currcon].cmap, &disp[currcon].var, 1); do_fb_set_var(&disp[con].var, 1); currcon = con; /* Install new colormap */ do_install_cmap(con); return(0);} /* * Update the `var' structure (called by fbcon.c) * * This call looks only at yoffset and the FB_VMODE_YWRAP flag in `var'. * Since it's called by a kernel driver, no range checking is done. */static int mc68328fb_updatevar(int con){ return(0);} /* * Blank the display. */static void mc68328fb_blank(int blank){ fbhw->blank(blank);} /* * Get a Video Mode */static int get_video_mode(const char *name){ int i; for (i = 1; i < NUM_PREDEF_MODES; i++) if (!strcmp(name, mc68328_fb_modenames[i])) return(i); return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -