Commit | Line | Data |
---|---|---|
9e8be272 LP |
1 | /* |
2 | * rcar_du_vgacon.c -- R-Car Display Unit VGA Connector | |
3 | * | |
4 | * Copyright (C) 2013 Renesas 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 | ||
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" | |
6978f123 | 19 | #include "rcar_du_encoder.h" |
9e8be272 LP |
20 | #include "rcar_du_kms.h" |
21 | #include "rcar_du_vgacon.h" | |
22 | ||
23 | static int rcar_du_vga_connector_get_modes(struct drm_connector *connector) | |
24 | { | |
25 | return 0; | |
26 | } | |
27 | ||
28 | static int rcar_du_vga_connector_mode_valid(struct drm_connector *connector, | |
29 | struct drm_display_mode *mode) | |
30 | { | |
31 | return MODE_OK; | |
32 | } | |
33 | ||
34 | static const struct drm_connector_helper_funcs connector_helper_funcs = { | |
35 | .get_modes = rcar_du_vga_connector_get_modes, | |
36 | .mode_valid = rcar_du_vga_connector_mode_valid, | |
37 | .best_encoder = rcar_du_connector_best_encoder, | |
38 | }; | |
39 | ||
40 | static void rcar_du_vga_connector_destroy(struct drm_connector *connector) | |
41 | { | |
42 | drm_sysfs_connector_remove(connector); | |
43 | drm_connector_cleanup(connector); | |
44 | } | |
45 | ||
46 | static enum drm_connector_status | |
47 | rcar_du_vga_connector_detect(struct drm_connector *connector, bool force) | |
48 | { | |
3864c6f4 | 49 | return connector_status_connected; |
9e8be272 LP |
50 | } |
51 | ||
52 | static const struct drm_connector_funcs connector_funcs = { | |
53 | .dpms = drm_helper_connector_dpms, | |
54 | .detect = rcar_du_vga_connector_detect, | |
55 | .fill_modes = drm_helper_probe_single_connector_modes, | |
56 | .destroy = rcar_du_vga_connector_destroy, | |
57 | }; | |
58 | ||
59 | int rcar_du_vga_connector_init(struct rcar_du_device *rcdu, | |
60 | struct rcar_du_encoder *renc) | |
61 | { | |
62 | struct rcar_du_connector *rcon; | |
63 | struct drm_connector *connector; | |
64 | int ret; | |
65 | ||
66 | rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL); | |
67 | if (rcon == NULL) | |
68 | return -ENOMEM; | |
69 | ||
70 | connector = &rcon->connector; | |
71 | connector->display_info.width_mm = 0; | |
72 | connector->display_info.height_mm = 0; | |
73 | ||
74 | ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs, | |
75 | DRM_MODE_CONNECTOR_VGA); | |
76 | if (ret < 0) | |
77 | return ret; | |
78 | ||
79 | drm_connector_helper_add(connector, &connector_helper_funcs); | |
80 | ret = drm_sysfs_connector_add(connector); | |
81 | if (ret < 0) | |
82 | return ret; | |
83 | ||
84 | drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); | |
85 | drm_object_property_set_value(&connector->base, | |
86 | rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF); | |
87 | ||
88 | ret = drm_mode_connector_attach_encoder(connector, &renc->encoder); | |
89 | if (ret < 0) | |
90 | return ret; | |
91 | ||
92 | connector->encoder = &renc->encoder; | |
93 | rcon->encoder = renc; | |
94 | ||
95 | return 0; | |
96 | } |