linux/drivers/video/fbdev/matrox/matroxfb_misc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *
 * Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200 and G400
 *
 * (c) 1998-2002 Petr Vandrovec <[email protected]>
 *
 * Portions Copyright (c) 2001 Matrox Graphics Inc.
 *
 * Version: 1.65 2002/08/14
 *
 * MTRR stuff: 1998 Tom Rini <[email protected]>
 *
 * Contributors: "menion?" <[email protected]>
 *                     Betatesting, fixes, ideas
 *
 *               "Kurt Garloff" <[email protected]>
 *                     Betatesting, fixes, ideas, videomodes, videomodes timmings
 *
 *               "Tom Rini" <[email protected]>
 *                     MTRR stuff, PPC cleanups, betatesting, fixes, ideas
 *
 *               "Bibek Sahu" <[email protected]>
 *                     Access device through readb|w|l and write b|w|l
 *                     Extensive debugging stuff
 *
 *               "Daniel Haun" <[email protected]>
 *                     Testing, hardware cursor fixes
 *
 *               "Scott Wood" <[email protected]>
 *                     Fixes
 *
 *               "Gerd Knorr" <[email protected]>
 *                     Betatesting
 *
 *               "Kelly French" <[email protected]>
 *               "Fernando Herrera" <[email protected]>
 *                     Betatesting, bug reporting
 *
 *               "Pablo Bianucci" <[email protected]>
 *                     Fixes, ideas, betatesting
 *
 *               "Inaky Perez Gonzalez" <[email protected]>
 *                     Fixes, enhandcements, ideas, betatesting
 *
 *               "Ryuichi Oikawa" <[email protected]>
 *                     PPC betatesting, PPC support, backward compatibility
 *
 *               "Paul Womar" <[email protected]>
 *               "Owen Waller" <[email protected]>
 *                     PPC betatesting
 *
 *               "Thomas Pornin" <[email protected]>
 *                     Alpha betatesting
 *
 *               "Pieter van Leuven" <[email protected]>
 *               "Ulf Jaenicke-Roessler" <[email protected]>
 *                     G100 testing
 *
 *               "H. Peter Arvin" <[email protected]>
 *                     Ideas
 *
 *               "Cort Dougan" <[email protected]>
 *                     CHRP fixes and PReP cleanup
 *
 *               "Mark Vojkovich" <[email protected]>
 *                     G400 support
 *
 *               "David C. Hansen" <[email protected]>
 *                     Fixes
 *
 *               "Ian Romanick" <[email protected]>
 *                     Find PInS data in BIOS on PowerPC systems.
 *
 * (following author is not in any relation with this code, but his code
 *  is included in this driver)
 *
 * Based on framebuffer driver for VBE 2.0 compliant graphic boards
 *     (c) 1998 Gerd Knorr <[email protected]>
 *
 * (following author is not in any relation with this code, but his ideas
 *  were used when writing this driver)
 *
 *		 FreeVBE/AF (Matrox), "Shawn Hargreaves" <[email protected]>
 *
 */


#include "matroxfb_misc.h"
#include <linux/interrupt.h>
#include <linux/matroxfb.h>

void matroxfb_DAC_out(const struct matrox_fb_info *minfo, int reg, int val)
{}

int matroxfb_DAC_in(const struct matrox_fb_info *minfo, int reg)
{}

void matroxfb_var2my(struct fb_var_screeninfo* var, struct my_timming* mt) {}

int matroxfb_PLL_calcclock(const struct matrox_pll_features* pll, unsigned int freq, unsigned int fmax,
		unsigned int* in, unsigned int* feed, unsigned int* post) {}

int matroxfb_vgaHWinit(struct matrox_fb_info *minfo, struct my_timming *m)
{
	unsigned int hd, hs, he, hbe, ht;
	unsigned int vd, vs, ve, vt, lc;
	unsigned int wd;
	unsigned int divider;
	int i;
	struct matrox_hw_state * const hw = &minfo->hw;

	DBG(__func__)

	hw->SEQ[0] = 0x00;
	hw->SEQ[1] = 0x01;	/* or 0x09 */
	hw->SEQ[2] = 0x0F;	/* bitplanes */
	hw->SEQ[3] = 0x00;
	hw->SEQ[4] = 0x0E;
	/* CRTC 0..7, 9, 16..19, 21, 22 are reprogrammed by Matrox Millennium code... Hope that by MGA1064 too */
	if (m->dblscan) {
		m->VTotal <<= 1;
		m->VDisplay <<= 1;
		m->VSyncStart <<= 1;
		m->VSyncEnd <<= 1;
	}
	if (m->interlaced) {
		m->VTotal >>= 1;
		m->VDisplay >>= 1;
		m->VSyncStart >>= 1;
		m->VSyncEnd >>= 1;
	}

	/* GCTL is ignored when not using 0xA0000 aperture */
	hw->GCTL[0] = 0x00;
	hw->GCTL[1] = 0x00;
	hw->GCTL[2] = 0x00;
	hw->GCTL[3] = 0x00;
	hw->GCTL[4] = 0x00;
	hw->GCTL[5] = 0x40;
	hw->GCTL[6] = 0x05;
	hw->GCTL[7] = 0x0F;
	hw->GCTL[8] = 0xFF;

	/* Whole ATTR is ignored in PowerGraphics mode */
	for (i = 0; i < 16; i++)
		hw->ATTR[i] = i;
	hw->ATTR[16] = 0x41;
	hw->ATTR[17] = 0xFF;
	hw->ATTR[18] = 0x0F;
	hw->ATTR[19] = 0x00;
	hw->ATTR[20] = 0x00;

	hd = m->HDisplay >> 3;
	hs = m->HSyncStart >> 3;
	he = m->HSyncEnd >> 3;
	ht = m->HTotal >> 3;
	/* standard timmings are in 8pixels, but for interleaved we cannot */
	/* do it for 4bpp (because of (4bpp >> 1(interleaved))/4 == 0) */
	/* using 16 or more pixels per unit can save us */
	divider = minfo->curr.final_bppShift;
	while (divider & 3) {
		hd >>= 1;
		hs >>= 1;
		he >>= 1;
		ht >>= 1;
		divider <<= 1;
	}
	divider = divider / 4;
	/* divider can be from 1 to 8 */
	while (divider > 8) {
		hd <<= 1;
		hs <<= 1;
		he <<= 1;
		ht <<= 1;
		divider >>= 1;
	}
	hd = hd - 1;
	hs = hs - 1;
	he = he - 1;
	ht = ht - 1;
	vd = m->VDisplay - 1;
	vs = m->VSyncStart - 1;
	ve = m->VSyncEnd - 1;
	vt = m->VTotal - 2;
	lc = vd;
	/* G200 cannot work with (ht & 7) == 6 */
	if (((ht & 0x07) == 0x06) || ((ht & 0x0F) == 0x04))
		ht++;
	hbe = ht;
	wd = minfo->fbcon.var.xres_virtual * minfo->curr.final_bppShift / 64;

	hw->CRTCEXT[0] = 0;
	hw->CRTCEXT[5] = 0;
	if (m->interlaced) {
		hw->CRTCEXT[0] = 0x80;
		hw->CRTCEXT[5] = (hs + he - ht) >> 1;
		if (!m->dblscan)
			wd <<= 1;
		vt &= ~1;
	}
	hw->CRTCEXT[0] |=  (wd & 0x300) >> 4;
	hw->CRTCEXT[1] = (((ht - 4) & 0x100) >> 8) |
			  ((hd      & 0x100) >> 7) | /* blanking */
			  ((hs      & 0x100) >> 6) | /* sync start */
			   (hbe     & 0x040);	 /* end hor. blanking */
	/* FIXME: Enable vidrst only on G400, and only if TV-out is used */
	if (minfo->outputs[1].src == MATROXFB_SRC_CRTC1)
		hw->CRTCEXT[1] |= 0x88;		/* enable horizontal and vertical vidrst */
	hw->CRTCEXT[2] =  ((vt & 0xC00) >> 10) |
			  ((vd & 0x400) >>  8) |	/* disp end */
			  ((vd & 0xC00) >>  7) |	/* vblanking start */
			  ((vs & 0xC00) >>  5) |
			  ((lc & 0x400) >>  3);
	hw->CRTCEXT[3] = (divider - 1) | 0x80;
	hw->CRTCEXT[4] = 0;

	hw->CRTC[0] = ht-4;
	hw->CRTC[1] = hd;
	hw->CRTC[2] = hd;
	hw->CRTC[3] = (hbe & 0x1F) | 0x80;
	hw->CRTC[4] = hs;
	hw->CRTC[5] = ((hbe & 0x20) << 2) | (he & 0x1F);
	hw->CRTC[6] = vt & 0xFF;
	hw->CRTC[7] = ((vt & 0x100) >> 8) |
		      ((vd & 0x100) >> 7) |
		      ((vs & 0x100) >> 6) |
		      ((vd & 0x100) >> 5) |
		      ((lc & 0x100) >> 4) |
		      ((vt & 0x200) >> 4) |
		      ((vd & 0x200) >> 3) |
		      ((vs & 0x200) >> 2);
	hw->CRTC[8] = 0x00;
	hw->CRTC[9] = ((vd & 0x200) >> 4) |
		      ((lc & 0x200) >> 3);
	if (m->dblscan && !m->interlaced)
		hw->CRTC[9] |= 0x80;
	for (i = 10; i < 16; i++)
		hw->CRTC[i] = 0x00;
	hw->CRTC[16] = vs /* & 0xFF */;
	hw->CRTC[17] = (ve & 0x0F) | 0x20;
	hw->CRTC[18] = vd /* & 0xFF */;
	hw->CRTC[19] = wd /* & 0xFF */;
	hw->CRTC[20] = 0x00;
	hw->CRTC[21] = vd /* & 0xFF */;
	hw->CRTC[22] = (vt + 1) /* & 0xFF */;
	hw->CRTC[23] = 0xC3;
	hw->CRTC[24] = lc;
	return 0;
};

void matroxfb_vgaHWrestore(struct matrox_fb_info *minfo)
{}

static void get_pins(unsigned char __iomem* pins, struct matrox_bios* bd) {}

static void get_bios_version(unsigned char __iomem * vbios, struct matrox_bios* bd) {}

static void get_bios_output(unsigned char __iomem* vbios, struct matrox_bios* bd) {}

static void get_bios_tvout(unsigned char __iomem* vbios, struct matrox_bios* bd) {}

static void parse_bios(unsigned char __iomem* vbios, struct matrox_bios* bd) {}

static int parse_pins1(struct matrox_fb_info *minfo,
		       const struct matrox_bios *bd)
{}

static void default_pins1(struct matrox_fb_info *minfo)
{}

static int parse_pins2(struct matrox_fb_info *minfo,
		       const struct matrox_bios *bd)
{}

static void default_pins2(struct matrox_fb_info *minfo)
{}

static int parse_pins3(struct matrox_fb_info *minfo,
		       const struct matrox_bios *bd)
{}

static void default_pins3(struct matrox_fb_info *minfo)
{}

static int parse_pins4(struct matrox_fb_info *minfo,
		       const struct matrox_bios *bd)
{}

static void default_pins4(struct matrox_fb_info *minfo)
{}

static int parse_pins5(struct matrox_fb_info *minfo,
		       const struct matrox_bios *bd)
{}

static void default_pins5(struct matrox_fb_info *minfo)
{}

static int matroxfb_set_limits(struct matrox_fb_info *minfo,
			       const struct matrox_bios *bd)
{}

void matroxfb_read_pins(struct matrox_fb_info *minfo)
{}

EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();		/* DAC1064, Ti3026 */
EXPORT_SYMBOL();		/* DAC1064, Ti3026 */
EXPORT_SYMBOL();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();