1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
*/
#include <common.h>
#include <driver.h>
#include <init.h>
#include <malloc.h>
#include <mach/linux.h>
#include <fb.h>
#include <errno.h>
#include <gui/graphic_utils.h>
#define to_mask(color) GENMASK(color.length - 1, color.offset)
static void sdlfb_enable(struct fb_info *info)
{
struct sdl_fb_info sdl_info = {
.screen_base = info->screen_base,
.xres = info->xres, .yres = info->yres, .bpp = info->bits_per_pixel,
.rmask = to_mask(info->red),
.gmask = to_mask(info->green),
.bmask = to_mask(info->blue),
.amask = to_mask(info->transp),
};
sdl_video_open(&sdl_info);
}
static void sdlfb_disable(struct fb_info *info)
{
sdl_video_close();
}
static struct fb_ops sdlfb_ops = {
.fb_enable = sdlfb_enable,
.fb_disable = sdlfb_disable,
};
static int sdlfb_probe(struct device *dev)
{
struct fb_info *fb;
int ret = -EIO;
if (!dev->platform_data)
return -EIO;
fb = xzalloc(sizeof(*fb));
fb->modes.modes = fb->mode = dev->platform_data;
fb->modes.num_modes = 1;
fb->xres = fb->mode->xres;
fb->yres = fb->mode->yres;
fb->bits_per_pixel = 32;
fb->transp.length = 8;
fb->red.length = 8;
fb->green.length = 8;
fb->blue.length = 8;
fb->transp.offset = 24;
fb->red.offset = 16;
fb->green.offset = 8;
fb->blue.offset = 0;
fb->priv = fb;
fb->fbops = &sdlfb_ops;
fb->dev.parent = dev;
fb->screen_base = xzalloc(fb->xres * fb->yres *
fb->bits_per_pixel >> 3);
/* add runtime hardware info */
dev->priv = fb;
ret = register_framebuffer(fb);
if (!ret)
return 0;
kfree(fb->screen_base);
kfree(fb);
return ret;
}
static void sdlfb_remove(struct device *dev)
{
struct fb_info *fb = dev->priv;
kfree(fb->screen_base);
kfree(fb);
}
static struct driver sdlfb_driver = {
.name = "sdlfb",
.probe = sdlfb_probe,
.remove = sdlfb_remove,
};
device_platform_driver(sdlfb_driver);
|