xref: /openbmc/linux/include/drm/drm_fb_helper.h (revision 11e17a08)
1785b93efSDave Airlie /*
2785b93efSDave Airlie  * Copyright (c) 2006-2009 Red Hat Inc.
3785b93efSDave Airlie  * Copyright (c) 2006-2008 Intel Corporation
4785b93efSDave Airlie  * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
5785b93efSDave Airlie  *
6785b93efSDave Airlie  * DRM framebuffer helper functions
7785b93efSDave Airlie  *
8785b93efSDave Airlie  * Permission to use, copy, modify, distribute, and sell this software and its
9785b93efSDave Airlie  * documentation for any purpose is hereby granted without fee, provided that
10785b93efSDave Airlie  * the above copyright notice appear in all copies and that both that copyright
11785b93efSDave Airlie  * notice and this permission notice appear in supporting documentation, and
12785b93efSDave Airlie  * that the name of the copyright holders not be used in advertising or
13785b93efSDave Airlie  * publicity pertaining to distribution of the software without specific,
14785b93efSDave Airlie  * written prior permission.  The copyright holders make no representations
15785b93efSDave Airlie  * about the suitability of this software for any purpose.  It is provided "as
16785b93efSDave Airlie  * is" without express or implied warranty.
17785b93efSDave Airlie  *
18785b93efSDave Airlie  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19785b93efSDave Airlie  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20785b93efSDave Airlie  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21785b93efSDave Airlie  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22785b93efSDave Airlie  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23785b93efSDave Airlie  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24785b93efSDave Airlie  * OF THIS SOFTWARE.
25785b93efSDave Airlie  *
26785b93efSDave Airlie  * Authors:
27785b93efSDave Airlie  *      Dave Airlie <airlied@linux.ie>
28785b93efSDave Airlie  *      Jesse Barnes <jesse.barnes@intel.com>
29785b93efSDave Airlie  */
30785b93efSDave Airlie #ifndef DRM_FB_HELPER_H
31785b93efSDave Airlie #define DRM_FB_HELPER_H
32785b93efSDave Airlie 
334abe3520SDave Airlie struct drm_fb_helper;
344abe3520SDave Airlie 
351a7aba7fSJesse Barnes #include <linux/kgdb.h>
361a7aba7fSJesse Barnes 
37785b93efSDave Airlie struct drm_fb_helper_crtc {
38785b93efSDave Airlie 	struct drm_mode_set mode_set;
398be48d92SDave Airlie 	struct drm_display_mode *desired_mode;
40785b93efSDave Airlie };
41785b93efSDave Airlie 
4238651674SDave Airlie struct drm_fb_helper_surface_size {
4338651674SDave Airlie 	u32 fb_width;
4438651674SDave Airlie 	u32 fb_height;
4538651674SDave Airlie 	u32 surface_width;
4638651674SDave Airlie 	u32 surface_height;
4738651674SDave Airlie 	u32 surface_bpp;
4838651674SDave Airlie 	u32 surface_depth;
4938651674SDave Airlie };
5038651674SDave Airlie 
51207fd329SDaniel Vetter /**
52207fd329SDaniel Vetter  * struct drm_fb_helper_funcs - driver callbacks for the fbdev emulation library
53207fd329SDaniel Vetter  * @gamma_set: - Set the given gamma lut register on the given crtc.
54207fd329SDaniel Vetter  * @gamma_get: - Read the given gamma lut register on the given crtc, used to
55207fd329SDaniel Vetter  * 		 save the current lut when force-restoring the fbdev for e.g.
56207fd329SDaniel Vetter  * 		 kdbg.
57207fd329SDaniel Vetter  * @fb_probe: - Driver callback to allocate and initialize the fbdev info
58207fd329SDaniel Vetter  * 		structure. Futhermore it also needs to allocate the drm
59207fd329SDaniel Vetter  * 		framebuffer used to back the fbdev.
60207fd329SDaniel Vetter  *
61207fd329SDaniel Vetter  * Driver callbacks used by the fbdev emulation helper library.
62207fd329SDaniel Vetter  */
634abe3520SDave Airlie struct drm_fb_helper_funcs {
644abe3520SDave Airlie 	void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
654abe3520SDave Airlie 			  u16 blue, int regno);
664abe3520SDave Airlie 	void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
674abe3520SDave Airlie 			  u16 *blue, int regno);
684abe3520SDave Airlie 
694abe3520SDave Airlie 	int (*fb_probe)(struct drm_fb_helper *helper,
704abe3520SDave Airlie 			struct drm_fb_helper_surface_size *sizes);
7111e17a08SJesse Barnes 	bool (*initial_config)(struct drm_fb_helper *fb_helper,
7211e17a08SJesse Barnes 			       struct drm_fb_helper_crtc **crtcs,
7311e17a08SJesse Barnes 			       struct drm_display_mode **modes,
7411e17a08SJesse Barnes 			       bool *enabled, int width, int height);
754abe3520SDave Airlie };
764abe3520SDave Airlie 
77d50ba256SDave Airlie struct drm_fb_helper_connector {
780b4c0f3fSDave Airlie 	struct drm_connector *connector;
791794d257SChris Wilson 	struct drm_cmdline_mode cmdline_mode;
80d50ba256SDave Airlie };
81d50ba256SDave Airlie 
82785b93efSDave Airlie struct drm_fb_helper {
83785b93efSDave Airlie 	struct drm_framebuffer *fb;
84785b93efSDave Airlie 	struct drm_device *dev;
85785b93efSDave Airlie 	int crtc_count;
86785b93efSDave Airlie 	struct drm_fb_helper_crtc *crtc_info;
870b4c0f3fSDave Airlie 	int connector_count;
880b4c0f3fSDave Airlie 	struct drm_fb_helper_connector **connector_info;
89785b93efSDave Airlie 	struct drm_fb_helper_funcs *funcs;
9038651674SDave Airlie 	struct fb_info *fbdev;
9138651674SDave Airlie 	u32 pseudo_palette[17];
92785b93efSDave Airlie 	struct list_head kernel_fb_list;
938be48d92SDave Airlie 
944abe3520SDave Airlie 	/* we got a hotplug but fbdev wasn't running the console
954abe3520SDave Airlie 	   delay until next set_par */
964abe3520SDave Airlie 	bool delayed_hotplug;
97785b93efSDave Airlie };
98785b93efSDave Airlie 
994abe3520SDave Airlie int drm_fb_helper_init(struct drm_device *dev,
1008be48d92SDave Airlie 		       struct drm_fb_helper *helper, int crtc_count,
101eb1f8e4fSDave Airlie 		       int max_conn);
1024abe3520SDave Airlie void drm_fb_helper_fini(struct drm_fb_helper *helper);
103785b93efSDave Airlie int drm_fb_helper_blank(int blank, struct fb_info *info);
104785b93efSDave Airlie int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
105785b93efSDave Airlie 			      struct fb_info *info);
106785b93efSDave Airlie int drm_fb_helper_set_par(struct fb_info *info);
107785b93efSDave Airlie int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
108785b93efSDave Airlie 			    struct fb_info *info);
109785b93efSDave Airlie int drm_fb_helper_setcolreg(unsigned regno,
110785b93efSDave Airlie 			    unsigned red,
111785b93efSDave Airlie 			    unsigned green,
112785b93efSDave Airlie 			    unsigned blue,
113785b93efSDave Airlie 			    unsigned transp,
114785b93efSDave Airlie 			    struct fb_info *info);
115785b93efSDave Airlie 
116e8e7a2b8SDave Airlie bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper);
11738651674SDave Airlie void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper,
118785b93efSDave Airlie 			    uint32_t fb_width, uint32_t fb_height);
1193632ef89SDave Airlie void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
1203632ef89SDave Airlie 			    uint32_t depth);
1213632ef89SDave Airlie 
122068143d3SDave Airlie int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
123d50ba256SDave Airlie 
1247394371dSChris Wilson int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
1254abe3520SDave Airlie bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel);
1260b4c0f3fSDave Airlie int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper);
1271a7aba7fSJesse Barnes int drm_fb_helper_debug_enter(struct fb_info *info);
1281a7aba7fSJesse Barnes int drm_fb_helper_debug_leave(struct fb_info *info);
1298be48d92SDave Airlie 
130785b93efSDave Airlie #endif
131