|
@@ -1322,8 +1322,16 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
|
|
switch (ctrl->id) {
|
|
switch (ctrl->id) {
|
|
case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
|
|
case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
|
|
case V4L2_CID_RF_TUNER_BANDWIDTH:
|
|
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;
|
|
c->bandwidth_hz = s->bandwidth->val;
|
|
|
|
|