cec: Add poll function for app chk new msg [1/1]

PD#SWPL-14177

Problem:
Add feature, for support poll function for check
cec new msg.

Solution:
Add feature, add poll api

Verify:
tl1

Change-Id: I1582438aa945201753fe04732a78f8f8d499dfca
Signed-off-by: Yong Qin <yong.qin@amlogic.com>
This commit is contained in:
Yong Qin
2019-09-17 15:25:56 +08:00
committed by Luke Go
parent 5f76278b11
commit bb1fca4a7f
2 changed files with 37 additions and 6 deletions

View File

@@ -51,6 +51,7 @@
#include <linux/pm_wakeup.h>
#include <linux/pm_wakeirq.h>
#include <linux/pm.h>
#include <linux/poll.h>
#include <linux/amlogic/media/frame_provider/tvin/tvin.h>
#include <linux/amlogic/media/vout/hdmi_tx/hdmi_tx_cec_20.h>
#include <linux/amlogic/media/vout/hdmi_tx/hdmi_tx_module.h>
@@ -68,6 +69,8 @@
#define HR_DELAY(n) (ktime_set(0, n * 1000 * 1000))
#define MAX_INT 0x7ffffff
DECLARE_WAIT_QUEUE_HEAD(cec_msg_wait_queue);
#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND
static struct early_suspend aocec_suspend_handler;
#endif
@@ -599,8 +602,9 @@ void cecb_irq_handle(void)
if ((intr_cec & CEC_IRQ_RX_EOM) || lock) {
cecb_pick_msg(rx_msg, &rx_len);
CEC_INFO_L(L_2, "irqflg:RX_EOM\n");
complete(&cec_dev->rx_ok);
new_msg = 1;
/*complete(&cec_dev->rx_ok);*/
/*new_msg = 1;*/
cec_new_msg_push();
dwork = &cec_dev->cec_work;
mod_delayed_work(cec_dev->cec_thread, dwork, 0);
}
@@ -2321,9 +2325,9 @@ static void ceca_tasklet_pro(unsigned long arg)
if ((-1) == ceca_rx_irq_handle(rx_msg, &rx_len))
return;
complete(&cec_dev->rx_ok);
/* check rx buffer is full */
new_msg = 1;
/*complete(&cec_dev->rx_ok);*/
/*new_msg = 1;*/
cec_new_msg_push();
mod_delayed_work(cec_dev->cec_thread, dwork, 0);
}
}
@@ -2935,6 +2939,7 @@ static ssize_t hdmitx_cec_read(struct file *f, char __user *buf,
return 0;
}
new_msg = 0;
/*CEC_ERR("read msg end\n");*/
if (copy_to_user(buf, rx_msg, rx_len))
return -EINVAL;
@@ -3364,6 +3369,30 @@ static long hdmitx_cec_compat_ioctl(struct file *f,
}
#endif
/*
* For android framework check new message
*/
static unsigned int cec_poll(struct file *filp, poll_table *wait)
{
unsigned int mask = 0;
poll_wait(filp, &cec_msg_wait_queue, wait);
if (new_msg)
mask |= POLLIN | POLLRDNORM;
return mask;
}
/*
* cec new message wait queue - wake up poll process
*/
void cec_new_msg_push(void)
{
complete(&cec_dev->rx_ok);
new_msg = 1;
wake_up(&cec_msg_wait_queue);
}
/* for improve rw permission */
static char *aml_cec_class_devnode(struct device *dev, umode_t *mode)
{
@@ -3389,6 +3418,7 @@ static const struct file_operations hdmitx_cec_fops = {
.write = hdmitx_cec_write,
.release = hdmitx_cec_release,
.unlocked_ioctl = hdmitx_cec_ioctl,
.poll = cec_poll,
#ifdef CONFIG_COMPAT
.compat_ioctl = hdmitx_cec_compat_ioctl,
#endif

View File

@@ -18,7 +18,7 @@
#ifndef __AO_CEC_H__
#define __AO_CEC_H__
#define CEC_DRIVER_VERSION "2019/11/13: avoid kmalloc fail, and system crash\n"
#define CEC_DRIVER_VERSION "2019/11/15:add poll for andorid chk new msg\n"
#define CEC_FRAME_DELAY msecs_to_jiffies(400)
#define CEC_DEV_NAME "cec"
@@ -580,5 +580,6 @@ extern void cec_logicaddr_add(unsigned int cec_sel, unsigned int l_add);
extern void cec_clear_all_logical_addr(unsigned int cec_sel);
extern int dump_cecrx_reg(char *b);
extern void cec_ip_share_io(u32 share, u32 cec_ip);
void cec_new_msg_push(void);
#endif /* __AO_CEC_H__ */