1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <drm/drmP.h>
15#include <drm/drm_atomic_helper.h>
16#include <drm/drm_crtc.h>
17#include <drm/drm_crtc_helper.h>
18
19#include "rcar_du_drv.h"
20#include "rcar_du_encoder.h"
21#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
29static const struct drm_connector_helper_funcs connector_helper_funcs = {
30 .get_modes = rcar_du_vga_connector_get_modes,
31};
32
33static enum drm_connector_status
34rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
35{
36 return connector_status_connected;
37}
38
39static const struct drm_connector_funcs connector_funcs = {
40 .dpms = drm_atomic_helper_connector_dpms,
41 .reset = drm_atomic_helper_connector_reset,
42 .detect = rcar_du_vga_connector_detect,
43 .fill_modes = drm_helper_probe_single_connector_modes,
44 .destroy = drm_connector_cleanup,
45 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
46 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
47};
48
49int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
50 struct rcar_du_encoder *renc)
51{
52 struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
53 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;
64 connector->interlace_allowed = true;
65
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);
72
73 connector->dpms = DRM_MODE_DPMS_OFF;
74 drm_object_property_set_value(&connector->base,
75 rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
76
77 ret = drm_mode_connector_attach_encoder(connector, encoder);
78 if (ret < 0)
79 return ret;
80
81 return 0;
82}
83