Whoo, stuff is starting to look cleaner and cleaner.
* 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;
/* 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;
"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 */
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;
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);
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;
#include "util/u_memory.h"
#include "r300_chipset.h"
+#include "r300_winsys.h"
struct r300_screen {
/* Parent class */
}
/* 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 */
/* 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. */
}
#endif
-#endif /* R300_WINSYS_H */
\ No newline at end of file
+#endif /* R300_WINSYS_H */
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);
}
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*)⌖
+
+ /* 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);
* 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);