diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-03-18 12:59:34 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:46 -0400 |
commit | 5fa7b9f3c0f249a4faed6c3e534917199249ead8 (patch) | |
tree | 3346ea4654c5dfb971c3f6509869e154b60d6576 /drivers/media | |
parent | 8f84a775c2ad8a0d95f944f6397248b9c0c25e50 (diff) |
V4L/DVB (11275): tvaudio: fix mute and s/g_tuner handling
The mute control depends on CHIP_HAS_INPUTSEL, so test for that first.
The s/g_tuner code should check whether getmode/setmode is set at the
beginning instead of filling in the struct and discovering at
the end that this chip doesn't implement audiomodes after all (i.e. is
a simple muxer chip).
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/tvaudio.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index e8ab28532d94..faa9e3dd782f 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -1511,6 +1511,8 @@ static int tvaudio_g_ctrl(struct v4l2_subdev *sd, | |||
1511 | 1511 | ||
1512 | switch (ctrl->id) { | 1512 | switch (ctrl->id) { |
1513 | case V4L2_CID_AUDIO_MUTE: | 1513 | case V4L2_CID_AUDIO_MUTE: |
1514 | if (!(desc->flags & CHIP_HAS_INPUTSEL)) | ||
1515 | break; | ||
1514 | ctrl->value=chip->muted; | 1516 | ctrl->value=chip->muted; |
1515 | return 0; | 1517 | return 0; |
1516 | case V4L2_CID_AUDIO_VOLUME: | 1518 | case V4L2_CID_AUDIO_VOLUME: |
@@ -1552,6 +1554,9 @@ static int tvaudio_s_ctrl(struct v4l2_subdev *sd, | |||
1552 | 1554 | ||
1553 | switch (ctrl->id) { | 1555 | switch (ctrl->id) { |
1554 | case V4L2_CID_AUDIO_MUTE: | 1556 | case V4L2_CID_AUDIO_MUTE: |
1557 | if (!(desc->flags & CHIP_HAS_INPUTSEL)) | ||
1558 | break; | ||
1559 | |||
1555 | if (ctrl->value < 0 || ctrl->value >= 2) | 1560 | if (ctrl->value < 0 || ctrl->value >= 2) |
1556 | return -ERANGE; | 1561 | return -ERANGE; |
1557 | chip->muted = ctrl->value; | 1562 | chip->muted = ctrl->value; |
@@ -1636,7 +1641,9 @@ static int tvaudio_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) | |||
1636 | 1641 | ||
1637 | switch (qc->id) { | 1642 | switch (qc->id) { |
1638 | case V4L2_CID_AUDIO_MUTE: | 1643 | case V4L2_CID_AUDIO_MUTE: |
1639 | return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0); | 1644 | if (desc->flags & CHIP_HAS_INPUTSEL) |
1645 | return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0); | ||
1646 | break; | ||
1640 | case V4L2_CID_AUDIO_VOLUME: | 1647 | case V4L2_CID_AUDIO_VOLUME: |
1641 | if (desc->flags & CHIP_HAS_VOLUME) | 1648 | if (desc->flags & CHIP_HAS_VOLUME) |
1642 | return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 58880); | 1649 | return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 58880); |
@@ -1661,7 +1668,9 @@ static int tvaudio_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing * | |||
1661 | struct CHIPSTATE *chip = to_state(sd); | 1668 | struct CHIPSTATE *chip = to_state(sd); |
1662 | struct CHIPDESC *desc = chip->desc; | 1669 | struct CHIPDESC *desc = chip->desc; |
1663 | 1670 | ||
1664 | if (!(desc->flags & CHIP_HAS_INPUTSEL) || rt->input >= 4) | 1671 | if (!(desc->flags & CHIP_HAS_INPUTSEL)) |
1672 | return 0; | ||
1673 | if (rt->input >= 4) | ||
1665 | return -EINVAL; | 1674 | return -EINVAL; |
1666 | /* There are four inputs: tuner, radio, extern and intern. */ | 1675 | /* There are four inputs: tuner, radio, extern and intern. */ |
1667 | chip->input = rt->input; | 1676 | chip->input = rt->input; |
@@ -1678,8 +1687,11 @@ static int tvaudio_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1678 | struct CHIPDESC *desc = chip->desc; | 1687 | struct CHIPDESC *desc = chip->desc; |
1679 | int mode = 0; | 1688 | int mode = 0; |
1680 | 1689 | ||
1690 | if (!desc->setmode) | ||
1691 | return 0; | ||
1681 | if (chip->radio) | 1692 | if (chip->radio) |
1682 | return 0; | 1693 | return 0; |
1694 | |||
1683 | switch (vt->audmode) { | 1695 | switch (vt->audmode) { |
1684 | case V4L2_TUNER_MODE_MONO: | 1696 | case V4L2_TUNER_MODE_MONO: |
1685 | case V4L2_TUNER_MODE_STEREO: | 1697 | case V4L2_TUNER_MODE_STEREO: |
@@ -1695,7 +1707,7 @@ static int tvaudio_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1695 | } | 1707 | } |
1696 | chip->audmode = vt->audmode; | 1708 | chip->audmode = vt->audmode; |
1697 | 1709 | ||
1698 | if (desc->setmode && mode) { | 1710 | if (mode) { |
1699 | chip->watch_stereo = 0; | 1711 | chip->watch_stereo = 0; |
1700 | /* del_timer(&chip->wt); */ | 1712 | /* del_timer(&chip->wt); */ |
1701 | chip->mode = mode; | 1713 | chip->mode = mode; |
@@ -1710,15 +1722,17 @@ static int tvaudio_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1710 | struct CHIPDESC *desc = chip->desc; | 1722 | struct CHIPDESC *desc = chip->desc; |
1711 | int mode = V4L2_TUNER_MODE_MONO; | 1723 | int mode = V4L2_TUNER_MODE_MONO; |
1712 | 1724 | ||
1725 | if (!desc->getmode) | ||
1726 | return 0; | ||
1713 | if (chip->radio) | 1727 | if (chip->radio) |
1714 | return 0; | 1728 | return 0; |
1729 | |||
1715 | vt->audmode = chip->audmode; | 1730 | vt->audmode = chip->audmode; |
1716 | vt->rxsubchans = 0; | 1731 | vt->rxsubchans = 0; |
1717 | vt->capability = V4L2_TUNER_CAP_STEREO | | 1732 | vt->capability = V4L2_TUNER_CAP_STEREO | |
1718 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; | 1733 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; |
1719 | 1734 | ||
1720 | if (desc->getmode) | 1735 | mode = desc->getmode(chip); |
1721 | mode = desc->getmode(chip); | ||
1722 | 1736 | ||
1723 | if (mode & V4L2_TUNER_MODE_MONO) | 1737 | if (mode & V4L2_TUNER_MODE_MONO) |
1724 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; | 1738 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; |