kernel - cleanup vfs_cache debugging
[dragonfly.git] / sys / dev / drm / drm_panel.c
bloba0b61bba273520ce3c6521b7590e4ec3865c5633
1 /*
2 * Copyright (C) 2013, NVIDIA Corporation. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include <linux/err.h>
25 #include <linux/module.h>
27 #include <drm/drmP.h>
28 #include <drm/drm_crtc.h>
29 #include <drm/drm_panel.h>
31 static DEFINE_MUTEX(panel_lock);
32 static LINUX_LIST_HEAD(panel_list);
34 void drm_panel_init(struct drm_panel *panel)
36 INIT_LIST_HEAD(&panel->list);
38 EXPORT_SYMBOL(drm_panel_init);
40 int drm_panel_add(struct drm_panel *panel)
42 mutex_lock(&panel_lock);
43 list_add_tail(&panel->list, &panel_list);
44 mutex_unlock(&panel_lock);
46 return 0;
48 EXPORT_SYMBOL(drm_panel_add);
50 void drm_panel_remove(struct drm_panel *panel)
52 mutex_lock(&panel_lock);
53 list_del_init(&panel->list);
54 mutex_unlock(&panel_lock);
56 EXPORT_SYMBOL(drm_panel_remove);
58 int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector)
60 if (panel->connector)
61 return -EBUSY;
63 panel->connector = connector;
64 panel->drm = connector->dev;
66 return 0;
68 EXPORT_SYMBOL(drm_panel_attach);
70 int drm_panel_detach(struct drm_panel *panel)
72 panel->connector = NULL;
73 panel->drm = NULL;
75 return 0;
77 EXPORT_SYMBOL(drm_panel_detach);
79 #ifdef CONFIG_OF
80 struct drm_panel *of_drm_find_panel(struct device_node *np)
82 struct drm_panel *panel;
84 mutex_lock(&panel_lock);
86 list_for_each_entry(panel, &panel_list, list) {
87 if (panel->dev->of_node == np) {
88 mutex_unlock(&panel_lock);
89 return panel;
93 mutex_unlock(&panel_lock);
94 return NULL;
96 EXPORT_SYMBOL(of_drm_find_panel);
97 #endif
99 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
100 MODULE_DESCRIPTION("DRM panel infrastructure");