本帖最后由 xyh12344 于 2014-8-28 10:12 编辑
FSL_TICS_Rita 发表于 2014-8-28 09:30
你好,我是回答你SR的那个人,我们的CRM系统有些问题,现在附件看不了,昨天我也给你发邮件了,你把附件 ...
好的,
static int tve_update_detect_status(void)
{
int old_detect = tve.detect;
u32 stat_lm, stat_sm, stat;
u32 int_ctl;
u32 cd_cont_reg;
u32 timeout = 40;
unsigned long lock_flags;
char event_string[16];
char *envp[] = { event_string, NULL };
#ifdef CONFIG_MACH_MX53_KSW
tve.detect = 3;
tve.output_mode = YPBPR;
return tve.detect;
#else
spin_lock_irqsave(&tve_lock, lock_flags);
if (!enabled) {
pr_warning("Warning: update tve status while it disabled!\n");
tve.detect = 0;
goto done;
}
int_ctl = __raw_readl(tve.base + tve_regs->tve_int_cont_reg);
cd_cont_reg = __raw_readl(tve.base + tve_regs->tve_cd_cont_reg);
if ((cd_cont_reg & 0x1) == 0) {
pr_warning("Warning: pls enable TVE CD first!\n");
goto done;
}
stat = __raw_readl(tve.base + tve_regs->tve_stat_reg);
while (((stat & CD_MON_END_INT) == 0) && (timeout > 0)) {
spin_unlock_irqrestore(&tve_lock, lock_flags);
msleep(2);
spin_lock_irqsave(&tve_lock, lock_flags);
timeout -= 2;
if (!enabled) {
pr_warning("Warning: update tve status while it disabled!\n");
tve.detect = 0;
goto done;
} else
stat = __raw_readl(tve.base + tve_regs->tve_stat_reg);
}
if (((stat & CD_MON_END_INT) == 0) && (timeout <= 0)) {
pr_warning("Warning: get detect result without CD_MON_END_INT!\n");
goto done;
}
stat = stat >> tve_reg_fields->cd_ch_stat_offset;
stat_lm = stat & (CD_CH_0_LM_ST | CD_CH_1_LM_ST | CD_CH_2_LM_ST);
if ((stat_lm == (CD_CH_0_LM_ST | CD_CH_1_LM_ST | CD_CH_2_LM_ST)) &&
((stat & (CD_CH_0_SM_ST | CD_CH_1_SM_ST | CD_CH_2_SM_ST)) == 0)
) {
tve.detect = 3;
tve.output_mode = YPBPR;
} else if ((stat_lm == (CD_CH_0_LM_ST | CD_CH_1_LM_ST)) &&
((stat & (CD_CH_0_SM_ST | CD_CH_1_SM_ST)) == 0)) {
tve.detect = 4;
tve.output_mode = SVIDEO;
} else if (stat_lm == CD_CH_0_LM_ST) {
stat_sm = stat & CD_CH_0_SM_ST;
if (stat_sm != 0) {
/* headset */
tve.detect = 2;
tve.output_mode = TV_OFF;
} else {
tve.detect = 1;
tve.output_mode = CVBS0;
}
} else if (stat_lm == CD_CH_2_LM_ST) {
stat_sm = stat & CD_CH_2_SM_ST;
if (stat_sm != 0) {
/* headset */
tve.detect = 2;
tve.output_mode = TV_OFF;
} else {
tve.detect = 1;
tve.output_mode = CVBS2;
}
} else {
/* none */
tve.detect = 0;
tve.output_mode = TV_OFF;
}
tve_set_tvout_mode(tve.output_mode);
/* clear interrupt */
__raw_writel(CD_MON_END_INT | CD_LM_INT | CD_SM_INT,
tve.base + tve_regs->tve_stat_reg);
__raw_writel(int_ctl | CD_SM_INT | CD_LM_INT,
tve.base + tve_regs->tve_int_cont_reg);
done:
spin_unlock_irqrestore(&tve_lock, lock_flags);
if (old_detect != tve.detect) {
sysfs_notify(&tve.pdev->dev.kobj, NULL, "headphone");
if (tve.detect == 1)
sprintf(event_string, "EVENT=CVBS0");
else if (tve.detect == 3)
sprintf(event_string, "EVENT=YPBPR");
else if (tve.detect == 4)
sprintf(event_string, "EVENT=SVIDEO");
else
sprintf(event_string, "EVENT=NONE");
kobject_uevent_env(&tve.pdev->dev.kobj, KOBJ_CHANGE, envp);
}
dev_dbg(&tve.pdev->dev, "detect = %d mode = %d\n",
tve.detect, tve.output_mode);
return tve.detect;
#endif
}
使用以上代码,TVOUT会显示黑白屏幕,
static int tve_update_detect_status(void)
{
int old_detect = tve.detect;
u32 stat_lm, stat_sm, stat;
u32 int_ctl;
u32 cd_cont_reg;
u32 timeout = 40;
unsigned long lock_flags;
char event_string[16];
char *envp[] = { event_string, NULL };
spin_lock_irqsave(&tve_lock, lock_flags);
if (!enabled) {
pr_warning("Warning: update tve status while it disabled!\n");
tve.detect = 0;
goto done;
}
int_ctl = __raw_readl(tve.base + tve_regs->tve_int_cont_reg);
cd_cont_reg = __raw_readl(tve.base + tve_regs->tve_cd_cont_reg);
if ((cd_cont_reg & 0x1) == 0) {
pr_warning("Warning: pls enable TVE CD first!\n");
goto done;
}
stat = __raw_readl(tve.base + tve_regs->tve_stat_reg);
while (((stat & CD_MON_END_INT) == 0) && (timeout > 0)) {
spin_unlock_irqrestore(&tve_lock, lock_flags);
msleep(2);
spin_lock_irqsave(&tve_lock, lock_flags);
timeout -= 2;
if (!enabled) {
pr_warning("Warning: update tve status while it disabled!\n");
tve.detect = 0;
goto done;
} else
stat = __raw_readl(tve.base + tve_regs->tve_stat_reg);
}
if (((stat & CD_MON_END_INT) == 0) && (timeout <= 0)) {
pr_warning("Warning: get detect result without CD_MON_END_INT!\n");
goto done;
}
stat = stat >> tve_reg_fields->cd_ch_stat_offset;
stat_lm = stat & (CD_CH_0_LM_ST | CD_CH_1_LM_ST | CD_CH_2_LM_ST);
if ((stat_lm == (CD_CH_0_LM_ST | CD_CH_1_LM_ST | CD_CH_2_LM_ST)) &&
((stat & (CD_CH_0_SM_ST | CD_CH_1_SM_ST | CD_CH_2_SM_ST)) == 0)
) {
tve.detect = 3;
tve.output_mode = YPBPR;
} else if ((stat_lm == (CD_CH_0_LM_ST | CD_CH_1_LM_ST)) &&
((stat & (CD_CH_0_SM_ST | CD_CH_1_SM_ST)) == 0)) {
tve.detect = 4;
tve.output_mode = SVIDEO;
} else if (stat_lm == CD_CH_0_LM_ST) {
stat_sm = stat & CD_CH_0_SM_ST;
if (stat_sm != 0) {
/* headset */
tve.detect = 2;
tve.output_mode = TV_OFF;
} else {
tve.detect = 1;
tve.output_mode = CVBS0;
}
} else if (stat_lm == CD_CH_2_LM_ST) {
stat_sm = stat & CD_CH_2_SM_ST;
if (stat_sm != 0) {
/* headset */
tve.detect = 2;
tve.output_mode = TV_OFF;
} else {
tve.detect = 1;
tve.output_mode = CVBS2;
}
} else {
/* none */
tve.detect = 0;
tve.output_mode = TV_OFF;
}
tve_set_tvout_mode(tve.output_mode);
/* clear interrupt */
__raw_writel(CD_MON_END_INT | CD_LM_INT | CD_SM_INT,
tve.base + tve_regs->tve_stat_reg);
__raw_writel(int_ctl | CD_SM_INT | CD_LM_INT,
tve.base + tve_regs->tve_int_cont_reg);
done:
spin_unlock_irqrestore(&tve_lock, lock_flags);
if (old_detect != tve.detect) {
sysfs_notify(&tve.pdev->dev.kobj, NULL, "headphone");
if (tve.detect == 1)
sprintf(event_string, "EVENT=CVBS0");
else if (tve.detect == 3)
sprintf(event_string, "EVENT=YPBPR");
else if (tve.detect == 4)
sprintf(event_string, "EVENT=SVIDEO");
else
sprintf(event_string, "EVENT=NONE");
kobject_uevent_env(&tve.pdev->dev.kobj, KOBJ_CHANGE, envp);
}
dev_dbg(&tve.pdev->dev, "detect = %d mode = %d\n",
tve.detect, tve.output_mode);
return tve.detect;
}
使用以上代码,会显示绿屏幕,green screen.
这个函数的代码,在 tve.c中。
我很困惑,,,
|