aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2013-02-13 06:40:19 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-06-17 07:00:50 -0400
commit94140f0d225fd1261e11a9d883be6de5692d57d8 (patch)
treea1b9c2d2742fb8fca18b84680feda7dfcf5a84b8 /drivers/video
parenta65c8bdab9f122270d149e1ef084a6d11181ecdd (diff)
OMAPDSS: implement display sysfs without dss bus
We aim to remove the custom omapdss bus totally, as it's quite a strange construct and won't be compatible with common display framework. One problem on the road is that we have sysfs files for each display, and they depend on the omapdss bus. This patch creates the display sysfs files independent of the omapdss bus. This gives us backwards compatibility without using the omapdss bus for the sysfs files. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/omap2/dss/apply.c15
-rw-r--r--drivers/video/omap2/dss/core.c28
-rw-r--r--drivers/video/omap2/dss/display-sysfs.c125
-rw-r--r--drivers/video/omap2/dss/dss.h6
4 files changed, 79 insertions, 95 deletions
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index dbd3c2f28a83..ced656ae7059 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -1581,7 +1581,6 @@ static DEFINE_MUTEX(compat_init_lock);
1581int omapdss_compat_init(void) 1581int omapdss_compat_init(void)
1582{ 1582{
1583 struct platform_device *pdev = dss_get_core_pdev(); 1583 struct platform_device *pdev = dss_get_core_pdev();
1584 struct omap_dss_device *dssdev = NULL;
1585 int i, r; 1584 int i, r;
1586 1585
1587 mutex_lock(&compat_init_lock); 1586 mutex_lock(&compat_init_lock);
@@ -1627,12 +1626,9 @@ int omapdss_compat_init(void)
1627 if (r) 1626 if (r)
1628 goto err_mgr_ops; 1627 goto err_mgr_ops;
1629 1628
1630 for_each_dss_dev(dssdev) { 1629 r = display_init_sysfs(pdev);
1631 r = display_init_sysfs(pdev, dssdev); 1630 if (r)
1632 /* XXX uninit sysfs files on error */ 1631 goto err_disp_sysfs;
1633 if (r)
1634 goto err_disp_sysfs;
1635 }
1636 1632
1637 dispc_runtime_get(); 1633 dispc_runtime_get();
1638 1634
@@ -1649,6 +1645,7 @@ out:
1649 1645
1650err_init_irq: 1646err_init_irq:
1651 dispc_runtime_put(); 1647 dispc_runtime_put();
1648 display_uninit_sysfs(pdev);
1652 1649
1653err_disp_sysfs: 1650err_disp_sysfs:
1654 dss_uninstall_mgr_ops(); 1651 dss_uninstall_mgr_ops();
@@ -1668,7 +1665,6 @@ EXPORT_SYMBOL(omapdss_compat_init);
1668void omapdss_compat_uninit(void) 1665void omapdss_compat_uninit(void)
1669{ 1666{
1670 struct platform_device *pdev = dss_get_core_pdev(); 1667 struct platform_device *pdev = dss_get_core_pdev();
1671 struct omap_dss_device *dssdev = NULL;
1672 1668
1673 mutex_lock(&compat_init_lock); 1669 mutex_lock(&compat_init_lock);
1674 1670
@@ -1677,8 +1673,7 @@ void omapdss_compat_uninit(void)
1677 1673
1678 dss_dispc_uninitialize_irq(); 1674 dss_dispc_uninitialize_irq();
1679 1675
1680 for_each_dss_dev(dssdev) 1676 display_uninit_sysfs(pdev);
1681 display_uninit_sysfs(pdev, dssdev);
1682 1677
1683 dss_uninstall_mgr_ops(); 1678 dss_uninstall_mgr_ops();
1684 1679
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 17b52343f74c..b6ce394396e2 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -292,37 +292,9 @@ static int dss_bus_match(struct device *dev, struct device_driver *driver)
292 return strcmp(dssdev->driver_name, driver->name) == 0; 292 return strcmp(dssdev->driver_name, driver->name) == 0;
293} 293}
294 294
295static ssize_t device_name_show(struct device *dev,
296 struct device_attribute *attr, char *buf)
297{
298 struct omap_dss_device *dssdev = to_dss_device(dev);
299 return snprintf(buf, PAGE_SIZE, "%s\n",
300 dssdev->name ?
301 dssdev->name : "");
302}
303
304static struct device_attribute default_dev_attrs[] = {
305 __ATTR(name, S_IRUGO, device_name_show, NULL),
306 __ATTR_NULL,
307};
308
309static ssize_t driver_name_show(struct device_driver *drv, char *buf)
310{
311 struct omap_dss_driver *dssdrv = to_dss_driver(drv);
312 return snprintf(buf, PAGE_SIZE, "%s\n",
313 dssdrv->driver.name ?
314 dssdrv->driver.name : "");
315}
316static struct driver_attribute default_drv_attrs[] = {
317 __ATTR(name, S_IRUGO, driver_name_show, NULL),
318 __ATTR_NULL,
319};
320
321static struct bus_type dss_bus_type = { 295static struct bus_type dss_bus_type = {
322 .name = "omapdss", 296 .name = "omapdss",
323 .match = dss_bus_match, 297 .match = dss_bus_match,
324 .dev_attrs = default_dev_attrs,
325 .drv_attrs = default_drv_attrs,
326}; 298};
327 299
328static void dss_bus_release(struct device *dev) 300static void dss_bus_release(struct device *dev)
diff --git a/drivers/video/omap2/dss/display-sysfs.c b/drivers/video/omap2/dss/display-sysfs.c
index 81d5dc6e509f..58abbafeab17 100644
--- a/drivers/video/omap2/dss/display-sysfs.c
+++ b/drivers/video/omap2/dss/display-sysfs.c
@@ -22,17 +22,40 @@
22 22
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/jiffies.h>
26#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/sysfs.h>
27 27
28#include <video/omapdss.h> 28#include <video/omapdss.h>
29#include "dss.h" 29#include "dss.h"
30#include "dss_features.h" 30
31static struct omap_dss_device *to_dss_device_sysfs(struct device *dev)
32{
33 struct omap_dss_device *dssdev = NULL;
34
35 for_each_dss_dev(dssdev) {
36 if (&dssdev->dev == dev) {
37 omap_dss_put_device(dssdev);
38 return dssdev;
39 }
40 }
41
42 return NULL;
43}
44
45static ssize_t display_name_show(struct device *dev,
46 struct device_attribute *attr, char *buf)
47{
48 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
49
50 return snprintf(buf, PAGE_SIZE, "%s\n",
51 dssdev->name ?
52 dssdev->name : "");
53}
31 54
32static ssize_t display_enabled_show(struct device *dev, 55static ssize_t display_enabled_show(struct device *dev,
33 struct device_attribute *attr, char *buf) 56 struct device_attribute *attr, char *buf)
34{ 57{
35 struct omap_dss_device *dssdev = to_dss_device(dev); 58 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
36 59
37 return snprintf(buf, PAGE_SIZE, "%d\n", 60 return snprintf(buf, PAGE_SIZE, "%d\n",
38 omapdss_device_is_enabled(dssdev)); 61 omapdss_device_is_enabled(dssdev));
@@ -42,7 +65,7 @@ static ssize_t display_enabled_store(struct device *dev,
42 struct device_attribute *attr, 65 struct device_attribute *attr,
43 const char *buf, size_t size) 66 const char *buf, size_t size)
44{ 67{
45 struct omap_dss_device *dssdev = to_dss_device(dev); 68 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
46 int r; 69 int r;
47 bool enable; 70 bool enable;
48 71
@@ -70,7 +93,7 @@ static ssize_t display_enabled_store(struct device *dev,
70static ssize_t display_tear_show(struct device *dev, 93static ssize_t display_tear_show(struct device *dev,
71 struct device_attribute *attr, char *buf) 94 struct device_attribute *attr, char *buf)
72{ 95{
73 struct omap_dss_device *dssdev = to_dss_device(dev); 96 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
74 return snprintf(buf, PAGE_SIZE, "%d\n", 97 return snprintf(buf, PAGE_SIZE, "%d\n",
75 dssdev->driver->get_te ? 98 dssdev->driver->get_te ?
76 dssdev->driver->get_te(dssdev) : 0); 99 dssdev->driver->get_te(dssdev) : 0);
@@ -79,7 +102,7 @@ static ssize_t display_tear_show(struct device *dev,
79static ssize_t display_tear_store(struct device *dev, 102static ssize_t display_tear_store(struct device *dev,
80 struct device_attribute *attr, const char *buf, size_t size) 103 struct device_attribute *attr, const char *buf, size_t size)
81{ 104{
82 struct omap_dss_device *dssdev = to_dss_device(dev); 105 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
83 int r; 106 int r;
84 bool te; 107 bool te;
85 108
@@ -100,7 +123,7 @@ static ssize_t display_tear_store(struct device *dev,
100static ssize_t display_timings_show(struct device *dev, 123static ssize_t display_timings_show(struct device *dev,
101 struct device_attribute *attr, char *buf) 124 struct device_attribute *attr, char *buf)
102{ 125{
103 struct omap_dss_device *dssdev = to_dss_device(dev); 126 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
104 struct omap_video_timings t; 127 struct omap_video_timings t;
105 128
106 if (!dssdev->driver->get_timings) 129 if (!dssdev->driver->get_timings)
@@ -117,7 +140,7 @@ static ssize_t display_timings_show(struct device *dev,
117static ssize_t display_timings_store(struct device *dev, 140static ssize_t display_timings_store(struct device *dev,
118 struct device_attribute *attr, const char *buf, size_t size) 141 struct device_attribute *attr, const char *buf, size_t size)
119{ 142{
120 struct omap_dss_device *dssdev = to_dss_device(dev); 143 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
121 struct omap_video_timings t = dssdev->panel.timings; 144 struct omap_video_timings t = dssdev->panel.timings;
122 int r, found; 145 int r, found;
123 146
@@ -156,7 +179,7 @@ static ssize_t display_timings_store(struct device *dev,
156static ssize_t display_rotate_show(struct device *dev, 179static ssize_t display_rotate_show(struct device *dev,
157 struct device_attribute *attr, char *buf) 180 struct device_attribute *attr, char *buf)
158{ 181{
159 struct omap_dss_device *dssdev = to_dss_device(dev); 182 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
160 int rotate; 183 int rotate;
161 if (!dssdev->driver->get_rotate) 184 if (!dssdev->driver->get_rotate)
162 return -ENOENT; 185 return -ENOENT;
@@ -167,7 +190,7 @@ static ssize_t display_rotate_show(struct device *dev,
167static ssize_t display_rotate_store(struct device *dev, 190static ssize_t display_rotate_store(struct device *dev,
168 struct device_attribute *attr, const char *buf, size_t size) 191 struct device_attribute *attr, const char *buf, size_t size)
169{ 192{
170 struct omap_dss_device *dssdev = to_dss_device(dev); 193 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
171 int rot, r; 194 int rot, r;
172 195
173 if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate) 196 if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
@@ -187,7 +210,7 @@ static ssize_t display_rotate_store(struct device *dev,
187static ssize_t display_mirror_show(struct device *dev, 210static ssize_t display_mirror_show(struct device *dev,
188 struct device_attribute *attr, char *buf) 211 struct device_attribute *attr, char *buf)
189{ 212{
190 struct omap_dss_device *dssdev = to_dss_device(dev); 213 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
191 int mirror; 214 int mirror;
192 if (!dssdev->driver->get_mirror) 215 if (!dssdev->driver->get_mirror)
193 return -ENOENT; 216 return -ENOENT;
@@ -198,7 +221,7 @@ static ssize_t display_mirror_show(struct device *dev,
198static ssize_t display_mirror_store(struct device *dev, 221static ssize_t display_mirror_store(struct device *dev,
199 struct device_attribute *attr, const char *buf, size_t size) 222 struct device_attribute *attr, const char *buf, size_t size)
200{ 223{
201 struct omap_dss_device *dssdev = to_dss_device(dev); 224 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
202 int r; 225 int r;
203 bool mirror; 226 bool mirror;
204 227
@@ -219,7 +242,7 @@ static ssize_t display_mirror_store(struct device *dev,
219static ssize_t display_wss_show(struct device *dev, 242static ssize_t display_wss_show(struct device *dev,
220 struct device_attribute *attr, char *buf) 243 struct device_attribute *attr, char *buf)
221{ 244{
222 struct omap_dss_device *dssdev = to_dss_device(dev); 245 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
223 unsigned int wss; 246 unsigned int wss;
224 247
225 if (!dssdev->driver->get_wss) 248 if (!dssdev->driver->get_wss)
@@ -233,7 +256,7 @@ static ssize_t display_wss_show(struct device *dev,
233static ssize_t display_wss_store(struct device *dev, 256static ssize_t display_wss_store(struct device *dev,
234 struct device_attribute *attr, const char *buf, size_t size) 257 struct device_attribute *attr, const char *buf, size_t size)
235{ 258{
236 struct omap_dss_device *dssdev = to_dss_device(dev); 259 struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
237 u32 wss; 260 u32 wss;
238 int r; 261 int r;
239 262
@@ -254,6 +277,7 @@ static ssize_t display_wss_store(struct device *dev,
254 return size; 277 return size;
255} 278}
256 279
280static DEVICE_ATTR(name, S_IRUGO, display_name_show, NULL);
257static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR, 281static DEVICE_ATTR(enabled, S_IRUGO|S_IWUSR,
258 display_enabled_show, display_enabled_store); 282 display_enabled_show, display_enabled_store);
259static DEVICE_ATTR(tear_elim, S_IRUGO|S_IWUSR, 283static DEVICE_ATTR(tear_elim, S_IRUGO|S_IWUSR,
@@ -267,59 +291,54 @@ static DEVICE_ATTR(mirror, S_IRUGO|S_IWUSR,
267static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR, 291static DEVICE_ATTR(wss, S_IRUGO|S_IWUSR,
268 display_wss_show, display_wss_store); 292 display_wss_show, display_wss_store);
269 293
270static struct device_attribute *display_sysfs_attrs[] = { 294static const struct attribute *display_sysfs_attrs[] = {
271 &dev_attr_enabled, 295 &dev_attr_name.attr,
272 &dev_attr_tear_elim, 296 &dev_attr_enabled.attr,
273 &dev_attr_timings, 297 &dev_attr_tear_elim.attr,
274 &dev_attr_rotate, 298 &dev_attr_timings.attr,
275 &dev_attr_mirror, 299 &dev_attr_rotate.attr,
276 &dev_attr_wss, 300 &dev_attr_mirror.attr,
301 &dev_attr_wss.attr,
277 NULL 302 NULL
278}; 303};
279 304
280int display_init_sysfs(struct platform_device *pdev, 305int display_init_sysfs(struct platform_device *pdev)
281 struct omap_dss_device *dssdev)
282{ 306{
283 struct device_attribute *attr; 307 struct omap_dss_device *dssdev = NULL;
284 int i, r; 308 int r;
285 309
286 /* create device sysfs files */ 310 for_each_dss_dev(dssdev) {
287 i = 0; 311 struct kobject *kobj = &dssdev->dev.kobj;
288 while ((attr = display_sysfs_attrs[i++]) != NULL) {
289 r = device_create_file(&dssdev->dev, attr);
290 if (r) {
291 for (i = i - 2; i >= 0; i--) {
292 attr = display_sysfs_attrs[i];
293 device_remove_file(&dssdev->dev, attr);
294 }
295 312
296 DSSERR("failed to create sysfs file\n"); 313 r = sysfs_create_files(kobj, display_sysfs_attrs);
297 return r; 314 if (r) {
315 DSSERR("failed to create sysfs files\n");
316 goto err;
298 } 317 }
299 }
300 318
301 /* create display? sysfs links */ 319 r = sysfs_create_link(&pdev->dev.kobj, kobj, dssdev->alias);
302 r = sysfs_create_link(&pdev->dev.kobj, &dssdev->dev.kobj, 320 if (r) {
303 dev_name(&dssdev->dev)); 321 sysfs_remove_files(kobj, display_sysfs_attrs);
304 if (r) {
305 while ((attr = display_sysfs_attrs[i++]) != NULL)
306 device_remove_file(&dssdev->dev, attr);
307 322
308 DSSERR("failed to create sysfs display link\n"); 323 DSSERR("failed to create sysfs display link\n");
309 return r; 324 goto err;
325 }
310 } 326 }
311 327
312 return 0; 328 return 0;
329
330err:
331 display_uninit_sysfs(pdev);
332
333 return r;
313} 334}
314 335
315void display_uninit_sysfs(struct platform_device *pdev, 336void display_uninit_sysfs(struct platform_device *pdev)
316 struct omap_dss_device *dssdev)
317{ 337{
318 struct device_attribute *attr; 338 struct omap_dss_device *dssdev = NULL;
319 int i = 0;
320
321 sysfs_remove_link(&pdev->dev.kobj, dev_name(&dssdev->dev));
322 339
323 while ((attr = display_sysfs_attrs[i++]) != NULL) 340 for_each_dss_dev(dssdev) {
324 device_remove_file(&dssdev->dev, attr); 341 sysfs_remove_link(&pdev->dev.kobj, dssdev->alias);
342 sysfs_remove_files(&dssdev->dev.kobj, display_sysfs_attrs);
343 }
325} 344}
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 7964d3b9853b..03d729ac8c42 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -188,10 +188,8 @@ int dss_suspend_all_devices(void);
188int dss_resume_all_devices(void); 188int dss_resume_all_devices(void);
189void dss_disable_all_devices(void); 189void dss_disable_all_devices(void);
190 190
191int display_init_sysfs(struct platform_device *pdev, 191int display_init_sysfs(struct platform_device *pdev);
192 struct omap_dss_device *dssdev); 192void display_uninit_sysfs(struct platform_device *pdev);
193void display_uninit_sysfs(struct platform_device *pdev,
194 struct omap_dss_device *dssdev);
195 193
196/* manager */ 194/* manager */
197int dss_init_overlay_managers(void); 195int dss_init_overlay_managers(void);