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 37b0ee9e7fSDave Airlie struct drm_fb_offset { 38b0ee9e7fSDave Airlie int x, y; 39b0ee9e7fSDave Airlie }; 40b0ee9e7fSDave Airlie 41785b93efSDave Airlie struct drm_fb_helper_crtc { 42785b93efSDave Airlie struct drm_mode_set mode_set; 438be48d92SDave Airlie struct drm_display_mode *desired_mode; 44b0ee9e7fSDave Airlie int x, y; 45785b93efSDave Airlie }; 46785b93efSDave Airlie 4738651674SDave Airlie struct drm_fb_helper_surface_size { 4838651674SDave Airlie u32 fb_width; 4938651674SDave Airlie u32 fb_height; 5038651674SDave Airlie u32 surface_width; 5138651674SDave Airlie u32 surface_height; 5238651674SDave Airlie u32 surface_bpp; 5338651674SDave Airlie u32 surface_depth; 5438651674SDave Airlie }; 5538651674SDave Airlie 56207fd329SDaniel Vetter /** 57207fd329SDaniel Vetter * struct drm_fb_helper_funcs - driver callbacks for the fbdev emulation library 587b97936fSVille Syrjälä * @gamma_set: Set the given gamma lut register on the given crtc. 597b97936fSVille Syrjälä * @gamma_get: Read the given gamma lut register on the given crtc, used to 60207fd329SDaniel Vetter * save the current lut when force-restoring the fbdev for e.g. 61207fd329SDaniel Vetter * kdbg. 627b97936fSVille Syrjälä * @fb_probe: Driver callback to allocate and initialize the fbdev info 63e227867fSMasanari Iida * structure. Furthermore it also needs to allocate the drm 64207fd329SDaniel Vetter * framebuffer used to back the fbdev. 657b97936fSVille Syrjälä * @initial_config: Setup an initial fbdev display configuration 66207fd329SDaniel Vetter * 67207fd329SDaniel Vetter * Driver callbacks used by the fbdev emulation helper library. 68207fd329SDaniel Vetter */ 694abe3520SDave Airlie struct drm_fb_helper_funcs { 704abe3520SDave Airlie void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green, 714abe3520SDave Airlie u16 blue, int regno); 724abe3520SDave Airlie void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green, 734abe3520SDave Airlie u16 *blue, int regno); 744abe3520SDave Airlie 754abe3520SDave Airlie int (*fb_probe)(struct drm_fb_helper *helper, 764abe3520SDave Airlie struct drm_fb_helper_surface_size *sizes); 7711e17a08SJesse Barnes bool (*initial_config)(struct drm_fb_helper *fb_helper, 7811e17a08SJesse Barnes struct drm_fb_helper_crtc **crtcs, 7911e17a08SJesse Barnes struct drm_display_mode **modes, 80b0ee9e7fSDave Airlie struct drm_fb_offset *offsets, 8111e17a08SJesse Barnes bool *enabled, int width, int height); 824abe3520SDave Airlie }; 834abe3520SDave Airlie 84d50ba256SDave Airlie struct drm_fb_helper_connector { 850b4c0f3fSDave Airlie struct drm_connector *connector; 86d50ba256SDave Airlie }; 87d50ba256SDave Airlie 88785b93efSDave Airlie struct drm_fb_helper { 89785b93efSDave Airlie struct drm_framebuffer *fb; 90785b93efSDave Airlie struct drm_device *dev; 91785b93efSDave Airlie int crtc_count; 92785b93efSDave Airlie struct drm_fb_helper_crtc *crtc_info; 930b4c0f3fSDave Airlie int connector_count; 9465c2a89cSDave Airlie int connector_info_alloc_count; 950b4c0f3fSDave Airlie struct drm_fb_helper_connector **connector_info; 963a493879SThierry Reding const struct drm_fb_helper_funcs *funcs; 9738651674SDave Airlie struct fb_info *fbdev; 9838651674SDave Airlie u32 pseudo_palette[17]; 99785b93efSDave Airlie struct list_head kernel_fb_list; 1008be48d92SDave Airlie 1014abe3520SDave Airlie /* we got a hotplug but fbdev wasn't running the console 1024abe3520SDave Airlie delay until next set_par */ 1034abe3520SDave Airlie bool delayed_hotplug; 104785b93efSDave Airlie }; 105785b93efSDave Airlie 10610a23102SThierry Reding void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, 10710a23102SThierry Reding const struct drm_fb_helper_funcs *funcs); 1084abe3520SDave Airlie int drm_fb_helper_init(struct drm_device *dev, 1098be48d92SDave Airlie struct drm_fb_helper *helper, int crtc_count, 110eb1f8e4fSDave Airlie int max_conn); 1114abe3520SDave Airlie void drm_fb_helper_fini(struct drm_fb_helper *helper); 112785b93efSDave Airlie int drm_fb_helper_blank(int blank, struct fb_info *info); 113785b93efSDave Airlie int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, 114785b93efSDave Airlie struct fb_info *info); 115785b93efSDave Airlie int drm_fb_helper_set_par(struct fb_info *info); 116785b93efSDave Airlie int drm_fb_helper_check_var(struct fb_var_screeninfo *var, 117785b93efSDave Airlie struct fb_info *info); 118785b93efSDave Airlie 1195ea1f752SRob Clark bool drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper); 12038651674SDave Airlie void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, 121785b93efSDave Airlie uint32_t fb_width, uint32_t fb_height); 1223632ef89SDave Airlie void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 1233632ef89SDave Airlie uint32_t depth); 1243632ef89SDave Airlie 125068143d3SDave Airlie int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); 126d50ba256SDave Airlie 1277394371dSChris Wilson int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); 12801934c2aSThierry Reding int drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); 1290b4c0f3fSDave Airlie int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper); 1301a7aba7fSJesse Barnes int drm_fb_helper_debug_enter(struct fb_info *info); 1311a7aba7fSJesse Barnes int drm_fb_helper_debug_leave(struct fb_info *info); 1322f1046f3SJesse Barnes struct drm_display_mode * 1332f1046f3SJesse Barnes drm_has_preferred_mode(struct drm_fb_helper_connector *fb_connector, 1342f1046f3SJesse Barnes int width, int height); 1352f1046f3SJesse Barnes struct drm_display_mode * 1362f1046f3SJesse Barnes drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn, 1372f1046f3SJesse Barnes int width, int height); 1388be48d92SDave Airlie 13965c2a89cSDave Airlie int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector); 14065c2a89cSDave Airlie int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, 14165c2a89cSDave Airlie struct drm_connector *connector); 142785b93efSDave Airlie #endif 143