From c8d1e99810581d7737e84434f2522fb270d84253 Mon Sep 17 00:00:00 2001 From: Evoke Zhang Date: Thu, 20 Jun 2019 21:47:48 +0800 Subject: [PATCH] vout: add poll support for ioctl [1/4] PD#SWPL-8450 Problem: need poll method for vout ioctl Solution: add poll support for vout ioctl Verify: x301 Change-Id: I9312e8ce9708d700f26d79ac5eadf762fac9bf62 Signed-off-by: Evoke Zhang --- .../amlogic/media/vout/vout_serve/vout2_serve.c | 23 +++++++++++++++++++ drivers/amlogic/media/vout/vout_serve/vout_func.h | 1 + drivers/amlogic/media/vout/vout_serve/vout_serve.c | 26 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/drivers/amlogic/media/vout/vout_serve/vout2_serve.c b/drivers/amlogic/media/vout/vout_serve/vout2_serve.c index df9c2cd..05bc9f2 100644 --- a/drivers/amlogic/media/vout/vout_serve/vout2_serve.c +++ b/drivers/amlogic/media/vout/vout_serve/vout2_serve.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include @@ -206,6 +208,12 @@ char *get_vout2_mode_internal(void) } EXPORT_SYMBOL(get_vout2_mode_internal); +static inline void vout2_setmode_wakeup_queue(void) +{ + if (vout2_cdev) + wake_up(&vout2_cdev->setmode_queue); +} + static int set_vout2_mode(char *name) { enum vmode_e mode; @@ -240,6 +248,7 @@ static int set_vout2_mode(char *name) vout2_notifier_call_chain(VOUT_EVENT_MODE_CHANGE, &mode); extcon_set_state_sync(vout2_excton_setmode, EXTCON_TYPE_DISP, 0); + vout2_setmode_wakeup_queue(); return ret; } @@ -670,6 +679,17 @@ static long vout2_compat_ioctl(struct file *file, unsigned int cmd, } #endif +static unsigned int vout2_poll(struct file *file, poll_table *wait) +{ + struct vout_cdev_s *vcdev = file->private_data; + unsigned int mask = 0; + + poll_wait(file, &vcdev->setmode_queue, wait); + mask = (POLLIN | POLLRDNORM); + + return mask; +} + static const struct file_operations vout2_fops = { .owner = THIS_MODULE, .open = vout2_io_open, @@ -678,6 +698,7 @@ static const struct file_operations vout2_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = vout2_compat_ioctl, #endif + .poll = vout2_poll, }; static int vout2_fops_create(void) @@ -712,6 +733,8 @@ static int vout2_fops_create(void) goto vout2_fops_err3; } + init_waitqueue_head(&vout2_cdev->setmode_queue); + VOUTPR("vout2: %s OK\n", __func__); return 0; diff --git a/drivers/amlogic/media/vout/vout_serve/vout_func.h b/drivers/amlogic/media/vout/vout_serve/vout_func.h index cadda32..f22e05e 100644 --- a/drivers/amlogic/media/vout/vout_serve/vout_func.h +++ b/drivers/amlogic/media/vout/vout_serve/vout_func.h @@ -41,6 +41,7 @@ struct vout_cdev_s { dev_t devno; struct cdev cdev; struct device *dev; + wait_queue_head_t setmode_queue; }; #ifdef CONFIG_AMLOGIC_HDMITX diff --git a/drivers/amlogic/media/vout/vout_serve/vout_serve.c b/drivers/amlogic/media/vout/vout_serve/vout_serve.c index 107ea40..31b33c5 100644 --- a/drivers/amlogic/media/vout/vout_serve/vout_serve.c +++ b/drivers/amlogic/media/vout/vout_serve/vout_serve.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include /* Amlogic Headers */ #include @@ -223,6 +225,15 @@ char *get_vout_mode_uboot(void) } EXPORT_SYMBOL(get_vout_mode_uboot); +static inline void vout_setmode_wakeup_queue(void) +{ + if (tvout_monitor_flag) + return; + + if (vout_cdev) + wake_up(&vout_cdev->setmode_queue); +} + int set_vout_mode(char *name) { enum vmode_e mode; @@ -257,6 +268,7 @@ int set_vout_mode(char *name) vout_notifier_call_chain(VOUT_EVENT_MODE_CHANGE, &mode); extcon_set_state_sync(vout_excton_setmode, EXTCON_TYPE_DISP, 0); + vout_setmode_wakeup_queue(); return ret; } @@ -681,6 +693,17 @@ static long vout_compat_ioctl(struct file *file, unsigned int cmd, } #endif +static unsigned int vout_poll(struct file *file, poll_table *wait) +{ + struct vout_cdev_s *vcdev = file->private_data; + unsigned int mask = 0; + + poll_wait(file, &vcdev->setmode_queue, wait); + mask = (POLLIN | POLLRDNORM); + + return mask; +} + static const struct file_operations vout_fops = { .owner = THIS_MODULE, .open = vout_io_open, @@ -689,6 +712,7 @@ static const struct file_operations vout_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = vout_compat_ioctl, #endif + .poll = vout_poll, }; static int vout_fops_create(void) @@ -723,6 +747,8 @@ static int vout_fops_create(void) goto vout_fops_err3; } + init_waitqueue_head(&vout_cdev->setmode_queue); + VOUTPR("%s OK\n", __func__); return 0; -- 2.7.4