The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/mga_warp.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* mga_warp.c -- Matrox G200/G400 WARP engine management -*- linux-c -*-
    2  * Created: Thu Jan 11 21:29:32 2001 by gareth@valinux.com */
    3 /*-
    4  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
    5  * All Rights Reserved.
    6  *
    7  * Permission is hereby granted, free of charge, to any person obtaining a
    8  * copy of this software and associated documentation files (the "Software"),
    9  * to deal in the Software without restriction, including without limitation
   10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   11  * and/or sell copies of the Software, and to permit persons to whom the
   12  * Software is furnished to do so, subject to the following conditions:
   13  *
   14  * The above copyright notice and this permission notice (including the next
   15  * paragraph) shall be included in all copies or substantial portions of the
   16  * Software.
   17  *
   18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   21  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   24  * OTHER DEALINGS IN THE SOFTWARE.
   25  *
   26  * Authors:
   27  *    Gareth Hughes <gareth@valinux.com>
   28  *
   29  * $FreeBSD$
   30  */
   31 
   32 #include "dev/drm/mga.h"
   33 #include "dev/drm/drmP.h"
   34 #include "dev/drm/drm.h"
   35 #include "dev/drm/mga_drm.h"
   36 #include "dev/drm/mga_drv.h"
   37 #include "dev/drm/mga_ucode.h"
   38 
   39 
   40 #define MGA_WARP_CODE_ALIGN             256             /* in bytes */
   41 
   42 #define WARP_UCODE_SIZE( which )                                        \
   43         ((sizeof(which) / MGA_WARP_CODE_ALIGN + 1) * MGA_WARP_CODE_ALIGN)
   44 
   45 #define WARP_UCODE_INSTALL( which, where )                              \
   46 do {                                                                    \
   47         DRM_DEBUG( " pcbase = 0x%08lx  vcbase = %p\n", pcbase, vcbase );\
   48         dev_priv->warp_pipe_phys[where] = pcbase;                       \
   49         memcpy( vcbase, which, sizeof(which) );                         \
   50         pcbase += WARP_UCODE_SIZE( which );                             \
   51         vcbase += WARP_UCODE_SIZE( which );                             \
   52 } while (0)
   53 
   54 
   55 static unsigned int mga_warp_g400_microcode_size( drm_mga_private_t *dev_priv )
   56 {
   57         unsigned int size;
   58 
   59         size = ( WARP_UCODE_SIZE( warp_g400_tgz ) +
   60                  WARP_UCODE_SIZE( warp_g400_tgza ) +
   61                  WARP_UCODE_SIZE( warp_g400_tgzaf ) +
   62                  WARP_UCODE_SIZE( warp_g400_tgzf ) +
   63                  WARP_UCODE_SIZE( warp_g400_tgzs ) +
   64                  WARP_UCODE_SIZE( warp_g400_tgzsa ) +
   65                  WARP_UCODE_SIZE( warp_g400_tgzsaf ) +
   66                  WARP_UCODE_SIZE( warp_g400_tgzsf ) +
   67                  WARP_UCODE_SIZE( warp_g400_t2gz ) +
   68                  WARP_UCODE_SIZE( warp_g400_t2gza ) +
   69                  WARP_UCODE_SIZE( warp_g400_t2gzaf ) +
   70                  WARP_UCODE_SIZE( warp_g400_t2gzf ) +
   71                  WARP_UCODE_SIZE( warp_g400_t2gzs ) +
   72                  WARP_UCODE_SIZE( warp_g400_t2gzsa ) +
   73                  WARP_UCODE_SIZE( warp_g400_t2gzsaf ) +
   74                  WARP_UCODE_SIZE( warp_g400_t2gzsf ) );
   75 
   76         size = PAGE_ALIGN( size );
   77 
   78         DRM_DEBUG( "G400 ucode size = %d bytes\n", size );
   79         return size;
   80 }
   81 
   82 static unsigned int mga_warp_g200_microcode_size( drm_mga_private_t *dev_priv )
   83 {
   84         unsigned int size;
   85 
   86         size = ( WARP_UCODE_SIZE( warp_g200_tgz ) +
   87                  WARP_UCODE_SIZE( warp_g200_tgza ) +
   88                  WARP_UCODE_SIZE( warp_g200_tgzaf ) +
   89                  WARP_UCODE_SIZE( warp_g200_tgzf ) +
   90                  WARP_UCODE_SIZE( warp_g200_tgzs ) +
   91                  WARP_UCODE_SIZE( warp_g200_tgzsa ) +
   92                  WARP_UCODE_SIZE( warp_g200_tgzsaf ) +
   93                  WARP_UCODE_SIZE( warp_g200_tgzsf ) );
   94 
   95         size = PAGE_ALIGN( size );
   96 
   97         DRM_DEBUG( "G200 ucode size = %d bytes\n", size );
   98         return size;
   99 }
  100 
  101 static int mga_warp_install_g400_microcode( drm_mga_private_t *dev_priv )
  102 {
  103         unsigned char *vcbase = dev_priv->warp->handle;
  104         unsigned long pcbase = dev_priv->warp->offset;
  105         unsigned int size;
  106 
  107         size = mga_warp_g400_microcode_size( dev_priv );
  108         if ( size > dev_priv->warp->size ) {
  109                 DRM_ERROR( "microcode too large! (%u > %lu)\n",
  110                            size, dev_priv->warp->size );
  111                 return DRM_ERR(ENOMEM);
  112         }
  113 
  114         memset( dev_priv->warp_pipe_phys, 0,
  115                 sizeof(dev_priv->warp_pipe_phys) );
  116 
  117         WARP_UCODE_INSTALL( warp_g400_tgz,      MGA_WARP_TGZ );
  118         WARP_UCODE_INSTALL( warp_g400_tgzf,     MGA_WARP_TGZF );
  119         WARP_UCODE_INSTALL( warp_g400_tgza,     MGA_WARP_TGZA );
  120         WARP_UCODE_INSTALL( warp_g400_tgzaf,    MGA_WARP_TGZAF );
  121         WARP_UCODE_INSTALL( warp_g400_tgzs,     MGA_WARP_TGZS );
  122         WARP_UCODE_INSTALL( warp_g400_tgzsf,    MGA_WARP_TGZSF );
  123         WARP_UCODE_INSTALL( warp_g400_tgzsa,    MGA_WARP_TGZSA );
  124         WARP_UCODE_INSTALL( warp_g400_tgzsaf,   MGA_WARP_TGZSAF );
  125 
  126         WARP_UCODE_INSTALL( warp_g400_t2gz,     MGA_WARP_T2GZ );
  127         WARP_UCODE_INSTALL( warp_g400_t2gzf,    MGA_WARP_T2GZF );
  128         WARP_UCODE_INSTALL( warp_g400_t2gza,    MGA_WARP_T2GZA );
  129         WARP_UCODE_INSTALL( warp_g400_t2gzaf,   MGA_WARP_T2GZAF );
  130         WARP_UCODE_INSTALL( warp_g400_t2gzs,    MGA_WARP_T2GZS );
  131         WARP_UCODE_INSTALL( warp_g400_t2gzsf,   MGA_WARP_T2GZSF );
  132         WARP_UCODE_INSTALL( warp_g400_t2gzsa,   MGA_WARP_T2GZSA );
  133         WARP_UCODE_INSTALL( warp_g400_t2gzsaf,  MGA_WARP_T2GZSAF );
  134 
  135         return 0;
  136 }
  137 
  138 static int mga_warp_install_g200_microcode( drm_mga_private_t *dev_priv )
  139 {
  140         unsigned char *vcbase = dev_priv->warp->handle;
  141         unsigned long pcbase = dev_priv->warp->offset;
  142         unsigned int size;
  143 
  144         size = mga_warp_g200_microcode_size( dev_priv );
  145         if ( size > dev_priv->warp->size ) {
  146                 DRM_ERROR( "microcode too large! (%u > %lu)\n",
  147                            size, dev_priv->warp->size );
  148                 return DRM_ERR(ENOMEM);
  149         }
  150 
  151         memset( dev_priv->warp_pipe_phys, 0,
  152                 sizeof(dev_priv->warp_pipe_phys) );
  153 
  154         WARP_UCODE_INSTALL( warp_g200_tgz,      MGA_WARP_TGZ );
  155         WARP_UCODE_INSTALL( warp_g200_tgzf,     MGA_WARP_TGZF );
  156         WARP_UCODE_INSTALL( warp_g200_tgza,     MGA_WARP_TGZA );
  157         WARP_UCODE_INSTALL( warp_g200_tgzaf,    MGA_WARP_TGZAF );
  158         WARP_UCODE_INSTALL( warp_g200_tgzs,     MGA_WARP_TGZS );
  159         WARP_UCODE_INSTALL( warp_g200_tgzsf,    MGA_WARP_TGZSF );
  160         WARP_UCODE_INSTALL( warp_g200_tgzsa,    MGA_WARP_TGZSA );
  161         WARP_UCODE_INSTALL( warp_g200_tgzsaf,   MGA_WARP_TGZSAF );
  162 
  163         return 0;
  164 }
  165 
  166 int mga_warp_install_microcode( drm_mga_private_t *dev_priv )
  167 {
  168         switch ( dev_priv->chipset ) {
  169         case MGA_CARD_TYPE_G400:
  170                 return mga_warp_install_g400_microcode( dev_priv );
  171         case MGA_CARD_TYPE_G200:
  172                 return mga_warp_install_g200_microcode( dev_priv );
  173         default:
  174                 return DRM_ERR(EINVAL);
  175         }
  176 }
  177 
  178 #define WMISC_EXPECTED          (MGA_WUCODECACHE_ENABLE | MGA_WMASTER_ENABLE)
  179 
  180 int mga_warp_init( drm_mga_private_t *dev_priv )
  181 {
  182         u32 wmisc;
  183 
  184         /* FIXME: Get rid of these damned magic numbers...
  185          */
  186         switch ( dev_priv->chipset ) {
  187         case MGA_CARD_TYPE_G400:
  188                 MGA_WRITE( MGA_WIADDR2, MGA_WMODE_SUSPEND );
  189                 MGA_WRITE( MGA_WGETMSB, 0x00000E00 );
  190                 MGA_WRITE( MGA_WVRTXSZ, 0x00001807 );
  191                 MGA_WRITE( MGA_WACCEPTSEQ, 0x18000000 );
  192                 break;
  193         case MGA_CARD_TYPE_G200:
  194                 MGA_WRITE( MGA_WIADDR, MGA_WMODE_SUSPEND );
  195                 MGA_WRITE( MGA_WGETMSB, 0x1606 );
  196                 MGA_WRITE( MGA_WVRTXSZ, 7 );
  197                 break;
  198         default:
  199                 return DRM_ERR(EINVAL);
  200         }
  201 
  202         MGA_WRITE( MGA_WMISC, (MGA_WUCODECACHE_ENABLE |
  203                                MGA_WMASTER_ENABLE |
  204                                MGA_WCACHEFLUSH_ENABLE) );
  205         wmisc = MGA_READ( MGA_WMISC );
  206         if ( wmisc != WMISC_EXPECTED ) {
  207                 DRM_ERROR( "WARP engine config failed! 0x%x != 0x%x\n",
  208                            wmisc, WMISC_EXPECTED );
  209                 return DRM_ERR(EINVAL);
  210         }
  211 
  212         return 0;
  213 }

Cache object: bf01dd3f25f8947a40cb8c3848cfb924


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.