diff options
author | Antti Palosaari <crope@iki.fi> | 2014-03-10 13:28:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-14 04:39:58 -0400 |
commit | ea4d04f92c97c7986dfc363655f9c4143d35c2b9 (patch) | |
tree | 34c86225f718ce650c48a37d114256c4dfd0dcff | |
parent | bc9087549ea9f57c400013d08d311c7cd4892132 (diff) |
[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>
-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 141fc8b428ba..b09f7d8c12cf 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) | |||
1322 | switch (ctrl->id) { | 1322 | switch (ctrl->id) { |
1323 | case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO: | 1323 | case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO: |
1324 | case V4L2_CID_RF_TUNER_BANDWIDTH: | 1324 | case V4L2_CID_RF_TUNER_BANDWIDTH: |
1325 | if (s->bandwidth_auto->val) | 1325 | /* TODO: these controls should be moved to tuner drivers */ |
1326 | s->bandwidth->val = s->f_adc; | 1326 | if (s->bandwidth_auto->val) { |
1327 | /* Round towards the closest legal value */ | ||
1328 | s32 val = s->f_adc + s->bandwidth->step / 2; | ||
1329 | u32 offset; | ||
1330 | val = clamp(val, s->bandwidth->minimum, s->bandwidth->maximum); | ||
1331 | offset = val - s->bandwidth->minimum; | ||
1332 | offset = s->bandwidth->step * (offset / s->bandwidth->step); | ||
1333 | s->bandwidth->val = s->bandwidth->minimum + offset; | ||
1334 | } | ||
1327 | 1335 | ||
1328 | c->bandwidth_hz = s->bandwidth->val; | 1336 | c->bandwidth_hz = s->bandwidth->val; |
1329 | 1337 | ||