nv_of.c 1.8 KB

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