Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/drivers/video/nvidia/nv_of.c | |
3 | * | |
4 | * Copyright 2004 Antonino A. Daplas <adaplas @pol.net> | |
5 | * | |
6 | * Based on rivafb-i2c.c | |
7 | * | |
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. | |
11 | */ | |
12 | ||
1da177e4 LT |
13 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | |
1da177e4 LT |
15 | #include <linux/delay.h> |
16 | #include <linux/pci.h> | |
17 | #include <linux/fb.h> | |
18 | ||
19 | #include <asm/io.h> | |
20 | ||
21 | #include <asm/prom.h> | |
22 | #include <asm/pci-bridge.h> | |
23 | ||
24 | #include "nv_type.h" | |
25 | #include "nv_local.h" | |
26 | #include "nv_proto.h" | |
27 | ||
85f1503a | 28 | #include "../edid.h" |
1da177e4 | 29 | |
85f1503a | 30 | int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid) |
1da177e4 | 31 | { |
2d212479 | 32 | struct nvidia_par *par = info->par; |
85f1503a | 33 | struct device_node *parent, *dp; |
b04e3dd4 | 34 | const unsigned char *pedid = NULL; |
1da177e4 | 35 | static char *propnames[] = { |
85f1503a BH |
36 | "DFP,EDID", "LCD,EDID", "EDID", "EDID1", |
37 | "EDID,B", "EDID,A", NULL }; | |
1da177e4 LT |
38 | int i; |
39 | ||
85f1503a BH |
40 | parent = pci_device_to_OF_node(par->pci_dev); |
41 | if (parent == NULL) | |
42 | return -1; | |
43 | if (par->twoHeads) { | |
b04e3dd4 | 44 | const char *pname; |
85f1503a BH |
45 | int len; |
46 | ||
47 | for (dp = NULL; | |
48 | (dp = of_get_next_child(parent, dp)) != NULL;) { | |
40cd3a45 | 49 | pname = of_get_property(dp, "name", NULL); |
85f1503a BH |
50 | if (!pname) |
51 | continue; | |
52 | len = strlen(pname); | |
53 | if ((pname[len-1] == 'A' && conn == 1) || | |
54 | (pname[len-1] == 'B' && conn == 2)) { | |
55 | for (i = 0; propnames[i] != NULL; ++i) { | |
40cd3a45 SR |
56 | pedid = of_get_property(dp, |
57 | propnames[i], NULL); | |
85f1503a BH |
58 | if (pedid != NULL) |
59 | break; | |
60 | } | |
61 | of_node_put(dp); | |
62 | break; | |
63 | } | |
64 | } | |
65 | } | |
66 | if (pedid == NULL) { | |
1da177e4 | 67 | for (i = 0; propnames[i] != NULL; ++i) { |
40cd3a45 | 68 | pedid = of_get_property(parent, propnames[i], NULL); |
85f1503a BH |
69 | if (pedid != NULL) |
70 | break; | |
1da177e4 LT |
71 | } |
72 | } | |
85f1503a | 73 | if (pedid) { |
bfba7b37 | 74 | *out_edid = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL); |
85f1503a BH |
75 | if (*out_edid == NULL) |
76 | return -1; | |
85f1503a BH |
77 | printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn); |
78 | return 0; | |
79 | } | |
80 | return -1; | |
1da177e4 | 81 | } |