Subject: testers needed for change to ofb.c
To: None <port-macppc@netbsd.org>
From: Tim Kelly <hockey@dialectronics.com>
List: port-macppc
Date: 12/09/2004 15:32:17
Thanks to Brian Hechinger's observation that his Radeon card was not
getting a node in Open Firmware, we've uncovered a bug in the attachment
process of Open Firmware based frame buffers (ofb*). If you have the stock
video output device and can apply patches, please try the patch at the
bottom. I am wanting a wider range of boxes to make sure nothing breaks
with this approach. It also includes code that will get ofb to use 8 point
font up to and including 1024x768 resolution. So far Brian and I have
tested this with no ill effects.
thanks in advance,
tim
Index: ofb.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/ofb.c,v
retrieving revision 1.39
diff -d -u -r1.39 ofb.c
--- ofb.c 24 Apr 2004 15:49:00 -0000 1.39
+++ ofb.c 9 Dec 2004 15:49:28 -0000
@@ -117,6 +117,8 @@
static int ofb_getcmap __P((struct ofb_softc *, struct wsdisplay_cmap *));
static int ofb_putcmap __P((struct ofb_softc *, struct wsdisplay_cmap *));
+int ofb_match_console(int);
+
int
ofbmatch(parent, match, aux)
struct device *parent;
@@ -125,14 +127,18 @@
{
struct pci_attach_args *pa = aux;
+ printf("ofbmatch PCI tag: %x\n", pa->pa_tag);
+
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_CONTROL)
- return 1;
+ return ofb_match_console(pa->pa_tag);
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY)
- return 1;
+ return ofb_match_console(pa->pa_tag);
return 0;
+
+
}
void
@@ -150,12 +156,14 @@
console = ofb_is_console();
if (console) {
+ printf("ofb_is_console tag: %x\n", pa->pa_tag);
dc = &ofb_console_dc;
node = dc->dc_node;
sc->nscreens = 1;
} else {
int i, len, screenbytes;
+ printf("ofb_is_not_console tag: %x\n",pa->pa_tag);
dc = malloc(sizeof(struct ofb_devconfig), M_DEVBUF, M_WAITOK);
memset(dc, 0, sizeof(struct ofb_devconfig));
node = pcidev_to_ofdev(pa->pa_pc, pa->pa_tag);
@@ -282,7 +290,7 @@
ri->ri_flg = RI_FORCEMONO | RI_FULLCLEAR | RI_CENTER;
/* If screen is smaller than 1024x768, use small font. */
- if ((width < 1024 || height < 768) && copy_rom_font() == 0) {
+ if ((width <= 1024 || height <= 768) && copy_rom_font() == 0) {
int cols, rows;
OF_interpret("#lines", 1, &rows);
@@ -313,6 +321,51 @@
}
int
+#if 1
+ofb_match_console(tag)
+ pcitag_t tag;
+
+#else
+ofb_match_console(dev_node)
+ int dev_node;
+#endif
+{
+ int chosen, stdout, node;
+
+ chosen = OF_finddevice("/chosen");
+ OF_getprop(chosen, "stdout", &stdout, 4);
+ node = OF_instance_to_package(stdout);
+
+#if 1
+{
+ /* do it by "a-a" property and extract tag */
+ /* if no a-a, it's not the console we're looking for */
+ u_int reg[5];
+ int l;
+
+ l = OF_getprop(node, "assigned-addresses", reg, sizeof(reg));
+ printf("ofb_match_console tag: %x, l: %d\n", reg[0] & 0xfff00, l);
+ if (l > 4) {
+ if ((tag & 0xfff00) == (reg[0] & 0xfff00))
+ return 1;
+ else
+ return 0;
+ } else
+ return 0;
+
+}
+#else
+ dev_node = pcidev_to_ofdev(pc, tag);
+ dev_node = OF_instance_to_package(dev_node);
+
+ if (node == dev_node)
+ return 1;
+ else
+ return 0;
+#endif
+}
+
+int
ofb_is_console()
{
int chosen, stdout, node;
@@ -477,7 +530,7 @@
ofb_common_init(node, dc);
- if (ri->ri_width >= 1024 && ri->ri_height >= 768) {
+ if (ri->ri_width > 1024 && ri->ri_height > 768) {
int i, screenbytes = ri->ri_stride * ri->ri_height;
for (i = 0; i < screenbytes; i += sizeof(u_int32_t))