rcutorture: Eliminate unused ts_rem local from rcu_trace_clock_local()
[linux/fpc-iii.git] / drivers / gpu / drm / mxsfb / mxsfb_out.c
blobf7d729aa09bd40528815817e9f94ed5060bcb8d9
1 /*
2 * Copyright (C) 2016 Marek Vasut <marex@denx.de>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/of_graph.h>
16 #include <drm/drm_atomic.h>
17 #include <drm/drm_atomic_helper.h>
18 #include <drm/drm_crtc.h>
19 #include <drm/drm_crtc_helper.h>
20 #include <drm/drm_fb_cma_helper.h>
21 #include <drm/drm_gem_cma_helper.h>
22 #include <drm/drm_of.h>
23 #include <drm/drm_panel.h>
24 #include <drm/drm_plane_helper.h>
25 #include <drm/drm_simple_kms_helper.h>
26 #include <drm/drmP.h>
28 #include "mxsfb_drv.h"
30 static struct mxsfb_drm_private *
31 drm_connector_to_mxsfb_drm_private(struct drm_connector *connector)
33 return container_of(connector, struct mxsfb_drm_private, connector);
36 static int mxsfb_panel_get_modes(struct drm_connector *connector)
38 struct mxsfb_drm_private *mxsfb =
39 drm_connector_to_mxsfb_drm_private(connector);
41 if (mxsfb->panel)
42 return mxsfb->panel->funcs->get_modes(mxsfb->panel);
44 return 0;
47 static const struct
48 drm_connector_helper_funcs mxsfb_panel_connector_helper_funcs = {
49 .get_modes = mxsfb_panel_get_modes,
52 static enum drm_connector_status
53 mxsfb_panel_connector_detect(struct drm_connector *connector, bool force)
55 struct mxsfb_drm_private *mxsfb =
56 drm_connector_to_mxsfb_drm_private(connector);
58 if (mxsfb->panel)
59 return connector_status_connected;
61 return connector_status_disconnected;
64 static void mxsfb_panel_connector_destroy(struct drm_connector *connector)
66 struct mxsfb_drm_private *mxsfb =
67 drm_connector_to_mxsfb_drm_private(connector);
69 if (mxsfb->panel)
70 drm_panel_detach(mxsfb->panel);
72 drm_connector_unregister(connector);
73 drm_connector_cleanup(connector);
76 static const struct drm_connector_funcs mxsfb_panel_connector_funcs = {
77 .dpms = drm_atomic_helper_connector_dpms,
78 .detect = mxsfb_panel_connector_detect,
79 .fill_modes = drm_helper_probe_single_connector_modes,
80 .destroy = mxsfb_panel_connector_destroy,
81 .reset = drm_atomic_helper_connector_reset,
82 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
83 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
86 int mxsfb_create_output(struct drm_device *drm)
88 struct mxsfb_drm_private *mxsfb = drm->dev_private;
89 struct drm_panel *panel;
90 int ret;
92 ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, &panel, NULL);
93 if (ret)
94 return ret;
96 mxsfb->connector.dpms = DRM_MODE_DPMS_OFF;
97 mxsfb->connector.polled = 0;
98 drm_connector_helper_add(&mxsfb->connector,
99 &mxsfb_panel_connector_helper_funcs);
100 ret = drm_connector_init(drm, &mxsfb->connector,
101 &mxsfb_panel_connector_funcs,
102 DRM_MODE_CONNECTOR_Unknown);
103 if (!ret)
104 mxsfb->panel = panel;
106 return ret;