linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] PMAG-AA frame buffer driver rework
@ 2016-02-22  1:54 Maciej W. Rozycki
  2016-02-22  1:54 ` [PATCH 1/7] video: fbdev: pmag-aa-fb: Adapt to current APIs Maciej W. Rozycki
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:54 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

Hi,

 This is an update to the PMAG-AA frame buffer driver to adapt it to our 
current APIs, which I promised a while ago (too much of a while, which I 
apologise for).

 This series starts with a change that makes the driver build and retains 
its previous functionality.  A bunch of further clean-ups follow, each of 
which is explained individually.  There's a potential in this code for 
further clean-ups and improvements, but the weekend is running out quick 
now, so I had to stop somewhere.  Next time then.

 A couple of checkpatch.pl warnings are noted.

 First on using `printk(KERN_ERR ...' rather tha `pr_err'.  I could 
probably fix it, but I think it's not worth it by itself, the interface is 
not wrong and the issue is mainly cosmetical.  I think I'll just go across 
all the pmag* drivers at once and bulk convert these calls sometime.

 Second on using `mb()' (without a comment).  This is not a new problem as 
the driver has lots of these calls throughout.  Fixing them is blocked on 
the unavailability of generic cross-platform MMIO synchronisation and 
completion barriers.  See the discussion at: 
<http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=alpine.LFD.2.11.1404280048540.11598%40eddie.linux-mips.org> 
for details.  Most TURBOchannel drivers suffer from this problem due to 
the complexities around many MIPS processors being weakly ordered, 
including in particular those used in TURBOchannel systems.  Once the 
generic issue of MMIO barriers has been sorted out the hacks to use memory 
barriers (which just happen to DTRT on the MIPS platform, because there's 
just a single underlying mechanism for all kinds of barriers in the MIPS
architecture) in their place can be removed.

 All of these pieces have been visually tested with a live specimen.  VT 
only however at this point, no X11.

 Please apply,

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/7] video: fbdev: pmag-aa-fb: Adapt to current APIs
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
@ 2016-02-22  1:54 ` Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 2/7] video: fbdev: pmag-aa-fb: Enable building as a module Maciej W. Rozycki
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:54 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

Rework the driver to use the current frambuffer and TURBOchannel APIs, 
including proper resource management and using the new framework for 
hardware cursor support.

NB two Bt431 cursor generators are included onboard, both responding at 
the same TURBOchannel bus addresses and with their host data buses wired 
to byte lanes #0 and #1 respectively of the 32-bit bus.  Therefore both 
can be accessed simultaneously with 16-bit data transfers.  Cursor 
outputs of the chip wired to lane #0 drive the respective overlay select 
inputs of the Bt455 RAMDAC, whereas cursor outputs of the chip wired to 
lane #1 drive the respective P3 pixel select inputs of the RAMDAC.

So 5 (out of 17) Bt455 color registers are usable with this board: 
palette entries #0 and #1 for frame buffer pixel data driven while 
neither cursor generator is active, palette entries #8 and #9 for frame 
buffer pixel data driven while cursor generator #1 is active only and 
the overlay entry while cursor generator #0 is active.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-pmag-aa-fb.patch
Index: linux-20160211-4maxp64/drivers/video/fbdev/bt431.h
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/bt431.h
+++ linux-20160211-4maxp64/drivers/video/fbdev/bt431.h
@@ -2,6 +2,7 @@
  *	linux/drivers/video/bt431.h
  *
  *	Copyright 2003  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
+ *	Copyright 2016  Maciej W. Rozycki <macro@linux-mips.org>
  *
  *	This file is subject to the terms and conditions of the GNU General
  *	Public License. See the file COPYING in the main directory of this
@@ -9,6 +10,8 @@
  */
 #include <linux/types.h>
 
+#define BT431_CURSOR_SIZE	64
+
 /*
  * Bt431 cursor generator registers, 32-bit aligned.
  * Two twin Bt431 are used on the DECstation's PMAG-AA.
@@ -196,28 +199,30 @@ static inline void bt431_position_cursor
 	bt431_write_reg_inc(regs, (y >> 8) & 0x0f); /* BT431_REG_CYHI */
 }
 
-static inline void bt431_set_font(struct bt431_regs *regs, u8 fgc,
-				  u16 width, u16 height)
+static inline void bt431_set_cursor(struct bt431_regs *regs,
+				    const char *data, const char *mask,
+				    u16 rop, u16 width, u16 height)
 {
+	u16 x, y;
 	int i;
-	u16 fgp = fgc ? 0xffff : 0x0000;
-	u16 bgp = fgc ? 0x0000 : 0xffff;
 
+	i = 0;
+	width = DIV_ROUND_UP(width, 8);
 	bt431_select_reg(regs, BT431_REG_CRAM_BASE);
-	for (i = BT431_REG_CRAM_BASE; i <= BT431_REG_CRAM_END; i++) {
-		u16 value;
-
-		if (height << 6 <= i << 3)
-			value = bgp;
-		else if (width <= i % 8 << 3)
-			value = bgp;
-		else if (((width >> 3) & 0xffff) > i % 8)
-			value = fgp;
-		else
-			value = fgp & ~(bgp << (width % 8 << 1));
+	for (y = 0; y < BT431_CURSOR_SIZE; y++)
+		for (x = 0; x < BT431_CURSOR_SIZE / 8; x++) {
+			u16 val = 0;
 
-		bt431_write_cmap_inc(regs, value);
-	}
+			if (y < height && x < width) {
+				val = mask[i];
+				if (rop = ROP_XOR)
+					val = (val << 8) | (val ^ data[i]);
+				else
+					val = (val << 8) | (val & data[i]);
+				i++;
+			}
+			bt431_write_cmap_inc(regs, val);
+		}
 }
 
 static inline void bt431_init_cursor(struct bt431_regs *regs)
Index: linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/pmag-aa-fb.c
+++ linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
@@ -8,6 +8,7 @@
  *	and Harald Koerfgen <hkoerfg@web.de>, which itself is derived from
  *	"HP300 Topcat framebuffer support (derived from macfb of all things)
  *	Phil Blundell <philb@gnu.org> 1998"
+ *	Copyright (c) 2016  Maciej W. Rozycki
  *
  *	This file is subject to the terms and conditions of the GNU General
  *	Public License.  See the file COPYING in the main directory of this
@@ -21,37 +22,29 @@
  *
  *	2003-09-21  Thiemo Seufer  <seufer@csv.ica.uni-stuttgart.de>
  *		Hardware cursor support.
+ *
+ *	2016-02-21  Maciej W. Rozycki  <macro@linux-mips.org>
+ *		Version 0.03: Rewritten for the new FB and TC APIs.
  */
-#include <linux/module.h>
-#include <linux/kernel.h>
+
+#include <linux/compiler.h>
 #include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/init.h>
 #include <linux/fb.h>
-#include <linux/console.h>
-
-#include <asm/bootinfo.h>
-#include <asm/dec/machtype.h>
-#include <asm/dec/tc.h>
-
-#include <video/fbcon.h>
-#include <video/fbcon-cfb8.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/tc.h>
+#include <linux/timer.h>
 
 #include "bt455.h"
 #include "bt431.h"
 
 /* Version information */
-#define DRIVER_VERSION "0.02"
+#define DRIVER_VERSION "0.03"
 #define DRIVER_AUTHOR "Karsten Merker <merker@linuxtag.org>"
 #define DRIVER_DESCRIPTION "PMAG-AA Framebuffer Driver"
 
-/* Prototypes */
-static int aafb_set_var(struct fb_var_screeninfo *var, int con,
-			struct fb_info *info);
-
 /*
  * Bt455 RAM DAC register base offset (rel. to TC slot base address).
  */
@@ -68,443 +61,239 @@ static int aafb_set_var(struct fb_var_sc
  */
 #define PMAG_AA_ONBOARD_FBMEM_OFFSET	0x200000
 
-struct aafb_cursor {
-	struct timer_list timer;
-	int enable;
-	int on;
-	int vbl_cnt;
-	int blink_rate;
-	u16 x, y, width, height;
+struct aafb_par {
+	void __iomem *mmio;
+	struct bt455_regs __iomem *bt455;
+	struct bt431_regs __iomem *bt431;
 };
 
-#define CURSOR_TIMER_FREQ	(HZ / 50)
-#define CURSOR_BLINK_RATE	(20)
-#define CURSOR_DRAW_DELAY	(2)
-
-struct aafb_info {
-	struct fb_info info;
-	struct display disp;
-	struct aafb_cursor cursor;
-	struct bt455_regs *bt455;
-	struct bt431_regs *bt431;
-	unsigned long fb_start;
-	unsigned long fb_size;
-	unsigned long fb_line_length;
+static struct fb_var_screeninfo aafb_defined = {
+	.xres		= 1280,
+	.yres		= 1024,
+	.xres_virtual	= 2048,
+	.yres_virtual	= 1024,
+	.bits_per_pixel	= 8,
+	.grayscale	= 1,
+	.red.length	= 0,
+	.green.length	= 1,
+	.blue.length	= 0,
+	.activate	= FB_ACTIVATE_NOW,
+	.accel_flags	= FB_ACCEL_NONE,
+	.sync		= FB_SYNC_ON_GREEN,
+	.vmode		= FB_VMODE_NONINTERLACED,
 };
 
-/*
- * Max 3 TURBOchannel slots -> max 3 PMAG-AA.
- */
-static struct aafb_info my_fb_info[3];
-
-static struct aafb_par {
-} current_par;
-
-static int currcon = -1;
-
-static void aafb_set_cursor(struct aafb_info *info, int on)
-{
-	struct aafb_cursor *c = &info->cursor;
-
-	if (on) {
-		bt431_position_cursor(info->bt431, c->x, c->y);
-		bt431_enable_cursor(info->bt431);
-	} else
-		bt431_erase_cursor(info->bt431);
-}
-
-static void aafbcon_cursor(struct display *disp, int mode, int x, int y)
-{
-	struct aafb_info *info = (struct aafb_info *)disp->fb_info;
-	struct aafb_cursor *c = &info->cursor;
-
-	x *= fontwidth(disp);
-	y *= fontheight(disp);
-
-	if (c->x = x && c->y = y && (mode = CM_ERASE) = !c->enable)
-		return;
-
-	c->enable = 0;
-	if (c->on)
-		aafb_set_cursor(info, 0);
-	c->x = x - disp->var.xoffset;
-	c->y = y - disp->var.yoffset;
-
-	switch (mode) {
-		case CM_ERASE:
-			c->on = 0;
-			break;
-		case CM_DRAW:
-		case CM_MOVE:
-			if (c->on)
-				aafb_set_cursor(info, c->on);
-			else
-				c->vbl_cnt = CURSOR_DRAW_DELAY;
-			c->enable = 1;
-			break;
-	}
-}
+static struct fb_fix_screeninfo aafb_fix = {
+	.id		= "PMAG-AA",
+	.smem_len	= (2048 * 1024),
+	.type		= FB_TYPE_PACKED_PIXELS,
+	.visual		= FB_VISUAL_MONO10,
+	.ypanstep	= 1,
+	.ywrapstep	= 1,
+	.line_length	= 2048,
+	.mmio_len	= PMAG_AA_ONBOARD_FBMEM_OFFSET - PMAG_AA_BT455_OFFSET,
+};
 
-static int aafbcon_set_font(struct display *disp, int width, int height)
+static int aafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 {
-	struct aafb_info *info = (struct aafb_info *)disp->fb_info;
-	struct aafb_cursor *c = &info->cursor;
-	u8 fgc = ~attr_bgcol_ec(disp, disp->conp, &info->info);
+	struct aafb_par *par = info->par;
 
-	if (width > 64 || height > 64 || width < 0 || height < 0)
+	if (cursor->image.height > BT431_CURSOR_SIZE ||
+	    cursor->image.width > BT431_CURSOR_SIZE) {
+		bt431_erase_cursor(par->bt431);
 		return -EINVAL;
-
-	c->height = height;
-	c->width = width;
-
-	bt431_set_font(info->bt431, fgc, width, height);
-
-	return 1;
-}
-
-static void aafb_cursor_timer_handler(unsigned long data)
-{
-	struct aafb_info *info = (struct aafb_info *)data;
-	struct aafb_cursor *c = &info->cursor;
-
-	if (!c->enable)
-		goto out;
-
-	if (c->vbl_cnt && --c->vbl_cnt = 0) {
-		c->on ^= 1;
-		aafb_set_cursor(info, c->on);
-		c->vbl_cnt = c->blink_rate;
 	}
 
-out:
-	c->timer.expires = jiffies + CURSOR_TIMER_FREQ;
-	add_timer(&c->timer);
-}
-
-static void __init aafb_cursor_init(struct aafb_info *info)
-{
-	struct aafb_cursor *c = &info->cursor;
-
-	c->enable = 1;
-	c->on = 1;
-	c->x = c->y = 0;
-	c->width = c->height = 0;
-	c->vbl_cnt = CURSOR_DRAW_DELAY;
-	c->blink_rate = CURSOR_BLINK_RATE;
-
-	init_timer(&c->timer);
-	c->timer.data = (unsigned long)info;
-	c->timer.function = aafb_cursor_timer_handler;
-	mod_timer(&c->timer, jiffies + CURSOR_TIMER_FREQ);
-}
-
-static void __exit aafb_cursor_exit(struct aafb_info *info)
-{
-	struct aafb_cursor *c = &info->cursor;
-
-	del_timer_sync(&c->timer);
-}
-
-static struct display_switch aafb_switch8 = {
-	.setup = fbcon_cfb8_setup,
-	.bmove = fbcon_cfb8_bmove,
-	.clear = fbcon_cfb8_clear,
-	.putc = fbcon_cfb8_putc,
-	.putcs = fbcon_cfb8_putcs,
-	.revc = fbcon_cfb8_revc,
-	.cursor = aafbcon_cursor,
-	.set_font = aafbcon_set_font,
-	.clear_margins = fbcon_cfb8_clear_margins,
-	.fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
-};
+	if (!cursor->enable)
+		bt431_erase_cursor(par->bt431);
 
-static void aafb_get_par(struct aafb_par *par)
-{
-	*par = current_par;
-}
+	if (cursor->set & FB_CUR_SETPOS)
+		bt431_position_cursor(par->bt431,
+				      cursor->image.dx, cursor->image.dy);
+	if (cursor->set & FB_CUR_SETCMAP) {
+		u8 fg = cursor->image.fg_color ? 0xf : 0x0;
+		u8 bg = cursor->image.bg_color ? 0xf : 0x0;
 
-static int aafb_get_fix(struct fb_fix_screeninfo *fix, int con,
-			struct fb_info *info)
-{
-	struct aafb_info *ip = (struct aafb_info *)info;
+		bt455_write_cmap_entry(par->bt455, 8, 0, bg, 0);
+		bt455_write_cmap_entry(par->bt455, 9, 0, bg, 0);
+		bt455_write_ovly_entry(par->bt455, 0, 0, fg, 0);
+	}
+	if (cursor->set & (FB_CUR_SETSIZE | FB_CUR_SETSHAPE | FB_CUR_SETIMAGE))
+		bt431_set_cursor(par->bt431,
+				 cursor->image.data, cursor->mask, cursor->rop,
+				 cursor->image.width, cursor->image.height);
 
-	memset(fix, 0, sizeof(struct fb_fix_screeninfo));
-	strcpy(fix->id, "PMAG-AA");
-	fix->smem_start = ip->fb_start;
-	fix->smem_len = ip->fb_size;
-	fix->type = FB_TYPE_PACKED_PIXELS;
-	fix->ypanstep = 1;
-	fix->ywrapstep = 1;
-	fix->visual = FB_VISUAL_MONO10;
-	fix->line_length = 1280;
-	fix->accel = FB_ACCEL_NONE;
+	if (cursor->enable)
+		bt431_enable_cursor(par->bt431);
 
 	return 0;
 }
 
-static void aafb_set_disp(struct display *disp, int con,
-			  struct aafb_info *info)
-{
-	struct fb_fix_screeninfo fix;
-
-	disp->fb_info = &info->info;
-	aafb_set_var(&disp->var, con, &info->info);
-	if (disp->conp && disp->conp->vc_sw && disp->conp->vc_sw->con_cursor)
-		disp->conp->vc_sw->con_cursor(disp->conp, CM_ERASE);
-	disp->dispsw = &aafb_switch8;
-	disp->dispsw_data = 0;
-
-	aafb_get_fix(&fix, con, &info->info);
-	disp->screen_base = (u8 *) fix.smem_start;
-	disp->visual = fix.visual;
-	disp->type = fix.type;
-	disp->type_aux = fix.type_aux;
-	disp->ypanstep = fix.ypanstep;
-	disp->ywrapstep = fix.ywrapstep;
-	disp->line_length = fix.line_length;
-	disp->next_line = 2048;
-	disp->can_soft_blank = 1;
-	disp->inverse = 0;
-	disp->scrollmode = SCROLL_YREDRAW;
-
-	aafbcon_set_font(disp, fontwidth(disp), fontheight(disp));
-}
+/* 0 unblanks, any other blanks. */
 
-static int aafb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
-			 struct fb_info *info)
+static int aafb_blank(int blank, struct fb_info *info)
 {
-	static u16 color[2] = {0x0000, 0x000f};
-	static struct fb_cmap aafb_cmap = {0, 2, color, color, color, NULL};
+	struct aafb_par *par = info->par;
+	u8 val = blank ? 0x00 : 0x0f;
 
-	fb_copy_cmap(&aafb_cmap, cmap, kspc ? 0 : 2);
+	bt455_write_cmap_entry(par->bt455, 1, val, val, val);
 	return 0;
 }
 
-static int aafb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
-			 struct fb_info *info)
-{
-	u16 color[2] = {0x0000, 0x000f};
-
-	if (cmap->start = 0
-	    && cmap->len = 2
-	    && memcmp(cmap->red, color, sizeof(color)) = 0
-	    && memcmp(cmap->green, color, sizeof(color)) = 0
-	    && memcmp(cmap->blue, color, sizeof(color)) = 0
-	    && cmap->transp = NULL)
-		return 0;
-	else
-		return -EINVAL;
-}
-
-static int aafb_ioctl(struct fb_info *info, u32 cmd, unsigned long arg)
-{
-	/* TODO: Not yet implemented */
-	return -ENOIOCTLCMD;
-}
+static struct fb_ops aafb_ops = {
+	.owner		= THIS_MODULE,
+	.fb_blank	= aafb_blank,
+	.fb_fillrect	= cfb_fillrect,
+	.fb_copyarea	= cfb_copyarea,
+	.fb_imageblit	= cfb_imageblit,
+	.fb_cursor	= aafb_cursor,
+};
 
-static int aafb_switch(int con, struct fb_info *info)
+static int pmagaafb_probe(struct device *dev)
 {
-	struct aafb_info *ip = (struct aafb_info *)info;
-	struct display *old = (currcon < 0) ? &ip->disp : (fb_display + currcon);
-	struct display *new = (con < 0) ? &ip->disp : (fb_display + con);
-
-	if (old->conp && old->conp->vc_sw && old->conp->vc_sw->con_cursor)
-		old->conp->vc_sw->con_cursor(old->conp, CM_ERASE);
+	struct tc_dev *tdev = to_tc_dev(dev);
+	resource_size_t start, len;
+	struct fb_info *info;
+	struct aafb_par *par;
+	int err;
 
-	/* Set the current console. */
-	currcon = con;
-	aafb_set_disp(new, con, ip);
+	info = framebuffer_alloc(sizeof(struct aafb_par), dev);
+	if (!info) {
+		printk(KERN_ERR "%s: Cannot allocate memory\n", dev_name(dev));
+		return -ENOMEM;
+	}
 
-	return 0;
-}
+	par = info->par;
+	dev_set_drvdata(dev, info);
 
-static void aafb_encode_var(struct fb_var_screeninfo *var,
-			    struct aafb_par *par)
-{
-	var->xres = 1280;
-	var->yres = 1024;
-	var->xres_virtual = 2048;
-	var->yres_virtual = 1024;
-	var->xoffset = 0;
-	var->yoffset = 0;
-	var->bits_per_pixel = 8;
-	var->grayscale = 1;
-	var->red.offset = 0;
-	var->red.length = 0;
-	var->red.msb_right = 0;
-	var->green.offset = 0;
-	var->green.length = 1;
-	var->green.msb_right = 0;
-	var->blue.offset = 0;
-	var->blue.length = 0;
-	var->blue.msb_right = 0;
-	var->transp.offset = 0;
-	var->transp.length = 0;
-	var->transp.msb_right = 0;
-	var->nonstd = 0;
-	var->activate &= ~FB_ACTIVATE_MASK & FB_ACTIVATE_NOW;
-	var->accel_flags = 0;
-	var->sync = FB_SYNC_ON_GREEN;
-	var->vmode &= ~FB_VMODE_MASK & FB_VMODE_NONINTERLACED;
-}
+	info->fbops = &aafb_ops;
+	info->fix = aafb_fix;
+	info->var = aafb_defined;
+	info->flags = FBINFO_DEFAULT;
 
-static int aafb_get_var(struct fb_var_screeninfo *var, int con,
-			struct fb_info *info)
-{
-	if (con < 0) {
-		struct aafb_par par;
+	/* Request the I/O MEM resource. */
+	start = tdev->resource.start;
+	len = tdev->resource.end - start + 1;
+	if (!request_mem_region(start, len, dev_name(dev))) {
+		printk(KERN_ERR "%s: Cannot reserve FB region\n",
+		       dev_name(dev));
+		err = -EBUSY;
+		goto err_alloc;
+	}
 
-		memset(var, 0, sizeof(struct fb_var_screeninfo));
-		aafb_get_par(&par);
-		aafb_encode_var(var, &par);
-	} else
-		*var = info->var;
+	/* MMIO mapping setup. */
+	info->fix.mmio_start = start + PMAG_AA_BT455_OFFSET;
+	par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
+	if (!par->mmio) {
+		printk(KERN_ERR "%s: Cannot map MMIO\n", dev_name(dev));
+		err = -ENOMEM;
+		goto err_resource;
+	}
+	par->bt455 = par->mmio - PMAG_AA_BT455_OFFSET + PMAG_AA_BT455_OFFSET;
+	par->bt431 = par->mmio - PMAG_AA_BT455_OFFSET + PMAG_AA_BT431_OFFSET;
 
-	return 0;
-}
+	/* Frame buffer mapping setup. */
+	info->fix.smem_start = start + PMAG_AA_ONBOARD_FBMEM_OFFSET;
+	info->screen_base = ioremap_nocache(info->fix.smem_start,
+					    info->fix.smem_len);
+	if (!info->screen_base) {
+		printk(KERN_ERR "%s: Cannot map FB\n", dev_name(dev));
+		err = -ENOMEM;
+		goto err_mmio_map;
+	}
+	info->screen_size = info->fix.smem_len;
 
-static int aafb_set_var(struct fb_var_screeninfo *var, int con,
-			struct fb_info *info)
-{
-	struct aafb_par par;
+	/* Init colormap. */
+	bt455_write_cmap_entry(par->bt455, 0, 0x00, 0x00, 0x00);
+	bt455_write_cmap_entry(par->bt455, 1, 0x0f, 0x0f, 0x0f);
 
-	aafb_get_par(&par);
-	aafb_encode_var(var, &par);
-	info->var = *var;
+	/* Init hardware cursor. */
+	bt431_erase_cursor(par->bt431);
+	bt431_init_cursor(par->bt431);
 
-	return 0;
-}
+	err = register_framebuffer(info);
+	if (err < 0) {
+		printk(KERN_ERR "%s: Cannot register framebuffer\n",
+		       dev_name(dev));
+		goto err_smem_map;
+	}
 
-static int aafb_update_var(int con, struct fb_info *info)
-{
-	struct aafb_info *ip = (struct aafb_info *)info;
-	struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
+	get_device(dev);
 
-	if (con = currcon)
-		aafbcon_cursor(disp, CM_ERASE, ip->cursor.x, ip->cursor.y);
+	pr_info("fb%d: %s frame buffer device at %s\n",
+		info->node, info->fix.id, dev_name(dev));
 
 	return 0;
-}
-
-/* 0 unblanks, any other blanks. */
 
-static void aafb_blank(int blank, struct fb_info *info)
-{
-	struct aafb_info *ip = (struct aafb_info *)info;
-	u8 val = blank ? 0x00 : 0x0f;
 
-	bt455_write_cmap_entry(ip->bt455, 1, val, val, val);
-	aafbcon_cursor(&ip->disp, CM_ERASE, ip->cursor.x, ip->cursor.y);
-}
-
-static struct fb_ops aafb_ops = {
-	.owner = THIS_MODULE,
-	.fb_get_fix = aafb_get_fix,
-	.fb_get_var = aafb_get_var,
-	.fb_set_var = aafb_set_var,
-	.fb_get_cmap = aafb_get_cmap,
-	.fb_set_cmap = aafb_set_cmap,
-	.fb_ioctl = aafb_ioctl
-};
-
-static int __init init_one(int slot)
-{
-	unsigned long base_addr = CKSEG1ADDR(get_tc_base_addr(slot));
-	struct aafb_info *ip = &my_fb_info[slot];
-
-	memset(ip, 0, sizeof(struct aafb_info));
-
-	/*
-	 * Framebuffer display memory base address and friends.
-	 */
-	ip->bt455 = (struct bt455_regs *) (base_addr + PMAG_AA_BT455_OFFSET);
-	ip->bt431 = (struct bt431_regs *) (base_addr + PMAG_AA_BT431_OFFSET);
-	ip->fb_start = base_addr + PMAG_AA_ONBOARD_FBMEM_OFFSET;
-	ip->fb_size = 2048 * 1024; /* fb_fix_screeninfo.smem_length
-				      seems to be physical */
-	ip->fb_line_length = 2048;
-
-	/*
-	 * Let there be consoles..
-	 */
-	strcpy(ip->info.modename, "PMAG-AA");
-	ip->info.node = -1;
-	ip->info.flags = FBINFO_FLAG_DEFAULT;
-	ip->info.fbops = &aafb_ops;
-	ip->info.disp = &ip->disp;
-	ip->info.changevar = NULL;
-	ip->info.switch_con = &aafb_switch;
-	ip->info.updatevar = &aafb_update_var;
-	ip->info.blank = &aafb_blank;
-
-	aafb_set_disp(&ip->disp, currcon, ip);
-
-	/*
-	 * Configure the RAM DACs.
-	 */
-	bt455_erase_cursor(ip->bt455);
-
-	/* Init colormap. */
-	bt455_write_cmap_entry(ip->bt455, 0, 0x00, 0x00, 0x00);
-	bt455_write_cmap_entry(ip->bt455, 1, 0x0f, 0x0f, 0x0f);
-
-	/* Init hardware cursor. */
-	bt431_init_cursor(ip->bt431);
-	aafb_cursor_init(ip);
-
-	/* Clear the screen. */
-	memset ((void *)ip->fb_start, 0, ip->fb_size);
+err_smem_map:
+	iounmap(info->screen_base);
 
-	if (register_framebuffer(&ip->info) < 0)
-		return -EINVAL;
+err_mmio_map:
+	iounmap(par->mmio);
 
-	printk(KERN_INFO "fb%d: %s frame buffer in TC slot %d\n",
-	       GET_FB_IDX(ip->info.node), ip->info.modename, slot);
+err_resource:
+	release_mem_region(start, len);
 
-	return 0;
+err_alloc:
+	framebuffer_release(info);
+	return err;
 }
 
-static int __exit exit_one(int slot)
+static int __exit pmagaafb_remove(struct device *dev)
 {
-	struct aafb_info *ip = &my_fb_info[slot];
-
-	if (unregister_framebuffer(&ip->info) < 0)
-		return -EINVAL;
+	struct tc_dev *tdev = to_tc_dev(dev);
+	struct fb_info *info = dev_get_drvdata(dev);
+	struct aafb_par *par = info->par;
+	resource_size_t start, len;
 
+	put_device(dev);
+	unregister_framebuffer(info);
+	iounmap(info->screen_base);
+	iounmap(par->mmio);
+	start = tdev->resource.start;
+	len = tdev->resource.end - start + 1;
+	release_mem_region(start, len);
+	framebuffer_release(info);
 	return 0;
 }
 
 /*
  * Initialise the framebuffer.
  */
-int __init pmagaafb_init(void)
-{
-	int sid;
-	int found = 0;
+static const struct tc_device_id pmagaafb_tc_table[] = {
+	{ "DEC     ", "PMAG-AA " },
+	{ }
+};
+MODULE_DEVICE_TABLE(tc, pmagaafb_tc_table);
 
-	while ((sid = search_tc_card("PMAG-AA")) >= 0) {
-		found = 1;
-		claim_tc_card(sid);
-		init_one(sid);
-	}
+static struct tc_driver pmagaafb_driver = {
+	.id_table	= pmagaafb_tc_table,
+	.driver		= {
+		.name	= "pmagaafb",
+		.bus	= &tc_bus_type,
+		.probe	= pmagaafb_probe,
+		.remove	= __exit_p(pmagaafb_remove),
+	},
+};
 
-	return found ? 0 : -ENXIO;
+static int __init pmagaafb_init(void)
+{
+#ifndef MODULE
+	if (fb_get_options("pmagaafb", NULL))
+		return -ENXIO;
+#endif
+	return tc_register_driver(&pmagaafb_driver);
 }
 
 static void __exit pmagaafb_exit(void)
 {
-	int sid;
-
-	while ((sid = search_tc_card("PMAG-AA")) >= 0) {
-		exit_one(sid);
-		release_tc_card(sid);
-	}
+	tc_unregister_driver(&pmagaafb_driver);
 }
 
+module_init(pmagaafb_init);
+module_exit(pmagaafb_exit);
+
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
 MODULE_LICENSE("GPL");
-#ifdef MODULE
-module_init(pmagaafb_init);
-module_exit(pmagaafb_exit);
-#endif

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/7] video: fbdev: pmag-aa-fb: Enable building as a module
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
  2016-02-22  1:54 ` [PATCH 1/7] video: fbdev: pmag-aa-fb: Adapt to current APIs Maciej W. Rozycki
@ 2016-02-22  1:55 ` Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 3/7] video: fbdev: pmag-aa-fb: Report video timings Maciej W. Rozycki
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:55 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

With the current TURBOchannel API support is automagical.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-pmag-aa-module.patch
Index: linux-20160211-4maxp64/drivers/video/fbdev/Kconfig
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/Kconfig
+++ linux-20160211-4maxp64/drivers/video/fbdev/Kconfig
@@ -1808,8 +1808,8 @@ config FB_HIT
 	  frame buffer card.
 
 config FB_PMAG_AA
-	bool "PMAG-AA TURBOchannel framebuffer support"
-	depends on (FB = y) && TC
+	tristate "PMAG-AA TURBOchannel framebuffer support"
+	depends on FB && TC
  	select FB_CFB_FILLRECT
  	select FB_CFB_COPYAREA
  	select FB_CFB_IMAGEBLIT

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/7] video: fbdev: pmag-aa-fb: Report video timings
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
  2016-02-22  1:54 ` [PATCH 1/7] video: fbdev: pmag-aa-fb: Adapt to current APIs Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 2/7] video: fbdev: pmag-aa-fb: Enable building as a module Maciej W. Rozycki
@ 2016-02-22  1:55 ` Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 4/7] video: fbdev: bt455: Remove unneeded colormap helpers for cursor support Maciej W. Rozycki
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:55 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

The board uses hardwired timings compatible with 72Hz DEC VR319-DA and 
VRM17-AA monitors, according to the board owner's manual[1].  These 
timings are accordingly taken from the VR319 manual[2].

References:

[1] "The Monochrome Frame Buffer TURBOchannel Module", Digital Equipment
    Corporation, Order Number: EK-MFBOM-TC-001, December 1991

[2] "Installing and Using the VR319 Monochrome Monitor", Digital
    Equipment Corporation, Order Number: EK-VR319-IN-001, First Edition,
    January 1990, Table 6-1 "Video Timing--1280 x 1024 Resolution"

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-pmag-aa-timing.patch
Index: linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/pmag-aa-fb.c
+++ linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
@@ -79,6 +79,13 @@ static struct fb_var_screeninfo aafb_def
 	.blue.length	= 0,
 	.activate	= FB_ACTIVATE_NOW,
 	.accel_flags	= FB_ACCEL_NONE,
+	.pixclock	= 7645,
+	.left_margin	= 224,
+	.right_margin	= 32,
+	.upper_margin	= 33,
+	.lower_margin	= 3,
+	.hsync_len	= 160,
+	.vsync_len	= 3,
 	.sync		= FB_SYNC_ON_GREEN,
 	.vmode		= FB_VMODE_NONINTERLACED,
 };

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/7] video: fbdev: bt455: Remove unneeded colormap helpers for cursor support
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
                   ` (2 preceding siblings ...)
  2016-02-22  1:55 ` [PATCH 3/7] video: fbdev: pmag-aa-fb: Report video timings Maciej W. Rozycki
@ 2016-02-22  1:55 ` Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 5/7] video: fbdev: pmag-ba-fb: Fix and rework Bt455 colormap handling Maciej W. Rozycki
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:55 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-bt455-cursor.diff
Index: linux-20160211-4maxp64/drivers/video/fbdev/bt455.h
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/bt455.h
+++ linux-20160211-4maxp64/drivers/video/fbdev/bt455.h
@@ -67,28 +67,3 @@ static inline void bt455_write_ovly_entr
 	wmb();
 	regs->addr_ovly = blue & 0x0f;
 }
-
-static inline void bt455_set_cursor(struct bt455_regs *regs)
-{
-	mb();
-	regs->addr_ovly = 0x0f;
-	wmb();
-	regs->addr_ovly = 0x0f;
-	wmb();
-	regs->addr_ovly = 0x0f;
-}
-
-static inline void bt455_erase_cursor(struct bt455_regs *regs)
-{
-	/* bt455_write_cmap_entry(regs, 8, 0x00, 0x00, 0x00); */
-	/* bt455_write_cmap_entry(regs, 9, 0x00, 0x00, 0x00); */
-	bt455_write_ovly_entry(regs, 8, 0x03, 0x03, 0x03);
-	bt455_write_ovly_entry(regs, 9, 0x07, 0x07, 0x07);
-
-	wmb();
-	regs->addr_ovly = 0x09;
-	wmb();
-	regs->addr_ovly = 0x09;
-	wmb();
-	regs->addr_ovly = 0x09;
-}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/7] video: fbdev: pmag-ba-fb: Fix and rework Bt455 colormap handling
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
                   ` (3 preceding siblings ...)
  2016-02-22  1:55 ` [PATCH 4/7] video: fbdev: bt455: Remove unneeded colormap helpers for cursor support Maciej W. Rozycki
@ 2016-02-22  1:55 ` Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 6/7] video: fbdev: pmag-ba-fb: Optimize Bt455 colormap addressing Maciej W. Rozycki
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:55 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

The Bt455 is a greyscale RAMDAC, using the green color palette entries 
only while still providing registers for the red and blue components, 
all the three of which have to be loaded on palette updates.  Chip 
documentation [1] mandates that the unused red and blue registers are 
written with 0.

Therefore update code to follow this requirement and given that it makes 
the red and blue components unusable remove them from internal API calls 
altogether.

References:

[1] "Bt454 Bt455 170 MHz Monolithic CMOS 16 Color Palette RAMDAC",
    Brooktree Corporation, Document Number: L454001, Rev. I

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-bt455-cmap-grey.diff
Index: linux-20160211-4maxp64/drivers/video/fbdev/bt455.h
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/bt455.h
+++ linux-20160211-4maxp64/drivers/video/fbdev/bt455.h
@@ -2,6 +2,7 @@
  *	linux/drivers/video/bt455.h
  *
  *	Copyright 2003  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
+ *	Copyright 2016  Maciej W. Rozycki <macro@linux-mips.org>
  *
  *	This file is subject to the terms and conditions of the GNU General
  *	Public License. See the file COPYING in the main directory of this
@@ -32,38 +33,38 @@ static inline void bt455_select_reg(stru
 /*
  * Read/write to a Bt455 color map register.
  */
-static inline void bt455_read_cmap_entry(struct bt455_regs *regs, int cr,
-					 u8* red, u8* green, u8* blue)
+static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
+					 int cr, u8 *grey)
 {
 	bt455_select_reg(regs, cr);
 	mb();
-	*red = regs->addr_cmap_data & 0x0f;
+	regs->addr_cmap_data;
 	rmb();
-	*green = regs->addr_cmap_data & 0x0f;
+	*grey = regs->addr_cmap_data & 0xf;
 	rmb();
-	*blue = regs->addr_cmap_data & 0x0f;
+	regs->addr_cmap_data;
 }
 
-static inline void bt455_write_cmap_entry(struct bt455_regs *regs, int cr,
-					  u8 red, u8 green, u8 blue)
+static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
+					  int cr, u8 grey)
 {
 	bt455_select_reg(regs, cr);
 	wmb();
-	regs->addr_cmap_data = red & 0x0f;
+	regs->addr_cmap_data = 0x0;
 	wmb();
-	regs->addr_cmap_data = green & 0x0f;
+	regs->addr_cmap_data = grey & 0xf;
 	wmb();
-	regs->addr_cmap_data = blue & 0x0f;
+	regs->addr_cmap_data = 0x0;
 }
 
-static inline void bt455_write_ovly_entry(struct bt455_regs *regs, int cr,
-					  u8 red, u8 green, u8 blue)
+static inline void bt455_write_ovly_entry(struct bt455_regs *regs,
+					  int cr, u8 grey)
 {
 	bt455_select_reg(regs, cr);
 	wmb();
-	regs->addr_ovly = red & 0x0f;
+	regs->addr_ovly = 0x0;
 	wmb();
-	regs->addr_ovly = green & 0x0f;
+	regs->addr_ovly = grey & 0xf;
 	wmb();
-	regs->addr_ovly = blue & 0x0f;
+	regs->addr_ovly = 0x0;
 }
Index: linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/pmag-aa-fb.c
+++ linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
@@ -121,9 +121,9 @@ static int aafb_cursor(struct fb_info *i
 		u8 fg = cursor->image.fg_color ? 0xf : 0x0;
 		u8 bg = cursor->image.bg_color ? 0xf : 0x0;
 
-		bt455_write_cmap_entry(par->bt455, 8, 0, bg, 0);
-		bt455_write_cmap_entry(par->bt455, 9, 0, bg, 0);
-		bt455_write_ovly_entry(par->bt455, 0, 0, fg, 0);
+		bt455_write_cmap_entry(par->bt455, 8, bg);
+		bt455_write_cmap_entry(par->bt455, 9, bg);
+		bt455_write_ovly_entry(par->bt455, 0, fg);
 	}
 	if (cursor->set & (FB_CUR_SETSIZE | FB_CUR_SETSHAPE | FB_CUR_SETIMAGE))
 		bt431_set_cursor(par->bt431,
@@ -143,7 +143,7 @@ static int aafb_blank(int blank, struct 
 	struct aafb_par *par = info->par;
 	u8 val = blank ? 0x00 : 0x0f;
 
-	bt455_write_cmap_entry(par->bt455, 1, val, val, val);
+	bt455_write_cmap_entry(par->bt455, 1, val);
 	return 0;
 }
 
@@ -211,8 +211,8 @@ static int pmagaafb_probe(struct device 
 	info->screen_size = info->fix.smem_len;
 
 	/* Init colormap. */
-	bt455_write_cmap_entry(par->bt455, 0, 0x00, 0x00, 0x00);
-	bt455_write_cmap_entry(par->bt455, 1, 0x0f, 0x0f, 0x0f);
+	bt455_write_cmap_entry(par->bt455, 0, 0x0);
+	bt455_write_cmap_entry(par->bt455, 1, 0xf);
 
 	/* Init hardware cursor. */
 	bt431_erase_cursor(par->bt431);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6/7] video: fbdev: pmag-ba-fb: Optimize Bt455 colormap addressing
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
                   ` (4 preceding siblings ...)
  2016-02-22  1:55 ` [PATCH 5/7] video: fbdev: pmag-ba-fb: Fix and rework Bt455 colormap handling Maciej W. Rozycki
@ 2016-02-22  1:55 ` Maciej W. Rozycki
  2016-02-22  1:55 ` [PATCH 7/7] video: fbdev: bt431: Correct cursor format control macro Maciej W. Rozycki
  2016-02-26 11:15 ` [PATCH 0/7] PMAG-AA frame buffer driver rework Tomi Valkeinen
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:55 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

Use the address autoincrement feature when accessing successive palette 
entries and also skip loading a palette address in overlay register 
assesses which do not use that address.  Provide a red/green/blue 
register sequencer reset helper for use in overlay register assesses 
where the state of the sequencer is not known.

References:

[1] "Bt454 Bt455 170 MHz Monolithic CMOS 16 Color Palette RAMDAC",
    Brooktree Corporation, Document Number: L454001, Rev. I

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-bt455-cmap-addr.diff
Index: linux-20160211-4maxp64/drivers/video/fbdev/bt455.h
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/bt455.h
+++ linux-20160211-4maxp64/drivers/video/fbdev/bt455.h
@@ -30,13 +30,17 @@ static inline void bt455_select_reg(stru
 	regs->addr_cmap = ir & 0x0f;
 }
 
+static inline void bt455_reset_reg(struct bt455_regs *regs)
+{
+	mb();
+	regs->addr_clr = 0;
+}
+
 /*
  * Read/write to a Bt455 color map register.
  */
-static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
-					 int cr, u8 *grey)
+static inline void bt455_read_cmap_next(struct bt455_regs *regs, u8 *grey)
 {
-	bt455_select_reg(regs, cr);
 	mb();
 	regs->addr_cmap_data;
 	rmb();
@@ -45,10 +49,8 @@ static inline void bt455_read_cmap_entry
 	regs->addr_cmap_data;
 }
 
-static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
-					  int cr, u8 grey)
+static inline void bt455_write_cmap_next(struct bt455_regs *regs, u8 grey)
 {
-	bt455_select_reg(regs, cr);
 	wmb();
 	regs->addr_cmap_data = 0x0;
 	wmb();
@@ -57,10 +59,8 @@ static inline void bt455_write_cmap_entr
 	regs->addr_cmap_data = 0x0;
 }
 
-static inline void bt455_write_ovly_entry(struct bt455_regs *regs,
-					  int cr, u8 grey)
+static inline void bt455_write_ovly_next(struct bt455_regs *regs, u8 grey)
 {
-	bt455_select_reg(regs, cr);
 	wmb();
 	regs->addr_ovly = 0x0;
 	wmb();
@@ -68,3 +68,23 @@ static inline void bt455_write_ovly_entr
 	wmb();
 	regs->addr_ovly = 0x0;
 }
+
+static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
+					 int cr, u8 *grey)
+{
+	bt455_select_reg(regs, cr);
+	bt455_read_cmap_next(regs, grey);
+}
+
+static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
+					  int cr, u8 grey)
+{
+	bt455_select_reg(regs, cr);
+	bt455_write_cmap_next(regs, grey);
+}
+
+static inline void bt455_write_ovly_entry(struct bt455_regs *regs, u8 grey)
+{
+	bt455_reset_reg(regs);
+	bt455_write_ovly_next(regs, grey);
+}
Index: linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/pmag-aa-fb.c
+++ linux-20160211-4maxp64/drivers/video/fbdev/pmag-aa-fb.c
@@ -122,8 +122,8 @@ static int aafb_cursor(struct fb_info *i
 		u8 bg = cursor->image.bg_color ? 0xf : 0x0;
 
 		bt455_write_cmap_entry(par->bt455, 8, bg);
-		bt455_write_cmap_entry(par->bt455, 9, bg);
-		bt455_write_ovly_entry(par->bt455, 0, fg);
+		bt455_write_cmap_next(par->bt455, bg);
+		bt455_write_ovly_next(par->bt455, fg);
 	}
 	if (cursor->set & (FB_CUR_SETSIZE | FB_CUR_SETSHAPE | FB_CUR_SETIMAGE))
 		bt431_set_cursor(par->bt431,
@@ -212,7 +212,7 @@ static int pmagaafb_probe(struct device 
 
 	/* Init colormap. */
 	bt455_write_cmap_entry(par->bt455, 0, 0x0);
-	bt455_write_cmap_entry(par->bt455, 1, 0xf);
+	bt455_write_cmap_next(par->bt455, 0xf);
 
 	/* Init hardware cursor. */
 	bt431_erase_cursor(par->bt431);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 7/7] video: fbdev: bt431: Correct cursor format control macro
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
                   ` (5 preceding siblings ...)
  2016-02-22  1:55 ` [PATCH 6/7] video: fbdev: pmag-ba-fb: Optimize Bt455 colormap addressing Maciej W. Rozycki
@ 2016-02-22  1:55 ` Maciej W. Rozycki
  2016-02-26 11:15 ` [PATCH 0/7] PMAG-AA frame buffer driver rework Tomi Valkeinen
  7 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-22  1:55 UTC (permalink / raw)
  To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel

The Bt431 cursor generator supports simultaneous generation of a 64 x 64
and a cross hair cursor in which the cursor format control bit (bit D4)
of the command register "specifies whether the contents of the cursor
RAM are to be logically exclusive-ORed (logical zero) or ORed (logical
one) with the cross hair cursor".  Rename the relevant macro accordingly.

References:

[1] "Bt431 Monolithic CMOS 64 x 64 Pixel Cursor Generator", Brooktree
    Corporation, Document Number: L431001, Rev. J

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-bt431-cmd-xor.diff
Index: linux-20160211-4maxp64/drivers/video/fbdev/bt431.h
=================================--- linux-20160211-4maxp64.orig/drivers/video/fbdev/bt431.h
+++ linux-20160211-4maxp64/drivers/video/fbdev/bt431.h
@@ -63,7 +63,7 @@ static inline u8 bt431_get_value(u16 val
 #define BT431_CMD_CURS_ENABLE	0x40
 #define BT431_CMD_XHAIR_ENABLE	0x20
 #define BT431_CMD_OR_CURSORS	0x10
-#define BT431_CMD_AND_CURSORS	0x00
+#define BT431_CMD_XOR_CURSORS	0x00
 #define BT431_CMD_1_1_MUX	0x00
 #define BT431_CMD_4_1_MUX	0x04
 #define BT431_CMD_5_1_MUX	0x08

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/7] PMAG-AA frame buffer driver rework
  2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
                   ` (6 preceding siblings ...)
  2016-02-22  1:55 ` [PATCH 7/7] video: fbdev: bt431: Correct cursor format control macro Maciej W. Rozycki
@ 2016-02-26 11:15 ` Tomi Valkeinen
  2016-02-27 22:23   ` Maciej W. Rozycki
  7 siblings, 1 reply; 10+ messages in thread
From: Tomi Valkeinen @ 2016-02-26 11:15 UTC (permalink / raw)
  To: Maciej W. Rozycki, Jean-Christophe Plagniol-Villard,
	Geert Uytterhoeven
  Cc: linux-fbdev, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 515 bytes --]

On 22/02/16 03:54, Maciej W. Rozycki wrote:
> Hi,
> 
>  This is an update to the PMAG-AA frame buffer driver to adapt it to our 
> current APIs, which I promised a while ago (too much of a while, which I 
> apologise for).

Interesting hardware. I like the names of these things. "Monolithic CMOS
64 x 64 Pixel Cursor Generator", "TURBOchannel Color Frame Buffer".

Also interesting to see the git history of a file going almost directly
to the initial git commit.

Thanks, queued for 4.6.

 Tomi


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/7] PMAG-AA frame buffer driver rework
  2016-02-26 11:15 ` [PATCH 0/7] PMAG-AA frame buffer driver rework Tomi Valkeinen
@ 2016-02-27 22:23   ` Maciej W. Rozycki
  0 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2016-02-27 22:23 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Ralf Baechle, Jean-Christophe Plagniol-Villard,
	Geert Uytterhoeven, linux-fbdev, linux-kernel

Hi Tomi,

> >  This is an update to the PMAG-AA frame buffer driver to adapt it to our 
> > current APIs, which I promised a while ago (too much of a while, which I 
> > apologise for).
> 
> Interesting hardware. I like the names of these things. "Monolithic CMOS
> 64 x 64 Pixel Cursor Generator", "TURBOchannel Color Frame Buffer".

 Indeed, it sounds so 1980s, doesn't it?  It took me a while too to figure 
out how to wire it to a monitor as the adapter has a TNC connector for its 
output (the colour adapters from the line have a DA-3W3 connector each 
instead).  Fortunately at least video signalling is standard -- EIA-343A 
-- so a modern VGA monitor can be used as long as it does sync-on-green.

> Also interesting to see the git history of a file going almost directly
> to the initial git commit.

 FYI, for anything beyond you'd have to get at LMO's GIT history, e.g.:

$ git blame 66f0a432564b -- drivers/video/fbdev/pmag-aa-fb.c

on a checkout from <git://git.linux-mips.org/pub/scm/ralf/linux>.

 Ralf had been running his MIPS tree in CVS since forever and consequently 
had a slightly more detailed history of changes than Linus had with his 
master copy.  When the move from BitKeeper to GIT was made Ralf was kind 
enough to go through the pain and converted his CVS repository to GIT 
before merging with Linus.

 There are older branches there as well, namely: linux-2.4, linux-2.2, and 
linux-2.0 (anything beyond these is linear on master).  Most operations on 
the master branch are cut through at the initial Linus's commit though, 
you need to name a commit preceding that point -- such as one immediately 
before, which I referred to above -- to go past.

> Thanks, queued for 4.6.

 Thanks.

 I've since noticed blanking will need an update to interpret VESA modes 
correctly, i.e. return errors for the unsupported ones.  This is a minor 
issue, so I'll group it with blanking support for the other two boards 
which is missing for the Bt459 RAMDAC they use.  The Bt459 can switch sync 
generation off, so the full powerdown mode can be supported too in 
addition to plain screen blanking (obviously you can't switch individual 
sync signals in a composite signal).

 Cursor support for the Bt459 would be good to have too; noted as a future 
enhancement possibility.

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-02-27 22:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22  1:54 [PATCH 0/7] PMAG-AA frame buffer driver rework Maciej W. Rozycki
2016-02-22  1:54 ` [PATCH 1/7] video: fbdev: pmag-aa-fb: Adapt to current APIs Maciej W. Rozycki
2016-02-22  1:55 ` [PATCH 2/7] video: fbdev: pmag-aa-fb: Enable building as a module Maciej W. Rozycki
2016-02-22  1:55 ` [PATCH 3/7] video: fbdev: pmag-aa-fb: Report video timings Maciej W. Rozycki
2016-02-22  1:55 ` [PATCH 4/7] video: fbdev: bt455: Remove unneeded colormap helpers for cursor support Maciej W. Rozycki
2016-02-22  1:55 ` [PATCH 5/7] video: fbdev: pmag-ba-fb: Fix and rework Bt455 colormap handling Maciej W. Rozycki
2016-02-22  1:55 ` [PATCH 6/7] video: fbdev: pmag-ba-fb: Optimize Bt455 colormap addressing Maciej W. Rozycki
2016-02-22  1:55 ` [PATCH 7/7] video: fbdev: bt431: Correct cursor format control macro Maciej W. Rozycki
2016-02-26 11:15 ` [PATCH 0/7] PMAG-AA frame buffer driver rework Tomi Valkeinen
2016-02-27 22:23   ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).