amd/r300: Wire up GETPARAM ioctls.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Thu, 22 Jan 2009 21:34:21 +0000 (13:34 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 2 Feb 2009 07:30:25 +0000 (23:30 -0800)
Whoo, stuff is starting to look cleaner and cleaner.

src/gallium/drivers/r300/r300_chipset.c
src/gallium/drivers/r300/r300_chipset.h
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_screen.h
src/gallium/drivers/r300/r300_winsys.h
src/gallium/winsys/drm/amd/amd_context.c
src/gallium/winsys/drm/amd/amd_r300.c
src/gallium/winsys/drm/amd/amd_r300.h

index b7de235..f2dc8ae 100644 (file)
  * Radeons. */
 
 /* Parse a PCI ID and fill an r300_capabilities struct with information. */
-void r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps)
+void r300_parse_chipset(struct r300_capabilities* caps)
 {
     /* Reasonable defaults */
-    caps->pci_id = pci_id;
     caps->has_tcl = TRUE;
     caps->is_r500 = FALSE;
     caps->num_vert_pipes = 4;
@@ -38,7 +37,7 @@ void r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps)
     /* Note: These are not ordered by PCI ID. I leave that task to GCC,
      * which will perform the ordering while collating jump tables. Instead,
      * I've tried to group them according to capabilities and age. */
-    switch (pci_id) {
+    switch (caps->pci_id) {
         case 0x4144:
             caps->family = CHIP_FAMILY_R300;
             break;
index 548d7a6..f1502ff 100644 (file)
@@ -100,6 +100,6 @@ static const char* chip_families[] = {
     "RV570"
 };
 
-void r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps);
+void r300_parse_chipset(struct r300_capabilities* caps);
 
 #endif /* R300_CHIPSET_H */
index 467594e..f254b2f 100644 (file)
@@ -43,7 +43,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300->winsys = r300_winsys;
     r300->context.winsys = winsys;
-    r300->context.screen = r300_create_screen(winsys, r300_winsys->pci_id);
+    r300->context.screen = r300_create_screen(winsys, r300_winsys);
 
     r300->context.destroy = r300_destroy_context;
 
index a241d60..63ddd3b 100644 (file)
@@ -149,7 +149,8 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)
     FREE(r300screen);
 }
 
-struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys, uint32_t pci_id)
+struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
+                                       struct r300_winsys* r300_winsys)
 {
     struct r300_screen* r300screen = CALLOC_STRUCT(r300_screen);
     struct r300_capabilities* caps = CALLOC_STRUCT(r300_capabilities);
@@ -157,7 +158,10 @@ struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys, uint32_t pci_
     if (!r300screen || !caps)
         return NULL;
 
-    r300_parse_chipset(pci_id, caps);
+    caps->pci_id = r300_winsys->pci_id;
+    caps->num_frag_pipes = r300_winsys->gb_pipes;
+
+    r300_parse_chipset(caps);
 
     r300screen->caps = caps;
     r300screen->screen.winsys = winsys;
index b6c3d1f..83d5a75 100644 (file)
@@ -28,6 +28,7 @@
 #include "util/u_memory.h"
 
 #include "r300_chipset.h"
+#include "r300_winsys.h"
 
 struct r300_screen {
     /* Parent class */
@@ -43,6 +44,7 @@ static struct r300_screen* r300_screen(struct pipe_screen* screen) {
 }
 
 /* Creates a new r300 screen. */
-struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys, uint pci_id);
+struct pipe_screen* r300_create_screen(struct pipe_winsys* winsys,
+                                       struct r300_winsys* r300_winsys);
 
 #endif /* R300_SCREEN_H */
index 319152c..867d65b 100644 (file)
@@ -41,6 +41,9 @@ struct r300_winsys {
     /* PCI ID */
     uint32_t pci_id;
 
+    /* GB pipe count */
+    uint32_t gb_pipes;
+
     /* CS object. This is very much like Intel's batchbuffer.
      * Fill it full of dwords and relocs and then submit.
      * Repeat as needed. */
@@ -89,4 +92,4 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 }
 #endif
 
-#endif /* R300_WINSYS_H */
\ No newline at end of file
+#endif /* R300_WINSYS_H */
index 5331168..7a486c9 100644 (file)
@@ -244,11 +244,10 @@ GLboolean amd_context_create(const __GLcontextModes *visual,
 
     if (GL_TRUE) {
         fprintf(stderr, "Creating r300 context...");
-        /* XXX today we pretend to be a very lame R300    vvvvvv */
-        pipe = r300_create_context(NULL,
-                                   amd_context->pipe_winsys,
-                                   amd_create_r300_winsys(amd_context->drm_fd,
-                                                          0x4144));
+        pipe =
+            r300_create_context(NULL,
+                                amd_context->pipe_winsys,
+                                amd_create_r300_winsys(amd_context->drm_fd));
     } else {
         pipe = amd_create_softpipe(amd_context);
     }
index a7a70fd..04295e8 100644 (file)
@@ -43,13 +43,45 @@ static void amd_r300_flush_cs(struct radeon_cs* cs)
     radeon_cs_erase(cs);
 }
 
-struct r300_winsys* amd_create_r300_winsys(int fd, uint32_t pci_id)
+/* Helper function to do the ioctls needed for setup and init. */
+static void do_ioctls(struct r300_winsys* winsys, int fd)
+{
+    drm_radeon_getparam_t gp;
+    uint32_t target;
+    int retval;
+
+    /* XXX is this cast safe? */
+    gp.value = (int*)&target;
+
+    /* First, get PCI ID */
+    gp.param = RADEON_PARAM_DEVICE_ID;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get PCI ID, error number %d",
+                __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->pci_id = target;
+
+    /* Then, get the number of pixel pipes */
+    gp.param = RADEON_PARAM_NUM_GB_PIPES;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+    if (retval) {
+        fprintf(stderr, "%s: Failed to get GB pipe count, error number %d",
+                __FUNCTION__, retval);
+        exit(1);
+    }
+    winsys->gb_pipes = target;
+
+}
+
+struct r300_winsys* amd_create_r300_winsys(int fd)
 {
     struct r300_winsys* winsys = calloc(1, sizeof(struct r300_winsys));
 
-    struct radeon_cs_manager* csm = radeon_cs_manager_gem_ctor(fd);
+    do_ioctls(winsys, fd);
 
-    winsys->pci_id = pci_id;
+    struct radeon_cs_manager* csm = radeon_cs_manager_gem_ctor(fd);
 
     winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4);
 
index 0d229fe..d80c235 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+/* XXX WTF is this! I shouldn't have to include those first three! FUCK! */
+#include <stdint.h>
+#include <stdlib.h>
+#include "drm.h"
+#include "radeon_drm.h"
 #include "radeon_cs.h"
 
 #include "r300_winsys.h"
 
 #include "amd_buffer.h"
 
-struct r300_winsys* amd_create_r300_winsys(int fd, uint32_t pci_id);
+struct r300_winsys* amd_create_r300_winsys(int fd);