Lines Matching +full:mc +full:- +full:sid
1 // SPDX-License-Identifier: GPL-2.0-only
6 * (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
33 * "Gerd Knorr" <kraxel@goldbach.isdn.cs.tu-berlin.de>
57 * "Ulf Jaenicke-Roessler" <ujr@physik.phy.tu-dresden.de>
73 * G400 MAX/non-MAX distinction
81 * "Denis Zaitsev" <zzz@cd-club.ru>
84 * "Mike Pieper" <mike@pieper-family.de>
94 * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
128 /* --------------------------------------------------------------------- */
134 /* --------------------------------------------------------------------- */
138 0,0, /* virtual -> visible no offset */
139 8, /* depth -> load bits_per_pixel */
147 -1,-1,
156 /* --------------------------------------------------------------------- */
159 struct matroxfb_dh_fb_info *info = minfo->crtc2.info; in update_crtc2()
162 if (info && (info->fbcon.var.bits_per_pixel == minfo->fbcon.var.bits_per_pixel) in update_crtc2()
163 && (info->fbcon.var.xres_virtual == minfo->fbcon.var.xres_virtual) in update_crtc2()
164 && (info->fbcon.var.green.length == minfo->fbcon.var.green.length) in update_crtc2()
166 switch (minfo->fbcon.var.bits_per_pixel) { in update_crtc2()
170 if (info->interlaced) { in update_crtc2()
172 mga_outl(0x3C28, pos + minfo->fbcon.var.xres_virtual * minfo->fbcon.var.bits_per_pixel / 8); in update_crtc2()
183 if (minfo->crtc1.panpos >= 0) { in matroxfb_crtc1_panpos()
188 panpos = minfo->crtc1.panpos; in matroxfb_crtc1_panpos()
192 minfo->crtc1.panpos = -1; /* No update pending anymore */ in matroxfb_crtc1_panpos()
213 minfo->crtc1.vsync.cnt++; in matrox_irq()
215 wake_up_interruptible(&minfo->crtc1.vsync.wait); in matrox_irq()
220 minfo->crtc2.vsync.cnt++; in matrox_irq()
221 wake_up_interruptible(&minfo->crtc2.vsync.wait); in matrox_irq()
231 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) in matroxfb_enable_irq()
236 if (!test_and_set_bit(0, &minfo->irq_flags)) { in matroxfb_enable_irq()
237 if (request_irq(minfo->pcidev->irq, matrox_irq, in matroxfb_enable_irq()
239 clear_bit(0, &minfo->irq_flags); in matroxfb_enable_irq()
240 return -EINVAL; in matroxfb_enable_irq()
259 if (test_and_clear_bit(0, &minfo->irq_flags)) { in matroxfb_disable_irq()
260 /* Flush pending pan-at-vbl request... */ in matroxfb_disable_irq()
262 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) in matroxfb_disable_irq()
266 free_irq(minfo->pcidev->irq, minfo); in matroxfb_disable_irq()
278 vs = &minfo->crtc1.vsync; in matroxfb_wait_for_sync()
281 if (minfo->devflags.accelerator != FB_ACCEL_MATROX_MGAG400) { in matroxfb_wait_for_sync()
282 return -ENODEV; in matroxfb_wait_for_sync()
284 vs = &minfo->crtc2.vsync; in matroxfb_wait_for_sync()
287 return -ENODEV; in matroxfb_wait_for_sync()
294 cnt = vs->cnt; in matroxfb_wait_for_sync()
295 ret = wait_event_interruptible_timeout(vs->wait, cnt != vs->cnt, HZ/10); in matroxfb_wait_for_sync()
301 return -ETIMEDOUT; in matroxfb_wait_for_sync()
306 /* --------------------------------------------------------------------- */
321 if (minfo->dead) in matrox_pan_var()
324 minfo->fbcon.var.xoffset = var->xoffset; in matrox_pan_var()
325 minfo->fbcon.var.yoffset = var->yoffset; in matrox_pan_var()
326 …pos = (minfo->fbcon.var.yoffset * minfo->fbcon.var.xres_virtual + minfo->fbcon.var.xoffset) * minf… in matrox_pan_var()
327 pos += minfo->curr.ydstorg.chunks; in matrox_pan_var()
328 p0 = minfo->hw.CRTC[0x0D] = pos & 0xFF; in matrox_pan_var()
329 p1 = minfo->hw.CRTC[0x0C] = (pos & 0xFF00) >> 8; in matrox_pan_var()
330 …p2 = minfo->hw.CRTCEXT[0] = (minfo->hw.CRTCEXT[0] & 0xB0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & … in matrox_pan_var()
331 p3 = minfo->hw.CRTCEXT[8] = pos >> 21; in matrox_pan_var()
334 vbl = (var->activate & FB_ACTIVATE_VBL) && (matroxfb_enable_irq(minfo, 0) == 0); in matrox_pan_var()
341 if (minfo->devflags.support32MB) in matrox_pan_var()
344 minfo->crtc1.panpos = p2; in matrox_pan_var()
347 minfo->crtc1.panpos = -1; in matrox_pan_var()
361 * framebuffer and iounmap memory, neither fbmem nor fbcon-cfb* does not check in matroxfb_remove()
367 minfo->dead = 1; in matroxfb_remove()
368 if (minfo->usecount) { in matroxfb_remove()
373 unregister_framebuffer(&minfo->fbcon); in matroxfb_remove()
375 arch_phys_wc_del(minfo->wc_cookie); in matroxfb_remove()
376 iounmap(minfo->mmio.vbase.vaddr); in matroxfb_remove()
377 iounmap(minfo->video.vbase.vaddr); in matroxfb_remove()
378 release_mem_region(minfo->video.base, minfo->video.len_maximum); in matroxfb_remove()
379 release_mem_region(minfo->mmio.base, 16384); in matroxfb_remove()
393 if (minfo->dead) { in matroxfb_open()
394 return -ENXIO; in matroxfb_open()
396 minfo->usecount++; in matroxfb_open()
398 minfo->userusecount++; in matroxfb_open()
410 if (0 == --minfo->userusecount) { in matroxfb_release()
414 if (!(--minfo->usecount) && minfo->dead) { in matroxfb_release()
443 if (minfo->devflags.video64bits) in matroxfb_get_final_bppShift()
468 if (minfo->devflags.accelerator == FB_ACCEL_MATROX_MGAG400) in matroxfb_test_and_set_rounding()
477 xres += rounding-over; in matroxfb_test_and_set_rounding()
491 width = minfo->capable.vxres; in matroxfb_pitch_adjust()
493 if (minfo->devflags.precise_width) { in matroxfb_pitch_adjust()
511 switch (var->bits_per_pixel) { in matroxfb_get_cmap_len()
552 unsigned int bpp = var->bits_per_pixel; in matroxfb_decode_var()
559 case 4: if (!minfo->capable.cfb4) return -EINVAL; in matroxfb_decode_var()
565 default: return -EINVAL; in matroxfb_decode_var()
568 vramlen = minfo->video.len_usable; in matroxfb_decode_var()
569 if (var->yres_virtual < var->yres) in matroxfb_decode_var()
570 var->yres_virtual = var->yres; in matroxfb_decode_var()
571 if (var->xres_virtual < var->xres) in matroxfb_decode_var()
572 var->xres_virtual = var->xres; in matroxfb_decode_var()
574 var->xres_virtual = matroxfb_pitch_adjust(minfo, var->xres_virtual, bpp); in matroxfb_decode_var()
575 memlen = var->xres_virtual * bpp * var->yres_virtual / 8; in matroxfb_decode_var()
577 var->yres_virtual = vramlen * 8 / (var->xres_virtual * bpp); in matroxfb_decode_var()
578 memlen = var->xres_virtual * bpp * var->yres_virtual / 8; in matroxfb_decode_var()
583 if (!minfo->capable.cross4MB && (memlen > 0x400000)) { in matroxfb_decode_var()
588 unsigned int m1 = linelen = var->xres_virtual * bpp / 8; in matroxfb_decode_var()
593 while (m2 >= m1) m2 -= m1; in matroxfb_decode_var()
598 max_yres = (vramlen - m2) / linelen; in matroxfb_decode_var()
599 if (var->yres_virtual > max_yres) in matroxfb_decode_var()
600 var->yres_virtual = max_yres; in matroxfb_decode_var()
604 if (var->yres_virtual > 32767) in matroxfb_decode_var()
605 var->yres_virtual = 32767; in matroxfb_decode_var()
607 if it was possible. We should return -EINVAL, but I disagree */ in matroxfb_decode_var()
608 if (var->yres_virtual < var->yres) in matroxfb_decode_var()
609 var->yres = var->yres_virtual; in matroxfb_decode_var()
610 if (var->xres_virtual < var->xres) in matroxfb_decode_var()
611 var->xres = var->xres_virtual; in matroxfb_decode_var()
612 if (var->xoffset + var->xres > var->xres_virtual) in matroxfb_decode_var()
613 var->xoffset = var->xres_virtual - var->xres; in matroxfb_decode_var()
614 if (var->yoffset + var->yres > var->yres_virtual) in matroxfb_decode_var()
615 var->yoffset = var->yres_virtual - var->yres; in matroxfb_decode_var()
617 if (bpp == 16 && var->green.length == 5) { in matroxfb_decode_var()
618 bpp--; /* an artificial value - 15 */ in matroxfb_decode_var()
621 for (rgbt = table; rgbt->bpp < bpp; rgbt++); in matroxfb_decode_var()
623 var->clr.offset = rgbt->clr.offset;\ in matroxfb_decode_var()
624 var->clr.length = rgbt->clr.length in matroxfb_decode_var()
630 *visual = rgbt->visual; in matroxfb_decode_var()
635 var->transp.length, var->red.length, var->green.length, var->blue.length, in matroxfb_decode_var()
636 var->transp.offset, var->red.offset, var->green.offset, var->blue.offset); in matroxfb_decode_var()
639 dprintk(KERN_INFO "requested %d*%d/%dbpp (%d*%d)\n", var->xres, var->yres, var->bits_per_pixel, in matroxfb_decode_var()
640 var->xres_virtual, var->yres_virtual); in matroxfb_decode_var()
659 if (regno >= minfo->curr.cmap_len) in matroxfb_setcolreg()
662 if (minfo->fbcon.var.grayscale) { in matroxfb_setcolreg()
667 red = CNVT_TOHW(red, minfo->fbcon.var.red.length); in matroxfb_setcolreg()
668 green = CNVT_TOHW(green, minfo->fbcon.var.green.length); in matroxfb_setcolreg()
669 blue = CNVT_TOHW(blue, minfo->fbcon.var.blue.length); in matroxfb_setcolreg()
670 transp = CNVT_TOHW(transp, minfo->fbcon.var.transp.length); in matroxfb_setcolreg()
672 switch (minfo->fbcon.var.bits_per_pixel) { in matroxfb_setcolreg()
685 (red << minfo->fbcon.var.red.offset) | in matroxfb_setcolreg()
686 (green << minfo->fbcon.var.green.offset) | in matroxfb_setcolreg()
687 (blue << minfo->fbcon.var.blue.offset) | in matroxfb_setcolreg()
688 (transp << minfo->fbcon.var.transp.offset); /* for 1:5:5:5 */ in matroxfb_setcolreg()
689 minfo->cmap[regno] = col | (col << 16); in matroxfb_setcolreg()
696 minfo->cmap[regno] = in matroxfb_setcolreg()
697 (red << minfo->fbcon.var.red.offset) | in matroxfb_setcolreg()
698 (green << minfo->fbcon.var.green.offset) | in matroxfb_setcolreg()
699 (blue << minfo->fbcon.var.blue.offset) | in matroxfb_setcolreg()
700 (transp << minfo->fbcon.var.transp.offset); /* 8:8:8:8 */ in matroxfb_setcolreg()
708 struct fb_fix_screeninfo *fix = &minfo->fbcon.fix; in matroxfb_init_fix()
711 strcpy(fix->id,"MATROX"); in matroxfb_init_fix()
713 fix->xpanstep = 8; /* 8 for 8bpp, 4 for 16bpp, 2 for 32bpp */ in matroxfb_init_fix()
714 fix->ypanstep = 1; in matroxfb_init_fix()
715 fix->ywrapstep = 0; in matroxfb_init_fix()
716 fix->mmio_start = minfo->mmio.base; in matroxfb_init_fix()
717 fix->mmio_len = minfo->mmio.len; in matroxfb_init_fix()
718 fix->accel = minfo->devflags.accelerator; in matroxfb_init_fix()
723 struct fb_fix_screeninfo *fix = &minfo->fbcon.fix; in matroxfb_update_fix()
726 mutex_lock(&minfo->fbcon.mm_lock); in matroxfb_update_fix()
727 fix->smem_start = minfo->video.base + minfo->curr.ydstorg.bytes; in matroxfb_update_fix()
728 fix->smem_len = minfo->video.len_usable - minfo->curr.ydstorg.bytes; in matroxfb_update_fix()
729 mutex_unlock(&minfo->fbcon.mm_lock); in matroxfb_update_fix()
740 if (minfo->dead) { in matroxfb_check_var()
741 return -ENXIO; in matroxfb_check_var()
759 if (minfo->dead) { in matroxfb_set_par()
760 return -ENXIO; in matroxfb_set_par()
763 var = &info->var; in matroxfb_set_par()
766 minfo->fbcon.screen_base = vaddr_va(minfo->video.vbase) + ydstorg; in matroxfb_set_par()
768 minfo->fbcon.fix.visual = visual; in matroxfb_set_par()
769 minfo->fbcon.fix.type = FB_TYPE_PACKED_PIXELS; in matroxfb_set_par()
770 minfo->fbcon.fix.type_aux = 0; in matroxfb_set_par()
771 minfo->fbcon.fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3; in matroxfb_set_par()
775 minfo->curr.cmap_len = cmap_len; in matroxfb_set_par()
776 ydstorg += minfo->devflags.ydstorg; in matroxfb_set_par()
777 minfo->curr.ydstorg.bytes = ydstorg; in matroxfb_set_par()
778 minfo->curr.ydstorg.chunks = ydstorg >> (isInterleave(minfo) ? 3 : 2); in matroxfb_set_par()
779 if (var->bits_per_pixel == 4) in matroxfb_set_par()
780 minfo->curr.ydstorg.pixels = ydstorg; in matroxfb_set_par()
782 minfo->curr.ydstorg.pixels = (ydstorg * 8) / var->bits_per_pixel; in matroxfb_set_par()
783 minfo->curr.final_bppShift = matroxfb_get_final_bppShift(minfo, var->bits_per_pixel); in matroxfb_set_par()
791 switch (var->bits_per_pixel) { in matroxfb_set_par()
799 hw = &minfo->hw; in matroxfb_set_par()
801 down_read(&minfo->altout.lock); in matroxfb_set_par()
803 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 && in matroxfb_set_par()
804 minfo->outputs[out].output->compute) { in matroxfb_set_par()
805 minfo->outputs[out].output->compute(minfo->outputs[out].data, &mt); in matroxfb_set_par()
808 up_read(&minfo->altout.lock); in matroxfb_set_par()
809 minfo->crtc1.pixclock = mt.pixclock; in matroxfb_set_par()
810 minfo->crtc1.mnp = mt.mnp; in matroxfb_set_par()
811 minfo->hw_switch->init(minfo, &mt); in matroxfb_set_par()
812 pos = (var->yoffset * var->xres_virtual + var->xoffset) * minfo->curr.final_bppShift / 32; in matroxfb_set_par()
813 pos += minfo->curr.ydstorg.chunks; in matroxfb_set_par()
815 hw->CRTC[0x0D] = pos & 0xFF; in matroxfb_set_par()
816 hw->CRTC[0x0C] = (pos & 0xFF00) >> 8; in matroxfb_set_par()
817 hw->CRTCEXT[0] = (hw->CRTCEXT[0] & 0xF0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40); in matroxfb_set_par()
818 hw->CRTCEXT[8] = pos >> 21; in matroxfb_set_par()
819 minfo->hw_switch->restore(minfo); in matroxfb_set_par()
821 down_read(&minfo->altout.lock); in matroxfb_set_par()
823 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 && in matroxfb_set_par()
824 minfo->outputs[out].output->program) { in matroxfb_set_par()
825 minfo->outputs[out].output->program(minfo->outputs[out].data); in matroxfb_set_par()
829 if (minfo->outputs[out].src == MATROXFB_SRC_CRTC1 && in matroxfb_set_par()
830 minfo->outputs[out].output->start) { in matroxfb_set_par()
831 minfo->outputs[out].output->start(minfo->outputs[out].data); in matroxfb_set_par()
834 up_read(&minfo->altout.lock); in matroxfb_set_par()
838 minfo->initialized = 1; in matroxfb_set_par()
849 vblank->flags = FB_VBLANK_HAVE_VCOUNT | FB_VBLANK_HAVE_VSYNC | in matroxfb_get_vblank()
852 vblank->vcount = mga_inl(M_VCOUNT); in matroxfb_get_vblank()
857 vblank->flags |= FB_VBLANK_HBLANKING; in matroxfb_get_vblank()
859 vblank->flags |= FB_VBLANK_VSYNCING; in matroxfb_get_vblank()
860 if (vblank->vcount >= minfo->fbcon.var.yres) in matroxfb_get_vblank()
861 vblank->flags |= FB_VBLANK_VBLANKING; in matroxfb_get_vblank()
862 if (test_bit(0, &minfo->irq_flags)) { in matroxfb_get_vblank()
863 vblank->flags |= FB_VBLANK_HAVE_COUNT; in matroxfb_get_vblank()
866 vblank->count = minfo->crtc1.vsync.cnt; in matroxfb_get_vblank()
883 if (minfo->dead) { in matroxfb_ioctl()
884 return -ENXIO; in matroxfb_ioctl()
897 return -EFAULT; in matroxfb_ioctl()
905 return -EFAULT; in matroxfb_ioctl()
916 return -EFAULT; in matroxfb_ioctl()
918 return -ENXIO; in matroxfb_ioctl()
919 down_read(&minfo->altout.lock); in matroxfb_ioctl()
920 oproc = minfo->outputs[mom.output].output; in matroxfb_ioctl()
922 val = -ENXIO; in matroxfb_ioctl()
923 } else if (!oproc->verifymode) { in matroxfb_ioctl()
927 val = -EINVAL; in matroxfb_ioctl()
930 val = oproc->verifymode(minfo->outputs[mom.output].data, mom.mode); in matroxfb_ioctl()
933 if (minfo->outputs[mom.output].mode != mom.mode) { in matroxfb_ioctl()
934 minfo->outputs[mom.output].mode = mom.mode; in matroxfb_ioctl()
938 up_read(&minfo->altout.lock); in matroxfb_ioctl()
941 switch (minfo->outputs[mom.output].src) { in matroxfb_ioctl()
949 down_read(&minfo->crtc2.lock); in matroxfb_ioctl()
950 crtc2 = minfo->crtc2.info; in matroxfb_ioctl()
952 crtc2->fbcon.fbops->fb_set_par(&crtc2->fbcon); in matroxfb_ioctl()
953 up_read(&minfo->crtc2.lock); in matroxfb_ioctl()
966 return -EFAULT; in matroxfb_ioctl()
968 return -ENXIO; in matroxfb_ioctl()
969 down_read(&minfo->altout.lock); in matroxfb_ioctl()
970 oproc = minfo->outputs[mom.output].output; in matroxfb_ioctl()
972 val = -ENXIO; in matroxfb_ioctl()
974 mom.mode = minfo->outputs[mom.output].mode; in matroxfb_ioctl()
977 up_read(&minfo->altout.lock); in matroxfb_ioctl()
981 return -EFAULT; in matroxfb_ioctl()
991 return -EFAULT; in matroxfb_ioctl()
995 return -ENXIO; in matroxfb_ioctl()
996 if (!minfo->outputs[i].output) in matroxfb_ioctl()
997 return -ENXIO; in matroxfb_ioctl()
998 switch (minfo->outputs[i].src) { in matroxfb_ioctl()
1003 return -EBUSY; in matroxfb_ioctl()
1007 if (minfo->devflags.panellink) { in matroxfb_ioctl()
1010 return -EINVAL; in matroxfb_ioctl()
1012 if (minfo->outputs[i].src == MATROXFB_SRC_CRTC2) { in matroxfb_ioctl()
1013 return -EBUSY; in matroxfb_ioctl()
1021 if (minfo->outputs[i].src != MATROXFB_SRC_CRTC1) { in matroxfb_ioctl()
1023 minfo->outputs[i].src = MATROXFB_SRC_CRTC1; in matroxfb_ioctl()
1025 } else if (minfo->outputs[i].src == MATROXFB_SRC_CRTC1) { in matroxfb_ioctl()
1027 minfo->outputs[i].src = MATROXFB_SRC_NONE; in matroxfb_ioctl()
1041 if (minfo->outputs[i].src == MATROXFB_SRC_CRTC1) { in matroxfb_ioctl()
1046 return -EFAULT; in matroxfb_ioctl()
1055 if (minfo->outputs[i].output) { in matroxfb_ioctl()
1056 switch (minfo->outputs[i].src) { in matroxfb_ioctl()
1064 if (minfo->devflags.panellink) { in matroxfb_ioctl()
1071 return -EFAULT; in matroxfb_ioctl()
1080 if (minfo->outputs[i].output) { in matroxfb_ioctl()
1085 return -EFAULT; in matroxfb_ioctl()
1095 sprintf(r.bus_info, "PCI:%s", pci_name(minfo->pcidev)); in matroxfb_ioctl()
1099 return -EFAULT; in matroxfb_ioctl()
1109 return -EFAULT; in matroxfb_ioctl()
1111 down_read(&minfo->altout.lock); in matroxfb_ioctl()
1112 if (!minfo->outputs[1].output) { in matroxfb_ioctl()
1113 err = -ENXIO; in matroxfb_ioctl()
1114 } else if (minfo->outputs[1].output->getqueryctrl) { in matroxfb_ioctl()
1115 err = minfo->outputs[1].output->getqueryctrl(minfo->outputs[1].data, &qctrl); in matroxfb_ioctl()
1117 err = -EINVAL; in matroxfb_ioctl()
1119 up_read(&minfo->altout.lock); in matroxfb_ioctl()
1122 return -EFAULT; in matroxfb_ioctl()
1131 return -EFAULT; in matroxfb_ioctl()
1133 down_read(&minfo->altout.lock); in matroxfb_ioctl()
1134 if (!minfo->outputs[1].output) { in matroxfb_ioctl()
1135 err = -ENXIO; in matroxfb_ioctl()
1136 } else if (minfo->outputs[1].output->getctrl) { in matroxfb_ioctl()
1137 err = minfo->outputs[1].output->getctrl(minfo->outputs[1].data, &ctrl); in matroxfb_ioctl()
1139 err = -EINVAL; in matroxfb_ioctl()
1141 up_read(&minfo->altout.lock); in matroxfb_ioctl()
1144 return -EFAULT; in matroxfb_ioctl()
1153 return -EFAULT; in matroxfb_ioctl()
1155 down_read(&minfo->altout.lock); in matroxfb_ioctl()
1156 if (!minfo->outputs[1].output) { in matroxfb_ioctl()
1157 err = -ENXIO; in matroxfb_ioctl()
1158 } else if (minfo->outputs[1].output->setctrl) { in matroxfb_ioctl()
1159 err = minfo->outputs[1].output->setctrl(minfo->outputs[1].data, &ctrl); in matroxfb_ioctl()
1161 err = -EINVAL; in matroxfb_ioctl()
1163 up_read(&minfo->altout.lock); in matroxfb_ioctl()
1167 return -ENOTTY; in matroxfb_ioctl()
1181 if (minfo->dead) in matroxfb_blank()
1230 /* 9-F */
1246 static int cross4MB = -1; /* "matroxfb:cross4MB" */
1258 static int dev = -1; /* "matroxfb:dev:xxxxx" */
1260 static int depth = -1; /* "matroxfb:depth:xxxxx" */
1270 static int sync = -1; /* "matroxfb:sync:xxxxx" */
1275 static int dfp_type = -1; /* "matroxfb:dfp:xxx */
1276 static int memtype = -1; /* "matroxfb:memtype:xxx" */
1295 vm = minfo->video.vbase; in matroxfb_getmemory()
1314 mga_writeb(vm, offs, mga_readb(vm, offs) - 0x02); in matroxfb_getmemory()
1325 *realSize = offs - 0x100000; in matroxfb_getmemory()
1327 minfo->interleave = !(!isMillenium(minfo) || ((offs - 0x100000) & 0x3FFFFF)); in matroxfb_getmemory()
1388 /* from doc it looks like that accelerator can draw only to low 16MB :-( Direct accesses & displayi…
1424 unsigned short vendor, device, rev, svid, sid; member
1491 "MGA-G100 (PCI)"},
1498 "MGA-G100 (AGP)"},
1505 "MGA-G200 (PCI)"},
1512 "MGA-G200eW (PCI)"},
1519 "MGA-G200 (AGP)"},
1547 "MGA-G200 (AGP)"},
1607 minfo->outputs[0].default_src = MATROXFB_SRC_CRTC1; in setDefaultOutputs()
1608 if (minfo->devflags.g450dac) { in setDefaultOutputs()
1609 minfo->outputs[1].default_src = MATROXFB_SRC_CRTC1; in setDefaultOutputs()
1610 minfo->outputs[2].default_src = MATROXFB_SRC_CRTC1; in setDefaultOutputs()
1612 minfo->outputs[2].default_src = MATROXFB_SRC_CRTC1; in setDefaultOutputs()
1622 minfo->outputs[i].default_src = MATROXFB_SRC_NONE; in setDefaultOutputs()
1624 minfo->outputs[i].default_src = MATROXFB_SRC_CRTC1; in setDefaultOutputs()
1625 } else if (c == '2' && minfo->devflags.crtc2) { in setDefaultOutputs()
1626 minfo->outputs[i].default_src = MATROXFB_SRC_CRTC2; in setDefaultOutputs()
1653 minfo->hw_switch = b->base->lowlevel; in initMatrox2()
1654 minfo->devflags.accelerator = b->base->accelID; in initMatrox2()
1655 minfo->max_pixel_clock = b->maxclk; in initMatrox2()
1657 printk(KERN_INFO "matroxfb: Matrox %s detected\n", b->name); in initMatrox2()
1658 minfo->capable.plnwt = 1; in initMatrox2()
1659 minfo->chip = b->chip; in initMatrox2()
1660 minfo->capable.srcorg = b->flags & DEVF_SRCORG; in initMatrox2()
1661 minfo->devflags.video64bits = b->flags & DEVF_VIDEO64BIT; in initMatrox2()
1662 if (b->flags & DEVF_TEXT4B) { in initMatrox2()
1663 minfo->devflags.vgastep = 4; in initMatrox2()
1664 minfo->devflags.textmode = 4; in initMatrox2()
1665 minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP16; in initMatrox2()
1666 } else if (b->flags & DEVF_TEXT16B) { in initMatrox2()
1667 minfo->devflags.vgastep = 16; in initMatrox2()
1668 minfo->devflags.textmode = 1; in initMatrox2()
1669 minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP16; in initMatrox2()
1671 minfo->devflags.vgastep = 8; in initMatrox2()
1672 minfo->devflags.textmode = 1; in initMatrox2()
1673 minfo->devflags.text_type_aux = FB_AUX_TEXT_MGA_STEP8; in initMatrox2()
1675 minfo->devflags.support32MB = (b->flags & DEVF_SUPPORT32MB) != 0; in initMatrox2()
1676 minfo->devflags.precise_width = !(b->flags & DEVF_ANY_VXRES); in initMatrox2()
1677 minfo->devflags.crtc2 = (b->flags & DEVF_CRTC2) != 0; in initMatrox2()
1678 minfo->devflags.maven_capable = (b->flags & DEVF_MAVEN_CAPABLE) != 0; in initMatrox2()
1679 minfo->devflags.dualhead = (b->flags & DEVF_DUALHEAD) != 0; in initMatrox2()
1680 minfo->devflags.dfp_type = dfp_type; in initMatrox2()
1681 minfo->devflags.g450dac = (b->flags & DEVF_G450DAC) != 0; in initMatrox2()
1682 minfo->devflags.textstep = minfo->devflags.vgastep * minfo->devflags.textmode; in initMatrox2()
1683 minfo->devflags.textvram = 65536 / minfo->devflags.textmode; in initMatrox2()
1685 if (b->flags & DEVF_PANELLINK_CAPABLE) { in initMatrox2()
1686 minfo->outputs[2].data = minfo; in initMatrox2()
1687 minfo->outputs[2].output = &panellink_output; in initMatrox2()
1688 minfo->outputs[2].src = minfo->outputs[2].default_src; in initMatrox2()
1689 minfo->outputs[2].mode = MATROXFB_OUTPUT_MODE_MONITOR; in initMatrox2()
1690 minfo->devflags.panellink = 1; in initMatrox2()
1693 if (minfo->capable.cross4MB < 0) in initMatrox2()
1694 minfo->capable.cross4MB = b->flags & DEVF_CROSS4MB; in initMatrox2()
1695 if (b->flags & DEVF_SWAPS) { in initMatrox2()
1696 ctrlptr_phys = pci_resource_start(minfo->pcidev, 1); in initMatrox2()
1697 video_base_phys = pci_resource_start(minfo->pcidev, 0); in initMatrox2()
1698 minfo->devflags.fbResource = PCI_BASE_ADDRESS_0; in initMatrox2()
1700 ctrlptr_phys = pci_resource_start(minfo->pcidev, 0); in initMatrox2()
1701 video_base_phys = pci_resource_start(minfo->pcidev, 1); in initMatrox2()
1702 minfo->devflags.fbResource = PCI_BASE_ADDRESS_1; in initMatrox2()
1704 err = -EINVAL; in initMatrox2()
1713 memsize = b->base->maxvram; in initMatrox2()
1720 minfo->video.len_maximum = memsize; in initMatrox2()
1727 err = -ENOMEM; in initMatrox2()
1729 minfo->mmio.vbase.vaddr = ioremap(ctrlptr_phys, 16384); in initMatrox2()
1730 if (!minfo->mmio.vbase.vaddr) { in initMatrox2()
1734 minfo->mmio.base = ctrlptr_phys; in initMatrox2()
1735 minfo->mmio.len = 16384; in initMatrox2()
1736 minfo->video.base = video_base_phys; in initMatrox2()
1737 minfo->video.vbase.vaddr = ioremap_wc(video_base_phys, memsize); in initMatrox2()
1738 if (!minfo->video.vbase.vaddr) { in initMatrox2()
1747 pci_read_config_dword(minfo->pcidev, PCI_OPTION_REG, &mga_option); in initMatrox2()
1748 pci_read_config_dword(minfo->pcidev, PCI_COMMAND, &cmd); in initMatrox2()
1754 if (!(mga_option & 0x20000000) && !minfo->devflags.nopciretry) { in initMatrox2()
1758 minfo->devflags.nopciretry = 1; in initMatrox2()
1760 pci_write_config_dword(minfo->pcidev, PCI_COMMAND, cmd); in initMatrox2()
1761 pci_write_config_dword(minfo->pcidev, PCI_OPTION_REG, mga_option); in initMatrox2()
1762 minfo->hw.MXoptionReg = mga_option; in initMatrox2()
1764 /* select non-DMA memory for PCI_MGA_DATA, otherwise dump of PCI cfg space can lock PCI bus */ in initMatrox2()
1766 pci_write_config_dword(minfo->pcidev, PCI_MGA_INDEX, 0x00003C00); in initMatrox2()
1769 err = -ENXIO; in initMatrox2()
1771 if (minfo->hw_switch->preinit(minfo)) { in initMatrox2()
1775 err = -ENOMEM; in initMatrox2()
1776 if (!matroxfb_getmemory(minfo, memsize, &minfo->video.len) || !minfo->video.len) { in initMatrox2()
1780 minfo->devflags.ydstorg = 0; in initMatrox2()
1782 minfo->video.base = video_base_phys; in initMatrox2()
1783 minfo->video.len_usable = minfo->video.len; in initMatrox2()
1784 if (minfo->video.len_usable > b->base->maxdisplayable) in initMatrox2()
1785 minfo->video.len_usable = b->base->maxdisplayable; in initMatrox2()
1787 minfo->wc_cookie = arch_phys_wc_add(video_base_phys, in initMatrox2()
1788 minfo->video.len); in initMatrox2()
1790 if (!minfo->devflags.novga) in initMatrox2()
1793 minfo->hw_switch->reset(minfo); in initMatrox2()
1795 minfo->fbcon.monspecs.hfmin = 0; in initMatrox2()
1796 minfo->fbcon.monspecs.hfmax = fh; in initMatrox2()
1797 minfo->fbcon.monspecs.vfmin = 0; in initMatrox2()
1798 minfo->fbcon.monspecs.vfmax = fv; in initMatrox2()
1799 minfo->fbcon.monspecs.dpms = 0; /* TBD */ in initMatrox2()
1802 vesafb_defined.red = colors[depth-1].red; in initMatrox2()
1803 vesafb_defined.green = colors[depth-1].green; in initMatrox2()
1804 vesafb_defined.blue = colors[depth-1].blue; in initMatrox2()
1805 vesafb_defined.bits_per_pixel = colors[depth-1].bits_per_pixel; in initMatrox2()
1811 minfo->fbops = matroxfb_ops; in initMatrox2()
1812 minfo->fbcon.fbops = &minfo->fbops; in initMatrox2()
1813 minfo->fbcon.pseudo_palette = minfo->cmap; in initMatrox2()
1814 minfo->fbcon.flags = FBINFO_PARTIAL_PAN_OK | /* Prefer panning for scroll under MC viewer/edit */ in initMatrox2()
1815 FBINFO_HWACCEL_COPYAREA | /* We have hw-assisted bmove */ in initMatrox2()
1821 minfo->video.len_usable &= PAGE_MASK; in initMatrox2()
1822 fb_alloc_cmap(&minfo->fbcon.cmap, 256, 1); in initMatrox2()
1827 fb_find_mode(&vesafb_defined, &minfo->fbcon, videomode[0] ? videomode : NULL, in initMatrox2()
1849 if (sync != -1) in initMatrox2()
1918 minfo->fbcon.screen_base = vaddr_va(minfo->video.vbase); in initMatrox2()
1920 matroxfb_check_var(&vesafb_defined, &minfo->fbcon); in initMatrox2()
1925 minfo->fbcon.var = vesafb_defined; in initMatrox2()
1926 err = -EINVAL; in initMatrox2()
1932 minfo->video.base, vaddr_va(minfo->video.vbase), minfo->video.len); in initMatrox2()
1937 minfo->fbcon.device = &minfo->pcidev->dev; in initMatrox2()
1938 if (register_framebuffer(&minfo->fbcon) < 0) { in initMatrox2()
1941 fb_info(&minfo->fbcon, "%s frame buffer device\n", minfo->fbcon.fix.id); in initMatrox2()
1945 if (!minfo->initialized) { in initMatrox2()
1946 fb_info(&minfo->fbcon, "initializing hardware\n"); in initMatrox2()
1950 fb_set_var(&minfo->fbcon, &vesafb_defined); in initMatrox2()
1956 iounmap(minfo->video.vbase.vaddr); in initMatrox2()
1958 iounmap(minfo->mmio.vbase.vaddr); in initMatrox2()
1960 release_mem_region(video_base_phys, minfo->video.len_maximum); in initMatrox2()
1975 list_add(&drv->node, &matroxfb_driver_list); in matroxfb_register_driver()
1979 if (minfo->drivers_count == MATROXFB_MAX_FB_DRIVERS) in matroxfb_register_driver()
1981 p = drv->probe(minfo); in matroxfb_register_driver()
1983 minfo->drivers_data[minfo->drivers_count] = p; in matroxfb_register_driver()
1984 minfo->drivers[minfo->drivers_count++] = drv; in matroxfb_register_driver()
1993 list_del(&drv->node); in matroxfb_unregister_driver()
1997 for (i = 0; i < minfo->drivers_count; ) { in matroxfb_unregister_driver()
1998 if (minfo->drivers[i] == drv) { in matroxfb_unregister_driver()
1999 if (drv && drv->remove) in matroxfb_unregister_driver()
2000 drv->remove(minfo, minfo->drivers_data[i]); in matroxfb_unregister_driver()
2001 minfo->drivers[i] = minfo->drivers[--minfo->drivers_count]; in matroxfb_unregister_driver()
2002 minfo->drivers_data[i] = minfo->drivers_data[minfo->drivers_count]; in matroxfb_unregister_driver()
2012 list_add(&minfo->next_fb, &matroxfb_list); in matroxfb_register_device()
2015 drv = matroxfb_driver_l(drv->node.next)) { in matroxfb_register_device()
2016 if (drv->probe) { in matroxfb_register_device()
2017 void *p = drv->probe(minfo); in matroxfb_register_device()
2019 minfo->drivers_data[i] = p; in matroxfb_register_device()
2020 minfo->drivers[i++] = drv; in matroxfb_register_device()
2026 minfo->drivers_count = i; in matroxfb_register_device()
2032 list_del(&minfo->next_fb); in matroxfb_unregister_device()
2033 for (i = 0; i < minfo->drivers_count; i++) { in matroxfb_unregister_device()
2034 struct matroxfb_driver* drv = minfo->drivers[i]; in matroxfb_unregister_device()
2036 if (drv && drv->remove) in matroxfb_unregister_device()
2037 drv->remove(minfo, minfo->drivers_data[i]); in matroxfb_unregister_device()
2044 u_int16_t sid; in matroxfb_probe() local
2054 svid = pdev->subsystem_vendor; in matroxfb_probe()
2055 sid = pdev->subsystem_device; in matroxfb_probe()
2056 for (b = dev_list; b->vendor; b++) { in matroxfb_probe()
2057 …if ((b->vendor != pdev->vendor) || (b->device != pdev->device) || (b->rev < pdev->revision)) conti… in matroxfb_probe()
2058 if (b->svid) in matroxfb_probe()
2059 if ((b->svid != svid) || (b->sid != sid)) continue; in matroxfb_probe()
2063 if (!b->vendor) in matroxfb_probe()
2064 return -ENODEV; in matroxfb_probe()
2067 dev--; in matroxfb_probe()
2068 return -ENODEV; in matroxfb_probe()
2072 return -1; in matroxfb_probe()
2077 return -ENOMEM; in matroxfb_probe()
2079 minfo->pcidev = pdev; in matroxfb_probe()
2080 minfo->dead = 0; in matroxfb_probe()
2081 minfo->usecount = 0; in matroxfb_probe()
2082 minfo->userusecount = 0; in matroxfb_probe()
2086 minfo->devflags.memtype = memtype; in matroxfb_probe()
2087 if (memtype != -1) in matroxfb_probe()
2090 minfo->devflags.novga = novga; in matroxfb_probe()
2091 minfo->devflags.nobios = nobios; in matroxfb_probe()
2092 minfo->devflags.noinit = noinit; in matroxfb_probe()
2098 minfo->devflags.novga = 1; in matroxfb_probe()
2099 minfo->devflags.nobios = 1; in matroxfb_probe()
2100 minfo->devflags.noinit = 0; in matroxfb_probe()
2103 minfo->devflags.nopciretry = no_pci_retry; in matroxfb_probe()
2104 minfo->devflags.mga_24bpp_fix = inv24; in matroxfb_probe()
2105 minfo->devflags.precise_width = option_precise_width; in matroxfb_probe()
2106 minfo->devflags.sgram = sgram; in matroxfb_probe()
2107 minfo->capable.cross4MB = cross4MB; in matroxfb_probe()
2109 spin_lock_init(&minfo->lock.DAC); in matroxfb_probe()
2110 spin_lock_init(&minfo->lock.accel); in matroxfb_probe()
2111 init_rwsem(&minfo->crtc2.lock); in matroxfb_probe()
2112 init_rwsem(&minfo->altout.lock); in matroxfb_probe()
2113 mutex_init(&minfo->fbcon.mm_lock); in matroxfb_probe()
2114 minfo->irq_flags = 0; in matroxfb_probe()
2115 init_waitqueue_head(&minfo->crtc1.vsync.wait); in matroxfb_probe()
2116 init_waitqueue_head(&minfo->crtc2.vsync.wait); in matroxfb_probe()
2117 minfo->crtc1.panpos = -1; in matroxfb_probe()
2125 return -1; in matroxfb_probe()
2178 /* **************************** init-time only **************************** */
2196 /* 10-FF */
2277 if (maxclk < 1000) maxclk *= 1000; /* kHz -> Hz, MHz -> kHz */ in matroxfb_init_params()
2278 if (maxclk < 1000000) maxclk *= 1000; /* kHz -> Hz, 1MHz minimum */ in matroxfb_init_params()
2284 for (RSptr = vesamap; RSptr->vesa; RSptr++) { in matroxfb_init_params()
2285 if (RSptr->vesa == vesa) break; in matroxfb_init_params()
2287 if (!RSptr->vesa) { in matroxfb_init_params()
2292 int res = RSResolution(RSptr->info)-1; in matroxfb_init_params()
2311 if (depth == -1) in matroxfb_init_params()
2312 depth = RSDepth(RSptr->info); in matroxfb_init_params()
2320 return -ENODEV; in matrox_init()
2324 dev = -1; /* accept all new devices... */ in matrox_init()
2328 /* **************************** exit-time only **************************** */
2336 /* ************************* init in-kernel code ************************** */
2485 return -ENODEV; in matroxfb_init()
2489 return -ENXIO; in matroxfb_init()
2503 MODULE_AUTHOR("(c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>");
2518 MODULE_PARM_DESC(novga, "VGA I/O (0x3C0-0x3DF) disabled (0 or 1=disabled) (default=0)");
2522 MODULE_PARM_DESC(noinit, "Disables W/SG/SD-RAM and bus interface initialization (0 or 1=do not init…
2536 MODULE_PARM_DESC(vesa, "Startup videomode (0x000-0x1FF) (default=0x101)");
2560 MODULE_PARM_DESC(maxclk, "Startup maximal clock, 0-999MHz, 1000-999999kHz, 1000000-INF Hz");
2562 MODULE_PARM_DESC(fh, "Startup horizontal frequency, 0-999kHz, 1000-INF Hz");
2564 MODULE_PARM_DESC(fv, "Startup vertical frequency, 0-INF Hz\n"
2588 return -ENXIO; in matroxfb_init()
2604 else if (depth != -1) { in matroxfb_init()
2606 depth = -1; in matroxfb_init()