//#define CRTC2
// YUY2 support (see config.format) added by A'rpi/ESP-team
// double buffering added by A'rpi/ESP-team
// Set this value, if autodetection fails! (video ram size in megabytes)
// #define MGA_MEMORY_SIZE 16
//#define MGA_ALLOW_IRQ
#define MGA_VSYNC_POS 2
/*
*
* mga_vid.c
*
* Copyright (C) 1999 Aaron Holtzman
*
* Module skeleton based on gutted agpgart module by Jeff Hartmann
* <slicer@ionet.net>
*
* Matrox MGA G200/G400 YUV Video Interface module Version 0.1.0
*
* BES == Back End Scaler
*
* This software has been released under the terms of the GNU Public
* license. See http://www.gnu.org/copyleft/gpl.html for details.
*/
//It's entirely possible this major conflicts with something else
/* mknod /dev/mga_vid c 178 0 */
#include <linux/config.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10)
#include <linux/malloc.h>
#else
#include <linux/slab.h>
#endif
#include <linux/pci.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include "mga_vid.h"
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/io.h>
#define TRUE 1
#define FALSE 0
#define MGA_VID_MAJOR 178
//#define MGA_VIDMEM_SIZE mga_ram_size
#ifndef PCI_DEVICE_ID_MATROX_G200_PCI
#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
#endif
#ifndef PCI_DEVICE_ID_MATROX_G200_AGP
#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
#endif
#ifndef PCI_DEVICE_ID_MATROX_G400
#define PCI_DEVICE_ID_MATROX_G400 0x0525
#endif
#ifndef PCI_DEVICE_ID_MATROX_G550
#define PCI_DEVICE_ID_MATROX_G550 0x2527
#endif
MODULE_AUTHOR("Aaron Holtzman <aholtzma@engr.uvic.ca>");
#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
#endif
#define PARAM_BRIGHTNESS "brightness="
#define PARAM_CONTRAST "contrast="
#define PARAM_BLACKIE "blackie="
#define PARAM_BUFF_SIZE 4096
static uint8_t *mga_param_buff = NULL;
static uint32_t mga_param_buff_size=0;
static uint32_t mga_param_buff_len=0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
#include <linux/ctype.h>
#define min(x,y) (((x)<(y))?(x):(y))
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
{
unsigned long result = 0,value;
if (!base) {
base = 10;
if (*cp == '0') {
base = 8;
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
cp++;
base = 16;
}
}
}
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
? toupper(*cp) : *cp)-'A'+10) < base) {
result = result*base + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
long simple_strtol(const char *cp,char **endp,unsigned int base)
{
if(*cp=='-')
return -simple_strtoul(cp+1,endp,base);
return simple_strtoul(cp,endp,base);
}
#endif
typedef struct bes_registers_s
{
//BES Control
uint32_t besctl;
//BES Global control
uint32_t besglobctl;
//Luma control (brightness and contrast)
uint32_t beslumactl;
//Line pitch
uint32_t bespitch;
//Buffer A-1 Chroma 3 plane org
uint32_t besa1c3org;
//Buffer A-1 Chroma org
uint32_t besa1corg;
//Buffer A-1 Luma org
uint32_t besa1org;
//Buffer A-2 Chroma 3 plane org
uint32_t besa2c3org;
//Buffer A-2 Chroma org
uint32_t besa2corg;
//Buffer A-2 Luma org
uint32_t besa2org;
//Buffer B-1 Chroma 3 plane org
uint32_t besb1c3org;
//Buffer B-1 Chroma org
uint32_t besb1corg;
//Buffer B-1 Luma org
uint32_t besb1org;
//Buffer B-2 Chroma 3 plane org
uint32_t besb2c3org;
//Buffer B-2 Chroma org
uint32_t besb2corg;
//Buffer B-2 Luma org
uint32_t besb2org;
//BES Horizontal coord
uint32_t beshcoord;
//BES Horizontal inverse scaling [5.14]
uint32_t beshiscal;
//BES Horizontal source start [10.14] (for scaling)
uint32_t beshsrcst;
//BES Horizontal source ending [10.14] (for scaling)
uint32_t beshsrcend;
//BES Horizontal source last
uint32_t beshsrclst;
//BES Vertical coord
uint32_t besvcoord;
//BES Vertical inverse scaling [5.14]
uint32_t besviscal;
//BES Field 1 vertical source last position
uint32_t besv1srclst;
//BES Field 1 weight start
uint32_t besv1wght;
//BES Field 2 vertical source last position
uint32_t besv2srclst;
//BES Field 2 weight start
uint32_t besv2wght;
//configurable stuff
int brightness;
int contrast;
int blackie;
} bes_registers_t;
static bes_registers_t regs;
#ifdef CRTC2
typedef struct crtc2_registers_s
{
uint32_t c2ctl;
uint32_t c2datactl;
uint32_t c2misc;
uint32_t c2hparam;
uint32_t c2hsync;
uint32_t c2offset;
uint32_t c2pl2startadd0;
uint32_t c2pl2startadd1;
uint32_t c2pl3startadd0;
uint32_t c2pl3startadd1;
uint32_t c2preload;
uint32_t c2spicstartadd0;
uint32_t c2spicstartadd1;
uint32_t c2startadd0;
uint32_t c2startadd1;
uint32_t c2subpiclut;
uint32_t c2vcount;
uint32_t c2vparam;
uint32_t c2vsync;
} crtc2_registers_t;
static crtc2_registers_t cregs;
#endif
static uint32_t mga_vid_in_use = 0;
static uint32_t is_g400 = 0;
static uint32_t vid_src_ready = 0;
static uint32_t vid_overlay_on = 0;
static uint8_t *mga_mmio_base = 0;
static uint32_t mga_mem_base = 0;
static int mga_src_base = 0; // YUV buffer position in video memory
static uint32_t mga_ram_size = 0; // how much megabytes videoram we have
static uint32_t mga_top_reserved = 0; // reserved space for console font (matroxfb + fastfont)
//static int mga_force_memsize = 0;
MODULE_PARM(mga_ram_size, "i");
MODULE_PARM(mga_top_reserved, "i");
static struct pci_dev *pci_dev;
static mga_vid_config_t mga_config;
static int col
|