2005-04-17 05:20:36 +07:00
|
|
|
/* mga_state.c -- State support for MGA G200/G400 -*- linux-c -*-
|
|
|
|
* Created: Thu Jan 27 02:53:43 2000 by jhartmann@precisioninsight.com
|
|
|
|
*
|
|
|
|
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* 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:
|
|
|
|
* Jeff Hartmann <jhartmann@valinux.com>
|
|
|
|
* Keith Whitwell <keith@tungstengraphics.com>
|
|
|
|
*
|
|
|
|
* Rewritten by:
|
|
|
|
* Gareth Hughes <gareth@valinux.com>
|
|
|
|
*/
|
|
|
|
|
2012-10-03 00:01:07 +07:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/mga_drm.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "mga_drv.h"
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
* DMA hardware state programming functions
|
|
|
|
*/
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_emit_clip_rect(drm_mga_private_t *dev_priv,
|
|
|
|
struct drm_clip_rect *box)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
|
|
|
unsigned int pitch = dev_priv->front_pitch;
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Force reset of DWGCTL on G400 (eliminates clip disable bit).
|
|
|
|
*/
|
2005-10-21 05:49:00 +07:00
|
|
|
if (dev_priv->chipset >= 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 15:20:09 +07:00
|
|
|
DMA_BLOCK(MGA_DWGCTL, ctx->dwgctl,
|
|
|
|
MGA_LEN + MGA_EXEC, 0x80000000,
|
|
|
|
MGA_DWGCTL, ctx->dwgctl,
|
|
|
|
MGA_LEN + MGA_EXEC, 0x80000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
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 15:20:09 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_CXBNDRY, ((box->x2 - 1) << 16) | box->x1,
|
2005-09-25 11:28:13 +07:00
|
|
|
MGA_YTOP, box->y1 * pitch, MGA_YBOT, (box->y2 - 1) * pitch);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g200_emit_context(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(3);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DSTORG, ctx->dstorg,
|
|
|
|
MGA_MACCESS, ctx->maccess,
|
|
|
|
MGA_PLNWT, ctx->plnwt, MGA_DWGCTL, ctx->dwgctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_ALPHACTRL, ctx->alphactrl,
|
|
|
|
MGA_FOGCOL, ctx->fogcolor,
|
|
|
|
MGA_WFLAG, ctx->wflag, MGA_ZORG, dev_priv->depth_offset);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_FCOL, ctx->fcol,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g400_emit_context(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(4);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DSTORG, ctx->dstorg,
|
|
|
|
MGA_MACCESS, ctx->maccess,
|
|
|
|
MGA_PLNWT, ctx->plnwt, MGA_DWGCTL, ctx->dwgctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_ALPHACTRL, ctx->alphactrl,
|
|
|
|
MGA_FOGCOL, ctx->fogcolor,
|
|
|
|
MGA_WFLAG, ctx->wflag, MGA_ZORG, dev_priv->depth_offset);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WFLAG1, ctx->wflag,
|
|
|
|
MGA_TDUALSTAGE0, ctx->tdualstage0,
|
|
|
|
MGA_TDUALSTAGE1, ctx->tdualstage1, MGA_FCOL, ctx->fcol);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_STENCIL, ctx->stencil,
|
|
|
|
MGA_STENCILCTL, ctx->stencilctl,
|
|
|
|
MGA_DMAPAD, 0x00000000, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g200_emit_tex0(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[0];
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(4);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXCTL2, tex->texctl2,
|
|
|
|
MGA_TEXCTL, tex->texctl,
|
|
|
|
MGA_TEXFILTER, tex->texfilter,
|
|
|
|
MGA_TEXBORDERCOL, tex->texbordercol);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXORG, tex->texorg,
|
|
|
|
MGA_TEXORG1, tex->texorg1,
|
|
|
|
MGA_TEXORG2, tex->texorg2, MGA_TEXORG3, tex->texorg3);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXORG4, tex->texorg4,
|
|
|
|
MGA_TEXWIDTH, tex->texwidth,
|
|
|
|
MGA_TEXHEIGHT, tex->texheight, MGA_WR24, tex->texwidth);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR34, tex->texheight,
|
|
|
|
MGA_TEXTRANS, 0x0000ffff,
|
|
|
|
MGA_TEXTRANSHIGH, 0x0000ffff, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g400_emit_tex0(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[0];
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2007-11-05 09:50:58 +07:00
|
|
|
/* printk("mga_g400_emit_tex0 %x %x %x\n", tex->texorg, */
|
|
|
|
/* tex->texctl, tex->texctl2); */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(6);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXCTL2, tex->texctl2 | MGA_G400_TC2_MAGIC,
|
|
|
|
MGA_TEXCTL, tex->texctl,
|
|
|
|
MGA_TEXFILTER, tex->texfilter,
|
|
|
|
MGA_TEXBORDERCOL, tex->texbordercol);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXORG, tex->texorg,
|
|
|
|
MGA_TEXORG1, tex->texorg1,
|
|
|
|
MGA_TEXORG2, tex->texorg2, MGA_TEXORG3, tex->texorg3);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXORG4, tex->texorg4,
|
|
|
|
MGA_TEXWIDTH, tex->texwidth,
|
|
|
|
MGA_TEXHEIGHT, tex->texheight, MGA_WR49, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR57, 0x00000000,
|
|
|
|
MGA_WR53, 0x00000000,
|
|
|
|
MGA_WR61, 0x00000000, MGA_WR52, MGA_G400_WR_MAGIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR60, MGA_G400_WR_MAGIC,
|
|
|
|
MGA_WR54, tex->texwidth | MGA_G400_WR_MAGIC,
|
|
|
|
MGA_WR62, tex->texheight | MGA_G400_WR_MAGIC,
|
|
|
|
MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_TEXTRANS, 0x0000ffff, MGA_TEXTRANSHIGH, 0x0000ffff);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g400_emit_tex1(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[1];
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2007-11-05 09:50:58 +07:00
|
|
|
/* printk("mga_g400_emit_tex1 %x %x %x\n", tex->texorg, */
|
|
|
|
/* tex->texctl, tex->texctl2); */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(5);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXCTL2, (tex->texctl2 |
|
|
|
|
MGA_MAP1_ENABLE |
|
|
|
|
MGA_G400_TC2_MAGIC),
|
|
|
|
MGA_TEXCTL, tex->texctl,
|
|
|
|
MGA_TEXFILTER, tex->texfilter,
|
|
|
|
MGA_TEXBORDERCOL, tex->texbordercol);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXORG, tex->texorg,
|
|
|
|
MGA_TEXORG1, tex->texorg1,
|
|
|
|
MGA_TEXORG2, tex->texorg2, MGA_TEXORG3, tex->texorg3);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_TEXORG4, tex->texorg4,
|
|
|
|
MGA_TEXWIDTH, tex->texwidth,
|
|
|
|
MGA_TEXHEIGHT, tex->texheight, MGA_WR49, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR57, 0x00000000,
|
|
|
|
MGA_WR53, 0x00000000,
|
|
|
|
MGA_WR61, 0x00000000,
|
|
|
|
MGA_WR52, tex->texwidth | MGA_G400_WR_MAGIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR60, tex->texheight | MGA_G400_WR_MAGIC,
|
|
|
|
MGA_TEXTRANS, 0x0000ffff,
|
|
|
|
MGA_TEXTRANSHIGH, 0x0000ffff,
|
|
|
|
MGA_TEXCTL2, tex->texctl2 | MGA_G400_TC2_MAGIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g200_emit_pipe(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
unsigned int pipe = sarea_priv->warp_pipe;
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(3);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WIADDR, MGA_WMODE_SUSPEND,
|
|
|
|
MGA_WVRTXSZ, 0x00000007,
|
|
|
|
MGA_WFLAG, 0x00000000, MGA_WR24, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR25, 0x00000100,
|
|
|
|
MGA_WR34, 0x00000000,
|
|
|
|
MGA_WR42, 0x0000ffff, MGA_WR60, 0x0000ffff);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-07-16 22:13:03 +07:00
|
|
|
/* Padding required due to hardware bug.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
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 15:20:09 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0xffffffff,
|
|
|
|
MGA_DMAPAD, 0xffffffff,
|
|
|
|
MGA_DMAPAD, 0xffffffff,
|
|
|
|
MGA_WIADDR, (dev_priv->warp_pipe_phys[pipe] |
|
|
|
|
MGA_WMODE_START | dev_priv->wagp_enable));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static __inline__ void mga_g400_emit_pipe(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
unsigned int pipe = sarea_priv->warp_pipe;
|
|
|
|
DMA_LOCALS;
|
|
|
|
|
2007-11-05 09:50:58 +07:00
|
|
|
/* printk("mga_g400_emit_pipe %x\n", pipe); */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(10);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WIADDR2, MGA_WMODE_SUSPEND,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (pipe & MGA_T2) {
|
|
|
|
DMA_BLOCK(MGA_WVRTXSZ, 0x00001e09,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WACCEPTSEQ, 0x00000000,
|
|
|
|
MGA_WACCEPTSEQ, 0x00000000,
|
|
|
|
MGA_WACCEPTSEQ, 0x00000000,
|
|
|
|
MGA_WACCEPTSEQ, 0x1e000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dev_priv->warp_pipe & MGA_T2) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Flush the WARP pipe */
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_YDST, 0x00000000,
|
|
|
|
MGA_FXLEFT, 0x00000000,
|
|
|
|
MGA_FXRIGHT, 0x00000001,
|
|
|
|
MGA_DWGCTL, MGA_DWGCTL_FLUSH);
|
|
|
|
|
|
|
|
DMA_BLOCK(MGA_LEN + MGA_EXEC, 0x00000001,
|
|
|
|
MGA_DWGSYNC, 0x00007000,
|
|
|
|
MGA_TEXCTL2, MGA_G400_TC2_MAGIC,
|
|
|
|
MGA_LEN + MGA_EXEC, 0x00000000);
|
|
|
|
|
|
|
|
DMA_BLOCK(MGA_TEXCTL2, (MGA_DUALTEX |
|
|
|
|
MGA_G400_TC2_MAGIC),
|
|
|
|
MGA_LEN + MGA_EXEC, 0x00000000,
|
|
|
|
MGA_TEXCTL2, MGA_G400_TC2_MAGIC,
|
|
|
|
MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WVRTXSZ, 0x00001807,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WACCEPTSEQ, 0x00000000,
|
|
|
|
MGA_WACCEPTSEQ, 0x00000000,
|
|
|
|
MGA_WACCEPTSEQ, 0x00000000,
|
|
|
|
MGA_WACCEPTSEQ, 0x18000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WFLAG, 0x00000000,
|
|
|
|
MGA_WFLAG1, 0x00000000,
|
|
|
|
MGA_WR56, MGA_G400_WR56_MAGIC, MGA_DMAPAD, 0x00000000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR49, 0x00000000, /* tex0 */
|
|
|
|
MGA_WR57, 0x00000000, /* tex0 */
|
|
|
|
MGA_WR53, 0x00000000, /* tex1 */
|
|
|
|
MGA_WR61, 0x00000000); /* tex1 */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_WR54, MGA_G400_WR_MAGIC, /* tex0 width */
|
|
|
|
MGA_WR62, MGA_G400_WR_MAGIC, /* tex0 height */
|
|
|
|
MGA_WR52, MGA_G400_WR_MAGIC, /* tex1 width */
|
|
|
|
MGA_WR60, MGA_G400_WR_MAGIC); /* tex1 height */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-07-16 22:13:03 +07:00
|
|
|
/* Padding required due to hardware bug */
|
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 15:20:09 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0xffffffff,
|
|
|
|
MGA_DMAPAD, 0xffffffff,
|
|
|
|
MGA_DMAPAD, 0xffffffff,
|
|
|
|
MGA_WIADDR2, (dev_priv->warp_pipe_phys[pipe] |
|
|
|
|
MGA_WMODE_START | dev_priv->wagp_enable));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_g200_emit_state(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
unsigned int dirty = sarea_priv->dirty;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (sarea_priv->warp_pipe != dev_priv->warp_pipe) {
|
|
|
|
mga_g200_emit_pipe(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev_priv->warp_pipe = sarea_priv->warp_pipe;
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_CONTEXT) {
|
|
|
|
mga_g200_emit_context(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->dirty &= ~MGA_UPLOAD_CONTEXT;
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_TEX0) {
|
|
|
|
mga_g200_emit_tex0(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->dirty &= ~MGA_UPLOAD_TEX0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_g400_emit_state(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
unsigned int dirty = sarea_priv->dirty;
|
|
|
|
int multitex = sarea_priv->warp_pipe & MGA_T2;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (sarea_priv->warp_pipe != dev_priv->warp_pipe) {
|
|
|
|
mga_g400_emit_pipe(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev_priv->warp_pipe = sarea_priv->warp_pipe;
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_CONTEXT) {
|
|
|
|
mga_g400_emit_context(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->dirty &= ~MGA_UPLOAD_CONTEXT;
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_TEX0) {
|
|
|
|
mga_g400_emit_tex0(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->dirty &= ~MGA_UPLOAD_TEX0;
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if ((dirty & MGA_UPLOAD_TEX1) && multitex) {
|
|
|
|
mga_g400_emit_tex1(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->dirty &= ~MGA_UPLOAD_TEX1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
* SAREA state verification
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Disallow all write destinations except the front and backbuffer.
|
|
|
|
*/
|
2010-07-12 06:46:57 +07:00
|
|
|
static int mga_verify_context(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (ctx->dstorg != dev_priv->front_offset &&
|
|
|
|
ctx->dstorg != dev_priv->back_offset) {
|
|
|
|
DRM_ERROR("*** bad DSTORG: %x (front %x, back %x)\n\n",
|
|
|
|
ctx->dstorg, dev_priv->front_offset,
|
|
|
|
dev_priv->back_offset);
|
2005-04-17 05:20:36 +07:00
|
|
|
ctx->dstorg = 0;
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disallow texture reads from PCI space.
|
|
|
|
*/
|
2010-07-12 06:46:57 +07:00
|
|
|
static int mga_verify_tex(drm_mga_private_t *dev_priv, int unit)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_texture_regs_t *tex = &sarea_priv->tex_state[unit];
|
|
|
|
unsigned int org;
|
|
|
|
|
|
|
|
org = tex->texorg & (MGA_TEXORGMAP_MASK | MGA_TEXORGACC_MASK);
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (org == (MGA_TEXORGMAP_SYSMEM | MGA_TEXORGACC_PCI)) {
|
|
|
|
DRM_ERROR("*** bad TEXORG: 0x%x, unit %d\n", tex->texorg, unit);
|
2005-04-17 05:20:36 +07:00
|
|
|
tex->texorg = 0;
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static int mga_verify_state(drm_mga_private_t *dev_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
unsigned int dirty = sarea_priv->dirty;
|
|
|
|
int ret = 0;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_CONTEXT)
|
|
|
|
ret |= mga_verify_context(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_TEX0)
|
|
|
|
ret |= mga_verify_tex(dev_priv, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
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 15:20:09 +07:00
|
|
|
if (dev_priv->chipset >= MGA_CARD_TYPE_G400) {
|
|
|
|
if (dirty & MGA_UPLOAD_TEX1)
|
|
|
|
ret |= mga_verify_tex(dev_priv, 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_PIPE)
|
|
|
|
ret |= (sarea_priv->warp_pipe > MGA_MAX_G400_PIPES);
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dirty & MGA_UPLOAD_PIPE)
|
|
|
|
ret |= (sarea_priv->warp_pipe > MGA_MAX_G200_PIPES);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
return (ret == 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static int mga_verify_iload(drm_mga_private_t *dev_priv,
|
2005-09-25 11:28:13 +07:00
|
|
|
unsigned int dstorg, unsigned int length)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-09-25 11:28:13 +07:00
|
|
|
if (dstorg < dev_priv->texture_offset ||
|
|
|
|
dstorg + length > (dev_priv->texture_offset +
|
|
|
|
dev_priv->texture_size)) {
|
|
|
|
DRM_ERROR("*** bad iload DSTORG: 0x%x\n", dstorg);
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (length & MGA_ILOAD_MASK) {
|
|
|
|
DRM_ERROR("*** bad iload length: 0x%x\n",
|
|
|
|
length & MGA_ILOAD_MASK);
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static int mga_verify_blit(drm_mga_private_t *dev_priv,
|
2005-09-25 11:28:13 +07:00
|
|
|
unsigned int srcorg, unsigned int dstorg)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-09-25 11:28:13 +07:00
|
|
|
if ((srcorg & 0x3) == (MGA_SRCACC_PCI | MGA_SRCMAP_SYSMEM) ||
|
|
|
|
(dstorg & 0x3) == (MGA_SRCACC_PCI | MGA_SRCMAP_SYSMEM)) {
|
|
|
|
DRM_ERROR("*** bad blit: src=0x%x dst=0x%x\n", srcorg, dstorg);
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_dma_dispatch_clear(struct drm_device *dev, drm_mga_clear_t *clear)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
2007-07-11 13:09:54 +07:00
|
|
|
struct drm_clip_rect *pbox = sarea_priv->boxes;
|
2005-04-17 05:20:36 +07:00
|
|
|
int nbox = sarea_priv->nbox;
|
|
|
|
int i;
|
|
|
|
DMA_LOCALS;
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DWGSYNC, 0x00007100, MGA_DWGSYNC, 0x00007000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
for (i = 0; i < nbox; i++) {
|
2007-07-11 13:09:54 +07:00
|
|
|
struct drm_clip_rect *box = &pbox[i];
|
2005-04-17 05:20:36 +07:00
|
|
|
u32 height = box->y2 - box->y1;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG(" from=%d,%d to=%d,%d\n",
|
|
|
|
box->x1, box->y1, box->x2, box->y2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (clear->flags & MGA_FRONT) {
|
|
|
|
BEGIN_DMA(2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, clear->color_mask,
|
|
|
|
MGA_YDSTLEN, (box->y1 << 16) | height,
|
|
|
|
MGA_FXBNDRY, (box->x2 << 16) | box->x1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_FCOL, clear->clear_color,
|
|
|
|
MGA_DSTORG, dev_priv->front_offset,
|
|
|
|
MGA_DWGCTL + MGA_EXEC, dev_priv->clear_cmd);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (clear->flags & MGA_BACK) {
|
|
|
|
BEGIN_DMA(2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, clear->color_mask,
|
|
|
|
MGA_YDSTLEN, (box->y1 << 16) | height,
|
|
|
|
MGA_FXBNDRY, (box->x2 << 16) | box->x1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_FCOL, clear->clear_color,
|
|
|
|
MGA_DSTORG, dev_priv->back_offset,
|
|
|
|
MGA_DWGCTL + MGA_EXEC, dev_priv->clear_cmd);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (clear->flags & MGA_DEPTH) {
|
|
|
|
BEGIN_DMA(2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, clear->depth_mask,
|
|
|
|
MGA_YDSTLEN, (box->y1 << 16) | height,
|
|
|
|
MGA_FXBNDRY, (box->x2 << 16) | box->x1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_FCOL, clear->clear_depth,
|
|
|
|
MGA_DSTORG, dev_priv->depth_offset,
|
|
|
|
MGA_DWGCTL + MGA_EXEC, dev_priv->clear_cmd);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Force reset of DWGCTL */
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, ctx->plnwt, MGA_DWGCTL, ctx->dwgctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
|
|
|
|
FLUSH_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_dma_dispatch_swap(struct drm_device *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
2007-07-11 13:09:54 +07:00
|
|
|
struct drm_clip_rect *pbox = sarea_priv->boxes;
|
2005-04-17 05:20:36 +07:00
|
|
|
int nbox = sarea_priv->nbox;
|
|
|
|
int i;
|
|
|
|
DMA_LOCALS;
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
sarea_priv->last_frame.head = dev_priv->prim.tail;
|
|
|
|
sarea_priv->last_frame.wrap = dev_priv->prim.last_wrap;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(4 + nbox);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DWGSYNC, 0x00007100, MGA_DWGSYNC, 0x00007000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DSTORG, dev_priv->front_offset,
|
|
|
|
MGA_MACCESS, dev_priv->maccess,
|
|
|
|
MGA_SRCORG, dev_priv->back_offset,
|
|
|
|
MGA_AR5, dev_priv->front_pitch);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, 0xffffffff, MGA_DWGCTL, MGA_DWGCTL_COPY);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
for (i = 0; i < nbox; i++) {
|
2007-07-11 13:09:54 +07:00
|
|
|
struct drm_clip_rect *box = &pbox[i];
|
2005-04-17 05:20:36 +07:00
|
|
|
u32 height = box->y2 - box->y1;
|
|
|
|
u32 start = box->y1 * dev_priv->front_pitch;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG(" from=%d,%d to=%d,%d\n",
|
|
|
|
box->x1, box->y1, box->x2, box->y2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_AR0, start + box->x2 - 1,
|
|
|
|
MGA_AR3, start + box->x1,
|
|
|
|
MGA_FXBNDRY, ((box->x2 - 1) << 16) | box->x1,
|
|
|
|
MGA_YDSTLEN + MGA_EXEC, (box->y1 << 16) | height);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, ctx->plnwt,
|
|
|
|
MGA_SRCORG, dev_priv->front_offset, MGA_DWGCTL, ctx->dwgctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
|
|
|
|
FLUSH_DMA();
|
|
|
|
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_DEBUG("... done.\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_dma_dispatch_vertex(struct drm_device *dev, struct drm_buf *buf)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
u32 address = (u32) buf->bus_address;
|
|
|
|
u32 length = (u32) buf->used;
|
|
|
|
int i = 0;
|
|
|
|
DMA_LOCALS;
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_DEBUG("buf=%d used=%d\n", buf->idx, buf->used);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (buf->used) {
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv->dispatched = 1;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
MGA_EMIT_STATE(dev_priv, sarea_priv->dirty);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
do {
|
2005-09-25 11:28:13 +07:00
|
|
|
if (i < sarea_priv->nbox) {
|
|
|
|
mga_emit_clip_rect(dev_priv,
|
|
|
|
&sarea_priv->boxes[i]);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
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 15:20:09 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_SECADDRESS, (address |
|
|
|
|
MGA_DMA_VERTEX),
|
|
|
|
MGA_SECEND, ((address + length) |
|
|
|
|
dev_priv->dma_access));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
2005-09-25 11:28:13 +07:00
|
|
|
} while (++i < sarea_priv->nbox);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (buf_priv->discard) {
|
|
|
|
AGE_BUFFER(buf_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->pending = 0;
|
|
|
|
buf->used = 0;
|
|
|
|
buf_priv->dispatched = 0;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_freelist_put(dev, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
FLUSH_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_dma_dispatch_indices(struct drm_device *dev, struct drm_buf *buf,
|
2005-09-25 11:28:13 +07:00
|
|
|
unsigned int start, unsigned int end)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
u32 address = (u32) buf->bus_address;
|
|
|
|
int i = 0;
|
|
|
|
DMA_LOCALS;
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_DEBUG("buf=%d start=%d end=%d\n", buf->idx, start, end);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (start != end) {
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv->dispatched = 1;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
MGA_EMIT_STATE(dev_priv, sarea_priv->dirty);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
do {
|
2005-09-25 11:28:13 +07:00
|
|
|
if (i < sarea_priv->nbox) {
|
|
|
|
mga_emit_clip_rect(dev_priv,
|
|
|
|
&sarea_priv->boxes[i]);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
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 15:20:09 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_SETUPADDRESS, address + start,
|
|
|
|
MGA_SETUPEND, ((address + end) |
|
|
|
|
dev_priv->dma_access));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
2005-09-25 11:28:13 +07:00
|
|
|
} while (++i < sarea_priv->nbox);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (buf_priv->discard) {
|
|
|
|
AGE_BUFFER(buf_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->pending = 0;
|
|
|
|
buf->used = 0;
|
|
|
|
buf_priv->dispatched = 0;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_freelist_put(dev, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
FLUSH_DMA();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This copies a 64 byte aligned agp region to the frambuffer with a
|
|
|
|
* standard blit, the ioctl needs to do checking.
|
|
|
|
*/
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_dma_dispatch_iload(struct drm_device *dev, struct drm_buf *buf,
|
2005-09-25 11:28:13 +07:00
|
|
|
unsigned int dstorg, unsigned int length)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
|
|
|
|
drm_mga_context_regs_t *ctx = &dev_priv->sarea_priv->context_state;
|
2005-09-25 11:28:13 +07:00
|
|
|
u32 srcorg =
|
|
|
|
buf->bus_address | dev_priv->dma_access | MGA_SRCMAP_SYSMEM;
|
2005-04-17 05:20:36 +07:00
|
|
|
u32 y2;
|
|
|
|
DMA_LOCALS;
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("buf=%d used=%d\n", buf->idx, buf->used);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
y2 = length / 64;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(5);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DWGSYNC, 0x00007100, MGA_DWGSYNC, 0x00007000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DSTORG, dstorg,
|
|
|
|
MGA_MACCESS, 0x00000000, MGA_SRCORG, srcorg, MGA_AR5, 64);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_PITCH, 64,
|
|
|
|
MGA_PLNWT, 0xffffffff,
|
|
|
|
MGA_DMAPAD, 0x00000000, MGA_DWGCTL, MGA_DWGCTL_COPY);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_AR0, 63,
|
|
|
|
MGA_AR3, 0,
|
|
|
|
MGA_FXBNDRY, (63 << 16) | 0, MGA_YDSTLEN + MGA_EXEC, y2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_PLNWT, ctx->plnwt,
|
|
|
|
MGA_SRCORG, dev_priv->front_offset,
|
|
|
|
MGA_PITCH, dev_priv->front_pitch, MGA_DWGSYNC, 0x00007000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
AGE_BUFFER(buf_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
buf->pending = 0;
|
|
|
|
buf->used = 0;
|
|
|
|
buf_priv->dispatched = 0;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_freelist_put(dev, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
FLUSH_DMA();
|
|
|
|
}
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
static void mga_dma_dispatch_blit(struct drm_device *dev, drm_mga_blit_t *blit)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
drm_mga_context_regs_t *ctx = &sarea_priv->context_state;
|
2007-07-11 13:09:54 +07:00
|
|
|
struct drm_clip_rect *pbox = sarea_priv->boxes;
|
2005-04-17 05:20:36 +07:00
|
|
|
int nbox = sarea_priv->nbox;
|
|
|
|
u32 scandir = 0, i;
|
|
|
|
DMA_LOCALS;
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
BEGIN_DMA(4 + nbox);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DWGSYNC, 0x00007100, MGA_DWGSYNC, 0x00007000);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DWGCTL, MGA_DWGCTL_COPY,
|
|
|
|
MGA_PLNWT, blit->planemask,
|
|
|
|
MGA_SRCORG, blit->srcorg, MGA_DSTORG, blit->dstorg);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_SGN, scandir,
|
|
|
|
MGA_MACCESS, dev_priv->maccess,
|
|
|
|
MGA_AR5, blit->ydir * blit->src_pitch,
|
|
|
|
MGA_PITCH, blit->dst_pitch);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
for (i = 0; i < nbox; i++) {
|
2005-04-17 05:20:36 +07:00
|
|
|
int srcx = pbox[i].x1 + blit->delta_sx;
|
|
|
|
int srcy = pbox[i].y1 + blit->delta_sy;
|
|
|
|
int dstx = pbox[i].x1 + blit->delta_dx;
|
|
|
|
int dsty = pbox[i].y1 + blit->delta_dy;
|
|
|
|
int h = pbox[i].y2 - pbox[i].y1;
|
|
|
|
int w = pbox[i].x2 - pbox[i].x1 - 1;
|
|
|
|
int start;
|
|
|
|
|
2010-07-12 06:46:57 +07:00
|
|
|
if (blit->ydir == -1)
|
2005-04-17 05:20:36 +07:00
|
|
|
srcy = blit->height - srcy - 1;
|
|
|
|
|
|
|
|
start = srcy * blit->src_pitch + srcx;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_AR0, start + w,
|
|
|
|
MGA_AR3, start,
|
|
|
|
MGA_FXBNDRY, ((dstx + w) << 16) | (dstx & 0xffff),
|
|
|
|
MGA_YDSTLEN + MGA_EXEC, (dsty << 16) | h);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Do something to flush AGP?
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Force reset of DWGCTL */
|
2005-09-25 11:28:13 +07:00
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_PLNWT, ctx->plnwt,
|
|
|
|
MGA_PITCH, dev_priv->front_pitch, MGA_DWGCTL, ctx->dwgctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ADVANCE_DMA();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_dma_clear(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
2007-09-03 09:06:45 +07:00
|
|
|
drm_mga_clear_t *clear = data;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-08-25 17:23:09 +07:00
|
|
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
mga_dma_dispatch_clear(dev, clear);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Make sure we restore the 3D state next time.
|
|
|
|
*/
|
|
|
|
dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CONTEXT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_dma_swap(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
|
|
|
|
2007-08-25 17:23:09 +07:00
|
|
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_dma_dispatch_swap(dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Make sure we restore the 3D state next time.
|
|
|
|
*/
|
|
|
|
dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CONTEXT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_dma_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
2007-07-11 13:32:08 +07:00
|
|
|
struct drm_device_dma *dma = dev->dma;
|
2007-07-11 13:17:42 +07:00
|
|
|
struct drm_buf *buf;
|
2005-04-17 05:20:36 +07:00
|
|
|
drm_mga_buf_priv_t *buf_priv;
|
2007-09-03 09:06:45 +07:00
|
|
|
drm_mga_vertex_t *vertex = data;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-08-25 17:23:09 +07:00
|
|
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
if (vertex->idx < 0 || vertex->idx > dma->buf_count)
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2007-09-03 09:06:45 +07:00
|
|
|
buf = dma->buflist[vertex->idx];
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv = buf->dev_private;
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
buf->used = vertex->used;
|
|
|
|
buf_priv->discard = vertex->discard;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (!mga_verify_state(dev_priv)) {
|
2007-09-03 09:06:45 +07:00
|
|
|
if (vertex->discard) {
|
2005-09-25 11:28:13 +07:00
|
|
|
if (buf_priv->dispatched == 1)
|
|
|
|
AGE_BUFFER(buf_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv->dispatched = 0;
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_freelist_put(dev, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_dma_dispatch_vertex(dev, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_dma_indices(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
2007-07-11 13:32:08 +07:00
|
|
|
struct drm_device_dma *dma = dev->dma;
|
2007-07-11 13:17:42 +07:00
|
|
|
struct drm_buf *buf;
|
2005-04-17 05:20:36 +07:00
|
|
|
drm_mga_buf_priv_t *buf_priv;
|
2007-09-03 09:06:45 +07:00
|
|
|
drm_mga_indices_t *indices = data;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-08-25 17:23:09 +07:00
|
|
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
if (indices->idx < 0 || indices->idx > dma->buf_count)
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
buf = dma->buflist[indices->idx];
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv = buf->dev_private;
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
buf_priv->discard = indices->discard;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (!mga_verify_state(dev_priv)) {
|
2007-09-03 09:06:45 +07:00
|
|
|
if (indices->discard) {
|
2005-09-25 11:28:13 +07:00
|
|
|
if (buf_priv->dispatched == 1)
|
|
|
|
AGE_BUFFER(buf_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv->dispatched = 0;
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_freelist_put(dev, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
mga_dma_dispatch_indices(dev, buf, indices->start, indices->end);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-07-11 13:32:08 +07:00
|
|
|
struct drm_device_dma *dma = dev->dma;
|
2005-04-17 05:20:36 +07:00
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
2007-07-11 13:17:42 +07:00
|
|
|
struct drm_buf *buf;
|
2005-04-17 05:20:36 +07:00
|
|
|
drm_mga_buf_priv_t *buf_priv;
|
2007-09-03 09:06:45 +07:00
|
|
|
drm_mga_iload_t *iload = data;
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-08-25 17:23:09 +07:00
|
|
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#if 0
|
2005-09-25 11:28:13 +07:00
|
|
|
if (mga_do_wait_for_idle(dev_priv) < 0) {
|
|
|
|
if (MGA_DMA_DEBUG)
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_INFO("-EBUSY\n");
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EBUSY;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
#endif
|
2007-09-03 09:06:45 +07:00
|
|
|
if (iload->idx < 0 || iload->idx > dma->buf_count)
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
buf = dma->buflist[iload->idx];
|
2005-04-17 05:20:36 +07:00
|
|
|
buf_priv = buf->dev_private;
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
if (mga_verify_iload(dev_priv, iload->dstorg, iload->length)) {
|
2005-09-25 11:28:13 +07:00
|
|
|
mga_freelist_put(dev, buf);
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
mga_dma_dispatch_iload(dev, buf, iload->dstorg, iload->length);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Make sure we restore the 3D state next time.
|
|
|
|
*/
|
|
|
|
dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CONTEXT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
|
|
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
2007-09-03 09:06:45 +07:00
|
|
|
drm_mga_blit_t *blit = data;
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-08-25 17:23:09 +07:00
|
|
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
2005-04-17 05:20:36 +07:00
|
|
|
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
if (mga_verify_blit(dev_priv, blit->srcorg, blit->dstorg))
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
mga_dma_dispatch_blit(dev, blit);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Make sure we restore the 3D state next time.
|
|
|
|
*/
|
|
|
|
dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CONTEXT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
2007-09-03 09:06:45 +07:00
|
|
|
drm_mga_getparam_t *param = data;
|
2005-04-17 05:20:36 +07:00
|
|
|
int value;
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
if (!dev_priv) {
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_ERROR("called with no initialization\n");
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
switch (param->param) {
|
2005-04-17 05:20:36 +07:00
|
|
|
case MGA_PARAM_IRQ_NR:
|
2013-11-04 02:27:09 +07:00
|
|
|
value = dev->pdev->irq;
|
2005-04-17 05:20:36 +07:00
|
|
|
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 15:20:09 +07:00
|
|
|
case MGA_PARAM_CARD_TYPE:
|
|
|
|
value = dev_priv->chipset;
|
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
default:
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2013-12-11 17:34:44 +07:00
|
|
|
if (copy_to_user(param->value, &value, sizeof(int))) {
|
2005-09-25 11:28:13 +07:00
|
|
|
DRM_ERROR("copy_to_user\n");
|
2007-08-25 16:22:43 +07:00
|
|
|
return -EFAULT;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2005-09-25 11:28:13 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
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 15:20:09 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
2007-09-03 09:06:45 +07:00
|
|
|
u32 *fence = data;
|
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 15:20:09 +07:00
|
|
|
DMA_LOCALS;
|
|
|
|
|
|
|
|
if (!dev_priv) {
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_ERROR("called with no initialization\n");
|
2007-08-25 16:22:43 +07: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 15:20:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
/* I would normal do this assignment in the declaration of fence,
|
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 15:20:09 +07:00
|
|
|
* but dev_priv may be NULL.
|
|
|
|
*/
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
*fence = dev_priv->next_fence_to_post;
|
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 15:20:09 +07:00
|
|
|
dev_priv->next_fence_to_post++;
|
|
|
|
|
|
|
|
BEGIN_DMA(1);
|
|
|
|
DMA_BLOCK(MGA_DMAPAD, 0x00000000,
|
|
|
|
MGA_DMAPAD, 0x00000000,
|
2005-09-25 11:28:13 +07:00
|
|
|
MGA_DMAPAD, 0x00000000, MGA_SOFTRAP, 0x00000000);
|
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 15:20:09 +07:00
|
|
|
ADVANCE_DMA();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
static int mga_wait_fence(struct drm_device *dev, void *data, struct drm_file *
|
|
|
|
file_priv)
|
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 15:20:09 +07:00
|
|
|
{
|
|
|
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
2007-09-03 09:06:45 +07:00
|
|
|
u32 *fence = data;
|
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 15:20:09 +07:00
|
|
|
|
|
|
|
if (!dev_priv) {
|
2008-01-24 12:58:57 +07:00
|
|
|
DRM_ERROR("called with no initialization\n");
|
2007-08-25 16:22:43 +07: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 15:20:09 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
|
|
|
|
2007-09-03 09:06:45 +07:00
|
|
|
mga_driver_fence_wait(dev, fence);
|
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 15:20:09 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-03 00:27:49 +07:00
|
|
|
const struct drm_ioctl_desc mga_ioctls[] = {
|
2010-08-14 17:20:34 +07:00
|
|
|
DRM_IOCTL_DEF_DRV(MGA_INIT, mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_FLUSH, mga_dma_flush, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_RESET, mga_dma_reset, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_SWAP, mga_dma_swap, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_CLEAR, mga_dma_clear, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_VERTEX, mga_dma_vertex, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_INDICES, mga_dma_indices, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_ILOAD, mga_dma_iload, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_BLIT, mga_dma_blit, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_GETPARAM, mga_getparam, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_SET_FENCE, mga_set_fence, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_WAIT_FENCE, mga_wait_fence, DRM_AUTH),
|
|
|
|
DRM_IOCTL_DEF_DRV(MGA_DMA_BOOTSTRAP, mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2014-06-09 20:39:49 +07:00
|
|
|
int mga_max_ioctl = ARRAY_SIZE(mga_ioctls);
|