aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/msp3400.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index 1bf0fb38b918..fd0589352822 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -166,8 +166,6 @@ struct msp3400c {
166 int watch_stereo:1; 166 int watch_stereo:1;
167}; 167};
168 168
169#define MIN(a,b) (((a)>(b))?(b):(a))
170#define MAX(a,b) (((a)>(b))?(a):(b))
171#define HAVE_NICAM(msp) (((msp->rev2>>8) & 0xff) != 00) 169#define HAVE_NICAM(msp) (((msp->rev2>>8) & 0xff) != 00)
172#define HAVE_SIMPLE(msp) ((msp->rev1 & 0xff) >= 'D'-'@') 170#define HAVE_SIMPLE(msp) ((msp->rev1 & 0xff) >= 'D'-'@')
173#define HAVE_SIMPLER(msp) ((msp->rev1 & 0xff) >= 'G'-'@') 171#define HAVE_SIMPLER(msp) ((msp->rev1 & 0xff) >= 'G'-'@')
@@ -1670,9 +1668,9 @@ static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1670 return 0; 1668 return 0;
1671 case V4L2_CID_AUDIO_BALANCE: 1669 case V4L2_CID_AUDIO_BALANCE:
1672 { 1670 {
1673 int volume = MAX(msp->left, msp->right); 1671 int volume = max(msp->left, msp->right);
1674 1672
1675 ctrl->value = (32768 * MIN(msp->left, msp->right)) / 1673 ctrl->value = (32768 * min(msp->left, msp->right)) /
1676 (volume ? volume : 1); 1674 (volume ? volume : 1);
1677 ctrl->value = (msp->left < msp->right) ? 1675 ctrl->value = (msp->left < msp->right) ?
1678 (65535 - ctrl->value) : ctrl->value; 1676 (65535 - ctrl->value) : ctrl->value;
@@ -1687,7 +1685,7 @@ static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1687 ctrl->value = msp->treble; 1685 ctrl->value = msp->treble;
1688 return 0; 1686 return 0;
1689 case V4L2_CID_AUDIO_VOLUME: 1687 case V4L2_CID_AUDIO_VOLUME:
1690 ctrl->value = MAX(msp->left, msp->right); 1688 ctrl->value = max(msp->left, msp->right);
1691 return 0; 1689 return 0;
1692 default: 1690 default:
1693 return -EINVAL; 1691 return -EINVAL;
@@ -1710,7 +1708,7 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1710 return 0; 1708 return 0;
1711 case V4L2_CID_AUDIO_BALANCE: 1709 case V4L2_CID_AUDIO_BALANCE:
1712 balance=ctrl->value; 1710 balance=ctrl->value;
1713 volume = MAX(msp->left, msp->right); 1711 volume = max(msp->left, msp->right);
1714 set_volume=1; 1712 set_volume=1;
1715 break; 1713 break;
1716 case V4L2_CID_AUDIO_BASS: 1714 case V4L2_CID_AUDIO_BASS:
@@ -1722,9 +1720,9 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1722 msp3400c_settreble(client, msp->treble); 1720 msp3400c_settreble(client, msp->treble);
1723 return 0; 1721 return 0;
1724 case V4L2_CID_AUDIO_VOLUME: 1722 case V4L2_CID_AUDIO_VOLUME:
1725 volume = MAX(msp->left, msp->right); 1723 volume = max(msp->left, msp->right);
1726 1724
1727 balance = (32768 * MIN(msp->left, msp->right)) / 1725 balance = (32768 * min(msp->left, msp->right)) /
1728 (volume ? volume : 1); 1726 (volume ? volume : 1);
1729 balance = (msp->left < msp->right) ? 1727 balance = (msp->left < msp->right) ?
1730 (65535 - balance) : balance; 1728 (65535 - balance) : balance;
@@ -1739,8 +1737,8 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
1739 } 1737 }
1740 1738
1741 if (set_volume) { 1739 if (set_volume) {
1742 msp->left = (MIN(65536 - balance, 32768) * volume) / 32768; 1740 msp->left = (min(65536 - balance, 32768) * volume) / 32768;
1743 msp->right = (MIN(balance, 32768) * volume) / 32768; 1741 msp->right = (min(balance, 32768) * volume) / 32768;
1744 1742
1745 msp3400_dbg("volume=%d, balance=%d, left=%d, right=%d", 1743 msp3400_dbg("volume=%d, balance=%d, left=%d, right=%d",
1746 volume,balance,msp->left,msp->right); 1744 volume,balance,msp->left,msp->right);
@@ -1861,8 +1859,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
1861 1859
1862 if (msp->muted) 1860 if (msp->muted)
1863 va->flags |= VIDEO_AUDIO_MUTE; 1861 va->flags |= VIDEO_AUDIO_MUTE;
1864 va->volume = MAX(msp->left, msp->right); 1862 va->volume = max(msp->left, msp->right);
1865 va->balance = (32768 * MIN(msp->left, msp->right)) / 1863 va->balance = (32768 * min(msp->left, msp->right)) /
1866 (va->volume ? va->volume : 1); 1864 (va->volume ? va->volume : 1);
1867 va->balance = (msp->left < msp->right) ? 1865 va->balance = (msp->left < msp->right) ?
1868 (65535 - va->balance) : va->balance; 1866 (65535 - va->balance) : va->balance;
@@ -1881,9 +1879,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
1881 1879
1882 msp3400_dbg("VIDIOCSAUDIO\n"); 1880 msp3400_dbg("VIDIOCSAUDIO\n");
1883 msp->muted = (va->flags & VIDEO_AUDIO_MUTE); 1881 msp->muted = (va->flags & VIDEO_AUDIO_MUTE);
1884 msp->left = (MIN(65536 - va->balance, 32768) * 1882 msp->left = (min(65536 - va->balance, 32768) *
1885 va->volume) / 32768; 1883 va->volume) / 32768;
1886 msp->right = (MIN(va->balance, 32768) * va->volume) / 32768; 1884 msp->right = (min((int)va->balance, 32768) * va->volume) / 32768;
1887 msp->bass = va->bass; 1885 msp->bass = va->bass;
1888 msp->treble = va->treble; 1886 msp->treble = va->treble;
1889 msp3400_dbg("VIDIOCSAUDIO setting va->volume to %d\n", 1887 msp3400_dbg("VIDIOCSAUDIO setting va->volume to %d\n",