diff options
author | Antti Palosaari <crope@iki.fi> | 2014-03-10 14:28:45 -0300 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-11-18 11:56:12 +0900 |
commit | 75a50932bf9b2944dbcc037b81112360b9c85d4e (patch) | |
tree | 65c5a0bf17dd7c70bcaad8c2493c8ca3226fac81 /drivers/staging | |
parent | 92b32dcff3069075c3acfc6abc6fd91dfd8cfc30 (diff) | |
download | linux-3.10-75a50932bf9b2944dbcc037b81112360b9c85d4e.tar.gz linux-3.10-75a50932bf9b2944dbcc037b81112360b9c85d4e.tar.bz2 linux-3.10-75a50932bf9b2944dbcc037b81112360b9c85d4e.zip |
upstream: [media] rtl2832_sdr: clamp bandwidth to nearest legal value in automode
Clamp bandwidth to nearest legal value in automode in order to pass
v4l2-compliance test.
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c index 141fc8b428b..b09f7d8c12c 100644 --- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c +++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c @@ -1322,8 +1322,16 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO: case V4L2_CID_RF_TUNER_BANDWIDTH: - if (s->bandwidth_auto->val) - s->bandwidth->val = s->f_adc; + /* TODO: these controls should be moved to tuner drivers */ + if (s->bandwidth_auto->val) { + /* Round towards the closest legal value */ + s32 val = s->f_adc + s->bandwidth->step / 2; + u32 offset; + val = clamp(val, s->bandwidth->minimum, s->bandwidth->maximum); + offset = val - s->bandwidth->minimum; + offset = s->bandwidth->step * (offset / s->bandwidth->step); + s->bandwidth->val = s->bandwidth->minimum + offset; + } c->bandwidth_hz = s->bandwidth->val; |