2 * rcar_du_lvdscon.c -- R-Car Display Unit LVDS Connector
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
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.
15 #include <drm/drm_atomic_helper.h>
16 #include <drm/drm_crtc.h>
17 #include <drm/drm_crtc_helper.h>
18 #include <drm/drm_panel.h>
20 #include <video/display_timing.h>
21 #include <video/of_display_timing.h>
22 #include <video/videomode.h>
24 #include "rcar_du_drv.h"
25 #include "rcar_du_encoder.h"
26 #include "rcar_du_kms.h"
27 #include "rcar_du_lvdscon.h"
29 static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector)
31 struct rcar_du_connector *rcon = to_rcar_connector(connector);
33 return drm_panel_get_modes(rcon->panel);
36 static const struct drm_connector_helper_funcs connector_helper_funcs = {
37 .get_modes = rcar_du_lvds_connector_get_modes,
40 static void rcar_du_lvds_connector_destroy(struct drm_connector *connector)
42 struct rcar_du_connector *rcon = to_rcar_connector(connector);
44 drm_panel_detach(rcon->panel);
45 drm_connector_cleanup(connector);
48 static const struct drm_connector_funcs connector_funcs = {
49 .reset = drm_atomic_helper_connector_reset,
50 .fill_modes = drm_helper_probe_single_connector_modes,
51 .destroy = rcar_du_lvds_connector_destroy,
52 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
53 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
56 int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
57 struct rcar_du_encoder *renc,
58 const struct device_node *np)
60 struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
61 struct rcar_du_connector *rcon;
62 struct drm_connector *connector;
65 rcon = devm_kzalloc(rcdu->dev, sizeof(*rcon), GFP_KERNEL);
69 connector = &rcon->connector;
71 rcon->panel = of_drm_find_panel(np);
75 ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
76 DRM_MODE_CONNECTOR_LVDS);
80 drm_connector_helper_add(connector, &connector_helper_funcs);
82 ret = drm_mode_connector_attach_encoder(connector, encoder);
86 ret = drm_panel_attach(rcon->panel, connector);