📄 radeonfb.c
字号:
rinfo->panel_xres = 800; break; case 768:#if defined(__powerpc__) if (rinfo->dviDisp_type == MT_LCD) rinfo->panel_xres = 1152; else#endif rinfo->panel_xres = 1024; break; case 1024: rinfo->panel_xres = 1280; break; case 1050: rinfo->panel_xres = 1400; break; case 1200: rinfo->panel_xres = 1600; break; default: printk("radeonfb: Failed to detect DFP panel size\n"); return 0; } printk("radeonfb: detected DFP panel size from registers: %dx%d\n", rinfo->panel_xres, rinfo->panel_yres); tmp = INREG(FP_CRTC_H_TOTAL_DISP); a = (tmp & FP_CRTC_H_TOTAL_MASK) + 4; b = (tmp & 0x01ff0000) >> FP_CRTC_H_DISP_SHIFT; rinfo->hblank = (a - b + 1) * 8; tmp = INREG(FP_H_SYNC_STRT_WID); rinfo->hOver_plus = (unsigned short) ((tmp & FP_H_SYNC_STRT_CHAR_MASK) >> FP_H_SYNC_STRT_CHAR_SHIFT) - b - 1; rinfo->hOver_plus *= 8; rinfo->hSync_width = (unsigned short) ((tmp & FP_H_SYNC_WID_MASK) >> FP_H_SYNC_WID_SHIFT); rinfo->hSync_width *= 8; tmp = INREG(FP_CRTC_V_TOTAL_DISP); a = (tmp & FP_CRTC_V_TOTAL_MASK) + 1; b = (tmp & FP_CRTC_V_DISP_MASK) >> FP_CRTC_V_DISP_SHIFT; rinfo->vblank = a - b /* + 24 */ ; tmp = INREG(FP_V_SYNC_STRT_WID); rinfo->vOver_plus = (unsigned short) (tmp & FP_V_SYNC_STRT_MASK) - b + 1; rinfo->vSync_width = (unsigned short) ((tmp & FP_V_SYNC_WID_MASK) >> FP_V_SYNC_WID_SHIFT); return 1; } return 1;}#ifdef CONFIG_ALL_PPCstatic int radeon_read_OF (struct radeonfb_info *rinfo){ struct device_node *dp; unsigned int *xtal; dp = pci_device_to_OF_node(rinfo->pdev); xtal = (unsigned int *) get_property(dp, "ATY,RefCLK", 0); rinfo->pll.ref_clk = *xtal / 10; if (*xtal) return 1; else return 0;}#endif static void radeon_engine_init (struct radeonfb_info *rinfo){ u32 temp; /* disable 3D engine */ OUTREG(RB3D_CNTL, 0); radeon_engine_reset (); radeon_fifo_wait (1); OUTREG(DSTCACHE_MODE, 0); /* XXX */ rinfo->pitch = ((rinfo->xres * (rinfo->bpp / 8) + 0x3f)) >> 6; radeon_fifo_wait (1); temp = INREG(DEFAULT_PITCH_OFFSET); OUTREG(DEFAULT_PITCH_OFFSET, ((temp & 0xc0000000) | (rinfo->pitch << 0x16))); radeon_fifo_wait (1); OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN); radeon_fifo_wait (1); OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX | DEFAULT_SC_BOTTOM_MAX)); temp = radeon_get_dstbpp(rinfo->depth); rinfo->dp_gui_master_cntl = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS); radeon_fifo_wait (1); OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl | GMC_BRUSH_SOLID_COLOR | GMC_SRC_DATATYPE_COLOR)); radeon_fifo_wait (7); /* clear line drawing regs */ OUTREG(DST_LINE_START, 0); OUTREG(DST_LINE_END, 0); /* set brush color regs */ OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff); OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000); /* set source color regs */ OUTREG(DP_SRC_FRGD_CLR, 0xffffffff); OUTREG(DP_SRC_BKGD_CLR, 0x00000000); /* default write mask */ OUTREG(DP_WRITE_MSK, 0xffffffff); radeon_engine_idle ();}static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo){ struct fb_info *info; info = &rinfo->info; strcpy (info->modename, rinfo->name); info->node = -1; info->flags = FBINFO_FLAG_DEFAULT; info->fbops = &radeon_fb_ops; info->display_fg = NULL; strncpy (info->fontname, fontname, sizeof (info->fontname)); info->fontname[sizeof (info->fontname) - 1] = 0; info->changevar = NULL; info->switch_con = radeonfb_switch; info->updatevar = radeonfb_updatevar; info->blank = radeonfb_blank; if (radeon_init_disp (rinfo) < 0) return -1; return 0;}static int __devinit radeon_init_disp (struct radeonfb_info *rinfo){ struct fb_info *info; struct display *disp; info = &rinfo->info; disp = &rinfo->disp; disp->var = radeonfb_default_var;#if defined(__powerpc__) if (rinfo->dviDisp_type == MT_LCD) { if (mac_vmode_to_var(VMODE_1152_768_60, CMODE_8, &disp->var)) disp->var = radeonfb_default_var; }#endif rinfo->depth = var_to_depth(&disp->var); rinfo->bpp = disp->var.bits_per_pixel; info->disp = disp; radeon_set_dispsw (rinfo, disp); if (noaccel) disp->scrollmode = SCROLL_YREDRAW; else disp->scrollmode = 0; rinfo->currcon_display = disp; if ((radeon_init_disp_var (rinfo)) < 0) return -1; return 0;}static int radeon_init_disp_var (struct radeonfb_info *rinfo){#ifndef MODULE if (mode_option) fb_find_mode (&rinfo->disp.var, &rinfo->info, mode_option, NULL, 0, NULL, 8); else#endif#if defined(__powerpc__) if (rinfo->dviDisp_type == MT_LCD) { if (mac_vmode_to_var(VMODE_1152_768_60, CMODE_8, &rinfo->disp.var)) rinfo->disp.var = radeonfb_default_var; } else#endif if (rinfo->use_default_var) /* We will use the modified default far */ rinfo->disp.var = radeonfb_default_var; else fb_find_mode (&rinfo->disp.var, &rinfo->info, "640x480-8@60", NULL, 0, NULL, 0); if (noaccel) rinfo->disp.var.accel_flags &= ~FB_ACCELF_TEXT; else rinfo->disp.var.accel_flags |= FB_ACCELF_TEXT; return 0;}static void radeon_set_dispsw (struct radeonfb_info *rinfo, struct display *disp){ int accel; accel = disp->var.accel_flags & FB_ACCELF_TEXT; disp->dispsw_data = NULL; disp->screen_base = (char*)rinfo->fb_base; disp->type = FB_TYPE_PACKED_PIXELS; disp->type_aux = 0; disp->ypanstep = 1; disp->ywrapstep = 0; disp->can_soft_blank = 1; disp->inverse = 0; switch (disp->var.bits_per_pixel) {#ifdef FBCON_HAS_CFB8 case 8: disp->dispsw = &fbcon_cfb8; disp->visual = FB_VISUAL_PSEUDOCOLOR; disp->line_length = disp->var.xres_virtual; break;#endif#ifdef FBCON_HAS_CFB16 case 16: disp->dispsw = &fbcon_cfb16; disp->dispsw_data = &rinfo->con_cmap.cfb16; disp->visual = FB_VISUAL_DIRECTCOLOR; disp->line_length = disp->var.xres_virtual * 2; break;#endif #ifdef FBCON_HAS_CFB32 case 24: disp->dispsw = &fbcon_cfb24; disp->dispsw_data = &rinfo->con_cmap.cfb24; disp->visual = FB_VISUAL_DIRECTCOLOR; disp->line_length = disp->var.xres_virtual * 4; break;#endif#ifdef FBCON_HAS_CFB32 case 32: disp->dispsw = &fbcon_cfb32; disp->dispsw_data = &rinfo->con_cmap.cfb32; disp->visual = FB_VISUAL_DIRECTCOLOR; disp->line_length = disp->var.xres_virtual * 4; break; #endif default: printk ("radeonfb: setting fbcon_dummy renderer\n"); disp->dispsw = &fbcon_dummy; } return;} static void do_install_cmap(int con, struct fb_info *info){ struct radeonfb_info *rinfo = (struct radeonfb_info *) info; if (con != rinfo->currcon) return; if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, radeon_setcolreg, info); else { int size = radeon_get_cmap_len(&fb_display[con].var); fb_set_cmap(fb_default_cmap(size), 1, radeon_setcolreg, info); }}static int radeonfb_do_maximize(struct radeonfb_info *rinfo, struct fb_var_screeninfo *var, struct fb_var_screeninfo *v, int nom, int den){ static struct { int xres, yres; } modes[] = { {1600, 1280}, {1280, 1024}, {1024, 768}, {800, 600}, {640, 480}, {-1, -1} }; int i; /* use highest possible virtual resolution */ if (v->xres_virtual == -1 && v->yres_virtual == -1) { printk("radeonfb: using max availabe virtual resolution\n"); for (i=0; modes[i].xres != -1; i++) { if (modes[i].xres * nom / den * modes[i].yres < rinfo->video_ram / 2) break; } if (modes[i].xres == -1) { printk("radeonfb: could not find virtual resolution that fits into video memory!\n"); return -EINVAL; } v->xres_virtual = modes[i].xres; v->yres_virtual = modes[i].yres; printk("radeonfb: virtual resolution set to max of %dx%d\n", v->xres_virtual, v->yres_virtual); } else if (v->xres_virtual == -1) { v->xres_virtual = (rinfo->video_ram * den / (nom * v->yres_virtual * 2)) & ~15; } else if (v->yres_virtual == -1) { v->xres_virtual = (v->xres_virtual + 15) & ~15; v->yres_virtual = rinfo->video_ram * den / (nom * v->xres_virtual *2); } else { if (v->xres_virtual * nom / den * v->yres_virtual > rinfo->video_ram) { return -EINVAL; } } if (v->xres_virtual * nom / den >= 8192) { v->xres_virtual = 8192 * den / nom - 16; } if (v->xres_virtual < v->xres) return -EINVAL; if (v->yres_virtual < v->yres) return -EINVAL; return 0;} /* * fb ops */static int radeonfb_get_fix (struct fb_fix_screeninfo *fix, int con, struct fb_info *info){ struct radeonfb_info *rinfo = (struct radeonfb_info *) info; struct display *disp; disp = (con < 0) ? rinfo->info.disp : &fb_display[con]; memset (fix, 0, sizeof (struct fb_fix_screeninfo)); strcpy (fix->id, rinfo->name); fix->smem_start = rinfo->fb_base_phys; fix->smem_len = rinfo->video_ram; fix->type = disp->type; fix->type_aux = disp->type_aux; fix->visual = disp->visual; fix->xpanstep = 8; fix->ypanstep = 1; fix->ywrapstep = 0; fix->line_length = disp->line_length; fix->mmio_start = rinfo->mmio_base_phys; fix->mmio_len = RADEON_REGSIZE; if (noaccel) fix->accel = FB_ACCEL_NONE; else fix->accel = 40; /* XXX */ return 0;}static int radeonfb_get_var (struct fb_var_screeninfo *var, int con, struct fb_info *info){ struct radeonfb_info *rinfo = (struct radeonfb_info *) info; *var = (con < 0) ? rinfo->disp.var : fb_display[con].var; return 0;}static int radeonfb_set_var (struct fb_var_screeninfo *var, int con, struct fb_info *info){ struct radeonfb_info *rinfo = (struct radeonfb_info *) info; struct display *disp; struct fb_var_screeninfo v; int nom, den, accel; unsigned chgvar = 0; disp = (con < 0) ? rinfo->info.disp : &fb_display[con]; accel = var->accel_flags & FB_ACCELF_TEXT; if (con >= 0) { chgvar = ((disp->var.xres != var->xres) || (disp->var.yres != var->yres) || (disp->var.xres_virtual != var->xres_virtual) || (disp->var.yres_virtual != var->yres_virtual) || (disp->var.bits_per_pixel != var->bits_per_pixel) || memcmp (&disp->var.red, &var->red, sizeof (var->red)) || memcmp (&disp->var.green, &var->green, sizeof (var->green)) || memcmp (&disp->var.blue, &var->blue, sizeof (var->blue))); } memcpy (&v, var, sizeof (v)); switch (v.bits_per_pixel) { case 0 ... 8: v.bits_per_pixel = 8; break; case 9 ... 16: v.bits_per_pixel = 16; break; case 17 ... 24: v.bits_per_pixel = 24; break; case 25 ... 32: v.bits_per_pixel = 32; break; default: return -EINVAL; } switch (var_to_depth(&v)) {#ifdef FBCON_HAS_CFB8 case 8: nom = den = 1; disp->line_length = v.xres_virtual; disp->visual = FB_VISUAL_PSEUDOCOLOR; v.red.offset = v.green.offset = v.blue.offset = 0; v.red.length = v.green.length = v.blue.length = 8; v.transp.offset = v.transp.length = 0; break;#endif #ifdef FBCON_HAS_CFB16 case 15: nom = 2; den = 1; disp->line_length = v.xres_virtual * 2; disp->visual = FB_VISUAL_DIRECTCOLOR; v.red.offset = 10; v.green.offset = 5; v.red.offset = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -