aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ps3/ps3av.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>2007-10-16 04:29:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:20 -0400
commit71a27fecaf836093a30fe538c5ab98ef0b25bfc8 (patch)
tree52addb93c5c7100609807633cec834d0c3e3ac1f /drivers/ps3/ps3av.c
parenteea820ab0b189d74620dca376817a2e599eb1ab1 (diff)
ps3av: use PS3 video mode ids in autodetect code
It doesn't make much sense to use the PS3AV_CMD_VIDEO_VID_* values in the autodetection code, just to convert them to PS3 video mode ids afterwards. Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/ps3/ps3av.c')
-rw-r--r--drivers/ps3/ps3av.c90
1 files changed, 40 insertions, 50 deletions
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index c1bcad66ce75..51feb7e46b0e 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -585,75 +585,65 @@ static void ps3avd(struct work_struct *work)
585 complete(&ps3av->done); 585 complete(&ps3av->done);
586} 586}
587 587
588static int ps3av_vid2table_id(int vid) 588static int ps3av_resbit2id(u32 res_50, u32 res_60)
589{ 589{
590 int i; 590 int id = 0;
591
592 for (i = 1; i < ARRAY_SIZE(video_mode_table); i++)
593 if (video_mode_table[i].vid == vid)
594 return i;
595 return -1;
596}
597
598static int ps3av_resbit2vid(u32 res_50, u32 res_60)
599{
600 int vid = -1;
601 591
602 if (res_50 > res_60) { /* if res_50 == res_60, res_60 will be used */ 592 if (res_50 > res_60) { /* if res_50 == res_60, res_60 will be used */
603 if (res_50 & PS3AV_RESBIT_1920x1080P) 593 if (res_50 & PS3AV_RESBIT_1920x1080P)
604 vid = PS3AV_CMD_VIDEO_VID_1080P_50HZ; 594 id = 10;
605 else if (res_50 & PS3AV_RESBIT_1920x1080I) 595 else if (res_50 & PS3AV_RESBIT_1920x1080I)
606 vid = PS3AV_CMD_VIDEO_VID_1080I_50HZ; 596 id = 9;
607 else if (res_50 & PS3AV_RESBIT_1280x720P) 597 else if (res_50 & PS3AV_RESBIT_1280x720P)
608 vid = PS3AV_CMD_VIDEO_VID_720P_50HZ; 598 id = 8;
609 else if (res_50 & PS3AV_RESBIT_720x576P) 599 else if (res_50 & PS3AV_RESBIT_720x576P)
610 vid = PS3AV_CMD_VIDEO_VID_576P; 600 id = 7;
611 else 601 else
612 vid = -1; 602 id = 0;
613 } else { 603 } else {
614 if (res_60 & PS3AV_RESBIT_1920x1080P) 604 if (res_60 & PS3AV_RESBIT_1920x1080P)
615 vid = PS3AV_CMD_VIDEO_VID_1080P_60HZ; 605 id = 5;
616 else if (res_60 & PS3AV_RESBIT_1920x1080I) 606 else if (res_60 & PS3AV_RESBIT_1920x1080I)
617 vid = PS3AV_CMD_VIDEO_VID_1080I_60HZ; 607 id = 4;
618 else if (res_60 & PS3AV_RESBIT_1280x720P) 608 else if (res_60 & PS3AV_RESBIT_1280x720P)
619 vid = PS3AV_CMD_VIDEO_VID_720P_60HZ; 609 id = 3;
620 else if (res_60 & PS3AV_RESBIT_720x480P) 610 else if (res_60 & PS3AV_RESBIT_720x480P)
621 vid = PS3AV_CMD_VIDEO_VID_480P; 611 id = 2;
622 else 612 else
623 vid = -1; 613 id = 0;
624 } 614 }
625 return vid; 615 return id;
626} 616}
627 617
628static int ps3av_hdmi_get_vid(struct ps3av_info_monitor *info) 618static int ps3av_hdmi_get_id(struct ps3av_info_monitor *info)
629{ 619{
630 u32 res_50, res_60; 620 u32 res_50, res_60;
631 int vid = -1; 621 int id;
632 622
633 if (info->monitor_type != PS3AV_MONITOR_TYPE_HDMI) 623 if (info->monitor_type != PS3AV_MONITOR_TYPE_HDMI)
634 return -1; 624 return 0;
635 625
636 /* check native resolution */ 626 /* check native resolution */
637 res_50 = info->res_50.native & PS3AV_RES_MASK_50; 627 res_50 = info->res_50.native & PS3AV_RES_MASK_50;
638 res_60 = info->res_60.native & PS3AV_RES_MASK_60; 628 res_60 = info->res_60.native & PS3AV_RES_MASK_60;
639 if (res_50 || res_60) { 629 if (res_50 || res_60) {
640 vid = ps3av_resbit2vid(res_50, res_60); 630 id = ps3av_resbit2id(res_50, res_60);
641 return vid; 631 return id;
642 } 632 }
643 633
644 /* check resolution */ 634 /* check resolution */
645 res_50 = info->res_50.res_bits & PS3AV_RES_MASK_50; 635 res_50 = info->res_50.res_bits & PS3AV_RES_MASK_50;
646 res_60 = info->res_60.res_bits & PS3AV_RES_MASK_60; 636 res_60 = info->res_60.res_bits & PS3AV_RES_MASK_60;
647 if (res_50 || res_60) { 637 if (res_50 || res_60) {
648 vid = ps3av_resbit2vid(res_50, res_60); 638 id = ps3av_resbit2id(res_50, res_60);
649 return vid; 639 return id;
650 } 640 }
651 641
652 if (ps3av->region & PS3AV_REGION_60) 642 if (ps3av->region & PS3AV_REGION_60)
653 vid = PS3AV_DEFAULT_HDMI_VID_REG_60; 643 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
654 else 644 else
655 vid = PS3AV_DEFAULT_HDMI_VID_REG_50; 645 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
656 return vid; 646 return id;
657} 647}
658 648
659static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *monitor_info) 649static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *monitor_info)
@@ -717,11 +707,11 @@ static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *
717static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf, 707static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
718 int boot) 708 int boot)
719{ 709{
720 int i, res, vid = -1, dvi = 0, rgb = 0; 710 int i, res, id = 0, dvi = 0, rgb = 0;
721 struct ps3av_pkt_av_get_monitor_info monitor_info; 711 struct ps3av_pkt_av_get_monitor_info monitor_info;
722 struct ps3av_info_monitor *info; 712 struct ps3av_info_monitor *info;
723 713
724 /* get vid for hdmi */ 714 /* get mode id for hdmi */
725 for (i = 0; i < av_hw_conf->num_of_hdmi; i++) { 715 for (i = 0; i < av_hw_conf->num_of_hdmi; i++) {
726 res = ps3av_cmd_video_get_monitor_info(&monitor_info, 716 res = ps3av_cmd_video_get_monitor_info(&monitor_info,
727 PS3AV_CMD_AVPORT_HDMI_0 + 717 PS3AV_CMD_AVPORT_HDMI_0 +
@@ -737,49 +727,49 @@ static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
737 break; 727 break;
738 } 728 }
739 /* check HDMI */ 729 /* check HDMI */
740 vid = ps3av_hdmi_get_vid(info); 730 id = ps3av_hdmi_get_id(info);
741 if (vid != -1) { 731 if (id) {
742 /* got valid vid */ 732 /* got valid mode id */
743 break; 733 break;
744 } 734 }
745 } 735 }
746 736
747 if (dvi) { 737 if (dvi) {
748 /* DVI mode */ 738 /* DVI mode */
749 vid = PS3AV_DEFAULT_DVI_VID; 739 id = PS3AV_DEFAULT_DVI_MODE_ID;
750 } else if (vid == -1) { 740 } else if (!id) {
751 /* no HDMI interface or HDMI is off */ 741 /* no HDMI interface or HDMI is off */
752 if (ps3av->region & PS3AV_REGION_60) 742 if (ps3av->region & PS3AV_REGION_60)
753 vid = PS3AV_DEFAULT_AVMULTI_VID_REG_60; 743 id = PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_60;
754 else 744 else
755 vid = PS3AV_DEFAULT_AVMULTI_VID_REG_50; 745 id = PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_50;
756 if (ps3av->region & PS3AV_REGION_RGB) 746 if (ps3av->region & PS3AV_REGION_RGB)
757 rgb = PS3AV_MODE_RGB; 747 rgb = PS3AV_MODE_RGB;
758 } else if (boot) { 748 } else if (boot) {
759 /* HDMI: using DEFAULT HDMI_VID while booting up */ 749 /* HDMI: using DEFAULT HDMI_MODE_ID while booting up */
760 info = &monitor_info.info; 750 info = &monitor_info.info;
761 if (ps3av->region & PS3AV_REGION_60) { 751 if (ps3av->region & PS3AV_REGION_60) {
762 if (info->res_60.res_bits & PS3AV_RESBIT_720x480P) 752 if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
763 vid = PS3AV_DEFAULT_HDMI_VID_REG_60; 753 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
764 else if (info->res_50.res_bits & PS3AV_RESBIT_720x576P) 754 else if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
765 vid = PS3AV_DEFAULT_HDMI_VID_REG_50; 755 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
766 else { 756 else {
767 /* default */ 757 /* default */
768 vid = PS3AV_DEFAULT_HDMI_VID_REG_60; 758 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
769 } 759 }
770 } else { 760 } else {
771 if (info->res_50.res_bits & PS3AV_RESBIT_720x576P) 761 if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
772 vid = PS3AV_DEFAULT_HDMI_VID_REG_50; 762 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
773 else if (info->res_60.res_bits & PS3AV_RESBIT_720x480P) 763 else if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
774 vid = PS3AV_DEFAULT_HDMI_VID_REG_60; 764 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
775 else { 765 else {
776 /* default */ 766 /* default */
777 vid = PS3AV_DEFAULT_HDMI_VID_REG_50; 767 id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
778 } 768 }
779 } 769 }
780 } 770 }
781 771
782 return (ps3av_vid2table_id(vid) | dvi | rgb); 772 return id | dvi | rgb;
783} 773}
784 774
785static int ps3av_get_hw_conf(struct ps3av *ps3av) 775static int ps3av_get_hw_conf(struct ps3av *ps3av)