2 * linux/drivers/video/omap2/dss/display.c
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * Some code and ideas taken from drivers/video/omap/ driver
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
23 #define DSS_SUBSYS_NAME "DISPLAY"
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/jiffies.h>
28 #include <linux/platform_device.h>
33 void omapdss_default_get_timings(struct omap_dss_device *dssdev,
36 *vm = dssdev->panel.vm;
38 EXPORT_SYMBOL(omapdss_default_get_timings);
40 static LIST_HEAD(panel_list);
41 static DEFINE_MUTEX(panel_list_mutex);
42 static int disp_num_counter;
44 int omapdss_register_display(struct omap_dss_device *dssdev)
46 struct omap_dss_driver *drv = dssdev->driver;
47 struct list_head *cur;
51 * Note: this presumes that all displays either have an DT alias, or
54 id = of_alias_get_id(dssdev->dev->of_node, "display");
56 id = disp_num_counter++;
58 snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
60 /* Use 'label' property for name, if it exists */
61 of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
63 if (dssdev->name == NULL)
64 dssdev->name = dssdev->alias;
66 if (drv && drv->get_timings == NULL)
67 drv->get_timings = omapdss_default_get_timings;
69 mutex_lock(&panel_list_mutex);
70 list_for_each(cur, &panel_list) {
71 struct omap_dss_device *ldev = list_entry(cur,
72 struct omap_dss_device,
74 if (strcmp(ldev->alias, dssdev->alias) > 0)
77 list_add_tail(&dssdev->panel_list, cur);
78 mutex_unlock(&panel_list_mutex);
81 EXPORT_SYMBOL(omapdss_register_display);
83 void omapdss_unregister_display(struct omap_dss_device *dssdev)
85 mutex_lock(&panel_list_mutex);
86 list_del(&dssdev->panel_list);
87 mutex_unlock(&panel_list_mutex);
89 EXPORT_SYMBOL(omapdss_unregister_display);
91 bool omapdss_component_is_display(struct device_node *node)
93 struct omap_dss_device *dssdev;
96 mutex_lock(&panel_list_mutex);
97 list_for_each_entry(dssdev, &panel_list, panel_list) {
98 if (dssdev->dev->of_node == node) {
104 mutex_unlock(&panel_list_mutex);
107 EXPORT_SYMBOL(omapdss_component_is_display);
109 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
111 if (!try_module_get(dssdev->owner))
114 if (get_device(dssdev->dev) == NULL) {
115 module_put(dssdev->owner);
121 EXPORT_SYMBOL(omap_dss_get_device);
123 void omap_dss_put_device(struct omap_dss_device *dssdev)
125 put_device(dssdev->dev);
126 module_put(dssdev->owner);
128 EXPORT_SYMBOL(omap_dss_put_device);
131 * ref count of the found device is incremented.
132 * ref count of from-device is decremented.
134 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
137 struct omap_dss_device *dssdev;
139 mutex_lock(&panel_list_mutex);
141 if (list_empty(&panel_list)) {
147 dssdev = list_first_entry(&panel_list, struct omap_dss_device,
149 omap_dss_get_device(dssdev);
153 omap_dss_put_device(from);
155 list_for_each(l, &panel_list) {
156 dssdev = list_entry(l, struct omap_dss_device, panel_list);
157 if (dssdev == from) {
158 if (list_is_last(l, &panel_list)) {
163 dssdev = list_entry(l->next, struct omap_dss_device,
165 omap_dss_get_device(dssdev);
170 WARN(1, "'from' dssdev not found\n");
174 mutex_unlock(&panel_list_mutex);
177 EXPORT_SYMBOL(omap_dss_get_next_device);
179 struct omap_dss_device *omap_dss_find_device(void *data,
180 int (*match)(struct omap_dss_device *dssdev, void *data))
182 struct omap_dss_device *dssdev = NULL;
184 while ((dssdev = omap_dss_get_next_device(dssdev)) != NULL) {
185 if (match(dssdev, data))
191 EXPORT_SYMBOL(omap_dss_find_device);