Initializing whole tuner every time when frequency is changed is wrong
and unnecessary. Init tuner only when streaming is started. Change
other parameters runtime.

Signed-off-by: Antti Palosaari <cr...@iki.fi>
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 25 +++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index 0d96aea..cc554f7 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -912,7 +912,7 @@ err:
        return;
 };
 
-static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state *s)
+static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_state *s)
 {
        struct dvb_frontend *fe = s->fe;
        struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@@ -946,15 +946,24 @@ static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state 
*s)
        if (!test_bit(POWER_ON, &s->flags))
                return 0;
 
-       if (fe->ops.tuner_ops.init)
-               fe->ops.tuner_ops.init(fe);
-
        if (fe->ops.tuner_ops.set_params)
                fe->ops.tuner_ops.set_params(fe);
 
        return 0;
 };
 
+static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state *s)
+{
+       struct dvb_frontend *fe = s->fe;
+
+       dev_dbg(&s->udev->dev, "%s:\n", __func__);
+
+       if (fe->ops.tuner_ops.init)
+               fe->ops.tuner_ops.init(fe);
+
+       return 0;
+};
+
 static void rtl2832_sdr_unset_tuner(struct rtl2832_sdr_state *s)
 {
        struct dvb_frontend *fe = s->fe;
@@ -988,6 +997,10 @@ static int rtl2832_sdr_start_streaming(struct vb2_queue 
*vq, unsigned int count)
        if (ret)
                goto err;
 
+       ret = rtl2832_sdr_set_tuner_freq(s);
+       if (ret)
+               goto err;
+
        ret = rtl2832_sdr_set_adc(s);
        if (ret)
                goto err;
@@ -1127,6 +1140,7 @@ static int rtl2832_sdr_s_frequency(struct file *file, 
void *priv,
 {
        struct rtl2832_sdr_state *s = video_drvdata(file);
        int ret, band;
+
        dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d frequency=%u\n",
                        __func__, f->tuner, f->type, f->frequency);
 
@@ -1153,7 +1167,8 @@ static int rtl2832_sdr_s_frequency(struct file *file, 
void *priv,
                s->f_tuner = f->frequency;
                dev_dbg(&s->udev->dev, "%s: RF frequency=%u Hz\n",
                                __func__, f->frequency);
-               ret = rtl2832_sdr_set_tuner(s);
+
+               ret = rtl2832_sdr_set_tuner_freq(s);
        } else {
                ret = -EINVAL;
        }
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to