1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _FB_INTERNAL_H
4 #define _FB_INTERNAL_H
5 
6 #include <linux/device.h>
7 #include <linux/fb.h>
8 #include <linux/mutex.h>
9 
10 /* fb_devfs.c */
11 #if defined(CONFIG_FB_DEVICE)
12 int fb_register_chrdev(void);
13 void fb_unregister_chrdev(void);
14 #else
fb_register_chrdev(void)15 static inline int fb_register_chrdev(void)
16 {
17 	return 0;
18 }
fb_unregister_chrdev(void)19 static inline void fb_unregister_chrdev(void)
20 { }
21 #endif
22 
23 /* fbmem.c */
24 extern struct class *fb_class;
25 extern struct mutex registration_lock;
26 extern struct fb_info *registered_fb[FB_MAX];
27 extern int num_registered_fb;
28 struct fb_info *get_fb_info(unsigned int idx);
29 void put_fb_info(struct fb_info *fb_info);
30 
31 /* fb_procfs.c */
32 #if defined(CONFIG_FB_DEVICE)
33 int fb_init_procfs(void);
34 void fb_cleanup_procfs(void);
35 #else
fb_init_procfs(void)36 static inline int fb_init_procfs(void)
37 {
38 	return 0;
39 }
fb_cleanup_procfs(void)40 static inline void fb_cleanup_procfs(void)
41 { }
42 #endif
43 
44 /* fbsysfs.c */
45 #if defined(CONFIG_FB_DEVICE)
46 int fb_device_create(struct fb_info *fb_info);
47 void fb_device_destroy(struct fb_info *fb_info);
48 #else
fb_device_create(struct fb_info * fb_info)49 static inline int fb_device_create(struct fb_info *fb_info)
50 {
51 	/*
52 	 * Acquire a reference on the parent device to avoid
53 	 * unplug operations behind our back. With the fbdev
54 	 * device enabled, this is performed within register_device().
55 	 */
56 	get_device(fb_info->device);
57 
58 	return 0;
59 }
fb_device_destroy(struct fb_info * fb_info)60 static inline void fb_device_destroy(struct fb_info *fb_info)
61 {
62 	/* Undo the get_device() from fb_device_create() */
63 	put_device(fb_info->device);
64 }
65 #endif
66 
67 #endif
68