1 #include <linux/delay.h>
2 #include "cat66121_hdmi.h"
3 #include "cat66121_hdmi_hw.h"
4 #include <asm/atomic.h>
7 #include <mach/iomux.h>
9 #define HDMITX_INPUT_SIGNAL_TYPE 0 // for default(Sync Sep Mode)
10 #define INPUT_SPDIF_ENABLE 0
11 extern int CAT66121_Interrupt_Process(void);
12 /*******************************
14 ******************************/
15 static _XDATA AVI_InfoFrame AviInfo;
16 static _XDATA Audio_InfoFrame AudioInfo;
17 static unsigned long VideoPixelClock;
18 static unsigned int pixelrep;
20 /* I2C read/write funcs */
21 BYTE HDMITX_ReadI2C_Byte(BYTE RegAddr)
23 struct i2c_msg msgs[2];
29 /* Write device addr fisrt */
30 msgs[0].addr = cat66121_hdmi->client->addr;
31 msgs[0].flags = !I2C_M_RD;
33 msgs[0].buf = &buf[0];
34 msgs[0].scl_rate= 100*1000;
35 /* Then, begin to read data */
36 msgs[1].addr = cat66121_hdmi->client->addr;
37 msgs[1].flags = I2C_M_RD;
39 msgs[1].buf = &buf[0];
40 msgs[1].scl_rate= 100*1000;
42 ret = i2c_transfer(cat66121_hdmi->client->adapter, msgs, 2);
44 printk("I2C transfer Error! ret = %d\n", ret);
46 //ErrorF("Reg%02xH: 0x%02x\n", RegAddr, buf[0]);
50 SYS_STATUS HDMITX_WriteI2C_Byte(BYTE RegAddr, BYTE data)
59 msg.addr = cat66121_hdmi->client->addr;
60 msg.flags = !I2C_M_RD;
63 msg.scl_rate= 100*1000;
65 ret = i2c_transfer(cat66121_hdmi->client->adapter, &msg, 1);
67 printk("I2C transfer Error!\n");
72 SYS_STATUS HDMITX_ReadI2C_ByteN(BYTE RegAddr, BYTE *pData, int N)
74 struct i2c_msg msgs[2];
79 msgs[0].addr = cat66121_hdmi->client->addr;
80 msgs[0].flags = !I2C_M_RD;
82 msgs[0].buf = &pData[0];
83 msgs[0].scl_rate= 100*1000;
85 msgs[1].addr = cat66121_hdmi->client->addr;
86 msgs[1].flags = I2C_M_RD;
89 msgs[1].scl_rate= 100*1000;
91 ret = i2c_transfer(cat66121_hdmi->client->adapter, msgs, 2);
93 printk("I2C transfer Error! ret = %d\n", ret);
98 SYS_STATUS HDMITX_WriteI2C_ByteN(BYTE RegAddr, BYTE *pData, int N)
105 memcpy(&buf[1], pData, N);
107 msg.addr = cat66121_hdmi->client->addr;
108 msg.flags = !I2C_M_RD;
110 msg.buf = buf; // gModify.Exp."Include RegAddr"
111 msg.scl_rate= 100*1000;
113 ret = i2c_transfer(cat66121_hdmi->client->adapter, &msg, 1);
115 printk("I2C transfer Error! ret = %d\n", ret);
119 SYS_STATUS HDMITX_SetI2C_Byte(BYTE Reg,BYTE Mask,BYTE Value)
124 Temp=HDMITX_ReadI2C_Byte(Reg);
132 return HDMITX_WriteI2C_Byte(Reg,Temp);
134 int cat66121_hdmi_sys_init(void)
136 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
139 InitHDMITX_Variable();
142 return HDMI_ERROR_SUCESS;
145 void cat66121_hdmi_interrupt()
149 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
150 if(hdmi->state == HDMI_SLEEP)
151 hdmi->state = WAIT_HOTPLUG;
152 queue_delayed_work(hdmi->workqueue, &hdmi->delay_work, msecs_to_jiffies(10));
155 int cat66121_hdmi_sys_detect_hpd(void)
157 char hdmi_status = 0;
158 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
161 //sysstat = HDMITX_ReadI2C_Byte(REG_SYS_STATUS) ;
162 //*hpdstatus = ((sysstat & B_HPDETECT) == B_HPDETECT)?TRUE:FALSE ;
163 hdmi_status = HDMITX_DevLoopProc();
165 return HDMI_HPD_ACTIVED;
167 return HDMI_HPD_REMOVED;
170 int cat66121_hdmi_sys_read_edid(int block, unsigned char *buff)
172 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
173 return (getHDMITX_EDIDBlock(block, buff) == TRUE)?HDMI_ERROR_SUCESS:HDMI_ERROR_FALSE;
176 static void cat66121_sys_config_avi(int VIC, int bOutputColorMode, int aspec, int Colorimetry, int pixelrep)
178 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
179 // AVI_InfoFrame AviInfo;
183 int cat66121_hdmi_sys_config_video(struct hdmi_video_para *vpara)
185 HDMITX_ChangeDisplayOption(vpara->vic,HDMI_RGB444) ;
186 return HDMI_ERROR_SUCESS;
189 static void cat66121_hdmi_config_aai(void)
191 printk( "[%s]\n", __FUNCTION__);
194 int cat66121_hdmi_sys_config_audio(struct hdmi_audio *audio)
196 printk( "[%s]\n", __FUNCTION__);
197 return HDMI_ERROR_SUCESS;
200 void cat66121_hdmi_sys_enalbe_output(int enable)
203 printk( "[%s]\n", __FUNCTION__);
206 int cat66121_hdmi_sys_insert(void)
208 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
209 printk( "[%s]\n", __FUNCTION__);
213 int cat66121_hdmi_sys_remove(void)
215 hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
216 // printk( "[%s]\n", __FUNCTION__);