nv_of.c 1.7 KB

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