All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kristian Høgsberg" <krh@bitplanet.net>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 02/16] intel: Use the PCI ID map for determining chipset gen
Date: Tue,  7 Jun 2011 15:34:07 -0400	[thread overview]
Message-ID: <1307475261-32695-3-git-send-email-krh@bitplanet.net> (raw)
In-Reply-To: <1307475261-32695-1-git-send-email-krh@bitplanet.net>

---
 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);
-- 
1.7.4.4

  parent reply	other threads:[~2011-06-07 19:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 19:34 [PATCH 00/16] Move chipset specific stuff to struct intel_chipset Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 01/16] intel: Use gen number instead of PCI ID in decoder Kristian Høgsberg
2011-06-08  0:52   ` Eric Anholt
2011-06-07 19:34 ` Kristian Høgsberg [this message]
2011-06-07 19:34 ` [PATCH 03/16] intel: IS_9XX is just gen >= 3 Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 04/16] intel: Remove unused IS_915 macro Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 05/16] intel: Replace intel_screen::gen with the chipset struct Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 06/16] intel: Add a is_945 bit to chipinfo and use that instead of IS_945 Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 07/16] intel: Remove unused IS_MOBILE and IS_IGD* macros Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 08/16] intel: Replace single use of IS_965 with gen check Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 09/16] intel: Drop unused IS_GEN4 macro Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 10/16] intel: Drop unused IS_GEN5-7 macros Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 11/16] intel: Put urb and thread limits into the chipset struct Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 12/16] intel: Drop unused IS_SNB/IVB_GT1/2 macros Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 13/16] intel: Replace IS_G4X macro with an is_g4x bit in the chipset struct Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 14/16] intel: Add is_855ish for handling 855 and 865 specific lod clamping Kristian Høgsberg
2011-06-07 20:22   ` Chris Wilson
2011-06-08  1:13     ` Eric Anholt
2011-06-07 19:34 ` [PATCH 15/16] intel: Get chipset name from PCI ID list Kristian Høgsberg
2011-06-07 19:34 ` [PATCH 16/16] intel: Remove intel_chipsets.h Kristian Høgsberg
2011-06-08 11:51 ` [PATCH 00/16] Move chipset specific stuff to struct intel_chipset Kenneth Graunke
2011-06-08 18:36   ` Kristian Høgsberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307475261-32695-3-git-send-email-krh@bitplanet.net \
    --to=krh@bitplanet.net \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.