Module Name: src Committed By: riastradh Date: Sun Sep 8 16:38:51 UTC 2013
Modified Files: src/sys/external/bsd/drm2/dist/drm [riastradh-drm2]: drm_fb_helper.c src/sys/external/bsd/drm2/dist/drm/i915 [riastradh-drm2]: intel_display.c intel_drv.h src/sys/external/bsd/drm2/dist/include/drm [riastradh-drm2]: drm_fb_helper.h src/sys/external/bsd/drm2/i915drm [riastradh-drm2]: intel_fb.c src/sys/modules/drm2 [riastradh-drm2]: Makefile Log Message: Round of hacking on i915 framebuffers. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 \ src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c cvs rdiff -u -r1.1.1.1.2.8 -r1.1.1.1.2.9 \ src/sys/external/bsd/drm2/dist/drm/i915/intel_display.c cvs rdiff -u -r1.1.1.1.2.4 -r1.1.1.1.2.5 \ src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h cvs rdiff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 \ src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/i915drm/intel_fb.c cvs rdiff -u -r1.1.2.41 -r1.1.2.42 src/sys/modules/drm2/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c diff -u src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.1.1.1.2.2 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.1.1.1.2.3 --- src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.1.1.1.2.2 Tue Jul 23 21:28:21 2013 +++ src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c Sun Sep 8 16:38:51 2013 @@ -34,6 +34,12 @@ #include <linux/slab.h> #include <linux/fb.h> #include <linux/module.h> +#include <linux/device.h> +#include <linux/export.h> +#include <linux/list.h> +#include <linux/notifier.h> +#include <linux/printk.h> +#include <linux/sysrq.h> #include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> @@ -43,7 +49,12 @@ MODULE_AUTHOR("David Airlie, Jesse Barne MODULE_DESCRIPTION("DRM KMS helper"); MODULE_LICENSE("GPL and additional rights"); +#ifdef __NetBSD__ /* XXX LIST_HEAD means something else */ +static struct list_head kernel_fb_helper_list = + LIST_HEAD_INIT(kernel_fb_helper_list); +#else static LIST_HEAD(kernel_fb_helper_list); +#endif /** * DOC: fbdev helpers @@ -82,6 +93,7 @@ fail: } EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors); +#ifndef __NetBSD__ /* XXX fb command line */ static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper) { struct drm_fb_helper_connector *fb_helper_conn; @@ -135,7 +147,9 @@ static int drm_fb_helper_parse_command_l } return 0; } +#endif +#ifndef __NetBSD__ /* XXX fb info */ static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper) { uint16_t *r_base, *g_base, *b_base; @@ -238,6 +252,7 @@ int drm_fb_helper_debug_leave(struct fb_ return 0; } EXPORT_SYMBOL(drm_fb_helper_debug_leave); +#endif bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper) { @@ -272,7 +287,7 @@ static bool drm_fb_helper_force_kernel_m return error; } -int drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed, +static int drm_fb_helper_panic(struct notifier_block *n, unsigned long ununsed, void *panic_str) { /* @@ -323,9 +338,10 @@ static struct sysrq_key_op sysrq_drm_fb_ .action_msg = "Restore framebuffer console", }; #else -static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; +static struct sysrq_key_op sysrq_drm_fb_helper_restore_op; #endif +#ifndef __NetBSD__ /* XXX fb info */ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) { struct drm_fb_helper *fb_helper = info->par; @@ -382,6 +398,7 @@ int drm_fb_helper_blank(int blank, struc return 0; } EXPORT_SYMBOL(drm_fb_helper_blank); +#endif static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper) { @@ -462,6 +479,7 @@ void drm_fb_helper_fini(struct drm_fb_he } EXPORT_SYMBOL(drm_fb_helper_fini); +#ifndef __NetBSD__ /* XXX fb info */ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, u16 blue, u16 regno, struct fb_info *info) { @@ -656,22 +674,17 @@ int drm_fb_helper_check_var(struct fb_va return 0; } EXPORT_SYMBOL(drm_fb_helper_check_var); +#endif /* this will let fbcon do the mode init */ -int drm_fb_helper_set_par(struct fb_info *info) +static int +drm_fb_helper_set_config(struct drm_fb_helper *fb_helper) { - struct drm_fb_helper *fb_helper = info->par; struct drm_device *dev = fb_helper->dev; - struct fb_var_screeninfo *var = &info->var; struct drm_crtc *crtc; int ret; int i; - if (var->pixclock != 0) { - DRM_ERROR("PIXEL CLOCK SET\n"); - return -EINVAL; - } - mutex_lock(&dev->mode_config.mutex); for (i = 0; i < fb_helper->crtc_count; i++) { crtc = fb_helper->crtc_info[i].mode_set.crtc; @@ -689,6 +702,20 @@ int drm_fb_helper_set_par(struct fb_info } return 0; } + +#ifndef __NetBSD__ +int drm_fb_helper_set_par(struct fb_info *info) +{ + struct drm_fb_helper *fb_helper = info->par; + struct fb_var_screeninfo *var = &info->var; + + if (var->pixclock != 0) { + DRM_ERROR("PIXEL CLOCK SET\n"); + return -EINVAL; + } + + return drm_fb_helper_set_config(fb_helper); +} EXPORT_SYMBOL(drm_fb_helper_set_par); int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, @@ -722,6 +749,7 @@ int drm_fb_helper_pan_display(struct fb_ return ret; } EXPORT_SYMBOL(drm_fb_helper_pan_display); +#endif int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, int preferred_bpp) @@ -729,7 +757,9 @@ int drm_fb_helper_single_fb_probe(struct int new_fb = 0; int crtc_count = 0; int i; +#ifndef __NetBSD__ /* XXX fb info */ struct fb_info *info; +#endif struct drm_fb_helper_surface_size sizes; int gamma_size = 0; @@ -808,13 +838,16 @@ int drm_fb_helper_single_fb_probe(struct if (new_fb < 0) return new_fb; +#ifndef __NetBSD__ /* XXX fb info */ info = fb_helper->fbdev; +#endif /* set the fb pointer */ for (i = 0; i < fb_helper->crtc_count; i++) fb_helper->crtc_info[i].mode_set.fb = fb_helper->fb; if (new_fb) { +#ifndef __NetBSD__ /* XXX fb info */ info->var.pixclock = 0; if (register_framebuffer(info) < 0) return -EINVAL; @@ -822,8 +855,13 @@ int drm_fb_helper_single_fb_probe(struct dev_info(fb_helper->dev->dev, "fb%d: %s frame buffer device\n", info->node, info->fix.id); +#endif } else { +#ifdef __NetBSD__ /* XXX fb info */ + drm_fb_helper_set_config(fb_helper); +#else drm_fb_helper_set_par(info); +#endif } /* Switch back to kernel console on panic */ @@ -841,6 +879,7 @@ int drm_fb_helper_single_fb_probe(struct } EXPORT_SYMBOL(drm_fb_helper_single_fb_probe); +#ifndef __NetBSD__ /* XXX fb info */ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, uint32_t depth) { @@ -934,6 +973,7 @@ void drm_fb_helper_fill_var(struct fb_in info->var.yres = fb_height; } EXPORT_SYMBOL(drm_fb_helper_fill_var); +#endif static int drm_fb_helper_probe_connector_modes(struct drm_fb_helper *fb_helper, uint32_t maxX, @@ -975,6 +1015,9 @@ static bool drm_has_cmdline_mode(struct static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn, int width, int height) { +#ifdef __NetBSD__ /* XXX fb command line */ + return NULL; +#else struct drm_cmdline_mode *cmdline_mode; struct drm_display_mode *mode = NULL; @@ -1011,6 +1054,7 @@ create_mode: cmdline_mode); list_add(&mode->head, &fb_helper_conn->connector->modes); return mode; +#endif } static bool drm_connector_enabled(struct drm_connector *connector, bool strict) @@ -1333,7 +1377,9 @@ bool drm_fb_helper_initial_config(struct /* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions(fb_helper->dev); +#ifndef __NetBSD__ /* XXX fb command line */ drm_fb_helper_parse_command_line(fb_helper); +#endif count = drm_fb_helper_probe_connector_modes(fb_helper, dev->mode_config.max_width, Index: src/sys/external/bsd/drm2/dist/drm/i915/intel_display.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_display.c:1.1.1.1.2.8 src/sys/external/bsd/drm2/dist/drm/i915/intel_display.c:1.1.1.1.2.9 --- src/sys/external/bsd/drm2/dist/drm/i915/intel_display.c:1.1.1.1.2.8 Wed Jul 24 03:39:23 2013 +++ src/sys/external/bsd/drm2/dist/drm/i915/intel_display.c Sun Sep 8 16:38:51 2013 @@ -2240,13 +2240,6 @@ intel_pipe_set_base_atomic(struct drm_cr return dev_priv->display.update_plane(crtc, fb, x, y); } -#ifdef __NetBSD__ /* XXX fb */ -static int -intel_finish_fb(struct drm_framebuffer *old_fb __unused) -{ - return 0; -} -#else static int intel_finish_fb(struct drm_framebuffer *old_fb) { @@ -2255,9 +2248,20 @@ intel_finish_fb(struct drm_framebuffer * bool was_interruptible = dev_priv->mm.interruptible; int ret; +#ifdef __NetBSD__ /* XXX DRM_WAIT_UNINTERRUPTIBLE_UNTIL */ + mutex_lock(&dev_priv->pending_flip_lock); + do { + DRM_WAIT_UNTIL(ret, &dev_priv->pending_flip_queue, + &dev_priv->pending_flip_lock, + (atomic_read(&dev_priv->mm.wedged) || + atomic_read(&obj->pending_flip) == 0)); + } while (ret); + mutex_unlock(&dev_priv->pending_flip_lock); +#else wait_event(dev_priv->pending_flip_queue, atomic_read(&dev_priv->mm.wedged) || atomic_read(&obj->pending_flip) == 0); +#endif /* Big Hammer, we also need to ensure that any pending * MI_WAIT_FOR_EVENT inside a user batch buffer on the @@ -2273,7 +2277,6 @@ intel_finish_fb(struct drm_framebuffer * return ret; } -#endif static void intel_crtc_update_sarea_pos(struct drm_crtc *crtc, int x, int y) { @@ -6638,38 +6641,36 @@ intel_framebuffer_create(struct drm_devi return &intel_fb->base; } -#ifndef __NetBSD__ /* XXX fb */ static u32 intel_framebuffer_pitch_for_width(int width, int bpp) { u32 pitch = DIV_ROUND_UP(width * bpp, 8); +#ifdef __NetBSD__ /* XXX ALIGN already means something. */ + return round_up(pitch, 64); +#else return ALIGN(pitch, 64); +#endif } static u32 intel_framebuffer_size_for_mode(struct drm_display_mode *mode, int bpp) { u32 pitch = intel_framebuffer_pitch_for_width(mode->hdisplay, bpp); +#ifdef __NetBSD__ /* XXX ALIGN already means something. */ + return round_up(pitch * mode->vdisplay, PAGE_SIZE); +#else return ALIGN(pitch * mode->vdisplay, PAGE_SIZE); -} #endif - -#ifdef __NetBSD__ /* XXX fb */ -static struct drm_framebuffer * -intel_framebuffer_create_for_mode(struct drm_device *dev __unused, - struct drm_display_mode *mode __unused, - int depth __unused, int bpp __unused) -{ - return NULL; } -#else + static struct drm_framebuffer * intel_framebuffer_create_for_mode(struct drm_device *dev, struct drm_display_mode *mode, int depth, int bpp) { struct drm_i915_gem_object *obj; - struct drm_mode_fb_cmd2 mode_cmd = { 0 }; + static const struct drm_mode_fb_cmd2 zero_mode_cmd; + struct drm_mode_fb_cmd2 mode_cmd = zero_mode_cmd; obj = i915_gem_alloc_object(dev, intel_framebuffer_size_for_mode(mode, bpp)); @@ -6684,16 +6685,7 @@ intel_framebuffer_create_for_mode(struct return intel_framebuffer_create(dev, &mode_cmd, obj); } -#endif -#ifdef __NetBSD__ /* XXX fb */ -static struct drm_framebuffer * -mode_fits_in_fbdev(struct drm_device *dev __unused, - struct drm_display_mode *mode __unused) -{ - return NULL; -} -#else static struct drm_framebuffer * mode_fits_in_fbdev(struct drm_device *dev, struct drm_display_mode *mode) @@ -6719,7 +6711,6 @@ mode_fits_in_fbdev(struct drm_device *de return fb; } -#endif bool intel_get_load_detect_pipe(struct drm_connector *connector, struct drm_display_mode *mode, Index: src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h:1.1.1.1.2.4 src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h:1.1.1.1.2.5 --- src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h:1.1.1.1.2.4 Wed Jul 24 03:11:21 2013 +++ src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h Sun Sep 8 16:38:51 2013 @@ -31,9 +31,7 @@ #include "i915_drv.h" #include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> -#ifndef __NetBSD__ #include <drm/drm_fb_helper.h> -#endif #include <drm/drm_dp_helper.h> #define _wait_for(COND, MS, W) ({ \ @@ -132,14 +130,12 @@ struct intel_framebuffer { struct drm_i915_gem_object *obj; }; -#ifndef __NetBSD__ /* XXX fb */ struct intel_fbdev { struct drm_fb_helper helper; struct intel_framebuffer ifb; struct list_head fbdev_list; struct drm_display_mode *our_mode; }; -#endif struct intel_encoder { struct drm_encoder base; Index: src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h diff -u src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h:1.1.1.1.2.2 src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h:1.1.1.1.2.3 --- src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h:1.1.1.1.2.2 Tue Jul 23 21:28:23 2013 +++ src/sys/external/bsd/drm2/dist/include/drm/drm_fb_helper.h Sun Sep 8 16:38:51 2013 @@ -73,7 +73,9 @@ struct drm_fb_helper { int connector_count; struct drm_fb_helper_connector **connector_info; struct drm_fb_helper_funcs *funcs; +#ifndef __NetBSD__ /* XXX fb info */ struct fb_info *fbdev; +#endif u32 pseudo_palette[17]; struct list_head kernel_fb_list; @@ -89,6 +91,7 @@ int drm_fb_helper_init(struct drm_device struct drm_fb_helper *helper, int crtc_count, int max_conn); void drm_fb_helper_fini(struct drm_fb_helper *helper); +#ifndef __NetBSD__ /* XXX fb info */ int drm_fb_helper_blank(int blank, struct fb_info *info); int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); @@ -101,20 +104,27 @@ int drm_fb_helper_setcolreg(unsigned reg unsigned blue, unsigned transp, struct fb_info *info); +#endif bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper); void drm_fb_helper_restore(void); +#ifndef __NetBSD__ /* XXX fb info */ void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, uint32_t fb_width, uint32_t fb_height); void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, uint32_t depth); +#endif +#ifndef __NetBSD__ /* XXX fb cmap */ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); +#endif int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper); +#ifndef __NetBSD__ /* XXX fb info */ int drm_fb_helper_debug_enter(struct fb_info *info); int drm_fb_helper_debug_leave(struct fb_info *info); +#endif #endif Index: src/sys/external/bsd/drm2/i915drm/intel_fb.c diff -u src/sys/external/bsd/drm2/i915drm/intel_fb.c:1.1.2.1 src/sys/external/bsd/drm2/i915drm/intel_fb.c:1.1.2.2 --- src/sys/external/bsd/drm2/i915drm/intel_fb.c:1.1.2.1 Wed Jul 24 03:52:13 2013 +++ src/sys/external/bsd/drm2/i915drm/intel_fb.c Sun Sep 8 16:38:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: intel_fb.c,v 1.1.2.1 2013/07/24 03:52:13 riastradh Exp $ */ +/* $NetBSD: intel_fb.c,v 1.1.2.2 2013/09/08 16:38:51 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -32,17 +32,37 @@ /* intel_fb.c stubs */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: intel_fb.c,v 1.1.2.1 2013/07/24 03:52:13 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intel_fb.c,v 1.1.2.2 2013/09/08 16:38:51 riastradh Exp $"); + +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> #include "i915_drv.h" +#include "intel_drv.h" void intel_fb_output_poll_changed(struct drm_device *dev __unused) { + struct drm_i915_private *const dev_priv = dev->dev_private; + + drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper); } void intel_fb_restore_mode(struct drm_device *dev __unused) { -} + struct drm_i915_private *const dev_priv = dev->dev_private; + struct drm_plane *plane; + int ret; + + mutex_lock(&dev->mode_config.mutex); + ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper); + if (ret) + DRM_ERROR("failed to restore fbdev mode: %d\n", ret); + + list_for_each_entry(plane, &dev->mode_config.plane_list, head) + (*plane->funcs->disable_plane)(plane); + + mutex_unlock(&dev->mode_config.mutex); +} Index: src/sys/modules/drm2/Makefile diff -u src/sys/modules/drm2/Makefile:1.1.2.41 src/sys/modules/drm2/Makefile:1.1.2.42 --- src/sys/modules/drm2/Makefile:1.1.2.41 Sun Sep 8 16:11:29 2013 +++ src/sys/modules/drm2/Makefile Sun Sep 8 16:38:51 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1.2.41 2013/09/08 16:11:29 riastradh Exp $ +# $NetBSD: Makefile,v 1.1.2.42 2013/09/08 16:38:51 riastradh Exp $ .include "../Makefile.inc" .include "Makefile.inc" @@ -25,7 +25,7 @@ SRCS+= drm_dp_helper.c SRCS+= drm_drv.c SRCS+= drm_edid.c #SRCS+= drm_encoder_slave.c # XXX Rewrite for i2c. -#SRCS+= drm_fb_helper.c # XXX Rewrite for wsconsole. +SRCS+= drm_fb_helper.c # XXX Rewrite for wsconsole. SRCS+= drm_fops.c SRCS+= drm_gem.c SRCS+= drm_global.c