Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6295 serge 1
/*
2
 * fbsysfs.c - framebuffer device class and attributes
3
 *
4
 * Copyright (c) 2004 James Simmons 
5
 *
6
 *	This program is free software you can redistribute it and/or
7
 *	modify it under the terms of the GNU General Public License
8
 *	as published by the Free Software Foundation; either version
9
 *	2 of the License, or (at your option) any later version.
10
 */
11
 
12
/*
13
 * Note:  currently there's only stubs for framebuffer_alloc and
14
 * framebuffer_release here.  The reson for that is that until all drivers
15
 * are converted to use it a sysfsification will open OOPSable races.
16
 */
17
 
18
#include 
19
#include 
20
#include 
21
#include 
22
 
23
#define FB_SYSFS_FLAG_ATTR 1
24
 
25
/**
26
 * framebuffer_alloc - creates a new frame buffer info structure
27
 *
28
 * @size: size of driver private data, can be zero
29
 * @dev: pointer to the device for this fb, this can be NULL
30
 *
31
 * Creates a new frame buffer info structure. Also reserves @size bytes
32
 * for driver private data (info->par). info->par (if any) will be
33
 * aligned to sizeof(long).
34
 *
35
 * Returns the new structure, or NULL if an error occurred.
36
 *
37
 */
38
struct fb_info *framebuffer_alloc(size_t size, struct device *dev)
39
{
40
#define BYTES_PER_LONG (BITS_PER_LONG/8)
41
#define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
42
	int fb_info_size = sizeof(struct fb_info);
43
	struct fb_info *info;
44
	char *p;
45
 
46
	if (size)
47
		fb_info_size += PADDING;
48
 
49
	p = kzalloc(fb_info_size + size, GFP_KERNEL);
50
 
51
	if (!p)
52
		return NULL;
53
 
54
	info = (struct fb_info *) p;
55
 
56
	if (size)
57
		info->par = p + fb_info_size;
58
 
59
	info->device = dev;
60
 
61
#ifdef CONFIG_FB_BACKLIGHT
62
	mutex_init(&info->bl_curve_mutex);
63
#endif
64
 
65
	return info;
66
#undef PADDING
67
#undef BYTES_PER_LONG
68
}
69
EXPORT_SYMBOL(framebuffer_alloc);
70
 
71
/**
72
 * framebuffer_release - marks the structure available for freeing
73
 *
74
 * @info: frame buffer info structure
75
 *
76
 * Drop the reference count of the device embedded in the
77
 * framebuffer info structure.
78
 *
79
 */
80
void framebuffer_release(struct fb_info *info)
81
{
82
	if (!info)
83
		return;
84
	kfree(info->apertures);
85
	kfree(info);
86
}
87
EXPORT_SYMBOL(framebuffer_release);