xref: /linux/include/asm-generic/video.h (revision 2697b79a469b68e3ad3640f55284359c1396278d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __ASM_GENERIC_VIDEO_H_
4 #define __ASM_GENERIC_VIDEO_H_
5 
6 /*
7  * Only include this header file from your architecture's <asm/fb.h>.
8  */
9 
10 #include <linux/io.h>
11 #include <linux/mm_types.h>
12 #include <linux/pgtable.h>
13 #include <linux/types.h>
14 
15 struct device;
16 
17 #ifndef pgprot_framebuffer
18 #define pgprot_framebuffer pgprot_framebuffer
19 static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
20 					  unsigned long vm_start, unsigned long vm_end,
21 					  unsigned long offset)
22 {
23 	return pgprot_writecombine(prot);
24 }
25 #endif
26 
27 #ifndef video_is_primary_device
28 #define video_is_primary_device video_is_primary_device
29 static inline bool video_is_primary_device(struct device *dev)
30 {
31 	return false;
32 }
33 #endif
34 
35 /*
36  * I/O helpers for the framebuffer. Prefer these functions over their
37  * regular counterparts. The regular I/O functions provide in-order
38  * access and swap bytes to/from little-endian ordering. Neither is
39  * required for framebuffers. Instead, the helpers read and write
40  * raw framebuffer data. Independent operations can be reordered for
41  * improved performance.
42  */
43 
44 #ifndef fb_readb
45 static inline u8 fb_readb(const volatile void __iomem *addr)
46 {
47 	return __raw_readb(addr);
48 }
49 #define fb_readb fb_readb
50 #endif
51 
52 #ifndef fb_readw
53 static inline u16 fb_readw(const volatile void __iomem *addr)
54 {
55 	return __raw_readw(addr);
56 }
57 #define fb_readw fb_readw
58 #endif
59 
60 #ifndef fb_readl
61 static inline u32 fb_readl(const volatile void __iomem *addr)
62 {
63 	return __raw_readl(addr);
64 }
65 #define fb_readl fb_readl
66 #endif
67 
68 #ifndef fb_readq
69 #if defined(__raw_readq)
70 static inline u64 fb_readq(const volatile void __iomem *addr)
71 {
72 	return __raw_readq(addr);
73 }
74 #define fb_readq fb_readq
75 #endif
76 #endif
77 
78 #ifndef fb_writeb
79 static inline void fb_writeb(u8 b, volatile void __iomem *addr)
80 {
81 	__raw_writeb(b, addr);
82 }
83 #define fb_writeb fb_writeb
84 #endif
85 
86 #ifndef fb_writew
87 static inline void fb_writew(u16 b, volatile void __iomem *addr)
88 {
89 	__raw_writew(b, addr);
90 }
91 #define fb_writew fb_writew
92 #endif
93 
94 #ifndef fb_writel
95 static inline void fb_writel(u32 b, volatile void __iomem *addr)
96 {
97 	__raw_writel(b, addr);
98 }
99 #define fb_writel fb_writel
100 #endif
101 
102 #ifndef fb_writeq
103 #if defined(__raw_writeq)
104 static inline void fb_writeq(u64 b, volatile void __iomem *addr)
105 {
106 	__raw_writeq(b, addr);
107 }
108 #define fb_writeq fb_writeq
109 #endif
110 #endif
111 
112 #ifndef fb_memcpy_fromio
113 static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
114 {
115 	memcpy_fromio(to, from, n);
116 }
117 #define fb_memcpy_fromio fb_memcpy_fromio
118 #endif
119 
120 #ifndef fb_memcpy_toio
121 static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
122 {
123 	memcpy_toio(to, from, n);
124 }
125 #define fb_memcpy_toio fb_memcpy_toio
126 #endif
127 
128 #ifndef fb_memset
129 static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
130 {
131 	memset_io(addr, c, n);
132 }
133 #define fb_memset fb_memset_io
134 #endif
135 
136 #endif /* __ASM_GENERIC_VIDEO_H_ */
137