aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 12:25:14 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-09 12:25:14 -0500
commitc0477ad9feca01bd8eff95d7482c33753d05c700 (patch)
treeaa2640078fdb82cb4bb9c065e7549ecdbc836ca7 /drivers/media/video/msp3400.c
parentc432a072b6b597c7af138f2fee337d79261b44f4 (diff)
V4L/DVB (3099): Fixed device controls for em28xx on WinTV USB2 devices
- Controls now come from video and audio decoder driver for msp3400 and tvp5150. - Added audio and sound controls as provided by msp3400 and tvp5150. Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/video/msp3400.c')
-rw-r--r--drivers/media/video/msp3400.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index fc2896bc42c0..8d47d7894248 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -1642,6 +1642,45 @@ static void msp_any_detect_stereo(struct i2c_client *client)
1642 } 1642 }
1643} 1643}
1644 1644
1645static struct v4l2_queryctrl msp34xx_qctrl[] = {
1646 {
1647 .id = V4L2_CID_AUDIO_VOLUME,
1648 .name = "Volume",
1649 .minimum = 0,
1650 .maximum = 65535,
1651 .step = 65535/100,
1652 .default_value = 58880,
1653 .flags = 0,
1654 .type = V4L2_CTRL_TYPE_INTEGER,
1655 },{
1656 .id = V4L2_CID_AUDIO_MUTE,
1657 .name = "Mute",
1658 .minimum = 0,
1659 .maximum = 1,
1660 .step = 1,
1661 .default_value = 1,
1662 .flags = 0,
1663 .type = V4L2_CTRL_TYPE_BOOLEAN,
1664 },{
1665 .id = V4L2_CID_AUDIO_BASS,
1666 .name = "Bass",
1667 .minimum = 0,
1668 .maximum = 65535,
1669 .step = 65535/100,
1670 .default_value = 32768,
1671 .type = V4L2_CTRL_TYPE_INTEGER,
1672 },{
1673 .id = V4L2_CID_AUDIO_TREBLE,
1674 .name = "Treble",
1675 .minimum = 0,
1676 .maximum = 65535,
1677 .step = 65535/100,
1678 .default_value = 32768,
1679 .type = V4L2_CTRL_TYPE_INTEGER,
1680 },
1681};
1682
1683
1645static void msp_any_set_audmode(struct i2c_client *client, int audmode) 1684static void msp_any_set_audmode(struct i2c_client *client, int audmode)
1646{ 1685{
1647 struct msp3400c *msp = i2c_get_clientdata(client); 1686 struct msp3400c *msp = i2c_get_clientdata(client);
@@ -1658,6 +1697,95 @@ static void msp_any_set_audmode(struct i2c_client *client, int audmode)
1658 } 1697 }
1659} 1698}
1660 1699
1700static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1701{
1702 struct msp3400c *msp = i2c_get_clientdata(client);
1703
1704 switch (ctrl->id) {
1705 case V4L2_CID_AUDIO_MUTE:
1706 ctrl->value = msp->muted;
1707 return 0;
1708 case V4L2_CID_AUDIO_BALANCE:
1709 {
1710 int volume = MAX(msp->left, msp->right);
1711
1712 ctrl->value = (32768 * MIN(msp->left, msp->right)) /
1713 (volume ? volume : 1);
1714 ctrl->value = (msp->left < msp->right) ?
1715 (65535 - ctrl->value) : ctrl->value;
1716 if (0 == volume)
1717 ctrl->value = 32768;
1718 return 0;
1719 }
1720 case V4L2_CID_AUDIO_BASS:
1721 ctrl->value = msp->bass;
1722 return 0;
1723 case V4L2_CID_AUDIO_TREBLE:
1724 ctrl->value = msp->treble;
1725 return 0;
1726 case V4L2_CID_AUDIO_VOLUME:
1727 ctrl->value = MAX(msp->left, msp->right);
1728 return 0;
1729 default:
1730 return -EINVAL;
1731 }
1732}
1733
1734static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1735{
1736 struct msp3400c *msp = i2c_get_clientdata(client);
1737 int set_volume=0, balance, volume;
1738
1739 switch (ctrl->id) {
1740 case V4L2_CID_AUDIO_MUTE:
1741 if (ctrl->value>=0 && ctrl->value<2)
1742 msp->muted = ctrl->value;
1743 else
1744 return -ERANGE;
1745
1746 msp3400c_setvolume(client, msp->muted, msp->left, msp->right);
1747 return 0;
1748 case V4L2_CID_AUDIO_BALANCE:
1749 balance=ctrl->value;
1750 volume = MAX(msp->left, msp->right);
1751 set_volume=1;
1752 break;
1753 case V4L2_CID_AUDIO_BASS:
1754 msp->bass=ctrl->value;
1755 msp3400c_setbass(client, msp->bass);
1756 return 0;
1757 case V4L2_CID_AUDIO_TREBLE:
1758 msp->treble=ctrl->value;
1759 msp3400c_settreble(client, msp->treble);
1760 return 0;
1761 case V4L2_CID_AUDIO_VOLUME:
1762 volume = MAX(msp->left, msp->right);
1763
1764 balance = (32768 * MIN(msp->left, msp->right)) /
1765 (volume ? volume : 1);
1766 balance = (msp->left < msp->right) ?
1767 (65535 - balance) : balance;
1768 if (0 == volume)
1769 balance = 32768;
1770
1771 volume=ctrl->value;
1772 set_volume=1;
1773 break;
1774 default:
1775 return -EINVAL;
1776 }
1777
1778 if (set_volume) {
1779 msp->left = (MIN(65536 - balance, 32768) * volume) / 32768;
1780 msp->right = (MIN(balance, 32768) * volume) / 32768;
1781
1782 msp3400_dbg("volume=%d, balance=%d, left=%d, right=%d",
1783 volume,balance,msp->left,msp->right);
1784
1785 msp3400c_setvolume(client, msp->muted, msp->left, msp->right);
1786 }
1787 return 0;
1788}
1661 1789
1662static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) 1790static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
1663{ 1791{
@@ -2027,6 +2155,37 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
2027 2155
2028 break; 2156 break;
2029 } 2157 }
2158 case VIDIOC_QUERYCTRL:
2159 {
2160 struct v4l2_queryctrl *qc = arg;
2161 int i;
2162
2163 msp3400_dbg("VIDIOC_QUERYCTRL");
2164
2165 for (i = 0; i < ARRAY_SIZE(msp34xx_qctrl); i++)
2166 if (qc->id && qc->id == msp34xx_qctrl[i].id) {
2167 memcpy(qc, &(msp34xx_qctrl[i]),
2168 sizeof(*qc));
2169 return 0;
2170 }
2171
2172 return -EINVAL;
2173 }
2174 case VIDIOC_G_CTRL:
2175 {
2176 struct v4l2_control *ctrl = arg;
2177 msp3400_dbg("VIDIOC_G_CTRL\n");
2178
2179 return msp_get_ctrl(client, ctrl);
2180 }
2181 case VIDIOC_S_CTRL:
2182 {
2183 struct v4l2_control *ctrl = arg;
2184
2185 msp3400_dbg("VIDIOC_S_CTRL\n");
2186
2187 return msp_set_ctrl(client, ctrl);
2188 }
2030 2189
2031 default: 2190 default:
2032 /* nothing */ 2191 /* nothing */