Lines Matching +full:pre +full:- +full:programmed

2  *  linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device
10 * Sven Luther, <luther@dpt-info.u-strasbg.fr>
16 * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT)
97 return fb_readl(par->v_regs + off); in PM3_READ_REG()
102 fb_writel(v, par->v_regs + off); in PM3_WRITE_REG()
151 int f, pre, post; in pm3fb_calculate_clock() local
157 for (pre = 1; pre < 256; pre++) { in pm3fb_calculate_clock()
159 freq = ((2*PM3_REF_CLOCK * f) >> post) / pre; in pm3fb_calculate_clock()
161 ? reqclock - freq in pm3fb_calculate_clock()
162 : freq - reqclock; in pm3fb_calculate_clock()
166 *prescale = pre; in pm3fb_calculate_clock()
176 if (var->bits_per_pixel == 16) in pm3fb_depth()
177 return var->red.length + var->green.length in pm3fb_depth()
178 + var->blue.length; in pm3fb_depth()
180 return var->bits_per_pixel; in pm3fb_depth()
200 struct pm3_par *par = info->par; in pm3fb_sync()
216 struct pm3_par *par = info->par; in pm3fb_init_engine()
217 const u32 width = (info->var.xres_virtual + 7) & ~7; in pm3fb_init_engine()
290 switch (info->var.bits_per_pixel) { in pm3fb_init_engine()
311 info->var.bits_per_pixel); in pm3fb_init_engine()
332 unsigned long sofb = info->screen_size / in pm3fb_init_engine()
333 info->fix.line_length; in pm3fb_init_engine()
339 switch (info->var.bits_per_pixel) { in pm3fb_init_engine()
354 info->var.bits_per_pixel); in pm3fb_init_engine()
379 struct pm3_par *par = info->par; in pm3fb_fillrect()
383 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? in pm3fb_fillrect()
384 ((u32 *)info->pseudo_palette)[region->color] : region->color; in pm3fb_fillrect()
386 if (info->state != FBINFO_STATE_RUNNING) in pm3fb_fillrect()
388 if (info->flags & FBINFO_HWACCEL_DISABLED) { in pm3fb_fillrect()
392 if (region->rop == ROP_COPY ) in pm3fb_fillrect()
398 vxres = info->var.xres_virtual; in pm3fb_fillrect()
399 vyres = info->var.yres_virtual; in pm3fb_fillrect()
408 modded.width = vxres - modded.dx; in pm3fb_fillrect()
410 modded.height = vyres - modded.dy; in pm3fb_fillrect()
412 if (info->var.bits_per_pixel == 8) in pm3fb_fillrect()
414 if (info->var.bits_per_pixel <= 16) in pm3fb_fillrect()
443 struct pm3_par *par = info->par; in pm3fb_copyarea()
448 if (info->state != FBINFO_STATE_RUNNING) in pm3fb_copyarea()
450 if (info->flags & FBINFO_HWACCEL_DISABLED) { in pm3fb_copyarea()
457 vxres = info->var.xres_virtual; in pm3fb_copyarea()
458 vyres = info->var.yres_virtual; in pm3fb_copyarea()
466 modded.width = vxres - modded.sx; in pm3fb_copyarea()
468 modded.width = vxres - modded.dx; in pm3fb_copyarea()
470 modded.height = vyres - modded.sy; in pm3fb_copyarea()
472 modded.height = vyres - modded.dy; in pm3fb_copyarea()
474 o_x = modded.sx - modded.dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */ in pm3fb_copyarea()
475 o_y = modded.sy - modded.dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */ in pm3fb_copyarea()
499 PM3RectanglePosition_XOffset(modded.dx - x_align) | in pm3fb_copyarea()
514 struct pm3_par *par = info->par; in pm3fb_imageblit()
515 u32 height = image->height; in pm3fb_imageblit()
517 const u32 *src = (const u32 *)image->data; in pm3fb_imageblit()
519 if (info->state != FBINFO_STATE_RUNNING) in pm3fb_imageblit()
521 if (info->flags & FBINFO_HWACCEL_DISABLED) { in pm3fb_imageblit()
525 switch (info->fix.visual) { in pm3fb_imageblit()
527 fgx = image->fg_color; in pm3fb_imageblit()
528 bgx = image->bg_color; in pm3fb_imageblit()
532 fgx = par->palette[image->fg_color]; in pm3fb_imageblit()
533 bgx = par->palette[image->bg_color]; in pm3fb_imageblit()
536 if (image->depth != 1) { in pm3fb_imageblit()
541 if (info->var.bits_per_pixel == 8) { in pm3fb_imageblit()
545 if (info->var.bits_per_pixel <= 16) { in pm3fb_imageblit()
564 ((image->dy & 0x0fff) << 16) | (image->dx & 0x0fff)); in pm3fb_imageblit()
566 (((image->dy + image->height) & 0x0fff) << 16) | in pm3fb_imageblit()
567 ((image->dx + image->width) & 0x0fff)); in pm3fb_imageblit()
569 PM3RectanglePosition_XOffset(image->dx) | in pm3fb_imageblit()
570 PM3RectanglePosition_YOffset(image->dy)); in pm3fb_imageblit()
576 PM3Render2D_Width(image->width) | in pm3fb_imageblit()
577 PM3Render2D_Height(image->height)); in pm3fb_imageblit()
580 while (height--) { in pm3fb_imageblit()
581 int width = ((image->width + 7) >> 3) in pm3fb_imageblit()
582 + info->pixmap.scan_align - 1; in pm3fb_imageblit()
586 int i = PM3_FIFO_SIZE - 1; in pm3fb_imageblit()
589 while (i--) { in pm3fb_imageblit()
593 width -= PM3_FIFO_SIZE - 1; in pm3fb_imageblit()
597 while (width--) { in pm3fb_imageblit()
615 struct pm3_par *par = info->par; in pm3fb_cursor()
619 return -EINVAL; /* just to force soft_cursor() call */ in pm3fb_cursor()
621 /* Too large of a cursor or wrong bpp :-( */ in pm3fb_cursor()
622 if (cursor->image.width > 64 || in pm3fb_cursor()
623 cursor->image.height > 64 || in pm3fb_cursor()
624 cursor->image.depth > 1) in pm3fb_cursor()
625 return -EINVAL; in pm3fb_cursor()
628 if (cursor->enable) in pm3fb_cursor()
638 if (!cursor->set) in pm3fb_cursor()
641 if (cursor->set & FB_CUR_SETPOS) { in pm3fb_cursor()
642 int x = cursor->image.dx - info->var.xoffset; in pm3fb_cursor()
643 int y = cursor->image.dy - info->var.yoffset; in pm3fb_cursor()
651 if (cursor->set & FB_CUR_SETHOT) { in pm3fb_cursor()
653 cursor->hot.x & 0x3f); in pm3fb_cursor()
655 cursor->hot.y & 0x3f); in pm3fb_cursor()
658 if (cursor->set & FB_CUR_SETCMAP) { in pm3fb_cursor()
659 u32 fg_idx = cursor->image.fg_color; in pm3fb_cursor()
660 u32 bg_idx = cursor->image.bg_color; in pm3fb_cursor()
661 struct fb_cmap cmap = info->cmap; in pm3fb_cursor()
679 if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) { in pm3fb_cursor()
680 u8 *bitmap = (u8 *)cursor->image.data; in pm3fb_cursor()
681 u8 *mask = (u8 *)cursor->mask; in pm3fb_cursor()
685 for (i = 0; i < cursor->image.height; i++) { in pm3fb_cursor()
686 int j = (cursor->image.width + 7) >> 3; in pm3fb_cursor()
687 int k = 8 - j; in pm3fb_cursor()
689 for (; j > 0; j--) { in pm3fb_cursor()
692 if (cursor->rop == ROP_COPY) in pm3fb_cursor()
705 for (; k > 0; k--) { in pm3fb_cursor()
719 struct pm3_par *par = info->par; in pm3fb_write_mode()
722 const u32 hsstart = info->var.right_margin; in pm3fb_write_mode()
723 const u32 hsend = hsstart + info->var.hsync_len; in pm3fb_write_mode()
724 const u32 hbend = hsend + info->var.left_margin; in pm3fb_write_mode()
725 const u32 xres = (info->var.xres + 31) & ~31; in pm3fb_write_mode()
727 const u32 vsstart = info->var.lower_margin; in pm3fb_write_mode()
728 const u32 vsend = vsstart + info->var.vsync_len; in pm3fb_write_mode()
729 const u32 vbend = vsend + info->var.upper_margin; in pm3fb_write_mode()
730 const u32 vtotal = info->var.yres + vbend; in pm3fb_write_mode()
731 const u32 width = (info->var.xres_virtual + 7) & ~7; in pm3fb_write_mode()
732 const unsigned bpp = info->var.bits_per_pixel; in pm3fb_write_mode()
741 pm3fb_shift_bpp(bpp, htotal - 1)); in pm3fb_write_mode()
752 PM3_WRITE_REG(par, PM3VTotal, vtotal - 1); in pm3fb_write_mode()
753 PM3_WRITE_REG(par, PM3VsEnd, vsend - 1); in pm3fb_write_mode()
754 PM3_WRITE_REG(par, PM3VsStart, vsstart - 1); in pm3fb_write_mode()
803 * Oxygen VX1 - it appears that setting PM3VideoControl and in pm3fb_write_mode()
805 * any net change - they seem to xor together. Only set the in pm3fb_write_mode()
806 * sync options in PM3RD_SyncControl. --rmk in pm3fb_write_mode()
809 unsigned int video = par->video; in pm3fb_write_mode()
819 PM3_WRITE_REG(par, PM3ScreenBase, par->base); in pm3fb_write_mode()
828 unsigned long pixclock = PICOS2KHZ(info->var.pixclock); in pm3fb_write_mode()
832 DPRINTK("Pixclock: %ld, Pre: %d, Feedback: %d, Post: %d\n", in pm3fb_write_mode()
845 if ((par->video & PM3VideoControl_HSYNC_MASK) == in pm3fb_write_mode()
848 if ((par->video & PM3VideoControl_VSYNC_MASK) == in pm3fb_write_mode()
857 switch (pm3fb_depth(&info->var)) { in pm3fb_write_mode()
915 unsigned bpp = var->red.length + var->green.length in pm3fb_check_var()
916 + var->blue.length + var->transp.length; in pm3fb_check_var()
918 if (bpp != var->bits_per_pixel) { in pm3fb_check_var()
921 switch (var->bits_per_pixel) { in pm3fb_check_var()
923 var->red.length = 8; in pm3fb_check_var()
924 var->green.length = 8; in pm3fb_check_var()
925 var->blue.length = 8; in pm3fb_check_var()
926 var->red.offset = 0; in pm3fb_check_var()
927 var->green.offset = 0; in pm3fb_check_var()
928 var->blue.offset = 0; in pm3fb_check_var()
929 var->transp.offset = 0; in pm3fb_check_var()
930 var->transp.length = 0; in pm3fb_check_var()
933 var->red.length = 5; in pm3fb_check_var()
934 var->blue.length = 5; in pm3fb_check_var()
935 var->green.length = 6; in pm3fb_check_var()
936 var->transp.length = 0; in pm3fb_check_var()
939 var->red.length = 8; in pm3fb_check_var()
940 var->green.length = 8; in pm3fb_check_var()
941 var->blue.length = 8; in pm3fb_check_var()
942 var->transp.length = 8; in pm3fb_check_var()
946 var->bits_per_pixel); in pm3fb_check_var()
947 return -EINVAL; in pm3fb_check_var()
951 if (var->bits_per_pixel > 8 ) { in pm3fb_check_var()
952 var->blue.offset = 0; in pm3fb_check_var()
953 var->green.offset = var->blue.length; in pm3fb_check_var()
954 var->red.offset = var->green.offset + var->green.length; in pm3fb_check_var()
955 var->transp.offset = var->red.offset + var->red.length; in pm3fb_check_var()
957 var->height = -1; in pm3fb_check_var()
958 var->width = -1; in pm3fb_check_var()
960 if (var->xres != var->xres_virtual) { in pm3fb_check_var()
963 return -EINVAL; in pm3fb_check_var()
966 if (var->yres > var->yres_virtual) { in pm3fb_check_var()
969 return -EINVAL; in pm3fb_check_var()
972 if (var->xoffset) { in pm3fb_check_var()
974 return -EINVAL; in pm3fb_check_var()
977 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { in pm3fb_check_var()
979 return -EINVAL; in pm3fb_check_var()
982 var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */ in pm3fb_check_var()
983 lpitch = var->xres * ((var->bits_per_pixel + 7) >> 3); in pm3fb_check_var()
985 if (var->xres < 200 || var->xres > 2048) { in pm3fb_check_var()
986 DPRINTK("width not supported: %u\n", var->xres); in pm3fb_check_var()
987 return -EINVAL; in pm3fb_check_var()
990 if (var->yres < 200 || var->yres > 4095) { in pm3fb_check_var()
991 DPRINTK("height not supported: %u\n", var->yres); in pm3fb_check_var()
992 return -EINVAL; in pm3fb_check_var()
995 if (lpitch * var->yres_virtual > info->fix.smem_len) { in pm3fb_check_var()
997 var->xres, var->yres_virtual, var->bits_per_pixel); in pm3fb_check_var()
998 return -EINVAL; in pm3fb_check_var()
1001 if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) { in pm3fb_check_var()
1003 PICOS2KHZ(var->pixclock)); in pm3fb_check_var()
1004 return -EINVAL; in pm3fb_check_var()
1007 var->accel_flags = 0; /* Can't mmap if this is on */ in pm3fb_check_var()
1010 var->xres, var->yres, var->bits_per_pixel); in pm3fb_check_var()
1016 struct pm3_par *par = info->par; in pm3fb_set_par()
1017 const u32 xres = (info->var.xres + 31) & ~31; in pm3fb_set_par()
1018 const unsigned bpp = info->var.bits_per_pixel; in pm3fb_set_par()
1020 par->base = pm3fb_shift_bpp(bpp, (info->var.yoffset * xres) in pm3fb_set_par()
1021 + info->var.xoffset); in pm3fb_set_par()
1022 par->video = 0; in pm3fb_set_par()
1024 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) in pm3fb_set_par()
1025 par->video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; in pm3fb_set_par()
1027 par->video |= PM3VideoControl_HSYNC_ACTIVE_LOW; in pm3fb_set_par()
1029 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) in pm3fb_set_par()
1030 par->video |= PM3VideoControl_VSYNC_ACTIVE_HIGH; in pm3fb_set_par()
1032 par->video |= PM3VideoControl_VSYNC_ACTIVE_LOW; in pm3fb_set_par()
1034 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) in pm3fb_set_par()
1035 par->video |= PM3VideoControl_LINE_DOUBLE_ON; in pm3fb_set_par()
1037 if ((info->var.activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) in pm3fb_set_par()
1038 par->video |= PM3VideoControl_ENABLE; in pm3fb_set_par()
1044 par->video |= PM3VideoControl_PIXELSIZE_8BIT; in pm3fb_set_par()
1047 par->video |= PM3VideoControl_PIXELSIZE_16BIT; in pm3fb_set_par()
1050 par->video |= PM3VideoControl_PIXELSIZE_32BIT; in pm3fb_set_par()
1057 info->fix.visual = in pm3fb_set_par()
1059 info->fix.line_length = ((info->var.xres_virtual + 7) >> 3) * bpp; in pm3fb_set_par()
1073 struct pm3_par *par = info->par; in pm3fb_setcolreg()
1076 return -EINVAL; in pm3fb_setcolreg()
1080 if (info->var.grayscale) in pm3fb_setcolreg()
1084 * var->{color}.offset contains start of bitfield in pm3fb_setcolreg()
1085 * var->{color}.length contains length of bitfield in pm3fb_setcolreg()
1087 * pseudo_palette[X] is programmed to (X << red.offset) | in pm3fb_setcolreg()
1090 * RAMDAC[X] is programmed to (red, green, blue) in pm3fb_setcolreg()
1091 * color depth = SUM(var->{color}.length) in pm3fb_setcolreg()
1094 * var->{color}.offset is 0 in pm3fb_setcolreg()
1095 * var->{color}.length contains width of DAC or the number in pm3fb_setcolreg()
1098 * RAMDAC[X] is programmed to (red, green, blue) in pm3fb_setcolreg()
1099 * color depth = var->{color}.length in pm3fb_setcolreg()
1106 #define CNVT_TOHW(val, width) ((((val) << (width)) + 0x7FFF - (val)) >> 16) in pm3fb_setcolreg()
1107 red = CNVT_TOHW(red, info->var.red.length); in pm3fb_setcolreg()
1108 green = CNVT_TOHW(green, info->var.green.length); in pm3fb_setcolreg()
1109 blue = CNVT_TOHW(blue, info->var.blue.length); in pm3fb_setcolreg()
1110 transp = CNVT_TOHW(transp, info->var.transp.length); in pm3fb_setcolreg()
1113 if (info->fix.visual == FB_VISUAL_TRUECOLOR || in pm3fb_setcolreg()
1114 info->fix.visual == FB_VISUAL_DIRECTCOLOR) { in pm3fb_setcolreg()
1118 return -EINVAL; in pm3fb_setcolreg()
1120 v = (red << info->var.red.offset) | in pm3fb_setcolreg()
1121 (green << info->var.green.offset) | in pm3fb_setcolreg()
1122 (blue << info->var.blue.offset) | in pm3fb_setcolreg()
1123 (transp << info->var.transp.offset); in pm3fb_setcolreg()
1125 switch (info->var.bits_per_pixel) { in pm3fb_setcolreg()
1130 ((u32 *)(info->pseudo_palette))[regno] = v; in pm3fb_setcolreg()
1134 } else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) in pm3fb_setcolreg()
1143 struct pm3_par *par = info->par; in pm3fb_pan_display()
1144 const u32 xres = (info->var.xres + 31) & ~31; in pm3fb_pan_display()
1146 par->base = pm3fb_shift_bpp(info->var.bits_per_pixel, in pm3fb_pan_display()
1147 (var->yoffset * xres) in pm3fb_pan_display()
1148 + var->xoffset); in pm3fb_pan_display()
1150 PM3_WRITE_REG(par, PM3ScreenBase, par->base); in pm3fb_pan_display()
1156 struct pm3_par *par = info->par; in pm3fb_blank()
1157 u32 video = par->video; in pm3fb_blank()
1160 * Oxygen VX1 - it appears that setting PM3VideoControl and in pm3fb_blank()
1162 * any net change - they seem to xor together. Only set the in pm3fb_blank()
1163 * sync options in PM3RD_SyncControl. --rmk in pm3fb_blank()
1220 /* ------------------------------------------------------------------------- */
1235 /* Linear frame buffer - request region and map it. */ in pm3fb_size_memory()
1249 /* TODO: card-specific stuff, *before* accessing *any* FB memory */ in pm3fb_size_memory()
1260 * nasty stuff IMHO ;-) in pm3fb_size_memory()
1291 fb_readl((screen_mem + ((i - 32) * 1048576))); in pm3fb_size_memory()
1317 struct device *device = &dev->dev; /* for pci drivers */ in pm3fb_probe()
1319 int retval = -ENXIO; in pm3fb_probe()
1336 return -ENOMEM; in pm3fb_probe()
1337 par = info->par; in pm3fb_probe()
1347 DPRINTK("Adjusting register base for big-endian.\n"); in pm3fb_probe()
1350 /* Registers - request region and map it. */ in pm3fb_probe()
1356 par->v_regs = in pm3fb_probe()
1358 if (!par->v_regs) { in pm3fb_probe()
1365 /* Linear frame buffer - request region and map it. */ in pm3fb_probe()
1377 info->screen_base = ioremap_wc(pm3fb_fix.smem_start, in pm3fb_probe()
1379 if (!info->screen_base) { in pm3fb_probe()
1384 info->screen_size = pm3fb_fix.smem_len; in pm3fb_probe()
1387 par->wc_cookie = arch_phys_wc_add(pm3fb_fix.smem_start, in pm3fb_probe()
1389 info->fbops = &pm3fb_ops; in pm3fb_probe()
1391 par->video = PM3_READ_REG(par, PM3VideoControl); in pm3fb_probe()
1393 info->fix = pm3fb_fix; in pm3fb_probe()
1394 info->pseudo_palette = par->palette; in pm3fb_probe()
1395 info->flags = FBINFO_HWACCEL_XPAN | in pm3fb_probe()
1403 info->flags |= FBINFO_HWACCEL_DISABLED; in pm3fb_probe()
1405 info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL); in pm3fb_probe()
1406 if (!info->pixmap.addr) { in pm3fb_probe()
1407 retval = -ENOMEM; in pm3fb_probe()
1410 info->pixmap.size = PM3_PIXMAP_SIZE; in pm3fb_probe()
1411 info->pixmap.buf_align = 4; in pm3fb_probe()
1412 info->pixmap.scan_align = 4; in pm3fb_probe()
1413 info->pixmap.access_align = 32; in pm3fb_probe()
1414 info->pixmap.flags = FB_PIXMAP_SYSTEM; in pm3fb_probe()
1423 retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8); in pm3fb_probe()
1426 retval = -EINVAL; in pm3fb_probe()
1430 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { in pm3fb_probe()
1431 retval = -ENOMEM; in pm3fb_probe()
1438 pm3fb_check_var(&info->var, info); in pm3fb_probe()
1441 retval = -EINVAL; in pm3fb_probe()
1444 fb_info(info, "%s frame buffer device\n", info->fix.id); in pm3fb_probe()
1449 fb_dealloc_cmap(&info->cmap); in pm3fb_probe()
1451 kfree(info->pixmap.addr); in pm3fb_probe()
1453 iounmap(info->screen_base); in pm3fb_probe()
1456 iounmap(par->v_regs); in pm3fb_probe()
1471 struct fb_fix_screeninfo *fix = &info->fix; in pm3fb_remove()
1472 struct pm3_par *par = info->par; in pm3fb_remove()
1475 fb_dealloc_cmap(&info->cmap); in pm3fb_remove()
1477 arch_phys_wc_del(par->wc_cookie); in pm3fb_remove()
1478 iounmap(info->screen_base); in pm3fb_remove()
1479 release_mem_region(fix->smem_start, fix->smem_len); in pm3fb_remove()
1480 iounmap(par->v_regs); in pm3fb_remove()
1481 release_mem_region(fix->mmio_start, fix->mmio_len); in pm3fb_remove()
1483 kfree(info->pixmap.addr); in pm3fb_remove()
1547 return -ENODEV; in pm3fb_init()
1551 return -ENODEV; in pm3fb_init()
1569 MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");