summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <vignatti@freedesktop.org>2009-05-14 03:40:25 -0300
committerTiago Vignatti <vignatti@freedesktop.org>2009-05-14 03:40:25 -0300
commit18a186804bc4e496a392cb31003cef25798f6c7b (patch)
tree21cd11564c3a9acb64775055b15b3778c200edc9
parent812ad80018d49f6e4f1be8256d86488690c3ba52 (diff)
downloadlibpciaccess-18a186804bc4e496a392cb31003cef25798f6c7b.tar.gz
libpciaccess-18a186804bc4e496a392cb31003cef25798f6c7b.tar.bz2
libpciaccess-18a186804bc4e496a392cb31003cef25798f6c7b.zip
Delete vga_arb_rec.
-rw-r--r--include/pciaccess.h41
-rw-r--r--src/common_vgaarb.c53
-rw-r--r--src/common_vgaarb_stub.c21
3 files changed, 50 insertions, 65 deletions
diff --git a/include/pciaccess.h b/include/pciaccess.h
index 4087264..b7dad13 100644
--- a/include/pciaccess.h
+++ b/include/pciaccess.h
@@ -375,6 +375,12 @@ struct pci_device {
* the \c pci_device structure.
*/
intptr_t user_data;
+
+ /**
+ * Used by the VGA arbiter. Kind of resource decoded by the device and
+ * the file descriptor. */
+ int vgaarb_rsrc;
+ int vgaarb_fd;
};
@@ -479,19 +485,13 @@ struct pci_pcmcia_bridge_info {
* VGA Arbiter definitions, functions and related.
*/
-typedef int VgaArbRsrcType;
-
-/* This is a mask that can be OR'ed */
-#define VGA_ARB_RSRC_NONE 0
-#define VGA_ARB_RSRC_LEGACY_IO 1
-#define VGA_ARB_RSRC_LEGACY_MEM 2
-#define VGA_ARB_RSRC_NORMAL_IO 4
-#define VGA_ARB_RSRC_NORMAL_MEM 8
-
-typedef struct {
- int fd;
- VgaArbRsrcType rsrc;
-} vga_arb_rec, *vga_arb_ptr;
+/* Legacy VGA regions */
+#define VGA_ARB_RSRC_NONE 0x00
+#define VGA_ARB_RSRC_LEGACY_IO 0x01
+#define VGA_ARB_RSRC_LEGACY_MEM 0x02
+/* Non-legacy access */
+#define VGA_ARB_RSRC_NORMAL_IO 0x04
+#define VGA_ARB_RSRC_NORMAL_MEM 0x08
/*
* With exception of vga_arb_trylock(), all functions bellow return 1 on success
@@ -504,13 +504,12 @@ typedef struct {
* it will print error messages at stderr.
*
*/
-int pci_device_vgaarb_init (vga_arb_ptr *vgaDev);
-void pci_device_vgaarb_fini (vga_arb_ptr vgaDev);
-int pci_device_vgaarb_set_target (vga_arb_ptr vgaDev, unsigned int domain,
- unsigned int bus, unsigned int dev, unsigned int fn);
-int pci_device_vgaarb_decodes (vga_arb_ptr vgaDev);
-int pci_device_vgaarb_lock (vga_arb_ptr vgaDev);
-int pci_device_vgaarb_trylock (vga_arb_ptr vgaDev);
-int pci_device_vgaarb_unlock (vga_arb_ptr vgaDev);
+int pci_device_vgaarb_init (struct pci_device *dev);
+void pci_device_vgaarb_fini (struct pci_device *dev);
+int pci_device_vgaarb_set_target (struct pci_device *dev);
+int pci_device_vgaarb_decodes (struct pci_device *dev);
+int pci_device_vgaarb_lock (struct pci_device *dev);
+int pci_device_vgaarb_trylock (struct pci_device *dev);
+int pci_device_vgaarb_unlock (struct pci_device *dev);
#endif /* PCIACCESS_H */
diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index cc1e262..9cf7385 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -45,28 +45,22 @@
#define VGAARB_DEV "/dev/vga_arbiter"
int
-pci_device_vgaarb_init(vga_arb_ptr *vgaDev)
+pci_device_vgaarb_init(struct pci_device *dev)
{
- *vgaDev = malloc (sizeof(vga_arb_ptr *));
- if (vgaDev == NULL) {
- fprintf(stderr, "%s: malloc: couldn't allocate memory\n", __FUNCTION__);
- return 0;
- }
-
- (*vgaDev)->rsrc = 0;
+ dev->vgaarb_rsrc = VGA_ARB_RSRC_NONE;
- if (((*vgaDev)->fd = open (VGAARB_DEV, O_RDWR)) < 0) {
+ if ((dev->vgaarb_fd = open (VGAARB_DEV, O_RDWR)) < 0) {
perror("device open failed");
- return 0;
+ return 1;
}
- return (*vgaDev)->fd;
+ return 0;
}
void
-pci_device_vgaarb_fini(vga_arb_ptr vgaDev)
+pci_device_vgaarb_fini(struct pci_device *dev)
{
- if (close(vgaDev->fd) == -1)
+ if (close(dev->vgaarb_fd) == -1)
perror("device close failed");
}
@@ -112,7 +106,7 @@ vgaarb_write(int fd, char *buf, int len)
}
static const char *
-rsrc_to_str(VgaArbRsrcType iostate)
+rsrc_to_str(int iostate)
{
switch (iostate) {
case VGA_ARB_RSRC_LEGACY_IO | VGA_ARB_RSRC_LEGACY_MEM:
@@ -155,49 +149,48 @@ vga_arb_read(vga_arb_ptr vgaDev)
}
#endif
int
-pci_device_vgaarb_set_target(vga_arb_ptr vgaDev, unsigned int domain,
- unsigned int bus, unsigned int dev, unsigned int fn)
+pci_device_vgaarb_set_target(struct pci_device *dev)
{
int len;
char buf[BUFSIZE];
len = snprintf(buf, BUFSIZE, "target PCI:%d:%d:%d.%d",
- domain, bus, dev, fn);
+ dev->domain, dev->bus, dev->dev, dev->func);
- return vgaarb_write(vgaDev->fd, buf, len);
+ return vgaarb_write(dev->vgaarb_fd, buf, len);
}
int
-pci_device_vgaarb_decodes(vga_arb_ptr vgaDev)
+pci_device_vgaarb_decodes(struct pci_device *dev)
{
int len;
char buf[BUFSIZE];
- len = snprintf(buf, BUFSIZE, "decodes %s", rsrc_to_str(vgaDev->rsrc));
+ len = snprintf(buf, BUFSIZE, "decodes %s", rsrc_to_str(dev->vgaarb_rsrc));
- return vgaarb_write(vgaDev->fd, buf, len);
+ return vgaarb_write(dev->vgaarb_fd, buf, len);
}
int
-pci_device_vgaarb_lock(vga_arb_ptr vgaDev)
+pci_device_vgaarb_lock(struct pci_device *dev)
{
int len;
char buf[BUFSIZE];
- len = snprintf(buf, BUFSIZE, "lock %s", rsrc_to_str(vgaDev->rsrc));
+ len = snprintf(buf, BUFSIZE, "lock %s", rsrc_to_str(dev->vgaarb_rsrc));
- return vgaarb_write(vgaDev->fd, buf, len);
+ return vgaarb_write(dev->vgaarb_fd, buf, len);
}
int
-pci_device_vgaarb_trylock(vga_arb_ptr vgaDev)
+pci_device_vgaarb_trylock(struct pci_device *dev)
{
int len, write_ret;
char buf[BUFSIZE];
- len = snprintf(buf, BUFSIZE, "trylock %s", rsrc_to_str(vgaDev->rsrc));
+ len = snprintf(buf, BUFSIZE, "trylock %s", rsrc_to_str(dev->vgaarb_rsrc));
- write_ret = vgaarb_write(vgaDev->fd, buf, len);
+ write_ret = vgaarb_write(dev->vgaarb_fd, buf, len);
if (write_ret == 0)
return -1;
@@ -209,12 +202,12 @@ pci_device_vgaarb_trylock(vga_arb_ptr vgaDev)
}
int
-pci_device_vgaarb_unlock(vga_arb_ptr vgaDev)
+pci_device_vgaarb_unlock(struct pci_device *dev)
{
int len;
char buf[BUFSIZE];
- len = snprintf(buf, BUFSIZE, "unlock %s", rsrc_to_str(vgaDev->rsrc));
+ len = snprintf(buf, BUFSIZE, "unlock %s", rsrc_to_str(dev->vgaarb_rsrc));
- return vgaarb_write(vgaDev->fd, buf, len);
+ return vgaarb_write(dev->vgaarb_fd, buf, len);
}
diff --git a/src/common_vgaarb_stub.c b/src/common_vgaarb_stub.c
index 9fa36ac..976dbb2 100644
--- a/src/common_vgaarb_stub.c
+++ b/src/common_vgaarb_stub.c
@@ -33,44 +33,37 @@
int
-vga_arb_read(vga_arb_ptr vgaDev)
+vga_arb_set_target(struct pci_device *dev)
{
return 1;
}
int
-vga_arb_set_target(vga_arb_ptr vgaDev, unsigned int domain, unsigned int bus,
- unsigned int dev, unsigned int fn)
+vga_arb_lock(struct pci_device *dev)
{
return 1;
}
int
-vga_arb_lock(vga_arb_ptr vgaDev)
+vga_arb_trylock(struct pci_device *dev)
{
return 1;
}
int
-vga_arb_trylock(vga_arb_ptr vgaDev)
+vga_arb_unlock(struct pci_device *dev)
{
return 1;
}
int
-vga_arb_unlock(vga_arb_ptr vgaDev)
+vga_arb_decodes(struct pci_device *dev)
{
return 1;
}
int
-vga_arb_decodes(vga_arb_ptr vgaDev)
-{
- return 1;
-}
-
-int
-vga_arb_init(vga_arb_ptr *vgaDev)
+vga_arb_init(struct pci_device *dev)
{
#ifdef DEBUG
fprintf(stderr, "%s: YOU'RE USING THE STUB FUNCTIONS!\n", __FUNCTION__);
@@ -79,6 +72,6 @@ vga_arb_init(vga_arb_ptr *vgaDev)
}
void
-vga_arb_fini(vga_arb_ptr vgaDev)
+vga_arb_fini(struct pci_device *dev)
{
}