From 3b403975b552b8e98a0a057433dcd4cdcb0ef3aa Mon Sep 17 00:00:00 2001 From: kfx Date: Fri, 6 May 2011 09:23:14 +0800 Subject: [PATCH] update hdmi driver --- drivers/video/hdmi/hdmi-new/chips/anx7150.c | 41 ++++++++++--------- .../video/hdmi/hdmi-new/chips/anx7150_hw.c | 4 +- .../video/hdmi/hdmi-new/chips/anx7150_hw.h | 1 + drivers/video/hdmi/hdmi-new/hdmi-codec.c | 5 +++ drivers/video/hdmi/hdmi-new/hdmi-core.c | 9 ++++ drivers/video/hdmi/hdmi-new/hdmi-fb.c | 4 +- drivers/video/hdmi/hdmi-new/hdmi-sysfs.c | 16 ++++---- .../video/hdmi/hdmi-old/chips/anx7150_hw.c | 2 +- include/linux/hdmi-new.h | 5 +++ sound/soc/codecs/wm8900.c | 21 +++++++++- 10 files changed, 75 insertions(+), 33 deletions(-) mode change 100644 => 100755 drivers/video/hdmi/hdmi-new/hdmi-codec.c diff --git a/drivers/video/hdmi/hdmi-new/chips/anx7150.c b/drivers/video/hdmi/hdmi-new/chips/anx7150.c index 1032398f8567..f977d7f41974 100755 --- a/drivers/video/hdmi/hdmi-new/chips/anx7150.c +++ b/drivers/video/hdmi/hdmi-new/chips/anx7150.c @@ -37,7 +37,8 @@ int anx7150_i2c_write_p1_reg(struct i2c_client *client, char reg, char *val) static int anx7150_param_chg(struct anx7150_pdata *anx) { int resolution_real; - + + hdmi_set_spk(anx->hdmi->display_on); hdmi_switch_fb(anx->hdmi, anx->hdmi->display_on); resolution_real = ANX7150_Get_Optimal_resolution(anx->hdmi->resolution); HDMI_Set_Video_Format(resolution_real); @@ -60,23 +61,22 @@ static int anx7150_insert(struct hdmi *hdmi) struct anx7150_pdata *anx = hdmi_priv(hdmi); anx7150_plug(anx->client); - if(anx->is_changed) { - if(ANX7150_Parse_EDID(anx->client,&anx->dev) < 0) - { - dev_info(&anx->client->dev, "parse EDID error\n"); - anx7150_unplug(anx->client); - return -1; - } - while(--tmo && ANX7150_GET_SENSE_STATE(anx->client) != 1) - mdelay(10); - if(tmo <= 0) - { - anx7150_unplug(anx->client); - return -1; - } - anx->is_changed = 0; + if(ANX7150_Parse_EDID(anx->client,&anx->dev) < 0) + { + dev_info(&anx->client->dev, "parse EDID error\n"); + anx7150_unplug(anx->client); + return -1; } - + + while(--tmo && ANX7150_GET_SENSE_STATE(anx->client) != 1) + mdelay(10); + if(tmo <= 0) + { + anx7150_unplug(anx->client); + return -1; + } + if(!hdmi->display_on) + return 0; anx7150_param_chg(anx); return 0; } @@ -85,6 +85,7 @@ static int anx7150_remove(struct hdmi *hdmi) struct anx7150_pdata *anx = hdmi_priv(hdmi); anx7150_unplug(anx->client); + hdmi_set_spk(HDMI_DISABLE); hdmi_switch_fb(hdmi, HDMI_DISABLE); return 0; @@ -166,7 +167,8 @@ static void anx7150_early_suspend(struct early_suspend *h) dev_info(&anx->client->dev, "anx7150 enter early suspend\n"); anx->is_early_suspend = 1; flush_delayed_work(&anx->work); - hdmi_suspend(anx->hdmi); + if(anx->hdmi->display_on) + hdmi_suspend(anx->hdmi); return; } @@ -179,7 +181,8 @@ static void anx7150_early_resume(struct early_suspend *h) early_suspend); dev_info(&anx->client->dev, "anx7150 exit early suspend\n"); anx->is_early_suspend = 0; - ret = hdmi_resume(anx->hdmi); + if(anx->hdmi->display_on) + ret = hdmi_resume(anx->hdmi); return; } diff --git a/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.c b/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.c index c8be59e6162a..0b0a79371e38 100755 --- a/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.c +++ b/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.c @@ -461,7 +461,7 @@ static int anx7150_hardware_initial(struct i2c_client *client) rc = anx7150_i2c_write_p0_reg(client, ANX7150_SYS_CTRL1_REG, &c);//power down HDCP, 090630 rc = anx7150_i2c_read_p0_reg(client, ANX7150_SYS_CTRL3_REG, &c);//jack wen, for spdif input from SD0. - c &= (0xef); + c &= (0xfe); rc = anx7150_i2c_write_p0_reg(client, ANX7150_SYS_CTRL3_REG, &c);//power down all, 090630 return rc; @@ -598,7 +598,7 @@ int anx7150_plug(struct i2c_client *client) return rc; } -static int anx7150_set_avmute(struct i2c_client *client) +int anx7150_set_avmute(struct i2c_client *client) { int rc = 0; char c; diff --git a/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.h b/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.h index 63fb5a5b181c..baf289e389f3 100755 --- a/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.h +++ b/drivers/video/hdmi/hdmi-new/chips/anx7150_hw.h @@ -1262,6 +1262,7 @@ void HDMI_Set_Video_Format(u8 video_format); void HDMI_Set_Audio_Fs( u8 audio_fs); int ANX7150_PLAYBACK_Process(void); int ANX7150_Blue_Screen(struct anx7150_pdata *anx); +int anx7150_set_avmute(struct i2c_client *client); #endif diff --git a/drivers/video/hdmi/hdmi-new/hdmi-codec.c b/drivers/video/hdmi/hdmi-new/hdmi-codec.c old mode 100644 new mode 100755 index e10c31240057..fe0adfd66fed --- a/drivers/video/hdmi/hdmi-new/hdmi-codec.c +++ b/drivers/video/hdmi/hdmi-new/hdmi-codec.c @@ -1,6 +1,11 @@ #include +extern void wm8990_set_spk(bool on); int hdmi_codec_set_audio_fs(unsigned char audio_fs) { return 0; } +void hdmi_set_spk(int on) +{ + wm8990_set_spk(!on); +} \ No newline at end of file diff --git a/drivers/video/hdmi/hdmi-new/hdmi-core.c b/drivers/video/hdmi/hdmi-new/hdmi-core.c index 3a7f04f9a6c6..f5d64984d519 100755 --- a/drivers/video/hdmi/hdmi-new/hdmi-core.c +++ b/drivers/video/hdmi/hdmi-new/hdmi-core.c @@ -133,6 +133,15 @@ struct hdmi *get_hdmi_struct(int nr) else return ref_info[nr].hdmi; } +int hdmi_is_insert(void) +{ + struct hdmi *hdmi = get_hdmi_struct(0); + + if(hdmi && hdmi->ops && hdmi->ops->hdmi_precent) + return hdmi->ops->hdmi_precent(hdmi); + else + return 0; +} static int __init hdmi_class_init(void) { int i; diff --git a/drivers/video/hdmi/hdmi-new/hdmi-fb.c b/drivers/video/hdmi/hdmi-new/hdmi-fb.c index 057d413f3a88..6673def1ba98 100755 --- a/drivers/video/hdmi/hdmi-new/hdmi-fb.c +++ b/drivers/video/hdmi/hdmi-new/hdmi-fb.c @@ -257,8 +257,8 @@ int hdmi_switch_fb(struct hdmi *hdmi, int type) int hdmi_resolution_changed(struct hdmi *hdmi, int xres, int yres, int video_on) { int ret = 0; - if(hdmi->display_on == 0|| hdmi->plug == 0) - return ret; + if(!hdmi->display_on || !hdmi->ops->hdmi_precent(hdmi) || !hdmi->auto_switch) + return 0; if(xres > 1280 && hdmi->resolution != HDMI_1920x1080p_50Hz) { hdmi->resolution = HDMI_1920x1080p_50Hz; diff --git a/drivers/video/hdmi/hdmi-new/hdmi-sysfs.c b/drivers/video/hdmi/hdmi-new/hdmi-sysfs.c index c3dc2afa0eb5..6a8523dae905 100755 --- a/drivers/video/hdmi/hdmi-new/hdmi-sysfs.c +++ b/drivers/video/hdmi/hdmi-new/hdmi-sysfs.c @@ -10,20 +10,20 @@ static ssize_t hdmi_show_state_attrs(struct device *dev, struct hdmi *hdmi = dev_get_drvdata(dev); return sprintf(buf, "display_on=%d\n" - //"plug=%d\n" + "plug=%d\n" + "auto_switch=%d\n" + "hdcp_on=%d\n" + "audio_fs=%d\n" + "resolution=%d\n" "--------------------------\n" "resolution support:\n" "0 -- 1280x720p_50Hz\n" "1 -- 1280x720p_60Hz\n" "2 -- 720x576p_50Hz\n" "3 -- 1920x1080p_50Hz\n" - "--------------------------\n" - //"auto_switch=%d\n" - "hdcp_on=%d\n" - "audio_fs=%d\n" - "resolution=%d\n", - hdmi->display_on,/*hdmi->plug,*/ - /*hdmi->auto_switch,*/ hdmi->hdcp_on, + "--------------------------\n", + hdmi->display_on,hdmi->ops->hdmi_precent(hdmi), + hdmi->auto_switch, hdmi->hdcp_on, hdmi->audio_fs, hdmi->resolution); } static ssize_t hdmi_restore_state_attrs(struct device *dev, diff --git a/drivers/video/hdmi/hdmi-old/chips/anx7150_hw.c b/drivers/video/hdmi/hdmi-old/chips/anx7150_hw.c index 811e607a8f41..8c3e49e3b59f 100755 --- a/drivers/video/hdmi/hdmi-old/chips/anx7150_hw.c +++ b/drivers/video/hdmi/hdmi-old/chips/anx7150_hw.c @@ -461,7 +461,7 @@ static int anx7150_hardware_initial(struct i2c_client *client) rc = anx7150_i2c_write_p0_reg(client, ANX7150_SYS_CTRL1_REG, &c);//power down HDCP, 090630 rc = anx7150_i2c_read_p0_reg(client, ANX7150_SYS_CTRL3_REG, &c);//jack wen, for spdif input from SD0. - c &= (0xef); + c &= (0xfe); rc = anx7150_i2c_write_p0_reg(client, ANX7150_SYS_CTRL3_REG, &c);//power down all, 090630 return rc; diff --git a/include/linux/hdmi-new.h b/include/linux/hdmi-new.h index 78790ee53af7..9c6a534fb90b 100755 --- a/include/linux/hdmi-new.h +++ b/include/linux/hdmi-new.h @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef CONFIG_HDMI_DEBUG @@ -67,6 +68,8 @@ struct hdmi { u8 resolution; u8 audio_fs; + int hdmi_stay_awake; + struct device *dev; struct delayed_work changed_work; struct completion complete; @@ -74,6 +77,7 @@ struct hdmi { unsigned long priv[0] ____cacheline_aligned; }; +extern int hdmi_is_insert(void); extern void *hdmi_priv(struct hdmi *hdmi); extern struct hdmi *hdmi_register(int extra, struct device *parent); extern void hdmi_unregister(struct hdmi *hdmi); @@ -90,5 +94,6 @@ extern int hdmi_resolution_changed(struct hdmi *hdmi, int xres, int yres, int vi extern struct hdmi *get_hdmi_struct(int nr); extern int hdmi_get_default_resolution(void *screen); +extern void hdmi_set_spk(int on); #endif diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index fab1029649ae..d723a2e9179d 100755 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -160,6 +160,7 @@ static int wm8900_current_status = WM8900_IS_SHUTDOWN; struct snd_soc_codec_device soc_codec_dev_wm8900; static struct snd_soc_codec *wm8900_codec; +static bool isSPKon = true; struct wm8900_priv { struct snd_soc_codec codec; @@ -227,6 +228,22 @@ static void wm8900_reset(struct snd_soc_codec *codec) sizeof(codec->reg_cache)); } +void wm8990_set_spk(bool on) +{ + isSPKon = on; + if (on) { +#ifdef SPK_CON + gpio_set_value(SPK_CON, GPIO_HIGH); +#endif + } else { +#ifdef SPK_CON + gpio_set_value(SPK_CON, GPIO_LOW); +#endif + } +} + +EXPORT_SYMBOL_GPL(wm8990_set_spk); + static void wm8900_powerdown(void) { printk("Power down wm8900\n"); @@ -310,7 +327,9 @@ static void wm8900_set_hw(struct snd_soc_codec *codec) msleep(20); #ifdef SPK_CON - gpio_set_value(SPK_CON, GPIO_HIGH); + if (isSPKon) { + gpio_set_value(SPK_CON, GPIO_HIGH); + } #endif wm8900_current_status |= WM8900_IS_STARTUP; -- 2.34.1