aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>2008-02-06 04:39:29 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:17 -0500
commit084ffff29844a4bce69999d67809e6c00309ba58 (patch)
tree11c98d8c1c127edc227cb610ffcac4e7c321bcc3
parent3c4f594a6da410789975dcde16b07b62c62fa564 (diff)
ps3: use symbolic names for video modes
Use symbolic names for video modes Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/ps3/ps3av.c39
-rw-r--r--drivers/video/ps3fb.c17
-rw-r--r--include/asm-powerpc/ps3av.h41
3 files changed, 60 insertions, 37 deletions
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index 9671d0cd18c6..6f2f90ebb020 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -542,7 +542,7 @@ static void ps3av_set_videomode_packet(u32 id)
542 542
543static void ps3av_set_videomode_cont(u32 id, u32 old_id) 543static void ps3av_set_videomode_cont(u32 id, u32 old_id)
544{ 544{
545 static int vesa = 0; 545 static int vesa;
546 int res; 546 int res;
547 547
548 /* video signal off */ 548 /* video signal off */
@@ -552,9 +552,9 @@ static void ps3av_set_videomode_cont(u32 id, u32 old_id)
552 * AV backend needs non-VESA mode setting at least one time 552 * AV backend needs non-VESA mode setting at least one time
553 * when VESA mode is used. 553 * when VESA mode is used.
554 */ 554 */
555 if (vesa == 0 && (id & PS3AV_MODE_MASK) >= 11) { 555 if (vesa == 0 && (id & PS3AV_MODE_MASK) >= PS3AV_MODE_WXGA) {
556 /* vesa mode */ 556 /* vesa mode */
557 ps3av_set_videomode_packet(2); /* 480P */ 557 ps3av_set_videomode_packet(PS3AV_MODE_480P);
558 } 558 }
559 vesa = 1; 559 vesa = 1;
560 560
@@ -594,20 +594,21 @@ static const struct {
594 unsigned mask : 19; 594 unsigned mask : 19;
595 unsigned id : 4; 595 unsigned id : 4;
596} ps3av_preferred_modes[] = { 596} ps3av_preferred_modes[] = {
597 { .mask = PS3AV_RESBIT_WUXGA << SHIFT_VESA, .id = 13 }, 597 { PS3AV_RESBIT_WUXGA << SHIFT_VESA, PS3AV_MODE_WUXGA },
598 { .mask = PS3AV_RESBIT_1920x1080P << SHIFT_60, .id = 5 }, 598 { PS3AV_RESBIT_1920x1080P << SHIFT_60, PS3AV_MODE_1080P60 },
599 { .mask = PS3AV_RESBIT_1920x1080P << SHIFT_50, .id = 10 }, 599 { PS3AV_RESBIT_1920x1080P << SHIFT_50, PS3AV_MODE_1080P50 },
600 { .mask = PS3AV_RESBIT_1920x1080I << SHIFT_60, .id = 4 }, 600 { PS3AV_RESBIT_1920x1080I << SHIFT_60, PS3AV_MODE_1080I60 },
601 { .mask = PS3AV_RESBIT_1920x1080I << SHIFT_50, .id = 9 }, 601 { PS3AV_RESBIT_1920x1080I << SHIFT_50, PS3AV_MODE_1080I50 },
602 { .mask = PS3AV_RESBIT_SXGA << SHIFT_VESA, .id = 12 }, 602 { PS3AV_RESBIT_SXGA << SHIFT_VESA, PS3AV_MODE_SXGA },
603 { .mask = PS3AV_RESBIT_WXGA << SHIFT_VESA, .id = 11 }, 603 { PS3AV_RESBIT_WXGA << SHIFT_VESA, PS3AV_MODE_WXGA },
604 { .mask = PS3AV_RESBIT_1280x720P << SHIFT_60, .id = 3 }, 604 { PS3AV_RESBIT_1280x720P << SHIFT_60, PS3AV_MODE_720P60 },
605 { .mask = PS3AV_RESBIT_1280x720P << SHIFT_50, .id = 8 }, 605 { PS3AV_RESBIT_1280x720P << SHIFT_50, PS3AV_MODE_720P50 },
606 { .mask = PS3AV_RESBIT_720x480P << SHIFT_60, .id = 2 }, 606 { PS3AV_RESBIT_720x480P << SHIFT_60, PS3AV_MODE_480P },
607 { .mask = PS3AV_RESBIT_720x576P << SHIFT_50, .id = 7 }, 607 { PS3AV_RESBIT_720x576P << SHIFT_50, PS3AV_MODE_576P },
608}; 608};
609 609
610static 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)
611{ 612{
612 unsigned int i; 613 unsigned int i;
613 u32 res_all; 614 u32 res_all;
@@ -636,9 +637,9 @@ static int ps3av_resbit2id(u32 res_50, u32 res_60, u32 res_vesa)
636 return 0; 637 return 0;
637} 638}
638 639
639static int ps3av_hdmi_get_id(struct ps3av_info_monitor *info) 640static enum ps3av_mode_num ps3av_hdmi_get_id(struct ps3av_info_monitor *info)
640{ 641{
641 int id; 642 enum ps3av_mode_num id;
642 643
643 if (safe_mode) 644 if (safe_mode)
644 return PS3AV_DEFAULT_HDMI_MODE_ID_REG_60; 645 return PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
@@ -852,7 +853,7 @@ int ps3av_set_video_mode(u32 id)
852 853
853 /* auto mode */ 854 /* auto mode */
854 option = id & ~PS3AV_MODE_MASK; 855 option = id & ~PS3AV_MODE_MASK;
855 if ((id & PS3AV_MODE_MASK) == 0) { 856 if ((id & PS3AV_MODE_MASK) == PS3AV_MODE_AUTO) {
856 id = ps3av_auto_videomode(&ps3av->av_hw_conf); 857 id = ps3av_auto_videomode(&ps3av->av_hw_conf);
857 if (id < 1) { 858 if (id < 1) {
858 printk(KERN_ERR "%s: invalid id :%d\n", __func__, id); 859 printk(KERN_ERR "%s: invalid id :%d\n", __func__, id);
@@ -958,7 +959,7 @@ static int ps3av_probe(struct ps3_system_bus_device *dev)
958 return -ENOMEM; 959 return -ENOMEM;
959 960
960 mutex_init(&ps3av->mutex); 961 mutex_init(&ps3av->mutex);
961 ps3av->ps3av_mode = 0; 962 ps3av->ps3av_mode = PS3AV_MODE_AUTO;
962 ps3av->dev = dev; 963 ps3av->dev = dev;
963 964
964 INIT_WORK(&ps3av->work, ps3avd); 965 INIT_WORK(&ps3av->work, ps3avd);
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 044a423a72cb..1f982bd6cc17 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -338,7 +338,7 @@ static int ps3fb_get_res_table(u32 xres, u32 yres, int mode)
338static unsigned int ps3fb_find_mode(const struct fb_var_screeninfo *var, 338static unsigned int ps3fb_find_mode(const struct fb_var_screeninfo *var,
339 u32 *ddr_line_length, u32 *xdr_line_length) 339 u32 *ddr_line_length, u32 *xdr_line_length)
340{ 340{
341 unsigned int i, mode; 341 unsigned int i, fi, mode;
342 342
343 for (i = 0; i < ARRAY_SIZE(ps3fb_modedb); i++) 343 for (i = 0; i < ARRAY_SIZE(ps3fb_modedb); i++)
344 if (var->xres == ps3fb_modedb[i].xres && 344 if (var->xres == ps3fb_modedb[i].xres &&
@@ -359,7 +359,8 @@ static unsigned int ps3fb_find_mode(const struct fb_var_screeninfo *var,
359 359
360found: 360found:
361 /* Cropped broadcast modes use the full line length */ 361 /* Cropped broadcast modes use the full line length */
362 *ddr_line_length = ps3fb_modedb[i < 10 ? i + 13 : i].xres * BPP; 362 fi = i < PS3AV_MODE_1080P50 ? i + PS3AV_MODE_WUXGA : i;
363 *ddr_line_length = ps3fb_modedb[fi].xres * BPP;
363 364
364 if (ps3_compare_firmware_version(1, 9, 0) >= 0) { 365 if (ps3_compare_firmware_version(1, 9, 0) >= 0) {
365 *xdr_line_length = GPU_ALIGN_UP(max(var->xres, 366 *xdr_line_length = GPU_ALIGN_UP(max(var->xres,
@@ -370,7 +371,9 @@ found:
370 *xdr_line_length = *ddr_line_length; 371 *xdr_line_length = *ddr_line_length;
371 372
372 /* Full broadcast modes have the full mode bit set */ 373 /* Full broadcast modes have the full mode bit set */
373 mode = i > 12 ? (i - 12) | PS3FB_FULL_MODE_BIT : i + 1; 374 mode = i+1;
375 if (mode > PS3AV_MODE_WUXGA)
376 mode = (mode - PS3AV_MODE_WUXGA) | PS3FB_FULL_MODE_BIT;
374 377
375 pr_debug("ps3fb_find_mode: mode %u\n", mode); 378 pr_debug("ps3fb_find_mode: mode %u\n", mode);
376 379
@@ -382,14 +385,14 @@ static const struct fb_videomode *ps3fb_default_mode(int id)
382 u32 mode = id & PS3AV_MODE_MASK; 385 u32 mode = id & PS3AV_MODE_MASK;
383 u32 flags; 386 u32 flags;
384 387
385 if (mode < 1 || mode > 13) 388 if (mode < PS3AV_MODE_480I || mode > PS3AV_MODE_WUXGA)
386 return NULL; 389 return NULL;
387 390
388 flags = id & ~PS3AV_MODE_MASK; 391 flags = id & ~PS3AV_MODE_MASK;
389 392
390 if (mode <= 10 && flags & PS3FB_FULL_MODE_BIT) { 393 if (mode <= PS3AV_MODE_1080P50 && flags & PS3FB_FULL_MODE_BIT) {
391 /* Full broadcast mode */ 394 /* Full broadcast mode */
392 return &ps3fb_modedb[mode + 12]; 395 return &ps3fb_modedb[mode + PS3AV_MODE_WUXGA - 1];
393 } 396 }
394 397
395 return &ps3fb_modedb[mode - 1]; 398 return &ps3fb_modedb[mode - 1];
@@ -1080,7 +1083,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1080 1083
1081 if (!ps3fb_mode) 1084 if (!ps3fb_mode)
1082 ps3fb_mode = ps3av_get_mode(); 1085 ps3fb_mode = ps3av_get_mode();
1083 dev_dbg(&dev->core, "ps3av_mode:%d\n", ps3fb_mode); 1086 dev_dbg(&dev->core, "ps3fb_mode: %d\n", ps3fb_mode);
1084 1087
1085 if (ps3fb_mode > 0 && 1088 if (ps3fb_mode > 0 &&
1086 !ps3av_video_mode2res(ps3fb_mode, &xres, &yres)) { 1089 !ps3av_video_mode2res(ps3fb_mode, &xres, &yres)) {
diff --git a/include/asm-powerpc/ps3av.h b/include/asm-powerpc/ps3av.h
index 81a2942b2c4c..fda98715cd35 100644
--- a/include/asm-powerpc/ps3av.h
+++ b/include/asm-powerpc/ps3av.h
@@ -310,19 +310,25 @@
310#define PS3AV_MONITOR_TYPE_HDMI 1 /* HDMI */ 310#define PS3AV_MONITOR_TYPE_HDMI 1 /* HDMI */
311#define PS3AV_MONITOR_TYPE_DVI 2 /* DVI */ 311#define PS3AV_MONITOR_TYPE_DVI 2 /* DVI */
312 312
313#define PS3AV_DEFAULT_HDMI_MODE_ID_REG_60 2 /* 480p */
314#define PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_60 1 /* 480i */
315#define PS3AV_DEFAULT_HDMI_MODE_ID_REG_50 7 /* 576p */
316#define PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_50 6 /* 576i */
317
318#define PS3AV_REGION_60 0x01
319#define PS3AV_REGION_50 0x02
320#define PS3AV_REGION_RGB 0x10
321
322#define get_status(buf) (((__u32 *)buf)[2])
323#define PS3AV_HDR_SIZE 4 /* version + size */
324 313
325/* for video mode */ 314/* for video mode */
315enum ps3av_mode_num {
316 PS3AV_MODE_AUTO = 0,
317 PS3AV_MODE_480I = 1,
318 PS3AV_MODE_480P = 2,
319 PS3AV_MODE_720P60 = 3,
320 PS3AV_MODE_1080I60 = 4,
321 PS3AV_MODE_1080P60 = 5,
322 PS3AV_MODE_576I = 6,
323 PS3AV_MODE_576P = 7,
324 PS3AV_MODE_720P50 = 8,
325 PS3AV_MODE_1080I50 = 9,
326 PS3AV_MODE_1080P50 = 10,
327 PS3AV_MODE_WXGA = 11,
328 PS3AV_MODE_SXGA = 12,
329 PS3AV_MODE_WUXGA = 13,
330};
331
326#define PS3AV_MODE_MASK 0x000F 332#define PS3AV_MODE_MASK 0x000F
327#define PS3AV_MODE_HDCP_OFF 0x1000 /* Retail PS3 product doesn't support this */ 333#define PS3AV_MODE_HDCP_OFF 0x1000 /* Retail PS3 product doesn't support this */
328#define PS3AV_MODE_DITHER 0x0800 334#define PS3AV_MODE_DITHER 0x0800
@@ -333,6 +339,19 @@
333#define PS3AV_MODE_RGB 0x0020 339#define PS3AV_MODE_RGB 0x0020
334 340
335 341
342#define PS3AV_DEFAULT_HDMI_MODE_ID_REG_60 PS3AV_MODE_480P
343#define PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_60 PS3AV_MODE_480I
344#define PS3AV_DEFAULT_HDMI_MODE_ID_REG_50 PS3AV_MODE_576P
345#define PS3AV_DEFAULT_AVMULTI_MODE_ID_REG_50 PS3AV_MODE_576I
346
347#define PS3AV_REGION_60 0x01
348#define PS3AV_REGION_50 0x02
349#define PS3AV_REGION_RGB 0x10
350
351#define get_status(buf) (((__u32 *)buf)[2])
352#define PS3AV_HDR_SIZE 4 /* version + size */
353
354
336/** command packet structure **/ 355/** command packet structure **/
337struct ps3av_send_hdr { 356struct ps3av_send_hdr {
338 u16 version; 357 u16 version;