From patchwork Tue Jun 7 19:34:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristian Hogsberg X-Patchwork-Id: 859222 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p57JbZIB001048 for ; Tue, 7 Jun 2011 19:37:55 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 592369F5EF for ; Tue, 7 Jun 2011 12:37:35 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 89A0B9F6FC for ; Tue, 7 Jun 2011 12:36:00 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 07 Jun 2011 12:35:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,333,1304319600"; d="scan'208";a="10755381" Received: from unknown (HELO intel.com) ([10.255.12.225]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2011 12:35:59 -0700 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= To: intel-gfx@lists.freedesktop.org Date: Tue, 7 Jun 2011 15:34:07 -0400 Message-Id: <1307475261-32695-3-git-send-email-krh@bitplanet.net> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1307475261-32695-1-git-send-email-krh@bitplanet.net> References: <1307475261-32695-1-git-send-email-krh@bitplanet.net> Subject: [Intel-gfx] [PATCH 02/16] intel: Use the PCI ID map for determining chipset gen X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 07 Jun 2011 19:37:55 +0000 (UTC) --- src/mesa/drivers/dri/i915/Makefile | 2 +- src/mesa/drivers/dri/i965/Makefile | 2 +- src/mesa/drivers/dri/intel/intel_screen.c | 96 +++++++++++++++++++++++------ 3 files changed, 80 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 79e03f2..16f4316 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -58,7 +58,7 @@ C_SOURCES = \ ASM_SOURCES = -DRIVER_DEFINES = -I../intel -DI915 \ +DRIVER_DEFINES = -I../intel -I$(TOP)/include -DI915 \ $(shell pkg-config libdrm --atleast-version=2.3.1 \ && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 44f28cd..ed1497b 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -128,7 +128,7 @@ CXX_SOURCES = \ ASM_SOURCES = -DRIVER_DEFINES = -I../intel +DRIVER_DEFINES = -I../intel -I$(TOP)/include INCLUDES += $(INTEL_CFLAGS) DRI_LIB_DEPS += $(INTEL_LIBS) diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index deca11d..9939b4d 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -432,6 +432,37 @@ intelDestroyBuffer(__DRIdrawable * driDrawPriv) * init-designated function to register chipids and createcontext * functions. */ + +struct intel_chipset { + int gen; +}; + +#define CHIPSET(id, name, info) { id, &intel_chipset_##info }, + + +struct intel_chipset_map { + int device_id; + const struct intel_chipset *chipset; +}; + +#ifdef I915 + +static const struct intel_chipset intel_chipset_i8xx = { + .gen = 2 +}; + +static const struct intel_chipset intel_chipset_i915 = { + .gen = 3 +}; + +static const struct intel_chipset intel_chipset_i945 = { + .gen = 3 +}; + +static const struct intel_chipset_map chipset_map[] = { +#include "pci_ids/i915_pci_ids.h" +}; + extern GLboolean i830CreateContext(const struct gl_config * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); @@ -440,21 +471,58 @@ extern GLboolean i915CreateContext(int api, const struct gl_config * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); + +#else + +static const struct intel_chipset intel_chipset_i965 = { + .gen = 4 +}; + +static const struct intel_chipset intel_chipset_g4x = { + .gen = 4 +}; + +static const struct intel_chipset intel_chipset_ilk = { + .gen = 5 +}; + +static const struct intel_chipset intel_chipset_snb_gt1 = { + .gen = 6 +}; + +static const struct intel_chipset intel_chipset_snb_gt2 = { + .gen = 6 +}; + +static const struct intel_chipset intel_chipset_ivb_gt1 = { + .gen = 7 +}; + +static const struct intel_chipset intel_chipset_ivb_gt2 = { + .gen = 7 +}; + +static const struct intel_chipset_map chipset_map[] = { +#include "pci_ids/i965_pci_ids.h" +}; + extern GLboolean brwCreateContext(int api, const struct gl_config * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); +#endif + static GLboolean intelCreateContext(gl_api api, const struct gl_config * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate) { +#ifdef I915 __DRIscreen *sPriv = driContextPriv->driScreenPriv; struct intel_screen *intelScreen = sPriv->private; -#ifdef I915 if (IS_9XX(intelScreen->deviceID)) { if (!IS_965(intelScreen->deviceID)) { return i915CreateContext(api, mesaVis, driContextPriv, @@ -465,12 +533,8 @@ intelCreateContext(gl_api api, return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate); } #else - if (IS_965(intelScreen->deviceID)) - return brwCreateContext(api, mesaVis, - driContextPriv, sharedContextPrivate); + return brwCreateContext(api, mesaVis, driContextPriv, sharedContextPrivate); #endif - fprintf(stderr, "Unrecognized deviceID 0x%x\n", intelScreen->deviceID); - return GL_FALSE; } static GLboolean @@ -520,6 +584,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) GLenum fb_type[3]; unsigned int api_mask; char *devid_override; + int i; static const GLenum back_buffer_modes[] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML @@ -556,18 +621,13 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) intelScreen->deviceID = strtod(devid_override, NULL); } - if (IS_GEN7(intelScreen->deviceID)) { - intelScreen->gen = 7; - } else if (IS_GEN6(intelScreen->deviceID)) { - intelScreen->gen = 6; - } else if (IS_GEN5(intelScreen->deviceID)) { - intelScreen->gen = 5; - } else if (IS_965(intelScreen->deviceID)) { - intelScreen->gen = 4; - } else if (IS_9XX(intelScreen->deviceID)) { - intelScreen->gen = 3; - } else { - intelScreen->gen = 2; + for (i = 0; i < Elements(chipset_map); i++) + if (chipset_map[i].device_id == intelScreen->deviceID) + intelScreen->gen = chipset_map[i].chipset->gen; + if (intelScreen->gen == 0) { + fprintf(stderr, "\nERROR! Unrecognized chipset:: 0x%04x\n", + intelScreen->deviceID); + return GL_FALSE; } api_mask = (1 << __DRI_API_OPENGL);