OpenCores
URL https://opencores.org/ocsvn/axi_vga_fb/axi_vga_fb/trunk

Subversion Repositories axi_vga_fb

[/] [axi_vga_fb/] [trunk/] [v586fb.c] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ultro
/*
2
 * linux/drivers/video/v586fb.c -- v586 frame buffer device
3
 *
4
 * Copyright (C) 2017
5
 *
6
 *      This driver is derived from the q40 one done by :
7
 *      Richard Zidlicky <rz@linux-m68k.org>
8
 *
9
 *  This file is subject to the terms and conditions of the GNU General Public
10
 *  License. See the file COPYING in the main directory of this archive for
11
 *  more details.
12
 */
13
 
14
#include <linux/kernel.h>
15
#include <linux/errno.h>
16
#include <linux/string.h>
17
#include <linux/mm.h>
18
#include <linux/delay.h>
19
#include <linux/interrupt.h>
20
#include <linux/platform_device.h>
21
 
22
#include <asm/uaccess.h>
23
#include <asm/setup.h>
24
#include <linux/fb.h>
25
#include <linux/module.h>
26
#include <asm/pgtable.h>
27
 
28
#define v586_PHYS_SCREEN_ADDR 0x000A0000
29
#define v586_PHYS_SCREEN_SIZE 0x00020000
30
/* static void *videomemory; */
31
static u_long videomemorysize = v586_PHYS_SCREEN_SIZE;
32
module_param(videomemorysize, ulong, 0);
33
 
34
static struct fb_fix_screeninfo v586fb_fix = {
35
        .id             = "v586fb",
36
        .smem_len       = 640*200,
37
        .type           = FB_TYPE_PACKED_PIXELS,
38
        .visual         = FB_VISUAL_TRUECOLOR,
39
        .line_length    = 640,
40
        .accel          = FB_ACCEL_NONE,
41
};
42
 
43
static struct fb_var_screeninfo v586fb_var = {
44
        .xres           = 640,
45
        .yres           = 200,
46
        .xres_virtual   = 640,
47
        .yres_virtual   = 200,
48
        .bits_per_pixel = 8,
49
        .red            = {0, 3, 0},
50
        .green          = {3, 3, 0},
51
        .blue           = {6, 2, 0},
52
        .activate       = FB_ACTIVATE_NOW,
53
        .height         = 230,
54
        .width          = 300,
55
        .vmode          = FB_VMODE_NONINTERLACED,
56
};
57
 
58
static struct fb_ops v586fb_ops = {
59
        .owner          = THIS_MODULE,
60
        .fb_fillrect    = cfb_fillrect,
61
        .fb_copyarea    = cfb_copyarea,
62
        .fb_imageblit   = cfb_imageblit,
63
};
64
 
65
static int v586fb_probe(struct platform_device *dev)
66
{
67
        struct fb_info *info;
68
 
69
        v586fb_fix.smem_start = v586_PHYS_SCREEN_ADDR;
70
 
71
        info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
72
        if (!info)
73
                return -ENOMEM;
74
 
75
        if (!request_mem_region(v586_PHYS_SCREEN_ADDR, v586_PHYS_SCREEN_SIZE,   "v586fb")) {
76
                printk(KERN_INFO"v586fb: cannot get framebuffer\n");
77
        }
78
 
79
        info->var = v586fb_var;
80
        info->fix = v586fb_fix;
81
        info->fbops = &v586fb_ops;
82
        info->flags = FBINFO_DEFAULT;  /* not as module for now */
83
        info->par = NULL;
84
        info->screen_base = ioremap(v586_PHYS_SCREEN_ADDR,videomemorysize); /* (char *) v586fb_fix.smem_start; */
85
 
86
        if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
87
                framebuffer_release(info);
88
                return -ENOMEM;
89
        }
90
 
91
        if (register_framebuffer(info) < 0) {
92
                printk(KERN_ERR "Unable to register v586fb frame buffer\n");
93
                fb_dealloc_cmap(&info->cmap);
94
                framebuffer_release(info);
95
                return -EINVAL;
96
        }
97
 
98
        fb_info(info, "v586fb frame buffer alive and kicking !\n");
99
        return 0;
100
}
101
 
102
static struct platform_driver v586fb_driver = {
103
        .probe  = v586fb_probe,
104
        .driver = {
105
                .name   = "v586fb",
106
        },
107
};
108
 
109
static struct platform_device v586fb_device = {
110
        .name   = "v586fb",
111
};
112
 
113
int __init v586fb_init(void)
114
{
115
        int ret = 0;
116
 
117
        if (fb_get_options("v586fb", NULL))
118
                return -ENODEV;
119
 
120
        ret = platform_driver_register(&v586fb_driver);
121
 
122
        if (!ret) {
123
                ret = platform_device_register(&v586fb_device);
124
                if (ret)
125
                        platform_driver_unregister(&v586fb_driver);
126
        }
127
        return ret;
128
}
129
 
130
module_init(v586fb_init);
131
MODULE_LICENSE("GPL");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.