summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared-core/mga_drv.h1
-rw-r--r--shared-core/mga_warp.c58
2 files changed, 24 insertions, 35 deletions
diff --git a/shared-core/mga_drv.h b/shared-core/mga_drv.h
index 86dedbe8..e12dbd42 100644
--- a/shared-core/mga_drv.h
+++ b/shared-core/mga_drv.h
@@ -130,6 +130,7 @@ extern void mga_do_dma_wrap_end(drm_mga_private_t * dev_priv);
extern int mga_freelist_put(drm_device_t * dev, drm_buf_t * buf);
/* mga_warp.c */
+extern unsigned int mga_warp_microcode_size(const drm_mga_private_t * dev_priv);
extern int mga_warp_install_microcode(drm_mga_private_t * dev_priv);
extern int mga_warp_init(drm_mga_private_t * dev_priv);
diff --git a/shared-core/mga_warp.c b/shared-core/mga_warp.c
index a5d35911..b8fe48d1 100644
--- a/shared-core/mga_warp.c
+++ b/shared-core/mga_warp.c
@@ -47,11 +47,8 @@ do { \
vcbase += WARP_UCODE_SIZE( which ); \
} while (0)
-static unsigned int mga_warp_g400_microcode_size(drm_mga_private_t * dev_priv)
-{
- unsigned int size;
-
- size = (WARP_UCODE_SIZE(warp_g400_tgz) +
+static const unsigned int mga_warp_g400_microcode_size =
+ (WARP_UCODE_SIZE(warp_g400_tgz) +
WARP_UCODE_SIZE(warp_g400_tgza) +
WARP_UCODE_SIZE(warp_g400_tgzaf) +
WARP_UCODE_SIZE(warp_g400_tgzf) +
@@ -68,17 +65,8 @@ static unsigned int mga_warp_g400_microcode_size(drm_mga_private_t * dev_priv)
WARP_UCODE_SIZE(warp_g400_t2gzsaf) +
WARP_UCODE_SIZE(warp_g400_t2gzsf));
- size = PAGE_ALIGN(size);
-
- DRM_DEBUG("G400 ucode size = %d bytes\n", size);
- return size;
-}
-
-static unsigned int mga_warp_g200_microcode_size(drm_mga_private_t * dev_priv)
-{
- unsigned int size;
-
- size = (WARP_UCODE_SIZE(warp_g200_tgz) +
+static const unsigned int mga_warp_g200_microcode_size =
+ (WARP_UCODE_SIZE(warp_g200_tgz) +
WARP_UCODE_SIZE(warp_g200_tgza) +
WARP_UCODE_SIZE(warp_g200_tgzaf) +
WARP_UCODE_SIZE(warp_g200_tgzf) +
@@ -87,24 +75,23 @@ static unsigned int mga_warp_g200_microcode_size(drm_mga_private_t * dev_priv)
WARP_UCODE_SIZE(warp_g200_tgzsaf) +
WARP_UCODE_SIZE(warp_g200_tgzsf));
- size = PAGE_ALIGN(size);
- DRM_DEBUG("G200 ucode size = %d bytes\n", size);
- return size;
+unsigned int mga_warp_microcode_size(const drm_mga_private_t * dev_priv)
+{
+ switch (dev_priv->chipset) {
+ case MGA_CARD_TYPE_G400:
+ return PAGE_ALIGN(mga_warp_g400_microcode_size);
+ case MGA_CARD_TYPE_G200:
+ return PAGE_ALIGN(mga_warp_g200_microcode_size);
+ default:
+ return 0;
+ }
}
static int mga_warp_install_g400_microcode(drm_mga_private_t * dev_priv)
{
unsigned char *vcbase = dev_priv->warp->handle;
unsigned long pcbase = dev_priv->warp->offset;
- unsigned int size;
-
- size = mga_warp_g400_microcode_size(dev_priv);
- if (size > dev_priv->warp->size) {
- DRM_ERROR("microcode too large! (%u > %lu)\n",
- size, dev_priv->warp->size);
- return DRM_ERR(ENOMEM);
- }
memset(dev_priv->warp_pipe_phys, 0, sizeof(dev_priv->warp_pipe_phys));
@@ -133,14 +120,6 @@ static int mga_warp_install_g200_microcode(drm_mga_private_t * dev_priv)
{
unsigned char *vcbase = dev_priv->warp->handle;
unsigned long pcbase = dev_priv->warp->offset;
- unsigned int size;
-
- size = mga_warp_g200_microcode_size(dev_priv);
- if (size > dev_priv->warp->size) {
- DRM_ERROR("microcode too large! (%u > %lu)\n",
- size, dev_priv->warp->size);
- return DRM_ERR(ENOMEM);
- }
memset(dev_priv->warp_pipe_phys, 0, sizeof(dev_priv->warp_pipe_phys));
@@ -158,6 +137,15 @@ static int mga_warp_install_g200_microcode(drm_mga_private_t * dev_priv)
int mga_warp_install_microcode(drm_mga_private_t * dev_priv)
{
+ const unsigned int size = mga_warp_microcode_size(dev_priv);
+
+ 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);
+ return DRM_ERR(ENOMEM);
+ }
+
switch (dev_priv->chipset) {
case MGA_CARD_TYPE_G400:
return mga_warp_install_g400_microcode(dev_priv);