rcar_du_vgacon.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * rcar_du_vgacon.c -- R-Car Display Unit VGA Connector
  3. *
  4. * Copyright (C) 2013-2014 Renesas Electronics Corporation
  5. *
  6. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <drm/drmP.h>
  14. #include <drm/drm_atomic_helper.h>
  15. #include <drm/drm_crtc.h>
  16. #include <drm/drm_crtc_helper.h>
  17. #include "rcar_du_drv.h"
  18. #include "rcar_du_encoder.h"
  19. #include "rcar_du_kms.h"
  20. #include "rcar_du_vgacon.h"
  21. static int rcar_du_vga_connector_get_modes(struct drm_connector *connector)
  22. {
  23. return 0;
  24. }
  25. static const struct drm_connector_helper_funcs connector_helper_funcs = {
  26. .get_modes = rcar_du_vga_connector_get_modes,
  27. .best_encoder = rcar_du_connector_best_encoder,
  28. };
  29. static void rcar_du_vga_connector_destroy(struct drm_connector *connector)
  30. {
  31. drm_connector_unregister(connector);
  32. drm_connector_cleanup(connector);
  33. }
  34. static enum drm_connector_status
  35. rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
  36. {
  37. return connector_status_connected;
  38. }
  39. static const struct drm_connector_funcs connector_funcs = {
  40. .dpms = drm_atomic_helper_connector_dpms,
  41. .reset = drm_atomic_helper_connector_reset,
  42. .detect = rcar_du_vga_connector_detect,
  43. .fill_modes = drm_helper_probe_single_connector_modes,
  44. .destroy = rcar_du_vga_connector_destroy,
  45. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  46. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  47. };
  48. int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
  49. struct rcar_du_encoder *renc)
  50. {
  51. struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
  52. struct rcar_du_connector *rcon;
  53. struct drm_connector *connector;
  54. int ret;
  55. rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL);
  56. if (rcon == NULL)
  57. return -ENOMEM;
  58. connector = &rcon->connector;
  59. connector->display_info.width_mm = 0;
  60. connector->display_info.height_mm = 0;
  61. connector->interlace_allowed = true;
  62. ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
  63. DRM_MODE_CONNECTOR_VGA);
  64. if (ret < 0)
  65. return ret;
  66. drm_connector_helper_add(connector, &connector_helper_funcs);
  67. ret = drm_connector_register(connector);
  68. if (ret < 0)
  69. return ret;
  70. connector->dpms = DRM_MODE_DPMS_OFF;
  71. drm_object_property_set_value(&connector->base,
  72. rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
  73. ret = drm_mode_connector_attach_encoder(connector, encoder);
  74. if (ret < 0)
  75. return ret;
  76. rcon->encoder = renc;
  77. return 0;
  78. }