nouveau: fail CreateScreen on unknown cards instead of guessing.
authorBen Skeggs <darktama@iinet.net.au>
Mon, 15 Jan 2007 06:23:04 +0000 (17:23 +1100)
committerBen Skeggs <darktama@iinet.net.au>
Mon, 15 Jan 2007 06:23:04 +0000 (17:23 +1100)
src/mesa/drivers/dri/nouveau/nouveau_card.c
src/mesa/drivers/dri/nouveau/nouveau_screen.c

index ae4f4c7ae5a66d26f8b55c775fe2897ecf6d081e..91f12f0d704a36cb90798e4f96a1d5fdd78cb9c3 100644 (file)
@@ -10,8 +10,8 @@ nouveau_card* nouveau_card_lookup(uint32_t device_id)
        int i;
        for(i=0;i<sizeof(nouveau_card_list)/sizeof(nouveau_card)-1;i++)
                if (nouveau_card_list[i].id==(device_id&0xffff))
-                       break;
-       return &(nouveau_card_list[i]);
+                       return &(nouveau_card_list[i]);
+       return NULL;
 }
 
 
index 0e3901cfcaba7c072d72810d3ba5904a7d36d544..ab7742df14f339c6e133d7018f4d74f62e436b57 100644 (file)
@@ -71,6 +71,14 @@ static nouveauScreenPtr nouveauCreateScreen(__DRIscreenPrivate *sPriv)
                return NULL;
        }
        
+       screen->card=nouveau_card_lookup(dri_priv->device_id);
+       if (!screen->card) {
+               __driUtilMessage("%s: Unknown card type 0x%04x:0x%04x\n",
+                       __func__, dri_priv->device_id >> 16, dri_priv->device_id & 0xFFFF);
+               FREE(screen);
+               return NULL;
+       }
+
        /* parse information in __driConfigOptions */
        driParseOptionInfo (&screen->optionCache,__driConfigOptions, __driNConfigOptions);
 
@@ -82,7 +90,6 @@ static nouveauScreenPtr nouveauCreateScreen(__DRIscreenPrivate *sPriv)
        screen->depthOffset = dri_priv->depth_offset;
        screen->depthPitch  = dri_priv->depth_pitch;
 
-       screen->card=nouveau_card_lookup(dri_priv->device_id);
        screen->driScreen = sPriv;
        return screen;
 }