* per-fb mmap for platinumfb and valkyriefb in 2.4
@ 2000-09-13 20:36 Michel Lanners
2000-09-13 21:10 ` per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2) Michel Lanners
2000-11-19 11:04 ` per-fb mmap for platinumfb and valkyriefb in 2.4 Michel Lanners
0 siblings, 2 replies; 8+ messages in thread
From: Michel Lanners @ 2000-09-13 20:36 UTC (permalink / raw)
To: linuxppc-dev
Hi all,
Below is the per-fb mmap implementation I already posted here for
controlfb, but this time for the other two powermacfb drivers:
valkyriefb and platinumfb.
Patch is against Paul's rsync tree at 2.4.0-test7, but since I don't
expect much change in this area it should apply equally well to anything
more recent ;-)
Since I don't have any of these hardware devices, it's untested. If you
do test, expect a 2-to-4-times performance boost on scrolling:
[mlan@piglet ~]$ x11perf -scroll500
I get around 35/sec on controlfb at 1152x870@32bpp with XF4.0; around
9/sec without the optimized caching in the mmap().
Have fun!
Michel
PS Will appear on sourceforge soon.....
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art.
23, Rue Paul Henkes | Ask Questions. Make Mistakes.
L-1710 Luxembourg |
email mlan@cpu.lu |
http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2)
2000-09-13 20:36 per-fb mmap for platinumfb and valkyriefb in 2.4 Michel Lanners
@ 2000-09-13 21:10 ` Michel Lanners
2000-09-13 22:24 ` Martin Costabel
2000-11-19 11:04 ` per-fb mmap for platinumfb and valkyriefb in 2.4 Michel Lanners
1 sibling, 1 reply; 8+ messages in thread
From: Michel Lanners @ 2000-09-13 21:10 UTC (permalink / raw)
To: linuxppc-dev
[-- Attachment #1: Type: TEXT/plain, Size: 725 bytes --]
Hi all,
On 13 Sep, this message from mlan echoed through cyberspace:
> Below is the per-fb mmap implementation
Err.. nothing was below. Stupid /me... it's getting late.
Anyway, here it is for both 2.2 and 2.4. Note that to compile on 2.2,
you need my controlfb patch implementing mmap as well, since without it,
this one won't compile (get it on sourceforge).
Have fun!
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art.
23, Rue Paul Henkes | Ask Questions. Make Mistakes.
L-1710 Luxembourg |
email mlan@cpu.lu |
http://www.cpu.lu/~mlan | Learn Always. "
[-- Attachment #2: 2.2-powermacfb.diff --]
[-- Type: TEXT/plain, Size: 4428 bytes --]
--- linux-2.2.17-pristine/drivers/video/valkyriefb.c Thu Oct 1 19:02:21 1998
+++ linux-2.2.17/drivers/video/valkyriefb.c Wed Sep 13 22:56:33 2000
@@ -133,6 +133,8 @@
struct fb_info *info);
static int valkyrie_ioctl(struct inode *inode, struct file *file, u_int cmd,
u_long arg, int con, struct fb_info *info);
+static int valkyrie_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma);
static int read_valkyrie_sense(struct fb_info_valkyrie *p);
static inline int valkyrie_vram_reqd(int video_mode, int color_mode);
@@ -159,7 +161,8 @@
valkyrie_get_cmap,
valkyrie_set_cmap,
valkyrie_pan_display,
- valkyrie_ioctl
+ valkyrie_ioctl,
+ valkyrie_mmap
};
static int valkyriefb_getcolreg(u_int regno, u_int *red, u_int *green,
@@ -308,6 +311,52 @@
u_long arg, int con, struct fb_info *info)
{
return -EINVAL;
+}
+
+/* Private mmap since we want to have a different caching on the framebuffer
+ * for valkyriefb.
+ * Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
+ */
+static int valkyrie_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct fb_ops *fb = info->fbops;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ unsigned long start;
+ u32 len;
+
+ fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
+
+ start = (unsigned long)fix.smem_start;
+ len = (start & ~PAGE_MASK)+fix.smem_len;
+ len = (len+~PAGE_MASK) & PAGE_MASK;
+ if (vma->vm_offset >= len) {
+ /* memory mapped io */
+ vma->vm_offset -= len;
+ fb->fb_get_var(&var, PROC_CONSOLE(info), info);
+ if (var.accel_flags)
+ return -EINVAL;
+ start = (unsigned long)fix.mmio_start;
+ len = (start & ~PAGE_MASK)+fix.mmio_len;
+ len = (len+~PAGE_MASK) & PAGE_MASK;
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
+ } else {
+ /* framebuffer */
+ pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+ }
+ start &= PAGE_MASK;
+ if ((vma->vm_end - vma->vm_start + vma->vm_offset) > len)
+ return -EINVAL;
+ vma->vm_offset += start;
+ if (vma->vm_offset & ~PAGE_MASK)
+ return -ENXIO;
+
+ if (remap_page_range(vma->vm_start, vma->vm_offset,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+
+ return 0;
}
static int valkyriefb_switch(int con, struct fb_info *fb)
--- linux-2.2.17-pristine/drivers/video/platinumfb.c Wed Sep 15 07:48:12 1999
+++ linux-2.2.17/drivers/video/platinumfb.c Wed Sep 13 23:00:54 2000
@@ -118,6 +118,8 @@
struct fb_info *info);
static int platinum_ioctl(struct inode *inode, struct file *file, u_int cmd,
u_long arg, int con, struct fb_info *info);
+static int platinum_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma);
/*
@@ -175,7 +177,8 @@
platinum_get_cmap,
platinum_set_cmap,
platinum_pan_display,
- platinum_ioctl
+ platinum_ioctl,
+ platinum_mmap
};
@@ -377,6 +380,52 @@
{
printk(KERN_ERR "platinum_ioctl not yet implemented\n");
return -EINVAL;
+}
+
+/* Private mmap since we want to have a different caching on the framebuffer
+ * for platinumfb.
+ * Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
+ */
+static int platinum_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct fb_ops *fb = info->fbops;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ unsigned long start;
+ u32 len;
+
+ fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
+
+ start = (unsigned long)fix.smem_start;
+ len = (start & ~PAGE_MASK)+fix.smem_len;
+ len = (len+~PAGE_MASK) & PAGE_MASK;
+ if (vma->vm_offset >= len) {
+ /* memory mapped io */
+ vma->vm_offset -= len;
+ fb->fb_get_var(&var, PROC_CONSOLE(info), info);
+ if (var.accel_flags)
+ return -EINVAL;
+ start = (unsigned long)fix.mmio_start;
+ len = (start & ~PAGE_MASK)+fix.mmio_len;
+ len = (len+~PAGE_MASK) & PAGE_MASK;
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
+ } else {
+ /* framebuffer */
+ pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+ }
+ start &= PAGE_MASK;
+ if ((vma->vm_end - vma->vm_start + vma->vm_offset) > len)
+ return -EINVAL;
+ vma->vm_offset += start;
+ if (vma->vm_offset & ~PAGE_MASK)
+ return -ENXIO;
+
+ if (remap_page_range(vma->vm_start, vma->vm_offset,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+
+ return 0;
}
static int platinum_switch(int con, struct fb_info *fb)
[-- Attachment #3: 2.4-powermacfb.diff --]
[-- Type: TEXT/plain, Size: 4083 bytes --]
--- linux-2.4.paul/drivers/video/platinumfb.c Sat Aug 5 09:40:52 2000
+++ linux/drivers/video/platinumfb.c Wed Sep 13 22:06:57 2000
@@ -111,6 +111,8 @@
struct fb_info *info);
static int platinum_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
+static int platinum_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma);
/*
@@ -163,6 +165,7 @@
fb_set_var: platinum_set_var,
fb_get_cmap: platinum_get_cmap,
fb_set_cmap: platinum_set_cmap,
+ fb_mmap: platinum_mmap,
};
static int platinum_get_fix(struct fb_fix_screeninfo *fix, int con,
@@ -326,6 +329,47 @@
return fb_set_cmap(cmap, kspc, platinum_setcolreg, info);
else
fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
+ return 0;
+}
+
+/* Private mmap since we want to have a different caching on the framebuffer
+ * for platinumfb.
+ * Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
+ */
+static int platinum_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct fb_ops *fb = info->fbops;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ unsigned long off, start;
+ u32 len;
+
+ fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
+ off = vma->vm_pgoff << PAGE_SHIFT;
+
+ /* frame buffer memory */
+ start = fix.smem_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.smem_len);
+ if (off >= len) {
+ /* memory mapped io */
+ off -= len;
+ fb->fb_get_var(&var, PROC_CONSOLE(info), info);
+ if (var.accel_flags)
+ return -EINVAL;
+ start = fix.mmio_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len);
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
+ } else {
+ /* framebuffer */
+ pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+ }
+ start &= PAGE_MASK;
+ vma->vm_pgoff = off >> PAGE_SHIFT;
+ if (io_remap_page_range(vma->vm_start, off,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+
return 0;
}
--- linux-2.4.paul/drivers/video/valkyriefb.c Fri Aug 25 03:17:16 2000
+++ linux/drivers/video/valkyriefb.c Wed Sep 13 22:20:39 2000
@@ -128,6 +128,8 @@
struct fb_info *info);
static int valkyrie_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
+static int valkyrie_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma);
static int read_valkyrie_sense(struct fb_info_valkyrie *p);
static inline int valkyrie_vram_reqd(int video_mode, int color_mode);
@@ -152,6 +154,7 @@
fb_set_var: valkyrie_set_var,
fb_get_cmap: valkyrie_get_cmap,
fb_set_cmap: valkyrie_set_cmap,
+ fb_mmap: valkyrie_mmap,
};
static int valkyriefb_getcolreg(u_int regno, u_int *red, u_int *green,
@@ -269,6 +272,47 @@
return fb_set_cmap(cmap, kspc, valkyriefb_setcolreg, info);
}
fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
+ return 0;
+}
+
+/* Private mmap since we want to have a different caching on the framebuffer
+ * for valkyriefb.
+ * Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
+ */
+static int valkyrie_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct fb_ops *fb = info->fbops;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ unsigned long off, start;
+ u32 len;
+
+ fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
+ off = vma->vm_pgoff << PAGE_SHIFT;
+
+ /* frame buffer memory */
+ start = fix.smem_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.smem_len);
+ if (off >= len) {
+ /* memory mapped io */
+ off -= len;
+ fb->fb_get_var(&var, PROC_CONSOLE(info), info);
+ if (var.accel_flags)
+ return -EINVAL;
+ start = fix.mmio_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len);
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
+ } else {
+ /* framebuffer */
+ pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+ }
+ start &= PAGE_MASK;
+ vma->vm_pgoff = off >> PAGE_SHIFT;
+ if (io_remap_page_range(vma->vm_start, off,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+
return 0;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2)
2000-09-13 21:10 ` per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2) Michel Lanners
@ 2000-09-13 22:24 ` Martin Costabel
2000-09-14 5:46 ` Michel Lanners
0 siblings, 1 reply; 8+ messages in thread
From: Martin Costabel @ 2000-09-13 22:24 UTC (permalink / raw)
To: mlan; +Cc: linuxppc-dev
Michel Lanners wrote:
>
> Hi all,
>
> On 13 Sep, this message from mlan echoed through cyberspace:
> > Below is the per-fb mmap implementation
>
> Err.. nothing was below. Stupid /me... it's getting late.
>
> Anyway, here it is for both 2.2 and 2.4. Note that to compile on 2.2,
> you need my controlfb patch implementing mmap as well, since without it,
> this one won't compile (get it on sourceforge).
Tried it for valkyriefb: Doesn't work. It works in console mode, where
it actually feels like it is scrolling fast, but starting X gives an
immediate system freeze. I tried it twice, but now I'll go to bed.
> Have fun!
Not much fun in hard rebooting and watching 15 minutes of fsck.
--
Martin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2)
2000-09-13 22:24 ` Martin Costabel
@ 2000-09-14 5:46 ` Michel Lanners
2000-09-14 22:48 ` Martin Costabel
0 siblings, 1 reply; 8+ messages in thread
From: Michel Lanners @ 2000-09-14 5:46 UTC (permalink / raw)
To: costabel; +Cc: linuxppc-dev
On 14 Sep, this message from Martin Costabel echoed through cyberspace:
>> Anyway, here it is for both 2.2 and 2.4. Note that to compile on 2.2,
>> you need my controlfb patch implementing mmap as well, since without it,
>> this one won't compile (get it on sourceforge).
>
> Tried it for valkyriefb: Doesn't work. It works in console mode, where
> it actually feels like it is scrolling fast, but starting X gives an
> immediate system freeze. I tried it twice, but now I'll go to bed.
Sh....
>> Have fun!
>
> Not much fun in hard rebooting and watching 15 minutes of fsck.
Sorry about that.... hope you slept well nevertheless ;-)
Can you have a look and see what might be wrong? Ill do the same,
hopefully tonight, but no guarantee...
A quick look shows that valkyrie has a single memory region, with the
framebuffer, the registers and the colormap all within the same region.
That might blow up the logic within valkyrie_mmap() to defferentiate between
framebuffer and mmio.
Thanks
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art.
23, Rue Paul Henkes | Ask Questions. Make Mistakes.
L-1710 Luxembourg |
email mlan@cpu.lu |
http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2)
2000-09-14 5:46 ` Michel Lanners
@ 2000-09-14 22:48 ` Martin Costabel
2000-09-14 23:07 ` Martin Costabel
2000-09-15 8:57 ` Michel Dänzer
0 siblings, 2 replies; 8+ messages in thread
From: Martin Costabel @ 2000-09-14 22:48 UTC (permalink / raw)
To: mlan; +Cc: linuxppc-dev
Michel Lanners wrote:
> > Tried it for valkyriefb: Doesn't work. It works in console mode, where
> > it actually feels like it is scrolling fast, but starting X gives an
> > immediate system freeze. I tried it twice, but now I'll go to bed.
> Can you have a look and see what might be wrong? Ill do the same,
> hopefully tonight, but no guarantee...
I don't really understand these things (as usual), but from staring at
your code it seemed to me that inserting the following line might be a
good idea (this is for the 2.4.0 case; I haven't tried the 2.2.x patch,
but there a corresponding line is present):
--- drivers/video/valkyriefb.c~ Wed Sep 13 23:18:59 2000
+++ drivers/video/valkyriefb.c Thu Sep 14 23:58:12 2000
@@ -308,6 +308,7 @@
pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
}
start &= PAGE_MASK;
+ off += start;
vma->vm_pgoff = off >> PAGE_SHIFT;
if (io_remap_page_range(vma->vm_start, off,
vma->vm_end - vma->vm_start, vma->vm_page_prot))
In any case, it is working now. In fact, I don't see any difference
between the situation before and after the patch. For x11perf
--scroll500, I get exactly as before 36.2/sec for 1024x768 at 8bit. This
is with XFree68-4.0.1; used to be 13/sec with older X servers.
One funny thing: In X, my Alt keys don't work correctly ("ModeShift")
any more, they give "Alt_R" now. In the console, this is still OK. I
suppose this cannot come from the mmap stuff, so this must come from
some of the other changes in the bitkeeper tree in the last 2 days. I
didn't change anything else in my config.
--
Martin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2)
2000-09-14 22:48 ` Martin Costabel
@ 2000-09-14 23:07 ` Martin Costabel
2000-09-15 8:57 ` Michel Dänzer
1 sibling, 0 replies; 8+ messages in thread
From: Martin Costabel @ 2000-09-14 23:07 UTC (permalink / raw)
To: mlan, linuxppc-dev
Martin Costabel wrote:
> One funny thing: In X, my Alt keys don't work correctly ("ModeShift")
> any more, they give "Alt_R" now. In the console, this is still OK. I
> suppose this cannot come from the mmap stuff, so this must come from
> some of the other changes in the bitkeeper tree in the last 2 days. I
> didn't change anything else in my config.
Sorry for the false alarm, after restarting X all keys are working
normally. Out of crash fear, I had unmounted a few partitions before
starting X and remounted them afterwards. Somehow the keymap got
perturbed by this.
--
Martin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2)
2000-09-14 22:48 ` Martin Costabel
2000-09-14 23:07 ` Martin Costabel
@ 2000-09-15 8:57 ` Michel Dänzer
1 sibling, 0 replies; 8+ messages in thread
From: Michel Dänzer @ 2000-09-15 8:57 UTC (permalink / raw)
To: Martin Costabel; +Cc: mlan, linuxppc-dev
Martin Costabel wrote:
> In fact, I don't see any difference between the situation before and after
> the patch. For x11perf --scroll500, I get exactly as before 36.2/sec for
> 1024x768 at 8bit. This is with XFree68-4.0.1; used to be 13/sec with older X
> servers.
X 4.x has ShadowFB, which shadows the framebufer in RAM and avoids reads from
VRAM.
I think Michel (the other one ;) either uses X 3.3.x or no ShadowFB.
Michel
PS: My Rage128 Mobility gives me 578.0/sec :)
--
Earthling Michel Dänzer (MrCooper) \ CS student and free software enthusiast
Debian GNU/Linux (powerpc,i386) user \ member of XFree86 and The DRI Project
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: per-fb mmap for platinumfb and valkyriefb in 2.4
2000-09-13 20:36 per-fb mmap for platinumfb and valkyriefb in 2.4 Michel Lanners
2000-09-13 21:10 ` per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2) Michel Lanners
@ 2000-11-19 11:04 ` Michel Lanners
1 sibling, 0 replies; 8+ messages in thread
From: Michel Lanners @ 2000-11-19 11:04 UTC (permalink / raw)
To: linuxppc-dev
[-- Attachment #1: Type: TEXT/plain, Size: 717 bytes --]
Hi all,
I finally came 'round to making a fixed version of my patches available.
It is attached below, and also available on sourceforge
(http://sourceforge.net/patch/?func=detailpatch&patch_id=101500&group_id=8234)
This is for 2.4 only. If anyone wants to go ahead and give it a try; let
me know how it works out, and also whether it improves anything ;-)
Cheers
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art.
23, Rue Paul Henkes | Ask Questions. Make Mistakes.
L-1710 Luxembourg |
email mlan@cpu.lu |
http://www.cpu.lu/~mlan | Learn Always. "
[-- Attachment #2: 2.4-powermacfb.diff --]
[-- Type: TEXT/plain, Size: 4251 bytes --]
--- linux-2.4.paul/drivers/video/platinumfb.c Sat Aug 5 09:40:52 2000
+++ linux/drivers/video/platinumfb.c Wed Sep 13 22:06:57 2000
@@ -111,6 +111,8 @@
struct fb_info *info);
static int platinum_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
+static int platinum_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma);
/*
@@ -163,6 +165,7 @@
fb_set_var: platinum_set_var,
fb_get_cmap: platinum_get_cmap,
fb_set_cmap: platinum_set_cmap,
+ fb_mmap: platinum_mmap,
};
static int platinum_get_fix(struct fb_fix_screeninfo *fix, int con,
@@ -326,6 +329,50 @@
return fb_set_cmap(cmap, kspc, platinum_setcolreg, info);
else
fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
+ return 0;
+}
+
+/* Private mmap since we want to have a different caching on the framebuffer
+ * for platinumfb.
+ * Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
+ */
+static int platinum_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct fb_ops *fb = info->fbops;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ unsigned long off, start;
+ u32 len;
+
+ fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
+ off = vma->vm_pgoff << PAGE_SHIFT;
+
+ /* frame buffer memory */
+ start = fix.smem_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.smem_len);
+ if (off >= len) {
+ /* memory mapped io */
+ off -= len;
+ fb->fb_get_var(&var, PROC_CONSOLE(info), info);
+ if (var.accel_flags)
+ return -EINVAL;
+ start = fix.mmio_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len);
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
+ } else {
+ /* framebuffer */
+ pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+ }
+ start &= PAGE_MASK;
+ if ((vma->vm_end - vma->vm_start + off) > len)
+ return -EINVAL;
+ off += start;
+ vma->vm_pgoff = off >> PAGE_SHIFT;
+ if (io_remap_page_range(vma->vm_start, off,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+
return 0;
}
--- linux-2.4.paul/drivers/video/valkyriefb.c Fri Aug 25 03:17:16 2000
+++ linux/drivers/video/valkyriefb.c Wed Sep 13 22:20:39 2000
@@ -128,6 +128,8 @@
struct fb_info *info);
static int valkyrie_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
+static int valkyrie_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma);
static int read_valkyrie_sense(struct fb_info_valkyrie *p);
static inline int valkyrie_vram_reqd(int video_mode, int color_mode);
@@ -152,6 +154,7 @@
fb_set_var: valkyrie_set_var,
fb_get_cmap: valkyrie_get_cmap,
fb_set_cmap: valkyrie_set_cmap,
+ fb_mmap: valkyrie_mmap,
};
static int valkyriefb_getcolreg(u_int regno, u_int *red, u_int *green,
@@ -269,6 +272,50 @@
return fb_set_cmap(cmap, kspc, valkyriefb_setcolreg, info);
}
fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
+ return 0;
+}
+
+/* Private mmap since we want to have a different caching on the framebuffer
+ * for valkyriefb.
+ * Note there's no locking in here; it's done in fb_mmap() in fbmem.c.
+ */
+static int valkyrie_mmap(struct fb_info *info, struct file *file,
+ struct vm_area_struct *vma)
+{
+ struct fb_ops *fb = info->fbops;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ unsigned long off, start;
+ u32 len;
+
+ fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
+ off = vma->vm_pgoff << PAGE_SHIFT;
+
+ /* frame buffer memory */
+ start = fix.smem_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.smem_len);
+ if (off >= len) {
+ /* memory mapped io */
+ off -= len;
+ fb->fb_get_var(&var, PROC_CONSOLE(info), info);
+ if (var.accel_flags)
+ return -EINVAL;
+ start = fix.mmio_start;
+ len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len);
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED;
+ } else {
+ /* framebuffer */
+ pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU;
+ }
+ start &= PAGE_MASK;
+ if ((vma->vm_end - vma->vm_start + off) > len)
+ return -EINVAL;
+ off += start;
+ vma->vm_pgoff = off >> PAGE_SHIFT;
+ if (io_remap_page_range(vma->vm_start, off,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+
return 0;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2000-11-19 11:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-09-13 20:36 per-fb mmap for platinumfb and valkyriefb in 2.4 Michel Lanners
2000-09-13 21:10 ` per-fb mmap for platinumfb and valkyriefb in 2.4 (and 2.2) Michel Lanners
2000-09-13 22:24 ` Martin Costabel
2000-09-14 5:46 ` Michel Lanners
2000-09-14 22:48 ` Martin Costabel
2000-09-14 23:07 ` Martin Costabel
2000-09-15 8:57 ` Michel Dänzer
2000-11-19 11:04 ` per-fb mmap for platinumfb and valkyriefb in 2.4 Michel Lanners
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).