arcpgu_hdmi.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * ARC PGU DRM driver.
  3. *
  4. * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <drm/drm_crtc.h>
  17. #include <drm/drm_encoder.h>
  18. #include <drm/drm_device.h>
  19. #include "arcpgu.h"
  20. static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
  21. .destroy = drm_encoder_cleanup,
  22. };
  23. int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
  24. {
  25. struct drm_encoder *encoder;
  26. struct drm_bridge *bridge;
  27. int ret = 0;
  28. encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
  29. if (encoder == NULL)
  30. return -ENOMEM;
  31. /* Locate drm bridge from the hdmi encoder DT node */
  32. bridge = of_drm_find_bridge(np);
  33. if (!bridge)
  34. return -EPROBE_DEFER;
  35. encoder->possible_crtcs = 1;
  36. encoder->possible_clones = 0;
  37. ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
  38. DRM_MODE_ENCODER_TMDS, NULL);
  39. if (ret)
  40. return ret;
  41. /* Link drm_bridge to encoder */
  42. ret = drm_bridge_attach(encoder, bridge, NULL);
  43. if (ret)
  44. drm_encoder_cleanup(encoder);
  45. return ret;
  46. }