1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (c) 2006-2009 Red Hat Inc.
3*4882a593Smuzhiyun * Copyright (c) 2006-2008 Intel Corporation
4*4882a593Smuzhiyun * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * DRM framebuffer helper functions
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * Permission to use, copy, modify, distribute, and sell this software and its
9*4882a593Smuzhiyun * documentation for any purpose is hereby granted without fee, provided that
10*4882a593Smuzhiyun * the above copyright notice appear in all copies and that both that copyright
11*4882a593Smuzhiyun * notice and this permission notice appear in supporting documentation, and
12*4882a593Smuzhiyun * that the name of the copyright holders not be used in advertising or
13*4882a593Smuzhiyun * publicity pertaining to distribution of the software without specific,
14*4882a593Smuzhiyun * written prior permission. The copyright holders make no representations
15*4882a593Smuzhiyun * about the suitability of this software for any purpose. It is provided "as
16*4882a593Smuzhiyun * is" without express or implied warranty.
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19*4882a593Smuzhiyun * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20*4882a593Smuzhiyun * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21*4882a593Smuzhiyun * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22*4882a593Smuzhiyun * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23*4882a593Smuzhiyun * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24*4882a593Smuzhiyun * OF THIS SOFTWARE.
25*4882a593Smuzhiyun *
26*4882a593Smuzhiyun * Authors:
27*4882a593Smuzhiyun * Dave Airlie <airlied@linux.ie>
28*4882a593Smuzhiyun * Jesse Barnes <jesse.barnes@intel.com>
29*4882a593Smuzhiyun */
30*4882a593Smuzhiyun #ifndef DRM_FB_HELPER_H
31*4882a593Smuzhiyun #define DRM_FB_HELPER_H
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun struct drm_fb_helper;
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun #include <drm/drm_client.h>
36*4882a593Smuzhiyun #include <drm/drm_crtc.h>
37*4882a593Smuzhiyun #include <drm/drm_device.h>
38*4882a593Smuzhiyun #include <linux/kgdb.h>
39*4882a593Smuzhiyun #include <linux/vgaarb.h>
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun enum mode_set_atomic {
42*4882a593Smuzhiyun LEAVE_ATOMIC_MODE_SET,
43*4882a593Smuzhiyun ENTER_ATOMIC_MODE_SET,
44*4882a593Smuzhiyun };
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun /**
47*4882a593Smuzhiyun * struct drm_fb_helper_surface_size - describes fbdev size and scanout surface size
48*4882a593Smuzhiyun * @fb_width: fbdev width
49*4882a593Smuzhiyun * @fb_height: fbdev height
50*4882a593Smuzhiyun * @surface_width: scanout buffer width
51*4882a593Smuzhiyun * @surface_height: scanout buffer height
52*4882a593Smuzhiyun * @surface_bpp: scanout buffer bpp
53*4882a593Smuzhiyun * @surface_depth: scanout buffer depth
54*4882a593Smuzhiyun *
55*4882a593Smuzhiyun * Note that the scanout surface width/height may be larger than the fbdev
56*4882a593Smuzhiyun * width/height. In case of multiple displays, the scanout surface is sized
57*4882a593Smuzhiyun * according to the largest width/height (so it is large enough for all CRTCs
58*4882a593Smuzhiyun * to scanout). But the fbdev width/height is sized to the minimum width/
59*4882a593Smuzhiyun * height of all the displays. This ensures that fbcon fits on the smallest
60*4882a593Smuzhiyun * of the attached displays. fb_width/fb_height is used by
61*4882a593Smuzhiyun * drm_fb_helper_fill_info() to fill out the &fb_info.var structure.
62*4882a593Smuzhiyun */
63*4882a593Smuzhiyun struct drm_fb_helper_surface_size {
64*4882a593Smuzhiyun u32 fb_width;
65*4882a593Smuzhiyun u32 fb_height;
66*4882a593Smuzhiyun u32 surface_width;
67*4882a593Smuzhiyun u32 surface_height;
68*4882a593Smuzhiyun u32 surface_bpp;
69*4882a593Smuzhiyun u32 surface_depth;
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun /**
73*4882a593Smuzhiyun * struct drm_fb_helper_funcs - driver callbacks for the fbdev emulation library
74*4882a593Smuzhiyun *
75*4882a593Smuzhiyun * Driver callbacks used by the fbdev emulation helper library.
76*4882a593Smuzhiyun */
77*4882a593Smuzhiyun struct drm_fb_helper_funcs {
78*4882a593Smuzhiyun /**
79*4882a593Smuzhiyun * @fb_probe:
80*4882a593Smuzhiyun *
81*4882a593Smuzhiyun * Driver callback to allocate and initialize the fbdev info structure.
82*4882a593Smuzhiyun * Furthermore it also needs to allocate the DRM framebuffer used to
83*4882a593Smuzhiyun * back the fbdev.
84*4882a593Smuzhiyun *
85*4882a593Smuzhiyun * This callback is mandatory.
86*4882a593Smuzhiyun *
87*4882a593Smuzhiyun * RETURNS:
88*4882a593Smuzhiyun *
89*4882a593Smuzhiyun * The driver should return 0 on success and a negative error code on
90*4882a593Smuzhiyun * failure.
91*4882a593Smuzhiyun */
92*4882a593Smuzhiyun int (*fb_probe)(struct drm_fb_helper *helper,
93*4882a593Smuzhiyun struct drm_fb_helper_surface_size *sizes);
94*4882a593Smuzhiyun };
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun /**
97*4882a593Smuzhiyun * struct drm_fb_helper - main structure to emulate fbdev on top of KMS
98*4882a593Smuzhiyun * @fb: Scanout framebuffer object
99*4882a593Smuzhiyun * @dev: DRM device
100*4882a593Smuzhiyun * @funcs: driver callbacks for fb helper
101*4882a593Smuzhiyun * @fbdev: emulated fbdev device info struct
102*4882a593Smuzhiyun * @pseudo_palette: fake palette of 16 colors
103*4882a593Smuzhiyun * @dirty_clip: clip rectangle used with deferred_io to accumulate damage to
104*4882a593Smuzhiyun * the screen buffer
105*4882a593Smuzhiyun * @dirty_lock: spinlock protecting @dirty_clip
106*4882a593Smuzhiyun * @dirty_work: worker used to flush the framebuffer
107*4882a593Smuzhiyun * @resume_work: worker used during resume if the console lock is already taken
108*4882a593Smuzhiyun *
109*4882a593Smuzhiyun * This is the main structure used by the fbdev helpers. Drivers supporting
110*4882a593Smuzhiyun * fbdev emulation should embedded this into their overall driver structure.
111*4882a593Smuzhiyun * Drivers must also fill out a &struct drm_fb_helper_funcs with a few
112*4882a593Smuzhiyun * operations.
113*4882a593Smuzhiyun */
114*4882a593Smuzhiyun struct drm_fb_helper {
115*4882a593Smuzhiyun /**
116*4882a593Smuzhiyun * @client:
117*4882a593Smuzhiyun *
118*4882a593Smuzhiyun * DRM client used by the generic fbdev emulation.
119*4882a593Smuzhiyun */
120*4882a593Smuzhiyun struct drm_client_dev client;
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun /**
123*4882a593Smuzhiyun * @buffer:
124*4882a593Smuzhiyun *
125*4882a593Smuzhiyun * Framebuffer used by the generic fbdev emulation.
126*4882a593Smuzhiyun */
127*4882a593Smuzhiyun struct drm_client_buffer *buffer;
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun struct drm_framebuffer *fb;
130*4882a593Smuzhiyun struct drm_device *dev;
131*4882a593Smuzhiyun const struct drm_fb_helper_funcs *funcs;
132*4882a593Smuzhiyun struct fb_info *fbdev;
133*4882a593Smuzhiyun u32 pseudo_palette[17];
134*4882a593Smuzhiyun struct drm_clip_rect dirty_clip;
135*4882a593Smuzhiyun spinlock_t dirty_lock;
136*4882a593Smuzhiyun struct work_struct dirty_work;
137*4882a593Smuzhiyun struct work_struct resume_work;
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun /**
140*4882a593Smuzhiyun * @lock:
141*4882a593Smuzhiyun *
142*4882a593Smuzhiyun * Top-level FBDEV helper lock. This protects all internal data
143*4882a593Smuzhiyun * structures and lists, such as @connector_info and @crtc_info.
144*4882a593Smuzhiyun *
145*4882a593Smuzhiyun * FIXME: fbdev emulation locking is a mess and long term we want to
146*4882a593Smuzhiyun * protect all helper internal state with this lock as well as reduce
147*4882a593Smuzhiyun * core KMS locking as much as possible.
148*4882a593Smuzhiyun */
149*4882a593Smuzhiyun struct mutex lock;
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun /**
152*4882a593Smuzhiyun * @kernel_fb_list:
153*4882a593Smuzhiyun *
154*4882a593Smuzhiyun * Entry on the global kernel_fb_helper_list, used for kgdb entry/exit.
155*4882a593Smuzhiyun */
156*4882a593Smuzhiyun struct list_head kernel_fb_list;
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun /**
159*4882a593Smuzhiyun * @delayed_hotplug:
160*4882a593Smuzhiyun *
161*4882a593Smuzhiyun * A hotplug was received while fbdev wasn't in control of the DRM
162*4882a593Smuzhiyun * device, i.e. another KMS master was active. The output configuration
163*4882a593Smuzhiyun * needs to be reprobe when fbdev is in control again.
164*4882a593Smuzhiyun */
165*4882a593Smuzhiyun bool delayed_hotplug;
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun /**
168*4882a593Smuzhiyun * @deferred_setup:
169*4882a593Smuzhiyun *
170*4882a593Smuzhiyun * If no outputs are connected (disconnected or unknown) the FB helper
171*4882a593Smuzhiyun * code will defer setup until at least one of the outputs shows up.
172*4882a593Smuzhiyun * This field keeps track of the status so that setup can be retried
173*4882a593Smuzhiyun * at every hotplug event until it succeeds eventually.
174*4882a593Smuzhiyun *
175*4882a593Smuzhiyun * Protected by @lock.
176*4882a593Smuzhiyun */
177*4882a593Smuzhiyun bool deferred_setup;
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun /**
180*4882a593Smuzhiyun * @preferred_bpp:
181*4882a593Smuzhiyun *
182*4882a593Smuzhiyun * Temporary storage for the driver's preferred BPP setting passed to
183*4882a593Smuzhiyun * FB helper initialization. This needs to be tracked so that deferred
184*4882a593Smuzhiyun * FB helper setup can pass this on.
185*4882a593Smuzhiyun *
186*4882a593Smuzhiyun * See also: @deferred_setup
187*4882a593Smuzhiyun */
188*4882a593Smuzhiyun int preferred_bpp;
189*4882a593Smuzhiyun };
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun static inline struct drm_fb_helper *
drm_fb_helper_from_client(struct drm_client_dev * client)192*4882a593Smuzhiyun drm_fb_helper_from_client(struct drm_client_dev *client)
193*4882a593Smuzhiyun {
194*4882a593Smuzhiyun return container_of(client, struct drm_fb_helper, client);
195*4882a593Smuzhiyun }
196*4882a593Smuzhiyun
197*4882a593Smuzhiyun /**
198*4882a593Smuzhiyun * define DRM_FB_HELPER_DEFAULT_OPS - helper define for drm drivers
199*4882a593Smuzhiyun *
200*4882a593Smuzhiyun * Helper define to register default implementations of drm_fb_helper
201*4882a593Smuzhiyun * functions. To be used in struct fb_ops of drm drivers.
202*4882a593Smuzhiyun */
203*4882a593Smuzhiyun #define DRM_FB_HELPER_DEFAULT_OPS \
204*4882a593Smuzhiyun .fb_check_var = drm_fb_helper_check_var, \
205*4882a593Smuzhiyun .fb_set_par = drm_fb_helper_set_par, \
206*4882a593Smuzhiyun .fb_setcmap = drm_fb_helper_setcmap, \
207*4882a593Smuzhiyun .fb_blank = drm_fb_helper_blank, \
208*4882a593Smuzhiyun .fb_pan_display = drm_fb_helper_pan_display, \
209*4882a593Smuzhiyun .fb_debug_enter = drm_fb_helper_debug_enter, \
210*4882a593Smuzhiyun .fb_debug_leave = drm_fb_helper_debug_leave, \
211*4882a593Smuzhiyun .fb_ioctl = drm_fb_helper_ioctl
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun #ifdef CONFIG_DRM_FBDEV_EMULATION
214*4882a593Smuzhiyun void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper,
215*4882a593Smuzhiyun const struct drm_fb_helper_funcs *funcs);
216*4882a593Smuzhiyun int drm_fb_helper_init(struct drm_device *dev, struct drm_fb_helper *helper);
217*4882a593Smuzhiyun void drm_fb_helper_fini(struct drm_fb_helper *helper);
218*4882a593Smuzhiyun int drm_fb_helper_blank(int blank, struct fb_info *info);
219*4882a593Smuzhiyun int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
220*4882a593Smuzhiyun struct fb_info *info);
221*4882a593Smuzhiyun int drm_fb_helper_set_par(struct fb_info *info);
222*4882a593Smuzhiyun int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
223*4882a593Smuzhiyun struct fb_info *info);
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper);
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun struct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper);
228*4882a593Smuzhiyun void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper);
229*4882a593Smuzhiyun void drm_fb_helper_fill_info(struct fb_info *info,
230*4882a593Smuzhiyun struct drm_fb_helper *fb_helper,
231*4882a593Smuzhiyun struct drm_fb_helper_surface_size *sizes);
232*4882a593Smuzhiyun
233*4882a593Smuzhiyun void drm_fb_helper_deferred_io(struct fb_info *info,
234*4882a593Smuzhiyun struct list_head *pagelist);
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun ssize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
237*4882a593Smuzhiyun size_t count, loff_t *ppos);
238*4882a593Smuzhiyun ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
239*4882a593Smuzhiyun size_t count, loff_t *ppos);
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun void drm_fb_helper_sys_fillrect(struct fb_info *info,
242*4882a593Smuzhiyun const struct fb_fillrect *rect);
243*4882a593Smuzhiyun void drm_fb_helper_sys_copyarea(struct fb_info *info,
244*4882a593Smuzhiyun const struct fb_copyarea *area);
245*4882a593Smuzhiyun void drm_fb_helper_sys_imageblit(struct fb_info *info,
246*4882a593Smuzhiyun const struct fb_image *image);
247*4882a593Smuzhiyun
248*4882a593Smuzhiyun void drm_fb_helper_cfb_fillrect(struct fb_info *info,
249*4882a593Smuzhiyun const struct fb_fillrect *rect);
250*4882a593Smuzhiyun void drm_fb_helper_cfb_copyarea(struct fb_info *info,
251*4882a593Smuzhiyun const struct fb_copyarea *area);
252*4882a593Smuzhiyun void drm_fb_helper_cfb_imageblit(struct fb_info *info,
253*4882a593Smuzhiyun const struct fb_image *image);
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend);
256*4882a593Smuzhiyun void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
257*4882a593Smuzhiyun bool suspend);
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
260*4882a593Smuzhiyun
261*4882a593Smuzhiyun int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd,
262*4882a593Smuzhiyun unsigned long arg);
263*4882a593Smuzhiyun
264*4882a593Smuzhiyun int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
265*4882a593Smuzhiyun int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel);
266*4882a593Smuzhiyun int drm_fb_helper_debug_enter(struct fb_info *info);
267*4882a593Smuzhiyun int drm_fb_helper_debug_leave(struct fb_info *info);
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun void drm_fb_helper_lastclose(struct drm_device *dev);
270*4882a593Smuzhiyun void drm_fb_helper_output_poll_changed(struct drm_device *dev);
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun void drm_fbdev_generic_setup(struct drm_device *dev,
273*4882a593Smuzhiyun unsigned int preferred_bpp);
274*4882a593Smuzhiyun #else
drm_fb_helper_prepare(struct drm_device * dev,struct drm_fb_helper * helper,const struct drm_fb_helper_funcs * funcs)275*4882a593Smuzhiyun static inline void drm_fb_helper_prepare(struct drm_device *dev,
276*4882a593Smuzhiyun struct drm_fb_helper *helper,
277*4882a593Smuzhiyun const struct drm_fb_helper_funcs *funcs)
278*4882a593Smuzhiyun {
279*4882a593Smuzhiyun }
280*4882a593Smuzhiyun
drm_fb_helper_init(struct drm_device * dev,struct drm_fb_helper * helper)281*4882a593Smuzhiyun static inline int drm_fb_helper_init(struct drm_device *dev,
282*4882a593Smuzhiyun struct drm_fb_helper *helper)
283*4882a593Smuzhiyun {
284*4882a593Smuzhiyun /* So drivers can use it to free the struct */
285*4882a593Smuzhiyun helper->dev = dev;
286*4882a593Smuzhiyun dev->fb_helper = helper;
287*4882a593Smuzhiyun
288*4882a593Smuzhiyun return 0;
289*4882a593Smuzhiyun }
290*4882a593Smuzhiyun
drm_fb_helper_fini(struct drm_fb_helper * helper)291*4882a593Smuzhiyun static inline void drm_fb_helper_fini(struct drm_fb_helper *helper)
292*4882a593Smuzhiyun {
293*4882a593Smuzhiyun if (helper && helper->dev)
294*4882a593Smuzhiyun helper->dev->fb_helper = NULL;
295*4882a593Smuzhiyun }
296*4882a593Smuzhiyun
drm_fb_helper_blank(int blank,struct fb_info * info)297*4882a593Smuzhiyun static inline int drm_fb_helper_blank(int blank, struct fb_info *info)
298*4882a593Smuzhiyun {
299*4882a593Smuzhiyun return 0;
300*4882a593Smuzhiyun }
301*4882a593Smuzhiyun
drm_fb_helper_pan_display(struct fb_var_screeninfo * var,struct fb_info * info)302*4882a593Smuzhiyun static inline int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
303*4882a593Smuzhiyun struct fb_info *info)
304*4882a593Smuzhiyun {
305*4882a593Smuzhiyun return 0;
306*4882a593Smuzhiyun }
307*4882a593Smuzhiyun
drm_fb_helper_set_par(struct fb_info * info)308*4882a593Smuzhiyun static inline int drm_fb_helper_set_par(struct fb_info *info)
309*4882a593Smuzhiyun {
310*4882a593Smuzhiyun return 0;
311*4882a593Smuzhiyun }
312*4882a593Smuzhiyun
drm_fb_helper_check_var(struct fb_var_screeninfo * var,struct fb_info * info)313*4882a593Smuzhiyun static inline int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
314*4882a593Smuzhiyun struct fb_info *info)
315*4882a593Smuzhiyun {
316*4882a593Smuzhiyun return 0;
317*4882a593Smuzhiyun }
318*4882a593Smuzhiyun
319*4882a593Smuzhiyun static inline int
drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper * fb_helper)320*4882a593Smuzhiyun drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
321*4882a593Smuzhiyun {
322*4882a593Smuzhiyun return 0;
323*4882a593Smuzhiyun }
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun static inline struct fb_info *
drm_fb_helper_alloc_fbi(struct drm_fb_helper * fb_helper)326*4882a593Smuzhiyun drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
327*4882a593Smuzhiyun {
328*4882a593Smuzhiyun return NULL;
329*4882a593Smuzhiyun }
330*4882a593Smuzhiyun
drm_fb_helper_unregister_fbi(struct drm_fb_helper * fb_helper)331*4882a593Smuzhiyun static inline void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
332*4882a593Smuzhiyun {
333*4882a593Smuzhiyun }
334*4882a593Smuzhiyun
335*4882a593Smuzhiyun static inline void
drm_fb_helper_fill_info(struct fb_info * info,struct drm_fb_helper * fb_helper,struct drm_fb_helper_surface_size * sizes)336*4882a593Smuzhiyun drm_fb_helper_fill_info(struct fb_info *info,
337*4882a593Smuzhiyun struct drm_fb_helper *fb_helper,
338*4882a593Smuzhiyun struct drm_fb_helper_surface_size *sizes)
339*4882a593Smuzhiyun {
340*4882a593Smuzhiyun }
341*4882a593Smuzhiyun
drm_fb_helper_setcmap(struct fb_cmap * cmap,struct fb_info * info)342*4882a593Smuzhiyun static inline int drm_fb_helper_setcmap(struct fb_cmap *cmap,
343*4882a593Smuzhiyun struct fb_info *info)
344*4882a593Smuzhiyun {
345*4882a593Smuzhiyun return 0;
346*4882a593Smuzhiyun }
347*4882a593Smuzhiyun
drm_fb_helper_ioctl(struct fb_info * info,unsigned int cmd,unsigned long arg)348*4882a593Smuzhiyun static inline int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd,
349*4882a593Smuzhiyun unsigned long arg)
350*4882a593Smuzhiyun {
351*4882a593Smuzhiyun return 0;
352*4882a593Smuzhiyun }
353*4882a593Smuzhiyun
drm_fb_helper_deferred_io(struct fb_info * info,struct list_head * pagelist)354*4882a593Smuzhiyun static inline void drm_fb_helper_deferred_io(struct fb_info *info,
355*4882a593Smuzhiyun struct list_head *pagelist)
356*4882a593Smuzhiyun {
357*4882a593Smuzhiyun }
358*4882a593Smuzhiyun
drm_fb_helper_defio_init(struct drm_fb_helper * fb_helper)359*4882a593Smuzhiyun static inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
360*4882a593Smuzhiyun {
361*4882a593Smuzhiyun return -ENODEV;
362*4882a593Smuzhiyun }
363*4882a593Smuzhiyun
drm_fb_helper_sys_read(struct fb_info * info,char __user * buf,size_t count,loff_t * ppos)364*4882a593Smuzhiyun static inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
365*4882a593Smuzhiyun char __user *buf, size_t count,
366*4882a593Smuzhiyun loff_t *ppos)
367*4882a593Smuzhiyun {
368*4882a593Smuzhiyun return -ENODEV;
369*4882a593Smuzhiyun }
370*4882a593Smuzhiyun
drm_fb_helper_sys_write(struct fb_info * info,const char __user * buf,size_t count,loff_t * ppos)371*4882a593Smuzhiyun static inline ssize_t drm_fb_helper_sys_write(struct fb_info *info,
372*4882a593Smuzhiyun const char __user *buf,
373*4882a593Smuzhiyun size_t count, loff_t *ppos)
374*4882a593Smuzhiyun {
375*4882a593Smuzhiyun return -ENODEV;
376*4882a593Smuzhiyun }
377*4882a593Smuzhiyun
drm_fb_helper_sys_fillrect(struct fb_info * info,const struct fb_fillrect * rect)378*4882a593Smuzhiyun static inline void drm_fb_helper_sys_fillrect(struct fb_info *info,
379*4882a593Smuzhiyun const struct fb_fillrect *rect)
380*4882a593Smuzhiyun {
381*4882a593Smuzhiyun }
382*4882a593Smuzhiyun
drm_fb_helper_sys_copyarea(struct fb_info * info,const struct fb_copyarea * area)383*4882a593Smuzhiyun static inline void drm_fb_helper_sys_copyarea(struct fb_info *info,
384*4882a593Smuzhiyun const struct fb_copyarea *area)
385*4882a593Smuzhiyun {
386*4882a593Smuzhiyun }
387*4882a593Smuzhiyun
drm_fb_helper_sys_imageblit(struct fb_info * info,const struct fb_image * image)388*4882a593Smuzhiyun static inline void drm_fb_helper_sys_imageblit(struct fb_info *info,
389*4882a593Smuzhiyun const struct fb_image *image)
390*4882a593Smuzhiyun {
391*4882a593Smuzhiyun }
392*4882a593Smuzhiyun
drm_fb_helper_cfb_fillrect(struct fb_info * info,const struct fb_fillrect * rect)393*4882a593Smuzhiyun static inline void drm_fb_helper_cfb_fillrect(struct fb_info *info,
394*4882a593Smuzhiyun const struct fb_fillrect *rect)
395*4882a593Smuzhiyun {
396*4882a593Smuzhiyun }
397*4882a593Smuzhiyun
drm_fb_helper_cfb_copyarea(struct fb_info * info,const struct fb_copyarea * area)398*4882a593Smuzhiyun static inline void drm_fb_helper_cfb_copyarea(struct fb_info *info,
399*4882a593Smuzhiyun const struct fb_copyarea *area)
400*4882a593Smuzhiyun {
401*4882a593Smuzhiyun }
402*4882a593Smuzhiyun
drm_fb_helper_cfb_imageblit(struct fb_info * info,const struct fb_image * image)403*4882a593Smuzhiyun static inline void drm_fb_helper_cfb_imageblit(struct fb_info *info,
404*4882a593Smuzhiyun const struct fb_image *image)
405*4882a593Smuzhiyun {
406*4882a593Smuzhiyun }
407*4882a593Smuzhiyun
drm_fb_helper_set_suspend(struct drm_fb_helper * fb_helper,bool suspend)408*4882a593Smuzhiyun static inline void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper,
409*4882a593Smuzhiyun bool suspend)
410*4882a593Smuzhiyun {
411*4882a593Smuzhiyun }
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun static inline void
drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper * fb_helper,bool suspend)414*4882a593Smuzhiyun drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, bool suspend)
415*4882a593Smuzhiyun {
416*4882a593Smuzhiyun }
417*4882a593Smuzhiyun
drm_fb_helper_hotplug_event(struct drm_fb_helper * fb_helper)418*4882a593Smuzhiyun static inline int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
419*4882a593Smuzhiyun {
420*4882a593Smuzhiyun return 0;
421*4882a593Smuzhiyun }
422*4882a593Smuzhiyun
drm_fb_helper_initial_config(struct drm_fb_helper * fb_helper,int bpp_sel)423*4882a593Smuzhiyun static inline int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper,
424*4882a593Smuzhiyun int bpp_sel)
425*4882a593Smuzhiyun {
426*4882a593Smuzhiyun return 0;
427*4882a593Smuzhiyun }
428*4882a593Smuzhiyun
drm_fb_helper_debug_enter(struct fb_info * info)429*4882a593Smuzhiyun static inline int drm_fb_helper_debug_enter(struct fb_info *info)
430*4882a593Smuzhiyun {
431*4882a593Smuzhiyun return 0;
432*4882a593Smuzhiyun }
433*4882a593Smuzhiyun
drm_fb_helper_debug_leave(struct fb_info * info)434*4882a593Smuzhiyun static inline int drm_fb_helper_debug_leave(struct fb_info *info)
435*4882a593Smuzhiyun {
436*4882a593Smuzhiyun return 0;
437*4882a593Smuzhiyun }
438*4882a593Smuzhiyun
drm_fb_helper_lastclose(struct drm_device * dev)439*4882a593Smuzhiyun static inline void drm_fb_helper_lastclose(struct drm_device *dev)
440*4882a593Smuzhiyun {
441*4882a593Smuzhiyun }
442*4882a593Smuzhiyun
drm_fb_helper_output_poll_changed(struct drm_device * dev)443*4882a593Smuzhiyun static inline void drm_fb_helper_output_poll_changed(struct drm_device *dev)
444*4882a593Smuzhiyun {
445*4882a593Smuzhiyun }
446*4882a593Smuzhiyun
447*4882a593Smuzhiyun static inline void
drm_fbdev_generic_setup(struct drm_device * dev,unsigned int preferred_bpp)448*4882a593Smuzhiyun drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
449*4882a593Smuzhiyun {
450*4882a593Smuzhiyun }
451*4882a593Smuzhiyun
452*4882a593Smuzhiyun #endif
453*4882a593Smuzhiyun
454*4882a593Smuzhiyun /**
455*4882a593Smuzhiyun * drm_fb_helper_remove_conflicting_framebuffers - remove firmware-configured framebuffers
456*4882a593Smuzhiyun * @a: memory range, users of which are to be removed
457*4882a593Smuzhiyun * @name: requesting driver name
458*4882a593Smuzhiyun * @primary: also kick vga16fb if present
459*4882a593Smuzhiyun *
460*4882a593Smuzhiyun * This function removes framebuffer devices (initialized by firmware/bootloader)
461*4882a593Smuzhiyun * which use memory range described by @a. If @a is NULL all such devices are
462*4882a593Smuzhiyun * removed.
463*4882a593Smuzhiyun */
464*4882a593Smuzhiyun static inline int
drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct * a,const char * name,bool primary)465*4882a593Smuzhiyun drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
466*4882a593Smuzhiyun const char *name, bool primary)
467*4882a593Smuzhiyun {
468*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_FB)
469*4882a593Smuzhiyun return remove_conflicting_framebuffers(a, name, primary);
470*4882a593Smuzhiyun #else
471*4882a593Smuzhiyun return 0;
472*4882a593Smuzhiyun #endif
473*4882a593Smuzhiyun }
474*4882a593Smuzhiyun
475*4882a593Smuzhiyun /**
476*4882a593Smuzhiyun * drm_fb_helper_remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices
477*4882a593Smuzhiyun * @pdev: PCI device
478*4882a593Smuzhiyun * @name: requesting driver name
479*4882a593Smuzhiyun *
480*4882a593Smuzhiyun * This function removes framebuffer devices (eg. initialized by firmware)
481*4882a593Smuzhiyun * using memory range configured for any of @pdev's memory bars.
482*4882a593Smuzhiyun *
483*4882a593Smuzhiyun * The function assumes that PCI device with shadowed ROM drives a primary
484*4882a593Smuzhiyun * display and so kicks out vga16fb.
485*4882a593Smuzhiyun */
486*4882a593Smuzhiyun static inline int
drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev * pdev,const char * name)487*4882a593Smuzhiyun drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
488*4882a593Smuzhiyun const char *name)
489*4882a593Smuzhiyun {
490*4882a593Smuzhiyun int ret = 0;
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun /*
493*4882a593Smuzhiyun * WARNING: Apparently we must kick fbdev drivers before vgacon,
494*4882a593Smuzhiyun * otherwise the vga fbdev driver falls over.
495*4882a593Smuzhiyun */
496*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_FB)
497*4882a593Smuzhiyun ret = remove_conflicting_pci_framebuffers(pdev, name);
498*4882a593Smuzhiyun #endif
499*4882a593Smuzhiyun if (ret == 0)
500*4882a593Smuzhiyun ret = vga_remove_vgacon(pdev);
501*4882a593Smuzhiyun return ret;
502*4882a593Smuzhiyun }
503*4882a593Smuzhiyun
504*4882a593Smuzhiyun #endif
505