update hdmi: modify hdmi init and add HDMI_SAVE_DATA config
authoryzq <yzq@rock-chips.com>
Mon, 5 Dec 2011 08:42:45 +0000 (16:42 +0800)
committeryzq <yzq@rock-chips.com>
Mon, 5 Dec 2011 08:42:45 +0000 (16:42 +0800)
drivers/rtc/rtc-HYM8563.c
drivers/video/hdmi/Kconfig
drivers/video/hdmi/chips/anx7150.c
drivers/video/hdmi/hdmi-core.c
drivers/video/hdmi/hdmi-sysfs.c
include/linux/hdmi.h

index ab18d469ddd8300e7815b058281271f2474a89de..2c292af643dcadf2de49d1ecc35bd3a6a44da450 100755 (executable)
@@ -38,7 +38,7 @@ struct hym8563 {
        struct rtc_wkalrm alarm;
        struct wake_lock wake_lock;
 };
-
+static struct i2c_client *gClient = NULL;
 static int hym8563_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], unsigned len)
 {
        int ret; 
@@ -275,7 +275,40 @@ static int hym8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
        mutex_unlock(&hym8563->mutex);
        return 0;
 }
+#ifdef CONFIG_HDMI_SAVE_DATA
+int hdmi_get_data(void)
+{
+    u8 regs=0;
+    if(gClient)
+        hym8563_i2c_read_regs(gClient, RTC_T_COUNT, &regs, 1);
+    else 
+    {
+        printk("%s rtc has no init\n",__func__);
+        return -1;
+    }
+    if(regs==0 || regs==0xff){
+        printk("%s rtc has no hdmi data\n",__func__);
+        return -1;
+    }
+    return (regs-1);
+}
+
+int hdmi_set_data(int data)
+{
+    u8 regs = (data+1)&0xff;
+    if(gClient)
+        hym8563_i2c_set_regs(gClient, RTC_T_COUNT, &regs, 1);
+    else 
+    {
+        printk("%s rtc has no init\n",__func__);
+        return -1;
+    }   
+    return 0;
+}
 
+EXPORT_SYMBOL(hdmi_get_data);
+EXPORT_SYMBOL(hdmi_set_data);
+#endif
 #if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
 static int hym8563_i2c_open_alarm(struct i2c_client *client)
 {
@@ -400,7 +433,7 @@ static int __devinit hym8563_probe(struct i2c_client *client, const struct i2c_d
        if (!hym8563) {
                return -ENOMEM;
        }
-               
+       gClient = client;       
        hym8563->client = client;
        mutex_init(&hym8563->mutex);
        wake_lock_init(&hym8563->wake_lock, WAKE_LOCK_SUSPEND, "rtc_hym8563");
index 2b01022ee40e09c5e9e07e779762c4f5ceb317df..2d68da6d7f92c7ea8f8015261a80f21c8d56ad5d 100755 (executable)
@@ -9,6 +9,12 @@ config HDMI
 if HDMI
 source "drivers/video/hdmi/chips/Kconfig"
 
+
+config HDMI_SAVE_DATA
+       bool "enable hdmi save data"    
+       help 
+               Enable hdmi save data in rtc register
+
 #config HDMI_DUAL_DISP
 #      bool "hdmi support dual display"
 #      help
index e1a479b1fe20a0ff0078e68e775e7703251799e2..8a6239cf1c1984183231de425babb9cd3f3e9cfd 100755 (executable)
@@ -116,15 +116,35 @@ static int anx7150_set_param(struct hdmi *hdmi)
        anx7150_param_chg(anx);\r
        return 0;\r
 }\r
+\r
 static int anx7150_init(struct hdmi *hdmi)\r
 {\r
        struct anx7150_pdata *anx = hdmi_priv(hdmi);\r
-\r
+#ifdef CONFIG_HDMI_SAVE_DATA\r
+    int hdmi_data = hdmi_get_data();\r
+    if(hdmi_data<0){\r
+    hdmi_set_data((hdmi->resolution&0x7)|((hdmi->scale&0x1f)<<3));\r
+    }\r
+    else{\r
+    hdmi->resolution = hdmi_data&0x7;\r
+    hdmi->scale_set= ((hdmi_data>>3)&0x1f) + MIN_SCALE;\r
+    hdmi->scale = hdmi->scale_set;\r
+    }\r
+#endif\r
        anx->init = 0;\r
-       hdmi_changed(hdmi, 1);\r
+       hdmi_changed(hdmi,1);\r
 \r
        return 0;\r
 }\r
+static void anx7150_init_work_func(struct work_struct *work)\r
+{\r
+    struct anx7150_pdata *anx = container_of(work, struct anx7150_pdata, work.work);\r
+\r
+    if(anx!=NULL)\r
+        anx7150_init(anx->hdmi);\r
+    else\r
+        printk("anx7150_init_work_func  err\n");\r
+}\r
 static struct hdmi_ops anx7150_ops = {\r
        .set_param = anx7150_set_param,\r
        .hdmi_precent = anx7150_precent,\r
@@ -172,7 +192,7 @@ static int anx7150_i2c_probe(struct i2c_client *client,const struct i2c_device_i
         return -ENOMEM;\r
     }\r
        hdmi->ops = &anx7150_ops;\r
-       hdmi->display_on = HDMI_DISABLE;\r
+       hdmi->display_on = HDMI_DEFAULT_MODE;\r
        hdmi->hdcp_on = HDMI_DISABLE;\r
        hdmi->audio_fs = HDMI_I2S_DEFAULT_Fs;\r
        hdmi->resolution = HDMI_DEFAULT_RESOLUTION;\r
@@ -209,6 +229,8 @@ static int anx7150_i2c_probe(struct i2c_client *client,const struct i2c_device_i
        register_early_suspend(&anx->early_suspend);\r
 #endif\r
        anx7150_unplug(anx->client);\r
+       INIT_DELAYED_WORK(&anx->work,anx7150_init_work_func);\r
+       schedule_delayed_work(&anx->work, msecs_to_jiffies(2000));\r
     dev_info(&client->dev, "anx7150 i2c probe ok\n");\r
     return 0;\r
 err_gpio_free:\r
index 3d9b6ab0f36ad4632efac06ca641e8bba2905f66..6e16767e35adec3d6dda91b3ff863b80e15a20ca 100755 (executable)
@@ -189,8 +189,10 @@ int hdmi_get_scale(void)
        struct hdmi* hdmi = get_hdmi_struct(0);\r
        if(!hdmi)\r
                return 100;\r
-       else\r
+       else if(hdmi->mode == DISP_ON_HDMI)\r
                return hdmi->scale;\r
+       else\r
+           return 100;\r
 }\r
 \r
 int hdmi_set_scale(int event, char *data, int len)\r
index afe20d9da28e45b4d0efd55bc5c4fe53a0264920..9a7b44fe5fd816ab063029b0a70b61b6446e11dc 100755 (executable)
@@ -3,6 +3,18 @@
 #include <linux/string.h>\r
 \r
 int debug_en = 0;\r
+\r
+#ifndef CONFIG_HDMI_SAVE_DATA\r
+int hdmi_get_data(void)\r
+{\r
+return 0;\r
+}\r
+int hdmi_set_data(int data)\r
+{\r
+return 0;\r
+}\r
+#endif\r
+\r
 static ssize_t hdmi_show_state_attrs(struct device *dev,\r
                                              struct device_attribute *attr,\r
                                              char *buf) \r
@@ -45,7 +57,9 @@ static ssize_t hdmi_restore_state_attrs(struct device *dev,
        char *p;\r
        const char *q;\r
        int set_param = 0, tmp = 0;\r
-\r
+       #ifdef CONFIG_HDMI_SAVE_DATA\r
+    int hdmi_data=0;\r
+    #endif\r
        if(hdmi->mode == DISP_ON_LCD)\r
        {\r
                dev_err(dev, "display on lcd, do not set parameter!\n");\r
@@ -107,6 +121,13 @@ static ssize_t hdmi_restore_state_attrs(struct device *dev,
                                hdmi->scale_set = tmp;\r
                                hdmi_dbg(dev, "set scale = %d\n", tmp);\r
                                hdmi->scale = tmp;\r
+                               #ifdef CONFIG_HDMI_SAVE_DATA\r
+                               hdmi_data = hdmi_get_data();\r
+                               if(hdmi_data<0)\r
+                                   hdmi->ops->init(hdmi);\r
+                               hdmi_data = (((hdmi->scale-MIN_SCALE)&0x1f)<<3) | (hdmi_data & 0x7);\r
+                               hdmi_set_data(hdmi_data);\r
+                               #endif\r
                        }\r
                        else\r
                        {\r
@@ -125,6 +146,13 @@ static ssize_t hdmi_restore_state_attrs(struct device *dev,
                                        set_param |= 1;\r
                                        hdmi_dbg(dev, "set resolution = %d\n", tmp);\r
                                        hdmi->resolution = tmp;\r
+                                       #ifdef CONFIG_HDMI_SAVE_DATA\r
+                                       hdmi_data = hdmi_get_data();\r
+                                       if(hdmi_data<0)\r
+                                       hdmi->ops->init(hdmi);\r
+                                       hdmi_data = (hdmi->resolution&0x7) | (hdmi_data & 0xf8);\r
+                                       hdmi_set_data(hdmi_data);\r
+                                       #endif\r
                                }\r
                        }\r
                        else\r
@@ -194,6 +222,7 @@ static ssize_t hdmi_restore_debug_attrs(struct device *dev,
                debug_en = tmp;\r
        return size;\r
 }\r
+#if 0\r
 static ssize_t hdmi_restore_init_attrs(struct device *dev, \r
                                                struct device_attribute *attr,\r
                                                const char *buf, size_t size)\r
@@ -217,13 +246,13 @@ static ssize_t hdmi_restore_init_attrs(struct device *dev,
                hdmi->ops->init(hdmi);\r
        return size;\r
 }\r
+#endif\r
 static struct device_attribute hdmi_attrs[] = {\r
        __ATTR(state, 0777, hdmi_show_state_attrs, hdmi_restore_state_attrs),\r
        __ATTR(enable, 0777, hdmi_show_switch_attrs, hdmi_restore_switch_attrs),\r
        __ATTR(debug, 0777, hdmi_show_debug_attrs, hdmi_restore_debug_attrs),\r
-       __ATTR(init, 0777, NULL, hdmi_restore_init_attrs),\r
+       //__ATTR(init, 0777, NULL, hdmi_restore_init_attrs),\r
 };\r
-\r
 int hdmi_create_attrs(struct hdmi *hdmi)\r
 {\r
        int rc = 0;\r
index b10f7f8fceea4be00907b11e264c0dc275cb54d4..551d2694f0faad77b382a7bb98d66f4f30b01027 100755 (executable)
@@ -119,4 +119,6 @@ extern int hdmi_get_scale(void);
 extern int hdmi_set_scale(int event, char *data, int len);\r
 extern int fb_get_video_mode(void);\r
 extern int display_on_hdmi(void);\r
+extern int hdmi_get_data(void);\r
+extern int hdmi_set_data(int data);\r
 #endif\r