[PATCH] mgag200: initial g200se driver

2012-04-26 Thread Ville Syrjälä
On Thu, Apr 26, 2012 at 02:48:45PM +0100, Dave Airlie wrote:
> From: Dave Airlie 
> 
> This is a driver for the G200 server engines chips,
> it doesn't driver any of the Matrix G series desktop cards.

BTW I have a pile of modesetting and card initialization code
written for all mga chips from 2064W up to G550, except these
G200 server variants.

It's mostly in userspace but I wrote some wrappers for kernel APIs,
so most of the code looks like kernel code (not drm/kms code though).

It was a night/weekend project for me at some point, and my plan was
to make a kms driver out of it, but I ran out of steam before I got
that far. I suppose I should try to get off my ass and do something
useful with that code.

-- 
Ville Syrj?l?
syrjala at sci.fi
http://www.sci.fi/~syrjala/


[PATCH] mgag200: initial g200se driver

2012-04-26 Thread Matt Turner
On Thu, Apr 26, 2012 at 9:48 AM, Dave Airlie  wrote:
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
> b/drivers/gpu/drm/mgag200/mgag200_mode.c
> new file mode 100644
> index 000..a74f946
> --- /dev/null
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -0,0 +1,1494 @@
> +/*
> + * Copyright 2000,2001 Sven Luther.

Here...

> + * Copyright 2010 Matt Turner.
> + * Copyright 2011 Red Hat 
> + *
> + * This file is subject to the terms and conditions of the GNU General
> + * Public License version 2. See the file COPYING in the main
> + * directory of this archive for more details.
> + *
> + * Authors: Matthew Garrett
> + * ? ? ? ? ? ? ? ? ? ? Matt Turner
> + * ? ? ? ? ? ? ? ? ? ? Sven Luther
> + * ? ? ? ? ? ? ? ? ? ? Thomas Witzel
> + * ? ? ? ? ? ? ? ? ? ? Alan Hourihane

and here, the copyrights and authorship for Sven Luther, Thomas
Witzel, and Alan Hourihane can be dropped. When I wrote glint_crtc.c,
I copied PM3DAC_CalculateClock from xf86-video-glint. With no remnants
of this function left, none of the code was written by them.


[PATCH] mgag200: initial g200se driver

2012-04-26 Thread Dave Airlie
From: Dave Airlie 

This is a driver for the G200 server engines chips,
it doesn't driver any of the Matrix G series desktop cards.

It will bind to G200 SE A,B, G200EV, G200WB, G200EH and G200ER cards.

Its based on previous work done my Matthew Garrett but remodelled
to follow the same style and flow as the AST server driver. It also
works along the same lines as the AST server driver wrt memory management.

There is no userspace driver planned, xf86-video-modesetting should be used.
It also appears these GPUs have no ARGB hw cursors.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/Kconfig|1 +
 drivers/gpu/drm/Makefile   |1 +
 drivers/gpu/drm/mgag200/Kconfig|8 +
 drivers/gpu/drm/mgag200/Makefile   |5 +
 drivers/gpu/drm/mgag200/mgag200_drv.c  |  115 +++
 drivers/gpu/drm/mgag200/mgag200_drv.h  |  274 ++
 drivers/gpu/drm/mgag200/mgag200_fb.c   |  293 +++
 drivers/gpu/drm/mgag200/mgag200_i2c.c  |  129 +++
 drivers/gpu/drm/mgag200/mgag200_main.c |  388 +
 drivers/gpu/drm/mgag200/mgag200_mode.c | 1494 
 drivers/gpu/drm/mgag200/mgag200_reg.h  |  659 ++
 drivers/gpu/drm/mgag200/mgag200_ttm.c  |  452 ++
 12 files changed, 3819 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/mgag200/Kconfig
 create mode 100644 drivers/gpu/drm/mgag200/Makefile
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_drv.c
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_drv.h
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_fb.c
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_i2c.c
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_main.c
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_mode.c
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_reg.h
 create mode 100644 drivers/gpu/drm/mgag200/mgag200_ttm.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 514049f..47b1d3a 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -167,3 +167,4 @@ source "drivers/gpu/drm/gma500/Kconfig"

 source "drivers/gpu/drm/ast/Kconfig"

+source "drivers/gpu/drm/mgag200/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index bd76195..0d91e1a 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_DRM_RADEON)+= radeon/
 obj-$(CONFIG_DRM_MGA)  += mga/
 obj-$(CONFIG_DRM_I810) += i810/
 obj-$(CONFIG_DRM_I915)  += i915/
+obj-$(CONFIG_DRM_MGAG200) += mgag200/
 obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
 obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
diff --git a/drivers/gpu/drm/mgag200/Kconfig b/drivers/gpu/drm/mgag200/Kconfig
new file mode 100644
index 000..9bc979f
--- /dev/null
+++ b/drivers/gpu/drm/mgag200/Kconfig
@@ -0,0 +1,8 @@
+config DRM_MGAG200
+   tristate "Kernel modesetting driver for MGA G200 server engines"
+   depends on DRM && PCI
+   select FB_SYS_FILLRECT
+   select FB_SYS_COPYAREA
+   select FB_SYS_IMAGEBLIT
+   select DRM_KMS_HELPER
+
diff --git a/drivers/gpu/drm/mgag200/Makefile b/drivers/gpu/drm/mgag200/Makefile
new file mode 100644
index 000..7db592e
--- /dev/null
+++ b/drivers/gpu/drm/mgag200/Makefile
@@ -0,0 +1,5 @@
+ccflags-y := -Iinclude/drm
+mgag200-y   := mgag200_main.o mgag200_mode.o \
+   mgag200_drv.o mgag200_fb.o mgag200_i2c.o mgag200_ttm.o
+
+obj-$(CONFIG_DRM_MGAG200) += mgag200.o
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
new file mode 100644
index 000..cf5cea2
--- /dev/null
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2010 Matt Turner.
+ * Copyright 2011 Red Hat 
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License version 2. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * Authors: Matthew Garrett
+ * Matt Turner
+ */
+#include 
+#include 
+#include "drmP.h"
+#include "drm.h"
+
+#include "mgag200_drv.h"
+
+#include "drm_pciids.h"
+
+/*
+ * This is the generic driver code. This binds the driver to the drm core,
+ * which then performs further device association and calls our graphics init
+ * functions
+ */
+int mgag200_modeset = -1;
+
+MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
+module_param_named(modeset, mgag200_modeset, int, 0400);
+
+static struct drm_driver driver;
+
+static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
+   { PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A 
},
+   { PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B 
},
+   { PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV },
+   { PCI_VENDOR_ID_MATROX, 0x532, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_WB },
+   { PCI_VENDOR_ID_MATROX, 0x533, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EH },
+   { PCI_VENDOR_ID_MATROX, 0x534, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_ER },
+   

[PATCH] mgag200: initial g200se driver

2012-04-26 Thread Adam Jackson
On Thu, 2012-04-26 at 14:48 +0100, Dave Airlie wrote:

> +/*
> + * Our emulated hardware has two sets of memory. One is video RAM and can
> + * simply be used as a linear framebuffer - the other provides mmio access
> + * to the display registers. The latter can also be accessed via IO port
> + * access, but we map the range and use mmio to program them instead
> + */

I suspect this comment came from somewhere near the emulated cirrus card
in qemu?  G200's definitely not emulated hardware.

> +/*
> + * The meat of this driver. The core passes us a mode and we have to program
> + * it. The modesetting here is the bare minimum required to satisfy the qemu
> + * emulation of this hardware, and running this against a real device is
> + * likely to result in an inadequately programmed mode. We've already had
> + * the opportunity to modify the mode, so whatever we receive here should
> + * be something that can be correctly programmed and displayed
> + */

Yep, drm/cirrus all over the place here.

> +/*
> + * This is called after a mode is programmed. It should reverse anything done
> + * by the prepare function
> + */
> +static void mga_crtc_commit(struct drm_crtc *crtc)
> +{

This appears to be missing the analog of the "Reset tagfifo" commit from
the X driver for G200ER:

http://cgit.freedesktop.org/xorg/driver/xf86-video-mga/commit/?id=01ca2186ea028b2549de509b51726aa08519fce0

Which, admittedly, is in an odd place in the X driver.

- ajax
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: 



Re: [PATCH] mgag200: initial g200se driver

2012-04-26 Thread Adam Jackson
On Thu, 2012-04-26 at 14:48 +0100, Dave Airlie wrote:

 +/*
 + * Our emulated hardware has two sets of memory. One is video RAM and can
 + * simply be used as a linear framebuffer - the other provides mmio access
 + * to the display registers. The latter can also be accessed via IO port
 + * access, but we map the range and use mmio to program them instead
 + */

I suspect this comment came from somewhere near the emulated cirrus card
in qemu?  G200's definitely not emulated hardware.

 +/*
 + * The meat of this driver. The core passes us a mode and we have to program
 + * it. The modesetting here is the bare minimum required to satisfy the qemu
 + * emulation of this hardware, and running this against a real device is
 + * likely to result in an inadequately programmed mode. We've already had
 + * the opportunity to modify the mode, so whatever we receive here should
 + * be something that can be correctly programmed and displayed
 + */

Yep, drm/cirrus all over the place here.

 +/*
 + * This is called after a mode is programmed. It should reverse anything done
 + * by the prepare function
 + */
 +static void mga_crtc_commit(struct drm_crtc *crtc)
 +{

This appears to be missing the analog of the Reset tagfifo commit from
the X driver for G200ER:

http://cgit.freedesktop.org/xorg/driver/xf86-video-mga/commit/?id=01ca2186ea028b2549de509b51726aa08519fce0

Which, admittedly, is in an odd place in the X driver.

- ajax


signature.asc
Description: This is a digitally signed message part
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] mgag200: initial g200se driver

2012-04-26 Thread Ville Syrjälä
On Thu, Apr 26, 2012 at 02:48:45PM +0100, Dave Airlie wrote:
 From: Dave Airlie airl...@redhat.com
 
 This is a driver for the G200 server engines chips,
 it doesn't driver any of the Matrix G series desktop cards.

BTW I have a pile of modesetting and card initialization code
written for all mga chips from 2064W up to G550, except these
G200 server variants.

It's mostly in userspace but I wrote some wrappers for kernel APIs,
so most of the code looks like kernel code (not drm/kms code though).

It was a night/weekend project for me at some point, and my plan was
to make a kms driver out of it, but I ran out of steam before I got
that far. I suppose I should try to get off my ass and do something
useful with that code.

-- 
Ville Syrjälä
syrj...@sci.fi
http://www.sci.fi/~syrjala/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] mgag200: initial g200se driver

2012-04-26 Thread Matt Turner
On Thu, Apr 26, 2012 at 9:48 AM, Dave Airlie airl...@gmail.com wrote:
 diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c 
 b/drivers/gpu/drm/mgag200/mgag200_mode.c
 new file mode 100644
 index 000..a74f946
 --- /dev/null
 +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
 @@ -0,0 +1,1494 @@
 +/*
 + * Copyright 2000,2001 Sven Luther.

Here...

 + * Copyright 2010 Matt Turner.
 + * Copyright 2011 Red Hat m...@redhat.com
 + *
 + * This file is subject to the terms and conditions of the GNU General
 + * Public License version 2. See the file COPYING in the main
 + * directory of this archive for more details.
 + *
 + * Authors: Matthew Garrett
 + *                     Matt Turner
 + *                     Sven Luther
 + *                     Thomas Witzel
 + *                     Alan Hourihane

and here, the copyrights and authorship for Sven Luther, Thomas
Witzel, and Alan Hourihane can be dropped. When I wrote glint_crtc.c,
I copied PM3DAC_CalculateClock from xf86-video-glint. With no remnants
of this function left, none of the code was written by them.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel