summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorbin Simpson <[email protected]>2009-01-22 13:34:21 -0800
committerCorbin Simpson <[email protected]>2009-02-01 23:30:25 -0800
commitecb7f29f74c8f7456302267fe31b1de4bcc103c5 (patch)
tree1f86aac7d7a005755dc7e9a00796e43a3ea9919b
parent90a96cb2addf48b3b48c039a8dc6de9e53bfb6df (diff)
amd/r300: Wire up GETPARAM ioctls.
Whoo, stuff is starting to look cleaner and cleaner.
-rw-r--r--src/gallium/drivers/r300/r300_chipset.c5
-rw-r--r--src/gallium/drivers/r300/r300_chipset.h2
-rw-r--r--src/gallium/drivers/r300/r300_context.c2
-rw-r--r--src/gallium/drivers/r300/r300_screen.c8
-rw-r--r--src/gallium/drivers/r300/r300_screen.h4
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h5
-rw-r--r--src/gallium/winsys/drm/amd/amd_context.c9
-rw-r--r--src/gallium/winsys/drm/amd/amd_r300.c38
-rw-r--r--src/gallium/winsys/drm/amd/amd_r300.h7
9 files changed, 62 insertions, 18 deletions
diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c
index b7de2359cbd..f2dc8aedaad 100644
--- a/src/gallium/drivers/r300/r300_chipset.c
+++ b/src/gallium/drivers/r300/r300_chipset.c
@@ -26,10 +26,9 @@
* 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;
diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h
index 548d7a6c500..f1502ff76c5 100644
--- a/src/gallium/drivers/r300/r300_chipset.h
+++ b/src/gallium/drivers/r300/r300_chipset.h
@@ -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 */
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 467594ec9b6..f254b2f2a32 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -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;
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index a241d606c0c..63ddd3b6a62 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -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;
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index b6c3d1f462f..83d5a75d0a2 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -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 */
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 319152c8536..867d65b7de1 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -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 */
diff --git a/src/gallium/winsys/drm/amd/amd_context.c b/src/gallium/winsys/drm/amd/amd_context.c
index 53311684ded..7a486c93a59 100644
--- a/src/gallium/winsys/drm/amd/amd_context.c
+++ b/src/gallium/winsys/drm/amd/amd_context.c
@@ -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);
}
diff --git a/src/gallium/winsys/drm/amd/amd_r300.c b/src/gallium/winsys/drm/amd/amd_r300.c
index a7a70fdd7ff..04295e8281b 100644
--- a/src/gallium/winsys/drm/amd/amd_r300.c
+++ b/src/gallium/winsys/drm/amd/amd_r300.c
@@ -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);
diff --git a/src/gallium/winsys/drm/amd/amd_r300.h b/src/gallium/winsys/drm/amd/amd_r300.h
index 0d229fe0c4c..d80c23594cd 100644
--- a/src/gallium/winsys/drm/amd/amd_r300.h
+++ b/src/gallium/winsys/drm/amd/amd_r300.h
@@ -20,10 +20,15 @@
* 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);