Re: [PATCH v2 5/6] Add a V4L2 driver for SI476X MFD

2012-10-09 Thread Hans Verkuil
Note: I'm CC-ing Halli. Halli, can you take a look at the proposed controls?

On Mon 8 October 2012 19:57:17 Andrey Smirnov wrote:
 On 10/08/2012 02:30 AM, Hans Verkuil wrote:
  On Sat October 6 2012 03:55:01 Andrey Smirnov wrote:
  This commit adds a driver that exposes all the radio related
  functionality of the Si476x series of chips via the V4L2 subsystem.
 
  Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
  ---
   drivers/media/radio/Kconfig|   17 +
   drivers/media/radio/Makefile   |1 +
   drivers/media/radio/radio-si476x.c | 1153 
  
   3 files changed, 1171 insertions(+)
   create mode 100644 drivers/media/radio/radio-si476x.c
 
  diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
  index 8090b87..3c79d09 100644
  --- a/drivers/media/radio/Kconfig
  +++ b/drivers/media/radio/Kconfig

snip

  +static const struct v4l2_ctrl_config si476x_ctrls[] = {
  +  /*
  + Tuning parameters
  + 'max tune errors' is shared for both AM/FM mode of operation
  +  */
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_RSSI_THRESHOLD,
  +  .name   = valid rssi threshold,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .min= -128,
  +  .max= 127,
  +  .step   = 1,
  +  },
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_SNR_THRESHOLD,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .name   = valid snr threshold,
  +  .min= -128,
  +  .max= 127,
  +  .step   = 1,
  +  },
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_MAX_TUNE_ERROR,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .name   = max tune errors,
  +  .min= 0,
  +  .max= 126 * 2,
  +  .step   = 2,
  +  },
  +  /*
  + Region specific parameters
  +  */
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_HARMONICS_COUNT,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .name   = count of harmonics to reject,
  +  .min= 0,
  +  .max= 20,
  +  .step   = 1,
  +  },
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_DEEMPHASIS,
  +  .type   = V4L2_CTRL_TYPE_MENU,
  +  .name   = de-emphassis,
  +  .qmenu  = deemphasis,
  +  .min= 0,
  +  .max= ARRAY_SIZE(deemphasis) - 1,
  +  .def= 0,
  +  },
  I think most if not all of the controls above are candidates for turning 
  into
  standardized controls. I recommend that you make a proposal (RFC) for this.
 
  This may be useful as well:
 
  http://lists-archives.com/linux-kernel/27641304-radio-fixes-and-new-features-for-fm.html
 
  This patch series contains a standardized DEEMPHASIS control.
  Note that this patch series is outdated, but patch 2/5 is OK.
 
 So do you want me to take that patch and make it the part of this patch
 set or do you want me to create a separate RFC with a patch set that
 contains all those controls?

No, that was just FYI. I've asked Halli Manjunatha, the author of that patch
series to make a new version that can be upstreamed. The reason it was stalled
was due to a long discussion at the time how to implement multiple frequency
bands, but now that that has been resolved this patch series can move forward
as well.

 
 Just to give some description:
 
 SI476X_CID_RSSI_THRESHOLD, SI476X_CID_SNR_THRESHOLD,
 SI476X_CID_MAX_TUNE_ERROR are used to determine at which level of SNR,
 RSSI the station station should be considered valid and what margin of
 error is to be used(SI476X_CID_MAX_TUNE_ERROR) for those parameters.

I know that other devices (wl128x) also have similar SNR, RSSI functionality.
Halli, can you check if it would make sense to have generic controls for this?

 SI476X_CID_HARMONICS_COUNT is the amount of AC grid noise harmonics
 build-in hardware(or maybe FW) will try to filter out in AM mode.

I don't really know whether this is chip specific or not. Halli, do you
have any input on this?

 It seems to me that the controls described above are quite chip specific
 should I also include them in the RFC?

Let's wait what Halli says, but yes, it should be included in the RFC: we
want to know if this should be standardized or not, so it's good to
mention it so people are aware of this.

  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_RDS_RECEPTION,
  +  .type   = V4L2_CTRL_TYPE_BOOLEAN,
  +  .name   = rds,
  +  .min= 0,
  +  .max= 1,
  +  .step   = 1,
  +  },
  If this control returns whether or not RDS is detected, then this control
  should be removed. VIDIOC_G_TUNER will return that information in 
  rxsubchans.
 
 This control allows to turn on/off RDS processing on the radio chip
 itself. In IRQ mode in decreases the 

Re: [PATCH v2 5/6] Add a V4L2 driver for SI476X MFD

2012-10-09 Thread halli manjunatha
On Tue, Oct 9, 2012 at 4:38 AM, Hans Verkuil hverk...@xs4all.nl wrote:
 Note: I'm CC-ing Halli. Halli, can you take a look at the proposed controls?

 On Mon 8 October 2012 19:57:17 Andrey Smirnov wrote:
 On 10/08/2012 02:30 AM, Hans Verkuil wrote:
  On Sat October 6 2012 03:55:01 Andrey Smirnov wrote:
  This commit adds a driver that exposes all the radio related
  functionality of the Si476x series of chips via the V4L2 subsystem.
 
  Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
  ---
   drivers/media/radio/Kconfig|   17 +
   drivers/media/radio/Makefile   |1 +
   drivers/media/radio/radio-si476x.c | 1153 
  
   3 files changed, 1171 insertions(+)
   create mode 100644 drivers/media/radio/radio-si476x.c
 
  diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
  index 8090b87..3c79d09 100644
  --- a/drivers/media/radio/Kconfig
  +++ b/drivers/media/radio/Kconfig

 snip

  +static const struct v4l2_ctrl_config si476x_ctrls[] = {
  +  /*
  + Tuning parameters
  + 'max tune errors' is shared for both AM/FM mode of operation
  +  */
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_RSSI_THRESHOLD,
  +  .name   = valid rssi threshold,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .min= -128,
  +  .max= 127,
  +  .step   = 1,
  +  },
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_SNR_THRESHOLD,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .name   = valid snr threshold,
  +  .min= -128,
  +  .max= 127,
  +  .step   = 1,
  +  },
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_MAX_TUNE_ERROR,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .name   = max tune errors,
  +  .min= 0,
  +  .max= 126 * 2,
  +  .step   = 2,
  +  },
  +  /*
  + Region specific parameters
  +  */
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_HARMONICS_COUNT,
  +  .type   = V4L2_CTRL_TYPE_INTEGER,
  +  .name   = count of harmonics to reject,
  +  .min= 0,
  +  .max= 20,
  +  .step   = 1,
  +  },
  +  {
  +  .ops= si476x_ctrl_ops,
  +  .id = SI476X_CID_DEEMPHASIS,
  +  .type   = V4L2_CTRL_TYPE_MENU,
  +  .name   = de-emphassis,
  +  .qmenu  = deemphasis,
  +  .min= 0,
  +  .max= ARRAY_SIZE(deemphasis) - 1,
  +  .def= 0,
  +  },
  I think most if not all of the controls above are candidates for turning 
  into
  standardized controls. I recommend that you make a proposal (RFC) for this.
 
  This may be useful as well:
 
  http://lists-archives.com/linux-kernel/27641304-radio-fixes-and-new-features-for-fm.html
 
  This patch series contains a standardized DEEMPHASIS control.
  Note that this patch series is outdated, but patch 2/5 is OK.

 So do you want me to take that patch and make it the part of this patch
 set or do you want me to create a separate RFC with a patch set that
 contains all those controls?

 No, that was just FYI. I've asked Halli Manjunatha, the author of that patch
 series to make a new version that can be upstreamed. The reason it was stalled
 was due to a long discussion at the time how to implement multiple frequency
 bands, but now that that has been resolved this patch series can move forward
 as well.


 Just to give some description:

 SI476X_CID_RSSI_THRESHOLD, SI476X_CID_SNR_THRESHOLD,
 SI476X_CID_MAX_TUNE_ERROR are used to determine at which level of SNR,
 RSSI the station station should be considered valid and what margin of
 error is to be used(SI476X_CID_MAX_TUNE_ERROR) for those parameters.

 I know that other devices (wl128x) also have similar SNR, RSSI functionality.
 Halli, can you check if it would make sense to have generic controls for this?

Yes, since depending on RSSI_THRESHOLD value driver has to decide
whether its a good channel or not or whether to consider the RDS data
coming from that channel valid

So I do recommend that we need to have these as generic controls

 SI476X_CID_HARMONICS_COUNT is the amount of AC grid noise harmonics
 build-in hardware(or maybe FW) will try to filter out in AM mode.

 I don't really know whether this is chip specific or not. Halli, do you
 have any input on this?

Seems like chip specific to me, for instant TI's FM chip-sets doesn't
have a control for ignoring HARMONICS but as Smirnov says his chip set
has these controls so in that case its better to include these in RFC
so that people can have a look in to it.

 It seems to me that the controls described above are quite chip specific
 should I also include them in the RFC?

 Let's wait what Halli says, but yes, it should be included in the RFC: we
 want to know if this should be standardized or not, so it's good to
 

Re: [PATCH v2 5/6] Add a V4L2 driver for SI476X MFD

2012-10-08 Thread Hans Verkuil
On Sat October 6 2012 03:55:01 Andrey Smirnov wrote:
 This commit adds a driver that exposes all the radio related
 functionality of the Si476x series of chips via the V4L2 subsystem.
 
 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/media/radio/Kconfig|   17 +
  drivers/media/radio/Makefile   |1 +
  drivers/media/radio/radio-si476x.c | 1153 
 
  3 files changed, 1171 insertions(+)
  create mode 100644 drivers/media/radio/radio-si476x.c
 
 diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
 index 8090b87..3c79d09 100644
 --- a/drivers/media/radio/Kconfig
 +++ b/drivers/media/radio/Kconfig
 @@ -16,6 +16,23 @@ config RADIO_SI470X
   bool Silicon Labs Si470x FM Radio Receiver support
   depends on VIDEO_V4L2
  
 +config RADIO_SI476X
 + tristate Silicon Laboratories Si476x I2C FM Radio
 + depends on I2C  VIDEO_V4L2
 + select MFD_CORE
 + select MFD_SI476X_CORE
 + select SND_SOC_SI476X
 + ---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
 +   file:Documentation/video4linux/API.html.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called radio-si476x.
 +
  source drivers/media/radio/si470x/Kconfig
  
  config USB_MR800
 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
 index c03ce4f..c4618e0 100644
 --- a/drivers/media/radio/Makefile
 +++ b/drivers/media/radio/Makefile
 @@ -19,6 +19,7 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
  obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
  obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
  obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
 +obj-$(CONFIG_RADIO_SI476X) += radio-si476x.o
  obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
  obj-$(CONFIG_USB_DSBR) += dsbr100.o
  obj-$(CONFIG_RADIO_SI470X) += si470x/
 diff --git a/drivers/media/radio/radio-si476x.c 
 b/drivers/media/radio/radio-si476x.c
 new file mode 100644
 index 000..2d943da
 --- /dev/null
 +++ b/drivers/media/radio/radio-si476x.c
 @@ -0,0 +1,1153 @@
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/interrupt.h
 +#include linux/slab.h
 +#include linux/atomic.h
 +#include linux/videodev2.h
 +#include linux/mutex.h
 +#include media/v4l2-common.h
 +#include media/v4l2-ioctl.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-event.h
 +#include media/v4l2-device.h
 +
 +#include linux/mfd/si476x-core.h
 +
 +#define FM_FREQ_RANGE_LOW   6400
 +#define FM_FREQ_RANGE_HIGH 10800
 +
 +#define AM_FREQ_RANGE_LOW52
 +#define AM_FREQ_RANGE_HIGH 3000
 +
 +#define PWRLINEFLTR (1  8)
 +
 +#define FREQ_MUL (1000 / 625)
 +
 +#define DRIVER_NAME si476x-radio
 +#define DRIVER_CARD SI476x AM/FM Receiver
 +
 +enum si476x_freq_bands {
 + SI476X_BAND_FM,
 + SI476X_BAND_AM,
 +};
 +
 +static const struct v4l2_frequency_band si476x_bands[] = {
 + [SI476X_BAND_FM] = {
 + .type   = V4L2_TUNER_RADIO,
 + .index  = SI476X_BAND_FM,
 + .capability = V4L2_TUNER_CAP_LOW
 + | V4L2_TUNER_CAP_STEREO
 + | V4L2_TUNER_CAP_RDS
 + | V4L2_TUNER_CAP_RDS_BLOCK_IO
 + | V4L2_TUNER_CAP_FREQ_BANDS,
 + .rangelow   =  64 * FREQ_MUL,
 + .rangehigh  = 108 * FREQ_MUL,
 + .modulation = V4L2_BAND_MODULATION_FM,
 + },
 + [SI476X_BAND_AM] = {
 + .type   = V4L2_TUNER_RADIO,
 + .index  = SI476X_BAND_AM,
 + .capability = V4L2_TUNER_CAP_LOW | 
 V4L2_TUNER_CAP_FREQ_BANDS,
 + .rangelow   = 0.52 * FREQ_MUL,
 + .rangehigh  = 30 * FREQ_MUL,
 + .modulation = V4L2_BAND_MODULATION_AM,
 + },
 +};
 +
 +#define PRIVATE_CTL_IDX(x) (x - V4L2_CID_PRIVATE_BASE)
 +
 +static int si476x_s_ctrl(struct v4l2_ctrl *ctrl);
 +
 +static const char * const deemphasis[] = {
 + 75 us,
 + 50 us,
 +};
 +
 +static const struct v4l2_ctrl_ops si476x_ctrl_ops = {
 + .s_ctrl = si476x_s_ctrl,
 +};
 +
 +static const struct v4l2_ctrl_config si476x_ctrls[] = {
 + /*
 +Tuning parameters
 +'max tune errors' is shared for both AM/FM mode of operation
 + */
 + {
 + .ops= si476x_ctrl_ops,
 + .id = SI476X_CID_RSSI_THRESHOLD,
 + .name   = valid rssi threshold,
 + .type   = V4L2_CTRL_TYPE_INTEGER,
 + .min= -128,
 + .max= 127,
 + .step   = 1,
 + },
 + {
 + .ops= si476x_ctrl_ops,
 + .id = SI476X_CID_SNR_THRESHOLD,
 + .type   = V4L2_CTRL_TYPE_INTEGER,
 + .name   = valid snr 

Re: [PATCH v2 5/6] Add a V4L2 driver for SI476X MFD

2012-10-08 Thread Andrey Smirnov
On 10/08/2012 02:30 AM, Hans Verkuil wrote:
 On Sat October 6 2012 03:55:01 Andrey Smirnov wrote:
 This commit adds a driver that exposes all the radio related
 functionality of the Si476x series of chips via the V4L2 subsystem.

 Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
 ---
  drivers/media/radio/Kconfig|   17 +
  drivers/media/radio/Makefile   |1 +
  drivers/media/radio/radio-si476x.c | 1153 
 
  3 files changed, 1171 insertions(+)
  create mode 100644 drivers/media/radio/radio-si476x.c

 diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
 index 8090b87..3c79d09 100644
 --- a/drivers/media/radio/Kconfig
 +++ b/drivers/media/radio/Kconfig
 @@ -16,6 +16,23 @@ config RADIO_SI470X
  bool Silicon Labs Si470x FM Radio Receiver support
  depends on VIDEO_V4L2
  
 +config RADIO_SI476X
 +tristate Silicon Laboratories Si476x I2C FM Radio
 +depends on I2C  VIDEO_V4L2
 +select MFD_CORE
 +select MFD_SI476X_CORE
 +select SND_SOC_SI476X
 +---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
 +  file:Documentation/video4linux/API.html.
 +
 +  To compile this driver as a module, choose M here: the
 +  module will be called radio-si476x.
 +
  source drivers/media/radio/si470x/Kconfig
  
  config USB_MR800
 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
 index c03ce4f..c4618e0 100644
 --- a/drivers/media/radio/Makefile
 +++ b/drivers/media/radio/Makefile
 @@ -19,6 +19,7 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
  obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
  obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
  obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
 +obj-$(CONFIG_RADIO_SI476X) += radio-si476x.o
  obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
  obj-$(CONFIG_USB_DSBR) += dsbr100.o
  obj-$(CONFIG_RADIO_SI470X) += si470x/
 diff --git a/drivers/media/radio/radio-si476x.c 
 b/drivers/media/radio/radio-si476x.c
 new file mode 100644
 index 000..2d943da
 --- /dev/null
 +++ b/drivers/media/radio/radio-si476x.c
 @@ -0,0 +1,1153 @@
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/interrupt.h
 +#include linux/slab.h
 +#include linux/atomic.h
 +#include linux/videodev2.h
 +#include linux/mutex.h
 +#include media/v4l2-common.h
 +#include media/v4l2-ioctl.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-event.h
 +#include media/v4l2-device.h
 +
 +#include linux/mfd/si476x-core.h
 +
 +#define FM_FREQ_RANGE_LOW   6400
 +#define FM_FREQ_RANGE_HIGH 10800
 +
 +#define AM_FREQ_RANGE_LOW52
 +#define AM_FREQ_RANGE_HIGH 3000
 +
 +#define PWRLINEFLTR (1  8)
 +
 +#define FREQ_MUL (1000 / 625)
 +
 +#define DRIVER_NAME si476x-radio
 +#define DRIVER_CARD SI476x AM/FM Receiver
 +
 +enum si476x_freq_bands {
 +SI476X_BAND_FM,
 +SI476X_BAND_AM,
 +};
 +
 +static const struct v4l2_frequency_band si476x_bands[] = {
 +[SI476X_BAND_FM] = {
 +.type   = V4L2_TUNER_RADIO,
 +.index  = SI476X_BAND_FM,
 +.capability = V4L2_TUNER_CAP_LOW
 +| V4L2_TUNER_CAP_STEREO
 +| V4L2_TUNER_CAP_RDS
 +| V4L2_TUNER_CAP_RDS_BLOCK_IO
 +| V4L2_TUNER_CAP_FREQ_BANDS,
 +.rangelow   =  64 * FREQ_MUL,
 +.rangehigh  = 108 * FREQ_MUL,
 +.modulation = V4L2_BAND_MODULATION_FM,
 +},
 +[SI476X_BAND_AM] = {
 +.type   = V4L2_TUNER_RADIO,
 +.index  = SI476X_BAND_AM,
 +.capability = V4L2_TUNER_CAP_LOW | 
 V4L2_TUNER_CAP_FREQ_BANDS,
 +.rangelow   = 0.52 * FREQ_MUL,
 +.rangehigh  = 30 * FREQ_MUL,
 +.modulation = V4L2_BAND_MODULATION_AM,
 +},
 +};
 +
 +#define PRIVATE_CTL_IDX(x) (x - V4L2_CID_PRIVATE_BASE)
 +
 +static int si476x_s_ctrl(struct v4l2_ctrl *ctrl);
 +
 +static const char * const deemphasis[] = {
 +75 us,
 +50 us,
 +};
 +
 +static const struct v4l2_ctrl_ops si476x_ctrl_ops = {
 +.s_ctrl = si476x_s_ctrl,
 +};
 +
 +static const struct v4l2_ctrl_config si476x_ctrls[] = {
 +/*
 +   Tuning parameters
 +   'max tune errors' is shared for both AM/FM mode of operation
 +*/
 +{
 +.ops= si476x_ctrl_ops,
 +.id = SI476X_CID_RSSI_THRESHOLD,
 +.name   = valid rssi threshold,
 +.type   = V4L2_CTRL_TYPE_INTEGER,
 +.min= -128,
 +.max= 127,
 +.step   = 1,
 +},
 +{
 +.ops= si476x_ctrl_ops,
 +.id = SI476X_CID_SNR_THRESHOLD,
 +.type   = V4L2_CTRL_TYPE_INTEGER,
 +.name   = valid snr threshold,
 + 

[PATCH v2 5/6] Add a V4L2 driver for SI476X MFD

2012-10-05 Thread Andrey Smirnov
This commit adds a driver that exposes all the radio related
functionality of the Si476x series of chips via the V4L2 subsystem.

Signed-off-by: Andrey Smirnov andrey.smir...@convergeddevices.net
---
 drivers/media/radio/Kconfig|   17 +
 drivers/media/radio/Makefile   |1 +
 drivers/media/radio/radio-si476x.c | 1153 
 3 files changed, 1171 insertions(+)
 create mode 100644 drivers/media/radio/radio-si476x.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 8090b87..3c79d09 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -16,6 +16,23 @@ config RADIO_SI470X
bool Silicon Labs Si470x FM Radio Receiver support
depends on VIDEO_V4L2
 
+config RADIO_SI476X
+   tristate Silicon Laboratories Si476x I2C FM Radio
+   depends on I2C  VIDEO_V4L2
+   select MFD_CORE
+   select MFD_SI476X_CORE
+   select SND_SOC_SI476X
+   ---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
+ file:Documentation/video4linux/API.html.
+
+ To compile this driver as a module, choose M here: the
+ module will be called radio-si476x.
+
 source drivers/media/radio/si470x/Kconfig
 
 config USB_MR800
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index c03ce4f..c4618e0 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
 obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
 obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
 obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
+obj-$(CONFIG_RADIO_SI476X) += radio-si476x.o
 obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
 obj-$(CONFIG_USB_DSBR) += dsbr100.o
 obj-$(CONFIG_RADIO_SI470X) += si470x/
diff --git a/drivers/media/radio/radio-si476x.c 
b/drivers/media/radio/radio-si476x.c
new file mode 100644
index 000..2d943da
--- /dev/null
+++ b/drivers/media/radio/radio-si476x.c
@@ -0,0 +1,1153 @@
+#include linux/module.h
+#include linux/delay.h
+#include linux/interrupt.h
+#include linux/slab.h
+#include linux/atomic.h
+#include linux/videodev2.h
+#include linux/mutex.h
+#include media/v4l2-common.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-event.h
+#include media/v4l2-device.h
+
+#include linux/mfd/si476x-core.h
+
+#define FM_FREQ_RANGE_LOW   6400
+#define FM_FREQ_RANGE_HIGH 10800
+
+#define AM_FREQ_RANGE_LOW52
+#define AM_FREQ_RANGE_HIGH 3000
+
+#define PWRLINEFLTR (1  8)
+
+#define FREQ_MUL (1000 / 625)
+
+#define DRIVER_NAME si476x-radio
+#define DRIVER_CARD SI476x AM/FM Receiver
+
+enum si476x_freq_bands {
+   SI476X_BAND_FM,
+   SI476X_BAND_AM,
+};
+
+static const struct v4l2_frequency_band si476x_bands[] = {
+   [SI476X_BAND_FM] = {
+   .type   = V4L2_TUNER_RADIO,
+   .index  = SI476X_BAND_FM,
+   .capability = V4L2_TUNER_CAP_LOW
+   | V4L2_TUNER_CAP_STEREO
+   | V4L2_TUNER_CAP_RDS
+   | V4L2_TUNER_CAP_RDS_BLOCK_IO
+   | V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   =  64 * FREQ_MUL,
+   .rangehigh  = 108 * FREQ_MUL,
+   .modulation = V4L2_BAND_MODULATION_FM,
+   },
+   [SI476X_BAND_AM] = {
+   .type   = V4L2_TUNER_RADIO,
+   .index  = SI476X_BAND_AM,
+   .capability = V4L2_TUNER_CAP_LOW | 
V4L2_TUNER_CAP_FREQ_BANDS,
+   .rangelow   = 0.52 * FREQ_MUL,
+   .rangehigh  = 30 * FREQ_MUL,
+   .modulation = V4L2_BAND_MODULATION_AM,
+   },
+};
+
+#define PRIVATE_CTL_IDX(x) (x - V4L2_CID_PRIVATE_BASE)
+
+static int si476x_s_ctrl(struct v4l2_ctrl *ctrl);
+
+static const char * const deemphasis[] = {
+   75 us,
+   50 us,
+};
+
+static const struct v4l2_ctrl_ops si476x_ctrl_ops = {
+   .s_ctrl = si476x_s_ctrl,
+};
+
+static const struct v4l2_ctrl_config si476x_ctrls[] = {
+   /*
+  Tuning parameters
+  'max tune errors' is shared for both AM/FM mode of operation
+   */
+   {
+   .ops= si476x_ctrl_ops,
+   .id = SI476X_CID_RSSI_THRESHOLD,
+   .name   = valid rssi threshold,
+   .type   = V4L2_CTRL_TYPE_INTEGER,
+   .min= -128,
+   .max= 127,
+   .step   = 1,
+   },
+   {
+   .ops= si476x_ctrl_ops,
+   .id = SI476X_CID_SNR_THRESHOLD,
+   .type   = V4L2_CTRL_TYPE_INTEGER,
+   .name   = valid snr threshold,
+   .min= -128,
+   .max= 127,
+