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

Subversion Repositories axi_vga_fb

[/] [axi_vga_fb/] [trunk/] [v586fb_rgb656.c] - Blame information for rev 5

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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