nv_of.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 (dp = NULL;
  39. (dp = of_get_next_child(parent, dp)) != NULL;) {
  40. pname = of_get_property(dp, "name", NULL);
  41. if (!pname)
  42. continue;
  43. len = strlen(pname);
  44. if ((pname[len-1] == 'A' && conn == 1) ||
  45. (pname[len-1] == 'B' && conn == 2)) {
  46. for (i = 0; propnames[i] != NULL; ++i) {
  47. pedid = of_get_property(dp,
  48. propnames[i], NULL);
  49. if (pedid != NULL)
  50. break;
  51. }
  52. of_node_put(dp);
  53. break;
  54. }
  55. }
  56. }
  57. if (pedid == NULL) {
  58. for (i = 0; propnames[i] != NULL; ++i) {
  59. pedid = of_get_property(parent, propnames[i], NULL);
  60. if (pedid != NULL)
  61. break;
  62. }
  63. }
  64. if (pedid) {
  65. *out_edid = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
  66. if (*out_edid == NULL)
  67. return -1;
  68. printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
  69. return 0;
  70. }
  71. return -1;
  72. }