2 * Copyright (C) 2009 Nokia Corporation
3 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
5 * Some code and ideas taken from drivers/video/omap/ driver
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published by
10 * the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
21 #define DSS_SUBSYS_NAME "DISPLAY"
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/jiffies.h>
26 #include <linux/platform_device.h>
31 static void omapdss_default_get_timings(struct omap_dss_device *dssdev,
34 *vm = dssdev->panel.vm;
37 static LIST_HEAD(panel_list);
38 static DEFINE_MUTEX(panel_list_mutex);
39 static int disp_num_counter;
41 int omapdss_register_display(struct omap_dss_device *dssdev)
43 struct omap_dss_driver *drv = dssdev->driver;
44 struct list_head *cur;
48 * Note: this presumes that all displays either have an DT alias, or
51 id = of_alias_get_id(dssdev->dev->of_node, "display");
53 id = disp_num_counter++;
55 snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
57 /* Use 'label' property for name, if it exists */
58 of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
60 if (dssdev->name == NULL)
61 dssdev->name = dssdev->alias;
63 if (drv && drv->get_timings == NULL)
64 drv->get_timings = omapdss_default_get_timings;
66 mutex_lock(&panel_list_mutex);
67 list_for_each(cur, &panel_list) {
68 struct omap_dss_device *ldev = list_entry(cur,
69 struct omap_dss_device,
71 if (strcmp(ldev->alias, dssdev->alias) > 0)
74 list_add_tail(&dssdev->panel_list, cur);
75 mutex_unlock(&panel_list_mutex);
78 EXPORT_SYMBOL(omapdss_register_display);
80 void omapdss_unregister_display(struct omap_dss_device *dssdev)
82 mutex_lock(&panel_list_mutex);
83 list_del(&dssdev->panel_list);
84 mutex_unlock(&panel_list_mutex);
86 EXPORT_SYMBOL(omapdss_unregister_display);
88 bool omapdss_component_is_display(struct device_node *node)
90 struct omap_dss_device *dssdev;
93 mutex_lock(&panel_list_mutex);
94 list_for_each_entry(dssdev, &panel_list, panel_list) {
95 if (dssdev->dev->of_node == node) {
101 mutex_unlock(&panel_list_mutex);
104 EXPORT_SYMBOL(omapdss_component_is_display);
106 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
108 if (!try_module_get(dssdev->owner))
111 if (get_device(dssdev->dev) == NULL) {
112 module_put(dssdev->owner);
118 EXPORT_SYMBOL(omap_dss_get_device);
120 void omap_dss_put_device(struct omap_dss_device *dssdev)
122 put_device(dssdev->dev);
123 module_put(dssdev->owner);
125 EXPORT_SYMBOL(omap_dss_put_device);
128 * ref count of the found device is incremented.
129 * ref count of from-device is decremented.
131 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
134 struct omap_dss_device *dssdev;
136 mutex_lock(&panel_list_mutex);
138 if (list_empty(&panel_list)) {
144 dssdev = list_first_entry(&panel_list, struct omap_dss_device,
146 omap_dss_get_device(dssdev);
150 omap_dss_put_device(from);
152 list_for_each(l, &panel_list) {
153 dssdev = list_entry(l, struct omap_dss_device, panel_list);
154 if (dssdev == from) {
155 if (list_is_last(l, &panel_list)) {
160 dssdev = list_entry(l->next, struct omap_dss_device,
162 omap_dss_get_device(dssdev);
167 WARN(1, "'from' dssdev not found\n");
171 mutex_unlock(&panel_list_mutex);
174 EXPORT_SYMBOL(omap_dss_get_next_device);