aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ps3/ps3av.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ps3/ps3av.c')
-rw-r--r--drivers/ps3/ps3av.c97
1 files changed, 33 insertions, 64 deletions
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index 87b3493d88e5..6f2f90ebb020 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -78,23 +78,21 @@ static const struct avset_video_mode {
78 u32 aspect; 78 u32 aspect;
79 u32 x; 79 u32 x;
80 u32 y; 80 u32 y;
81 u32 interlace;
82 u32 freq;
83} video_mode_table[] = { 81} video_mode_table[] = {
84 { 0, }, /* auto */ 82 { 0, }, /* auto */
85 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_480I, A_N, 720, 480, 1, 60}, 83 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_480I, A_N, 720, 480},
86 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_480P, A_N, 720, 480, 0, 60}, 84 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_480P, A_N, 720, 480},
87 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_720P_60HZ, A_N, 1280, 720, 0, 60}, 85 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_720P_60HZ, A_N, 1280, 720},
88 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080I_60HZ, A_W, 1920, 1080, 1, 60}, 86 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080I_60HZ, A_W, 1920, 1080},
89 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080P_60HZ, A_W, 1920, 1080, 0, 60}, 87 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080P_60HZ, A_W, 1920, 1080},
90 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_576I, A_N, 720, 576, 1, 50}, 88 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_576I, A_N, 720, 576},
91 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_576P, A_N, 720, 576, 0, 50}, 89 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_576P, A_N, 720, 576},
92 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_720P_50HZ, A_N, 1280, 720, 0, 50}, 90 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_720P_50HZ, A_N, 1280, 720},
93 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080I_50HZ, A_W, 1920, 1080, 1, 50}, 91 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080I_50HZ, A_W, 1920, 1080},
94 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080P_50HZ, A_W, 1920, 1080, 0, 50}, 92 {YUV444, XRGB, PS3AV_CMD_VIDEO_VID_1080P_50HZ, A_W, 1920, 1080},
95 { RGB8, XRGB, PS3AV_CMD_VIDEO_VID_WXGA, A_W, 1280, 768, 0, 60}, 93 { RGB8, XRGB, PS3AV_CMD_VIDEO_VID_WXGA, A_W, 1280, 768},
96 { RGB8, XRGB, PS3AV_CMD_VIDEO_VID_SXGA, A_N, 1280, 1024, 0, 60}, 94 { RGB8, XRGB, PS3AV_CMD_VIDEO_VID_SXGA, A_N, 1280, 1024},
97 { RGB8, XRGB, PS3AV_CMD_VIDEO_VID_WUXGA, A_W, 1920, 1200, 0, 60}, 95 { RGB8, XRGB, PS3AV_CMD_VIDEO_VID_WUXGA, A_W, 1920, 1200},
98}; 96};
99 97
100/* supported CIDs */ 98/* supported CIDs */
@@ -544,7 +542,7 @@ static void ps3av_set_videomode_packet(u32 id)
544 542
545static void ps3av_set_videomode_cont(u32 id, u32 old_id) 543static void ps3av_set_videomode_cont(u32 id, u32 old_id)
546{ 544{
547 static int vesa = 0; 545 static int vesa;
548 int res; 546 int res;
549 547
550 /* video signal off */ 548 /* video signal off */
@@ -554,9 +552,9 @@ static void ps3av_set_videomode_cont(u32 id, u32 old_id)
554 * AV backend needs non-VESA mode setting at least one time 552 * AV backend needs non-VESA mode setting at least one time
555 * when VESA mode is used. 553 * when VESA mode is used.
556 */ 554 */
557 if (vesa == 0 && (id & PS3AV_MODE_MASK) >= 11) { 555 if (vesa == 0 && (id & PS3AV_MODE_MASK) >= PS3AV_MODE_WXGA) {
558 /* vesa mode */ 556 /* vesa mode */
559 ps3av_set_videomode_packet(2); /* 480P */ 557 ps3av_set_videomode_packet(PS3AV_MODE_480P);
560 } 558 }
561 vesa = 1; 559 vesa = 1;
562 560
@@ -596,20 +594,21 @@ static const struct {
596 unsigned mask : 19; 594 unsigned mask : 19;
597 unsigned id : 4; 595 unsigned id : 4;
598} ps3av_preferred_modes[] = { 596} ps3av_preferred_modes[] = {
599 { .mask = PS3AV_RESBIT_WUXGA << SHIFT_VESA, .id = 13 }, 597 { PS3AV_RESBIT_WUXGA << SHIFT_VESA, PS3AV_MODE_WUXGA },
600 { .mask = PS3AV_RESBIT_1920x1080P << SHIFT_60, .id = 5 }, 598 { PS3AV_RESBIT_1920x1080P << SHIFT_60, PS3AV_MODE_1080P60 },
601 { .mask = PS3AV_RESBIT_1920x1080P << SHIFT_50, .id = 10 }, 599 { PS3AV_RESBIT_1920x1080P << SHIFT_50, PS3AV_MODE_1080P50 },
602 { .mask = PS3AV_RESBIT_1920x1080I << SHIFT_60, .id = 4 }, 600 { PS3AV_RESBIT_1920x1080I << SHIFT_60, PS3AV_MODE_1080I60 },
603 { .mask = PS3AV_RESBIT_1920x1080I << SHIFT_50, .id = 9 }, 601 { PS3AV_RESBIT_1920x1080I << SHIFT_50, PS3AV_MODE_1080I50 },
604 { .mask = PS3AV_RESBIT_SXGA << SHIFT_VESA, .id = 12 }, 602 { PS3AV_RESBIT_SXGA << SHIFT_VESA, PS3AV_MODE_SXGA },
605 { .mask = PS3AV_RESBIT_WXGA << SHIFT_VESA, .id = 11 }, 603 { PS3AV_RESBIT_WXGA << SHIFT_VESA, PS3AV_MODE_WXGA },
606 { .mask = PS3AV_RESBIT_1280x720P << SHIFT_60, .id = 3 }, 604 { PS3AV_RESBIT_1280x720P << SHIFT_60, PS3AV_MODE_720P60 },
607 { .mask = PS3AV_RESBIT_1280x720P << SHIFT_50, .id = 8 }, 605 { PS3AV_RESBIT_1280x720P << SHIFT_50, PS3AV_MODE_720P50 },
608 { .mask = PS3AV_RESBIT_720x480P << SHIFT_60, .id = 2 }, 606 { PS3AV_RESBIT_720x480P << SHIFT_60, PS3AV_MODE_480P },
609 { .mask = PS3AV_RESBIT_720x576P << SHIFT_50, .id = 7 }, 607 { PS3AV_RESBIT_720x576P << SHIFT_50, PS3AV_MODE_576P },
610}; 608};
611 609
612static int ps3av_resbit2id(u32 res_50, u32 res_60, u32 res_vesa) 610static enum ps3av_mode_num ps3av_resbit2id(u32 res_50, u32 res_60,
611 u32 res_vesa)
613{ 612{
614 unsigned int i; 613 unsigned int i;
615 u32 res_all; 614 u32 res_all;
@@ -638,9 +637,9 @@ static int ps3av_resbit2id(u32 res_50, u32 res_60, u32 res_vesa)
638 return 0; 637 return 0;
639} 638}
640 639
641static int ps3av_hdmi_get_id(struct ps3av_info_monitor *info) 640static enum ps3av_mode_num ps3av_hdmi_get_id(struct ps3av_info_monitor *info)
642{ 641{
643 int id; 642 enum ps3av_mode_num id;
644 643
645 if (safe_mode) 644 if (safe_mode)
646 return PS3AV_DEFAULT_HDMI_MODE_ID_REG_60; 645 return PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
@@ -854,7 +853,7 @@ int ps3av_set_video_mode(u32 id)
854 853
855 /* auto mode */ 854 /* auto mode */
856 option = id & ~PS3AV_MODE_MASK; 855 option = id & ~PS3AV_MODE_MASK;
857 if ((id & PS3AV_MODE_MASK) == 0) { 856 if ((id & PS3AV_MODE_MASK) == PS3AV_MODE_AUTO) {
858 id = ps3av_auto_videomode(&ps3av->av_hw_conf); 857 id = ps3av_auto_videomode(&ps3av->av_hw_conf);
859 if (id < 1) { 858 if (id < 1) {
860 printk(KERN_ERR "%s: invalid id :%d\n", __func__, id); 859 printk(KERN_ERR "%s: invalid id :%d\n", __func__, id);
@@ -889,36 +888,6 @@ int ps3av_get_mode(void)
889 888
890EXPORT_SYMBOL_GPL(ps3av_get_mode); 889EXPORT_SYMBOL_GPL(ps3av_get_mode);
891 890
892int ps3av_get_scanmode(int id)
893{
894 int size;
895
896 id = id & PS3AV_MODE_MASK;
897 size = ARRAY_SIZE(video_mode_table);
898 if (id > size - 1 || id < 0) {
899 printk(KERN_ERR "%s: invalid mode %d\n", __func__, id);
900 return -EINVAL;
901 }
902 return video_mode_table[id].interlace;
903}
904
905EXPORT_SYMBOL_GPL(ps3av_get_scanmode);
906
907int ps3av_get_refresh_rate(int id)
908{
909 int size;
910
911 id = id & PS3AV_MODE_MASK;
912 size = ARRAY_SIZE(video_mode_table);
913 if (id > size - 1 || id < 0) {
914 printk(KERN_ERR "%s: invalid mode %d\n", __func__, id);
915 return -EINVAL;
916 }
917 return video_mode_table[id].freq;
918}
919
920EXPORT_SYMBOL_GPL(ps3av_get_refresh_rate);
921
922/* get resolution by video_mode */ 891/* get resolution by video_mode */
923int ps3av_video_mode2res(u32 id, u32 *xres, u32 *yres) 892int ps3av_video_mode2res(u32 id, u32 *xres, u32 *yres)
924{ 893{
@@ -990,7 +959,7 @@ static int ps3av_probe(struct ps3_system_bus_device *dev)
990 return -ENOMEM; 959 return -ENOMEM;
991 960
992 mutex_init(&ps3av->mutex); 961 mutex_init(&ps3av->mutex);
993 ps3av->ps3av_mode = 0; 962 ps3av->ps3av_mode = PS3AV_MODE_AUTO;
994 ps3av->dev = dev; 963 ps3av->dev = dev;
995 964
996 INIT_WORK(&ps3av->work, ps3avd); 965 INIT_WORK(&ps3av->work, ps3avd);