Lines Matching +full:sync +full:- +full:on +full:- +full:green
2 * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device
6 * Ported to 2.6 kernel on 1 May 2007 by Krzysztof Helt <krzysztof.h1@wp.pl>
7 * based on pm2fb.c
9 * Based on code written by:
10 * Sven Luther, <luther@dpt-info.u-strasbg.fr>
13 * Based on linux/drivers/video/skeletonfb.c:
15 * Based on linux/driver/video/pm2fb.c:
16 * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT)
96 return fb_readl(par->v_regs + off); in PM3_READ_REG()
101 fb_writel(v, par->v_regs + off); in PM3_WRITE_REG()
160 ? reqclock - freq in pm3fb_calculate_clock()
161 : freq - reqclock; in pm3fb_calculate_clock()
175 if (var->bits_per_pixel == 16) in pm3fb_depth()
176 return var->red.length + var->green.length in pm3fb_depth()
177 + var->blue.length; in pm3fb_depth()
179 return var->bits_per_pixel; in pm3fb_depth()
199 struct pm3_par *par = info->par; in pm3fb_sync()
215 struct pm3_par *par = info->par; in pm3fb_init_engine()
216 const u32 width = (info->var.xres_virtual + 7) & ~7; in pm3fb_init_engine()
289 switch (info->var.bits_per_pixel) { in pm3fb_init_engine()
310 info->var.bits_per_pixel); in pm3fb_init_engine()
331 unsigned long sofb = info->screen_size / in pm3fb_init_engine()
332 info->fix.line_length; in pm3fb_init_engine()
338 switch (info->var.bits_per_pixel) { in pm3fb_init_engine()
353 info->var.bits_per_pixel); in pm3fb_init_engine()
378 struct pm3_par *par = info->par; in pm3fb_fillrect()
382 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? in pm3fb_fillrect()
383 ((u32 *)info->pseudo_palette)[region->color] : region->color; in pm3fb_fillrect()
385 if (info->state != FBINFO_STATE_RUNNING) in pm3fb_fillrect()
387 if (info->flags & FBINFO_HWACCEL_DISABLED) { in pm3fb_fillrect()
391 if (region->rop == ROP_COPY ) in pm3fb_fillrect()
397 vxres = info->var.xres_virtual; in pm3fb_fillrect()
398 vyres = info->var.yres_virtual; in pm3fb_fillrect()
407 modded.width = vxres - modded.dx; in pm3fb_fillrect()
409 modded.height = vyres - modded.dy; in pm3fb_fillrect()
411 if (info->var.bits_per_pixel == 8) in pm3fb_fillrect()
413 if (info->var.bits_per_pixel <= 16) in pm3fb_fillrect()
442 struct pm3_par *par = info->par; in pm3fb_copyarea()
447 if (info->state != FBINFO_STATE_RUNNING) in pm3fb_copyarea()
449 if (info->flags & FBINFO_HWACCEL_DISABLED) { in pm3fb_copyarea()
456 vxres = info->var.xres_virtual; in pm3fb_copyarea()
457 vyres = info->var.yres_virtual; in pm3fb_copyarea()
465 modded.width = vxres - modded.sx; in pm3fb_copyarea()
467 modded.width = vxres - modded.dx; in pm3fb_copyarea()
469 modded.height = vyres - modded.sy; in pm3fb_copyarea()
471 modded.height = vyres - modded.dy; in pm3fb_copyarea()
473 o_x = modded.sx - modded.dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */ in pm3fb_copyarea()
474 o_y = modded.sy - modded.dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */ in pm3fb_copyarea()
498 PM3RectanglePosition_XOffset(modded.dx - x_align) | in pm3fb_copyarea()
513 struct pm3_par *par = info->par; in pm3fb_imageblit()
514 u32 height = image->height; in pm3fb_imageblit()
516 const u32 *src = (const u32 *)image->data; in pm3fb_imageblit()
518 if (info->state != FBINFO_STATE_RUNNING) in pm3fb_imageblit()
520 if (info->flags & FBINFO_HWACCEL_DISABLED) { in pm3fb_imageblit()
524 switch (info->fix.visual) { in pm3fb_imageblit()
526 fgx = image->fg_color; in pm3fb_imageblit()
527 bgx = image->bg_color; in pm3fb_imageblit()
531 fgx = par->palette[image->fg_color]; in pm3fb_imageblit()
532 bgx = par->palette[image->bg_color]; in pm3fb_imageblit()
535 if (image->depth != 1) { in pm3fb_imageblit()
540 if (info->var.bits_per_pixel == 8) { in pm3fb_imageblit()
544 if (info->var.bits_per_pixel <= 16) { in pm3fb_imageblit()
563 ((image->dy & 0x0fff) << 16) | (image->dx & 0x0fff)); in pm3fb_imageblit()
565 (((image->dy + image->height) & 0x0fff) << 16) | in pm3fb_imageblit()
566 ((image->dx + image->width) & 0x0fff)); in pm3fb_imageblit()
568 PM3RectanglePosition_XOffset(image->dx) | in pm3fb_imageblit()
569 PM3RectanglePosition_YOffset(image->dy)); in pm3fb_imageblit()
575 PM3Render2D_Width(image->width) | in pm3fb_imageblit()
576 PM3Render2D_Height(image->height)); in pm3fb_imageblit()
579 while (height--) { in pm3fb_imageblit()
580 int width = ((image->width + 7) >> 3) in pm3fb_imageblit()
581 + info->pixmap.scan_align - 1; in pm3fb_imageblit()
585 int i = PM3_FIFO_SIZE - 1; in pm3fb_imageblit()
588 while (i--) { in pm3fb_imageblit()
592 width -= PM3_FIFO_SIZE - 1; in pm3fb_imageblit()
596 while (width--) { in pm3fb_imageblit()
614 struct pm3_par *par = info->par; in pm3fb_cursor()
618 return -EINVAL; /* just to force soft_cursor() call */ in pm3fb_cursor()
620 /* Too large of a cursor or wrong bpp :-( */ in pm3fb_cursor()
621 if (cursor->image.width > 64 || in pm3fb_cursor()
622 cursor->image.height > 64 || in pm3fb_cursor()
623 cursor->image.depth > 1) in pm3fb_cursor()
624 return -EINVAL; in pm3fb_cursor()
627 if (cursor->enable) in pm3fb_cursor()
637 if (!cursor->set) in pm3fb_cursor()
640 if (cursor->set & FB_CUR_SETPOS) { in pm3fb_cursor()
641 int x = cursor->image.dx - info->var.xoffset; in pm3fb_cursor()
642 int y = cursor->image.dy - info->var.yoffset; in pm3fb_cursor()
650 if (cursor->set & FB_CUR_SETHOT) { in pm3fb_cursor()
652 cursor->hot.x & 0x3f); in pm3fb_cursor()
654 cursor->hot.y & 0x3f); in pm3fb_cursor()
657 if (cursor->set & FB_CUR_SETCMAP) { in pm3fb_cursor()
658 u32 fg_idx = cursor->image.fg_color; in pm3fb_cursor()
659 u32 bg_idx = cursor->image.bg_color; in pm3fb_cursor()
660 struct fb_cmap cmap = info->cmap; in pm3fb_cursor()
666 cmap.green[fg_idx] >> 8 ); in pm3fb_cursor()
673 cmap.green[bg_idx] >> 8 ); in pm3fb_cursor()
678 if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) { in pm3fb_cursor()
679 u8 *bitmap = (u8 *)cursor->image.data; in pm3fb_cursor()
680 u8 *mask = (u8 *)cursor->mask; in pm3fb_cursor()
684 for (i = 0; i < cursor->image.height; i++) { in pm3fb_cursor()
685 int j = (cursor->image.width + 7) >> 3; in pm3fb_cursor()
686 int k = 8 - j; in pm3fb_cursor()
688 for (; j > 0; j--) { in pm3fb_cursor()
691 if (cursor->rop == ROP_COPY) in pm3fb_cursor()
704 for (; k > 0; k--) { in pm3fb_cursor()
718 struct pm3_par *par = info->par; in pm3fb_write_mode()
721 const u32 hsstart = info->var.right_margin; in pm3fb_write_mode()
722 const u32 hsend = hsstart + info->var.hsync_len; in pm3fb_write_mode()
723 const u32 hbend = hsend + info->var.left_margin; in pm3fb_write_mode()
724 const u32 xres = (info->var.xres + 31) & ~31; in pm3fb_write_mode()
726 const u32 vsstart = info->var.lower_margin; in pm3fb_write_mode()
727 const u32 vsend = vsstart + info->var.vsync_len; in pm3fb_write_mode()
728 const u32 vbend = vsend + info->var.upper_margin; in pm3fb_write_mode()
729 const u32 vtotal = info->var.yres + vbend; in pm3fb_write_mode()
730 const u32 width = (info->var.xres_virtual + 7) & ~7; in pm3fb_write_mode()
731 const unsigned bpp = info->var.bits_per_pixel; in pm3fb_write_mode()
740 pm3fb_shift_bpp(bpp, htotal - 1)); in pm3fb_write_mode()
751 PM3_WRITE_REG(par, PM3VTotal, vtotal - 1); in pm3fb_write_mode()
752 PM3_WRITE_REG(par, PM3VsEnd, vsend - 1); in pm3fb_write_mode()
753 PM3_WRITE_REG(par, PM3VsStart, vsstart - 1); in pm3fb_write_mode()
802 * Oxygen VX1 - it appears that setting PM3VideoControl and in pm3fb_write_mode()
803 * then PM3RD_SyncControl to the same SYNC settings undoes in pm3fb_write_mode()
804 * any net change - they seem to xor together. Only set the in pm3fb_write_mode()
805 * sync options in PM3RD_SyncControl. --rmk in pm3fb_write_mode()
808 unsigned int video = par->video; in pm3fb_write_mode()
818 PM3_WRITE_REG(par, PM3ScreenBase, par->base); in pm3fb_write_mode()
827 unsigned long pixclock = PICOS2KHZ(info->var.pixclock); in pm3fb_write_mode()
844 if ((par->video & PM3VideoControl_HSYNC_MASK) == in pm3fb_write_mode()
847 if ((par->video & PM3VideoControl_VSYNC_MASK) == in pm3fb_write_mode()
856 switch (pm3fb_depth(&info->var)) { in pm3fb_write_mode()
914 unsigned bpp = var->red.length + var->green.length in pm3fb_check_var()
915 + var->blue.length + var->transp.length; in pm3fb_check_var()
917 if (bpp != var->bits_per_pixel) { in pm3fb_check_var()
920 switch (var->bits_per_pixel) { in pm3fb_check_var()
922 var->red.length = 8; in pm3fb_check_var()
923 var->green.length = 8; in pm3fb_check_var()
924 var->blue.length = 8; in pm3fb_check_var()
925 var->red.offset = 0; in pm3fb_check_var()
926 var->green.offset = 0; in pm3fb_check_var()
927 var->blue.offset = 0; in pm3fb_check_var()
928 var->transp.offset = 0; in pm3fb_check_var()
929 var->transp.length = 0; in pm3fb_check_var()
932 var->red.length = 5; in pm3fb_check_var()
933 var->blue.length = 5; in pm3fb_check_var()
934 var->green.length = 6; in pm3fb_check_var()
935 var->transp.length = 0; in pm3fb_check_var()
938 var->red.length = 8; in pm3fb_check_var()
939 var->green.length = 8; in pm3fb_check_var()
940 var->blue.length = 8; in pm3fb_check_var()
941 var->transp.length = 8; in pm3fb_check_var()
945 var->bits_per_pixel); in pm3fb_check_var()
946 return -EINVAL; in pm3fb_check_var()
950 if (var->bits_per_pixel > 8 ) { in pm3fb_check_var()
951 var->blue.offset = 0; in pm3fb_check_var()
952 var->green.offset = var->blue.length; in pm3fb_check_var()
953 var->red.offset = var->green.offset + var->green.length; in pm3fb_check_var()
954 var->transp.offset = var->red.offset + var->red.length; in pm3fb_check_var()
956 var->height = -1; in pm3fb_check_var()
957 var->width = -1; in pm3fb_check_var()
959 if (var->xres != var->xres_virtual) { in pm3fb_check_var()
962 return -EINVAL; in pm3fb_check_var()
965 if (var->yres > var->yres_virtual) { in pm3fb_check_var()
968 return -EINVAL; in pm3fb_check_var()
971 if (var->xoffset) { in pm3fb_check_var()
973 return -EINVAL; in pm3fb_check_var()
976 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { in pm3fb_check_var()
978 return -EINVAL; in pm3fb_check_var()
981 var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */ in pm3fb_check_var()
982 lpitch = var->xres * ((var->bits_per_pixel + 7) >> 3); in pm3fb_check_var()
984 if (var->xres < 200 || var->xres > 2048) { in pm3fb_check_var()
985 DPRINTK("width not supported: %u\n", var->xres); in pm3fb_check_var()
986 return -EINVAL; in pm3fb_check_var()
989 if (var->yres < 200 || var->yres > 4095) { in pm3fb_check_var()
990 DPRINTK("height not supported: %u\n", var->yres); in pm3fb_check_var()
991 return -EINVAL; in pm3fb_check_var()
994 if (lpitch * var->yres_virtual > info->fix.smem_len) { in pm3fb_check_var()
996 var->xres, var->yres_virtual, var->bits_per_pixel); in pm3fb_check_var()
997 return -EINVAL; in pm3fb_check_var()
1000 if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) { in pm3fb_check_var()
1002 PICOS2KHZ(var->pixclock)); in pm3fb_check_var()
1003 return -EINVAL; in pm3fb_check_var()
1006 var->accel_flags = 0; /* Can't mmap if this is on */ in pm3fb_check_var()
1009 var->xres, var->yres, var->bits_per_pixel); in pm3fb_check_var()
1015 struct pm3_par *par = info->par; in pm3fb_set_par()
1016 const u32 xres = (info->var.xres + 31) & ~31; in pm3fb_set_par()
1017 const unsigned bpp = info->var.bits_per_pixel; in pm3fb_set_par()
1019 par->base = pm3fb_shift_bpp(bpp, (info->var.yoffset * xres) in pm3fb_set_par()
1020 + info->var.xoffset); in pm3fb_set_par()
1021 par->video = 0; in pm3fb_set_par()
1023 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) in pm3fb_set_par()
1024 par->video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; in pm3fb_set_par()
1026 par->video |= PM3VideoControl_HSYNC_ACTIVE_LOW; in pm3fb_set_par()
1028 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) in pm3fb_set_par()
1029 par->video |= PM3VideoControl_VSYNC_ACTIVE_HIGH; in pm3fb_set_par()
1031 par->video |= PM3VideoControl_VSYNC_ACTIVE_LOW; in pm3fb_set_par()
1033 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) in pm3fb_set_par()
1034 par->video |= PM3VideoControl_LINE_DOUBLE_ON; in pm3fb_set_par()
1036 if ((info->var.activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) in pm3fb_set_par()
1037 par->video |= PM3VideoControl_ENABLE; in pm3fb_set_par()
1043 par->video |= PM3VideoControl_PIXELSIZE_8BIT; in pm3fb_set_par()
1046 par->video |= PM3VideoControl_PIXELSIZE_16BIT; in pm3fb_set_par()
1049 par->video |= PM3VideoControl_PIXELSIZE_32BIT; in pm3fb_set_par()
1056 info->fix.visual = in pm3fb_set_par()
1058 info->fix.line_length = ((info->var.xres_virtual + 7) >> 3) * bpp; in pm3fb_set_par()
1068 static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, in pm3fb_setcolreg() argument
1072 struct pm3_par *par = info->par; in pm3fb_setcolreg()
1075 return -EINVAL; in pm3fb_setcolreg()
1079 if (info->var.grayscale) in pm3fb_setcolreg()
1080 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; in pm3fb_setcolreg()
1083 * var->{color}.offset contains start of bitfield in pm3fb_setcolreg()
1084 * var->{color}.length contains length of bitfield in pm3fb_setcolreg()
1087 * (X << green.offset) | in pm3fb_setcolreg()
1089 * RAMDAC[X] is programmed to (red, green, blue) in pm3fb_setcolreg()
1090 * color depth = SUM(var->{color}.length) in pm3fb_setcolreg()
1093 * var->{color}.offset is 0 in pm3fb_setcolreg()
1094 * var->{color}.length contains width of DAC or the number in pm3fb_setcolreg()
1097 * RAMDAC[X] is programmed to (red, green, blue) in pm3fb_setcolreg()
1098 * color depth = var->{color}.length in pm3fb_setcolreg()
1105 #define CNVT_TOHW(val, width) ((((val) << (width)) + 0x7FFF - (val)) >> 16) in pm3fb_setcolreg()
1106 red = CNVT_TOHW(red, info->var.red.length); in pm3fb_setcolreg()
1107 green = CNVT_TOHW(green, info->var.green.length); in pm3fb_setcolreg()
1108 blue = CNVT_TOHW(blue, info->var.blue.length); in pm3fb_setcolreg()
1109 transp = CNVT_TOHW(transp, info->var.transp.length); in pm3fb_setcolreg()
1112 if (info->fix.visual == FB_VISUAL_TRUECOLOR || in pm3fb_setcolreg()
1113 info->fix.visual == FB_VISUAL_DIRECTCOLOR) { in pm3fb_setcolreg()
1117 return -EINVAL; in pm3fb_setcolreg()
1119 v = (red << info->var.red.offset) | in pm3fb_setcolreg()
1120 (green << info->var.green.offset) | in pm3fb_setcolreg()
1121 (blue << info->var.blue.offset) | in pm3fb_setcolreg()
1122 (transp << info->var.transp.offset); in pm3fb_setcolreg()
1124 switch (info->var.bits_per_pixel) { in pm3fb_setcolreg()
1129 ((u32 *)(info->pseudo_palette))[regno] = v; in pm3fb_setcolreg()
1133 } else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) in pm3fb_setcolreg()
1134 pm3fb_set_color(par, regno, red, green, blue); in pm3fb_setcolreg()
1142 struct pm3_par *par = info->par; in pm3fb_pan_display()
1143 const u32 xres = (info->var.xres + 31) & ~31; in pm3fb_pan_display()
1145 par->base = pm3fb_shift_bpp(info->var.bits_per_pixel, in pm3fb_pan_display()
1146 (var->yoffset * xres) in pm3fb_pan_display()
1147 + var->xoffset); in pm3fb_pan_display()
1149 PM3_WRITE_REG(par, PM3ScreenBase, par->base); in pm3fb_pan_display()
1155 struct pm3_par *par = info->par; in pm3fb_blank()
1156 u32 video = par->video; in pm3fb_blank()
1159 * Oxygen VX1 - it appears that setting PM3VideoControl and in pm3fb_blank()
1160 * then PM3RD_SyncControl to the same SYNC settings undoes in pm3fb_blank()
1161 * any net change - they seem to xor together. Only set the in pm3fb_blank()
1162 * sync options in PM3RD_SyncControl. --rmk in pm3fb_blank()
1217 /* ------------------------------------------------------------------------- */
1232 /* Linear frame buffer - request region and map it. */ in pm3fb_size_memory()
1246 /* TODO: card-specific stuff, *before* accessing *any* FB memory */ in pm3fb_size_memory()
1257 * nasty stuff IMHO ;-) in pm3fb_size_memory()
1288 fb_readl((screen_mem + ((i - 32) * 1048576))); in pm3fb_size_memory()
1314 struct device *device = &dev->dev; /* for pci drivers */ in pm3fb_probe()
1316 int retval = -ENXIO; in pm3fb_probe()
1329 return -ENOMEM; in pm3fb_probe()
1330 par = info->par; in pm3fb_probe()
1340 DPRINTK("Adjusting register base for big-endian.\n"); in pm3fb_probe()
1343 /* Registers - request region and map it. */ in pm3fb_probe()
1349 par->v_regs = in pm3fb_probe()
1351 if (!par->v_regs) { in pm3fb_probe()
1358 /* Linear frame buffer - request region and map it. */ in pm3fb_probe()
1362 printk(KERN_WARNING "pm3fb: Can't find memory on board.\n"); in pm3fb_probe()
1370 info->screen_base = ioremap_wc(pm3fb_fix.smem_start, in pm3fb_probe()
1372 if (!info->screen_base) { in pm3fb_probe()
1377 info->screen_size = pm3fb_fix.smem_len; in pm3fb_probe()
1380 par->wc_cookie = arch_phys_wc_add(pm3fb_fix.smem_start, in pm3fb_probe()
1382 info->fbops = &pm3fb_ops; in pm3fb_probe()
1384 par->video = PM3_READ_REG(par, PM3VideoControl); in pm3fb_probe()
1386 info->fix = pm3fb_fix; in pm3fb_probe()
1387 info->pseudo_palette = par->palette; in pm3fb_probe()
1388 info->flags = FBINFO_DEFAULT | in pm3fb_probe()
1397 info->flags |= FBINFO_HWACCEL_DISABLED; in pm3fb_probe()
1399 info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL); in pm3fb_probe()
1400 if (!info->pixmap.addr) { in pm3fb_probe()
1401 retval = -ENOMEM; in pm3fb_probe()
1404 info->pixmap.size = PM3_PIXMAP_SIZE; in pm3fb_probe()
1405 info->pixmap.buf_align = 4; in pm3fb_probe()
1406 info->pixmap.scan_align = 4; in pm3fb_probe()
1407 info->pixmap.access_align = 32; in pm3fb_probe()
1408 info->pixmap.flags = FB_PIXMAP_SYSTEM; in pm3fb_probe()
1417 retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8); in pm3fb_probe()
1420 retval = -EINVAL; in pm3fb_probe()
1424 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { in pm3fb_probe()
1425 retval = -ENOMEM; in pm3fb_probe()
1432 pm3fb_check_var(&info->var, info); in pm3fb_probe()
1435 retval = -EINVAL; in pm3fb_probe()
1438 fb_info(info, "%s frame buffer device\n", info->fix.id); in pm3fb_probe()
1443 fb_dealloc_cmap(&info->cmap); in pm3fb_probe()
1445 kfree(info->pixmap.addr); in pm3fb_probe()
1447 iounmap(info->screen_base); in pm3fb_probe()
1450 iounmap(par->v_regs); in pm3fb_probe()
1465 struct fb_fix_screeninfo *fix = &info->fix; in pm3fb_remove()
1466 struct pm3_par *par = info->par; in pm3fb_remove()
1469 fb_dealloc_cmap(&info->cmap); in pm3fb_remove()
1471 arch_phys_wc_del(par->wc_cookie); in pm3fb_remove()
1472 iounmap(info->screen_base); in pm3fb_remove()
1473 release_mem_region(fix->smem_start, fix->smem_len); in pm3fb_remove()
1474 iounmap(par->v_regs); in pm3fb_remove()
1475 release_mem_region(fix->mmio_start, fix->mmio_len); in pm3fb_remove()
1477 kfree(info->pixmap.addr); in pm3fb_remove()
1505 * otherwise we fall back on the generic fb_setup().
1540 return -ENODEV; in pm3fb_init()
1558 MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");