linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <maurochehab@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Ondrej Zary <linux@rainbow-software.org>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	jirislaby@gmail.com, alsa-devel@alsa-project.org,
	Kernel development list <linux-kernel@vger.kernel.org>,
	linux-media@vger.kernel.org
Subject: Re: [RFC PATCH 1/3] tea575x-tuner: various improvements
Date: Tue, 22 Mar 2011 15:39:57 -0300	[thread overview]
Message-ID: <4D88ECFD.9000706@gmail.com> (raw)
In-Reply-To: <s5htyewr8xg.wl%tiwai@suse.de>

Em 21-03-2011 08:48, Takashi Iwai escreveu:
> At Sat, 19 Mar 2011 16:32:53 +0100,
> Ondrej Zary wrote:
>>
>> Improve tea575x-tuner with various good things from radio-maestro:
>> - extend frequency range to 50-150MHz
>> - fix querycap(): card name, CAP_RADIO
>> - improve g_tuner(): CAP_STEREO, stereo and tuned indication
>> - improve g_frequency(): tuner index checking and reading frequency from HW
>> - improve s_frequency(): tuner index and type checking
>>
>> Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> 
> Applied these 3 patches now to topic/misc branch of sound git tree
> (i.e. for 2.6.40 kernel).

Patches look sane to me, you may add my ACK if you want.

Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>

> 
> I leave the removal of radio-maestro to v4l guys, as this is fairly
> independent.
> 
> 
> thanks,
> 
> Takashi
> 
> 
>> --- linux-2.6.38-rc4-orig/sound/i2c/other/tea575x-tuner.c	2011-02-08 01:03:55.000000000 +0100
>> +++ linux-2.6.38-rc4/sound/i2c/other/tea575x-tuner.c	2011-03-19 15:40:14.000000000 +0100
>> @@ -37,8 +37,8 @@ static int radio_nr = -1;
>>  module_param(radio_nr, int, 0);
>>  
>>  #define RADIO_VERSION KERNEL_VERSION(0, 0, 2)
>> -#define FREQ_LO		 (87 * 16000)
>> -#define FREQ_HI		(108 * 16000)
>> +#define FREQ_LO		 (50UL * 16000)
>> +#define FREQ_HI		(150UL * 16000)
>>  
>>  /*
>>   * definitions
>> @@ -77,15 +77,29 @@ static struct v4l2_queryctrl radio_qctrl
>>   * lowlevel part
>>   */
>>  
>> +static void snd_tea575x_get_freq(struct snd_tea575x *tea)
>> +{
>> +	unsigned long freq;
>> +
>> +	freq = tea->ops->read(tea) & TEA575X_BIT_FREQ_MASK;
>> +	/* freq *= 12.5 */
>> +	freq *= 125;
>> +	freq /= 10;
>> +	/* crystal fixup */
>> +	if (tea->tea5759)
>> +		freq += tea->freq_fixup;
>> +	else
>> +		freq -= tea->freq_fixup;
>> +
>> +	tea->freq = freq * 16;		/* from kHz */
>> +}
>> +
>>  static void snd_tea575x_set_freq(struct snd_tea575x *tea)
>>  {
>>  	unsigned long freq;
>>  
>> -	freq = tea->freq / 16;		/* to kHz */
>> -	if (freq > 108000)
>> -		freq = 108000;
>> -	if (freq < 87000)
>> -		freq = 87000;
>> +	freq = clamp(tea->freq, FREQ_LO, FREQ_HI);
>> +	freq /= 16;		/* to kHz */
>>  	/* crystal fixup */
>>  	if (tea->tea5759)
>>  		freq -= tea->freq_fixup;
>> @@ -109,29 +123,33 @@ static int vidioc_querycap(struct file *
>>  {
>>  	struct snd_tea575x *tea = video_drvdata(file);
>>  
>> -	strcpy(v->card, tea->tea5759 ? "TEA5759" : "TEA5757");
>>  	strlcpy(v->driver, "tea575x-tuner", sizeof(v->driver));
>> -	strlcpy(v->card, "Maestro Radio", sizeof(v->card));
>> +	strlcpy(v->card, tea->tea5759 ? "TEA5759" : "TEA5757", sizeof(v->card));
>>  	sprintf(v->bus_info, "PCI");
>>  	v->version = RADIO_VERSION;
>> -	v->capabilities = V4L2_CAP_TUNER;
>> +	v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
>>  	return 0;
>>  }
>>  
>>  static int vidioc_g_tuner(struct file *file, void *priv,
>>  					struct v4l2_tuner *v)
>>  {
>> +	struct snd_tea575x *tea = video_drvdata(file);
>> +
>>  	if (v->index > 0)
>>  		return -EINVAL;
>>  
>> +	tea->ops->read(tea);
>> +
>>  	strcpy(v->name, "FM");
>>  	v->type = V4L2_TUNER_RADIO;
>> +	v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
>>  	v->rangelow = FREQ_LO;
>>  	v->rangehigh = FREQ_HI;
>> -	v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
>> -	v->capability = V4L2_TUNER_CAP_LOW;
>> -	v->audmode = V4L2_TUNER_MODE_MONO;
>> -	v->signal = 0xffff;
>> +	v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
>> +	v->audmode = tea->stereo ? V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO;
>> +	v->signal = tea->tuned ? 0xffff : 0;
>> +
>>  	return 0;
>>  }
>>  
>> @@ -148,7 +166,10 @@ static int vidioc_g_frequency(struct fil
>>  {
>>  	struct snd_tea575x *tea = video_drvdata(file);
>>  
>> +	if (f->tuner != 0)
>> +		return -EINVAL;
>>  	f->type = V4L2_TUNER_RADIO;
>> +	snd_tea575x_get_freq(tea);
>>  	f->frequency = tea->freq;
>>  	return 0;
>>  }
>> @@ -158,6 +179,9 @@ static int vidioc_s_frequency(struct fil
>>  {
>>  	struct snd_tea575x *tea = video_drvdata(file);
>>  
>> +	if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
>> +		return -EINVAL;
>> +
>>  	if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
>>  		return -EINVAL;
>>  
>> --- linux-2.6.38-rc4-orig/include/sound/tea575x-tuner.h	2011-02-08 01:03:55.000000000 +0100
>> +++ linux-2.6.38-rc4/include/sound/tea575x-tuner.h	2011-03-19 14:18:06.000000000 +0100
>> @@ -38,8 +38,10 @@ struct snd_tea575x {
>>  	struct snd_card *card;
>>  	struct video_device *vd;	/* video device */
>>  	int dev_nr;			/* requested device number + 1 */
>> -	int tea5759;			/* 5759 chip is present */
>> -	int mute;			/* Device is muted? */
>> +	bool tea5759;			/* 5759 chip is present */
>> +	bool mute;			/* Device is muted? */
>> +	bool stereo;			/* receiving stereo */
>> +	bool tuned;			/* tuned to a station */
>>  	unsigned int freq_fixup;	/* crystal onboard */
>>  	unsigned int val;		/* hw value */
>>  	unsigned long freq;		/* frequency */
>>
>>
>> -- 
>> Ondrej Zary
>>
> --
> 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


  reply	other threads:[~2011-03-22 18:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-12 18:19 radio-maestro broken (conflicts with snd-es1968) Ondrej Zary
2011-03-12 18:52 ` Hans Verkuil
2011-03-14  9:53   ` [alsa-devel] " Takashi Iwai
2011-03-14  9:59     ` Hans Verkuil
2011-03-14 10:08       ` Takashi Iwai
2011-03-14 10:28       ` Ondrej Zary
2011-03-14 10:29         ` Takashi Iwai
2011-03-14 11:57         ` Hans Verkuil
2011-03-19 15:32           ` [RFC PATCH 1/3] tea575x-tuner: various improvements Ondrej Zary
2011-03-21 11:48             ` Takashi Iwai
2011-03-22 18:39               ` Mauro Carvalho Chehab [this message]
2011-03-22 19:02             ` Hans Verkuil
2011-03-25 21:40               ` Ondrej Zary
2011-03-26 10:19                 ` Hans Verkuil
2011-03-29 19:25                   ` Ondrej Zary
2011-03-29 19:39                     ` Hans Verkuil
2011-03-19 15:33           ` [RFC PATCH 2/3] tea575x-tuner: remove dev_nr Ondrej Zary
2011-03-19 15:33           ` [RFC PATCH 3/3] es1968: add radio (tea575x tuner) support Ondrej Zary
2011-03-19 16:23           ` [RFC PATCH 4/3] remove radio-maestro Ondrej Zary
2011-03-22 18:44             ` Mauro Carvalho Chehab
2011-03-23  7:13               ` Takashi Iwai
2011-03-22 19:03             ` Hans Verkuil
2011-03-14  9:46 ` [alsa-devel] radio-maestro broken (conflicts with snd-es1968) Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D88ECFD.9000706@gmail.com \
    --to=maurochehab@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=hverkuil@xs4all.nl \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).