diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2009-09-22 19:47:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 10:39:52 -0400 |
commit | db88e382a043bf288a6257dc5069f19c5ae67df6 (patch) | |
tree | e105449e8427b7d574512ccd034d7173a4a5d3ca /drivers/video | |
parent | b008c64b5dfe37ac14928668da60132e9c8361ff (diff) |
viafb: clean up virtual memory handling
Clean the handling of ioremapped video memory up. The following changes
were made:
info->screen_base - viafb_FB_MM
(VRAM offset calculation) was replaced by
info->fix.smem_start - viafbinfo->fix.smem_start
which is essentially the same calculation but done with physical instead
virtual addresses.
*->fbmem_virt
was replaced by
viafbinfo->screen_base
This is true for viafbinfo and viafbinfo1 as the par pointers are equal.
An early initialization of viafbinfo1->fix.smem* was removed as done later
in viafb_setup_fixinfo.
This patch highlights that the only usage of the ioremapped video memory
in the driver is for hardware cursor handling. Even if it has to hold the
used virtual screen mapped for old-fashioned read/write calls (vs.
mmap'ed) a lot virtual memory could be saved by only ioremapping on
demand.
Code cleanup, no runtime changes expected.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Scott Fang <ScottFang@viatech.com.cn>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Harald Welte <laforge@gnumonks.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/via/global.c | 1 | ||||
-rw-r--r-- | drivers/video/via/global.h | 1 | ||||
-rw-r--r-- | drivers/video/via/viafbdev.c | 27 | ||||
-rw-r--r-- | drivers/video/via/viafbdev.h | 1 |
4 files changed, 8 insertions, 22 deletions
diff --git a/drivers/video/via/global.c b/drivers/video/via/global.c index 468be2425af3..1096fd5de2bf 100644 --- a/drivers/video/via/global.c +++ b/drivers/video/via/global.c | |||
@@ -46,7 +46,6 @@ int viafb_hotplug_refresh = 60; | |||
46 | unsigned int viafb_second_offset; | 46 | unsigned int viafb_second_offset; |
47 | int viafb_second_size; | 47 | int viafb_second_size; |
48 | int viafb_primary_dev = None_Device; | 48 | int viafb_primary_dev = None_Device; |
49 | void __iomem *viafb_FB_MM; | ||
50 | unsigned int viafb_second_xres = 640; | 49 | unsigned int viafb_second_xres = 640; |
51 | unsigned int viafb_second_yres = 480; | 50 | unsigned int viafb_second_yres = 480; |
52 | unsigned int viafb_second_virtual_xres; | 51 | unsigned int viafb_second_virtual_xres; |
diff --git a/drivers/video/via/global.h b/drivers/video/via/global.h index 7543d5f7e309..11382e5daf35 100644 --- a/drivers/video/via/global.h +++ b/drivers/video/via/global.h | |||
@@ -77,7 +77,6 @@ extern int viafb_hotplug_Yres; | |||
77 | extern int viafb_hotplug_bpp; | 77 | extern int viafb_hotplug_bpp; |
78 | extern int viafb_hotplug_refresh; | 78 | extern int viafb_hotplug_refresh; |
79 | extern int viafb_primary_dev; | 79 | extern int viafb_primary_dev; |
80 | extern void __iomem *viafb_FB_MM; | ||
81 | extern struct fb_cursor viacursor; | 80 | extern struct fb_cursor viacursor; |
82 | 81 | ||
83 | extern unsigned int viafb_second_xres; | 82 | extern unsigned int viafb_second_xres; |
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 0cd112a36901..86835ee41027 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c | |||
@@ -832,8 +832,7 @@ static void viafb_fillrect(struct fb_info *info, | |||
832 | /* Source Base Address */ | 832 | /* Source Base Address */ |
833 | writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE); | 833 | writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE); |
834 | /* Destination Base Address */ | 834 | /* Destination Base Address */ |
835 | writel(((unsigned long) (info->screen_base) - | 835 | writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3, |
836 | (unsigned long) viafb_FB_MM) >> 3, | ||
837 | viaparinfo->io_virt + VIA_REG_DSTBASE); | 836 | viaparinfo->io_virt + VIA_REG_DSTBASE); |
838 | /* Pitch */ | 837 | /* Pitch */ |
839 | pitch = (info->var.xres_virtual + 7) & ~7; | 838 | pitch = (info->var.xres_virtual + 7) & ~7; |
@@ -887,12 +886,10 @@ static void viafb_copyarea(struct fb_info *info, | |||
887 | } | 886 | } |
888 | 887 | ||
889 | /* Source Base Address */ | 888 | /* Source Base Address */ |
890 | writel(((unsigned long) (info->screen_base) - | 889 | writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3, |
891 | (unsigned long) viafb_FB_MM) >> 3, | ||
892 | viaparinfo->io_virt + VIA_REG_SRCBASE); | 890 | viaparinfo->io_virt + VIA_REG_SRCBASE); |
893 | /* Destination Base Address */ | 891 | /* Destination Base Address */ |
894 | writel(((unsigned long) (info->screen_base) - | 892 | writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3, |
895 | (unsigned long) viafb_FB_MM) >> 3, | ||
896 | viaparinfo->io_virt + VIA_REG_DSTBASE); | 893 | viaparinfo->io_virt + VIA_REG_DSTBASE); |
897 | /* Pitch */ | 894 | /* Pitch */ |
898 | pitch = (info->var.xres_virtual + 7) & ~7; | 895 | pitch = (info->var.xres_virtual + 7) & ~7; |
@@ -951,8 +948,7 @@ static void viafb_imageblit(struct fb_info *info, | |||
951 | /* Source Base Address */ | 948 | /* Source Base Address */ |
952 | writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE); | 949 | writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE); |
953 | /* Destination Base Address */ | 950 | /* Destination Base Address */ |
954 | writel(((unsigned long) (info->screen_base) - | 951 | writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3, |
955 | (unsigned long) viafb_FB_MM) >> 3, | ||
956 | viaparinfo->io_virt + VIA_REG_DSTBASE); | 952 | viaparinfo->io_virt + VIA_REG_DSTBASE); |
957 | /* Pitch */ | 953 | /* Pitch */ |
958 | pitch = (info->var.xres_virtual + 7) & ~7; | 954 | pitch = (info->var.xres_virtual + 7) & ~7; |
@@ -1170,7 +1166,7 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) | |||
1170 | } | 1166 | } |
1171 | } | 1167 | } |
1172 | 1168 | ||
1173 | memcpy(((struct viafb_par *)(info->par))->fbmem_virt + | 1169 | memcpy(viafbinfo->screen_base + |
1174 | ((struct viafb_par *)(info->par))->cursor_start, | 1170 | ((struct viafb_par *)(info->par))->cursor_start, |
1175 | cr_data->bak, CURSOR_SIZE); | 1171 | cr_data->bak, CURSOR_SIZE); |
1176 | out: | 1172 | out: |
@@ -2073,11 +2069,9 @@ static int __devinit via_pci_probe(void) | |||
2073 | viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize); | 2069 | viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize); |
2074 | viaparinfo->fbmem_free = viaparinfo->memsize; | 2070 | viaparinfo->fbmem_free = viaparinfo->memsize; |
2075 | viaparinfo->fbmem_used = 0; | 2071 | viaparinfo->fbmem_used = 0; |
2076 | viaparinfo->fbmem_virt = ioremap_nocache(viaparinfo->fbmem, | 2072 | viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem, |
2077 | viaparinfo->memsize); | 2073 | viaparinfo->memsize); |
2078 | viafbinfo->screen_base = (char *)viaparinfo->fbmem_virt; | 2074 | if (!viafbinfo->screen_base) { |
2079 | |||
2080 | if (!viaparinfo->fbmem_virt) { | ||
2081 | printk(KERN_INFO "ioremap failed\n"); | 2075 | printk(KERN_INFO "ioremap failed\n"); |
2082 | return -ENOMEM; | 2076 | return -ENOMEM; |
2083 | } | 2077 | } |
@@ -2110,7 +2104,6 @@ static int __devinit via_pci_probe(void) | |||
2110 | viafb_second_size * 1024 * 1024; | 2104 | viafb_second_size * 1024 * 1024; |
2111 | } | 2105 | } |
2112 | 2106 | ||
2113 | viafb_FB_MM = viaparinfo->fbmem_virt; | ||
2114 | tmpm = viafb_mode; | 2107 | tmpm = viafb_mode; |
2115 | tmpc = strsep(&tmpm, "x"); | 2108 | tmpc = strsep(&tmpm, "x"); |
2116 | strict_strtoul(tmpc, 0, &default_xres); | 2109 | strict_strtoul(tmpc, 0, &default_xres); |
@@ -2203,8 +2196,6 @@ static int __devinit via_pci_probe(void) | |||
2203 | viaparinfo1->memsize = viaparinfo->memsize - | 2196 | viaparinfo1->memsize = viaparinfo->memsize - |
2204 | viafb_second_offset; | 2197 | viafb_second_offset; |
2205 | viaparinfo->memsize = viafb_second_offset; | 2198 | viaparinfo->memsize = viafb_second_offset; |
2206 | viaparinfo1->fbmem_virt = viaparinfo->fbmem_virt + | ||
2207 | viafb_second_offset; | ||
2208 | viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset; | 2199 | viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset; |
2209 | 2200 | ||
2210 | viaparinfo1->fbmem_used = viaparinfo->fbmem_used; | 2201 | viaparinfo1->fbmem_used = viaparinfo->fbmem_used; |
@@ -2226,8 +2217,6 @@ static int __devinit via_pci_probe(void) | |||
2226 | memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info)); | 2217 | memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info)); |
2227 | viafbinfo1->screen_base = viafbinfo->screen_base + | 2218 | viafbinfo1->screen_base = viafbinfo->screen_base + |
2228 | viafb_second_offset; | 2219 | viafb_second_offset; |
2229 | viafbinfo1->fix.smem_start = viaparinfo1->fbmem; | ||
2230 | viafbinfo1->fix.smem_len = viaparinfo1->fbmem_free; | ||
2231 | 2220 | ||
2232 | default_var.xres = viafb_second_xres; | 2221 | default_var.xres = viafb_second_xres; |
2233 | default_var.yres = viafb_second_yres; | 2222 | default_var.yres = viafb_second_yres; |
@@ -2289,7 +2278,7 @@ static void __devexit via_pci_remove(void) | |||
2289 | unregister_framebuffer(viafbinfo); | 2278 | unregister_framebuffer(viafbinfo); |
2290 | if (viafb_dual_fb) | 2279 | if (viafb_dual_fb) |
2291 | unregister_framebuffer(viafbinfo1); | 2280 | unregister_framebuffer(viafbinfo1); |
2292 | iounmap((void *)viaparinfo->fbmem_virt); | 2281 | iounmap((void *)viafbinfo->screen_base); |
2293 | iounmap(viaparinfo->io_virt); | 2282 | iounmap(viaparinfo->io_virt); |
2294 | 2283 | ||
2295 | viafb_delete_i2c_buss(viaparinfo); | 2284 | viafb_delete_i2c_buss(viaparinfo); |
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h index 92318770107e..e5a247c1bb91 100644 --- a/drivers/video/via/viafbdev.h +++ b/drivers/video/via/viafbdev.h | |||
@@ -38,7 +38,6 @@ | |||
38 | #define VERSION_MINOR 4 | 38 | #define VERSION_MINOR 4 |
39 | 39 | ||
40 | struct viafb_par { | 40 | struct viafb_par { |
41 | void __iomem *fbmem_virt; /*framebuffer virtual memory address */ | ||
42 | void __iomem *io_virt; /*iospace virtual memory address */ | 41 | void __iomem *io_virt; /*iospace virtual memory address */ |
43 | unsigned int fbmem; /*framebuffer physical memory address */ | 42 | unsigned int fbmem; /*framebuffer physical memory address */ |
44 | unsigned int memsize; /*size of fbmem */ | 43 | unsigned int memsize; /*size of fbmem */ |