diff mbox

[RFCv3,07/10,media] tuner-core: add SDR support for g_tuner

Message ID 1366570839-662-8-git-send-email-mchehab@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab April 21, 2013, 7 p.m. UTC
Properly initialize the fields for VIDIOC_G_TUNER, if the
device is in SDR mode.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/v4l2-core/tuner-core.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

Comments

Hans Verkuil April 22, 2013, 7:18 a.m. UTC | #1
On Sun April 21 2013 21:00:36 Mauro Carvalho Chehab wrote:
> Properly initialize the fields for VIDIOC_G_TUNER, if the
> device is in SDR mode.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> ---
>  drivers/media/v4l2-core/tuner-core.c | 29 +++++++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
> index b97ec63..e54b5ae 100644
> --- a/drivers/media/v4l2-core/tuner-core.c
> +++ b/drivers/media/v4l2-core/tuner-core.c
> @@ -1190,7 +1190,31 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
>  	}
>  
>  	/* radio mode */
> -	if (vt->type == t->mode) {
> +	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
> +
> +	if (V4L2_TUNER_IS_SDR(vt->type)) {
> +		vt->rangelow  = tv_range[0] * 16000;
> +		vt->rangehigh = tv_range[1] * 16000;

Why use tv_range for SDR? It's a bit odd for something called SD 'Radio'.

Regards,

	Hans

> +	else {
> +		vt->rangelow = radio_range[0] * 16000;
> +		vt->rangehigh = radio_range[1] * 16000;
> +	}
> +	/* Check if the radio device is active */
> +	if (vt->type != t->mode)
> +		return 0;
> +
> +	if (V4L2_TUNER_IS_SDR(vt->type)) {
> +		if (fe_tuner_ops->get_bandwidth)
> +			fe_tuner_ops->get_bandwidth(&t->fe,
> +							&vt->bandwidth);
> +		if (fe_tuner_ops->get_if_frequency)
> +			fe_tuner_ops->get_if_frequency(&t->fe,
> +							&vt->int_freq);
> +		/*
> +			* Sampe rate is not a tuner props - it is up to the
> +			* bridge driver to fill it.
> +			*/
> +	} else {
>  		vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
>  		if (fe_tuner_ops->get_status) {
>  			u32 tuner_status;
> @@ -1203,9 +1227,6 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
>  		}
>  		vt->audmode = t->audmode;
>  	}
> -	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
> -	vt->rangelow = radio_range[0] * 16000;
> -	vt->rangehigh = radio_range[1] * 16000;
>  
>  	return 0;
>  }
> 
--
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
Mauro Carvalho Chehab April 22, 2013, 11:57 a.m. UTC | #2
Em 22-04-2013 04:18, Hans Verkuil escreveu:
> On Sun April 21 2013 21:00:36 Mauro Carvalho Chehab wrote:
>> Properly initialize the fields for VIDIOC_G_TUNER, if the
>> device is in SDR mode.
>>
>> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
>> ---
>>   drivers/media/v4l2-core/tuner-core.c | 29 +++++++++++++++++++++++++----
>>   1 file changed, 25 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
>> index b97ec63..e54b5ae 100644
>> --- a/drivers/media/v4l2-core/tuner-core.c
>> +++ b/drivers/media/v4l2-core/tuner-core.c
>> @@ -1190,7 +1190,31 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
>>   	}
>>
>>   	/* radio mode */
>> -	if (vt->type == t->mode) {
>> +	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
>> +
>> +	if (V4L2_TUNER_IS_SDR(vt->type)) {
>> +		vt->rangelow  = tv_range[0] * 16000;
>> +		vt->rangehigh = tv_range[1] * 16000;
>
> Why use tv_range for SDR? It's a bit odd for something called SD 'Radio'.

Because it is the widest known range, and it covers already the FM
range. A latter patch will improve the range, by adding a tuner
callback to query about what's the real supported range, with will
be typically broader than the TV one.

Regards,
Mauro
--
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/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index b97ec63..e54b5ae 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -1190,7 +1190,31 @@  static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
 	}
 
 	/* radio mode */
-	if (vt->type == t->mode) {
+	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
+
+	if (V4L2_TUNER_IS_SDR(vt->type)) {
+		vt->rangelow  = tv_range[0] * 16000;
+		vt->rangehigh = tv_range[1] * 16000;
+	else {
+		vt->rangelow = radio_range[0] * 16000;
+		vt->rangehigh = radio_range[1] * 16000;
+	}
+	/* Check if the radio device is active */
+	if (vt->type != t->mode)
+		return 0;
+
+	if (V4L2_TUNER_IS_SDR(vt->type)) {
+		if (fe_tuner_ops->get_bandwidth)
+			fe_tuner_ops->get_bandwidth(&t->fe,
+							&vt->bandwidth);
+		if (fe_tuner_ops->get_if_frequency)
+			fe_tuner_ops->get_if_frequency(&t->fe,
+							&vt->int_freq);
+		/*
+			* Sampe rate is not a tuner props - it is up to the
+			* bridge driver to fill it.
+			*/
+	} else {
 		vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
 		if (fe_tuner_ops->get_status) {
 			u32 tuner_status;
@@ -1203,9 +1227,6 @@  static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
 		}
 		vt->audmode = t->audmode;
 	}
-	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
-	vt->rangelow = radio_range[0] * 16000;
-	vt->rangehigh = radio_range[1] * 16000;
 
 	return 0;
 }