aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2011-09-28 17:19:51 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-10-04 21:10:12 -0400
commit2572df91d5528dfc639e52b7caaed98e3dec1e18 (patch)
tree24a2fab042da8c3de4434d5bf1eea999402e3417 /drivers
parent760af8f83d73dcd2ddf0dc8ebefcf4f0569c1a89 (diff)
drivers/video: fsl-diu-fb: use an enum for the AOI index
Each of the five AOIs created by the DIU driver has a special purpose, and they're not treated equally. It makes sense to identify them with an enum instead of a hard-coded number. Since the 'index' is now an enum, it can only contain allowed values, so there's no need to check for an invalid value. This simplifies some other code, such as fsl_diu_disable_panel(), which no longer needs to return an error code. Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/fsl-diu-fb.c94
1 files changed, 46 insertions, 48 deletions
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index 29652ab15ee0..c5f97318f193 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -360,8 +360,16 @@ struct fsl_diu_data {
360 enum fsl_diu_monitor_port monitor_port; 360 enum fsl_diu_monitor_port monitor_port;
361}; 361};
362 362
363enum mfb_index {
364 PLANE0 = 0, /* Plane 0, only one AOI that fills the screen */
365 PLANE1_AOI0, /* Plane 1, first AOI */
366 PLANE1_AOI1, /* Plane 1, second AOI */
367 PLANE2_AOI0, /* Plane 2, first AOI */
368 PLANE2_AOI1, /* Plane 2, second AOI */
369};
370
363struct mfb_info { 371struct mfb_info {
364 int index; 372 enum mfb_index index;
365 int type; 373 int type;
366 char *id; 374 char *id;
367 int registered; 375 int registered;
@@ -378,8 +386,8 @@ struct mfb_info {
378 386
379 387
380static struct mfb_info mfb_template[] = { 388static struct mfb_info mfb_template[] = {
381 { /* AOI 0 for plane 0 */ 389 {
382 .index = 0, 390 .index = PLANE0,
383 .type = MFB_TYPE_OUTPUT, 391 .type = MFB_TYPE_OUTPUT,
384 .id = "Panel0", 392 .id = "Panel0",
385 .registered = 0, 393 .registered = 0,
@@ -387,8 +395,8 @@ static struct mfb_info mfb_template[] = {
387 .x_aoi_d = 0, 395 .x_aoi_d = 0,
388 .y_aoi_d = 0, 396 .y_aoi_d = 0,
389 }, 397 },
390 { /* AOI 0 for plane 1 */ 398 {
391 .index = 1, 399 .index = PLANE1_AOI0,
392 .type = MFB_TYPE_OUTPUT, 400 .type = MFB_TYPE_OUTPUT,
393 .id = "Panel1 AOI0", 401 .id = "Panel1 AOI0",
394 .registered = 0, 402 .registered = 0,
@@ -397,8 +405,8 @@ static struct mfb_info mfb_template[] = {
397 .x_aoi_d = 0, 405 .x_aoi_d = 0,
398 .y_aoi_d = 0, 406 .y_aoi_d = 0,
399 }, 407 },
400 { /* AOI 1 for plane 1 */ 408 {
401 .index = 2, 409 .index = PLANE1_AOI1,
402 .type = MFB_TYPE_OUTPUT, 410 .type = MFB_TYPE_OUTPUT,
403 .id = "Panel1 AOI1", 411 .id = "Panel1 AOI1",
404 .registered = 0, 412 .registered = 0,
@@ -407,8 +415,8 @@ static struct mfb_info mfb_template[] = {
407 .x_aoi_d = 0, 415 .x_aoi_d = 0,
408 .y_aoi_d = 480, 416 .y_aoi_d = 480,
409 }, 417 },
410 { /* AOI 0 for plane 2 */ 418 {
411 .index = 3, 419 .index = PLANE2_AOI0,
412 .type = MFB_TYPE_OUTPUT, 420 .type = MFB_TYPE_OUTPUT,
413 .id = "Panel2 AOI0", 421 .id = "Panel2 AOI0",
414 .registered = 0, 422 .registered = 0,
@@ -417,8 +425,8 @@ static struct mfb_info mfb_template[] = {
417 .x_aoi_d = 640, 425 .x_aoi_d = 640,
418 .y_aoi_d = 0, 426 .y_aoi_d = 0,
419 }, 427 },
420 { /* AOI 1 for plane 2 */ 428 {
421 .index = 4, 429 .index = PLANE2_AOI1,
422 .type = MFB_TYPE_OUTPUT, 430 .type = MFB_TYPE_OUTPUT,
423 .id = "Panel2 AOI1", 431 .id = "Panel2 AOI1",
424 .registered = 0, 432 .registered = 0,
@@ -519,11 +527,11 @@ static int fsl_diu_enable_panel(struct fb_info *info)
519 527
520 if (mfbi->type != MFB_TYPE_OFF) { 528 if (mfbi->type != MFB_TYPE_OFF) {
521 switch (mfbi->index) { 529 switch (mfbi->index) {
522 case 0: /* plane 0 */ 530 case PLANE0:
523 if (hw->desc[0] != ad->paddr) 531 if (hw->desc[0] != ad->paddr)
524 wr_reg_wa(&hw->desc[0], ad->paddr); 532 wr_reg_wa(&hw->desc[0], ad->paddr);
525 break; 533 break;
526 case 1: /* plane 1 AOI 0 */ 534 case PLANE1_AOI0:
527 cmfbi = machine_data->fsl_diu_info[2]->par; 535 cmfbi = machine_data->fsl_diu_info[2]->par;
528 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */ 536 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */
529 if (cmfbi->count > 0) /* AOI1 open */ 537 if (cmfbi->count > 0) /* AOI1 open */
@@ -534,7 +542,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
534 wr_reg_wa(&hw->desc[1], ad->paddr); 542 wr_reg_wa(&hw->desc[1], ad->paddr);
535 } 543 }
536 break; 544 break;
537 case 3: /* plane 2 AOI 0 */ 545 case PLANE2_AOI0:
538 cmfbi = machine_data->fsl_diu_info[4]->par; 546 cmfbi = machine_data->fsl_diu_info[4]->par;
539 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */ 547 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */
540 if (cmfbi->count > 0) /* AOI1 open */ 548 if (cmfbi->count > 0) /* AOI1 open */
@@ -545,7 +553,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
545 wr_reg_wa(&hw->desc[2], ad->paddr); 553 wr_reg_wa(&hw->desc[2], ad->paddr);
546 } 554 }
547 break; 555 break;
548 case 2: /* plane 1 AOI 1 */ 556 case PLANE1_AOI1:
549 pmfbi = machine_data->fsl_diu_info[1]->par; 557 pmfbi = machine_data->fsl_diu_info[1]->par;
550 ad->next_ad = 0; 558 ad->next_ad = 0;
551 if (hw->desc[1] == machine_data->dummy_ad->paddr) 559 if (hw->desc[1] == machine_data->dummy_ad->paddr)
@@ -553,7 +561,7 @@ static int fsl_diu_enable_panel(struct fb_info *info)
553 else /* AOI0 open */ 561 else /* AOI0 open */
554 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr); 562 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
555 break; 563 break;
556 case 4: /* plane 2 AOI 1 */ 564 case PLANE2_AOI1:
557 pmfbi = machine_data->fsl_diu_info[3]->par; 565 pmfbi = machine_data->fsl_diu_info[3]->par;
558 ad->next_ad = 0; 566 ad->next_ad = 0;
559 if (hw->desc[2] == machine_data->dummy_ad->paddr) 567 if (hw->desc[2] == machine_data->dummy_ad->paddr)
@@ -561,29 +569,25 @@ static int fsl_diu_enable_panel(struct fb_info *info)
561 else /* AOI0 was open */ 569 else /* AOI0 was open */
562 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr); 570 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
563 break; 571 break;
564 default:
565 res = -EINVAL;
566 break;
567 } 572 }
568 } else 573 } else
569 res = -EINVAL; 574 res = -EINVAL;
570 return res; 575 return res;
571} 576}
572 577
573static int fsl_diu_disable_panel(struct fb_info *info) 578static void fsl_diu_disable_panel(struct fb_info *info)
574{ 579{
575 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par; 580 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
576 struct diu *hw = dr.diu_reg; 581 struct diu *hw = dr.diu_reg;
577 struct diu_ad *ad = mfbi->ad; 582 struct diu_ad *ad = mfbi->ad;
578 struct fsl_diu_data *machine_data = mfbi->parent; 583 struct fsl_diu_data *machine_data = mfbi->parent;
579 int res = 0;
580 584
581 switch (mfbi->index) { 585 switch (mfbi->index) {
582 case 0: /* plane 0 */ 586 case PLANE0:
583 if (hw->desc[0] != machine_data->dummy_ad->paddr) 587 if (hw->desc[0] != machine_data->dummy_ad->paddr)
584 wr_reg_wa(&hw->desc[0], machine_data->dummy_ad->paddr); 588 wr_reg_wa(&hw->desc[0], machine_data->dummy_ad->paddr);
585 break; 589 break;
586 case 1: /* plane 1 AOI 0 */ 590 case PLANE1_AOI0:
587 cmfbi = machine_data->fsl_diu_info[2]->par; 591 cmfbi = machine_data->fsl_diu_info[2]->par;
588 if (cmfbi->count > 0) /* AOI1 is open */ 592 if (cmfbi->count > 0) /* AOI1 is open */
589 wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr); 593 wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
@@ -592,7 +596,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
592 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr); 596 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
593 /* close AOI 0 */ 597 /* close AOI 0 */
594 break; 598 break;
595 case 3: /* plane 2 AOI 0 */ 599 case PLANE2_AOI0:
596 cmfbi = machine_data->fsl_diu_info[4]->par; 600 cmfbi = machine_data->fsl_diu_info[4]->par;
597 if (cmfbi->count > 0) /* AOI1 is open */ 601 if (cmfbi->count > 0) /* AOI1 is open */
598 wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr); 602 wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
@@ -601,7 +605,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
601 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr); 605 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
602 /* close AOI 0 */ 606 /* close AOI 0 */
603 break; 607 break;
604 case 2: /* plane 1 AOI 1 */ 608 case PLANE1_AOI1:
605 pmfbi = machine_data->fsl_diu_info[1]->par; 609 pmfbi = machine_data->fsl_diu_info[1]->par;
606 if (hw->desc[1] != ad->paddr) { 610 if (hw->desc[1] != ad->paddr) {
607 /* AOI1 is not the first in the chain */ 611 /* AOI1 is not the first in the chain */
@@ -612,7 +616,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
612 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr); 616 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad->paddr);
613 /* close AOI 1 */ 617 /* close AOI 1 */
614 break; 618 break;
615 case 4: /* plane 2 AOI 1 */ 619 case PLANE2_AOI1:
616 pmfbi = machine_data->fsl_diu_info[3]->par; 620 pmfbi = machine_data->fsl_diu_info[3]->par;
617 if (hw->desc[2] != ad->paddr) { 621 if (hw->desc[2] != ad->paddr) {
618 /* AOI1 is not the first in the chain */ 622 /* AOI1 is not the first in the chain */
@@ -623,12 +627,7 @@ static int fsl_diu_disable_panel(struct fb_info *info)
623 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr); 627 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad->paddr);
624 /* close AOI 1 */ 628 /* close AOI 1 */
625 break; 629 break;
626 default:
627 res = -EINVAL;
628 break;
629 } 630 }
630
631 return res;
632} 631}
633 632
634static void enable_lcdc(struct fb_info *info) 633static void enable_lcdc(struct fb_info *info)
@@ -660,7 +659,8 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
660{ 659{
661 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par; 660 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par;
662 struct fsl_diu_data *machine_data = mfbi->parent; 661 struct fsl_diu_data *machine_data = mfbi->parent;
663 int available_height, upper_aoi_bottom, index = mfbi->index; 662 int available_height, upper_aoi_bottom;
663 enum mfb_index index = mfbi->index;
664 int lower_aoi_is_open, upper_aoi_is_open; 664 int lower_aoi_is_open, upper_aoi_is_open;
665 __u32 base_plane_width, base_plane_height, upper_aoi_height; 665 __u32 base_plane_width, base_plane_height, upper_aoi_height;
666 666
@@ -672,14 +672,14 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
672 if (mfbi->y_aoi_d < 0) 672 if (mfbi->y_aoi_d < 0)
673 mfbi->y_aoi_d = 0; 673 mfbi->y_aoi_d = 0;
674 switch (index) { 674 switch (index) {
675 case 0: 675 case PLANE0:
676 if (mfbi->x_aoi_d != 0) 676 if (mfbi->x_aoi_d != 0)
677 mfbi->x_aoi_d = 0; 677 mfbi->x_aoi_d = 0;
678 if (mfbi->y_aoi_d != 0) 678 if (mfbi->y_aoi_d != 0)
679 mfbi->y_aoi_d = 0; 679 mfbi->y_aoi_d = 0;
680 break; 680 break;
681 case 1: /* AOI 0 */ 681 case PLANE1_AOI0:
682 case 3: 682 case PLANE2_AOI0:
683 lower_aoi_mfbi = machine_data->fsl_diu_info[index+1]->par; 683 lower_aoi_mfbi = machine_data->fsl_diu_info[index+1]->par;
684 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0; 684 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
685 if (var->xres > base_plane_width) 685 if (var->xres > base_plane_width)
@@ -696,8 +696,8 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
696 if ((mfbi->y_aoi_d + var->yres) > available_height) 696 if ((mfbi->y_aoi_d + var->yres) > available_height)
697 mfbi->y_aoi_d = available_height - var->yres; 697 mfbi->y_aoi_d = available_height - var->yres;
698 break; 698 break;
699 case 2: /* AOI 1 */ 699 case PLANE1_AOI1:
700 case 4: 700 case PLANE2_AOI1:
701 upper_aoi_mfbi = machine_data->fsl_diu_info[index-1]->par; 701 upper_aoi_mfbi = machine_data->fsl_diu_info[index-1]->par;
702 upper_aoi_height = 702 upper_aoi_height =
703 machine_data->fsl_diu_info[index-1]->var.yres; 703 machine_data->fsl_diu_info[index-1]->var.yres;
@@ -1002,7 +1002,7 @@ static int fsl_diu_set_par(struct fb_info *info)
1002 ad->ckmin_g = 255; 1002 ad->ckmin_g = 255;
1003 ad->ckmin_b = 255; 1003 ad->ckmin_b = 255;
1004 1004
1005 if (mfbi->index == 0) 1005 if (mfbi->index == PLANE0)
1006 update_lcdc(info); 1006 update_lcdc(info);
1007 return 0; 1007 return 0;
1008} 1008}
@@ -1195,7 +1195,7 @@ static int fsl_diu_open(struct fb_info *info, int user)
1195 int res = 0; 1195 int res = 0;
1196 1196
1197 /* free boot splash memory on first /dev/fb0 open */ 1197 /* free boot splash memory on first /dev/fb0 open */
1198 if (!mfbi->index && diu_ops.release_bootmem) 1198 if ((mfbi->index == PLANE0) && diu_ops.release_bootmem)
1199 diu_ops.release_bootmem(); 1199 diu_ops.release_bootmem();
1200 1200
1201 spin_lock(&diu_lock); 1201 spin_lock(&diu_lock);
@@ -1225,11 +1225,9 @@ static int fsl_diu_release(struct fb_info *info, int user)
1225 1225
1226 spin_lock(&diu_lock); 1226 spin_lock(&diu_lock);
1227 mfbi->count--; 1227 mfbi->count--;
1228 if (mfbi->count == 0) { 1228 if (mfbi->count == 0)
1229 res = fsl_diu_disable_panel(info); 1229 fsl_diu_disable_panel(info);
1230 if (res < 0) 1230
1231 mfbi->count++;
1232 }
1233 spin_unlock(&diu_lock); 1231 spin_unlock(&diu_lock);
1234 return res; 1232 return res;
1235} 1233}
@@ -1275,7 +1273,7 @@ static int __devinit install_fb(struct fb_info *info)
1275 if (init_fbinfo(info)) 1273 if (init_fbinfo(info))
1276 return -EINVAL; 1274 return -EINVAL;
1277 1275
1278 if (mfbi->index == 0) { /* plane 0 */ 1276 if (mfbi->index == PLANE0) {
1279 if (mfbi->edid_data) { 1277 if (mfbi->edid_data) {
1280 /* Now build modedb from EDID */ 1278 /* Now build modedb from EDID */
1281 fb_edid_to_monspecs(mfbi->edid_data, &info->monspecs); 1279 fb_edid_to_monspecs(mfbi->edid_data, &info->monspecs);
@@ -1296,7 +1294,7 @@ static int __devinit install_fb(struct fb_info *info)
1296 * For plane 0 we continue and look into 1294 * For plane 0 we continue and look into
1297 * driver's internal modedb. 1295 * driver's internal modedb.
1298 */ 1296 */
1299 if (mfbi->index == 0 && mfbi->edid_data) 1297 if ((mfbi->index == PLANE0) && mfbi->edid_data)
1300 has_default_mode = 0; 1298 has_default_mode = 0;
1301 else 1299 else
1302 return -EINVAL; 1300 return -EINVAL;
@@ -1360,7 +1358,7 @@ static void uninstall_fb(struct fb_info *info)
1360 if (!mfbi->registered) 1358 if (!mfbi->registered)
1361 return; 1359 return;
1362 1360
1363 if (mfbi->index == 0) 1361 if (mfbi->index == PLANE0)
1364 kfree(mfbi->edid_data); 1362 kfree(mfbi->edid_data);
1365 1363
1366 unregister_framebuffer(info); 1364 unregister_framebuffer(info);
@@ -1565,7 +1563,7 @@ static int __devinit fsl_diu_probe(struct platform_device *pdev)
1565 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info)); 1563 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
1566 mfbi->parent = machine_data; 1564 mfbi->parent = machine_data;
1567 1565
1568 if (mfbi->index == 0) { 1566 if (mfbi->index == PLANE0) {
1569 const u8 *prop; 1567 const u8 *prop;
1570 int len; 1568 int len;
1571 1569