18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2006-2009 Red Hat Inc.
38c2ecf20Sopenharmony_ci * Copyright (c) 2006-2008 Intel Corporation
48c2ecf20Sopenharmony_ci * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * DRM framebuffer helper functions
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Permission to use, copy, modify, distribute, and sell this software and its
98c2ecf20Sopenharmony_ci * documentation for any purpose is hereby granted without fee, provided that
108c2ecf20Sopenharmony_ci * the above copyright notice appear in all copies and that both that copyright
118c2ecf20Sopenharmony_ci * notice and this permission notice appear in supporting documentation, and
128c2ecf20Sopenharmony_ci * that the name of the copyright holders not be used in advertising or
138c2ecf20Sopenharmony_ci * publicity pertaining to distribution of the software without specific,
148c2ecf20Sopenharmony_ci * written prior permission.  The copyright holders make no representations
158c2ecf20Sopenharmony_ci * about the suitability of this software for any purpose.  It is provided "as
168c2ecf20Sopenharmony_ci * is" without express or implied warranty.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
198c2ecf20Sopenharmony_ci * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
208c2ecf20Sopenharmony_ci * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
218c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
228c2ecf20Sopenharmony_ci * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
238c2ecf20Sopenharmony_ci * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
248c2ecf20Sopenharmony_ci * OF THIS SOFTWARE.
258c2ecf20Sopenharmony_ci *
268c2ecf20Sopenharmony_ci * Authors:
278c2ecf20Sopenharmony_ci *      Dave Airlie <airlied@linux.ie>
288c2ecf20Sopenharmony_ci *      Jesse Barnes <jesse.barnes@intel.com>
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci#ifndef DRM_FB_HELPER_H
318c2ecf20Sopenharmony_ci#define DRM_FB_HELPER_H
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistruct drm_fb_helper;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#include <drm/drm_client.h>
368c2ecf20Sopenharmony_ci#include <drm/drm_crtc.h>
378c2ecf20Sopenharmony_ci#include <drm/drm_device.h>
388c2ecf20Sopenharmony_ci#include <linux/kgdb.h>
398c2ecf20Sopenharmony_ci#include <linux/vgaarb.h>
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cienum mode_set_atomic {
428c2ecf20Sopenharmony_ci	LEAVE_ATOMIC_MODE_SET,
438c2ecf20Sopenharmony_ci	ENTER_ATOMIC_MODE_SET,
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/**
478c2ecf20Sopenharmony_ci * struct drm_fb_helper_surface_size - describes fbdev size and scanout surface size
488c2ecf20Sopenharmony_ci * @fb_width: fbdev width
498c2ecf20Sopenharmony_ci * @fb_height: fbdev height
508c2ecf20Sopenharmony_ci * @surface_width: scanout buffer width
518c2ecf20Sopenharmony_ci * @surface_height: scanout buffer height
528c2ecf20Sopenharmony_ci * @surface_bpp: scanout buffer bpp
538c2ecf20Sopenharmony_ci * @surface_depth: scanout buffer depth
548c2ecf20Sopenharmony_ci *
558c2ecf20Sopenharmony_ci * Note that the scanout surface width/height may be larger than the fbdev
568c2ecf20Sopenharmony_ci * width/height.  In case of multiple displays, the scanout surface is sized
578c2ecf20Sopenharmony_ci * according to the largest width/height (so it is large enough for all CRTCs
588c2ecf20Sopenharmony_ci * to scanout).  But the fbdev width/height is sized to the minimum width/
598c2ecf20Sopenharmony_ci * height of all the displays.  This ensures that fbcon fits on the smallest
608c2ecf20Sopenharmony_ci * of the attached displays. fb_width/fb_height is used by
618c2ecf20Sopenharmony_ci * drm_fb_helper_fill_info() to fill out the &fb_info.var structure.
628c2ecf20Sopenharmony_ci */
638c2ecf20Sopenharmony_cistruct drm_fb_helper_surface_size {
648c2ecf20Sopenharmony_ci	u32 fb_width;
658c2ecf20Sopenharmony_ci	u32 fb_height;
668c2ecf20Sopenharmony_ci	u32 surface_width;
678c2ecf20Sopenharmony_ci	u32 surface_height;
688c2ecf20Sopenharmony_ci	u32 surface_bpp;
698c2ecf20Sopenharmony_ci	u32 surface_depth;
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/**
738c2ecf20Sopenharmony_ci * struct drm_fb_helper_funcs - driver callbacks for the fbdev emulation library
748c2ecf20Sopenharmony_ci *
758c2ecf20Sopenharmony_ci * Driver callbacks used by the fbdev emulation helper library.
768c2ecf20Sopenharmony_ci */
778c2ecf20Sopenharmony_cistruct drm_fb_helper_funcs {
788c2ecf20Sopenharmony_ci	/**
798c2ecf20Sopenharmony_ci	 * @fb_probe:
808c2ecf20Sopenharmony_ci	 *
818c2ecf20Sopenharmony_ci	 * Driver callback to allocate and initialize the fbdev info structure.
828c2ecf20Sopenharmony_ci	 * Furthermore it also needs to allocate the DRM framebuffer used to
838c2ecf20Sopenharmony_ci	 * back the fbdev.
848c2ecf20Sopenharmony_ci	 *
858c2ecf20Sopenharmony_ci	 * This callback is mandatory.
868c2ecf20Sopenharmony_ci	 *
878c2ecf20Sopenharmony_ci	 * RETURNS:
888c2ecf20Sopenharmony_ci	 *
898c2ecf20Sopenharmony_ci	 * The driver should return 0 on success and a negative error code on
908c2ecf20Sopenharmony_ci	 * failure.
918c2ecf20Sopenharmony_ci	 */
928c2ecf20Sopenharmony_ci	int (*fb_probe)(struct drm_fb_helper *helper,
938c2ecf20Sopenharmony_ci			struct drm_fb_helper_surface_size *sizes);
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/**
978c2ecf20Sopenharmony_ci * struct drm_fb_helper - main structure to emulate fbdev on top of KMS
988c2ecf20Sopenharmony_ci * @fb: Scanout framebuffer object
998c2ecf20Sopenharmony_ci * @dev: DRM device
1008c2ecf20Sopenharmony_ci * @funcs: driver callbacks for fb helper
1018c2ecf20Sopenharmony_ci * @fbdev: emulated fbdev device info struct
1028c2ecf20Sopenharmony_ci * @pseudo_palette: fake palette of 16 colors
1038c2ecf20Sopenharmony_ci * @dirty_clip: clip rectangle used with deferred_io to accumulate damage to
1048c2ecf20Sopenharmony_ci *              the screen buffer
1058c2ecf20Sopenharmony_ci * @dirty_lock: spinlock protecting @dirty_clip
1068c2ecf20Sopenharmony_ci * @dirty_work: worker used to flush the framebuffer
1078c2ecf20Sopenharmony_ci * @resume_work: worker used during resume if the console lock is already taken
1088c2ecf20Sopenharmony_ci *
1098c2ecf20Sopenharmony_ci * This is the main structure used by the fbdev helpers. Drivers supporting
1108c2ecf20Sopenharmony_ci * fbdev emulation should embedded this into their overall driver structure.
1118c2ecf20Sopenharmony_ci * Drivers must also fill out a &struct drm_fb_helper_funcs with a few
1128c2ecf20Sopenharmony_ci * operations.
1138c2ecf20Sopenharmony_ci */
1148c2ecf20Sopenharmony_cistruct drm_fb_helper {
1158c2ecf20Sopenharmony_ci	/**
1168c2ecf20Sopenharmony_ci	 * @client:
1178c2ecf20Sopenharmony_ci	 *
1188c2ecf20Sopenharmony_ci	 * DRM client used by the generic fbdev emulation.
1198c2ecf20Sopenharmony_ci	 */
1208c2ecf20Sopenharmony_ci	struct drm_client_dev client;
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	/**
1238c2ecf20Sopenharmony_ci	 * @buffer:
1248c2ecf20Sopenharmony_ci	 *
1258c2ecf20Sopenharmony_ci	 * Framebuffer used by the generic fbdev emulation.
1268c2ecf20Sopenharmony_ci	 */
1278c2ecf20Sopenharmony_ci	struct drm_client_buffer *buffer;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	struct drm_framebuffer *fb;
1308c2ecf20Sopenharmony_ci	struct drm_device *dev;
1318c2ecf20Sopenharmony_ci	const struct drm_fb_helper_funcs *funcs;
1328c2ecf20Sopenharmony_ci	struct fb_info *fbdev;
1338c2ecf20Sopenharmony_ci	u32 pseudo_palette[17];
1348c2ecf20Sopenharmony_ci	struct drm_clip_rect dirty_clip;
1358c2ecf20Sopenharmony_ci	spinlock_t dirty_lock;
1368c2ecf20Sopenharmony_ci	struct work_struct dirty_work;
1378c2ecf20Sopenharmony_ci	struct work_struct resume_work;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci	/**
1408c2ecf20Sopenharmony_ci	 * @lock:
1418c2ecf20Sopenharmony_ci	 *
1428c2ecf20Sopenharmony_ci	 * Top-level FBDEV helper lock. This protects all internal data
1438c2ecf20Sopenharmony_ci	 * structures and lists, such as @connector_info and @crtc_info.
1448c2ecf20Sopenharmony_ci	 *
1458c2ecf20Sopenharmony_ci	 * FIXME: fbdev emulation locking is a mess and long term we want to
1468c2ecf20Sopenharmony_ci	 * protect all helper internal state with this lock as well as reduce
1478c2ecf20Sopenharmony_ci	 * core KMS locking as much as possible.
1488c2ecf20Sopenharmony_ci	 */
1498c2ecf20Sopenharmony_ci	struct mutex lock;
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	/**
1528c2ecf20Sopenharmony_ci	 * @kernel_fb_list:
1538c2ecf20Sopenharmony_ci	 *
1548c2ecf20Sopenharmony_ci	 * Entry on the global kernel_fb_helper_list, used for kgdb entry/exit.
1558c2ecf20Sopenharmony_ci	 */
1568c2ecf20Sopenharmony_ci	struct list_head kernel_fb_list;
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	/**
1598c2ecf20Sopenharmony_ci	 * @delayed_hotplug:
1608c2ecf20Sopenharmony_ci	 *
1618c2ecf20Sopenharmony_ci	 * A hotplug was received while fbdev wasn't in control of the DRM
1628c2ecf20Sopenharmony_ci	 * device, i.e. another KMS master was active. The output configuration
1638c2ecf20Sopenharmony_ci	 * needs to be reprobe when fbdev is in control again.
1648c2ecf20Sopenharmony_ci	 */
1658c2ecf20Sopenharmony_ci	bool delayed_hotplug;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	/**
1688c2ecf20Sopenharmony_ci	 * @deferred_setup:
1698c2ecf20Sopenharmony_ci	 *
1708c2ecf20Sopenharmony_ci	 * If no outputs are connected (disconnected or unknown) the FB helper
1718c2ecf20Sopenharmony_ci	 * code will defer setup until at least one of the outputs shows up.
1728c2ecf20Sopenharmony_ci	 * This field keeps track of the status so that setup can be retried
1738c2ecf20Sopenharmony_ci	 * at every hotplug event until it succeeds eventually.
1748c2ecf20Sopenharmony_ci	 *
1758c2ecf20Sopenharmony_ci	 * Protected by @lock.
1768c2ecf20Sopenharmony_ci	 */
1778c2ecf20Sopenharmony_ci	bool deferred_setup;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	/**
1808c2ecf20Sopenharmony_ci	 * @preferred_bpp:
1818c2ecf20Sopenharmony_ci	 *
1828c2ecf20Sopenharmony_ci	 * Temporary storage for the driver's preferred BPP setting passed to
1838c2ecf20Sopenharmony_ci	 * FB helper initialization. This needs to be tracked so that deferred
1848c2ecf20Sopenharmony_ci	 * FB helper setup can pass this on.
1858c2ecf20Sopenharmony_ci	 *
1868c2ecf20Sopenharmony_ci	 * See also: @deferred_setup
1878c2ecf20Sopenharmony_ci	 */
1888c2ecf20Sopenharmony_ci	int preferred_bpp;
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistatic inline struct drm_fb_helper *
1928c2ecf20Sopenharmony_cidrm_fb_helper_from_client(struct drm_client_dev *client)
1938c2ecf20Sopenharmony_ci{
1948c2ecf20Sopenharmony_ci	return container_of(client, struct drm_fb_helper, client);
1958c2ecf20Sopenharmony_ci}
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci/**
1988c2ecf20Sopenharmony_ci * define DRM_FB_HELPER_DEFAULT_OPS - helper define for drm drivers
1998c2ecf20Sopenharmony_ci *
2008c2ecf20Sopenharmony_ci * Helper define to register default implementations of drm_fb_helper
2018c2ecf20Sopenharmony_ci * functions. To be used in struct fb_ops of drm drivers.
2028c2ecf20Sopenharmony_ci */
2038c2ecf20Sopenharmony_ci#define DRM_FB_HELPER_DEFAULT_OPS \
2048c2ecf20Sopenharmony_ci	.fb_check_var	= drm_fb_helper_check_var, \
2058c2ecf20Sopenharmony_ci	.fb_set_par	= drm_fb_helper_set_par, \
2068c2ecf20Sopenharmony_ci	.fb_setcmap	= drm_fb_helper_setcmap, \
2078c2ecf20Sopenharmony_ci	.fb_blank	= drm_fb_helper_blank, \
2088c2ecf20Sopenharmony_ci	.fb_pan_display	= drm_fb_helper_pan_display, \
2098c2ecf20Sopenharmony_ci	.fb_debug_enter = drm_fb_helper_debug_enter, \
2108c2ecf20Sopenharmony_ci	.fb_debug_leave = drm_fb_helper_debug_leave, \
2118c2ecf20Sopenharmony_ci	.fb_ioctl	= drm_fb_helper_ioctl
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci#ifdef CONFIG_DRM_FBDEV_EMULATION
2148c2ecf20Sopenharmony_civoid drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper,
2158c2ecf20Sopenharmony_ci			   const struct drm_fb_helper_funcs *funcs);
2168c2ecf20Sopenharmony_ciint drm_fb_helper_init(struct drm_device *dev, struct drm_fb_helper *helper);
2178c2ecf20Sopenharmony_civoid drm_fb_helper_fini(struct drm_fb_helper *helper);
2188c2ecf20Sopenharmony_ciint drm_fb_helper_blank(int blank, struct fb_info *info);
2198c2ecf20Sopenharmony_ciint drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
2208c2ecf20Sopenharmony_ci			      struct fb_info *info);
2218c2ecf20Sopenharmony_ciint drm_fb_helper_set_par(struct fb_info *info);
2228c2ecf20Sopenharmony_ciint drm_fb_helper_check_var(struct fb_var_screeninfo *var,
2238c2ecf20Sopenharmony_ci			    struct fb_info *info);
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ciint drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper);
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistruct fb_info *drm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper);
2288c2ecf20Sopenharmony_civoid drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper);
2298c2ecf20Sopenharmony_civoid drm_fb_helper_fill_info(struct fb_info *info,
2308c2ecf20Sopenharmony_ci			     struct drm_fb_helper *fb_helper,
2318c2ecf20Sopenharmony_ci			     struct drm_fb_helper_surface_size *sizes);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_civoid drm_fb_helper_deferred_io(struct fb_info *info,
2348c2ecf20Sopenharmony_ci			       struct list_head *pagelist);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_cissize_t drm_fb_helper_sys_read(struct fb_info *info, char __user *buf,
2378c2ecf20Sopenharmony_ci			       size_t count, loff_t *ppos);
2388c2ecf20Sopenharmony_cissize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf,
2398c2ecf20Sopenharmony_ci				size_t count, loff_t *ppos);
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_civoid drm_fb_helper_sys_fillrect(struct fb_info *info,
2428c2ecf20Sopenharmony_ci				const struct fb_fillrect *rect);
2438c2ecf20Sopenharmony_civoid drm_fb_helper_sys_copyarea(struct fb_info *info,
2448c2ecf20Sopenharmony_ci				const struct fb_copyarea *area);
2458c2ecf20Sopenharmony_civoid drm_fb_helper_sys_imageblit(struct fb_info *info,
2468c2ecf20Sopenharmony_ci				 const struct fb_image *image);
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_civoid drm_fb_helper_cfb_fillrect(struct fb_info *info,
2498c2ecf20Sopenharmony_ci				const struct fb_fillrect *rect);
2508c2ecf20Sopenharmony_civoid drm_fb_helper_cfb_copyarea(struct fb_info *info,
2518c2ecf20Sopenharmony_ci				const struct fb_copyarea *area);
2528c2ecf20Sopenharmony_civoid drm_fb_helper_cfb_imageblit(struct fb_info *info,
2538c2ecf20Sopenharmony_ci				 const struct fb_image *image);
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_civoid drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend);
2568c2ecf20Sopenharmony_civoid drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper,
2578c2ecf20Sopenharmony_ci					bool suspend);
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ciint drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ciint drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd,
2628c2ecf20Sopenharmony_ci			unsigned long arg);
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ciint drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
2658c2ecf20Sopenharmony_ciint drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel);
2668c2ecf20Sopenharmony_ciint drm_fb_helper_debug_enter(struct fb_info *info);
2678c2ecf20Sopenharmony_ciint drm_fb_helper_debug_leave(struct fb_info *info);
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_civoid drm_fb_helper_lastclose(struct drm_device *dev);
2708c2ecf20Sopenharmony_civoid drm_fb_helper_output_poll_changed(struct drm_device *dev);
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_civoid drm_fbdev_generic_setup(struct drm_device *dev,
2738c2ecf20Sopenharmony_ci			     unsigned int preferred_bpp);
2748c2ecf20Sopenharmony_ci#else
2758c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_prepare(struct drm_device *dev,
2768c2ecf20Sopenharmony_ci					struct drm_fb_helper *helper,
2778c2ecf20Sopenharmony_ci					const struct drm_fb_helper_funcs *funcs)
2788c2ecf20Sopenharmony_ci{
2798c2ecf20Sopenharmony_ci}
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_init(struct drm_device *dev,
2828c2ecf20Sopenharmony_ci		       struct drm_fb_helper *helper)
2838c2ecf20Sopenharmony_ci{
2848c2ecf20Sopenharmony_ci	/* So drivers can use it to free the struct */
2858c2ecf20Sopenharmony_ci	helper->dev = dev;
2868c2ecf20Sopenharmony_ci	dev->fb_helper = helper;
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	return 0;
2898c2ecf20Sopenharmony_ci}
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_fini(struct drm_fb_helper *helper)
2928c2ecf20Sopenharmony_ci{
2938c2ecf20Sopenharmony_ci	if (helper && helper->dev)
2948c2ecf20Sopenharmony_ci		helper->dev->fb_helper = NULL;
2958c2ecf20Sopenharmony_ci}
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_blank(int blank, struct fb_info *info)
2988c2ecf20Sopenharmony_ci{
2998c2ecf20Sopenharmony_ci	return 0;
3008c2ecf20Sopenharmony_ci}
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
3038c2ecf20Sopenharmony_ci					    struct fb_info *info)
3048c2ecf20Sopenharmony_ci{
3058c2ecf20Sopenharmony_ci	return 0;
3068c2ecf20Sopenharmony_ci}
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_set_par(struct fb_info *info)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	return 0;
3118c2ecf20Sopenharmony_ci}
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
3148c2ecf20Sopenharmony_ci					  struct fb_info *info)
3158c2ecf20Sopenharmony_ci{
3168c2ecf20Sopenharmony_ci	return 0;
3178c2ecf20Sopenharmony_ci}
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_cistatic inline int
3208c2ecf20Sopenharmony_cidrm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
3218c2ecf20Sopenharmony_ci{
3228c2ecf20Sopenharmony_ci	return 0;
3238c2ecf20Sopenharmony_ci}
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_cistatic inline struct fb_info *
3268c2ecf20Sopenharmony_cidrm_fb_helper_alloc_fbi(struct drm_fb_helper *fb_helper)
3278c2ecf20Sopenharmony_ci{
3288c2ecf20Sopenharmony_ci	return NULL;
3298c2ecf20Sopenharmony_ci}
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_unregister_fbi(struct drm_fb_helper *fb_helper)
3328c2ecf20Sopenharmony_ci{
3338c2ecf20Sopenharmony_ci}
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_cistatic inline void
3368c2ecf20Sopenharmony_cidrm_fb_helper_fill_info(struct fb_info *info,
3378c2ecf20Sopenharmony_ci			struct drm_fb_helper *fb_helper,
3388c2ecf20Sopenharmony_ci			struct drm_fb_helper_surface_size *sizes)
3398c2ecf20Sopenharmony_ci{
3408c2ecf20Sopenharmony_ci}
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_setcmap(struct fb_cmap *cmap,
3438c2ecf20Sopenharmony_ci					struct fb_info *info)
3448c2ecf20Sopenharmony_ci{
3458c2ecf20Sopenharmony_ci	return 0;
3468c2ecf20Sopenharmony_ci}
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd,
3498c2ecf20Sopenharmony_ci				      unsigned long arg)
3508c2ecf20Sopenharmony_ci{
3518c2ecf20Sopenharmony_ci	return 0;
3528c2ecf20Sopenharmony_ci}
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_deferred_io(struct fb_info *info,
3558c2ecf20Sopenharmony_ci					     struct list_head *pagelist)
3568c2ecf20Sopenharmony_ci{
3578c2ecf20Sopenharmony_ci}
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_defio_init(struct drm_fb_helper *fb_helper)
3608c2ecf20Sopenharmony_ci{
3618c2ecf20Sopenharmony_ci	return -ENODEV;
3628c2ecf20Sopenharmony_ci}
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_cistatic inline ssize_t drm_fb_helper_sys_read(struct fb_info *info,
3658c2ecf20Sopenharmony_ci					     char __user *buf, size_t count,
3668c2ecf20Sopenharmony_ci					     loff_t *ppos)
3678c2ecf20Sopenharmony_ci{
3688c2ecf20Sopenharmony_ci	return -ENODEV;
3698c2ecf20Sopenharmony_ci}
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistatic inline ssize_t drm_fb_helper_sys_write(struct fb_info *info,
3728c2ecf20Sopenharmony_ci					      const char __user *buf,
3738c2ecf20Sopenharmony_ci					      size_t count, loff_t *ppos)
3748c2ecf20Sopenharmony_ci{
3758c2ecf20Sopenharmony_ci	return -ENODEV;
3768c2ecf20Sopenharmony_ci}
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_sys_fillrect(struct fb_info *info,
3798c2ecf20Sopenharmony_ci					      const struct fb_fillrect *rect)
3808c2ecf20Sopenharmony_ci{
3818c2ecf20Sopenharmony_ci}
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_sys_copyarea(struct fb_info *info,
3848c2ecf20Sopenharmony_ci					      const struct fb_copyarea *area)
3858c2ecf20Sopenharmony_ci{
3868c2ecf20Sopenharmony_ci}
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_sys_imageblit(struct fb_info *info,
3898c2ecf20Sopenharmony_ci					       const struct fb_image *image)
3908c2ecf20Sopenharmony_ci{
3918c2ecf20Sopenharmony_ci}
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_cfb_fillrect(struct fb_info *info,
3948c2ecf20Sopenharmony_ci					      const struct fb_fillrect *rect)
3958c2ecf20Sopenharmony_ci{
3968c2ecf20Sopenharmony_ci}
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_cfb_copyarea(struct fb_info *info,
3998c2ecf20Sopenharmony_ci					      const struct fb_copyarea *area)
4008c2ecf20Sopenharmony_ci{
4018c2ecf20Sopenharmony_ci}
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_cfb_imageblit(struct fb_info *info,
4048c2ecf20Sopenharmony_ci					       const struct fb_image *image)
4058c2ecf20Sopenharmony_ci{
4068c2ecf20Sopenharmony_ci}
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper,
4098c2ecf20Sopenharmony_ci					     bool suspend)
4108c2ecf20Sopenharmony_ci{
4118c2ecf20Sopenharmony_ci}
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_cistatic inline void
4148c2ecf20Sopenharmony_cidrm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, bool suspend)
4158c2ecf20Sopenharmony_ci{
4168c2ecf20Sopenharmony_ci}
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
4198c2ecf20Sopenharmony_ci{
4208c2ecf20Sopenharmony_ci	return 0;
4218c2ecf20Sopenharmony_ci}
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper,
4248c2ecf20Sopenharmony_ci					       int bpp_sel)
4258c2ecf20Sopenharmony_ci{
4268c2ecf20Sopenharmony_ci	return 0;
4278c2ecf20Sopenharmony_ci}
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_debug_enter(struct fb_info *info)
4308c2ecf20Sopenharmony_ci{
4318c2ecf20Sopenharmony_ci	return 0;
4328c2ecf20Sopenharmony_ci}
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_cistatic inline int drm_fb_helper_debug_leave(struct fb_info *info)
4358c2ecf20Sopenharmony_ci{
4368c2ecf20Sopenharmony_ci	return 0;
4378c2ecf20Sopenharmony_ci}
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_lastclose(struct drm_device *dev)
4408c2ecf20Sopenharmony_ci{
4418c2ecf20Sopenharmony_ci}
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic inline void drm_fb_helper_output_poll_changed(struct drm_device *dev)
4448c2ecf20Sopenharmony_ci{
4458c2ecf20Sopenharmony_ci}
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_cistatic inline void
4488c2ecf20Sopenharmony_cidrm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
4498c2ecf20Sopenharmony_ci{
4508c2ecf20Sopenharmony_ci}
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci#endif
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci/**
4558c2ecf20Sopenharmony_ci * drm_fb_helper_remove_conflicting_framebuffers - remove firmware-configured framebuffers
4568c2ecf20Sopenharmony_ci * @a: memory range, users of which are to be removed
4578c2ecf20Sopenharmony_ci * @name: requesting driver name
4588c2ecf20Sopenharmony_ci * @primary: also kick vga16fb if present
4598c2ecf20Sopenharmony_ci *
4608c2ecf20Sopenharmony_ci * This function removes framebuffer devices (initialized by firmware/bootloader)
4618c2ecf20Sopenharmony_ci * which use memory range described by @a. If @a is NULL all such devices are
4628c2ecf20Sopenharmony_ci * removed.
4638c2ecf20Sopenharmony_ci */
4648c2ecf20Sopenharmony_cistatic inline int
4658c2ecf20Sopenharmony_cidrm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
4668c2ecf20Sopenharmony_ci					      const char *name, bool primary)
4678c2ecf20Sopenharmony_ci{
4688c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_FB)
4698c2ecf20Sopenharmony_ci	return remove_conflicting_framebuffers(a, name, primary);
4708c2ecf20Sopenharmony_ci#else
4718c2ecf20Sopenharmony_ci	return 0;
4728c2ecf20Sopenharmony_ci#endif
4738c2ecf20Sopenharmony_ci}
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci/**
4768c2ecf20Sopenharmony_ci * drm_fb_helper_remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices
4778c2ecf20Sopenharmony_ci * @pdev: PCI device
4788c2ecf20Sopenharmony_ci * @name: requesting driver name
4798c2ecf20Sopenharmony_ci *
4808c2ecf20Sopenharmony_ci * This function removes framebuffer devices (eg. initialized by firmware)
4818c2ecf20Sopenharmony_ci * using memory range configured for any of @pdev's memory bars.
4828c2ecf20Sopenharmony_ci *
4838c2ecf20Sopenharmony_ci * The function assumes that PCI device with shadowed ROM drives a primary
4848c2ecf20Sopenharmony_ci * display and so kicks out vga16fb.
4858c2ecf20Sopenharmony_ci */
4868c2ecf20Sopenharmony_cistatic inline int
4878c2ecf20Sopenharmony_cidrm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
4888c2ecf20Sopenharmony_ci						  const char *name)
4898c2ecf20Sopenharmony_ci{
4908c2ecf20Sopenharmony_ci	int ret = 0;
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci	/*
4938c2ecf20Sopenharmony_ci	 * WARNING: Apparently we must kick fbdev drivers before vgacon,
4948c2ecf20Sopenharmony_ci	 * otherwise the vga fbdev driver falls over.
4958c2ecf20Sopenharmony_ci	 */
4968c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_FB)
4978c2ecf20Sopenharmony_ci	ret = remove_conflicting_pci_framebuffers(pdev, name);
4988c2ecf20Sopenharmony_ci#endif
4998c2ecf20Sopenharmony_ci	if (ret == 0)
5008c2ecf20Sopenharmony_ci		ret = vga_remove_vgacon(pdev);
5018c2ecf20Sopenharmony_ci	return ret;
5028c2ecf20Sopenharmony_ci}
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci#endif
505