]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/ps3/ps3av.c
Merge branch 'master' of hera.kernel.org:/pub/scm/linux/kernel/git/kyle/parisc-2.6
[mv-sheeva.git] / drivers / ps3 / ps3av.c
index fbf8dcde967517db10d7fa8d8bcee7a1c77fa321..87b3493d88e5bea0f93b3fc0ef412bbb1232a722 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/notifier.h>
 #include <linux/ioctl.h>
+#include <linux/fb.h>
 
 #include <asm/firmware.h>
 #include <asm/ps3av.h>
@@ -33,6 +34,8 @@
 #define BUFSIZE          4096  /* vuart buf size */
 #define PS3AV_BUF_SIZE   512   /* max packet size */
 
+static int safe_mode;
+
 static int timeout = 5000;     /* in msec ( 5 sec ) */
 module_param(timeout, int, 0644);
 
@@ -639,6 +642,9 @@ static int ps3av_hdmi_get_id(struct ps3av_info_monitor *info)
 {
        int id;
 
+       if (safe_mode)
+               return PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
+
        /* check native resolution */
        id = ps3av_resbit2id(info->res_50.native, info->res_60.native,
                             info->res_vesa.native);
@@ -721,8 +727,42 @@ static void ps3av_monitor_info_dump(const struct ps3av_pkt_av_get_monitor_info *
        }
 }
 
-static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
-                               int boot)
+static const struct ps3av_monitor_quirk {
+       const char *monitor_name;
+       u32 clear_60;
+} ps3av_monitor_quirks[] = {
+       {
+               .monitor_name   = "DELL 2007WFP",
+               .clear_60       = PS3AV_RESBIT_1920x1080I
+       }, {
+               .monitor_name   = "L226WTQ",
+               .clear_60       = PS3AV_RESBIT_1920x1080I |
+                                 PS3AV_RESBIT_1920x1080P
+       }, {
+               .monitor_name   = "SyncMaster",
+               .clear_60       = PS3AV_RESBIT_1920x1080I
+       }
+};
+
+static void ps3av_fixup_monitor_info(struct ps3av_info_monitor *info)
+{
+       unsigned int i;
+       const struct ps3av_monitor_quirk *quirk;
+
+       for (i = 0; i < ARRAY_SIZE(ps3av_monitor_quirks); i++) {
+               quirk = &ps3av_monitor_quirks[i];
+               if (!strncmp(info->monitor_name, quirk->monitor_name,
+                            sizeof(info->monitor_name))) {
+                       pr_info("%s: Applying quirk for %s\n", __func__,
+                               quirk->monitor_name);
+                       info->res_60.res_bits &= ~quirk->clear_60;
+                       info->res_60.native &= ~quirk->clear_60;
+                       break;
+               }
+       }
+}
+
+static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf)
 {
        int i, res, id = 0, dvi = 0, rgb = 0;
        struct ps3av_pkt_av_get_monitor_info monitor_info;
@@ -739,6 +779,8 @@ static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
                ps3av_monitor_info_dump(&monitor_info);
 
                info = &monitor_info.info;
+               ps3av_fixup_monitor_info(info);
+
                switch (info->monitor_type) {
                case PS3AV_MONITOR_TYPE_DVI:
                        dvi = PS3AV_MODE_DVI;
@@ -758,28 +800,6 @@ static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf,
                if (ps3av->region & PS3AV_REGION_RGB)
                        rgb = PS3AV_MODE_RGB;
                pr_debug("%s: Using avmulti mode %d\n", __func__, id);
-       } else if (boot) {
-               /* HDMI: using DEFAULT HDMI_MODE_ID while booting up */
-               info = &monitor_info.info;
-               if (ps3av->region & PS3AV_REGION_60) {
-                       if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
-                               id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
-                       else if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
-                               id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
-                       else {
-                               /* default */
-                               id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
-                       }
-               } else {
-                       if (info->res_50.res_bits & PS3AV_RESBIT_720x576P)
-                               id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
-                       else if (info->res_60.res_bits & PS3AV_RESBIT_720x480P)
-                               id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_60;
-                       else {
-                               /* default */
-                               id = PS3AV_DEFAULT_HDMI_MODE_ID_REG_50;
-                       }
-               }
        }
 
        return id | dvi | rgb;
@@ -821,7 +841,7 @@ static int ps3av_get_hw_conf(struct ps3av *ps3av)
 }
 
 /* set mode using id */
-int ps3av_set_video_mode(u32 id, int boot)
+int ps3av_set_video_mode(u32 id)
 {
        int size;
        u32 option;
@@ -835,7 +855,7 @@ int ps3av_set_video_mode(u32 id, int boot)
        /* auto mode */
        option = id & ~PS3AV_MODE_MASK;
        if ((id & PS3AV_MODE_MASK) == 0) {
-               id = ps3av_auto_videomode(&ps3av->av_hw_conf, boot);
+               id = ps3av_auto_videomode(&ps3av->av_hw_conf);
                if (id < 1) {
                        printk(KERN_ERR "%s: invalid id :%d\n", __func__, id);
                        return -EINVAL;
@@ -855,34 +875,13 @@ int ps3av_set_video_mode(u32 id, int boot)
 
 EXPORT_SYMBOL_GPL(ps3av_set_video_mode);
 
-int ps3av_get_auto_mode(int boot)
+int ps3av_get_auto_mode(void)
 {
-       return ps3av_auto_videomode(&ps3av->av_hw_conf, boot);
+       return ps3av_auto_videomode(&ps3av->av_hw_conf);
 }
 
 EXPORT_SYMBOL_GPL(ps3av_get_auto_mode);
 
-int ps3av_set_mode(u32 id, int boot)
-{
-       int res;
-
-       res = ps3av_set_video_mode(id, boot);
-       if (res)
-               return res;
-
-       res = ps3av_set_audio_mode(PS3AV_CMD_AUDIO_NUM_OF_CH_2,
-                                  PS3AV_CMD_AUDIO_FS_48K,
-                                  PS3AV_CMD_AUDIO_WORD_BITS_16,
-                                  PS3AV_CMD_AUDIO_FORMAT_PCM,
-                                  PS3AV_CMD_AUDIO_SOURCE_SERIAL);
-       if (res)
-               return res;
-
-       return 0;
-}
-
-EXPORT_SYMBOL_GPL(ps3av_set_mode);
-
 int ps3av_get_mode(void)
 {
        return ps3av ? ps3av->ps3av_mode : 0;
@@ -1024,7 +1023,14 @@ static int ps3av_probe(struct ps3_system_bus_device *dev)
                       res);
 
        ps3av_get_hw_conf(ps3av);
-       id = ps3av_auto_videomode(&ps3av->av_hw_conf, 1);
+
+#ifdef CONFIG_FB
+       if (fb_mode_option && !strcmp(fb_mode_option, "safe"))
+               safe_mode = 1;
+#endif /* CONFIG_FB */
+       id = ps3av_auto_videomode(&ps3av->av_hw_conf);
+       safe_mode = 0;
+
        mutex_lock(&ps3av->mutex);
        ps3av->ps3av_mode = id;
        mutex_unlock(&ps3av->mutex);