Subject: Re: testers needed for change to ofb.c
To: Tim Kelly <hockey@dialectronics.com>
From: Chuck Silvers <chuq@chuq.com>
List: port-macppc
Date: 01/10/2005 08:19:09
--wRRV7LY7NUeQGEoC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
hi,
On Thu, Dec 16, 2004 at 12:51:38PM -0500, Tim Kelly wrote:
> At 7:11 PM -0800 12/13/04, Chuck Silvers wrote:
> >this has the effect of not matching video cards that are not the console,
> >is that the intent? if a machine has two video cards, shouldn't ofb
> >attach to both of them?
>
> I've reviewed the match/attach process and offer a compromise. I match any
> device that lists itself in Open Firmware as a "display" device_type and
> specifically match the console listed in /chosen's stdout to the PCI tag
> during attachment. As far as I know, the "display" device_type in OF will
> only be listed if the device indicates to OF that it is such a device, as
> opposed to the current method which uses PCI device types. Since they are
> not one and the same, this should allow granularity over ofb's such that
> only OF compliant display devices get matched and attached. Other display
> devices should be attached elsewhere, and as far as I know, X uses PCI
> discovery and tags to identify monitors.
this seems pretty reasonable. I cleaned up the patch (and removed the
font-size fiddling, since it's unrelated), it's attached.
could the people who were having trouble with the current code please try
this version?
does anyone know why ofb matches a PCI_PRODUCT_APPLE_CONTROL device
even if its class is not PCI_CLASS_DISPLAY? or is that just a mistake?
-Chuck
--wRRV7LY7NUeQGEoC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.ofb.4"
Index: arch/macppc/dev/ofb.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/ofb.c,v
retrieving revision 1.41
diff -u -p -r1.41 ofb.c
--- arch/macppc/dev/ofb.c 17 Dec 2004 05:44:12 -0000 1.41
+++ arch/macppc/dev/ofb.c 10 Jan 2005 16:15:41 -0000
@@ -124,15 +124,18 @@ ofbmatch(parent, match, aux)
void *aux;
{
struct pci_attach_args *pa = aux;
+ int node;
+ char type[16];
- if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE &&
- PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_CONTROL)
- return 1;
+ if (PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY &&
+ (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_APPLE ||
+ PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_APPLE_CONTROL))
+ return 0;
- if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY)
- return 1;
+ node = pcidev_to_ofdev(pa->pa_pc, pa->pa_tag);
+ OF_getprop(node, "device_type", type, sizeof(type));
- return 0;
+ return strcmp(type, "display") == 0;
}
void
@@ -143,11 +146,22 @@ ofbattach(parent, self, aux)
struct ofb_softc *sc = (struct ofb_softc *)self;
struct pci_attach_args *pa = aux;
struct wsemuldisplaydev_attach_args a;
- int console, node;
struct ofb_devconfig *dc;
+ int console, chosen, stdout, node, l;
+ u_int reg[5];
char devinfo[256];
- console = ofb_is_console();
+ /*
+ * Look up the "assigned-addresses" property of /chosen/stdout.
+ * If it exists and matches the PCI tag of the current device
+ * then this device is the console.
+ */
+
+ chosen = OF_finddevice("/chosen");
+ OF_getprop(chosen, "stdout", &stdout, 4);
+ node = OF_instance_to_package(stdout);
+ l = OF_getprop(node, "assigned-addresses", reg, sizeof(reg));
+ console = l > 4 && (pa->pa_tag & 0xfff00) == (reg[0] & 0xfff00);
if (console) {
dc = &ofb_console_dc;
@@ -321,22 +335,6 @@ ofb_common_init(node, dc)
}
int
-ofb_is_console()
-{
- int chosen, stdout, node;
- char type[16];
-
- chosen = OF_finddevice("/chosen");
- OF_getprop(chosen, "stdout", &stdout, 4);
- node = OF_instance_to_package(stdout);
- OF_getprop(node, "device_type", type, sizeof(type));
- if (strcmp(type, "display") == 0)
- return 1;
- else
- return 0;
-}
-
-int
ofb_ioctl(v, cmd, data, flag, p)
void *v;
u_long cmd;
--wRRV7LY7NUeQGEoC--