rcar_du_vgacon.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 enum drm_connector_status
  30. rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
  31. {
  32. return connector_status_connected;
  33. }
  34. static const struct drm_connector_funcs connector_funcs = {
  35. .dpms = drm_atomic_helper_connector_dpms,
  36. .reset = drm_atomic_helper_connector_reset,
  37. .detect = rcar_du_vga_connector_detect,
  38. .fill_modes = drm_helper_probe_single_connector_modes,
  39. .destroy = drm_connector_cleanup,
  40. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  41. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  42. };
  43. int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
  44. struct rcar_du_encoder *renc)
  45. {
  46. struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
  47. struct rcar_du_connector *rcon;
  48. struct drm_connector *connector;
  49. int ret;
  50. rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL);
  51. if (rcon == NULL)
  52. return -ENOMEM;
  53. connector = &rcon->connector;
  54. connector->display_info.width_mm = 0;
  55. connector->display_info.height_mm = 0;
  56. connector->interlace_allowed = true;
  57. ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
  58. DRM_MODE_CONNECTOR_VGA);
  59. if (ret < 0)
  60. return ret;
  61. drm_connector_helper_add(connector, &connector_helper_funcs);
  62. connector->dpms = DRM_MODE_DPMS_OFF;
  63. drm_object_property_set_value(&connector->base,
  64. rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
  65. ret = drm_mode_connector_attach_encoder(connector, encoder);
  66. if (ret < 0)
  67. return ret;
  68. rcon->encoder = renc;
  69. return 0;
  70. }