Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/pci.h> |
| 18 | #include <linux/fb.h> |
| 19 | |
| 20 | #include <asm/io.h> |
| 21 | |
| 22 | #include <asm/prom.h> |
| 23 | #include <asm/pci-bridge.h> |
| 24 | |
| 25 | #include "nv_type.h" |
| 26 | #include "nv_local.h" |
| 27 | #include "nv_proto.h" |
| 28 | |
Benjamin Herrenschmidt | 85f1503 | 2005-11-07 01:00:30 -0800 | [diff] [blame] | 29 | #include "../edid.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Benjamin Herrenschmidt | 85f1503 | 2005-11-07 01:00:30 -0800 | [diff] [blame] | 31 | int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { |
Alexey Dobriyan | 2d21247 | 2005-09-11 04:01:09 +0400 | [diff] [blame] | 33 | struct nvidia_par *par = info->par; |
Benjamin Herrenschmidt | 85f1503 | 2005-11-07 01:00:30 -0800 | [diff] [blame] | 34 | struct device_node *parent, *dp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | unsigned char *pedid = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | static char *propnames[] = { |
Benjamin Herrenschmidt | 85f1503 | 2005-11-07 01:00:30 -0800 | [diff] [blame] | 37 | "DFP,EDID", "LCD,EDID", "EDID", "EDID1", |
| 38 | "EDID,B", "EDID,A", NULL }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | int i; |
| 40 | |
Benjamin Herrenschmidt | 85f1503 | 2005-11-07 01:00:30 -0800 | [diff] [blame] | 41 | parent = pci_device_to_OF_node(par->pci_dev); |
| 42 | if (parent == NULL) |
| 43 | return -1; |
| 44 | if (par->twoHeads) { |
| 45 | char *pname; |
| 46 | int len; |
| 47 | |
| 48 | for (dp = NULL; |
| 49 | (dp = of_get_next_child(parent, dp)) != NULL;) { |
| 50 | pname = (char *)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 = (unsigned char *) |
| 58 | get_property(dp, propnames[i], |
| 59 | NULL); |
| 60 | if (pedid != NULL) |
| 61 | break; |
| 62 | } |
| 63 | of_node_put(dp); |
| 64 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | } |
Benjamin Herrenschmidt | 85f1503 | 2005-11-07 01:00:30 -0800 | [diff] [blame] | 68 | if (pedid == NULL) { |
| 69 | for (i = 0; propnames[i] != NULL; ++i) { |
| 70 | pedid = (unsigned char *) |
| 71 | get_property(parent, propnames[i], NULL); |
| 72 | if (pedid != NULL) |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | if (pedid) { |
| 77 | *out_edid = kmalloc(EDID_LENGTH, GFP_KERNEL); |
| 78 | if (*out_edid == NULL) |
| 79 | return -1; |
| 80 | memcpy(*out_edid, pedid, EDID_LENGTH); |
| 81 | printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn); |
| 82 | return 0; |
| 83 | } |
| 84 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |