[PATCH v3 1/1] radio: Add radio-timb

2010-02-03 Thread Richard Röjfors

This patch add supports for the radio system on the Intel Russellville board.

It's a In-Vehicle Infotainment board with a radio tuner and DSP.

This umbrella driver has the DSP and tuner as V4L2 subdevs and calls them
when needed.

Signed-off-by: Richard Röjfors richard.rojf...@pelagicore.com
---
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 3f40f37..c242939 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -429,4 +429,14 @@ config RADIO_TEF6862
  To compile this driver as a module, choose M here: the
  module will be called TEF6862.

+config RADIO_TIMBERDALE
+   tristate Enable the Timberdale radio driver
+   depends on MFD_TIMBERDALE  VIDEO_V4L2
+   select RADIO_TEF6862
+   select RADIO_SAA7706H
+   ---help---
+ This is a kind of umbrella driver for the Radio Tuner and DSP
+ found behind the Timberdale FPGA on the Russellville board.
+ Enabling this driver will automatically select the DSP and tuner.
+
 endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 01922ad..8973850 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -24,5 +24,6 @@ obj-$(CONFIG_RADIO_SI470X) += si470x/
 obj-$(CONFIG_USB_MR800) += radio-mr800.o
 obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
+obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o

 EXTRA_CFLAGS += -Isound
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
new file mode 100644
index 000..c650865
--- /dev/null
+++ b/drivers/media/radio/radio-timb.c
@@ -0,0 +1,260 @@
+/*
+ * radio-timb.c Timberdale FPGA Radio driver
+ * Copyright (c) 2009 Intel Corporation
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/version.h
+#include linux/io.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-device.h
+#include linux/platform_device.h
+#include linux/interrupt.h
+#include linux/i2c.h
+#include media/timb_radio.h
+
+#define DRIVER_NAME timb-radio
+
+struct timbradio {
+   struct timb_radio_platform_data pdata;
+   struct v4l2_subdev  *sd_tuner;
+   struct v4l2_subdev  *sd_dsp;
+   struct video_device *video_dev;
+   struct v4l2_device  v4l2_dev;
+};
+
+
+static int timbradio_vidioc_querycap(struct file *file, void  *priv,
+   struct v4l2_capability *v)
+{
+   strlcpy(v-driver, DRIVER_NAME, sizeof(v-driver));
+   strlcpy(v-card, Timberdale Radio, sizeof(v-card));
+   snprintf(v-bus_info, sizeof(v-bus_info), platform:DRIVER_NAME);
+   v-version = KERNEL_VERSION(0, 0, 1);
+   v-capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
+   return 0;
+}
+
+static int timbradio_vidioc_g_tuner(struct file *file, void *priv,
+   struct v4l2_tuner *v)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, g_tuner, v);
+}
+
+static int timbradio_vidioc_s_tuner(struct file *file, void *priv,
+   struct v4l2_tuner *v)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, s_tuner, v);
+}
+
+static int timbradio_vidioc_g_input(struct file *filp, void *priv,
+   unsigned int *i)
+{
+   *i = 0;
+   return 0;
+}
+
+static int timbradio_vidioc_s_input(struct file *filp, void *priv,
+   unsigned int i)
+{
+   return i ? -EINVAL : 0;
+}
+
+static int timbradio_vidioc_g_audio(struct file *file, void *priv,
+   struct v4l2_audio *a)
+{
+   a-index = 0;
+   strlcpy(a-name, Radio, sizeof(a-name));
+   a-capability = V4L2_AUDCAP_STEREO;
+   return 0;
+}
+
+
+static int timbradio_vidioc_s_audio(struct file *file, void *priv,
+   struct v4l2_audio *a)
+{
+   return a-index ? -EINVAL : 0;
+}
+
+static int timbradio_vidioc_s_frequency(struct file *file, void *priv,
+   struct v4l2_frequency *f)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, s_frequency, f);
+}
+
+static int timbradio_vidioc_g_frequency(struct file *file, void *priv,
+   struct v4l2_frequency *f)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, g_frequency, f);
+}
+
+static int timbradio_vidioc_queryctrl(struct file *file, void *priv,

Re: [PATCH v3 1/1] radio: Add radio-timb

2010-02-03 Thread Hans Verkuil

Hi Richard,

On Wed, 3 Feb 2010, Richard R?jfors wrote:


This patch add supports for the radio system on the Intel Russellville board.

It's a In-Vehicle Infotainment board with a radio tuner and DSP.

This umbrella driver has the DSP and tuner as V4L2 subdevs and calls them
when needed.

Signed-off-by: Richard R?jfors richard.rojf...@pelagicore.com
---
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 3f40f37..c242939 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -429,4 +429,14 @@ config RADIO_TEF6862
  To compile this driver as a module, choose M here: the
  module will be called TEF6862.

+config RADIO_TIMBERDALE
+   tristate Enable the Timberdale radio driver
+   depends on MFD_TIMBERDALE  VIDEO_V4L2
+   select RADIO_TEF6862
+   select RADIO_SAA7706H
+   ---help---
+ This is a kind of umbrella driver for the Radio Tuner and DSP
+ found behind the Timberdale FPGA on the Russellville board.
+ Enabling this driver will automatically select the DSP and tuner.
+
endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 01922ad..8973850 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -24,5 +24,6 @@ obj-$(CONFIG_RADIO_SI470X) += si470x/
obj-$(CONFIG_USB_MR800) += radio-mr800.o
obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
+obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o

EXTRA_CFLAGS += -Isound
diff --git a/drivers/media/radio/radio-timb.c 
b/drivers/media/radio/radio-timb.c

new file mode 100644
index 000..c650865
--- /dev/null
+++ b/drivers/media/radio/radio-timb.c
@@ -0,0 +1,260 @@
+/*
+ * radio-timb.c Timberdale FPGA Radio driver
+ * Copyright (c) 2009 Intel Corporation
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/version.h
+#include linux/io.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-device.h
+#include linux/platform_device.h
+#include linux/interrupt.h
+#include linux/i2c.h
+#include media/timb_radio.h
+
+#define DRIVER_NAME timb-radio
+
+struct timbradio {
+   struct timb_radio_platform_data pdata;
+   struct v4l2_subdev  *sd_tuner;
+   struct v4l2_subdev  *sd_dsp;
+   struct video_device *video_dev;


Recommend removing '*' here. See notes below.


+   struct v4l2_device  v4l2_dev;
+};
+
+
+static int timbradio_vidioc_querycap(struct file *file, void  *priv,
+   struct v4l2_capability *v)
+{
+   strlcpy(v-driver, DRIVER_NAME, sizeof(v-driver));
+   strlcpy(v-card, Timberdale Radio, sizeof(v-card));
+   snprintf(v-bus_info, sizeof(v-bus_info), platform:DRIVER_NAME);
+   v-version = KERNEL_VERSION(0, 0, 1);
+   v-capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
+   return 0;
+}
+
+static int timbradio_vidioc_g_tuner(struct file *file, void *priv,
+   struct v4l2_tuner *v)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, g_tuner, v);
+}
+
+static int timbradio_vidioc_s_tuner(struct file *file, void *priv,
+   struct v4l2_tuner *v)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, s_tuner, v);
+}
+
+static int timbradio_vidioc_g_input(struct file *filp, void *priv,
+   unsigned int *i)
+{
+   *i = 0;
+   return 0;
+}
+
+static int timbradio_vidioc_s_input(struct file *filp, void *priv,
+   unsigned int i)
+{
+   return i ? -EINVAL : 0;
+}
+
+static int timbradio_vidioc_g_audio(struct file *file, void *priv,
+   struct v4l2_audio *a)
+{
+   a-index = 0;
+   strlcpy(a-name, Radio, sizeof(a-name));
+   a-capability = V4L2_AUDCAP_STEREO;
+   return 0;
+}
+
+
+static int timbradio_vidioc_s_audio(struct file *file, void *priv,
+   struct v4l2_audio *a)
+{
+   return a-index ? -EINVAL : 0;
+}
+
+static int timbradio_vidioc_s_frequency(struct file *file, void *priv,
+   struct v4l2_frequency *f)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return v4l2_subdev_call(tr-sd_tuner, tuner, s_frequency, f);
+}
+
+static int timbradio_vidioc_g_frequency(struct file *file, void *priv,
+   struct v4l2_frequency *f)
+{
+   struct timbradio *tr = video_drvdata(file);
+   return