svn commit: r269620 - in head/sys: dev/fb dev/vt/hw/efifb dev/vt/hw/fb dev/vt/hw/ofwfb powerpc/ps3 sys

Nathan Whitehorn nwhitehorn at FreeBSD.org
Wed Aug 6 00:35:50 UTC 2014


Author: nwhitehorn
Date: Wed Aug  6 00:35:48 2014
New Revision: 269620
URL: http://svnweb.freebsd.org/changeset/base/269620

Log:
  Retire various intertwined bits of fbd(4) and vt_fb, in particular the
  pixel modification indirection. No actual drivers use it and those that
  might (e.g. creatorfb) use custom implementations of vd_bitbltchr().

Modified:
  head/sys/dev/fb/fbd.c
  head/sys/dev/vt/hw/efifb/efifb.c
  head/sys/dev/vt/hw/fb/vt_early_fb.c
  head/sys/dev/vt/hw/fb/vt_fb.c
  head/sys/dev/vt/hw/fb/vt_fb.h
  head/sys/dev/vt/hw/ofwfb/ofwfb.c
  head/sys/powerpc/ps3/ps3_syscons.c
  head/sys/sys/fbio.h

Modified: head/sys/dev/fb/fbd.c
==============================================================================
--- head/sys/dev/fb/fbd.c	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/dev/fb/fbd.c	Wed Aug  6 00:35:48 2014	(r269620)
@@ -165,6 +165,10 @@ fb_mmap(struct cdev *dev, vm_ooffset_t o
 	struct fb_info *info;
 
 	info = dev->si_drv1;
+
+	if ((info->fb_flags & FB_FLAG_NOMMAP) || info->fb_pbase == 0)
+		return (ENODEV);
+
 	if (offset < info->fb_size) {
 		*paddr = info->fb_pbase + offset;
 		return (0);
@@ -172,103 +176,6 @@ fb_mmap(struct cdev *dev, vm_ooffset_t o
 	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_read == 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)
 {
@@ -329,10 +236,6 @@ fbd_register(struct fb_info* info)
 		return (0);
 	}
 
-	err = fb_probe(info);
-	if (err)
-		return (err);
-
 	entry = malloc(sizeof(struct fb_list_entry), M_DEVBUF, M_WAITOK|M_ZERO);
 	entry->fb_info = info;
 
@@ -342,8 +245,10 @@ fbd_register(struct fb_info* info)
 	if (err)
 		return (err);
 
-	if (first)
-		vt_fb_attach(info);
+	if (first) {
+		if (vt_fb_attach(info) == CN_DEAD)
+			return (ENXIO);
+	}
 
 	return (0);
 }

Modified: head/sys/dev/vt/hw/efifb/efifb.c
==============================================================================
--- head/sys/dev/vt/hw/efifb/efifb.c	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/dev/vt/hw/efifb/efifb.c	Wed Aug  6 00:35:48 2014	(r269620)
@@ -154,12 +154,8 @@ vt_efifb_init(struct vt_device *vd)
 	info->fb_width = MIN(info->fb_width, VT_FB_DEFAULT_WIDTH);
 	info->fb_height = MIN(info->fb_height, VT_FB_DEFAULT_HEIGHT);
 
-	fb_probe(info);
 	vt_fb_init(vd);
 
-	/* Clear the screen. */
-	vt_fb_blank(vd, TC_BLACK);
-
 	return (CN_INTERNAL);
 }
 

Modified: head/sys/dev/vt/hw/fb/vt_early_fb.c
==============================================================================
--- head/sys/dev/vt/hw/fb/vt_early_fb.c	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/dev/vt/hw/fb/vt_early_fb.c	Wed Aug  6 00:35:48 2014	(r269620)
@@ -296,7 +296,6 @@ vt_efb_init(struct vt_device *vd)
 #else
 	vt_efb_initialize(info);
 #endif
-	fb_probe(info);
 	vt_fb_init(vd);
 
 	return (CN_INTERNAL);

Modified: head/sys/dev/vt/hw/fb/vt_fb.c
==============================================================================
--- head/sys/dev/vt/hw/fb/vt_fb.c	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/dev/vt/hw/fb/vt_fb.c	Wed Aug  6 00:35:48 2014	(r269620)
@@ -61,6 +61,30 @@ static struct vt_driver vt_fb_driver = {
 
 VT_DRIVER_DECLARE(vt_fb, vt_fb_driver);
 
+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;
+}
+
 int
 vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data, struct thread *td)
 {
@@ -134,20 +158,22 @@ vt_fb_setpixel(struct vt_device *vd, int
 	c = info->fb_cmap[color];
 	o = info->fb_stride * y + x * FBTYPE_GET_BYTESPP(info);
 
+	KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer"));
+
 	switch (FBTYPE_GET_BYTESPP(info)) {
 	case 1:
-		info->wr1(info, o, c);
+		vt_fb_mem_wr1(info, o, c);
 		break;
 	case 2:
-		info->wr2(info, o, c);
+		vt_fb_mem_wr2(info, o, c);
 		break;
 	case 3:
-		info->wr1(info, o, (c >> 16) & 0xff);
-		info->wr1(info, o + 1, (c >> 8) & 0xff);
-		info->wr1(info, o + 2, c & 0xff);
+		vt_fb_mem_wr1(info, o, (c >> 16) & 0xff);
+		vt_fb_mem_wr1(info, o + 1, (c >> 8) & 0xff);
+		vt_fb_mem_wr1(info, o + 2, c & 0xff);
 		break;
 	case 4:
-		info->wr4(info, o, c);
+		vt_fb_mem_wr4(info, o, c);
 		break;
 	default:
 		/* panic? */
@@ -183,32 +209,34 @@ vt_fb_blank(struct vt_device *vd, term_c
 	info = vd->vd_softc;
 	c = info->fb_cmap[color];
 
+	KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer"));
+
 	switch (FBTYPE_GET_BYTESPP(info)) {
 	case 1:
 		for (h = 0; h < info->fb_height; h++)
 			for (o = 0; o < info->fb_stride; o++)
-				info->wr1(info, h*info->fb_stride + o, c);
+				vt_fb_mem_wr1(info, h*info->fb_stride + o, c);
 		break;
 	case 2:
 		for (h = 0; h < info->fb_height; h++)
 			for (o = 0; o < info->fb_stride; o += 2)
-				info->wr2(info, h*info->fb_stride + o, c);
+				vt_fb_mem_wr2(info, h*info->fb_stride + o, c);
 		break;
 	case 3:
 		for (h = 0; h < info->fb_height; h++)
 			for (o = 0; o < info->fb_stride; o += 3) {
-				info->wr1(info, h*info->fb_stride + o,
+				vt_fb_mem_wr1(info, h*info->fb_stride + o,
 				    (c >> 16) & 0xff);
-				info->wr1(info, h*info->fb_stride + o + 1,
+				vt_fb_mem_wr1(info, h*info->fb_stride + o + 1,
 				    (c >> 8) & 0xff);
-				info->wr1(info, h*info->fb_stride + o + 2,
+				vt_fb_mem_wr1(info, h*info->fb_stride + o + 2,
 				    c & 0xff);
 			}
 		break;
 	case 4:
 		for (h = 0; h < info->fb_height; h++)
 			for (o = 0; o < info->fb_stride; o += 4)
-				info->wr4(info, h*info->fb_stride + o, c);
+				vt_fb_mem_wr4(info, h*info->fb_stride + o, c);
 		break;
 	default:
 		/* panic? */
@@ -241,6 +269,8 @@ vt_fb_bitbltchr(struct vt_device *vd, co
 	    info->fb_height))
 		return;
 
+	KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer"));
+
 	line = (info->fb_stride * top) + (left * bpp);
 	for (l = 0; l < height; l++) {
 		ch = src;
@@ -254,19 +284,19 @@ vt_fb_bitbltchr(struct vt_device *vd, co
 
 			switch(bpp) {
 			case 1:
-				info->wr1(info, o, cc);
+				vt_fb_mem_wr1(info, o, cc);
 				break;
 			case 2:
-				info->wr2(info, o, cc);
+				vt_fb_mem_wr2(info, o, cc);
 				break;
 			case 3:
 				/* Packed mode, so unaligned. Byte access. */
-				info->wr1(info, o, (cc >> 16) & 0xff);
-				info->wr1(info, o + 1, (cc >> 8) & 0xff);
-				info->wr1(info, o + 2, cc & 0xff);
+				vt_fb_mem_wr1(info, o, (cc >> 16) & 0xff);
+				vt_fb_mem_wr1(info, o + 1, (cc >> 8) & 0xff);
+				vt_fb_mem_wr1(info, o + 2, cc & 0xff);
 				break;
 			case 4:
-				info->wr4(info, o, cc);
+				vt_fb_mem_wr4(info, o, cc);
 				break;
 			default:
 				/* panic? */
@@ -303,6 +333,8 @@ vt_fb_maskbitbltchr(struct vt_device *vd
 	    info->fb_height))
 		return;
 
+	KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer"));
+
 	line = (info->fb_stride * top) + (left * bpp);
 	for (l = 0; l < height; l++) {
 		ch = src;
@@ -325,19 +357,19 @@ vt_fb_maskbitbltchr(struct vt_device *vd
 
 			switch(bpp) {
 			case 1:
-				info->wr1(info, o, cc);
+				vt_fb_mem_wr1(info, o, cc);
 				break;
 			case 2:
-				info->wr2(info, o, cc);
+				vt_fb_mem_wr2(info, o, cc);
 				break;
 			case 3:
 				/* Packed mode, so unaligned. Byte access. */
-				info->wr1(info, o, (cc >> 16) & 0xff);
-				info->wr1(info, o + 1, (cc >> 8) & 0xff);
-				info->wr1(info, o + 2, cc & 0xff);
+				vt_fb_mem_wr1(info, o, (cc >> 16) & 0xff);
+				vt_fb_mem_wr1(info, o + 1, (cc >> 8) & 0xff);
+				vt_fb_mem_wr1(info, o + 2, cc & 0xff);
 				break;
 			case 4:
-				info->wr4(info, o, cc);
+				vt_fb_mem_wr4(info, o, cc);
 				break;
 			default:
 				/* panic? */
@@ -393,6 +425,12 @@ vt_fb_init(struct vt_device *vd)
 	vd->vd_height = info->fb_height;
 	vd->vd_width = info->fb_width;
 
+	if (info->fb_size == 0)
+		return (CN_DEAD);
+
+	if (info->fb_pbase == 0)
+		info->fb_flags |= FB_FLAG_NOMMAP;
+
 	if (info->fb_cmsize <= 0) {
 		err = vt_fb_init_cmap(info->fb_cmap, FBTYPE_GET_BPP(info));
 		if (err)

Modified: head/sys/dev/vt/hw/fb/vt_fb.h
==============================================================================
--- head/sys/dev/vt/hw/fb/vt_fb.h	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/dev/vt/hw/fb/vt_fb.h	Wed Aug  6 00:35:48 2014	(r269620)
@@ -36,8 +36,6 @@ int vt_fb_attach(struct fb_info *info);
 void vt_fb_resume(void);
 void vt_fb_suspend(void);
 
-int fb_probe(struct fb_info *info);
-
 vd_init_t	vt_fb_init;
 vd_blank_t	vt_fb_blank;
 vd_bitbltchr_t	vt_fb_bitbltchr;

Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c
==============================================================================
--- head/sys/dev/vt/hw/ofwfb/ofwfb.c	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.c	Wed Aug  6 00:35:48 2014	(r269620)
@@ -399,7 +399,6 @@ ofwfb_init(struct vt_device *vd)
 	sc->fb.fb_pbase = fb_phys;
 
 	ofwfb_initialize(vd);
-	fb_probe(&sc->fb);
 	vt_fb_init(vd);
 
 	return (CN_INTERNAL);

Modified: head/sys/powerpc/ps3/ps3_syscons.c
==============================================================================
--- head/sys/powerpc/ps3/ps3_syscons.c	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/powerpc/ps3/ps3_syscons.c	Wed Aug  6 00:35:48 2014	(r269620)
@@ -188,12 +188,8 @@ ps3fb_init(struct vt_device *vd)
 	lv1_gpu_context_attribute(sc->sc_fbcontext,
 	    L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0);
 
-	fb_probe(&sc->fb_info);
-	sc->fb_info.fb_flags &= ~FB_FLAG_NOMMAP; /* Set wrongly by fb_probe */
 	vt_fb_init(vd);
-
-	/* Clear the screen. */
-	vt_fb_blank(vd, TC_BLACK);
+	sc->fb_info.fb_flags &= ~FB_FLAG_NOMMAP; /* Set wrongly by vt_fb_init */
 
 	return (CN_INTERNAL);
 }

Modified: head/sys/sys/fbio.h
==============================================================================
--- head/sys/sys/fbio.h	Wed Aug  6 00:35:32 2014	(r269619)
+++ head/sys/sys/fbio.h	Wed Aug  6 00:35:48 2014	(r269620)
@@ -115,19 +115,6 @@ struct fb_info;
 
 typedef int fb_enter_t(void *priv);
 typedef int fb_leave_t(void *priv);
-typedef int fb_write_t(void *priv, int offset, void *data, int size);
-typedef int fb_read_t(void *priv, int offset, void *data, int size);
-
-/* XXX: should use priv instead of fb_info too. */
-typedef void fb_copy_t(struct fb_info *sc, uint32_t offset_to, uint32_t offset_from,
-    uint32_t size);
-typedef void fb_wr1_t(struct fb_info *sc, uint32_t offset, uint8_t value);
-typedef void fb_wr2_t(struct fb_info *sc, uint32_t offset, uint16_t value);
-typedef void fb_wr4_t(struct fb_info *sc, uint32_t offset, uint32_t value);
-
-typedef int fb_ioctl_t(struct cdev *, u_long, caddr_t, int, struct thread *);
-typedef int fb_mmap_t(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
-    int prot, vm_memattr_t *memattr);
 
 struct fb_info {
 	/* Raw copy of fbtype. Do not change. */
@@ -138,16 +125,8 @@ struct fb_info {
 	int		fb_cmsize;	/* size of color map (entries) */
 	int		fb_size;	/* total size in bytes */
 
-	/* Methods. */
-	fb_write_t	*fb_write;	/* if NULL, direct mem write. */
-	fb_read_t	*fb_read;	/* if NULL, direct mem read. */
-
 	struct cdev 	*fb_cdev;
 
-	fb_wr1_t	*wr1;
-	fb_wr2_t	*wr2;
-	fb_wr4_t	*wr4;
-	fb_copy_t	*copy;
 	fb_enter_t	*enter;
 	fb_leave_t	*leave;
 


More information about the svn-src-all mailing list