aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2/omapfb/omapfb-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/omap2/omapfb/omapfb-sysfs.c')
-rw-r--r--drivers/video/omap2/omapfb/omapfb-sysfs.c87
1 files changed, 27 insertions, 60 deletions
diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c
index be5eb074b7d3..18fa9e1d0033 100644
--- a/drivers/video/omap2/omapfb/omapfb-sysfs.c
+++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c
@@ -49,7 +49,6 @@ static ssize_t store_rotate_type(struct device *dev,
49{ 49{
50 struct fb_info *fbi = dev_get_drvdata(dev); 50 struct fb_info *fbi = dev_get_drvdata(dev);
51 struct omapfb_info *ofbi = FB2OFB(fbi); 51 struct omapfb_info *ofbi = FB2OFB(fbi);
52 struct omapfb2_device *fbdev = ofbi->fbdev;
53 struct omapfb2_mem_region *rg; 52 struct omapfb2_mem_region *rg;
54 int rot_type; 53 int rot_type;
55 int r; 54 int r;
@@ -63,13 +62,12 @@ static ssize_t store_rotate_type(struct device *dev,
63 62
64 if (!lock_fb_info(fbi)) 63 if (!lock_fb_info(fbi))
65 return -ENODEV; 64 return -ENODEV;
66 omapfb_lock(fbdev);
67 65
68 r = 0; 66 r = 0;
69 if (rot_type == ofbi->rotation_type) 67 if (rot_type == ofbi->rotation_type)
70 goto out; 68 goto out;
71 69
72 rg = ofbi->region; 70 rg = omapfb_get_mem_region(ofbi->region);
73 71
74 if (rg->size) { 72 if (rg->size) {
75 r = -EBUSY; 73 r = -EBUSY;
@@ -83,8 +81,8 @@ static ssize_t store_rotate_type(struct device *dev,
83 * need to do any further parameter checking at this point. 81 * need to do any further parameter checking at this point.
84 */ 82 */
85put_region: 83put_region:
84 omapfb_put_mem_region(rg);
86out: 85out:
87 omapfb_unlock(fbdev);
88 unlock_fb_info(fbi); 86 unlock_fb_info(fbi);
89 87
90 return r ? r : count; 88 return r ? r : count;
@@ -106,7 +104,6 @@ static ssize_t store_mirror(struct device *dev,
106{ 104{
107 struct fb_info *fbi = dev_get_drvdata(dev); 105 struct fb_info *fbi = dev_get_drvdata(dev);
108 struct omapfb_info *ofbi = FB2OFB(fbi); 106 struct omapfb_info *ofbi = FB2OFB(fbi);
109 struct omapfb2_device *fbdev = ofbi->fbdev;
110 bool mirror; 107 bool mirror;
111 int r; 108 int r;
112 struct fb_var_screeninfo new_var; 109 struct fb_var_screeninfo new_var;
@@ -117,10 +114,11 @@ static ssize_t store_mirror(struct device *dev,
117 114
118 if (!lock_fb_info(fbi)) 115 if (!lock_fb_info(fbi))
119 return -ENODEV; 116 return -ENODEV;
120 omapfb_lock(fbdev);
121 117
122 ofbi->mirror = mirror; 118 ofbi->mirror = mirror;
123 119
120 omapfb_get_mem_region(ofbi->region);
121
124 memcpy(&new_var, &fbi->var, sizeof(new_var)); 122 memcpy(&new_var, &fbi->var, sizeof(new_var));
125 r = check_fb_var(fbi, &new_var); 123 r = check_fb_var(fbi, &new_var);
126 if (r) 124 if (r)
@@ -135,7 +133,8 @@ static ssize_t store_mirror(struct device *dev,
135 133
136 r = count; 134 r = count;
137out: 135out:
138 omapfb_unlock(fbdev); 136 omapfb_put_mem_region(ofbi->region);
137
139 unlock_fb_info(fbi); 138 unlock_fb_info(fbi);
140 139
141 return r; 140 return r;
@@ -274,11 +273,15 @@ static ssize_t store_overlays(struct device *dev, struct device_attribute *attr,
274 273
275 DBG("detaching %d\n", ofbi->overlays[i]->id); 274 DBG("detaching %d\n", ofbi->overlays[i]->id);
276 275
276 omapfb_get_mem_region(ofbi->region);
277
277 omapfb_overlay_enable(ovl, 0); 278 omapfb_overlay_enable(ovl, 0);
278 279
279 if (ovl->manager) 280 if (ovl->manager)
280 ovl->manager->apply(ovl->manager); 281 ovl->manager->apply(ovl->manager);
281 282
283 omapfb_put_mem_region(ofbi->region);
284
282 for (t = i + 1; t < ofbi->num_overlays; t++) { 285 for (t = i + 1; t < ofbi->num_overlays; t++) {
283 ofbi->rotation[t-1] = ofbi->rotation[t]; 286 ofbi->rotation[t-1] = ofbi->rotation[t];
284 ofbi->overlays[t-1] = ofbi->overlays[t]; 287 ofbi->overlays[t-1] = ofbi->overlays[t];
@@ -311,8 +314,12 @@ static ssize_t store_overlays(struct device *dev, struct device_attribute *attr,
311 } 314 }
312 315
313 if (added) { 316 if (added) {
317 omapfb_get_mem_region(ofbi->region);
318
314 r = omapfb_apply_changes(fbi, 0); 319 r = omapfb_apply_changes(fbi, 0);
315 320
321 omapfb_put_mem_region(ofbi->region);
322
316 if (r) 323 if (r)
317 goto out; 324 goto out;
318 } 325 }
@@ -330,13 +337,11 @@ static ssize_t show_overlays_rotate(struct device *dev,
330{ 337{
331 struct fb_info *fbi = dev_get_drvdata(dev); 338 struct fb_info *fbi = dev_get_drvdata(dev);
332 struct omapfb_info *ofbi = FB2OFB(fbi); 339 struct omapfb_info *ofbi = FB2OFB(fbi);
333 struct omapfb2_device *fbdev = ofbi->fbdev;
334 ssize_t l = 0; 340 ssize_t l = 0;
335 int t; 341 int t;
336 342
337 if (!lock_fb_info(fbi)) 343 if (!lock_fb_info(fbi))
338 return -ENODEV; 344 return -ENODEV;
339 omapfb_lock(fbdev);
340 345
341 for (t = 0; t < ofbi->num_overlays; t++) { 346 for (t = 0; t < ofbi->num_overlays; t++) {
342 l += snprintf(buf + l, PAGE_SIZE - l, "%s%d", 347 l += snprintf(buf + l, PAGE_SIZE - l, "%s%d",
@@ -345,7 +350,6 @@ static ssize_t show_overlays_rotate(struct device *dev,
345 350
346 l += snprintf(buf + l, PAGE_SIZE - l, "\n"); 351 l += snprintf(buf + l, PAGE_SIZE - l, "\n");
347 352
348 omapfb_unlock(fbdev);
349 unlock_fb_info(fbi); 353 unlock_fb_info(fbi);
350 354
351 return l; 355 return l;
@@ -356,7 +360,6 @@ static ssize_t store_overlays_rotate(struct device *dev,
356{ 360{
357 struct fb_info *fbi = dev_get_drvdata(dev); 361 struct fb_info *fbi = dev_get_drvdata(dev);
358 struct omapfb_info *ofbi = FB2OFB(fbi); 362 struct omapfb_info *ofbi = FB2OFB(fbi);
359 struct omapfb2_device *fbdev = ofbi->fbdev;
360 int num_ovls = 0, r, i; 363 int num_ovls = 0, r, i;
361 int len; 364 int len;
362 bool changed = false; 365 bool changed = false;
@@ -368,7 +371,6 @@ static ssize_t store_overlays_rotate(struct device *dev,
368 371
369 if (!lock_fb_info(fbi)) 372 if (!lock_fb_info(fbi))
370 return -ENODEV; 373 return -ENODEV;
371 omapfb_lock(fbdev);
372 374
373 if (len > 0) { 375 if (len > 0) {
374 char *p = (char *)buf; 376 char *p = (char *)buf;
@@ -405,7 +407,12 @@ static ssize_t store_overlays_rotate(struct device *dev,
405 for (i = 0; i < num_ovls; ++i) 407 for (i = 0; i < num_ovls; ++i)
406 ofbi->rotation[i] = rotation[i]; 408 ofbi->rotation[i] = rotation[i];
407 409
410 omapfb_get_mem_region(ofbi->region);
411
408 r = omapfb_apply_changes(fbi, 0); 412 r = omapfb_apply_changes(fbi, 0);
413
414 omapfb_put_mem_region(ofbi->region);
415
409 if (r) 416 if (r)
410 goto out; 417 goto out;
411 418
@@ -414,7 +421,6 @@ static ssize_t store_overlays_rotate(struct device *dev,
414 421
415 r = count; 422 r = count;
416out: 423out:
417 omapfb_unlock(fbdev);
418 unlock_fb_info(fbi); 424 unlock_fb_info(fbi);
419 425
420 return r; 426 return r;
@@ -425,19 +431,8 @@ static ssize_t show_size(struct device *dev,
425{ 431{
426 struct fb_info *fbi = dev_get_drvdata(dev); 432 struct fb_info *fbi = dev_get_drvdata(dev);
427 struct omapfb_info *ofbi = FB2OFB(fbi); 433 struct omapfb_info *ofbi = FB2OFB(fbi);
428 struct omapfb2_device *fbdev = ofbi->fbdev;
429 int r;
430 434
431 if (!lock_fb_info(fbi)) 435 return snprintf(buf, PAGE_SIZE, "%lu\n", ofbi->region->size);
432 return -ENODEV;
433 omapfb_lock(fbdev);
434
435 r = snprintf(buf, PAGE_SIZE, "%lu\n", ofbi->region->size);
436
437 omapfb_unlock(fbdev);
438 unlock_fb_info(fbi);
439
440 return r;
441} 436}
442 437
443static ssize_t store_size(struct device *dev, struct device_attribute *attr, 438static ssize_t store_size(struct device *dev, struct device_attribute *attr,
@@ -460,15 +455,15 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
460 455
461 if (!lock_fb_info(fbi)) 456 if (!lock_fb_info(fbi))
462 return -ENODEV; 457 return -ENODEV;
463 omapfb_lock(fbdev);
464 458
465 if (display && display->driver->sync) 459 if (display && display->driver->sync)
466 display->driver->sync(display); 460 display->driver->sync(display);
467 461
468 mutex_lock(&fbi->mm_lock);
469
470 rg = ofbi->region; 462 rg = ofbi->region;
471 463
464 down_write_nested(&rg->lock, rg->id);
465 atomic_inc(&rg->lock_count);
466
472 if (atomic_read(&rg->map_count)) { 467 if (atomic_read(&rg->map_count)) {
473 r = -EBUSY; 468 r = -EBUSY;
474 goto out; 469 goto out;
@@ -501,8 +496,9 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
501 496
502 r = count; 497 r = count;
503out: 498out:
504 mutex_unlock(&fbi->mm_lock); 499 atomic_dec(&rg->lock_count);
505 omapfb_unlock(fbdev); 500 up_write(&rg->lock);
501
506 unlock_fb_info(fbi); 502 unlock_fb_info(fbi);
507 503
508 return r; 504 return r;
@@ -513,19 +509,8 @@ static ssize_t show_phys(struct device *dev,
513{ 509{
514 struct fb_info *fbi = dev_get_drvdata(dev); 510 struct fb_info *fbi = dev_get_drvdata(dev);
515 struct omapfb_info *ofbi = FB2OFB(fbi); 511 struct omapfb_info *ofbi = FB2OFB(fbi);
516 struct omapfb2_device *fbdev = ofbi->fbdev;
517 int r;
518 512
519 if (!lock_fb_info(fbi)) 513 return snprintf(buf, PAGE_SIZE, "%0x\n", ofbi->region->paddr);
520 return -ENODEV;
521 omapfb_lock(fbdev);
522
523 r = snprintf(buf, PAGE_SIZE, "%0x\n", ofbi->region->paddr);
524
525 omapfb_unlock(fbdev);
526 unlock_fb_info(fbi);
527
528 return r;
529} 514}
530 515
531static ssize_t show_virt(struct device *dev, 516static ssize_t show_virt(struct device *dev,
@@ -541,20 +526,11 @@ static ssize_t show_upd_mode(struct device *dev,
541 struct device_attribute *attr, char *buf) 526 struct device_attribute *attr, char *buf)
542{ 527{
543 struct fb_info *fbi = dev_get_drvdata(dev); 528 struct fb_info *fbi = dev_get_drvdata(dev);
544 struct omapfb_info *ofbi = FB2OFB(fbi);
545 struct omapfb2_device *fbdev = ofbi->fbdev;
546 enum omapfb_update_mode mode; 529 enum omapfb_update_mode mode;
547 int r; 530 int r;
548 531
549 if (!lock_fb_info(fbi))
550 return -ENODEV;
551 omapfb_lock(fbdev);
552
553 r = omapfb_get_update_mode(fbi, &mode); 532 r = omapfb_get_update_mode(fbi, &mode);
554 533
555 omapfb_unlock(fbdev);
556 unlock_fb_info(fbi);
557
558 if (r) 534 if (r)
559 return r; 535 return r;
560 536
@@ -565,8 +541,6 @@ static ssize_t store_upd_mode(struct device *dev, struct device_attribute *attr,
565 const char *buf, size_t count) 541 const char *buf, size_t count)
566{ 542{
567 struct fb_info *fbi = dev_get_drvdata(dev); 543 struct fb_info *fbi = dev_get_drvdata(dev);
568 struct omapfb_info *ofbi = FB2OFB(fbi);
569 struct omapfb2_device *fbdev = ofbi->fbdev;
570 unsigned mode; 544 unsigned mode;
571 int r; 545 int r;
572 546
@@ -574,17 +548,10 @@ static ssize_t store_upd_mode(struct device *dev, struct device_attribute *attr,
574 if (r) 548 if (r)
575 return r; 549 return r;
576 550
577 if (!lock_fb_info(fbi))
578 return -ENODEV;
579 omapfb_lock(fbdev);
580
581 r = omapfb_set_update_mode(fbi, mode); 551 r = omapfb_set_update_mode(fbi, mode);
582 if (r) 552 if (r)
583 return r; 553 return r;
584 554
585 omapfb_unlock(fbdev);
586 unlock_fb_info(fbi);
587
588 return count; 555 return count;
589} 556}
590 557