blob: 752747a5e920e847ac689aa78555da1c12716b9e [file] [log] [blame]
Laurent Pinchart9e8be272013-06-15 14:21:51 +02001/*
2 * rcar_du_vgacon.c -- R-Car Display Unit VGA Connector
3 *
Laurent Pinchart36d50462014-02-06 18:13:52 +01004 * Copyright (C) 2013-2014 Renesas Electronics Corporation
Laurent Pinchart9e8be272013-06-15 14:21:51 +02005 *
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>
15#include <drm/drm_crtc.h>
16#include <drm/drm_crtc_helper.h>
17
18#include "rcar_du_drv.h"
Laurent Pinchart6978f122013-06-15 15:02:12 +020019#include "rcar_du_encoder.h"
Laurent Pinchart9e8be272013-06-15 14:21:51 +020020#include "rcar_du_kms.h"
21#include "rcar_du_vgacon.h"
22
23static int rcar_du_vga_connector_get_modes(struct drm_connector *connector)
24{
25 return 0;
26}
27
Laurent Pinchart9e8be272013-06-15 14:21:51 +020028static const struct drm_connector_helper_funcs connector_helper_funcs = {
29 .get_modes = rcar_du_vga_connector_get_modes,
Laurent Pinchart9e8be272013-06-15 14:21:51 +020030 .best_encoder = rcar_du_connector_best_encoder,
31};
32
33static void rcar_du_vga_connector_destroy(struct drm_connector *connector)
34{
Thomas Wood34ea3d32014-05-29 16:57:41 +010035 drm_connector_unregister(connector);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020036 drm_connector_cleanup(connector);
37}
38
39static enum drm_connector_status
40rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
41{
Laurent Pinchart3864c6f2013-03-14 22:45:22 +010042 return connector_status_connected;
Laurent Pinchart9e8be272013-06-15 14:21:51 +020043}
44
45static const struct drm_connector_funcs connector_funcs = {
46 .dpms = drm_helper_connector_dpms,
47 .detect = rcar_du_vga_connector_detect,
48 .fill_modes = drm_helper_probe_single_connector_modes,
49 .destroy = rcar_du_vga_connector_destroy,
50};
51
52int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
53 struct rcar_du_encoder *renc)
54{
Laurent Pinchart4b96b702014-03-31 01:50:16 +020055 struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020056 struct rcar_du_connector *rcon;
57 struct drm_connector *connector;
58 int ret;
59
60 rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL);
61 if (rcon == NULL)
62 return -ENOMEM;
63
64 connector = &rcon->connector;
65 connector->display_info.width_mm = 0;
66 connector->display_info.height_mm = 0;
67
68 ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
69 DRM_MODE_CONNECTOR_VGA);
70 if (ret < 0)
71 return ret;
72
73 drm_connector_helper_add(connector, &connector_helper_funcs);
Thomas Wood34ea3d32014-05-29 16:57:41 +010074 ret = drm_connector_register(connector);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020075 if (ret < 0)
76 return ret;
77
78 drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
79 drm_object_property_set_value(&connector->base,
80 rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
81
Laurent Pinchart4b96b702014-03-31 01:50:16 +020082 ret = drm_mode_connector_attach_encoder(connector, encoder);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020083 if (ret < 0)
84 return ret;
85
Laurent Pinchart4b96b702014-03-31 01:50:16 +020086 connector->encoder = encoder;
Laurent Pinchart9e8be272013-06-15 14:21:51 +020087 rcon->encoder = renc;
88
89 return 0;
90}