Merge remote-tracking branch 'pm/linux-next'
[linux-2.6/next.git] / drivers / video / nvidia / nv_of.c
blob3bc13df4b120fd12c9d888a40de7bef5f7ed3372
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/module.h>
14 #include <linux/kernel.h>
15 #include <linux/delay.h>
16 #include <linux/gfp.h>
17 #include <linux/pci.h>
18 #include <linux/fb.h>
20 #include <asm/io.h>
22 #include <asm/prom.h>
23 #include <asm/pci-bridge.h>
25 #include "nv_type.h"
26 #include "nv_local.h"
27 #include "nv_proto.h"
29 #include "../edid.h"
31 int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
33 struct nvidia_par *par = info->par;
34 struct device_node *parent, *dp;
35 const unsigned char *pedid = NULL;
36 static char *propnames[] = {
37 "DFP,EDID", "LCD,EDID", "EDID", "EDID1",
38 "EDID,B", "EDID,A", NULL };
39 int i;
41 parent = pci_device_to_OF_node(par->pci_dev);
42 if (parent == NULL)
43 return -1;
44 if (par->twoHeads) {
45 const char *pname;
46 int len;
48 for (dp = NULL;
49 (dp = of_get_next_child(parent, dp)) != NULL;) {
50 pname = of_get_property(dp, "name", NULL);
51 if (!pname)
52 continue;
53 len = strlen(pname);
54 if ((pname[len-1] == 'A' && conn == 1) ||
55 (pname[len-1] == 'B' && conn == 2)) {
56 for (i = 0; propnames[i] != NULL; ++i) {
57 pedid = of_get_property(dp,
58 propnames[i], NULL);
59 if (pedid != NULL)
60 break;
62 of_node_put(dp);
63 break;
67 if (pedid == NULL) {
68 for (i = 0; propnames[i] != NULL; ++i) {
69 pedid = of_get_property(parent, propnames[i], NULL);
70 if (pedid != NULL)
71 break;
74 if (pedid) {
75 *out_edid = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
76 if (*out_edid == NULL)
77 return -1;
78 printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
79 return 0;
81 return -1;