|
From: James S. <jsi...@tr...> - 2002-05-02 22:09:11
|
Here you go. Something to test it with. I like so see if anyone else is
also having this problem.
/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern char *optarg;
extern int optind, opterr, optopt;
#include <errno.h>
int errno;
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <setjmp.h>
#include <sys/mman.h>
#include <asm/page.h>
#include <asm/byteorder.h>
#include <asm/bitops.h>
#include <linux/fb.h>
static unsigned char fontdata_8x16[4096] = {
/* 65 0x41 'A' */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x10, /* 00010000 */
0x38, /* 00111000 */
0x6c, /* 01101100 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xfe, /* 11111110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0xc6, /* 11000110 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
0x00, /* 00000000 */
};
int
main(int argc, char **argv)
{
unsigned long mask, eorx;
int ppw, i, j, k, l;
unsigned long fgx, bgx, fgcolor = 0xFFFFFFFF, bgcolor = 0;
unsigned long *dst, *src = NULL;
struct fb_var_screeninfo fb_var;
struct fb_fix_screeninfo fb_fix;
int fb_mem_offset = 0, fbd, r;
char fbdevice[256];
int height, width;
unsigned long *dst1, *dst2, *src1;
int fbnum = 0;
int linesize;
long tmp;
fprintf(stderr, "Opening /dev/fb%d\n", fbnum);
sprintf(fbdevice, "/dev/fb%d", fbnum);
fbd = open(fbdevice, O_RDWR);
if (fbd < 0)
{
fprintf(stderr, "Couldn't open /dev/fb%d; errno: %d (%s)\n", fbnum, errno, strerror(errno));
exit(1);
}
r = ioctl(fbd, FBIOGET_VSCREENINFO, &fb_var);
if (r < 0)
{
fprintf(stderr, "IOCTL FBIOGET_VSCREENINFO error: %d errno: %d (%s)\n", r, errno, strerror(errno));
exit(1);
}
r = ioctl(fbd, FBIOGET_FSCREENINFO, &fb_fix);
if (r < 0)
{
fprintf(stderr, "IOCTL FBIOGET_FSCREENINFO error: %d errno: %d (%s)\n", r, errno, strerror(errno));
exit(1);
}
tmp = -1 >> (32 - fb_var.bits_per_pixel);
linesize = fb_fix.line_length;
fprintf(stderr, "Screen depth is %d\n", fb_var.bits_per_pixel);
/* map all FB memory */
fb_mem_offset = (unsigned long)(fb_fix.smem_start) & (~PAGE_MASK);
dst1 = mmap(NULL,fb_fix.smem_len+fb_mem_offset,PROT_WRITE,MAP_SHARED,fbd,0);
if (!dst1) {
fprintf(stderr, "MMap of /dev/fb%d failed\n", fbnum);
exit(1);
}
dst2 = mmap(fb_fix.mmio_start, fb_fix.mmio_len, PROT_WRITE,MAP_SHARED, fbd, 0);
if (!dst2) {
fprintf(stderr, "MMap of MMIO of /dev/fb%d failed\n", fbnum);
exit(1);
}
return(0);
}
|
|
From: Ani J. <aj...@sh...> - 2002-05-02 23:52:25
|
Well, I didn't try running this code, but its looks from your code below
that your mmap() is wrong. The first argument in mmap is rarely used and
typically a hint. You should be using the mmio address (fb_fix.mmio_start)
in the last argument instead of the first, and have the first agrument 0.
The last argument is the offset (in this case the physical offset in
memory).
After further looking at your code, it seems you are mmaping /dev/fb for
your MMIO. Is this even possible? Shouldn't you be mapping /dev/mem?
Has someone changed the fbdev layer so you can mmap mmio via /dev/fb?
ani
On Thu, 2 May 2002, James Simmons wrote:
> dst2 = mmap(fb_fix.mmio_start, fb_fix.mmio_len, PROT_WRITE,MAP_SHARED, fbd, 0);
> if (!dst2) {
> fprintf(stderr, "MMap of MMIO of /dev/fb%d failed\n", fbnum);
> exit(1);
> }
|
|
From: Antonino D. <ad...@po...> - 2002-05-03 00:59:51
|
On Fri, 2002-05-03 at 08:03, Ani Joshi wrote:
>
> Well, I didn't try running this code, but its looks from your code below
> that your mmap() is wrong. The first argument in mmap is rarely used and
> typically a hint. You should be using the mmio address (fb_fix.mmio_start)
> in the last argument instead of the first, and have the first agrument 0.
> The last argument is the offset (in this case the physical offset in
> memory).
>
> After further looking at your code, it seems you are mmaping /dev/fb for
> your MMIO. Is this even possible? Shouldn't you be mapping /dev/mem?
> Has someone changed the fbdev layer so you can mmap mmio via /dev/fb?
>
>
DirectFB mmaps mmio via /dev/fb. For the first argument (length), you
have to use a value <= fix.mmio_len, and for the last argument (offset),
you have to use a value >= fix.smem_len. At (offset == fix.smem_len),
the actual mmio offset mmaped is at 0.
By the way, may have to generally use NULL for the first argument
(start).
Tony
> ani
>
>
> On Thu, 2 May 2002, James Simmons wrote:
>
> > dst2 = mmap(fb_fix.mmio_start, fb_fix.mmio_len, PROT_WRITE,MAP_SHARED, fbd, 0);
> > if (!dst2) {
> > fprintf(stderr, "MMap of MMIO of /dev/fb%d failed\n", fbnum);
> > exit(1);
> > }
>
>
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: ban...@so...
> _______________________________________________
> Linux-fbdev-devel mailing list
> Lin...@li...
> https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
|
|
From: Antonino D. <ad...@po...> - 2002-05-03 01:29:59
|
On Thu, 2002-05-02 at 09:04, Antonino Daplas wrote: > DirectFB mmaps mmio via /dev/fb. For the first argument (length), you > have to use a value <= fix.mmio_len, and for the last argument (offset), Oops, I meant ... ... For the second argument (length), you ... Tony |
|
From: Geert U. <ge...@li...> - 2002-05-03 08:39:29
|
On Thu, 2 May 2002, Ani Joshi wrote:
> After further looking at your code, it seems you are mmaping /dev/fb for
> your MMIO. Is this even possible? Shouldn't you be mapping /dev/mem?
> Has someone changed the fbdev layer so you can mmap mmio via /dev/fb?
That change was made many years ago :-)
You have the frame buffer at offset 0...fix.smem_len-1, and the MMIO at
fix.smem_len...fix.smem_len+fix.mmio_len-1.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@li...
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
|
|
From: Ani J. <aj...@sh...> - 2002-05-03 13:41:02
|
Ah, it seems I never paid much attention to mmio and /dev/fb. So is this
the suggested use rather then /dev/mem?
ani
On Fri, 3 May 2002, Geert Uytterhoeven wrote:
> On Thu, 2 May 2002, Ani Joshi wrote:
> > After further looking at your code, it seems you are mmaping /dev/fb for
> > your MMIO. Is this even possible? Shouldn't you be mapping /dev/mem?
> > Has someone changed the fbdev layer so you can mmap mmio via /dev/fb?
>
> That change was made many years ago :-)
>
> You have the frame buffer at offset 0...fix.smem_len-1, and the MMIO at
> fix.smem_len...fix.smem_len+fix.mmio_len-1.
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@li...
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
|
|
From: Geert U. <ge...@li...> - 2002-05-03 13:55:46
|
On Fri, 3 May 2002, Ani Joshi wrote:
> Ah, it seems I never paid much attention to mmio and /dev/fb. So is this
> the suggested use rather then /dev/mem?
Yes.
It also means that the fbdev layer can keep track off who is using its MMIO.
Note that you cannot (error -EINVAL) mmap MMIO if var.accel_flags is set, to
prevent conflicts between accel engine accesses between user space and the
fbdev.
> On Fri, 3 May 2002, Geert Uytterhoeven wrote:
> > On Thu, 2 May 2002, Ani Joshi wrote:
> > > After further looking at your code, it seems you are mmaping /dev/fb for
> > > your MMIO. Is this even possible? Shouldn't you be mapping /dev/mem?
> > > Has someone changed the fbdev layer so you can mmap mmio via /dev/fb?
> >
> > That change was made many years ago :-)
> >
> > You have the frame buffer at offset 0...fix.smem_len-1, and the MMIO at
> > fix.smem_len...fix.smem_len+fix.mmio_len-1.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@li...
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
|