1/* SPDX-License-Identifier: GPL-2.0 */
2/* sbuslib.h: SBUS fb helper library interfaces */
3#ifndef _SBUSLIB_H
4#define _SBUSLIB_H
5
6struct device_node;
7struct fb_info;
8struct fb_var_screeninfo;
9struct vm_area_struct;
10
11struct sbus_mmap_map {
12	unsigned long voff;
13	unsigned long poff;
14	unsigned long size;
15};
16
17#define SBUS_MMAP_FBSIZE(n) (-n)
18#define SBUS_MMAP_EMPTY	0x80000000
19
20extern void sbusfb_fill_var(struct fb_var_screeninfo *var,
21			    struct device_node *dp, int bpp);
22extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
23			      unsigned long physbase, unsigned long fbsize,
24			      unsigned long iospace,
25			      struct vm_area_struct *vma);
26int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
27			struct fb_info *info,
28			int type, int fb_depth, unsigned long fb_size);
29int sbusfb_compat_ioctl(struct fb_info *info, unsigned int cmd,
30			unsigned long arg);
31
32/*
33 * Initialize struct fb_ops for SBUS I/O.
34 */
35
36#define __FB_DEFAULT_SBUS_OPS_RDWR(__prefix) \
37	.fb_read	= fb_io_read, \
38	.fb_write	= fb_io_write
39
40#define __FB_DEFAULT_SBUS_OPS_DRAW(__prefix) \
41	.fb_fillrect	= cfb_fillrect, \
42	.fb_copyarea	= cfb_copyarea, \
43	.fb_imageblit	= cfb_imageblit
44
45#ifdef CONFIG_COMPAT
46#define __FB_DEFAULT_SBUS_OPS_IOCTL(__prefix) \
47	.fb_ioctl		= __prefix ## _sbusfb_ioctl, \
48	.fb_compat_ioctl	= sbusfb_compat_ioctl
49#else
50#define __FB_DEFAULT_SBUS_OPS_IOCTL(__prefix) \
51	.fb_ioctl	= __prefix ## _sbusfb_ioctl
52#endif
53
54#define __FB_DEFAULT_SBUS_OPS_MMAP(__prefix) \
55	.fb_mmap	= __prefix ## _sbusfb_mmap
56
57#define FB_DEFAULT_SBUS_OPS(__prefix) \
58	__FB_DEFAULT_SBUS_OPS_RDWR(__prefix), \
59	__FB_DEFAULT_SBUS_OPS_DRAW(__prefix), \
60	__FB_DEFAULT_SBUS_OPS_IOCTL(__prefix), \
61	__FB_DEFAULT_SBUS_OPS_MMAP(__prefix)
62
63#endif /* _SBUSLIB_H */
64