All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonyoung Shim <jy0922.shim@samsung.com>
To: Tobias Lorenz <tobias.lorenz@gmx.net>
Cc: klimov.linux@gmail.com, linux-media@vger.kernel.org,
	kyungmin.park@samsung.com
Subject: Re: About the radio-si470x driver for I2C interface
Date: Tue, 14 Apr 2009 14:29:45 +0900	[thread overview]
Message-ID: <49E41F49.8000407@samsung.com> (raw)
In-Reply-To: <200904132035.57419.tobias.lorenz@gmx.net>

On 4/14/2009 3:35 AM, Tobias Lorenz wrote:
> Hi Joonyoung,
> 
>> I have some problem. There is codes for usb in radio-si470x-common.c file.
> 
>> Hrm, if it cannot be removed, maybe it seems to seperate using ifdef.
> 
>> What do you think about this?
> 
> I moved some more functions from radio-si470x-common.c file to
> radio-si470x-usb.c:
> 
> - si470x_start
> 
> - si470x_stop
> 
> - si470x_fops_open
> 
> - si470x_fops_release
> 
> Now the common file should be free of any USB specific components.
> 
> Please have a look at
> 
> http://linuxtv.org/hg/~tlorenz/v4l-dvb/
> 
> Maybe we can move something back later for optimization. But for now, it
> should be okay.
> 
> Bye,
> 
> Toby
> 

Hi Tobias,

I have some questions.

The i2c device is connected always unlike the usb device, so it doesn't
use disconnected and disconnect_lock of struct si470x_device, these are
usb specific.

Unlike you say, si470x_start and si470x_stop functions exist yet in
radio-si470x-common.c. 

I know from datasheet that software should wait for the powerup time(110ms)
after power up, and i verified it at the si4709 device using i2c interface,
but there is not at your implementation.

I wonder above things, and i send you the patch to fix make warning and build
errors, and for easy work.

=============================================================================
Fix compile warnings and errors of radio-si470x-i2c

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 linux/drivers/media/radio/si470x/Kconfig           |    2 +-
 linux/drivers/media/radio/si470x/Makefile          |    4 +-
 .../drivers/media/radio/si470x/radio-si470x-i2c.c  |  153 +++++++++-----------
 linux/drivers/media/radio/si470x/radio-si470x.h    |    5 +-
 4 files changed, 74 insertions(+), 90 deletions(-)

diff --git a/linux/drivers/media/radio/si470x/Kconfig b/linux/drivers/media/radio/si470x/Kconfig
index 3172e1a..07ac2d3 100644
--- a/linux/drivers/media/radio/si470x/Kconfig
+++ b/linux/drivers/media/radio/si470x/Kconfig
@@ -34,4 +34,4 @@ config I2C_SI470X
 	  computer's I2C port.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called radio-si470x-i2c.
+	  module will be called radio-i2c-si470x.
diff --git a/linux/drivers/media/radio/si470x/Makefile b/linux/drivers/media/radio/si470x/Makefile
index 945e7b1..a4bba94 100644
--- a/linux/drivers/media/radio/si470x/Makefile
+++ b/linux/drivers/media/radio/si470x/Makefile
@@ -3,7 +3,7 @@
 #
 
 radio-si470x-objs	:= radio-si470x-usb.o radio-si470x-common.o
-radio-si470x-i2c-objs	:= radio-si470x-i2c.o radio-si470x-common.o
+radio-i2c-si470x-objs	:= radio-si470x-i2c.o radio-si470x-common.o
 
 obj-$(CONFIG_USB_SI470X) += radio-si470x.o
-obj-$(CONFIG_I2C_SI470X) += radio-si470x-i2c.o
+obj-$(CONFIG_I2C_SI470X) += radio-i2c-si470x.o
diff --git a/linux/drivers/media/radio/si470x/radio-si470x-i2c.c b/linux/drivers/media/radio/si470x/radio-si470x-i2c.c
index 7058b84..27a0691 100644
--- a/linux/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/linux/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -57,14 +57,9 @@ MODULE_PARM_DESC(radio_nr, "Radio Nr");
  */
 int si470x_get_register(struct si470x_device *radio, int regnr)
 {
-	int retval;
+	/* TODO */
 
-	retval = 0; /* TODO */
-
-	if (retval >= 0)
-		radio->registers[regnr] = 0; /* TODO */
-
-	return (retval < 0) ? -EINVAL : 0;
+	return 0;
 }
 
 
@@ -73,13 +68,9 @@ int si470x_get_register(struct si470x_device *radio, int regnr)
  */
 int si470x_set_register(struct si470x_device *radio, int regnr)
 {
-	int retval;
-
-	radio->registers[regnr] = 0; /* TODO */
+	/* TODO */
 
-	retval = 0; /* TODO */
-
-	return (retval < 0) ? -EINVAL : 0;
+	return 0;
 }
 
 
@@ -88,16 +79,9 @@ int si470x_set_register(struct si470x_device *radio, int regnr)
  */
 int si470x_get_all_registers(struct si470x_device *radio)
 {
-	int retval;
-	unsigned char regnr;
-
-	retval = 0; /* TODO */
+	/* TODO */
 
-	if (retval >= 0)
-		for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++)
-			radio->registers[regnr] = 0; /* TODO */
-
-	return (retval < 0) ? -EINVAL : 0;
+	return 0;
 }
 
 
@@ -106,17 +90,9 @@ int si470x_get_all_registers(struct si470x_device *radio)
  */
 int si470x_get_rds_registers(struct si470x_device *radio)
 {
-	int retval;
-	int size;
-	unsigned char regnr;
-
-	retval = /* TODO */
+	/* TODO */
 
-	if (retval >= 0)
-		for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++)
-			radio->registers[STATUSRSSI + regnr] = 0; /* TODO */
-
-	return (retval < 0) ? -EINVAL : 0;
+	return 0;
 }
 
 
@@ -131,26 +107,15 @@ int si470x_get_rds_registers(struct si470x_device *radio)
 int si470x_fops_open(struct file *file)
 {
 	struct si470x_device *radio = video_drvdata(file);
-	int retval;
+	int retval = 0;
 
 	lock_kernel();
 	radio->users++;
 
-//	retval = usb_autopm_get_interface(radio->intf);
-//	if (retval < 0) {
-//		radio->users--;
-//		retval = -EIO;
-//		goto done;
-//	}
-//
-	if (radio->users == 1) {
+	if (radio->users == 1)
 		/* start radio */
 		retval = si470x_start(radio);
-		if (retval < 0)
-			usb_autopm_put_interface(radio->intf);
-	}
 
-done:
 	unlock_kernel();
 	return retval;
 }
@@ -170,16 +135,8 @@ int si470x_fops_release(struct file *file)
 		goto done;
 	}
 
-	mutex_lock(&radio->disconnect_lock);
 	radio->users--;
 	if (radio->users == 0) {
-		if (radio->disconnected) {
-			video_unregister_device(radio->videodev);
-			kfree(radio->buffer);
-			kfree(radio);
-			goto unlock;
-		}
-
 		/* stop rds reception */
 		cancel_delayed_work_sync(&radio->work);
 
@@ -188,12 +145,8 @@ int si470x_fops_release(struct file *file)
 
 		/* stop radio */
 		retval = si470x_stop(radio);
-//		usb_autopm_put_interface(radio->intf);
 	}
 
-unlock:
-	mutex_unlock(&radio->disconnect_lock);
-
 done:
 	return retval;
 }
@@ -210,11 +163,8 @@ done:
 int si470x_vidioc_querycap(struct file *file, void *priv,
 		struct v4l2_capability *capability)
 {
-	struct si470x_device *radio = video_drvdata(file);
-
 	strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
 	strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
-//	usb_make_path(radio->usbdev, capability->bus_info, sizeof(capability->bus_info));
 	capability->version = DRIVER_KERNEL_VERSION;
 	capability->capabilities = V4L2_CAP_HW_FREQ_SEEK |
 		V4L2_CAP_TUNER | V4L2_CAP_RADIO;
@@ -231,7 +181,8 @@ int si470x_vidioc_querycap(struct file *file, void *priv,
 /*
  * si470x_i2c_driver_probe - probe for the device
  */
-static int si470x_i2c_driver_probe()
+static int si470x_i2c_driver_probe(struct i2c_client *client,
+		const struct i2c_device_id *id)
 {
 	struct si470x_device *radio;
 	int retval = 0;
@@ -243,10 +194,6 @@ static int si470x_i2c_driver_probe()
 		goto err_initial;
 	}
 	radio->users = 0;
-	radio->disconnected = 0;
-//	radio->usbdev = interface_to_usbdev(intf);
-	radio->intf = intf;
-	mutex_init(&radio->disconnect_lock);
 	mutex_init(&radio->lock);
 
 	/* video device allocation and initialization */
@@ -267,22 +214,6 @@ static int si470x_i2c_driver_probe()
 	printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
 			radio->registers[DEVICEID], radio->registers[CHIPID]);
 
-	/* check if device and firmware is current */
-	if ((radio->registers[CHIPID] & CHIPID_FIRMWARE)
-			< RADIO_SW_VERSION_CURRENT) {
-		printk(KERN_WARNING DRIVER_NAME
-			": This driver is known to work with "
-			"firmware version %hu,\n", RADIO_SW_VERSION_CURRENT);
-		printk(KERN_WARNING DRIVER_NAME
-			": but the device has firmware version %hu.\n",
-			radio->registers[CHIPID] & CHIPID_FIRMWARE);
-		printk(KERN_WARNING DRIVER_NAME
-			": If you have some trouble using this driver,\n");
-		printk(KERN_WARNING DRIVER_NAME
-			": please report to V4L ML at "
-			"linux-media@vger.kernel.org\n");
-	}
-
 	/* set initial frequency */
 	si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
 
@@ -309,7 +240,6 @@ static int si470x_i2c_driver_probe()
 				": Could not register video device\n");
 		goto err_all;
 	}
-//	usb_set_intfdata(intf, radio);
 
 	return 0;
 err_all:
@@ -322,6 +252,60 @@ err_initial:
 	return retval;
 }
 
+/*
+ * si470x_i2c_driver_remove - remove the device
+ */
+static int si470x_i2c_driver_remove(struct i2c_client *client)
+{
+	/* TODO */
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+/*
+ * si470x_i2c_driver_suspend - suspend the device
+ */
+static int si470x_i2c_driver_suspend(struct i2c_client *client,
+		pm_message_t mesg)
+{
+	/* TODO */
+
+	return 0;
+}
+
+/*
+ * si470x_i2c_driver_resume - resume the device
+ */
+static int si470x_i2c_driver_resume(struct i2c_client *client)
+{
+	/* TODO */
+
+	return 0;
+}
+
+#else
+#define si470x_i2c_driver_suspend		NULL
+#define si470x_i2c_driver_resume		NULL
+#endif
+
+static const struct i2c_device_id si470x_i2c_driver_id[] = {
+	{ DRIVER_NAME, 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, si470x_i2c_driver_id);
+
+static struct i2c_driver si470x_i2c_driver = {
+	.driver = {
+		.name = DRIVER_NAME
+	},
+	.probe		= si470x_i2c_driver_probe,
+	.remove		= si470x_i2c_driver_remove,
+	.suspend	= si470x_i2c_driver_suspend,
+	.resume		= si470x_i2c_driver_resume,
+	.id_table	= si470x_i2c_driver_id,
+};
+
 
 
 /**************************************************************************
@@ -333,8 +317,7 @@ err_initial:
  */
 static int __init si470x_module_init(void)
 {
-	printk(KERN_INFO DRIVER_DESC ", Version " DRIVER_VERSION "\n");
-	return 0; /* TODO i2c_register */
+	return i2c_add_driver(&si470x_i2c_driver);
 }
 
 
@@ -343,7 +326,7 @@ static int __init si470x_module_init(void)
  */
 static void __exit si470x_module_exit(void)
 {
-	/* TODO i2c_deregister */
+	i2c_del_driver(&si470x_i2c_driver);
 }
 
 
diff --git a/linux/drivers/media/radio/si470x/radio-si470x.h b/linux/drivers/media/radio/si470x/radio-si470x.h
index 771300e..3953bce 100644
--- a/linux/drivers/media/radio/si470x/radio-si470x.h
+++ b/linux/drivers/media/radio/si470x/radio-si470x.h
@@ -41,6 +41,7 @@
 #include <linux/version.h>
 #include <linux/videodev2.h>
 #include <linux/mutex.h>
+#include <linux/i2c.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/rds.h>
@@ -155,9 +156,9 @@ struct si470x_device {
 	struct usb_interface *intf;
 #endif
 
-#ifdef CONFIG_I2C_SI470X_MODULE
+#if defined (CONFIG_I2C_SI470X) || (CONFIG_I2C_SI470X_MODULE)
 	/* reference to I2C device */
-	/* TODO */
+	struct i2c_client *client;
 #endif
 
 	/* reference to video device */
-- 
1.5.6.3

      parent reply	other threads:[~2009-04-14  5:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-06  3:13 About the radio-si470x driver for I2C interface Joonyoung Shim
2009-03-06 10:46 ` Mauro Carvalho Chehab
2009-03-07 15:27   ` Problem with changeset 10837: causes "make all" not to build many modules Alain Kalker
2009-03-08 16:54     ` Mauro Carvalho Chehab
2009-03-09  2:17       ` Alain Kalker
2009-03-09  4:30         ` Mauro Carvalho Chehab
2009-03-09 13:57           ` Alain Kalker
     [not found]   ` <200903092333.38819.tobias.lorenz@gmx.net>
2009-03-09 23:20     ` About the radio-si470x driver for I2C interface Mauro Carvalho Chehab
2009-03-31 22:54       ` Alexey Klimov
     [not found]         ` <4e1455be0904011754l2c51cf2fi6336d07d591cbb71@mail.gmail.com>
2009-04-02  1:42           ` Joonyoung Shim
     [not found]             ` <200904122256.12305.tobias.lorenz@gmx.net>
2009-04-13  1:14               ` Alexey Klimov
2009-04-13 11:06                 ` Hans Verkuil
2009-04-13  1:46               ` Joonyoung Shim
2009-04-13  5:30                 ` Joonyoung Shim
     [not found]                   ` <200904131215.05703.tobias.lorenz@gmx.net>
2009-04-13 10:31                     ` Joonyoung Shim
2009-04-13 10:42                       ` Joonyoung Shim
     [not found]                         ` <200904132035.57419.tobias.lorenz@gmx.net>
2009-04-14  5:29                           ` Joonyoung Shim [this message]

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=49E41F49.8000407@samsung.com \
    --to=jy0922.shim@samsung.com \
    --cc=klimov.linux@gmail.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=tobias.lorenz@gmx.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.