blob: 8d6125c1c0f9352fd9f5449b8877f4c3e89be05b [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>
Laurent Pinchart3e8da872015-02-20 11:30:59 +020015#include <drm/drm_atomic_helper.h>
Laurent Pinchart9e8be272013-06-15 14:21:51 +020016#include <drm/drm_crtc.h>
17#include <drm/drm_crtc_helper.h>
18
19#include "rcar_du_drv.h"
Laurent Pinchart6978f122013-06-15 15:02:12 +020020#include "rcar_du_encoder.h"
Laurent Pinchart9e8be272013-06-15 14:21:51 +020021#include "rcar_du_kms.h"
22#include "rcar_du_vgacon.h"
23
24static int rcar_du_vga_connector_get_modes(struct drm_connector *connector)
25{
26 return 0;
27}
28
Laurent Pinchart9e8be272013-06-15 14:21:51 +020029static const struct drm_connector_helper_funcs connector_helper_funcs = {
30 .get_modes = rcar_du_vga_connector_get_modes,
Laurent Pinchart9e8be272013-06-15 14:21:51 +020031};
32
Laurent Pinchart9e8be272013-06-15 14:21:51 +020033static enum drm_connector_status
34rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
35{
Laurent Pinchart3864c6f2013-03-14 22:45:22 +010036 return connector_status_connected;
Laurent Pinchart9e8be272013-06-15 14:21:51 +020037}
38
39static const struct drm_connector_funcs connector_funcs = {
Laurent Pinchartf3483232015-02-22 01:49:11 +020040 .dpms = drm_atomic_helper_connector_dpms,
Laurent Pinchart3e8da872015-02-20 11:30:59 +020041 .reset = drm_atomic_helper_connector_reset,
Laurent Pinchart9e8be272013-06-15 14:21:51 +020042 .detect = rcar_du_vga_connector_detect,
43 .fill_modes = drm_helper_probe_single_connector_modes,
Laurent Pinchartc1d4b382015-09-28 18:39:53 +030044 .destroy = drm_connector_cleanup,
Laurent Pinchart3e8da872015-02-20 11:30:59 +020045 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
46 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
Laurent Pinchart9e8be272013-06-15 14:21:51 +020047};
48
49int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
50 struct rcar_du_encoder *renc)
51{
Laurent Pinchart4b96b702014-03-31 01:50:16 +020052 struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020053 struct rcar_du_connector *rcon;
54 struct drm_connector *connector;
55 int ret;
56
57 rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL);
58 if (rcon == NULL)
59 return -ENOMEM;
60
61 connector = &rcon->connector;
62 connector->display_info.width_mm = 0;
63 connector->display_info.height_mm = 0;
Laurent Pinchart906eff72014-12-09 19:11:18 +020064 connector->interlace_allowed = true;
Laurent Pinchart9e8be272013-06-15 14:21:51 +020065
66 ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
67 DRM_MODE_CONNECTOR_VGA);
68 if (ret < 0)
69 return ret;
70
71 drm_connector_helper_add(connector, &connector_helper_funcs);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020072
Laurent Pinchartf3483232015-02-22 01:49:11 +020073 connector->dpms = DRM_MODE_DPMS_OFF;
Laurent Pinchart9e8be272013-06-15 14:21:51 +020074 drm_object_property_set_value(&connector->base,
75 rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
76
Laurent Pinchart4b96b702014-03-31 01:50:16 +020077 ret = drm_mode_connector_attach_encoder(connector, encoder);
Laurent Pinchart9e8be272013-06-15 14:21:51 +020078 if (ret < 0)
79 return ret;
80
Laurent Pinchart9e8be272013-06-15 14:21:51 +020081 return 0;
82}