1219820Sjeff/* 2219820Sjeff * Copyright (c) 2006-2009 Red Hat Inc. 3219820Sjeff * Copyright (c) 2006-2008 Intel Corporation 4219820Sjeff * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> 5219820Sjeff * 6219820Sjeff * DRM framebuffer helper functions 7219820Sjeff * 8219820Sjeff * Permission to use, copy, modify, distribute, and sell this software and its 9219820Sjeff * documentation for any purpose is hereby granted without fee, provided that 10219820Sjeff * the above copyright notice appear in all copies and that both that copyright 11219820Sjeff * notice and this permission notice appear in supporting documentation, and 12219820Sjeff * that the name of the copyright holders not be used in advertising or 13219820Sjeff * publicity pertaining to distribution of the software without specific, 14219820Sjeff * written prior permission. The copyright holders make no representations 15219820Sjeff * about the suitability of this software for any purpose. It is provided "as 16219820Sjeff * is" without express or implied warranty. 17219820Sjeff * 18219820Sjeff * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19219820Sjeff * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 20219820Sjeff * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 21219820Sjeff * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 22219820Sjeff * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 23219820Sjeff * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24219820Sjeff * OF THIS SOFTWARE. 25219820Sjeff * 26219820Sjeff * Authors: 27219820Sjeff * Dave Airlie <airlied@linux.ie> 28219820Sjeff * Jesse Barnes <jesse.barnes@intel.com> 29219820Sjeff * 30219820Sjeff * $FreeBSD$ 31219820Sjeff */ 32219820Sjeff#ifndef DRM_FB_HELPER_H 33219820Sjeff#define DRM_FB_HELPER_H 34219820Sjeff 35219820Sjeffstruct drm_fb_helper; 36219820Sjeff 37219820Sjeffstruct drm_fb_helper_crtc { 38219820Sjeff uint32_t crtc_id; 39219820Sjeff struct drm_mode_set mode_set; 40219820Sjeff struct drm_display_mode *desired_mode; 41219820Sjeff}; 42219820Sjeff 43219820Sjeff/* mode specified on the command line */ 44219820Sjeffstruct drm_fb_helper_cmdline_mode { 45219820Sjeff bool specified; 46219820Sjeff bool refresh_specified; 47219820Sjeff bool bpp_specified; 48219820Sjeff int xres, yres; 49219820Sjeff int bpp; 50219820Sjeff int refresh; 51219820Sjeff bool rb; 52219820Sjeff bool interlace; 53219820Sjeff bool cvt; 54219820Sjeff bool margins; 55219820Sjeff}; 56219820Sjeff 57219820Sjeffstruct drm_fb_helper_surface_size { 58219820Sjeff u32 fb_width; 59219820Sjeff u32 fb_height; 60219820Sjeff u32 surface_width; 61219820Sjeff u32 surface_height; 62219820Sjeff u32 surface_bpp; 63219820Sjeff u32 surface_depth; 64219820Sjeff}; 65219820Sjeff 66219820Sjeffstruct drm_fb_helper_funcs { 67219820Sjeff void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green, 68219820Sjeff u16 blue, int regno); 69219820Sjeff void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green, 70219820Sjeff u16 *blue, int regno); 71219820Sjeff 72219820Sjeff int (*fb_probe)(struct drm_fb_helper *helper, 73219820Sjeff struct drm_fb_helper_surface_size *sizes); 74219820Sjeff}; 75219820Sjeff 76219820Sjeffstruct drm_fb_helper_connector { 77219820Sjeff struct drm_fb_helper_cmdline_mode cmdline_mode; 78219820Sjeff struct drm_cmdline_mode cmdline_mode1; 79219820Sjeff struct drm_connector *connector; 80219820Sjeff}; 81219820Sjeff 82219820Sjeffstruct drm_fb_helper { 83219820Sjeff struct drm_framebuffer *fb; 84219820Sjeff struct drm_framebuffer *saved_fb; 85219820Sjeff struct drm_device *dev; 86219820Sjeff struct drm_display_mode *mode; 87219820Sjeff int crtc_count; 88219820Sjeff struct drm_fb_helper_crtc *crtc_info; 89219820Sjeff int connector_count; 90219820Sjeff struct drm_fb_helper_connector **connector_info; 91219820Sjeff struct drm_fb_helper_funcs *funcs; 92219820Sjeff int conn_limit; 93219820Sjeff struct fb_info *fbdev; 94219820Sjeff u32 pseudo_palette[17]; 95219820Sjeff struct list_head kernel_fb_list; 96219820Sjeff 97219820Sjeff /* we got a hotplug but fbdev wasn't running the console 98219820Sjeff delay until next set_par */ 99219820Sjeff bool delayed_hotplug; 100219820Sjeff}; 101219820Sjeff 102219820Sjeffstruct fb_var_screeninfo; 103219820Sjeffstruct fb_cmap; 104219820Sjeff 105219820Sjeffint drm_fb_helper_single_fb_probe(struct drm_fb_helper *helper, 106219820Sjeff int preferred_bpp); 107219820Sjeff 108219820Sjeffint drm_fb_helper_init(struct drm_device *dev, 109219820Sjeff struct drm_fb_helper *helper, int crtc_count, 110219820Sjeff int max_conn); 111219820Sjeffvoid drm_fb_helper_fini(struct drm_fb_helper *helper); 112219820Sjeffint drm_fb_helper_blank(int blank, struct fb_info *info); 113219820Sjeffint drm_fb_helper_pan_display(struct fb_var_screeninfo *var, 114219820Sjeff struct fb_info *info); 115219820Sjeffint drm_fb_helper_set_par(struct fb_info *info); 116219820Sjeffint drm_fb_helper_check_var(struct fb_var_screeninfo *var, 117219820Sjeff struct fb_info *info); 118219820Sjeffint drm_fb_helper_setcolreg(unsigned regno, 119219820Sjeff unsigned red, 120219820Sjeff unsigned green, 121219820Sjeff unsigned blue, 122219820Sjeff unsigned transp, 123219820Sjeff struct fb_info *info); 124219820Sjeff 125219820Sjeffbool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper); 126219820Sjeffvoid drm_fb_helper_restore(void); 127219820Sjeffvoid drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, 128219820Sjeff uint32_t fb_width, uint32_t fb_height); 129219820Sjeffvoid drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 130219820Sjeff uint32_t depth); 131219820Sjeff 132219820Sjeffint drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); 133219820Sjeff 134219820Sjeffint drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); 135219820Sjeffbool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); 136219820Sjeffint drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper); 137219820Sjeffint drm_fb_helper_debug_enter(struct fb_info *info); 138219820Sjeffint drm_fb_helper_debug_leave(struct fb_info *info); 139219820Sjeffbool drm_fb_helper_force_kernel_mode(void); 140219820Sjeff 141219820Sjeff#endif 142219820Sjeff