linux/drivers/video/fbdev/matrox/matroxfb_base.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
 *
 *               "Samuel Hocevar" <[email protected]>
 *                     Fixes
 *
 *               "Anton Altaparmakov" <[email protected]>
 *                     G400 MAX/non-MAX distinction
 *
 *               "Ken Aaker" <[email protected]>
 *                     memtype extension (needed for GXT130P RS/6000 adapter)
 *
 *               "Uns Lider" <[email protected]>
 *                     G100 PLNWT fixes
 *
 *               "Denis Zaitsev" <[email protected]>
 *                     Fixes
 *
 *               "Mike Pieper" <[email protected]>
 *                     TVOut enhandcements, V4L2 control interface.
 *
 *               "Diego Biurrun" <[email protected]>
 *                     DFP testing
 *
 * (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 <linux/aperture.h>
#include <linux/version.h>

#include "matroxfb_base.h"
#include "matroxfb_misc.h"
#include "matroxfb_accel.h"
#include "matroxfb_DAC1064.h"
#include "matroxfb_Ti3026.h"
#include "matroxfb_maven.h"
#include "matroxfb_crtc2.h"
#include "matroxfb_g450.h"
#include <linux/matroxfb.h>
#include <linux/interrupt.h>
#include <linux/nvram.h>
#include <linux/slab.h>
#include <linux/uaccess.h>

#ifdef CONFIG_PPC_PMAC
#include <asm/machdep.h>
static int default_vmode = VMODE_NVRAM;
static int default_cmode = CMODE_NVRAM;
#endif

static void matroxfb_unregister_device(struct matrox_fb_info* minfo);

/* --------------------------------------------------------------------- */

/*
 * card parameters
 */

/* --------------------------------------------------------------------- */

static struct fb_var_screeninfo vesafb_defined =;



/* --------------------------------------------------------------------- */
static void update_crtc2(struct matrox_fb_info *minfo, unsigned int pos)
{}

static void matroxfb_crtc1_panpos(struct matrox_fb_info *minfo)
{}

static irqreturn_t matrox_irq(int irq, void *dev_id)
{}

int matroxfb_enable_irq(struct matrox_fb_info *minfo, int reenable)
{}

static void matroxfb_disable_irq(struct matrox_fb_info *minfo)
{}

int matroxfb_wait_for_sync(struct matrox_fb_info *minfo, u_int32_t crtc)
{}

/* --------------------------------------------------------------------- */

static void matrox_pan_var(struct matrox_fb_info *minfo,
			   struct fb_var_screeninfo *var)
{}

static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy)
{}

	/*
	 * Open/Release the frame buffer device
	 */

static int matroxfb_open(struct fb_info *info, int user)
{}

static int matroxfb_release(struct fb_info *info, int user)
{}

static int matroxfb_pan_display(struct fb_var_screeninfo *var,
		struct fb_info* info) {}

static int matroxfb_get_final_bppShift(const struct matrox_fb_info *minfo,
				       int bpp)
{}

static int matroxfb_test_and_set_rounding(const struct matrox_fb_info *minfo,
					  int xres, int bpp)
{}

static int matroxfb_pitch_adjust(const struct matrox_fb_info *minfo, int xres,
				 int bpp)
{}

static int matroxfb_get_cmap_len(struct fb_var_screeninfo *var) {}

static int matroxfb_decode_var(const struct matrox_fb_info *minfo,
			       struct fb_var_screeninfo *var, int *visual,
			       int *video_cmap_len, unsigned int* ydstorg)
{}

static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
			      unsigned blue, unsigned transp,
			      struct fb_info *fb_info)
{}

static void matroxfb_init_fix(struct matrox_fb_info *minfo)
{}

static void matroxfb_update_fix(struct matrox_fb_info *minfo)
{}

static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{}

static int matroxfb_set_par(struct fb_info *info)
{}

static int matroxfb_get_vblank(struct matrox_fb_info *minfo,
			       struct fb_vblank *vblank)
{}

static struct matrox_altout panellink_output =;

static int matroxfb_ioctl(struct fb_info *info,
			  unsigned int cmd, unsigned long arg)
{}

/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */

static int matroxfb_blank(int blank, struct fb_info *info)
{}

static const struct fb_ops matroxfb_ops =;

#define RSDepth(X)
#define RS8bpp
#define RS15bpp
#define RS16bpp
#define RS32bpp
#define RS4bpp
#define RS24bpp
#define RSText
#define RSText8
/* 9-F */
static struct {} colors[] =;

/* initialized by setup, see explanation at end of file (search for MODULE_PARM_DESC) */
static unsigned int mem;		/* "matroxfb:mem:xxxxxM" */
static int option_precise_width =;	/* cannot be changed, option_precise_width==0 must imply noaccel */
static int inv24;			/* "matroxfb:inv24" */
static int cross4MB =;		/* "matroxfb:cross4MB" */
static int disabled;			/* "matroxfb:disabled" */
static int noaccel;			/* "matroxfb:noaccel" */
static int nopan;			/* "matroxfb:nopan" */
static int no_pci_retry;		/* "matroxfb:nopciretry" */
static int novga;			/* "matroxfb:novga" */
static int nobios;			/* "matroxfb:nobios" */
static int noinit =;			/* "matroxfb:init" */
static int inverse;			/* "matroxfb:inverse" */
static int sgram;			/* "matroxfb:sgram" */
static int mtrr =;			/* "matroxfb:nomtrr" */
static int grayscale;			/* "matroxfb:grayscale" */
static int dev =;			/* "matroxfb:dev:xxxxx" */
static unsigned int vesa =;		/* "matroxfb:vesa:xxxxx" */
static int depth =;			/* "matroxfb:depth:xxxxx" */
static unsigned int xres;		/* "matroxfb:xres:xxxxx" */
static unsigned int yres;		/* "matroxfb:yres:xxxxx" */
static unsigned int upper =;		/* "matroxfb:upper:xxxxx" */
static unsigned int lower =;		/* "matroxfb:lower:xxxxx" */
static unsigned int vslen;		/* "matroxfb:vslen:xxxxx" */
static unsigned int left =;		/* "matroxfb:left:xxxxx" */
static unsigned int right =;		/* "matroxfb:right:xxxxx" */
static unsigned int hslen;		/* "matroxfb:hslen:xxxxx" */
static unsigned int pixclock;		/* "matroxfb:pixclock:xxxxx" */
static int sync =;			/* "matroxfb:sync:xxxxx" */
static unsigned int fv;			/* "matroxfb:fv:xxxxx" */
static unsigned int fh;			/* "matroxfb:fh:xxxxxk" */
static unsigned int maxclk;		/* "matroxfb:maxclk:xxxxM" */
static int dfp;				/* "matroxfb:dfp */
static int dfp_type =;		/* "matroxfb:dfp:xxx */
static int memtype =;		/* "matroxfb:memtype:xxx" */
static char outputs[8];			/* "matroxfb:outputs:xxx" */

#ifndef MODULE
static char videomode[64];		/* "matroxfb:mode:xxxxx" or "matroxfb:xxxxx" */
#endif

static int matroxfb_getmemory(struct matrox_fb_info *minfo,
			      unsigned int maxSize, unsigned int *realSize)
{}

struct video_board {};
#ifdef CONFIG_FB_MATROX_MILLENIUM
static struct video_board vbMillennium =;

static struct video_board vbMillennium2 =;

static struct video_board vbMillennium2A =;
#endif	/* CONFIG_FB_MATROX_MILLENIUM */
#ifdef CONFIG_FB_MATROX_MYSTIQUE
static struct video_board vbMystique =;
#endif	/* CONFIG_FB_MATROX_MYSTIQUE */
#ifdef CONFIG_FB_MATROX_G
static struct video_board vbG100 =;

static struct video_board vbG200 =;
static struct video_board vbG200eW =;
/* from doc it looks like that accelerator can draw only to low 16MB :-( Direct accesses & displaying are OK for
   whole 32MB */
static struct video_board vbG400 =;
#endif

#define DEVF_VIDEO64BIT
#define DEVF_SWAPS
#define DEVF_SRCORG
#define DEVF_DUALHEAD
#define DEVF_CROSS4MB
#define DEVF_TEXT4B
/* #define DEVF_recycled	0x0040	*/
/* #define DEVF_recycled	0x0080	*/
#define DEVF_SUPPORT32MB
#define DEVF_ANY_VXRES
#define DEVF_TEXT16B
#define DEVF_CRTC2
#define DEVF_MAVEN_CAPABLE
#define DEVF_PANELLINK_CAPABLE
#define DEVF_G450DAC

#define DEVF_GCORE
#define DEVF_G2CORE
#define DEVF_G100
#define DEVF_G200
#define DEVF_G400
/* if you'll find how to drive DFP... */
#define DEVF_G450
#define DEVF_G550

static struct board {} dev_list[] =;

#ifndef MODULE
static const struct fb_videomode defaultmode =;

static int hotplug =;
#endif /* !MODULE */

static void setDefaultOutputs(struct matrox_fb_info *minfo)
{}

static int initMatrox2(struct matrox_fb_info *minfo, struct board *b)
{}

static LIST_HEAD(matroxfb_list);
static LIST_HEAD(matroxfb_driver_list);

#define matroxfb_l(x)
#define matroxfb_driver_l(x)
int matroxfb_register_driver(struct matroxfb_driver* drv) {}

void matroxfb_unregister_driver(struct matroxfb_driver* drv) {}

static void matroxfb_register_device(struct matrox_fb_info* minfo) {}

static void matroxfb_unregister_device(struct matrox_fb_info* minfo) {}

static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dummy) {}

static void pci_remove_matrox(struct pci_dev* pdev) {}

static const struct pci_device_id matroxfb_devices[] =;

MODULE_DEVICE_TABLE(pci, matroxfb_devices);


static struct pci_driver matroxfb_driver =;

/* **************************** init-time only **************************** */

#define RSResolution(X)
#define RS640x400
#define RS640x480
#define RS800x600
#define RS1024x768
#define RS1280x1024
#define RS1600x1200
#define RS768x576
#define RS960x720
#define RS1152x864
#define RS1408x1056
#define RS640x350
#define RS1056x344
#define RS1056x400
#define RS1056x480
#define RSNoxNo
/* 10-FF */
static struct {} timmings[] __initdata =;

#define RSCreate(X,Y)
static struct {} *RSptr, vesamap[] __initdata =;

static void __init matroxfb_init_params(void) {}

static int __init matrox_init(void) {}

/* **************************** exit-time only **************************** */

static void __exit matrox_done(void) {}

#ifndef MODULE

/* ************************* init in-kernel code ************************** */

static int __init matroxfb_setup(char *options) {}

static int __initdata initialized =;

static int __init matroxfb_init(void)
{}

#else

/* *************************** init module code **************************** */

MODULE_AUTHOR("(c) 1998-2002 Petr Vandrovec <[email protected]>");
MODULE_DESCRIPTION("Accelerated FBDev driver for Matrox Millennium/Mystique/G100/G200/G400/G450/G550");
MODULE_LICENSE("GPL");

module_param(mem, int, 0);
MODULE_PARM_DESC(mem, "Size of available memory in MB, KB or B (2,4,8,12,16MB, default=autodetect)");
module_param(disabled, int, 0);
MODULE_PARM_DESC(disabled, "Disabled (0 or 1=disabled) (default=0)");
module_param(noaccel, int, 0);
MODULE_PARM_DESC(noaccel, "Do not use accelerating engine (0 or 1=disabled) (default=0)");
module_param(nopan, int, 0);
MODULE_PARM_DESC(nopan, "Disable pan on startup (0 or 1=disabled) (default=0)");
module_param(no_pci_retry, int, 0);
MODULE_PARM_DESC(no_pci_retry, "PCI retries enabled (0 or 1=disabled) (default=0)");
module_param(novga, int, 0);
MODULE_PARM_DESC(novga, "VGA I/O (0x3C0-0x3DF) disabled (0 or 1=disabled) (default=0)");
module_param(nobios, int, 0);
MODULE_PARM_DESC(nobios, "Disables ROM BIOS (0 or 1=disabled) (default=do not change BIOS state)");
module_param(noinit, int, 0);
MODULE_PARM_DESC(noinit, "Disables W/SG/SD-RAM and bus interface initialization (0 or 1=do not initialize) (default=0)");
module_param(memtype, int, 0);
MODULE_PARM_DESC(memtype, "Memory type for G200/G400 (see Documentation/fb/matroxfb.rst for explanation) (default=3 for G200, 0 for G400)");
module_param(mtrr, int, 0);
MODULE_PARM_DESC(mtrr, "This speeds up video memory accesses (0=disabled or 1) (default=1)");
module_param(sgram, int, 0);
MODULE_PARM_DESC(sgram, "Indicates that G100/G200/G400 has SGRAM memory (0=SDRAM, 1=SGRAM) (default=0)");
module_param(inv24, int, 0);
MODULE_PARM_DESC(inv24, "Inverts clock polarity for 24bpp and loop frequency > 100MHz (default=do not invert polarity)");
module_param(inverse, int, 0);
MODULE_PARM_DESC(inverse, "Inverse (0 or 1) (default=0)");
module_param(dev, int, 0);
MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=all working)");
module_param(vesa, int, 0);
MODULE_PARM_DESC(vesa, "Startup videomode (0x000-0x1FF) (default=0x101)");
module_param(xres, int, 0);
MODULE_PARM_DESC(xres, "Horizontal resolution (px), overrides xres from vesa (default=vesa)");
module_param(yres, int, 0);
MODULE_PARM_DESC(yres, "Vertical resolution (scans), overrides yres from vesa (default=vesa)");
module_param(upper, int, 0);
MODULE_PARM_DESC(upper, "Upper blank space (scans), overrides upper from vesa (default=vesa)");
module_param(lower, int, 0);
MODULE_PARM_DESC(lower, "Lower blank space (scans), overrides lower from vesa (default=vesa)");
module_param(vslen, int, 0);
MODULE_PARM_DESC(vslen, "Vertical sync length (scans), overrides lower from vesa (default=vesa)");
module_param(left, int, 0);
MODULE_PARM_DESC(left, "Left blank space (px), overrides left from vesa (default=vesa)");
module_param(right, int, 0);
MODULE_PARM_DESC(right, "Right blank space (px), overrides right from vesa (default=vesa)");
module_param(hslen, int, 0);
MODULE_PARM_DESC(hslen, "Horizontal sync length (px), overrides hslen from vesa (default=vesa)");
module_param(pixclock, int, 0);
MODULE_PARM_DESC(pixclock, "Pixelclock (ns), overrides pixclock from vesa (default=vesa)");
module_param(sync, int, 0);
MODULE_PARM_DESC(sync, "Sync polarity, overrides sync from vesa (default=vesa)");
module_param(depth, int, 0);
MODULE_PARM_DESC(depth, "Color depth (0=text,8,15,16,24,32) (default=vesa)");
module_param(maxclk, int, 0);
MODULE_PARM_DESC(maxclk, "Startup maximal clock, 0-999MHz, 1000-999999kHz, 1000000-INF Hz");
module_param(fh, int, 0);
MODULE_PARM_DESC(fh, "Startup horizontal frequency, 0-999kHz, 1000-INF Hz");
module_param(fv, int, 0);
MODULE_PARM_DESC(fv, "Startup vertical frequency, 0-INF Hz\n"
"You should specify \"fv:max_monitor_vsync,fh:max_monitor_hsync,maxclk:max_monitor_dotclock\"");
module_param(grayscale, int, 0);
MODULE_PARM_DESC(grayscale, "Sets display into grayscale. Works perfectly with paletized videomode (4, 8bpp), some limitations apply to 16, 24 and 32bpp videomodes (default=nograyscale)");
module_param(cross4MB, int, 0);
MODULE_PARM_DESC(cross4MB, "Specifies that 4MB boundary can be in middle of line. (default=autodetected)");
module_param(dfp, int, 0);
MODULE_PARM_DESC(dfp, "Specifies whether to use digital flat panel interface of G200/G400 (0 or 1) (default=0)");
module_param(dfp_type, int, 0);
MODULE_PARM_DESC(dfp_type, "Specifies DFP interface type (0 to 255) (default=read from hardware)");
module_param_string(outputs, outputs, sizeof(outputs), 0);
MODULE_PARM_DESC(outputs, "Specifies which CRTC is mapped to which output (string of up to three letters, consisting of 0 (disabled), 1 (CRTC1), 2 (CRTC2)) (default=111 for Gx50, 101 for G200/G400 with DFP, and 100 for all other devices)");
#ifdef CONFIG_PPC_PMAC
module_param_named(vmode, default_vmode, int, 0);
MODULE_PARM_DESC(vmode, "Specify the vmode mode number that should be used (640x480 default)");
module_param_named(cmode, default_cmode, int, 0);
MODULE_PARM_DESC(cmode, "Specify the video depth that should be used (8bit default)");
#endif

static int __init matroxfb_init(void){

	DBG(__func__)

	if (disabled)
		return -ENXIO;

	if (depth == 0)
		depth = RSText;
	else if (depth == 4)
		depth = RS4bpp;
	else if (depth == 8)
		depth = RS8bpp;
	else if (depth == 15)
		depth = RS15bpp;
	else if (depth == 16)
		depth = RS16bpp;
	else if (depth == 24)
		depth = RS24bpp;
	else if (depth == 32)
		depth = RS32bpp;
	else if (depth != -1) {
		printk(KERN_ERR "matroxfb: depth %d is not supported, using default\n", depth);
		depth = -1;
	}
	matrox_init();
	/* never return failure; user can hotplug matrox later... */
	return 0;
}
#endif	/* MODULE */

module_init();
module_exit(matrox_done);
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();