diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2012-02-24 21:57:02 -0600 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-03-09 09:42:02 +0000 |
commit | 6f8be87e4e07a314709992fa0533949bb4014914 (patch) | |
tree | c569fbf3b0efa729893243845a13cc006eebf112 | |
parent | a069eac6681e901c8592fb27810a6864678608f9 (diff) |
switch to modern pci_device_map_range API
Ever since it was introduced in libpciaccess 0.10.0 four years ago,
pci_device_map_range has been the preferred way to map a PCI region
and pci_device_map_region has been a deprecated backward-compatibility
shim. Switch over. No functional change intended.
Noticed by gcc -Wdeprecated-declarations.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | avivotool.c | 31 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | radeonreg.c | 22 | ||||
-rw-r--r-- | radeontool.c | 22 |
4 files changed, 35 insertions, 42 deletions
diff --git a/avivotool.c b/avivotool.c index bc827b3..2f7d4e5 100644 --- a/avivotool.c +++ b/avivotool.c @@ -55,9 +55,8 @@ int reg_type[0x8001]; /* *ctrl_mem is mapped to the actual device's memory mapped control area. */ /* Not the address but what it points to is volatile. */ -struct pci_device *avivo_device = NULL; RADEONCardInfo *card_info = NULL; -unsigned int ctrl_region, fb_region; +pciaddr_t fb_base; unsigned char * volatile ctrl_mem; unsigned char * volatile fb_mem; @@ -567,13 +566,11 @@ void radeon_output_set(char *output, char *status) /* Select graphics mode? */ SET_REG(0x00000330, 0x00010600); SET_REG(0x00000338, 0x00000400); - SET_REG(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS, - avivo_device->regions[fb_region].base_addr); + SET_REG(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS, fb_base); /* These modelines are all hardcoded for my 1280x1024; * adjust to suit. */ SET_REG(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS, - avivo_device->regions[fb_region].base_addr + - (1280 * 1024 * 4)); + fb_base + 1280 * 1024 * 4); SET_REG(AVIVO_D1GRPH_X_END, 1280); SET_REG(AVIVO_D1GRPH_Y_END, 1024); @@ -651,7 +648,7 @@ int radeon_get_fb_params(char *crtc, int write, unsigned long *location, int *le return 0; } - *location -= avivo_device->regions[fb_region].base_addr; + *location -= fb_base; *location += (unsigned long) fb_mem; #endif return 1; @@ -1797,6 +1794,7 @@ static int map_radeon_mem(void) #endif struct pci_device_iterator *iter; struct pci_device *device; + pciaddr_t fb_size, ctrl_base, ctrl_size; int i = 0; if (pci_system_init() != 0) { @@ -1858,20 +1856,19 @@ static int map_radeon_mem(void) return -1; } - fb_region = 0; - ctrl_region = 2; - avivo_device = device; - - if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0) { + ctrl_base = device->regions[2].base_addr; + ctrl_size = device->regions[2].size; + if (!ctrl_size || pci_device_map_range(device, ctrl_base, ctrl_size, + PCI_DEV_MAP_FLAG_WRITABLE, (void **) &ctrl_mem)) { fprintf(stderr, "error: mapping ctrl region\n"); return -1; } - ctrl_mem = avivo_device->regions[ctrl_region].memory; - if (pci_device_map_region(avivo_device, fb_region, 1) == 0) - fb_mem = avivo_device->regions[fb_region].memory; - else - fb_mem = NULL; + fb_base = device->regions[0].base_addr; + fb_size = device->regions[0].size; + if (!fb_size || pci_device_map_range(device, fb_base, fb_size, + PCI_DEV_MAP_FLAG_WRITABLE, (void **) &fb_mem)) + fb_mem = NULL; pci_iterator_destroy(iter); diff --git a/configure.ac b/configure.ac index 45a5237..c71f021 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,6 @@ AC_DISABLE_STATIC AC_PROG_CC AC_PROG_INSTALL -PKG_CHECK_MODULES(LIBPCIACCESS, pciaccess) +PKG_CHECK_MODULES(LIBPCIACCESS, [pciaccess >= 0.10.0]) AC_OUTPUT([Makefile]) diff --git a/radeonreg.c b/radeonreg.c index 2223cee..7b76351 100644 --- a/radeonreg.c +++ b/radeonreg.c @@ -38,9 +38,7 @@ int skip; /* *ctrl_mem is mapped to the actual device's memory mapped control area. */ /* Not the address but what it points to is volatile. */ -struct pci_device *avivo_device = NULL; RADEONCardInfo *card_info = NULL; -unsigned int ctrl_region, fb_region; unsigned char * volatile ctrl_mem; unsigned char * volatile fb_mem; @@ -365,6 +363,7 @@ static int map_radeon_mem(void) #endif struct pci_device_iterator *iter; struct pci_device *device; + pciaddr_t fb_base, fb_size, ctrl_base, ctrl_size; int i = 0; if (pci_system_init() != 0) @@ -411,18 +410,17 @@ static int map_radeon_mem(void) card_info = &RADEONCards[i]; } - fb_region = 0; - ctrl_region = 2; - avivo_device = device; - - if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0) + ctrl_base = device->regions[2].base_addr; + ctrl_size = device->regions[2].size; + if (!ctrl_size || pci_device_map_range(device, ctrl_base, ctrl_size, + PCI_DEV_MAP_FLAG_WRITABLE, (void **) &ctrl_mem)) die("mapping ctrl region"); - ctrl_mem = avivo_device->regions[ctrl_region].memory; - if (pci_device_map_region(avivo_device, fb_region, 1) == 0) - fb_mem = avivo_device->regions[fb_region].memory; - else - fb_mem = NULL; + fb_base = device->regions[0].base_addr; + fb_size = device->regions[0].size; + if (!fb_size || pci_device_map_range(device, fb_base, fb_size, + PCI_DEV_MAP_FLAG_WRITABLE, (void **) &fb_mem)) + fb_mem = NULL; pci_iterator_destroy(iter); diff --git a/radeontool.c b/radeontool.c index cb0d12d..dbab763 100644 --- a/radeontool.c +++ b/radeontool.c @@ -31,9 +31,7 @@ int skip = 0; /* *radeon_cntl_mem is mapped to the actual device's memory mapped control area. */ /* Not the address but what it points to is volatile. */ -struct pci_device *avivo_device = NULL; unsigned char * volatile radeon_cntl_mem; -int ctrl_region = -1, fb_region = -1; unsigned char * volatile fb_mem; unsigned char * volatile ctrl_mem; static void radeon_rom_legacy_mmio_table(unsigned char *bios, int offset); @@ -917,6 +915,7 @@ static void map_radeon_cntl_mem(void) struct pci_slot_match match; struct pci_device_iterator *iter; struct pci_device *device; + pciaddr_t fb_base, fb_size, ctrl_base, ctrl_size; int i = 0; if (pci_system_init() != 0) @@ -948,18 +947,17 @@ static void map_radeon_cntl_mem(void) if (!device) die("cannot find Radeon device"); - fb_region = 0; - ctrl_region = 2; - avivo_device = device; - - if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0) + ctrl_base = device->regions[2].base_addr; + ctrl_size = device->regions[2].size; + if (!ctrl_size || pci_device_map_range(device, ctrl_base, ctrl_size, + PCI_DEV_MAP_FLAG_WRITABLE, (void **) &ctrl_mem)) die("mapping ctrl region"); - ctrl_mem = avivo_device->regions[ctrl_region].memory; - if (pci_device_map_region(avivo_device, fb_region, 1) == 0) - fb_mem = avivo_device->regions[fb_region].memory; - else - fb_mem = NULL; + fb_base = device->regions[0].base_addr; + fb_size = device->regions[0].size; + if (!fb_size || pci_device_map_range(device, fb_base, fb_size, + PCI_DEV_MAP_FLAG_WRITABLE, (void **) &fb_mem)) + fb_mem = NULL; pci_iterator_destroy(iter); |