Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * rcar_du_vgacon.c -- R-Car Display Unit VGA Connector |
| 3 | * |
Laurent Pinchart | 36d5046 | 2014-02-06 18:13:52 +0100 | [diff] [blame] | 4 | * Copyright (C) 2013-2014 Renesas Electronics Corporation |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 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 | |
| 14 | #include <drm/drmP.h> |
Laurent Pinchart | 3e8da87 | 2015-02-20 11:30:59 +0200 | [diff] [blame] | 15 | #include <drm/drm_atomic_helper.h> |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 16 | #include <drm/drm_crtc.h> |
| 17 | #include <drm/drm_crtc_helper.h> |
| 18 | |
| 19 | #include "rcar_du_drv.h" |
Laurent Pinchart | 6978f12 | 2013-06-15 15:02:12 +0200 | [diff] [blame] | 20 | #include "rcar_du_encoder.h" |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 21 | #include "rcar_du_kms.h" |
| 22 | #include "rcar_du_vgacon.h" |
| 23 | |
| 24 | static int rcar_du_vga_connector_get_modes(struct drm_connector *connector) |
| 25 | { |
| 26 | return 0; |
| 27 | } |
| 28 | |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 29 | static const struct drm_connector_helper_funcs connector_helper_funcs = { |
| 30 | .get_modes = rcar_du_vga_connector_get_modes, |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 31 | .best_encoder = rcar_du_connector_best_encoder, |
| 32 | }; |
| 33 | |
| 34 | static void rcar_du_vga_connector_destroy(struct drm_connector *connector) |
| 35 | { |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 36 | drm_connector_unregister(connector); |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 37 | drm_connector_cleanup(connector); |
| 38 | } |
| 39 | |
| 40 | static enum drm_connector_status |
| 41 | rcar_du_vga_connector_detect(struct drm_connector *connector, bool force) |
| 42 | { |
Laurent Pinchart | 3864c6f | 2013-03-14 22:45:22 +0100 | [diff] [blame] | 43 | return connector_status_connected; |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static const struct drm_connector_funcs connector_funcs = { |
| 47 | .dpms = drm_helper_connector_dpms, |
Laurent Pinchart | 3e8da87 | 2015-02-20 11:30:59 +0200 | [diff] [blame] | 48 | .reset = drm_atomic_helper_connector_reset, |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 49 | .detect = rcar_du_vga_connector_detect, |
| 50 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 51 | .destroy = rcar_du_vga_connector_destroy, |
Laurent Pinchart | 3e8da87 | 2015-02-20 11:30:59 +0200 | [diff] [blame] | 52 | .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, |
| 53 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | int rcar_du_vga_connector_init(struct rcar_du_device *rcdu, |
| 57 | struct rcar_du_encoder *renc) |
| 58 | { |
Laurent Pinchart | 4b96b70 | 2014-03-31 01:50:16 +0200 | [diff] [blame] | 59 | struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc); |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 60 | struct rcar_du_connector *rcon; |
| 61 | struct drm_connector *connector; |
| 62 | int ret; |
| 63 | |
| 64 | rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL); |
| 65 | if (rcon == NULL) |
| 66 | return -ENOMEM; |
| 67 | |
| 68 | connector = &rcon->connector; |
| 69 | connector->display_info.width_mm = 0; |
| 70 | connector->display_info.height_mm = 0; |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 71 | connector->interlace_allowed = true; |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 72 | |
| 73 | ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs, |
| 74 | DRM_MODE_CONNECTOR_VGA); |
| 75 | if (ret < 0) |
| 76 | return ret; |
| 77 | |
| 78 | drm_connector_helper_add(connector, &connector_helper_funcs); |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 79 | ret = drm_connector_register(connector); |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 80 | if (ret < 0) |
| 81 | return ret; |
| 82 | |
| 83 | drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); |
| 84 | drm_object_property_set_value(&connector->base, |
| 85 | rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF); |
| 86 | |
Laurent Pinchart | 4b96b70 | 2014-03-31 01:50:16 +0200 | [diff] [blame] | 87 | ret = drm_mode_connector_attach_encoder(connector, encoder); |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 88 | if (ret < 0) |
| 89 | return ret; |
| 90 | |
Laurent Pinchart | 9e8be27 | 2013-06-15 14:21:51 +0200 | [diff] [blame] | 91 | rcon->encoder = renc; |
| 92 | |
| 93 | return 0; |
| 94 | } |