2005-04-16 16:20:36 -06:00
|
|
|
/* mga_warp.c -- Matrox G200/G400 WARP engine management -*- linux-c -*-
|
|
|
|
* Created: Thu Jan 11 21:29:32 2001 by gareth@valinux.com
|
|
|
|
*
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Gareth Hughes <gareth@valinux.com>
|
|
|
|
*/
|
|
|
|
|
2009-08-23 11:34:25 -06:00
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/ihex.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#include "drmP.h"
|
|
|
|
#include "drm.h"
|
|
|
|
#include "mga_drm.h"
|
|
|
|
#include "mga_drv.h"
|
2009-08-23 11:34:25 -06:00
|
|
|
|
|
|
|
#define FIRMWARE_G200 "matrox/g200_warp.fw"
|
|
|
|
#define FIRMWARE_G400 "matrox/g400_warp.fw"
|
|
|
|
|
|
|
|
MODULE_FIRMWARE(FIRMWARE_G200);
|
|
|
|
MODULE_FIRMWARE(FIRMWARE_G400);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-09-24 22:28:13 -06:00
|
|
|
#define MGA_WARP_CODE_ALIGN 256 /* in bytes */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-08-23 11:34:25 -06:00
|
|
|
#define WARP_UCODE_SIZE(size) ALIGN(size, MGA_WARP_CODE_ALIGN)
|
|
|
|
|
2010-07-11 17:46:57 -06:00
|
|
|
int mga_warp_install_microcode(drm_mga_private_t *dev_priv)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2009-08-23 11:34:25 -06:00
|
|
|
unsigned char *vcbase = dev_priv->warp->handle;
|
|
|
|
unsigned long pcbase = dev_priv->warp->offset;
|
|
|
|
const char *firmware_name;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
const struct firmware *fw = NULL;
|
|
|
|
const struct ihex_binrec *rec;
|
|
|
|
unsigned int size;
|
|
|
|
int n_pipes, where;
|
|
|
|
int rc = 0;
|
|
|
|
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
switch (dev_priv->chipset) {
|
|
|
|
case MGA_CARD_TYPE_G400:
|
|
|
|
case MGA_CARD_TYPE_G550:
|
2009-08-23 11:34:25 -06:00
|
|
|
firmware_name = FIRMWARE_G400;
|
|
|
|
n_pipes = MGA_MAX_G400_PIPES;
|
|
|
|
break;
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
case MGA_CARD_TYPE_G200:
|
2009-08-23 11:34:25 -06:00
|
|
|
firmware_name = FIRMWARE_G200;
|
|
|
|
n_pipes = MGA_MAX_G200_PIPES;
|
|
|
|
break;
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
default:
|
2009-08-23 11:34:25 -06:00
|
|
|
return -EINVAL;
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-08-23 11:34:25 -06:00
|
|
|
pdev = platform_device_register_simple("mga_warp", 0, NULL, 0);
|
|
|
|
if (IS_ERR(pdev)) {
|
|
|
|
DRM_ERROR("mga: Failed to register microcode\n");
|
|
|
|
return PTR_ERR(pdev);
|
|
|
|
}
|
|
|
|
rc = request_ihex_firmware(&fw, firmware_name, &pdev->dev);
|
|
|
|
platform_device_unregister(pdev);
|
|
|
|
if (rc) {
|
|
|
|
DRM_ERROR("mga: Failed to load microcode \"%s\"\n",
|
|
|
|
firmware_name);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-08-23 11:34:25 -06:00
|
|
|
size = 0;
|
|
|
|
where = 0;
|
|
|
|
for (rec = (const struct ihex_binrec *)fw->data;
|
|
|
|
rec;
|
|
|
|
rec = ihex_next_binrec(rec)) {
|
|
|
|
size += WARP_UCODE_SIZE(be16_to_cpu(rec->len));
|
|
|
|
where++;
|
|
|
|
}
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
|
2009-08-23 11:34:25 -06:00
|
|
|
if (where != n_pipes) {
|
|
|
|
DRM_ERROR("mga: Invalid microcode \"%s\"\n", firmware_name);
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
size = PAGE_ALIGN(size);
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
DRM_DEBUG("MGA ucode size = %d bytes\n", size);
|
|
|
|
if (size > dev_priv->warp->size) {
|
|
|
|
DRM_ERROR("microcode too large! (%u > %lu)\n",
|
|
|
|
size, dev_priv->warp->size);
|
2009-08-23 11:34:25 -06:00
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out;
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
}
|
|
|
|
|
2009-08-23 11:34:25 -06:00
|
|
|
memset(dev_priv->warp_pipe_phys, 0, sizeof(dev_priv->warp_pipe_phys));
|
|
|
|
|
|
|
|
where = 0;
|
|
|
|
for (rec = (const struct ihex_binrec *)fw->data;
|
|
|
|
rec;
|
|
|
|
rec = ihex_next_binrec(rec)) {
|
|
|
|
unsigned int src_size, dst_size;
|
|
|
|
|
|
|
|
DRM_DEBUG(" pcbase = 0x%08lx vcbase = %p\n", pcbase, vcbase);
|
|
|
|
dev_priv->warp_pipe_phys[where] = pcbase;
|
|
|
|
src_size = be16_to_cpu(rec->len);
|
|
|
|
dst_size = WARP_UCODE_SIZE(src_size);
|
|
|
|
memcpy(vcbase, rec->data, src_size);
|
|
|
|
pcbase += dst_size;
|
|
|
|
vcbase += dst_size;
|
|
|
|
where++;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2009-08-23 11:34:25 -06:00
|
|
|
|
|
|
|
out:
|
|
|
|
release_firmware(fw);
|
|
|
|
return rc;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#define WMISC_EXPECTED (MGA_WUCODECACHE_ENABLE | MGA_WMASTER_ENABLE)
|
|
|
|
|
2010-07-11 17:46:57 -06:00
|
|
|
int mga_warp_init(drm_mga_private_t *dev_priv)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 wmisc;
|
|
|
|
|
|
|
|
/* FIXME: Get rid of these damned magic numbers...
|
|
|
|
*/
|
2005-09-24 22:28:13 -06:00
|
|
|
switch (dev_priv->chipset) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case MGA_CARD_TYPE_G400:
|
Add support for PCI MGA cards to MGA DRM.
This patch adds serveral new ioctls and a new query to get_param query to
support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this change,
the client-side driver no longer needs to map the primary DMA region or the
MMIO region. Previously, end-of-frame waiting was done by busy waiting in the
client-side driver until one of the MMIO registers (the current DMA pointer)
matched a pointer to the end of primary DMA space. By using interrupts, the
busy waiting and the extra mappings are removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
X-server, moves a *LOT* of code from the X-server into the kernel. This allows
the kernel to do whatever needs to be done to setup DMA buffers. The entire
process and the locations of the buffers are hidden from user-mode.
Additionally, a get_param query was added to differentiate between G4x0 cards
and G550 cards. A gap was left in the numbering sequence so that, if needed,
G450 cards could be distinguished from G400 cards. According to Ville
Syrjälä, the G4x0 cards and the G550 cards handle anisotropic filtering
differently. This seems the most compatible way to let the client-side driver
know which card it's own. Doing this very small change now eliminates the
need to bump the DRM minor version twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
(airlied - this may not work at this point, I think the follow on buffer
cleanup patches will be needed)
From: Ian Romanick <idr@us.ibm.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
2005-07-10 02:20:09 -06:00
|
|
|
case MGA_CARD_TYPE_G550:
|
|
|
|
MGA_WRITE(MGA_WIADDR2, MGA_WMODE_SUSPEND);
|
|
|
|
MGA_WRITE(MGA_WGETMSB, 0x00000E00);
|
|
|
|
MGA_WRITE(MGA_WVRTXSZ, 0x00001807);
|
|
|
|
MGA_WRITE(MGA_WACCEPTSEQ, 0x18000000);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
case MGA_CARD_TYPE_G200:
|
2005-09-24 22:28:13 -06:00
|
|
|
MGA_WRITE(MGA_WIADDR, MGA_WMODE_SUSPEND);
|
|
|
|
MGA_WRITE(MGA_WGETMSB, 0x1606);
|
|
|
|
MGA_WRITE(MGA_WVRTXSZ, 7);
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
default:
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2005-09-24 22:28:13 -06:00
|
|
|
MGA_WRITE(MGA_WMISC, (MGA_WUCODECACHE_ENABLE |
|
|
|
|
MGA_WMASTER_ENABLE | MGA_WCACHEFLUSH_ENABLE));
|
|
|
|
wmisc = MGA_READ(MGA_WMISC);
|
|
|
|
if (wmisc != WMISC_EXPECTED) {
|
|
|
|
DRM_ERROR("WARP engine config failed! 0x%x != 0x%x\n",
|
|
|
|
wmisc, WMISC_EXPECTED);
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|