Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Dec 2013 22:38:54 +0000 (UTC)
From:      Aleksandr Rybalko <ray@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r259016 - in head/sys: conf dev/drm2 dev/drm2/i915 dev/drm2/radeon dev/fb dev/vt kern modules/drm2/i915kms modules/drm2/radeonkms sparc64/sparc64 sys teken
Message-ID:  <201312052238.rB5McsVN020719@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ray
Date: Thu Dec  5 22:38:53 2013
New Revision: 259016
URL: http://svnweb.freebsd.org/changeset/base/259016

Log:
  Merge VT(9) project (a.k.a. newcons).
  
  Reviewed by:	nwhitehorn
  MFC_to_10_after:	re approval
  
  Sponsored by:	The FreeBSD Foundation

Added:
  head/sys/dev/fb/fb_if.m
     - copied unchanged from r259015, user/ed/newcons/sys/dev/fb/fb_if.m
  head/sys/dev/fb/fbd.c
     - copied unchanged from r259015, user/ed/newcons/sys/dev/fb/fbd.c
  head/sys/dev/vt/
     - copied from r259015, user/ed/newcons/sys/dev/vt/
  head/sys/kern/subr_terminal.c
     - copied unchanged from r259015, user/ed/newcons/sys/kern/subr_terminal.c
  head/sys/sys/terminal.h
     - copied unchanged from r259015, user/ed/newcons/sys/sys/terminal.h
Modified:
  head/sys/conf/files
  head/sys/conf/files.amd64
  head/sys/conf/files.arm
  head/sys/conf/files.i386
  head/sys/conf/files.powerpc
  head/sys/conf/files.sparc64
  head/sys/conf/kmod.mk
  head/sys/conf/options
  head/sys/dev/drm2/drm_fb_helper.c
  head/sys/dev/drm2/drm_os_freebsd.h
  head/sys/dev/drm2/i915/i915_drv.c
  head/sys/dev/drm2/i915/intel_fb.c
  head/sys/dev/drm2/radeon/radeon.h
  head/sys/dev/drm2/radeon/radeon_drv.c
  head/sys/dev/drm2/radeon/radeon_fb.c
  head/sys/dev/drm2/radeon/radeon_pm.c
  head/sys/modules/drm2/i915kms/Makefile
  head/sys/modules/drm2/radeonkms/Makefile
  head/sys/sparc64/sparc64/machdep.c
  head/sys/sys/consio.h
  head/sys/sys/eventhandler.h
  head/sys/sys/fbio.h
  head/sys/sys/tty.h
  head/sys/teken/teken.c
  head/sys/teken/teken.h
  head/sys/teken/teken_subr.h
Directory Properties:
  head/sys/   (props changed)
  head/sys/conf/   (props changed)

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/files	Thu Dec  5 22:38:53 2013	(r259016)
@@ -82,7 +82,7 @@ pccarddevs.h			standard				   \
 	compile-with	"${AWK} -f $S/tools/pccarddevs2h.awk $S/dev/pccard/pccarddevs" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"pccarddevs.h"
-teken_state.h		optional sc					   \
+teken_state.h		optional sc | vt				   \
 	dependency	"$S/teken/gensequences $S/teken/sequences" \
 	compile-with	"${AWK} -f $S/teken/gensequences $S/teken/sequences > teken_state.h" \
 	no-obj no-implicit-rule before-depend				   \
@@ -1396,6 +1396,8 @@ dev/ex/if_ex_isa.c		optional ex isa
 dev/ex/if_ex_pccard.c		optional ex pccard
 dev/exca/exca.c			optional cbb
 dev/fatm/if_fatm.c		optional fatm pci
+dev/fb/fbd.c			optional fbd | vt
+dev/fb/fb_if.m			optional fbd | vt
 dev/fb/splash.c			optional splash
 dev/fdt/fdt_common.c		optional fdt
 dev/fdt/fdt_ic_if.m		optional fdt
@@ -2461,6 +2463,17 @@ dev/vge/if_vge.c		optional vge
 
 dev/vkbd/vkbd.c			optional vkbd
 dev/vr/if_vr.c			optional vr pci
+dev/vt/colors/vt_termcolors.c	optional vt
+dev/vt/font/vt_font_default.c	optional vt
+dev/vt/font/vt_mouse_cursor.c	optional vt
+dev/vt/hw/fb/vt_fb.c		optional vt
+dev/vt/hw/vga/vga.c		optional vt vt_vga
+dev/vt/logo/logo_freebsd.c	optional vt
+dev/vt/vt_buf.c			optional vt
+dev/vt/vt_consolectl.c		optional vt
+dev/vt/vt_core.c		optional vt
+dev/vt/vt_font.c		optional vt
+dev/vt/vt_sysmouse.c		optional vt
 dev/vte/if_vte.c		optional vte pci
 dev/vx/if_vx.c			optional vx
 dev/vx/if_vx_eisa.c		optional vx eisa
@@ -2897,6 +2910,7 @@ kern/subr_sleepqueue.c		standard
 kern/subr_smp.c			standard
 kern/subr_stack.c		optional ddb | stack | ktr
 kern/subr_taskqueue.c		standard
+kern/subr_terminal.c		optional vt
 kern/subr_trap.c		standard
 kern/subr_turnstile.c		standard
 kern/subr_uio.c			standard
@@ -3796,7 +3810,7 @@ security/mac_portacl/mac_portacl.c optio
 security/mac_seeotheruids/mac_seeotheruids.c optional mac_seeotheruids
 security/mac_stub/mac_stub.c	optional mac_stub
 security/mac_test/mac_test.c	optional mac_test
-teken/teken.c			optional sc
+teken/teken.c			optional sc | vt
 ufs/ffs/ffs_alloc.c		optional ffs
 ufs/ffs/ffs_balloc.c		optional ffs
 ufs/ffs/ffs_inode.c		optional ffs

Modified: head/sys/conf/files.amd64
==============================================================================
--- head/sys/conf/files.amd64	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/files.amd64	Thu Dec  5 22:38:53 2013	(r259016)
@@ -241,7 +241,7 @@ dev/hyperv/vmbus/hv_connection.c			optio
 dev/hyperv/vmbus/hv_hv.c				optional	hyperv
 dev/hyperv/vmbus/hv_ring_buffer.c			optional	hyperv
 dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c			optional	hyperv
-dev/kbd/kbd.c			optional	atkbd | sc | ukbd
+dev/kbd/kbd.c			optional	atkbd | sc | ukbd | vt
 dev/lindev/full.c		optional	lindev
 dev/lindev/lindev.c		optional	lindev
 dev/nfe/if_nfe.c		optional	nfe pci

Modified: head/sys/conf/files.arm
==============================================================================
--- head/sys/conf/files.arm	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/files.arm	Thu Dec  5 22:38:53 2013	(r259016)
@@ -62,7 +62,7 @@ crypto/blowfish/bf_enc.c	optional	crypto
 crypto/des/des_enc.c		optional	crypto | ipsec | netsmb
 dev/fb/fb.c			optional	sc
 dev/hwpmc/hwpmc_arm.c		optional	hwpmc
-dev/kbd/kbd.c			optional	sc
+dev/kbd/kbd.c			optional	sc | vt
 dev/syscons/scgfbrndr.c		optional	sc
 dev/syscons/scterm-teken.c	optional	sc
 dev/syscons/scvtb.c		optional	sc

Modified: head/sys/conf/files.i386
==============================================================================
--- head/sys/conf/files.i386	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/files.i386	Thu Dec  5 22:38:53 2013	(r259016)
@@ -249,7 +249,7 @@ dev/ipmi/ipmi_smbios.c		optional ipmi
 dev/ipmi/ipmi_ssif.c		optional ipmi smbus
 dev/ipmi/ipmi_pci.c		optional ipmi pci
 dev/ipmi/ipmi_linux.c		optional ipmi compat_linux
-dev/kbd/kbd.c			optional atkbd | sc | ukbd
+dev/kbd/kbd.c			optional atkbd | sc | ukbd | vt
 dev/le/if_le_isa.c		optional le isa
 dev/lindev/full.c		optional lindev
 dev/lindev/lindev.c		optional lindev
@@ -293,6 +293,7 @@ dev/viawd/viawd.c		optional viawd
 dev/vmware/vmxnet3/if_vmx.c	optional vmx
 dev/acpica/acpi_if.m		standard
 dev/acpi_support/acpi_wmi_if.m	standard
+dev/vt/hw/xboxfb/xboxfb.c	optional vt_xboxfb
 dev/wbwd/wbwd.c			optional wbwd
 dev/wpi/if_wpi.c		optional wpi
 dev/isci/isci.c							optional isci

Modified: head/sys/conf/files.powerpc
==============================================================================
--- head/sys/conf/files.powerpc	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/files.powerpc	Thu Dec  5 22:38:53 2013	(r259016)
@@ -35,7 +35,7 @@ dev/iicbus/ad7417.c		optional	ad7417 pow
 dev/iicbus/ds1631.c		optional	ds1631 powermac
 dev/iicbus/ds1775.c		optional	ds1775 powermac
 dev/iicbus/max6690.c		optional	max6690 powermac
-dev/kbd/kbd.c			optional	sc
+dev/kbd/kbd.c			optional	sc | vt
 dev/nand/nfc_fsl.c		optional	nand mpc85xx
 # ofw can be either aim or fdt: fdt case handled in files. aim only powerpc specific.
 dev/ofw/openfirm.c		optional	aim
@@ -65,6 +65,7 @@ dev/tsec/if_tsec.c		optional	tsec
 dev/tsec/if_tsec_fdt.c		optional	tsec fdt
 dev/uart/uart_cpu_powerpc.c	optional	uart
 dev/usb/controller/ehci_fsl.c	optional	ehci mpc85xx
+dev/vt/hw/ofwfb/ofwfb.c		optional	vt aim
 kern/kern_clocksource.c		standard
 kern/subr_dummy_vdso_tc.c	standard
 kern/syscalls.c			optional	ktr

Modified: head/sys/conf/files.sparc64
==============================================================================
--- head/sys/conf/files.sparc64	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/files.sparc64	Thu Dec  5 22:38:53 2013	(r259016)
@@ -39,7 +39,7 @@ dev/fb/fb.c			optional	sc
 dev/fb/gallant12x22.c		optional	sc
 dev/fb/machfb.c			optional	machfb sc
 dev/hwpmc/hwpmc_sparc64.c	optional	hwpmc
-dev/kbd/kbd.c			optional	atkbd | sc | ukbd
+dev/kbd/kbd.c			optional	atkbd | sc | ukbd | vt
 dev/le/if_le_lebuffer.c		optional	le sbus
 dev/le/if_le_ledma.c		optional	le sbus
 dev/le/lebuffer_sbus.c		optional	le sbus
@@ -59,7 +59,8 @@ dev/syscons/scgfbrndr.c		optional	sc
 dev/syscons/scterm-teken.c	optional	sc
 dev/syscons/scvtb.c		optional	sc
 dev/uart/uart_cpu_sparc64.c	optional	uart
-dev/uart/uart_kbd_sun.c		optional	uart sc
+dev/uart/uart_kbd_sun.c		optional	uart sc | vt
+dev/vt/hw/ofwfb/ofwfb.c		optional	vt
 kern/kern_clocksource.c		standard
 kern/subr_dummy_vdso_tc.c	standard
 kern/syscalls.c			optional	ktr

Modified: head/sys/conf/kmod.mk
==============================================================================
--- head/sys/conf/kmod.mk	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/kmod.mk	Thu Dec  5 22:38:53 2013	(r259016)
@@ -340,7 +340,7 @@ CFLAGS+=	${CONF_CFLAGS}
 
 MFILES?= dev/acpica/acpi_if.m dev/acpi_support/acpi_wmi_if.m \
 	dev/agp/agp_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \
-	dev/gpio/gpio_if.m dev/gpio/gpiobus_if.m \
+	dev/fb/fb_if.m dev/gpio/gpio_if.m dev/gpio/gpiobus_if.m \
 	dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \
 	dev/mmc/mmcbr_if.m dev/mmc/mmcbus_if.m \
 	dev/mii/miibus_if.m dev/mvs/mvs_if.m dev/ofw/ofw_bus_if.m \

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/conf/options	Thu Dec  5 22:38:53 2013	(r259016)
@@ -731,8 +731,10 @@ SAFE_DEBUG		opt_safe.h
 SAFE_NO_RNG		opt_safe.h
 SAFE_RNDTEST		opt_safe.h
 
-# syscons options
+# syscons/vt options
 MAXCONS			opt_syscons.h
+VT_FB_DEFAULT_WIDTH	opt_syscons.h
+VT_FB_DEFAULT_HEIGHT	opt_syscons.h
 SC_ALT_MOUSE_IMAGE	opt_syscons.h
 SC_CUT_SPACES2TABS	opt_syscons.h
 SC_CUT_SEPCHARS		opt_syscons.h

Modified: head/sys/dev/drm2/drm_fb_helper.c
==============================================================================
--- head/sys/dev/drm2/drm_fb_helper.c	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/drm_fb_helper.c	Thu Dec  5 22:38:53 2013	(r259016)
@@ -36,6 +36,41 @@ __FBSDID("$FreeBSD$");
 #include <dev/drm2/drm_fb_helper.h>
 #include <dev/drm2/drm_crtc_helper.h>
 
+#if defined(__FreeBSD__)
+struct vt_kms_softc {
+	struct drm_fb_helper *fb_helper;
+	struct task	fb_mode_task;
+};
+
+static fb_enter_t	vt_kms_postswitch;
+static void vt_restore_fbdev_mode(void *, int);
+
+/* Call restore out of vt(9) locks. */
+static void
+vt_restore_fbdev_mode(void *arg, int pending)
+{
+	struct drm_fb_helper *fb_helper;
+	struct vt_kms_softc *sc;
+
+	sc = (struct vt_kms_softc *)arg;
+	fb_helper = sc->fb_helper;
+	sx_xlock(&fb_helper->dev->mode_config.mutex);
+	drm_fb_helper_restore_fbdev_mode(fb_helper);
+	sx_xunlock(&fb_helper->dev->mode_config.mutex);
+}
+
+static int
+vt_kms_postswitch(void *arg)
+{
+	struct vt_kms_softc *sc;
+
+	sc = (struct vt_kms_softc *)arg;
+	taskqueue_enqueue_fast(taskqueue_thread, &sc->fb_mode_task);
+
+	return (0);
+}
+#endif
+
 static DRM_LIST_HEAD(kernel_fb_helper_list);
 
 /* simple single crtc case helper function */
@@ -216,6 +251,10 @@ static int
 fb_get_options(const char *connector_name, char **option)
 {
 
+	/*
+	 * TODO: store mode options pointer in ${option} for connector with
+	 * name ${connector_name}
+	 */
 	return (1);
 }
 
@@ -892,11 +931,13 @@ int drm_fb_helper_single_fb_probe(struct
 	int new_fb = 0;
 	int crtc_count = 0;
 	int i;
-#if 0
 	struct fb_info *info;
-#endif
 	struct drm_fb_helper_surface_size sizes;
 	int gamma_size = 0;
+#if defined(__FreeBSD__)
+	struct vt_kms_softc *sc;
+	device_t kdev;
+#endif
 
 	memset(&sizes, 0, sizeof(struct drm_fb_helper_surface_size));
 	sizes.surface_depth = 24;
@@ -973,8 +1014,21 @@ int drm_fb_helper_single_fb_probe(struct
 	if (new_fb < 0)
 		return new_fb;
 
-#if 0
+#if defined(__FreeBSD__)
+	sc = malloc(sizeof(struct vt_kms_softc), DRM_MEM_KMS,
+	    M_WAITOK | M_ZERO);
+	sc->fb_helper = fb_helper;
+	TASK_INIT(&sc->fb_mode_task, 0, vt_restore_fbdev_mode, sc);
+
 	info = fb_helper->fbdev;
+
+	info->fb_name = device_get_nameunit(fb_helper->dev->device);
+	info->fb_depth = fb_helper->fb->bits_per_pixel;
+	info->fb_height = fb_helper->fb->height;
+	info->fb_width = fb_helper->fb->width;
+	info->fb_stride = fb_helper->fb->pitches[0];
+	info->fb_priv = sc;
+	info->enter = &vt_kms_postswitch;
 #endif
 
 	/* set the fb pointer */
@@ -982,7 +1036,18 @@ int drm_fb_helper_single_fb_probe(struct
 		fb_helper->crtc_info[i].mode_set.fb = fb_helper->fb;
 	}
 
-#if 0
+#if defined(__FreeBSD__)
+	if (new_fb) {
+		device_t fbd;
+		int ret;
+
+		kdev = fb_helper->dev->device;
+		fbd = device_add_child(kdev, "fbd", device_get_unit(kdev));
+		ret = device_probe_and_attach(fbd);
+		if (ret != 0)
+			DRM_ERROR("Failed to attach fbd device: %d\n", ret);
+	}
+#else
 	if (new_fb) {
 		info->var.pixclock = 0;
 		if (register_framebuffer(info) < 0) {
@@ -1006,7 +1071,6 @@ int drm_fb_helper_single_fb_probe(struct
 	if (new_fb)
 		list_add(&fb_helper->kernel_fb_list, &kernel_fb_helper_list);
 #endif
-
 	return 0;
 }
 

Modified: head/sys/dev/drm2/drm_os_freebsd.h
==============================================================================
--- head/sys/dev/drm2/drm_os_freebsd.h	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/drm_os_freebsd.h	Thu Dec  5 22:38:53 2013	(r259016)
@@ -6,6 +6,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/fbio.h>
+
 #if _BYTE_ORDER == _BIG_ENDIAN
 #define	__BIG_ENDIAN 4321
 #else

Modified: head/sys/dev/drm2/i915/i915_drv.c
==============================================================================
--- head/sys/dev/drm2/i915/i915_drv.c	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/i915/i915_drv.c	Thu Dec  5 22:38:53 2013	(r259016)
@@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$");
 #include <dev/drm2/drm_pciids.h>
 #include <dev/drm2/i915/intel_drv.h>
 
+#include "fb_if.h"
+
 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
 static drm_pci_id_list_t i915_pciidlist[] = {
 	i915_PCI_IDS
@@ -380,6 +382,25 @@ i915_attach(device_t kdev)
 	return (drm_attach(kdev, i915_pciidlist));
 }
 
+static struct fb_info *
+i915_fb_helper_getinfo(device_t kdev)
+{
+	struct intel_fbdev *ifbdev;
+	drm_i915_private_t *dev_priv;
+	struct drm_device *dev;
+	struct fb_info *info;
+
+	dev = device_get_softc(kdev);
+	dev_priv = dev->dev_private;
+	ifbdev = dev_priv->fbdev;
+	if (ifbdev == NULL)
+		return (NULL);
+
+	info = ifbdev->helper.fbdev;
+
+	return (info);
+}
+
 const struct intel_device_info *
 i915_get_device_id(int device)
 {
@@ -400,6 +421,10 @@ static device_method_t i915_methods[] = 
 	DEVMETHOD(device_suspend,	i915_suspend),
 	DEVMETHOD(device_resume,	i915_resume),
 	DEVMETHOD(device_detach,	drm_detach),
+
+	/* Framebuffer service methods */
+	DEVMETHOD(fb_getinfo,		i915_fb_helper_getinfo),
+
 	DEVMETHOD_END
 };
 

Modified: head/sys/dev/drm2/i915/intel_fb.c
==============================================================================
--- head/sys/dev/drm2/i915/intel_fb.c	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/i915/intel_fb.c	Thu Dec  5 22:38:53 2013	(r259016)
@@ -41,8 +41,8 @@ static int intelfb_create(struct intel_f
 	struct drm_device *dev = ifbdev->helper.dev;
 #if 0
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct fb_info *info;
 #endif
+	struct fb_info *info;
 	struct drm_framebuffer *fb;
 	struct drm_mode_fb_cmd2 mode_cmd;
 	struct drm_i915_gem_object *obj;
@@ -86,6 +86,16 @@ static int intelfb_create(struct intel_f
 	}
 
 	info->par = ifbdev;
+#else
+	info = malloc(sizeof(struct fb_info), DRM_MEM_KMS, M_WAITOK | M_ZERO);
+	info->fb_size = size;
+	info->fb_bpp = sizes->surface_bpp;
+	info->fb_width = sizes->fb_width;
+	info->fb_height = sizes->fb_height;
+	info->fb_pbase = dev->agp->base + obj->gtt_offset;
+	info->fb_vbase = (vm_offset_t)pmap_mapdev_attr(info->fb_pbase, size,
+	    PAT_WRITE_COMBINING);
+
 #endif
 
 	ret = intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, obj);
@@ -95,8 +105,8 @@ static int intelfb_create(struct intel_f
 	fb = &ifbdev->ifb.base;
 
 	ifbdev->helper.fb = fb;
-#if 0
 	ifbdev->helper.fbdev = info;
+#if 0
 
 	strcpy(info->fix.id, "inteldrmfb");
 
@@ -135,9 +145,8 @@ static int intelfb_create(struct intel_f
 
 	/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
 #endif
-
-	DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08x, bo %p\n",
-		      fb->width, fb->height,
+	DRM_DEBUG_KMS("allocated %dx%d (s %dbits) fb: 0x%08x, bo %p\n",
+		      fb->width, fb->height, fb->depth,
 		      obj->gtt_offset, obj);
 
 	DRM_UNLOCK(dev);

Modified: head/sys/dev/drm2/radeon/radeon.h
==============================================================================
--- head/sys/dev/drm2/radeon/radeon.h	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/radeon/radeon.h	Thu Dec  5 22:38:53 2013	(r259016)
@@ -2041,6 +2041,9 @@ void	radeon_pm_acpi_event_handler(struct
 int	radeon_ttm_init(struct radeon_device *rdev);
 void	radeon_ttm_fini(struct radeon_device *rdev);
 
+/* radeon_fb.c */
+struct fb_info *	radeon_fb_helper_getinfo(device_t kdev);
+
 /* r600.c */
 int r600_ih_ring_alloc(struct radeon_device *rdev);
 void r600_ih_ring_fini(struct radeon_device *rdev);

Modified: head/sys/dev/drm2/radeon/radeon_drv.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_drv.c	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/radeon/radeon_drv.c	Thu Dec  5 22:38:53 2013	(r259016)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/drm2/drm_pciids.h>
 
+#include "fb_if.h"
 
 /*
  * KMS wrapper.
@@ -495,6 +496,8 @@ radeon_resume(device_t kdev)
 	return (-ret);
 }
 
+extern struct fb_info *	radeon_fb_helper_getinfo(device_t kdev);
+
 static device_method_t radeon_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		radeon_probe),
@@ -502,6 +505,10 @@ static device_method_t radeon_methods[] 
 	DEVMETHOD(device_suspend,	radeon_suspend),
 	DEVMETHOD(device_resume,	radeon_resume),
 	DEVMETHOD(device_detach,	drm_detach),
+
+	/* Framebuffer service methods */
+	DEVMETHOD(fb_getinfo,		radeon_fb_helper_getinfo),
+
 	DEVMETHOD_END
 };
 

Modified: head/sys/dev/drm2/radeon/radeon_fb.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_fb.c	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/radeon/radeon_fb.c	Thu Dec  5 22:38:53 2013	(r259016)
@@ -27,6 +27,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <machine/_inttypes.h>
+
 #include <dev/drm2/drmP.h>
 #include <dev/drm2/drm_crtc.h>
 #include <dev/drm2/drm_crtc_helper.h>
@@ -46,7 +48,7 @@ struct radeon_fbdev {
 	struct radeon_device *rdev;
 };
 
-#ifdef DUMBBELL_WIP
+#if defined(__linux__)
 static struct fb_ops radeonfb_ops = {
 	.owner = THIS_MODULE,
 	.fb_check_var = drm_fb_helper_check_var,
@@ -60,7 +62,7 @@ static struct fb_ops radeonfb_ops = {
 	.fb_debug_enter = drm_fb_helper_debug_enter,
 	.fb_debug_leave = drm_fb_helper_debug_leave,
 };
-#endif /* DUMBBELL_WIP */
+#endif
 
 
 int radeon_align_pitch(struct radeon_device *rdev, int width, int bpp, bool tiled)
@@ -191,20 +193,13 @@ static int radeonfb_create(struct radeon
 			   struct drm_fb_helper_surface_size *sizes)
 {
 	struct radeon_device *rdev = rfbdev->rdev;
-#ifdef DUMBBELL_WIP
 	struct fb_info *info;
-#endif /* DUMBBELL_WIP */
 	struct drm_framebuffer *fb = NULL;
 	struct drm_mode_fb_cmd2 mode_cmd;
 	struct drm_gem_object *gobj = NULL;
 	struct radeon_bo *rbo = NULL;
-#ifdef DUMBBELL_WIP
-	device_t device = rdev->dev;
-#endif /* DUMBBELL_WIP */
 	int ret;
-#ifdef DUMBBELL_WIP
 	unsigned long tmp;
-#endif /* DUMBBELL_WIP */
 
 	mode_cmd.width = sizes->surface_width;
 	mode_cmd.height = sizes->surface_height;
@@ -224,16 +219,7 @@ static int radeonfb_create(struct radeon
 
 	rbo = gem_to_radeon_bo(gobj);
 
-#ifdef DUMBBELL_WIP
-	/* okay we have an object now allocate the framebuffer */
-	info = framebuffer_alloc(0, device);
-	if (info == NULL) {
-		ret = -ENOMEM;
-		goto out_unref;
-	}
-
-	info->par = rfbdev;
-#endif /* DUMBBELL_WIP */
+	info = malloc(sizeof(*info), DRM_MEM_KMS, M_WAITOK | M_ZERO);
 
 	ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
 	if (ret) {
@@ -245,61 +231,29 @@ static int radeonfb_create(struct radeon
 
 	/* setup helper */
 	rfbdev->helper.fb = fb;
-#ifdef DUMBBELL_WIP
 	rfbdev->helper.fbdev = info;
 
-	memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));
-
-	strcpy(info->fix.id, "radeondrmfb");
-
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
-
-	info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
-	info->fbops = &radeonfb_ops;
+	memset(rbo->kptr, 0x0, radeon_bo_size(rbo));
 
 	tmp = radeon_bo_gpu_offset(rbo) - rdev->mc.vram_start;
-	info->fix.smem_start = rdev->mc.aper_base + tmp;
-	info->fix.smem_len = radeon_bo_size(rbo);
-	info->screen_base = rbo->kptr;
-	info->screen_size = radeon_bo_size(rbo);
-
-	drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height);
-
-	/* setup aperture base/size for vesafb takeover */
-	info->apertures = alloc_apertures(1);
-	if (!info->apertures) {
-		ret = -ENOMEM;
-		goto out_unref;
-	}
-	info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
-	info->apertures->ranges[0].size = rdev->mc.aper_size;
+	info->fb_size  = radeon_bo_size(rbo);
+	info->fb_bpp = sizes->surface_bpp;
+	info->fb_width = sizes->surface_width;
+	info->fb_height = sizes->surface_height;
+	info->fb_pbase = rdev->mc.aper_base + tmp;
+	info->fb_vbase = (vm_offset_t)rbo->kptr;
 
-	/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
-
-	if (info->screen_base == NULL) {
-		ret = -ENOSPC;
-		goto out_unref;
-	}
-
-	ret = fb_alloc_cmap(&info->cmap, 256, 0);
-	if (ret) {
-		ret = -ENOMEM;
-		goto out_unref;
-	}
-
-	DRM_INFO("fb mappable at 0x%lX\n",  info->fix.smem_start);
+	DRM_INFO("fb mappable at 0x%" PRIXPTR "\n",  info->fb_pbase);
 	DRM_INFO("vram apper at 0x%lX\n",  (unsigned long)rdev->mc.aper_base);
 	DRM_INFO("size %lu\n", (unsigned long)radeon_bo_size(rbo));
 	DRM_INFO("fb depth is %d\n", fb->depth);
 	DRM_INFO("   pitch is %d\n", fb->pitches[0]);
 
-	vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
-#endif /* DUMBBELL_WIP */
 	return 0;
 
 out_unref:
 	if (rbo) {
-
+		/* TODO? dumbbell@ */
 	}
 	if (fb && ret) {
 		drm_gem_object_unreference(gobj);
@@ -332,21 +286,13 @@ void radeon_fb_output_poll_changed(struc
 
 static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
 {
-#ifdef DUMBBELL_WIP
 	struct fb_info *info;
-#endif /* DUMBBELL_WIP */
 	struct radeon_framebuffer *rfb = &rfbdev->rfb;
 
-#ifdef DUMBBELL_WIP
 	if (rfbdev->helper.fbdev) {
 		info = rfbdev->helper.fbdev;
-
-		unregister_framebuffer(info);
-		if (info->cmap.len)
-			fb_dealloc_cmap(&info->cmap);
-		framebuffer_release(info);
+		free(info, DRM_MEM_KMS);
 	}
-#endif /* DUMBBELL_WIP */
 
 	if (rfb->obj) {
 		DRM_UNLOCK(dev); /* Work around lock recursion. dumbbell@ */
@@ -431,3 +377,22 @@ bool radeon_fbdev_robj_is_fb(struct rade
 		return true;
 	return false;
 }
+
+struct fb_info *
+radeon_fb_helper_getinfo(device_t kdev)
+{
+	struct drm_device *dev;
+	struct radeon_device *rdev;
+	struct radeon_fbdev *rfbdev;
+	struct fb_info *info;
+
+	dev = device_get_softc(kdev);
+	rdev = dev->dev_private;
+	rfbdev = rdev->mode_info.rfbdev;
+	if (rfbdev == NULL)
+		return (NULL);
+
+	info = rfbdev->helper.fbdev;
+
+	return (info);
+}

Modified: head/sys/dev/drm2/radeon/radeon_pm.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_pm.c	Thu Dec  5 21:58:02 2013	(r259015)
+++ head/sys/dev/drm2/radeon/radeon_pm.c	Thu Dec  5 22:38:53 2013	(r259016)
@@ -248,7 +248,7 @@ static void radeon_pm_set_clocks(struct 
 	    (rdev->pm.requested_power_state_index == rdev->pm.current_power_state_index))
 		return;
 
-	DRM_LOCK(rdev->ddev);
+	//DRM_LOCK(rdev->ddev); XXX Recursion, already locked in drm_attach/drm_load -- dumbbell@
 	sx_xlock(&rdev->pm.mclk_lock);
 	sx_xlock(&rdev->ring_lock);
 
@@ -263,7 +263,7 @@ static void radeon_pm_set_clocks(struct 
 			/* needs a GPU reset dont reset here */
 			sx_xunlock(&rdev->ring_lock);
 			sx_xunlock(&rdev->pm.mclk_lock);
-			DRM_UNLOCK(rdev->ddev);
+			//DRM_UNLOCK(rdev->ddev); XXX Recursion, already locked in drm_attach/drm_load -- dumbbell@
 			return;
 		}
 	}
@@ -299,7 +299,7 @@ static void radeon_pm_set_clocks(struct 
 
 	sx_xunlock(&rdev->ring_lock);
 	sx_xunlock(&rdev->pm.mclk_lock);
-	DRM_UNLOCK(rdev->ddev);
+	//DRM_UNLOCK(rdev->ddev); XXX Recursion, already locked in drm_attach/drm_load -- dumbbell@
 }
 
 static void radeon_pm_print_states(struct radeon_device *rdev)

Copied: head/sys/dev/fb/fb_if.m (from r259015, user/ed/newcons/sys/dev/fb/fb_if.m)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/fb/fb_if.m	Thu Dec  5 22:38:53 2013	(r259016, copy of r259015, user/ed/newcons/sys/dev/fb/fb_if.m)
@@ -0,0 +1,13 @@
+#include <sys/bus.h>
+#include <sys/fbio.h>
+
+INTERFACE fb;
+
+METHOD int pin_max {
+	device_t dev;
+	int *npins;
+};
+
+METHOD struct fb_info * getinfo {
+	device_t dev;
+};

Copied: head/sys/dev/fb/fbd.c (from r259015, user/ed/newcons/sys/dev/fb/fbd.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/fb/fbd.c	Thu Dec  5 22:38:53 2013	(r259016, copy of r259015, user/ed/newcons/sys/dev/fb/fbd.c)
@@ -0,0 +1,467 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Aleksandr Rybalko under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/* Generic framebuffer */
+/* TODO unlink from VT(9) */
+/* TODO done normal /dev/fb methods */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/queue.h>
+#include <sys/fbio.h>
+
+#include <machine/bus.h>
+
+#include <dev/vt/vt.h>
+#include <dev/vt/hw/fb/vt_fb.h>
+
+#include "fb_if.h"
+
+LIST_HEAD(fb_list_head_t, fb_list_entry) fb_list_head =
+    LIST_HEAD_INITIALIZER(fb_list_head);
+struct fb_list_entry {
+	struct fb_info	*fb_info;
+	struct cdev	*fb_si;
+	LIST_ENTRY(fb_list_entry) fb_list;
+};
+
+struct fbd_softc {
+	device_t	sc_dev;
+	struct fb_info	*sc_info;
+};
+
+static void fbd_evh_init(void *);
+/* SI_ORDER_SECOND, just after EVENTHANDLERs initialized. */
+SYSINIT(fbd_evh_init, SI_SUB_CONFIGURE, SI_ORDER_SECOND, fbd_evh_init, NULL);
+
+static d_open_t		fb_open;
+static d_close_t	fb_close;
+static d_read_t		fb_read;
+static d_write_t	fb_write;
+static d_ioctl_t	fb_ioctl;
+static d_mmap_t		fb_mmap;
+
+static struct cdevsw fb_cdevsw = {
+	.d_version =	D_VERSION,
+	.d_flags =	D_NEEDGIANT,
+	.d_open =	fb_open,
+	.d_close =	fb_close,
+	.d_read =	fb_read,
+	.d_write =	fb_write,
+	.d_ioctl =	fb_ioctl,
+	.d_mmap =	fb_mmap,
+	.d_name =	"fb",
+};
+
+static int framebuffer_dev_unit = 0;
+
+static int
+fb_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
+{
+
+	return (0);
+}
+
+static int
+fb_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
+{
+
+	return (0);
+}
+
+static int
+fb_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
+    struct thread *td)
+{
+	struct fb_info *info;
+	int error;
+
+	error = 0;
+	info = dev->si_drv1;
+
+	switch (cmd) {
+	case FBIOGTYPE:
+		bcopy(info, (struct fbtype *)data, sizeof(struct fbtype));
+		break;
+
+	case FBIO_GETWINORG:	/* get frame buffer window origin */
+		*(u_int *)data = 0;
+		break;
+
+	case FBIO_GETDISPSTART:	/* get display start address */
+		((video_display_start_t *)data)->x = 0;
+		((video_display_start_t *)data)->y = 0;
+		break;
+
+	case FBIO_GETLINEWIDTH:	/* get scan line width in bytes */
+		*(u_int *)data = info->fb_stride;
+		break;
+
+	case FBIO_BLANK:	/* blank display */
+		error = 0;	/* TODO */
+		break;
+
+	default:
+		error = ENOIOCTL;
+		break;
+	}
+	return (error);
+}
+
+static int
+fb_read(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+	return (0); /* XXX nothing to read, yet */
+}
+
+static int
+fb_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+	return (0); /* XXX nothing written */
+}
+
+static int
+fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
+    vm_memattr_t *memattr)
+{
+	struct fb_info *info;
+
+	info = dev->si_drv1;
+	if (offset < info->fb_size) {
+		*paddr = info->fb_pbase + offset;
+		return (0);
+	}
+	return (EINVAL);
+}
+
+
+static void
+vt_fb_mem_wr1(struct fb_info *sc, uint32_t o, uint8_t v)
+{
+
+	KASSERT((o < sc->fb_size), ("Offset %#08x out of fb size", o));
+	*(uint8_t *)(sc->fb_vbase + o) = v;
+}
+
+static void
+vt_fb_mem_wr2(struct fb_info *sc, uint32_t o, uint16_t v)
+{
+
+	KASSERT((o < sc->fb_size), ("Offset %#08x out of fb size", o));
+	*(uint16_t *)(sc->fb_vbase + o) = v;
+}
+
+static void
+vt_fb_mem_wr4(struct fb_info *sc, uint32_t o, uint32_t v)
+{
+
+	KASSERT((o < sc->fb_size), ("Offset %#08x out of fb size", o));
+	*(uint32_t *)(sc->fb_vbase + o) = v;
+}
+
+static void
+vt_fb_mem_copy(struct fb_info *sc, uint32_t offset_to, uint32_t offset_from,
+    uint32_t size)
+{
+
+	memmove((void *)(sc->fb_vbase + offset_to), (void *)(sc->fb_vbase +
+	    offset_from), size);
+}
+
+static void
+vt_fb_indir_wr1(struct fb_info *sc, uint32_t o, uint8_t v)
+{
+
+	KASSERT((o < sc->fb_size), ("Offset %#08x out of fb size", o));
+	sc->fb_write(sc->fb_priv, o, &v, 1);
+}
+
+static void
+vt_fb_indir_wr2(struct fb_info *sc, uint32_t o, uint16_t v)
+{
+
+	KASSERT((o < sc->fb_size), ("Offset %#08x out of fb size", o));
+	sc->fb_write(sc->fb_priv, o, &v, 2);
+}
+
+static void
+vt_fb_indir_wr4(struct fb_info *sc, uint32_t o, uint32_t v)
+{
+
+	KASSERT((o < sc->fb_size), ("Offset %#08x out of fb size", o));
+	sc->fb_write(sc->fb_priv, o, &v, 4);
+}
+
+static void
+vt_fb_indir_copy(struct fb_info *sc, uint32_t offset_to, uint32_t offset_from,
+    uint32_t size)
+{
+
+	sc->copy(sc->fb_priv, offset_to, offset_from, size);
+}
+
+int
+fb_probe(struct fb_info *info)
+{
+
+	if (info->fb_size == 0)
+		return (ENXIO);
+
+	if (info->fb_write != NULL) {
+		if (info->fb_write == NULL) {
+			return (EINVAL);
+		}
+		info->fb_flags |= FB_FLAG_NOMMAP;
+		info->wr1 = &vt_fb_indir_wr1;
+		info->wr2 = &vt_fb_indir_wr2;
+		info->wr4 = &vt_fb_indir_wr4;
+		info->copy = &vt_fb_indir_copy;
+	} else if (info->fb_vbase != 0) {
+		if (info->fb_pbase == 0)
+			info->fb_flags |= FB_FLAG_NOMMAP;
+		info->wr1 = &vt_fb_mem_wr1;
+		info->wr2 = &vt_fb_mem_wr2;
+		info->wr4 = &vt_fb_mem_wr4;
+		info->copy = &vt_fb_mem_copy;
+	} else
+		return (ENXIO);
+
+	return (0);
+}
+
+
+static int
+fb_init(struct fb_list_entry *entry, int unit)
+{
+	struct fb_info *info;
+
+	info = entry->fb_info;
+	entry->fb_si = make_dev(&fb_cdevsw, unit, UID_ROOT, GID_WHEEL,
+	    0600, "fb%d", unit);
+	entry->fb_si->si_drv1 = info;
+
+	return (0);
+}
+
+int
+fbd_list()
+{
+	struct fb_list_entry *entry;
+
+	if (LIST_EMPTY(&fb_list_head))
+		return (ENOENT);
+
+	LIST_FOREACH(entry, &fb_list_head, fb_list) {
+		printf("FB %s @%p\n", entry->fb_info->fb_name,
+		    (void *)entry->fb_info->fb_pbase);
+	}
+
+	return (0);
+}
+
+static struct fb_list_entry *
+fbd_find(struct fb_info* info)
+{
+	struct fb_list_entry *entry, *tmp;
+
+	LIST_FOREACH_SAFE(entry, &fb_list_head, fb_list, tmp) {
+		if (entry->fb_info == info) {
+			return (entry);
+		}
+	}
+
+	return (NULL);
+}
+
+int
+fbd_register(struct fb_info* info)
+{
+	struct fb_list_entry *entry;
+	int err, first;
+
+	first = 0;
+	if (LIST_EMPTY(&fb_list_head))
+		first++;
+
+	entry = fbd_find(info);
+	if (entry != NULL) {
+		/* XXX Update framebuffer params */
+		return (0);
+	}
+
+	err = fb_probe(info);
+	if (err)
+		return (err);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312052238.rB5McsVN020719>