diff options
author | Shuah Khan <shuahkh@osg.samsung.com> | 2016-02-11 18:41:29 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-02-27 06:46:55 -0500 |
commit | 77fa4e072998705883c4dc672963b4bf7483cea9 (patch) | |
tree | 6b5d93eda723017ebb2bd3129ff4d2da86ffb990 /drivers/media/v4l2-core/v4l2-ioctl.c | |
parent | 50512333f2d7f09fc108e062278a82d2cbc6581c (diff) |
[media] media: Change v4l-core to check if source is free
Change s_input, s_fmt, s_tuner, s_frequency, querystd, s_hw_freq_seek,
and vb2_core_streamon interfaces that alter the tuner configuration to
check if it is free, by calling v4l_enable_media_source().
If source isn't free, return -EBUSY.
v4l_disable_media_source() is called from v4l2_fh_exit() to release
tuner (source).
vb2_core_streamon() uses v4l_vb2q_enable_media_source().
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-ioctl.c')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 14843090fd61..86c4c19b5d7b 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <media/v4l2-event.h> | 27 | #include <media/v4l2-event.h> |
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/videobuf2-v4l2.h> | 29 | #include <media/videobuf2-v4l2.h> |
30 | #include <media/v4l2-mc.h> | ||
30 | 31 | ||
31 | #include <trace/events/v4l2.h> | 32 | #include <trace/events/v4l2.h> |
32 | 33 | ||
@@ -1041,6 +1042,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, | |||
1041 | static int v4l_s_input(const struct v4l2_ioctl_ops *ops, | 1042 | static int v4l_s_input(const struct v4l2_ioctl_ops *ops, |
1042 | struct file *file, void *fh, void *arg) | 1043 | struct file *file, void *fh, void *arg) |
1043 | { | 1044 | { |
1045 | struct video_device *vfd = video_devdata(file); | ||
1046 | int ret; | ||
1047 | |||
1048 | ret = v4l_enable_media_source(vfd); | ||
1049 | if (ret) | ||
1050 | return ret; | ||
1044 | return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); | 1051 | return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); |
1045 | } | 1052 | } |
1046 | 1053 | ||
@@ -1452,6 +1459,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, | |||
1452 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; | 1459 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; |
1453 | int ret; | 1460 | int ret; |
1454 | 1461 | ||
1462 | ret = v4l_enable_media_source(vfd); | ||
1463 | if (ret) | ||
1464 | return ret; | ||
1455 | v4l_sanitize_format(p); | 1465 | v4l_sanitize_format(p); |
1456 | 1466 | ||
1457 | switch (p->type) { | 1467 | switch (p->type) { |
@@ -1641,7 +1651,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, | |||
1641 | { | 1651 | { |
1642 | struct video_device *vfd = video_devdata(file); | 1652 | struct video_device *vfd = video_devdata(file); |
1643 | struct v4l2_tuner *p = arg; | 1653 | struct v4l2_tuner *p = arg; |
1654 | int ret; | ||
1644 | 1655 | ||
1656 | ret = v4l_enable_media_source(vfd); | ||
1657 | if (ret) | ||
1658 | return ret; | ||
1645 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1659 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
1646 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1660 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1647 | return ops->vidioc_s_tuner(file, fh, p); | 1661 | return ops->vidioc_s_tuner(file, fh, p); |
@@ -1695,7 +1709,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops, | |||
1695 | struct video_device *vfd = video_devdata(file); | 1709 | struct video_device *vfd = video_devdata(file); |
1696 | const struct v4l2_frequency *p = arg; | 1710 | const struct v4l2_frequency *p = arg; |
1697 | enum v4l2_tuner_type type; | 1711 | enum v4l2_tuner_type type; |
1712 | int ret; | ||
1698 | 1713 | ||
1714 | ret = v4l_enable_media_source(vfd); | ||
1715 | if (ret) | ||
1716 | return ret; | ||
1699 | if (vfd->vfl_type == VFL_TYPE_SDR) { | 1717 | if (vfd->vfl_type == VFL_TYPE_SDR) { |
1700 | if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF) | 1718 | if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF) |
1701 | return -EINVAL; | 1719 | return -EINVAL; |
@@ -1750,7 +1768,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, | |||
1750 | { | 1768 | { |
1751 | struct video_device *vfd = video_devdata(file); | 1769 | struct video_device *vfd = video_devdata(file); |
1752 | v4l2_std_id id = *(v4l2_std_id *)arg, norm; | 1770 | v4l2_std_id id = *(v4l2_std_id *)arg, norm; |
1771 | int ret; | ||
1753 | 1772 | ||
1773 | ret = v4l_enable_media_source(vfd); | ||
1774 | if (ret) | ||
1775 | return ret; | ||
1754 | norm = id & vfd->tvnorms; | 1776 | norm = id & vfd->tvnorms; |
1755 | if (vfd->tvnorms && !norm) /* Check if std is supported */ | 1777 | if (vfd->tvnorms && !norm) /* Check if std is supported */ |
1756 | return -EINVAL; | 1778 | return -EINVAL; |
@@ -1764,7 +1786,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, | |||
1764 | { | 1786 | { |
1765 | struct video_device *vfd = video_devdata(file); | 1787 | struct video_device *vfd = video_devdata(file); |
1766 | v4l2_std_id *p = arg; | 1788 | v4l2_std_id *p = arg; |
1789 | int ret; | ||
1767 | 1790 | ||
1791 | ret = v4l_enable_media_source(vfd); | ||
1792 | if (ret) | ||
1793 | return ret; | ||
1768 | /* | 1794 | /* |
1769 | * If no signal is detected, then the driver should return | 1795 | * If no signal is detected, then the driver should return |
1770 | * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with | 1796 | * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with |
@@ -1783,7 +1809,11 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, | |||
1783 | struct video_device *vfd = video_devdata(file); | 1809 | struct video_device *vfd = video_devdata(file); |
1784 | struct v4l2_hw_freq_seek *p = arg; | 1810 | struct v4l2_hw_freq_seek *p = arg; |
1785 | enum v4l2_tuner_type type; | 1811 | enum v4l2_tuner_type type; |
1812 | int ret; | ||
1786 | 1813 | ||
1814 | ret = v4l_enable_media_source(vfd); | ||
1815 | if (ret) | ||
1816 | return ret; | ||
1787 | /* s_hw_freq_seek is not supported for SDR for now */ | 1817 | /* s_hw_freq_seek is not supported for SDR for now */ |
1788 | if (vfd->vfl_type == VFL_TYPE_SDR) | 1818 | if (vfd->vfl_type == VFL_TYPE_SDR) |
1789 | return -EINVAL; | 1819 | return -EINVAL; |