psb_intel_modes.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2007 Intel Corporation
  4. *
  5. * Authers: Jesse Barnes <jesse.barnes@intel.com>
  6. */
  7. #include <linux/i2c.h>
  8. #include <drm/drm_edid.h>
  9. #include "psb_intel_drv.h"
  10. /**
  11. * psb_intel_ddc_probe
  12. * @adapter: Associated I2C adaptor
  13. */
  14. bool psb_intel_ddc_probe(struct i2c_adapter *adapter)
  15. {
  16. u8 out_buf[] = { 0x0, 0x0 };
  17. u8 buf[2];
  18. int ret;
  19. struct i2c_msg msgs[] = {
  20. {
  21. .addr = 0x50,
  22. .flags = 0,
  23. .len = 1,
  24. .buf = out_buf,
  25. },
  26. {
  27. .addr = 0x50,
  28. .flags = I2C_M_RD,
  29. .len = 1,
  30. .buf = buf,
  31. }
  32. };
  33. ret = i2c_transfer(adapter, msgs, 2);
  34. if (ret == 2)
  35. return true;
  36. return false;
  37. }
  38. /**
  39. * psb_intel_ddc_get_modes - get modelist from monitor
  40. * @connector: DRM connector device to use
  41. * @adapter: Associated I2C adaptor
  42. *
  43. * Fetch the EDID information from @connector using the DDC bus.
  44. */
  45. int psb_intel_ddc_get_modes(struct drm_connector *connector,
  46. struct i2c_adapter *adapter)
  47. {
  48. struct edid *edid;
  49. int ret = 0;
  50. edid = drm_get_edid(connector, adapter);
  51. if (edid) {
  52. drm_connector_update_edid_property(connector, edid);
  53. ret = drm_add_edid_modes(connector, edid);
  54. kfree(edid);
  55. }
  56. return ret;
  57. }