kbuild: document howto build external modules using several directories
[linux-2.6/verdex.git] / drivers / video / nvidia / nv_of.c
blob7a03d040b1a3255bb0d9e2a5dbc4828b49c36c42
1 /*
2 * linux/drivers/video/nvidia/nv_of.c
4 * Copyright 2004 Antonino A. Daplas <adaplas @pol.net>
6 * Based on rivafb-i2c.c
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
10 * for more details.
13 #include <linux/config.h>
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/delay.h>
18 #include <linux/pci.h>
19 #include <linux/fb.h>
21 #include <asm/io.h>
23 #include <asm/prom.h>
24 #include <asm/pci-bridge.h>
26 #include "nv_type.h"
27 #include "nv_local.h"
28 #include "nv_proto.h"
30 #include "../edid.h"
32 int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
34 struct nvidia_par *par = info->par;
35 struct device_node *parent, *dp;
36 unsigned char *pedid = NULL;
37 static char *propnames[] = {
38 "DFP,EDID", "LCD,EDID", "EDID", "EDID1",
39 "EDID,B", "EDID,A", NULL };
40 int i;
42 parent = pci_device_to_OF_node(par->pci_dev);
43 if (parent == NULL)
44 return -1;
45 if (par->twoHeads) {
46 char *pname;
47 int len;
49 for (dp = NULL;
50 (dp = of_get_next_child(parent, dp)) != NULL;) {
51 pname = (char *)get_property(dp, "name", NULL);
52 if (!pname)
53 continue;
54 len = strlen(pname);
55 if ((pname[len-1] == 'A' && conn == 1) ||
56 (pname[len-1] == 'B' && conn == 2)) {
57 for (i = 0; propnames[i] != NULL; ++i) {
58 pedid = (unsigned char *)
59 get_property(dp, propnames[i],
60 NULL);
61 if (pedid != NULL)
62 break;
64 of_node_put(dp);
65 break;
69 if (pedid == NULL) {
70 for (i = 0; propnames[i] != NULL; ++i) {
71 pedid = (unsigned char *)
72 get_property(parent, propnames[i], NULL);
73 if (pedid != NULL)
74 break;
77 if (pedid) {
78 *out_edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
79 if (*out_edid == NULL)
80 return -1;
81 memcpy(*out_edid, pedid, EDID_LENGTH);
82 printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
83 return 0;
85 return -1;