diff mbox

[07/10] si2165: Fix DVB-T bandwidth default

Message ID 1447963442-9764-8-git-send-email-zzam@gentoo.org (mailing list archive)
State New, archived
Headers show

Commit Message

Matthias Schwarzott Nov. 19, 2015, 8:03 p.m. UTC
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
 drivers/media/dvb-frontends/si2165.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Mauro Carvalho Chehab Dec. 3, 2015, 2:15 p.m. UTC | #1
Em Thu, 19 Nov 2015 21:03:59 +0100
Matthias Schwarzott <zzam@gentoo.org> escreveu:


Please, add a description to your patches.

That's said, this patch should be called, instead:

si2165: Fix DVB-T bandwidth auto

DVB auto bandwidth mode (bandwidth_hz == 0) logic was setting
the initial value for dvb_rate to a wrong value. Fix it.

as a zero value here means to let the frontend to auto-detect
the bandwidth. Of course, assuming that si2165 is capable of
doing that.

If si2165 chip or driver doesn't support bandwidth auto-detection, it
should, instead, return -EINVAL.

Are you sure that it will auto-detect the bandwidth if we keep it
as 8MHz?

Regards,
Mauro





> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
>  drivers/media/dvb-frontends/si2165.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
> index 807a3c9..e97b0e6 100644
> --- a/drivers/media/dvb-frontends/si2165.c
> +++ b/drivers/media/dvb-frontends/si2165.c
> @@ -811,19 +811,18 @@ static int si2165_set_frontend(struct dvb_frontend *fe)
>  	u8 val[3];
>  	u32 dvb_rate = 0;
>  	u16 bw10k;
> +	u32 bw_hz = p->bandwidth_hz;
>  
>  	dprintk("%s: called\n", __func__);
>  
>  	if (!state->has_dvbt)
>  		return -EINVAL;
>  
> -	if (p->bandwidth_hz > 0) {
> -		dvb_rate = p->bandwidth_hz * 8 / 7;
> -		bw10k = p->bandwidth_hz / 10000;
> -	} else {
> -		dvb_rate = 8 * 8 / 7;
> -		bw10k = 800;
> -	}
> +	if (bw_hz == 0)
> +		bw_hz = 8000000;
> +
> +	dvb_rate = bw_hz * 8 / 7;
> +	bw10k = bw_hz / 10000;
>  
>  	/* standard = DVB-T */
>  	ret = si2165_writereg8(state, 0x00ec, 0x01);
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matthias Schwarzott Dec. 3, 2015, 8:11 p.m. UTC | #2
Am 03.12.2015 um 15:15 schrieb Mauro Carvalho Chehab:
> Em Thu, 19 Nov 2015 21:03:59 +0100
> Matthias Schwarzott <zzam@gentoo.org> escreveu:
> 
> 
> Please, add a description to your patches.
> 
> That's said, this patch should be called, instead:
> 
> si2165: Fix DVB-T bandwidth auto
> 
> DVB auto bandwidth mode (bandwidth_hz == 0) logic was setting
> the initial value for dvb_rate to a wrong value. Fix it.
> 
> as a zero value here means to let the frontend to auto-detect
> the bandwidth. Of course, assuming that si2165 is capable of
> doing that.
> 
> If si2165 chip or driver doesn't support bandwidth auto-detection, it
> should, instead, return -EINVAL.
> 
> Are you sure that it will auto-detect the bandwidth if we keep it
> as 8MHz?
> 

Thanks for the feedback.
As far as I know si2165 does not support auto-detection of bandwidth.

I only have 8MHz channels available I tried what happens when
configuring other bandwidth values - it will not lock.

So I will resend the modified the patch.

Regards
Matthias

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

Patch

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 807a3c9..e97b0e6 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -811,19 +811,18 @@  static int si2165_set_frontend(struct dvb_frontend *fe)
 	u8 val[3];
 	u32 dvb_rate = 0;
 	u16 bw10k;
+	u32 bw_hz = p->bandwidth_hz;
 
 	dprintk("%s: called\n", __func__);
 
 	if (!state->has_dvbt)
 		return -EINVAL;
 
-	if (p->bandwidth_hz > 0) {
-		dvb_rate = p->bandwidth_hz * 8 / 7;
-		bw10k = p->bandwidth_hz / 10000;
-	} else {
-		dvb_rate = 8 * 8 / 7;
-		bw10k = 800;
-	}
+	if (bw_hz == 0)
+		bw_hz = 8000000;
+
+	dvb_rate = bw_hz * 8 / 7;
+	bw10k = bw_hz / 10000;
 
 	/* standard = DVB-T */
 	ret = si2165_writereg8(state, 0x00ec, 0x01);