Re: [PATCH v9 3/4] V4L2: WL1273 FM Radio: Controls for the FM radio.

2010-09-16 Thread Matti J. Aaltonen
Hi.

On Wed, 2010-09-08 at 21:09 +0200, ext Mauro Carvalho Chehab wrote:
> > +static int wl1273_fm_vidioc_s_tuner(struct file *file, void *priv,
> > +   struct v4l2_tuner *tuner)
> > +{
> > + struct wl1273_device *radio =
video_get_drvdata(video_devdata(file));
> > + struct wl1273_core *core = radio->core;
> > + int r = 0;
> > +
> > + dev_dbg(radio->dev, "%s\n", __func__);
> > + dev_dbg(radio->dev, "tuner->index: %d\n", tuner->index);
> > + dev_dbg(radio->dev, "tuner->name: %s\n", tuner->name);
> > + dev_dbg(radio->dev, "tuner->capability: 0x%04x\n",
tuner->capability);
> > + dev_dbg(radio->dev, "tuner->rxsubchans: 0x%04x\n",
tuner->rxsubchans);
> > + dev_dbg(radio->dev, "tuner->rangelow: %d\n", tuner->rangelow);
> > + dev_dbg(radio->dev, "tuner->rangehigh: %d\n",
tuner->rangehigh);
> 
> Ranges should be using tuner->rangelow/rangehigh to change band
limits.

I just want to make sure that I understand you correctly. So the idea is
that with the g_tuner the driver can tell the frequency range that's
supported by the chip in RX mode, which is 76MHz to 108 MHz. The lowest
part is in the Japan band and the highest is in the Europe/USA band, the
middle section can be either...

Then the application can choose any sub-range of the above by calling
s_tuner with any values rangelow > 76MHz and rangehigh < 108MHz? After
that the driver just deals with the given frequencies by changing the
band if necessary?

Cheers,
Matti


--
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


Re: [PATCH v9 3/4] V4L2: WL1273 FM Radio: Controls for the FM radio.

2010-09-15 Thread Matti J. Aaltonen
Hi.

On Wed, 2010-09-08 at 21:09 +0200, ext Mauro Carvalho Chehab wrote:
> > +static int wl1273_fm_vidioc_s_tuner(struct file *file, void *priv,
> > + struct v4l2_tuner *tuner)
> > +{
> > + struct wl1273_device *radio = video_get_drvdata(video_devdata(file));
> > + struct wl1273_core *core = radio->core;
> > + int r = 0;
> > +
> > + dev_dbg(radio->dev, "%s\n", __func__);
> > + dev_dbg(radio->dev, "tuner->index: %d\n", tuner->index);
> > + dev_dbg(radio->dev, "tuner->name: %s\n", tuner->name);
> > + dev_dbg(radio->dev, "tuner->capability: 0x%04x\n", tuner->capability);
> > + dev_dbg(radio->dev, "tuner->rxsubchans: 0x%04x\n", tuner->rxsubchans);
> > + dev_dbg(radio->dev, "tuner->rangelow: %d\n", tuner->rangelow);
> > + dev_dbg(radio->dev, "tuner->rangehigh: %d\n", tuner->rangehigh);
> 
> Ranges should be using tuner->rangelow/rangehigh to change band limits.

I just want to make sure that I understand you correctly. So the idea is
that with the g_tuner the driver can tell the frequency range that's
supported by the chip in RX mode, which is 76MHz to 108 MHz. The lowest
part is in the Japan band and the highest is in the Europe/USA band, the
middle section can be either...

Then the application can choose any sub-range of the above by calling
s_tuner with any values rangelow > 76MHz and rangehigh < 108MHz? After
that the driver just deals with the given frequencies by changing the
band if necessary?

Cheers,
Matti






--
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


Re: [PATCH v9 3/4] V4L2: WL1273 FM Radio: Controls for the FM radio.

2010-09-08 Thread Mauro Carvalho Chehab
Em 30-08-2010 08:38, Matti J. Aaltonen escreveu:
> This driver implements V4L2 controls for the Texas Instruments
> WL1273 FM Radio.
> 
> Signed-off-by: Matti J. Aaltonen 
> ---
>  drivers/media/radio/Kconfig|   15 +
>  drivers/media/radio/Makefile   |1 +
>  drivers/media/radio/radio-wl1273.c | 1935 
> 
>  drivers/mfd/Kconfig|5 +
>  drivers/mfd/Makefile   |2 +
>  5 files changed, 1958 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/radio/radio-wl1273.c
> 
> diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
> index 83567b8..209fd37 100644
> --- a/drivers/media/radio/Kconfig
> +++ b/drivers/media/radio/Kconfig
> @@ -452,4 +452,19 @@ config RADIO_TIMBERDALE
> found behind the Timberdale FPGA on the Russellville board.
> Enabling this driver will automatically select the DSP and tuner.
>  
> +config RADIO_WL1273
> + tristate "Texas Instruments WL1273 I2C FM Radio"
> +depends on I2C && VIDEO_V4L2 && SND
> + select FW_LOADER
> + ---help---
> +   Choose Y here if you have this FM radio chip.
> +
> +   In order to control your radio card, you will need to use programs
> +   that are compatible with the Video For Linux 2 API.  Information on
> +   this API and pointers to "v4l2" programs may be found at
> +   .
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called radio-wl1273.
> +
>  endif # RADIO_ADAPTERS
> diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
> index f615583..d297074 100644
> --- a/drivers/media/radio/Makefile
> +++ b/drivers/media/radio/Makefile
> @@ -26,5 +26,6 @@ obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
>  obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
>  obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
>  obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
> +obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
>  

>From what I saw, wl1273-core and radio-wl1273 are just part of the same radio 
>driver.
So, the better would be to just merge them into one driver module, with 
something like:

obj-wl1273.o = radio-wl1273.o wl1273-core.o
obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o

And remove all those export_symbol' s from wl1273-core.

>  EXTRA_CFLAGS += -Isound
> diff --git a/drivers/media/radio/radio-wl1273.c 
> b/drivers/media/radio/radio-wl1273.c
> new file mode 100644
> index 000..aa1eeed
> --- /dev/null
> +++ b/drivers/media/radio/radio-wl1273.c
> @@ -0,0 +1,1935 @@
> +/*
> + * Driver for the Texas Instruments WL1273 FM radio.
> + *
> + * Copyright (C) Nokia Corporation
> + * Author: Matti J. Aaltonen 
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRIVER_DESC "Wl1273 FM Radio - V4L2"

Why V4L2??? Just call it as "Wl1273 FM Radio".

> +
> +#define WL1273_POWER_SET_OFF 0
> +#define WL1273_POWER_SET_FM  (1 << 0)
> +#define WL1273_POWER_SET_RDS (1 << 1)
> +#define WL1273_POWER_SET_RETENTION   (1 << 4)
> +
> +#define WL1273_PUPD_SET_OFF  0x00
> +#define WL1273_PUPD_SET_ON   0x01
> +#define WL1273_PUPD_SET_RETENTION0x10
> +
> +#define WL1273_FREQ(x)   (x * 1 / 625)
> +#define WL1273_INV_FREQ(x)   (x * 625 / 1)
> +
> +/*
> + * static int radio_nr - The number of the radio device
> + *
> + * The default is 0.
> + */
> +static int radio_nr = -1;
> +module_param(radio_nr, int, 0);
> +MODULE_PARM_DESC(radio_nr, "Radio Nr");
> +
> +struct wl1273_device {
> + struct v4l2_ctrl_handler ctrl_handler;
> + struct v4l2_device v4l2dev;
> + struct video_device videodev;
> + struct device *dev;
> + struct wl1273_core *core;
> + struct file *owner;
> + char *write_buf;
> + unsigned int rds_users;
> +};
> +
> +static int wl1273_fm_set_tx_freq(struct wl1273_core *core, unsigned int freq)
> +{
> + int r = 0;
> +
> + if (freq < 76000) {
> + dev_err(&core->i2c_dev->dev,
> + "Frequency out of range: %d < %d\n",
> + freq, core->bands[core->band].bottom_frequency);
> + return -ERANGE;
> + }
> +
> + if (freq > 108000) {
> + dev_err(&core->i2c

[PATCH v9 3/4] V4L2: WL1273 FM Radio: Controls for the FM radio.

2010-08-30 Thread Matti J. Aaltonen
This driver implements V4L2 controls for the Texas Instruments
WL1273 FM Radio.

Signed-off-by: Matti J. Aaltonen 
---
 drivers/media/radio/Kconfig|   15 +
 drivers/media/radio/Makefile   |1 +
 drivers/media/radio/radio-wl1273.c | 1935 
 drivers/mfd/Kconfig|5 +
 drivers/mfd/Makefile   |2 +
 5 files changed, 1958 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/radio-wl1273.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 83567b8..209fd37 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -452,4 +452,19 @@ config RADIO_TIMBERDALE
  found behind the Timberdale FPGA on the Russellville board.
  Enabling this driver will automatically select the DSP and tuner.
 
+config RADIO_WL1273
+   tristate "Texas Instruments WL1273 I2C FM Radio"
+depends on I2C && VIDEO_V4L2 && SND
+   select FW_LOADER
+   ---help---
+ Choose Y here if you have this FM radio chip.
+
+ In order to control your radio card, you will need to use programs
+ that are compatible with the Video For Linux 2 API.  Information on
+ this API and pointers to "v4l2" programs may be found at
+ .
+
+ To compile this driver as a module, choose M here: the
+ module will be called radio-wl1273.
+
 endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index f615583..d297074 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -26,5 +26,6 @@ obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
 obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o
+obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o
 
 EXTRA_CFLAGS += -Isound
diff --git a/drivers/media/radio/radio-wl1273.c 
b/drivers/media/radio/radio-wl1273.c
new file mode 100644
index 000..aa1eeed
--- /dev/null
+++ b/drivers/media/radio/radio-wl1273.c
@@ -0,0 +1,1935 @@
+/*
+ * Driver for the Texas Instruments WL1273 FM radio.
+ *
+ * Copyright (C) Nokia Corporation
+ * Author: Matti J. Aaltonen 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRIVER_DESC "Wl1273 FM Radio - V4L2"
+
+#define WL1273_POWER_SET_OFF   0
+#define WL1273_POWER_SET_FM(1 << 0)
+#define WL1273_POWER_SET_RDS   (1 << 1)
+#define WL1273_POWER_SET_RETENTION (1 << 4)
+
+#define WL1273_PUPD_SET_OFF0x00
+#define WL1273_PUPD_SET_ON 0x01
+#define WL1273_PUPD_SET_RETENTION  0x10
+
+#define WL1273_FREQ(x) (x * 1 / 625)
+#define WL1273_INV_FREQ(x) (x * 625 / 1)
+
+/*
+ * static int radio_nr - The number of the radio device
+ *
+ * The default is 0.
+ */
+static int radio_nr = -1;
+module_param(radio_nr, int, 0);
+MODULE_PARM_DESC(radio_nr, "Radio Nr");
+
+struct wl1273_device {
+   struct v4l2_ctrl_handler ctrl_handler;
+   struct v4l2_device v4l2dev;
+   struct video_device videodev;
+   struct device *dev;
+   struct wl1273_core *core;
+   struct file *owner;
+   char *write_buf;
+   unsigned int rds_users;
+};
+
+static int wl1273_fm_set_tx_freq(struct wl1273_core *core, unsigned int freq)
+{
+   int r = 0;
+
+   if (freq < 76000) {
+   dev_err(&core->i2c_dev->dev,
+   "Frequency out of range: %d < %d\n",
+   freq, core->bands[core->band].bottom_frequency);
+   return -ERANGE;
+   }
+
+   if (freq > 108000) {
+   dev_err(&core->i2c_dev->dev,
+   "Frequency out of range: %d > %d\n",
+   freq, core->bands[core->band].top_frequency);
+   return -ERANGE;
+   }
+
+   /*
+*  The driver works better with this sleep,
+*  the documentation doesn't mention it.
+*/
+   usleep_range(5000, 1);
+
+   dev_dbg(&core->i2c_dev->dev, "%s: freq: %d kHz\n", __func__, freq);
+
+   INIT_COMPLETION(core->busy);
+   /* Set the current tx channel */
+   r = wl1273_fm_write_cmd(core, WL1273_CHANL_SET, freq / 10);
+   if (r)
+   return r;
+
+