psb_intel_modes.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2007 Intel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Authers: Jesse Barnes <jesse.barnes@intel.com>
  18. */
  19. #include <linux/i2c.h>
  20. #include <linux/fb.h>
  21. #include <drm/drmP.h>
  22. #include "psb_intel_drv.h"
  23. /**
  24. * psb_intel_ddc_probe
  25. *
  26. */
  27. bool psb_intel_ddc_probe(struct i2c_adapter *adapter)
  28. {
  29. u8 out_buf[] = { 0x0, 0x0 };
  30. u8 buf[2];
  31. int ret;
  32. struct i2c_msg msgs[] = {
  33. {
  34. .addr = 0x50,
  35. .flags = 0,
  36. .len = 1,
  37. .buf = out_buf,
  38. },
  39. {
  40. .addr = 0x50,
  41. .flags = I2C_M_RD,
  42. .len = 1,
  43. .buf = buf,
  44. }
  45. };
  46. ret = i2c_transfer(adapter, msgs, 2);
  47. if (ret == 2)
  48. return true;
  49. return false;
  50. }
  51. /**
  52. * psb_intel_ddc_get_modes - get modelist from monitor
  53. * @connector: DRM connector device to use
  54. *
  55. * Fetch the EDID information from @connector using the DDC bus.
  56. */
  57. int psb_intel_ddc_get_modes(struct drm_connector *connector,
  58. struct i2c_adapter *adapter)
  59. {
  60. struct edid *edid;
  61. int ret = 0;
  62. edid = drm_get_edid(connector, adapter);
  63. if (edid) {
  64. drm_mode_connector_update_edid_property(connector, edid);
  65. ret = drm_add_edid_modes(connector, edid);
  66. kfree(edid);
  67. }
  68. return ret;
  69. }