diff options
author | Mauro Carvalho Chehab <devnull@localhost> | 2005-12-02 17:51:52 +0000 |
---|---|---|
committer | Mauro Carvalho Chehab <devnull@localhost> | 2005-12-02 17:51:52 +0000 |
commit | ab625030b5323e2c45002cb0941e411ef1461a5e (patch) | |
tree | 8328312ce25ffe0a7d23886977ac3a1c9d38e2d2 /linux/drivers/media/video/msp3400-driver.c | |
parent | 537ca5e2a1fcb98c83e30ee99525df96d3c3ff76 (diff) | |
download | mediapointer-dvb-s2-ab625030b5323e2c45002cb0941e411ef1461a5e.tar.gz mediapointer-dvb-s2-ab625030b5323e2c45002cb0941e411ef1461a5e.tar.bz2 |
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 'linux/drivers/media/video/msp3400-driver.c')
-rw-r--r-- | linux/drivers/media/video/msp3400-driver.c | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/linux/drivers/media/video/msp3400-driver.c b/linux/drivers/media/video/msp3400-driver.c index bf31a0bd1..633909231 100644 --- a/linux/drivers/media/video/msp3400-driver.c +++ b/linux/drivers/media/video/msp3400-driver.c @@ -1635,6 +1635,45 @@ static void msp_any_detect_stereo(struct i2c_client *client) } } +static struct v4l2_queryctrl msp34xx_qctrl[] = { + { + .id = V4L2_CID_AUDIO_VOLUME, + .name = "Volume", + .minimum = 0, + .maximum = 65535, + .step = 65535/100, + .default_value = 58880, + .flags = 0, + .type = V4L2_CTRL_TYPE_INTEGER, + },{ + .id = V4L2_CID_AUDIO_MUTE, + .name = "Mute", + .minimum = 0, + .maximum = 1, + .step = 1, + .default_value = 1, + .flags = 0, + .type = V4L2_CTRL_TYPE_BOOLEAN, + },{ + .id = V4L2_CID_AUDIO_BASS, + .name = "Bass", + .minimum = 0, + .maximum = 65535, + .step = 65535/100, + .default_value = 32768, + .type = V4L2_CTRL_TYPE_INTEGER, + },{ + .id = V4L2_CID_AUDIO_TREBLE, + .name = "Treble", + .minimum = 0, + .maximum = 65535, + .step = 65535/100, + .default_value = 32768, + .type = V4L2_CTRL_TYPE_INTEGER, + }, +}; + + static void msp_any_set_audmode(struct i2c_client *client, int audmode) { struct msp3400c *msp = i2c_get_clientdata(client); @@ -1651,6 +1690,95 @@ static void msp_any_set_audmode(struct i2c_client *client, int audmode) } } +static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) +{ + struct msp3400c *msp = i2c_get_clientdata(client); + + switch (ctrl->id) { + case V4L2_CID_AUDIO_MUTE: + ctrl->value = msp->muted; + return 0; + case V4L2_CID_AUDIO_BALANCE: + { + int volume = MAX(msp->left, msp->right); + + ctrl->value = (32768 * MIN(msp->left, msp->right)) / + (volume ? volume : 1); + ctrl->value = (msp->left < msp->right) ? + (65535 - ctrl->value) : ctrl->value; + if (0 == volume) + ctrl->value = 32768; + return 0; + } + case V4L2_CID_AUDIO_BASS: + ctrl->value = msp->bass; + return 0; + case V4L2_CID_AUDIO_TREBLE: + ctrl->value = msp->treble; + return 0; + case V4L2_CID_AUDIO_VOLUME: + ctrl->value = MAX(msp->left, msp->right); + return 0; + default: + return -EINVAL; + } +} + +static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) +{ + struct msp3400c *msp = i2c_get_clientdata(client); + int set_volume=0, balance, volume; + + switch (ctrl->id) { + case V4L2_CID_AUDIO_MUTE: + if (ctrl->value>=0 && ctrl->value<2) + msp->muted = ctrl->value; + else + return -ERANGE; + + msp3400c_setvolume(client, msp->muted, msp->left, msp->right); + return 0; + case V4L2_CID_AUDIO_BALANCE: + balance=ctrl->value; + volume = MAX(msp->left, msp->right); + set_volume=1; + break; + case V4L2_CID_AUDIO_BASS: + msp->bass=ctrl->value; + msp3400c_setbass(client, msp->bass); + return 0; + case V4L2_CID_AUDIO_TREBLE: + msp->treble=ctrl->value; + msp3400c_settreble(client, msp->treble); + return 0; + case V4L2_CID_AUDIO_VOLUME: + volume = MAX(msp->left, msp->right); + + balance = (32768 * MIN(msp->left, msp->right)) / + (volume ? volume : 1); + balance = (msp->left < msp->right) ? + (65535 - balance) : balance; + if (0 == volume) + balance = 32768; + + volume=ctrl->value; + set_volume=1; + break; + default: + return -EINVAL; + } + + if (set_volume) { + msp->left = (MIN(65536 - balance, 32768) * volume) / 32768; + msp->right = (MIN(balance, 32768) * volume) / 32768; + + msp3400_dbg("volume=%d, balance=%d, left=%d, right=%d", + volume,balance,msp->left,msp->right); + + msp3400c_setvolume(client, msp->muted, msp->left, msp->right); + } + return 0; +} static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) { @@ -2021,6 +2149,37 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) break; } + case VIDIOC_QUERYCTRL: + { + struct v4l2_queryctrl *qc = arg; + int i; + + msp3400_dbg("VIDIOC_QUERYCTRL"); + + for (i = 0; i < ARRAY_SIZE(msp34xx_qctrl); i++) + if (qc->id && qc->id == msp34xx_qctrl[i].id) { + memcpy(qc, &(msp34xx_qctrl[i]), + sizeof(*qc)); + return 0; + } + + return -EINVAL; + } + case VIDIOC_G_CTRL: + { + struct v4l2_control *ctrl = arg; + msp3400_dbg("VIDIOC_G_CTRL\n"); + + return msp_get_ctrl(client, ctrl); + } + case VIDIOC_S_CTRL: + { + struct v4l2_control *ctrl = arg; + + msp3400_dbg("VIDIOC_S_CTRL\n"); + + return msp_set_ctrl(client, ctrl); + } default: /* nothing */ |