amd/r300: Wire up GETPARAM ioctls.

Whoo, stuff is starting to look cleaner and cleaner.
This commit is contained in:
Corbin Simpson 2009-01-22 13:34:21 -08:00
parent 90a96cb2ad
commit ecb7f29f74
9 changed files with 62 additions and 18 deletions

View File

@ -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;

View 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 */

View 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;

View 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;

View 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 */

View 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 */
#endif /* R300_WINSYS_H */

View 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);
}

View 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*)⌖
/* 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);

View File

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