Lines Matching +full:clip +full:- +full:x +full:- +full:high
2 * linux/drivers/video/riva/fbdev.c - nVidia RIVA 128/TNT/TNT2 fb driver
6 * Copyright 1999-2000 Jeff Garzik
56 /* ------------------------------------------------------------------------- *
60 * ------------------------------------------------------------------------- */
91 /* ------------------------------------------------------------------------- *
95 * ------------------------------------------------------------------------- */
99 /* ------------------------------------------------------------------------- *
103 * ------------------------------------------------------------------------- */
195 /* ------------------------------------------------------------------------- *
199 * ------------------------------------------------------------------------- */
202 static int flatpanel = -1; /* Autodetect later */
203 static int forceCRTC = -1;
228 .height = -1,
229 .width = -1,
270 #define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX)
275 struct fb_info *info = pci_get_drvdata(par->pdev); in riva_bl_get_level_brightness()
280 nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; in riva_bl_get_level_brightness()
298 tmp_pmc = NV_RD32(par->riva.PMC, 0x10F0) & 0x0000FFFF; in riva_bl_update_status()
299 tmp_pcrt = NV_RD32(par->riva.PCRTC0, 0x081C) & 0xFFFFFFFC; in riva_bl_update_status()
305 NV_WR32(par->riva.PCRTC0, 0x081C, tmp_pcrt); in riva_bl_update_status()
306 NV_WR32(par->riva.PMC, 0x10F0, tmp_pmc); in riva_bl_update_status()
318 struct fb_info *info = pci_get_drvdata(par->pdev); in riva_bl_init()
322 if (!par->FlatPanel) in riva_bl_init()
331 snprintf(name, sizeof(name), "rivabl%d", info->node); in riva_bl_init()
335 props.max_brightness = FB_BACKLIGHT_LEVELS - 1; in riva_bl_init()
336 bd = backlight_device_register(name, info->device, par, &riva_bl_ops, in riva_bl_init()
339 info->bl_dev = NULL; in riva_bl_init()
344 info->bl_dev = bd; in riva_bl_init()
349 bd->props.brightness = bd->props.max_brightness; in riva_bl_init()
350 bd->props.power = FB_BLANK_UNBLANK; in riva_bl_init()
363 struct backlight_device *bd = info->bl_dev; in riva_bl_exit()
373 /* ------------------------------------------------------------------------- *
377 * ------------------------------------------------------------------------- */
382 VGA_WR08(par->riva.PCIO, 0x3d4, index); in CRTCout()
383 VGA_WR08(par->riva.PCIO, 0x3d5, val); in CRTCout()
389 VGA_WR08(par->riva.PCIO, 0x3d4, index); in CRTCin()
390 return (VGA_RD08(par->riva.PCIO, 0x3d5)); in CRTCin()
396 VGA_WR08(par->riva.PVIO, 0x3ce, index); in GRAout()
397 VGA_WR08(par->riva.PVIO, 0x3cf, val); in GRAout()
403 VGA_WR08(par->riva.PVIO, 0x3ce, index); in GRAin()
404 return (VGA_RD08(par->riva.PVIO, 0x3cf)); in GRAin()
410 VGA_WR08(par->riva.PVIO, 0x3c4, index); in SEQout()
411 VGA_WR08(par->riva.PVIO, 0x3c5, val); in SEQout()
417 VGA_WR08(par->riva.PVIO, 0x3c4, index); in SEQin()
418 return (VGA_RD08(par->riva.PVIO, 0x3c5)); in SEQin()
424 VGA_WR08(par->riva.PCIO, 0x3c0, index); in ATTRout()
425 VGA_WR08(par->riva.PCIO, 0x3c0, val); in ATTRout()
431 VGA_WR08(par->riva.PCIO, 0x3c0, index); in ATTRin()
432 return (VGA_RD08(par->riva.PCIO, 0x3c1)); in ATTRin()
437 VGA_WR08(par->riva.PVIO, 0x3c2, val); in MISCout()
442 return (VGA_RD08(par->riva.PVIO, 0x3cc)); in MISCin()
454 /* ------------------------------------------------------------------------- *
458 * ------------------------------------------------------------------------- */
461 * rivafb_load_cursor_image - load cursor image to hardware
466 * @bg: background color (ARGB1555) - alpha bit determines opacity
506 writel(tmp, &par->riva.CURSOR[k++]); in rivafb_load_cursor_image()
508 k += (MAX_CURS - w)/2; in rivafb_load_cursor_image()
512 /* ------------------------------------------------------------------------- *
516 * ------------------------------------------------------------------------- */
519 * riva_wclut - set CLUT entry
536 VGA_WR08(chip->PDIO, 0x3c8, regnum); in riva_wclut()
537 VGA_WR08(chip->PDIO, 0x3c9, red); in riva_wclut()
538 VGA_WR08(chip->PDIO, 0x3c9, green); in riva_wclut()
539 VGA_WR08(chip->PDIO, 0x3c9, blue); in riva_wclut()
543 * riva_rclut - read fromCLUT register
561 VGA_WR08(chip->PDIO, 0x3c7, regnum); in riva_rclut()
562 *red = VGA_RD08(chip->PDIO, 0x3c9); in riva_rclut()
563 *green = VGA_RD08(chip->PDIO, 0x3c9); in riva_rclut()
564 *blue = VGA_RD08(chip->PDIO, 0x3c9); in riva_rclut()
568 * riva_save_state - saves current chip state
584 par->riva.LockUnlock(&par->riva, 0); in riva_save_state()
586 par->riva.UnloadStateExt(&par->riva, ®s->ext); in riva_save_state()
588 regs->misc_output = MISCin(par); in riva_save_state()
591 regs->crtc[i] = CRTCin(par, i); in riva_save_state()
594 regs->attr[i] = ATTRin(par, i); in riva_save_state()
597 regs->gra[i] = GRAin(par, i); in riva_save_state()
600 regs->seq[i] = SEQin(par, i); in riva_save_state()
605 * riva_load_state - loads current chip state
620 RIVA_HW_STATE *state = ®s->ext; in riva_load_state()
626 par->riva.LockUnlock(&par->riva, 0); in riva_load_state()
628 par->riva.LoadStateExt(&par->riva, state); in riva_load_state()
630 MISCout(par, regs->misc_output); in riva_load_state()
638 CRTCout(par, i, regs->crtc[i]); in riva_load_state()
643 ATTRout(par, i, regs->attr[i]); in riva_load_state()
646 GRAout(par, i, regs->gra[i]); in riva_load_state()
649 SEQout(par, i, regs->seq[i]); in riva_load_state()
654 * riva_load_video_mode - calculate timings
669 struct riva_par *par = info->par; in riva_load_video_mode()
676 bpp = info->var.bits_per_pixel; in riva_load_video_mode()
677 if (bpp == 16 && info->var.green.length == 5) in riva_load_video_mode()
679 width = info->var.xres_virtual; in riva_load_video_mode()
680 hDisplaySize = info->var.xres; in riva_load_video_mode()
681 hDisplay = (hDisplaySize / 8) - 1; in riva_load_video_mode()
682 hStart = (hDisplaySize + info->var.right_margin) / 8 - 1; in riva_load_video_mode()
683 hEnd = (hDisplaySize + info->var.right_margin + in riva_load_video_mode()
684 info->var.hsync_len) / 8 - 1; in riva_load_video_mode()
685 hTotal = (hDisplaySize + info->var.right_margin + in riva_load_video_mode()
686 info->var.hsync_len + info->var.left_margin) / 8 - 5; in riva_load_video_mode()
690 height = info->var.yres_virtual; in riva_load_video_mode()
691 vDisplay = info->var.yres - 1; in riva_load_video_mode()
692 vStart = info->var.yres + info->var.lower_margin - 1; in riva_load_video_mode()
693 vEnd = info->var.yres + info->var.lower_margin + in riva_load_video_mode()
694 info->var.vsync_len - 1; in riva_load_video_mode()
695 vTotal = info->var.yres + info->var.lower_margin + in riva_load_video_mode()
696 info->var.vsync_len + info->var.upper_margin + 2; in riva_load_video_mode()
699 dotClock = 1000000000 / info->var.pixclock; in riva_load_video_mode()
703 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) in riva_load_video_mode()
706 if (par->FlatPanel) { in riva_load_video_mode()
707 vStart = vTotal - 3; in riva_load_video_mode()
708 vEnd = vTotal - 2; in riva_load_video_mode()
710 hStart = hTotal - 3; in riva_load_video_mode()
711 hEnd = hTotal - 2; in riva_load_video_mode()
755 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { in riva_load_video_mode()
762 if (par->riva.Architecture >= NV_ARCH_10) in riva_load_video_mode()
763 par->riva.CURSOR = (U032 __iomem *)(info->screen_base + par->riva.CursorStart); in riva_load_video_mode()
765 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) in riva_load_video_mode()
769 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) in riva_load_video_mode()
774 rc = CalcStateExt(&par->riva, &newmode.ext, par->pdev, bpp, width, in riva_load_video_mode()
779 newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) & in riva_load_video_mode()
781 if (par->FlatPanel == 1) { in riva_load_video_mode()
785 if (par->SecondCRTC) { in riva_load_video_mode()
786 newmode.ext.head = NV_RD32(par->riva.PCRTC0, 0x00000860) & in riva_load_video_mode()
788 newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) | in riva_load_video_mode()
793 } else if (par->riva.twoHeads) { in riva_load_video_mode()
794 newmode.ext.head = NV_RD32(par->riva.PCRTC0, 0x00000860) | in riva_load_video_mode()
796 newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) & in riva_load_video_mode()
799 newmode.ext.vpll2 = NV_RD32(par->riva.PRAMDAC0, 0x00000520); in riva_load_video_mode()
801 if (par->FlatPanel == 1) { in riva_load_video_mode()
806 par->current_state = newmode; in riva_load_video_mode()
807 riva_load_state(par, &par->current_state); in riva_load_video_mode()
808 par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */ in riva_load_video_mode()
821 var->xres = var->xres_virtual = modedb->xres; in riva_update_var()
822 var->yres = modedb->yres; in riva_update_var()
823 if (var->yres_virtual < var->yres) in riva_update_var()
824 var->yres_virtual = var->yres; in riva_update_var()
825 var->xoffset = var->yoffset = 0; in riva_update_var()
826 var->pixclock = modedb->pixclock; in riva_update_var()
827 var->left_margin = modedb->left_margin; in riva_update_var()
828 var->right_margin = modedb->right_margin; in riva_update_var()
829 var->upper_margin = modedb->upper_margin; in riva_update_var()
830 var->lower_margin = modedb->lower_margin; in riva_update_var()
831 var->hsync_len = modedb->hsync_len; in riva_update_var()
832 var->vsync_len = modedb->vsync_len; in riva_update_var()
833 var->sync = modedb->sync; in riva_update_var()
834 var->vmode = modedb->vmode; in riva_update_var()
839 * rivafb_do_maximize -
849 * -EINVAL on failure, 0 on success
867 {-1, -1} in rivafb_do_maximize()
873 if (var->xres_virtual == -1 && var->yres_virtual == -1) { in rivafb_do_maximize()
876 for (i = 0; modes[i].xres != -1; i++) { in rivafb_do_maximize()
878 info->fix.smem_len) in rivafb_do_maximize()
881 if (modes[i].xres == -1) { in rivafb_do_maximize()
884 NVTRACE("EXIT - EINVAL error\n"); in rivafb_do_maximize()
885 return -EINVAL; in rivafb_do_maximize()
887 var->xres_virtual = modes[i].xres; in rivafb_do_maximize()
888 var->yres_virtual = modes[i].yres; in rivafb_do_maximize()
892 var->xres_virtual, var->yres_virtual); in rivafb_do_maximize()
893 } else if (var->xres_virtual == -1) { in rivafb_do_maximize()
894 var->xres_virtual = (info->fix.smem_len * den / in rivafb_do_maximize()
895 (nom * var->yres_virtual)) & ~15; in rivafb_do_maximize()
897 "setting virtual X resolution to %d\n", var->xres_virtual); in rivafb_do_maximize()
898 } else if (var->yres_virtual == -1) { in rivafb_do_maximize()
899 var->xres_virtual = (var->xres_virtual + 15) & ~15; in rivafb_do_maximize()
900 var->yres_virtual = info->fix.smem_len * den / in rivafb_do_maximize()
901 (nom * var->xres_virtual); in rivafb_do_maximize()
903 "setting virtual Y resolution to %d\n", var->yres_virtual); in rivafb_do_maximize()
905 var->xres_virtual = (var->xres_virtual + 15) & ~15; in rivafb_do_maximize()
906 if (var->xres_virtual * nom / den * var->yres_virtual > info->fix.smem_len) { in rivafb_do_maximize()
908 "mode %dx%dx%d rejected...resolution too high to fit into video memory!\n", in rivafb_do_maximize()
909 var->xres, var->yres, var->bits_per_pixel); in rivafb_do_maximize()
910 NVTRACE("EXIT - EINVAL error\n"); in rivafb_do_maximize()
911 return -EINVAL; in rivafb_do_maximize()
915 if (var->xres_virtual * nom / den >= 8192) { in rivafb_do_maximize()
917 "virtual X resolution (%d) is too high, lowering to %d\n", in rivafb_do_maximize()
918 var->xres_virtual, 8192 * den / nom - 16); in rivafb_do_maximize()
919 var->xres_virtual = 8192 * den / nom - 16; in rivafb_do_maximize()
922 if (var->xres_virtual < var->xres) { in rivafb_do_maximize()
924 "virtual X resolution (%d) is smaller than real\n", var->xres_virtual); in rivafb_do_maximize()
925 return -EINVAL; in rivafb_do_maximize()
928 if (var->yres_virtual < var->yres) { in rivafb_do_maximize()
930 "virtual Y resolution (%d) is smaller than real\n", var->yres_virtual); in rivafb_do_maximize()
931 return -EINVAL; in rivafb_do_maximize()
933 if (var->yres_virtual > 0x7fff/nom) in rivafb_do_maximize()
934 var->yres_virtual = 0x7fff/nom; in rivafb_do_maximize()
935 if (var->xres_virtual > 0x7fff/nom) in rivafb_do_maximize()
936 var->xres_virtual = 0x7fff/nom; in rivafb_do_maximize()
944 RIVA_FIFO_FREE(par->riva, Patt, 4); in riva_set_pattern()
945 NV_WR32(&par->riva.Patt->Color0, 0, clr0); in riva_set_pattern()
946 NV_WR32(&par->riva.Patt->Color1, 0, clr1); in riva_set_pattern()
947 NV_WR32(par->riva.Patt->Monochrome, 0, pat0); in riva_set_pattern()
948 NV_WR32(par->riva.Patt->Monochrome, 4, pat1); in riva_set_pattern()
954 while (par->riva.Busy(&par->riva)); in wait_for_idle()
958 * Set ROP. Translate X rop into ROP3. Internal routine.
964 RIVA_FIFO_FREE(par->riva, Rop, 1); in riva_set_rop_solid()
965 NV_WR32(&par->riva.Rop->Rop3, 0, rop); in riva_set_rop_solid()
971 struct riva_par *par = info->par; in riva_setup_accel()
973 RIVA_FIFO_FREE(par->riva, Clip, 2); in riva_setup_accel()
974 NV_WR32(&par->riva.Clip->TopLeft, 0, 0x0); in riva_setup_accel()
975 NV_WR32(&par->riva.Clip->WidthHeight, 0, in riva_setup_accel()
976 (info->var.xres_virtual & 0xffff) | in riva_setup_accel()
977 (info->var.yres_virtual << 16)); in riva_setup_accel()
983 * riva_get_cmap_len - query current color map length
999 switch (var->green.length) { in riva_get_cmap_len()
1016 /* ------------------------------------------------------------------------- *
1020 * ------------------------------------------------------------------------- */
1024 struct riva_par *par = info->par; in rivafb_open()
1027 mutex_lock(&par->open_lock); in rivafb_open()
1028 if (!par->ref_count) { in rivafb_open()
1030 memset(&par->state, 0, sizeof(struct vgastate)); in rivafb_open()
1031 par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS; in rivafb_open()
1033 if (par->riva.Architecture == NV_ARCH_03) in rivafb_open()
1034 par->state.flags |= VGA_SAVE_CMAP; in rivafb_open()
1035 save_vga(&par->state); in rivafb_open()
1039 par->riva.LockUnlock(&par->riva, 0); in rivafb_open()
1041 riva_save_state(par, &par->initial_state); in rivafb_open()
1043 par->ref_count++; in rivafb_open()
1044 mutex_unlock(&par->open_lock); in rivafb_open()
1051 struct riva_par *par = info->par; in rivafb_release()
1054 mutex_lock(&par->open_lock); in rivafb_release()
1055 if (!par->ref_count) { in rivafb_release()
1056 mutex_unlock(&par->open_lock); in rivafb_release()
1057 return -EINVAL; in rivafb_release()
1059 if (par->ref_count == 1) { in rivafb_release()
1060 par->riva.LockUnlock(&par->riva, 0); in rivafb_release()
1061 par->riva.LoadStateExt(&par->riva, &par->initial_state.ext); in rivafb_release()
1062 riva_load_state(par, &par->initial_state); in rivafb_release()
1064 restore_vga(&par->state); in rivafb_release()
1066 par->riva.LockUnlock(&par->riva, 1); in rivafb_release()
1068 par->ref_count--; in rivafb_release()
1069 mutex_unlock(&par->open_lock); in rivafb_release()
1077 struct riva_par *par = info->par; in rivafb_check_var()
1078 int nom, den; /* translating from pixels->bytes */ in rivafb_check_var()
1082 if (!var->pixclock) in rivafb_check_var()
1083 return -EINVAL; in rivafb_check_var()
1085 switch (var->bits_per_pixel) { in rivafb_check_var()
1087 var->red.offset = var->green.offset = var->blue.offset = 0; in rivafb_check_var()
1088 var->red.length = var->green.length = var->blue.length = 8; in rivafb_check_var()
1089 var->bits_per_pixel = 8; in rivafb_check_var()
1093 var->green.length = 5; in rivafb_check_var()
1096 var->bits_per_pixel = 16; in rivafb_check_var()
1098 if (par->riva.Architecture == NV_ARCH_03) in rivafb_check_var()
1099 var->green.length = 5; in rivafb_check_var()
1100 if (var->green.length == 5) { in rivafb_check_var()
1102 var->red.offset = 10; in rivafb_check_var()
1103 var->green.offset = 5; in rivafb_check_var()
1104 var->blue.offset = 0; in rivafb_check_var()
1105 var->red.length = 5; in rivafb_check_var()
1106 var->green.length = 5; in rivafb_check_var()
1107 var->blue.length = 5; in rivafb_check_var()
1110 var->red.offset = 11; in rivafb_check_var()
1111 var->green.offset = 5; in rivafb_check_var()
1112 var->blue.offset = 0; in rivafb_check_var()
1113 var->red.length = 5; in rivafb_check_var()
1114 var->green.length = 6; in rivafb_check_var()
1115 var->blue.length = 5; in rivafb_check_var()
1121 var->red.length = var->green.length = var->blue.length = 8; in rivafb_check_var()
1122 var->bits_per_pixel = 32; in rivafb_check_var()
1123 var->red.offset = 16; in rivafb_check_var()
1124 var->green.offset = 8; in rivafb_check_var()
1125 var->blue.offset = 0; in rivafb_check_var()
1132 var->xres, var->yres, var->bits_per_pixel); in rivafb_check_var()
1133 NVTRACE("EXIT, returning -EINVAL\n"); in rivafb_check_var()
1134 return -EINVAL; in rivafb_check_var()
1138 if (!info->monspecs.vfmax || !info->monspecs.hfmax || in rivafb_check_var()
1139 !info->monspecs.dclkmax || !fb_validate_mode(var, info)) in rivafb_check_var()
1144 if (!mode_valid && info->monspecs.gtf) { in rivafb_check_var()
1150 mode = fb_find_best_mode(var, &info->modelist); in rivafb_check_var()
1157 if (!mode_valid && info->monspecs.modedb_len) in rivafb_check_var()
1158 return -EINVAL; in rivafb_check_var()
1160 if (var->xres_virtual < var->xres) in rivafb_check_var()
1161 var->xres_virtual = var->xres; in rivafb_check_var()
1162 if (var->yres_virtual <= var->yres) in rivafb_check_var()
1163 var->yres_virtual = -1; in rivafb_check_var()
1165 return -EINVAL; in rivafb_check_var()
1167 /* truncate xoffset and yoffset to maximum if too high */ in rivafb_check_var()
1168 if (var->xoffset > var->xres_virtual - var->xres) in rivafb_check_var()
1169 var->xoffset = var->xres_virtual - var->xres - 1; in rivafb_check_var()
1171 if (var->yoffset > var->yres_virtual - var->yres) in rivafb_check_var()
1172 var->yoffset = var->yres_virtual - var->yres - 1; in rivafb_check_var()
1174 var->red.msb_right = in rivafb_check_var()
1175 var->green.msb_right = in rivafb_check_var()
1176 var->blue.msb_right = in rivafb_check_var()
1177 var->transp.offset = var->transp.length = var->transp.msb_right = 0; in rivafb_check_var()
1184 struct riva_par *par = info->par; in rivafb_set_par()
1190 par->riva.LockUnlock(&par->riva, 0); in rivafb_set_par()
1194 if(!(info->flags & FBINFO_HWACCEL_DISABLED)) in rivafb_set_par()
1197 par->cursor_reset = 1; in rivafb_set_par()
1198 info->fix.line_length = (info->var.xres_virtual * (info->var.bits_per_pixel >> 3)); in rivafb_set_par()
1199 info->fix.visual = (info->var.bits_per_pixel == 8) ? in rivafb_set_par()
1202 if (info->flags & FBINFO_HWACCEL_DISABLED) in rivafb_set_par()
1203 info->pixmap.scan_align = 1; in rivafb_set_par()
1205 info->pixmap.scan_align = 4; in rivafb_set_par()
1220 * If the values don't fit, return -EINVAL.
1227 struct riva_par *par = info->par; in rivafb_pan_display()
1231 base = var->yoffset * info->fix.line_length + var->xoffset; in rivafb_pan_display()
1232 par->riva.SetStartAddress(&par->riva, base); in rivafb_pan_display()
1239 struct riva_par *par= info->par; in rivafb_blank()
1296 struct riva_par *par = info->par; in rivafb_setcolreg()
1297 RIVA_HW_INST *chip = &par->riva; in rivafb_setcolreg()
1300 if (regno >= riva_get_cmap_len(&info->var)) in rivafb_setcolreg()
1301 return -EINVAL; in rivafb_setcolreg()
1303 if (info->var.grayscale) { in rivafb_setcolreg()
1309 if (regno < 16 && info->fix.visual == FB_VISUAL_DIRECTCOLOR) { in rivafb_setcolreg()
1310 ((u32 *) info->pseudo_palette)[regno] = in rivafb_setcolreg()
1311 (regno << info->var.red.offset) | in rivafb_setcolreg()
1312 (regno << info->var.green.offset) | in rivafb_setcolreg()
1313 (regno << info->var.blue.offset); in rivafb_setcolreg()
1318 if (par->riva.Architecture == NV_ARCH_03) { in rivafb_setcolreg()
1319 switch (info->var.bits_per_pixel) { in rivafb_setcolreg()
1321 par->palette[regno] = ((red & 0xf800) >> 1) | in rivafb_setcolreg()
1326 par->palette[regno] = ((red & 0xff00) << 8) | in rivafb_setcolreg()
1334 switch (info->var.bits_per_pixel) { in rivafb_setcolreg()
1340 if (info->var.green.length == 5) { in rivafb_setcolreg()
1372 * rivafb_fillrect - hardware accelerated color fill function
1385 struct riva_par *par = info->par; in rivafb_fillrect()
1388 if ((info->flags & FBINFO_HWACCEL_DISABLED)) { in rivafb_fillrect()
1393 if (info->var.bits_per_pixel == 8) in rivafb_fillrect()
1394 color = rect->color; in rivafb_fillrect()
1396 if (par->riva.Architecture != NV_ARCH_03) in rivafb_fillrect()
1397 color = ((u32 *)info->pseudo_palette)[rect->color]; in rivafb_fillrect()
1399 color = par->palette[rect->color]; in rivafb_fillrect()
1402 switch (rect->rop) { in rivafb_fillrect()
1414 RIVA_FIFO_FREE(par->riva, Bitmap, 1); in rivafb_fillrect()
1415 NV_WR32(&par->riva.Bitmap->Color1A, 0, color); in rivafb_fillrect()
1417 RIVA_FIFO_FREE(par->riva, Bitmap, 2); in rivafb_fillrect()
1418 NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].TopLeft, 0, in rivafb_fillrect()
1419 (rect->dx << 16) | rect->dy); in rivafb_fillrect()
1421 NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].WidthHeight, 0, in rivafb_fillrect()
1422 (rect->width << 16) | rect->height); in rivafb_fillrect()
1429 * rivafb_copyarea - hardware accelerated blit function
1441 struct riva_par *par = info->par; in rivafb_copyarea()
1443 if ((info->flags & FBINFO_HWACCEL_DISABLED)) { in rivafb_copyarea()
1448 RIVA_FIFO_FREE(par->riva, Blt, 3); in rivafb_copyarea()
1449 NV_WR32(&par->riva.Blt->TopLeftSrc, 0, in rivafb_copyarea()
1450 (region->sy << 16) | region->sx); in rivafb_copyarea()
1451 NV_WR32(&par->riva.Blt->TopLeftDst, 0, in rivafb_copyarea()
1452 (region->dy << 16) | region->dx); in rivafb_copyarea()
1454 NV_WR32(&par->riva.Blt->WidthHeight, 0, in rivafb_copyarea()
1455 (region->height << 16) | region->width); in rivafb_copyarea()
1476 * setting of the bitmap, 1 - foreground, 0 - background.
1487 struct riva_par *par = info->par; in rivafb_imageblit()
1489 u8 *cdat = (u8 *) image->data; in rivafb_imageblit()
1493 if ((info->flags & FBINFO_HWACCEL_DISABLED) || image->depth != 1) { in rivafb_imageblit()
1498 switch (info->var.bits_per_pixel) { in rivafb_imageblit()
1500 fgx = image->fg_color; in rivafb_imageblit()
1501 bgx = image->bg_color; in rivafb_imageblit()
1505 if (par->riva.Architecture != NV_ARCH_03) { in rivafb_imageblit()
1506 fgx = ((u32 *)info->pseudo_palette)[image->fg_color]; in rivafb_imageblit()
1507 bgx = ((u32 *)info->pseudo_palette)[image->bg_color]; in rivafb_imageblit()
1509 fgx = par->palette[image->fg_color]; in rivafb_imageblit()
1510 bgx = par->palette[image->bg_color]; in rivafb_imageblit()
1512 if (info->var.green.length == 6) in rivafb_imageblit()
1517 RIVA_FIFO_FREE(par->riva, Bitmap, 7); in rivafb_imageblit()
1518 NV_WR32(&par->riva.Bitmap->ClipE.TopLeft, 0, in rivafb_imageblit()
1519 (image->dy << 16) | (image->dx & 0xFFFF)); in rivafb_imageblit()
1520 NV_WR32(&par->riva.Bitmap->ClipE.BottomRight, 0, in rivafb_imageblit()
1521 (((image->dy + image->height) << 16) | in rivafb_imageblit()
1522 ((image->dx + image->width) & 0xffff))); in rivafb_imageblit()
1523 NV_WR32(&par->riva.Bitmap->Color0E, 0, bgx); in rivafb_imageblit()
1524 NV_WR32(&par->riva.Bitmap->Color1E, 0, fgx); in rivafb_imageblit()
1525 NV_WR32(&par->riva.Bitmap->WidthHeightInE, 0, in rivafb_imageblit()
1526 (image->height << 16) | ((image->width + 31) & ~31)); in rivafb_imageblit()
1527 NV_WR32(&par->riva.Bitmap->WidthHeightOutE, 0, in rivafb_imageblit()
1528 (image->height << 16) | ((image->width + 31) & ~31)); in rivafb_imageblit()
1529 NV_WR32(&par->riva.Bitmap->PointE, 0, in rivafb_imageblit()
1530 (image->dy << 16) | (image->dx & 0xFFFF)); in rivafb_imageblit()
1532 d = &par->riva.Bitmap->MonochromeData01E; in rivafb_imageblit()
1534 width = (image->width + 31)/32; in rivafb_imageblit()
1535 size = width * image->height; in rivafb_imageblit()
1537 RIVA_FIFO_FREE(par->riva, Bitmap, 16); in rivafb_imageblit()
1544 size -= 16; in rivafb_imageblit()
1547 RIVA_FIFO_FREE(par->riva, Bitmap, size); in rivafb_imageblit()
1558 * rivafb_cursor - hardware cursor function
1572 struct riva_par *par = info->par; in rivafb_cursor()
1574 int i, set = cursor->set; in rivafb_cursor()
1577 if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS) in rivafb_cursor()
1578 return -ENXIO; in rivafb_cursor()
1580 par->riva.ShowHideCursor(&par->riva, 0); in rivafb_cursor()
1582 if (par->cursor_reset) { in rivafb_cursor()
1584 par->cursor_reset = 0; in rivafb_cursor()
1588 memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2); in rivafb_cursor()
1593 yy = cursor->image.dy - info->var.yoffset; in rivafb_cursor()
1594 xx = cursor->image.dx - info->var.xoffset; in rivafb_cursor()
1598 NV_WR32(par->riva.PRAMDAC, 0x0000300, temp); in rivafb_cursor()
1603 u32 bg_idx = cursor->image.bg_color; in rivafb_cursor()
1604 u32 fg_idx = cursor->image.fg_color; in rivafb_cursor()
1605 u32 s_pitch = (cursor->image.width+7) >> 3; in rivafb_cursor()
1607 u8 *dat = (u8 *) cursor->image.data; in rivafb_cursor()
1608 u8 *msk = (u8 *) cursor->mask; in rivafb_cursor()
1611 src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC); in rivafb_cursor()
1614 switch (cursor->rop) { in rivafb_cursor()
1616 for (i = 0; i < s_pitch * cursor->image.height; i++) in rivafb_cursor()
1621 for (i = 0; i < s_pitch * cursor->image.height; i++) in rivafb_cursor()
1627 cursor->image.height); in rivafb_cursor()
1629 bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) | in rivafb_cursor()
1630 ((info->cmap.green[bg_idx] & 0xf8) << 2) | in rivafb_cursor()
1631 ((info->cmap.blue[bg_idx] & 0xf8) >> 3) | in rivafb_cursor()
1634 fg = ((info->cmap.red[fg_idx] & 0xf8) << 7) | in rivafb_cursor()
1635 ((info->cmap.green[fg_idx] & 0xf8) << 2) | in rivafb_cursor()
1636 ((info->cmap.blue[fg_idx] & 0xf8) >> 3) | in rivafb_cursor()
1639 par->riva.LockUnlock(&par->riva, 0); in rivafb_cursor()
1642 cursor->image.width, in rivafb_cursor()
1643 cursor->image.height); in rivafb_cursor()
1648 if (cursor->enable) in rivafb_cursor()
1649 par->riva.ShowHideCursor(&par->riva, 1); in rivafb_cursor()
1656 struct riva_par *par = info->par; in rivafb_sync()
1662 /* ------------------------------------------------------------------------- *
1666 * ------------------------------------------------------------------------- */
1690 struct riva_par *par = info->par; in riva_set_fbinfo()
1693 info->flags = FBINFO_HWACCEL_XPAN in riva_set_fbinfo()
1700 if ((par->riva.Architecture == NV_ARCH_30) || noaccel) { in riva_set_fbinfo()
1702 info->flags |= FBINFO_HWACCEL_DISABLED; in riva_set_fbinfo()
1705 info->var = rivafb_default_var; in riva_set_fbinfo()
1706 info->fix.visual = (info->var.bits_per_pixel == 8) ? in riva_set_fbinfo()
1709 info->pseudo_palette = par->pseudo_palette; in riva_set_fbinfo()
1711 cmap_len = riva_get_cmap_len(&info->var); in riva_set_fbinfo()
1712 fb_alloc_cmap(&info->cmap, cmap_len, 0); in riva_set_fbinfo()
1714 info->pixmap.size = 8 * 1024; in riva_set_fbinfo()
1715 info->pixmap.buf_align = 4; in riva_set_fbinfo()
1716 info->pixmap.access_align = 32; in riva_set_fbinfo()
1717 info->pixmap.flags = FB_PIXMAP_SYSTEM; in riva_set_fbinfo()
1718 info->var.yres_virtual = -1; in riva_set_fbinfo()
1720 return (rivafb_check_var(&info->var, info)); in riva_set_fbinfo()
1725 struct riva_par *par = info->par; in riva_get_EDID_OF()
1735 for (; dp != NULL; dp = dp->child) { in riva_get_EDID_OF()
1736 disptype = of_get_property(dp, "display-type", NULL); in riva_get_EDID_OF()
1744 par->EDID = (unsigned char *)pedid; in riva_get_EDID_OF()
1757 struct riva_par *par = info->par; in riva_get_EDID_i2c()
1762 par->riva.LockUnlock(&par->riva, 0); in riva_get_EDID_i2c()
1765 if (!par->chan[i].par) in riva_get_EDID_i2c()
1767 riva_probe_i2c_connector(par, i, &par->EDID); in riva_get_EDID_i2c()
1768 if (par->EDID && !fb_parse_edid(par->EDID, &var)) { in riva_get_EDID_i2c()
1775 return (par->EDID) ? 1 : 0; in riva_get_EDID_i2c()
1782 struct fb_monspecs *specs = &info->monspecs; in riva_update_default_var()
1789 specs->modedb, specs->modedb_len, in riva_update_default_var()
1791 } else if (specs->modedb != NULL) { in riva_update_default_var()
1793 modedb = specs->modedb[0]; in riva_update_default_var()
1795 if (info->monspecs.misc & FB_MISC_1ST_DETAIL) { in riva_update_default_var()
1798 for (i = 0; i < specs->modedb_len; i++) { in riva_update_default_var()
1799 if (specs->modedb[i].flag & FB_MODE_IS_FIRST) { in riva_update_default_var()
1800 modedb = specs->modedb[i]; in riva_update_default_var()
1805 var->bits_per_pixel = 8; in riva_update_default_var()
1832 struct riva_par *par = info->par; in riva_get_edidinfo()
1834 fb_edid_to_monspecs(par->EDID, &info->monspecs); in riva_get_edidinfo()
1835 fb_videomode_to_modelist(info->monspecs.modedb, info->monspecs.modedb_len, in riva_get_edidinfo()
1836 &info->modelist); in riva_get_edidinfo()
1840 if (info->monspecs.input & FB_DISP_DDI) in riva_get_edidinfo()
1841 par->FlatPanel = 1; in riva_get_edidinfo()
1844 /* ------------------------------------------------------------------------- *
1848 * ------------------------------------------------------------------------- */
1854 switch (pd->device & 0x0ff0) { in riva_get_arch()
1859 case 0x0180: /* GeForce4 MX (8x AGP) */ in riva_get_arch()
1866 case 0x0280: /* GeForce4 Ti (8x AGP) */ in riva_get_arch()
1901 info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev); in rivafb_probe()
1903 ret = -ENOMEM; in rivafb_probe()
1906 default_par = info->par; in rivafb_probe()
1907 default_par->pdev = pd; in rivafb_probe()
1909 info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL); in rivafb_probe()
1910 if (info->pixmap.addr == NULL) { in rivafb_probe()
1911 ret = -ENOMEM; in rivafb_probe()
1927 mutex_init(&default_par->open_lock); in rivafb_probe()
1928 default_par->riva.Architecture = riva_get_arch(pd); in rivafb_probe()
1930 default_par->Chipset = (pd->vendor << 16) | pd->device; in rivafb_probe()
1931 printk(KERN_INFO PFX "nVidia device/chipset %X\n",default_par->Chipset); in rivafb_probe()
1933 if(default_par->riva.Architecture == 0) { in rivafb_probe()
1935 ret=-ENODEV; in rivafb_probe()
1938 if(default_par->riva.Architecture == NV_ARCH_10 || in rivafb_probe()
1939 default_par->riva.Architecture == NV_ARCH_20 || in rivafb_probe()
1940 default_par->riva.Architecture == NV_ARCH_30) { in rivafb_probe()
1941 sprintf(rivafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4); in rivafb_probe()
1943 sprintf(rivafb_fix.id, "NV%x", default_par->riva.Architecture); in rivafb_probe()
1946 default_par->FlatPanel = flatpanel; in rivafb_probe()
1949 default_par->forceCRTC = forceCRTC; in rivafb_probe()
1966 default_par->ctrl_base = ioremap(rivafb_fix.mmio_start, in rivafb_probe()
1968 if (!default_par->ctrl_base) { in rivafb_probe()
1970 ret = -EIO; in rivafb_probe()
1974 switch (default_par->riva.Architecture) { in rivafb_probe()
1980 default_par->riva.PRAMIN = ioremap(rivafb_fix.smem_start + 0x00C00000, 0x00008000); in rivafb_probe()
1981 if (!default_par->riva.PRAMIN) { in rivafb_probe()
1983 ret = -EIO; in rivafb_probe()
1991 default_par->riva.PCRTC0 = in rivafb_probe()
1992 (u32 __iomem *)(default_par->ctrl_base + 0x00600000); in rivafb_probe()
1993 default_par->riva.PRAMIN = in rivafb_probe()
1994 (u32 __iomem *)(default_par->ctrl_base + 0x00710000); in rivafb_probe()
1999 if (default_par->riva.Architecture == NV_ARCH_03) { in rivafb_probe()
2000 default_par->riva.PCRTC = default_par->riva.PCRTC0 in rivafb_probe()
2001 = default_par->riva.PGRAPH; in rivafb_probe()
2005 default_par->dclk_max = riva_get_maxdclk(default_par) * 1000; in rivafb_probe()
2006 info->screen_base = ioremap_wc(rivafb_fix.smem_start, in rivafb_probe()
2008 if (!info->screen_base) { in rivafb_probe()
2010 ret = -EIO; in rivafb_probe()
2015 default_par->wc_cookie = in rivafb_probe()
2019 info->fbops = &riva_fb_ops; in rivafb_probe()
2020 info->fix = rivafb_fix; in rivafb_probe()
2030 fb_destroy_modedb(info->monspecs.modedb); in rivafb_probe()
2031 info->monspecs.modedb = NULL; in rivafb_probe()
2043 riva_bl_init(info->par); in rivafb_probe()
2046 "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n", in rivafb_probe()
2047 info->fix.id, in rivafb_probe()
2049 info->fix.smem_len / (1024 * 1024), in rivafb_probe()
2050 info->fix.smem_start); in rivafb_probe()
2057 riva_delete_i2c_busses(info->par); in rivafb_probe()
2059 iounmap(info->screen_base); in rivafb_probe()
2061 if (default_par->riva.Architecture == NV_ARCH_03) in rivafb_probe()
2062 iounmap(default_par->riva.PRAMIN); in rivafb_probe()
2064 iounmap(default_par->ctrl_base); in rivafb_probe()
2069 kfree(info->pixmap.addr); in rivafb_probe()
2079 struct riva_par *par = info->par; in rivafb_remove()
2085 kfree(par->EDID); in rivafb_remove()
2091 arch_phys_wc_del(par->wc_cookie); in rivafb_remove()
2092 iounmap(par->ctrl_base); in rivafb_remove()
2093 iounmap(info->screen_base); in rivafb_remove()
2094 if (par->riva.Architecture == NV_ARCH_03) in rivafb_remove()
2095 iounmap(par->riva.PRAMIN); in rivafb_remove()
2097 kfree(info->pixmap.addr); in rivafb_remove()
2102 /* ------------------------------------------------------------------------- *
2106 * ------------------------------------------------------------------------- */
2123 forceCRTC = *p - '0'; in rivafb_setup()
2125 forceCRTC = -1; in rivafb_setup()
2153 /* ------------------------------------------------------------------------- *
2157 * ------------------------------------------------------------------------- */
2166 return -ENODEV; in rivafb_init()
2170 return -ENODEV; in rivafb_init()