All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver
@ 2009-04-24 16:39 Guennadi Liakhovetski
  2009-04-24 16:39 ` [PATCH 1/8] soc-camera: prepare for the platform driver conversion Guennadi Liakhovetski
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:39 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, Paul Mundt

Hi,

Having done the two conversion steps and getting ready to push them, the 
problem that I pushed back for later came forward: applying a patch that 
affects multiple v4l drivers and 6 (!) (the 7th one is approaching) 
platforms would be difficult... So, here comes a solution. With this patch 
I add a new platform-driver style probing to soc-camera without removing 
the old one. This way all current users still work and we can easily 
convert platforms one by one to the new scheme. Please, have a look, I'll 
reply to this message with one core and 7 platform patches, of which the 
latter should only be applied after the first one.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/8] soc-camera: prepare for the platform driver conversion
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
@ 2009-04-24 16:39 ` Guennadi Liakhovetski
  2009-04-24 16:40 ` [PATCH 2/8] ARM: convert pcm037 to the new platform-device soc-camera interface Guennadi Liakhovetski
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:39 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, Paul Mundt

Add a platform driver to soc_camera.c. This way we preserve backwards
compatibility with existing platforms and can start converting them one by one
to the new platform-device soc-camera interface.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/video/soc_camera.c |   71 +++++++++++++++++++++++++++++++++++---
 include/media/soc_camera.h       |    5 +++
 2 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 2d341f5..fecd7e7 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -16,19 +16,21 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/module.h>
-#include <linux/init.h>
 #include <linux/device.h>
-#include <linux/list.h>
 #include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/platform_device.h>
 #include <linux/vmalloc.h>
 
+#include <media/soc_camera.h>
 #include <media/v4l2-common.h>
-#include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
+#include <media/v4l2-ioctl.h>
 #include <media/videobuf-core.h>
-#include <media/soc_camera.h>
 
 /* Default to VGA resolution */
 #define DEFAULT_WIDTH	640
@@ -1159,6 +1161,57 @@ void soc_camera_video_stop(struct soc_camera_device *icd)
 }
 EXPORT_SYMBOL(soc_camera_video_stop);
 
+static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
+{
+	struct soc_camera_link *icl = pdev->dev.platform_data;
+	struct i2c_adapter *adap;
+	struct i2c_client *client;
+
+	if (!icl)
+		return -EINVAL;
+
+	adap = i2c_get_adapter(icl->i2c_adapter_id);
+	if (!adap) {
+		dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n",
+			 icl->i2c_adapter_id);
+		/* -ENODEV and -ENXIO do not produce an error on probe()... */
+		return -ENOENT;
+	}
+
+	icl->board_info->platform_data = icl;
+	client = i2c_new_device(adap, icl->board_info);
+	if (!client) {
+		i2c_put_adapter(adap);
+		return -ENOMEM;
+	}
+
+	platform_set_drvdata(pdev, client);
+
+	return 0;
+}
+
+static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
+{
+	struct i2c_client *client = platform_get_drvdata(pdev);
+
+	if (!client)
+		return -ENODEV;
+
+	i2c_unregister_device(client);
+	i2c_put_adapter(client->adapter);
+
+	return 0;
+}
+
+static struct platform_driver soc_camera_pdrv = {
+	.probe	= soc_camera_pdrv_probe,
+	.remove	= __exit_p(soc_camera_pdrv_remove),
+	.driver	= {
+		.name = "soc-camera-pdrv",
+		.owner = THIS_MODULE,
+	},
+};
+
 static int __init soc_camera_init(void)
 {
 	int ret = bus_register(&soc_camera_bus_type);
@@ -1168,8 +1221,14 @@ static int __init soc_camera_init(void)
 	if (ret)
 		goto edrvr;
 
+	ret = platform_driver_register(&soc_camera_pdrv);
+	if (ret)
+		goto epdr;
+
 	return 0;
 
+epdr:
+	driver_unregister(&ic_drv);
 edrvr:
 	bus_unregister(&soc_camera_bus_type);
 	return ret;
@@ -1177,6 +1236,7 @@ edrvr:
 
 static void __exit soc_camera_exit(void)
 {
+	platform_driver_unregister(&soc_camera_pdrv);
 	driver_unregister(&ic_drv);
 	bus_unregister(&soc_camera_bus_type);
 }
@@ -1187,3 +1247,4 @@ module_exit(soc_camera_exit);
 MODULE_DESCRIPTION("Image capture bus driver");
 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:soc-camera-pdrv");
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index bef5e81..23ecead 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -92,11 +92,16 @@ struct soc_camera_host_ops {
 #define SOCAM_SENSOR_INVERT_VSYNC	(1 << 3)
 #define SOCAM_SENSOR_INVERT_DATA	(1 << 4)
 
+struct i2c_board_info;
+
 struct soc_camera_link {
 	/* Camera bus id, used to match a camera and a bus */
 	int bus_id;
 	/* Per camera SOCAM_SENSOR_* bus flags */
 	unsigned long flags;
+	int i2c_adapter_id;
+	struct i2c_board_info *board_info;
+	const char *module_name;
 	/* Optional callbacks to power on or off and reset the sensor */
 	int (*power)(struct device *, int);
 	int (*reset)(struct device *);
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/8] ARM: convert pcm037 to the new platform-device soc-camera interface
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
  2009-04-24 16:39 ` [PATCH 1/8] soc-camera: prepare for the platform driver conversion Guennadi Liakhovetski
@ 2009-04-24 16:40 ` Guennadi Liakhovetski
  2009-04-24 16:40 ` [PATCH 3/8] ARM: convert pcm990 " Guennadi Liakhovetski
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:40 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, Sascha Hauer, Paul Mundt

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/arm/mach-mx3/pcm037.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c
index bfa814d..af49f03 100644
--- a/arch/arm/mach-mx3/pcm037.c
+++ b/arch/arm/mach-mx3/pcm037.c
@@ -293,9 +293,18 @@ static int pcm037_camera_power(struct device *dev, int on)
 	return 0;
 }
 
+static struct i2c_board_info pcm037_i2c_2_devices[] = {
+	{
+		I2C_BOARD_INFO("mt9t031", 0x5d),
+	},
+};
+
 static struct soc_camera_link iclink = {
-	.bus_id	= 0,			/* Must match with the camera ID */
-	.power = pcm037_camera_power,
+	.bus_id		= 0,		/* Must match with the camera ID */
+	.power		= pcm037_camera_power,
+	.board_info	= &pcm037_i2c_2_devices[0],
+	.i2c_adapter_id	= 2,
+	.module_name	= "mt9t031",
 };
 
 static struct i2c_board_info pcm037_i2c_devices[] = {
@@ -308,9 +317,10 @@ static struct i2c_board_info pcm037_i2c_devices[] = {
 	}
 };
 
-static struct i2c_board_info pcm037_i2c_2_devices[] = {
-	{
-		I2C_BOARD_INFO("mt9t031", 0x5d),
+static struct platform_device pcm037_camera = {
+	.name	= "soc-camera-pdrv",
+	.id	= 0,
+	.dev	= {
 		.platform_data = &iclink,
 	},
 };
@@ -390,6 +400,9 @@ static struct platform_device *devices[] __initdata = {
 	&pcm037_flash,
 	&pcm037_eth,
 	&pcm037_sram_device,
+#if defined(CONFIG_I2C_IMX) || defined(CONFIG_I2C_IMX_MODULE)
+	&pcm037_camera,
+#endif
 };
 
 static struct ipu_platform_data mx3_ipu_data = {
@@ -447,9 +460,6 @@ static void __init mxc_board_init(void)
 	i2c_register_board_info(1, pcm037_i2c_devices,
 			ARRAY_SIZE(pcm037_i2c_devices));
 
-	i2c_register_board_info(2, pcm037_i2c_2_devices,
-			ARRAY_SIZE(pcm037_i2c_2_devices));
-
 	mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data);
 	mxc_register_device(&mxc_i2c_device2, &pcm037_i2c_2_data);
 #endif
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/8] ARM: convert pcm990 to the new platform-device soc-camera interface
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
  2009-04-24 16:39 ` [PATCH 1/8] soc-camera: prepare for the platform driver conversion Guennadi Liakhovetski
  2009-04-24 16:40 ` [PATCH 2/8] ARM: convert pcm037 to the new platform-device soc-camera interface Guennadi Liakhovetski
@ 2009-04-24 16:40 ` Guennadi Liakhovetski
  2009-04-27  2:57   ` Eric Miao
  2009-04-24 16:40 ` [PATCH 4/8] ARM: convert em-x270 " Guennadi Liakhovetski
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:40 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, eric miao

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/arm/mach-pxa/pcm990-baseboard.c |   54 +++++++++++++++++++++++++++------
 1 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index 9ce1ef2..a1ae436 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -427,25 +427,56 @@ static void pcm990_camera_free_bus(struct soc_camera_link *link)
 	gpio_bus_switch = -EINVAL;
 }
 
-static struct soc_camera_link iclink = {
-	.bus_id	= 0, /* Must match with the camera ID above */
-	.query_bus_param = pcm990_camera_query_bus_param,
-	.set_bus_param = pcm990_camera_set_bus_param,
-	.free_bus = pcm990_camera_free_bus,
-};
-
 /* Board I2C devices. */
 static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
 	{
 		/* Must initialize before the camera(s) */
 		I2C_BOARD_INFO("pca9536", 0x41),
 		.platform_data = &pca9536_data,
-	}, {
+	},
+};
+
+static struct i2c_board_info __initdata pcm990_camera_i2c[] = {
+	{
 		I2C_BOARD_INFO("mt9v022", 0x48),
-		.platform_data = &iclink, /* With extender */
 	}, {
 		I2C_BOARD_INFO("mt9m001", 0x5d),
-		.platform_data = &iclink, /* With extender */
+	},
+};
+
+static struct soc_camera_link iclink[] = {
+	{
+		.bus_id			= 0, /* Must match with the camera ID */
+		.board_info		= &pcm990_camera_i2c[0],
+		.i2c_adapter_id		= 0,
+		.query_bus_param	= pcm990_camera_query_bus_param,
+		.set_bus_param		= pcm990_camera_set_bus_param,
+		.free_bus		= pcm990_camera_free_bus,
+		.module_name		= "mt9v022",
+	}, {
+		.bus_id			= 0, /* Must match with the camera ID */
+		.board_info		= &pcm990_camera_i2c[1],
+		.i2c_adapter_id		= 0,
+		.query_bus_param	= pcm990_camera_query_bus_param,
+		.set_bus_param		= pcm990_camera_set_bus_param,
+		.free_bus		= pcm990_camera_free_bus,
+		.module_name		= "mt9m001",
+	},
+};
+
+static struct platform_device pcm990_camera[] = {
+	{
+		.name	= "soc-camera-pdrv",
+		.id	= 0,
+		.dev	= {
+			.platform_data = &iclink[0],
+		},
+	}, {
+		.name	= "soc-camera-pdrv",
+		.id	= 1,
+		.dev	= {
+			.platform_data = &iclink[1],
+		},
 	},
 };
 #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
@@ -501,6 +532,9 @@ void __init pcm990_baseboard_init(void)
 	pxa_set_camera_info(&pcm990_pxacamera_platform_data);
 
 	i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
+
+	platform_device_register(&pcm990_camera[0]);
+	platform_device_register(&pcm990_camera[1]);
 #endif
 
 	printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/8] ARM: convert em-x270 to the new platform-device soc-camera interface
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
                   ` (2 preceding siblings ...)
  2009-04-24 16:40 ` [PATCH 3/8] ARM: convert pcm990 " Guennadi Liakhovetski
@ 2009-04-24 16:40 ` Guennadi Liakhovetski
  2009-04-24 16:40 ` [PATCH 5/8] ARM: convert mioa701 " Guennadi Liakhovetski
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:40 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, eric miao


Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/arm/mach-pxa/em-x270.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index bc0f73f..d35bc25 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -917,14 +917,24 @@ static int em_x270_sensor_power(struct device *dev, int on)
 	return 0;
 }
 
-static struct soc_camera_link iclink = {
-	.bus_id	= 0,
-	.power = em_x270_sensor_power,
-};
-
 static struct i2c_board_info em_x270_i2c_cam_info[] = {
 	{
 		I2C_BOARD_INFO("mt9m111", 0x48),
+	},
+};
+
+static struct soc_camera_link iclink = {
+	.bus_id		= 0,
+	.power		= em_x270_sensor_power,
+	.board_info	= &em_x270_i2c_cam_info[0],
+	.i2c_adapter_id	= 0,
+	.module_name	= "mt9m111",
+};
+
+static struct platform_device em_x270_camera = {
+	.name	= "soc-camera-pdrv",
+	.id	= -1,
+	.dev	= {
 		.platform_data = &iclink,
 	},
 };
@@ -936,8 +946,8 @@ static struct i2c_pxa_platform_data em_x270_i2c_info = {
 static void  __init em_x270_init_camera(void)
 {
 	pxa_set_i2c_info(&em_x270_i2c_info);
-	i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
 	pxa_set_camera_info(&em_x270_camera_platform_data);
+	platform_device_register(&em_x270_camera);
 }
 #else
 static inline void em_x270_init_camera(void) {}
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/8] ARM: convert mioa701 to the new platform-device soc-camera interface
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
                   ` (3 preceding siblings ...)
  2009-04-24 16:40 ` [PATCH 4/8] ARM: convert em-x270 " Guennadi Liakhovetski
@ 2009-04-24 16:40 ` Guennadi Liakhovetski
  2009-04-24 16:40 ` [PATCH 6/8] soc-camera: unify i2c device platform data to point to struct soc_camera_link Guennadi Liakhovetski
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:40 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, eric miao

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/arm/mach-pxa/mioa701.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index ff8052c..c360bce 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -725,19 +725,20 @@ struct pxacamera_platform_data mioa701_pxacamera_platform_data = {
 	.mclk_10khz = 5000,
 };
 
-static struct soc_camera_link iclink = {
-	.bus_id	= 0, /* Must match id in pxa27x_device_camera in device.c */
-};
-
 /* Board I2C devices. */
 static struct i2c_board_info __initdata mioa701_i2c_devices[] = {
 	{
-		/* Must initialize before the camera(s) */
 		I2C_BOARD_INFO("mt9m111", 0x5d),
-		.platform_data = &iclink,
 	},
 };
 
+static struct soc_camera_link iclink = {
+	.bus_id		= 0, /* Match id in pxa27x_device_camera in device.c */
+	.board_info	= &mioa701_i2c_devices[0],
+	.i2c_adapter_id	= 0,
+	.module_name	= "mt9m111",
+};
+
 struct i2c_pxa_platform_data i2c_pdata = {
 	.fast_mode = 1,
 };
@@ -771,6 +772,7 @@ MIO_SIMPLE_DEV(pxa2xx_pcm,	  "pxa2xx-pcm",	    NULL)
 MIO_SIMPLE_DEV(mioa701_sound,	  "mioa701-wm9713", NULL)
 MIO_SIMPLE_DEV(mioa701_board,	  "mioa701-board",  NULL)
 MIO_SIMPLE_DEV(gpio_vbus,	  "gpio-vbus",      &gpio_vbus_data);
+MIO_SIMPLE_DEV(mioa701_camera,	  "soc-camera-pdrv",&iclink);
 
 static struct platform_device *devices[] __initdata = {
 	&mioa701_gpio_keys,
@@ -781,6 +783,7 @@ static struct platform_device *devices[] __initdata = {
 	&power_dev,
 	&strataflash,
 	&gpio_vbus,
+	&mioa701_camera,
 	&mioa701_board,
 };
 
@@ -827,7 +830,6 @@ static void __init mioa701_machine_init(void)
 
 	pxa_set_i2c_info(&i2c_pdata);
 	pxa_set_camera_info(&mioa701_pxacamera_platform_data);
-	i2c_register_board_info(0, ARRAY_AND_SIZE(mioa701_i2c_devices));
 }
 
 static void mioa701_machine_exit(void)
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/8] soc-camera: unify i2c device platform data to point to struct soc_camera_link
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
                   ` (4 preceding siblings ...)
  2009-04-24 16:40 ` [PATCH 5/8] ARM: convert mioa701 " Guennadi Liakhovetski
@ 2009-04-24 16:40 ` Guennadi Liakhovetski
  2009-04-24 16:40 ` [PATCH 7/8] SH: convert ap325rxa to the new platform-device soc-camera interface Guennadi Liakhovetski
  2009-04-24 16:41 ` [PATCH 8/8] SH: convert migor " Guennadi Liakhovetski
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:40 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, Paul Mundt

Needed for a smooth transition to soc-camera as a platform driver.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Ok, this one will be a bit more difficult - it does touch two boards and 
two drivers. But changes are minimal, so, I hope we manage it to push it 
this way. Of course, I could replace it with about 3 stepwise patches, 
adding wrapper macros, etc, but it's not worth the effort.

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/sh/boards/board-ap325rxa.c   |    2 +-
 arch/sh/boards/mach-migor/setup.c |    4 ++--
 drivers/media/video/ov772x.c      |    6 ++++--
 drivers/media/video/tw9910.c      |    6 ++++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/sh/boards/board-ap325rxa.c b/arch/sh/boards/board-ap325rxa.c
index 39e4691..54c5cd1 100644
--- a/arch/sh/boards/board-ap325rxa.c
+++ b/arch/sh/boards/board-ap325rxa.c
@@ -414,7 +414,7 @@ static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = {
 	},
 	{
 		I2C_BOARD_INFO("ov772x", 0x21),
-		.platform_data = &ov7725_info,
+		.platform_data = &ov7725_info.link,
 	},
 };
 
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index 1ee1de0..c4b97e1 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -430,11 +430,11 @@ static struct i2c_board_info migor_i2c_devices[] = {
 	},
 	{
 		I2C_BOARD_INFO("ov772x", 0x21),
-		.platform_data = &ov7725_info,
+		.platform_data = &ov7725_info.link,
 	},
 	{
 		I2C_BOARD_INFO("tw9910", 0x45),
-		.platform_data = &tw9910_info,
+		.platform_data = &tw9910_info.link,
 	},
 };
 
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
index c0d9112..0bce255 100644
--- a/drivers/media/video/ov772x.c
+++ b/drivers/media/video/ov772x.c
@@ -1067,10 +1067,12 @@ static int ov772x_probe(struct i2c_client *client,
 	struct i2c_adapter        *adapter = to_i2c_adapter(client->dev.parent);
 	int                        ret;
 
-	info = client->dev.platform_data;
-	if (!info)
+	if (!client->dev.platform_data)
 		return -EINVAL;
 
+	info = container_of(client->dev.platform_data,
+			    struct ov772x_camera_info, link);
+
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
 		dev_err(&adapter->dev,
 			"I2C-Adapter doesn't support "
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c
index a399476..aa5065e 100644
--- a/drivers/media/video/tw9910.c
+++ b/drivers/media/video/tw9910.c
@@ -875,10 +875,12 @@ static int tw9910_probe(struct i2c_client *client,
 	const struct tw9910_scale_ctrl *scale;
 	int                             i, ret;
 
-	info = client->dev.platform_data;
-	if (!info)
+	if (!client->dev.platform_data)
 		return -EINVAL;
 
+	info = container_of(client->dev.platform_data,
+			    struct tw9910_video_info, link);
+
 	if (!i2c_check_functionality(to_i2c_adapter(client->dev.parent),
 				     I2C_FUNC_SMBUS_BYTE_DATA)) {
 		dev_err(&client->dev,
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/8] SH: convert ap325rxa to the new platform-device soc-camera interface
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
                   ` (5 preceding siblings ...)
  2009-04-24 16:40 ` [PATCH 6/8] soc-camera: unify i2c device platform data to point to struct soc_camera_link Guennadi Liakhovetski
@ 2009-04-24 16:40 ` Guennadi Liakhovetski
  2009-04-24 16:41 ` [PATCH 8/8] SH: convert migor " Guennadi Liakhovetski
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:40 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, Paul Mundt

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/sh/boards/board-ap325rxa.c |   50 +++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/arch/sh/boards/board-ap325rxa.c b/arch/sh/boards/board-ap325rxa.c
index 54c5cd1..4ceed71 100644
--- a/arch/sh/boards/board-ap325rxa.c
+++ b/arch/sh/boards/board-ap325rxa.c
@@ -346,15 +346,6 @@ static int ov7725_power(struct device *dev, int mode)
 	return 0;
 }
 
-static struct ov772x_camera_info ov7725_info = {
-	.buswidth  = SOCAM_DATAWIDTH_8,
-	.flags = OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP,
-	.edgectrl = OV772X_AUTO_EDGECTRL(0xf, 0),
-	.link = {
-		.power  = ov7725_power,
-	},
-};
-
 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
 	.flags = SH_CEU_FLAG_USE_8BIT_BUS,
 };
@@ -399,25 +390,48 @@ static struct platform_device sdcard_cn3_device = {
 	},
 };
 
-static struct platform_device *ap325rxa_devices[] __initdata = {
-	&smsc9118_device,
-	&ap325rxa_nor_flash_device,
-	&lcdc_device,
-	&ceu_device,
-	&nand_flash_device,
-	&sdcard_cn3_device,
-};
-
 static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("pcf8563", 0x51),
 	},
+};
+
+static struct i2c_board_info __initdata ap325rxa_i2c_camera[] = {
 	{
 		I2C_BOARD_INFO("ov772x", 0x21),
+	},
+};
+
+static struct ov772x_camera_info ov7725_info = {
+	.buswidth	= SOCAM_DATAWIDTH_8,
+	.flags		= OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP,
+	.edgectrl	= OV772X_AUTO_EDGECTRL(0xf, 0),
+	.link = {
+		.power		= ov7725_power,
+		.board_info	= &ap325rxa_i2c_camera[0],
+		.i2c_adapter_id	= 0,
+		.module_name	= "ov772x",
+	},
+};
+
+static struct platform_device ap325rxa_camera = {
+	.name	= "soc-camera-pdrv",
+	.id	= 0,
+	.dev	= {
 		.platform_data = &ov7725_info.link,
 	},
 };
 
+static struct platform_device *ap325rxa_devices[] __initdata = {
+	&smsc9118_device,
+	&ap325rxa_nor_flash_device,
+	&lcdc_device,
+	&ceu_device,
+	&nand_flash_device,
+	&sdcard_cn3_device,
+	&ap325rxa_camera,
+};
+
 static struct spi_board_info ap325rxa_spi_devices[] = {
 	{
 		.modalias = "mmc_spi",
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/8] SH: convert migor to the new platform-device soc-camera interface
  2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
                   ` (6 preceding siblings ...)
  2009-04-24 16:40 ` [PATCH 7/8] SH: convert ap325rxa to the new platform-device soc-camera interface Guennadi Liakhovetski
@ 2009-04-24 16:41 ` Guennadi Liakhovetski
  7 siblings, 0 replies; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-24 16:41 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Hans Verkuil, Robert Jarzmik, Magnus Damm, Paul Mundt

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

For review __ONLY__ for now - will re-submit after I have pushed 1/8

 arch/sh/boards/mach-migor/setup.c |   79 ++++++++++++++++++++++++-------------
 1 files changed, 52 insertions(+), 27 deletions(-)

diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index c4b97e1..785c3e1 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -381,21 +381,6 @@ static struct platform_device migor_ceu_device = {
 	},
 };
 
-static struct ov772x_camera_info ov7725_info = {
-	.buswidth  = SOCAM_DATAWIDTH_8,
-	.link = {
-		.power  = ov7725_power,
-	},
-};
-
-static struct tw9910_video_info tw9910_info = {
-	.buswidth = SOCAM_DATAWIDTH_8,
-	.mpout    = TW9910_MPO_FIELD,
-	.link = {
-		.power  = tw9910_power,
-	}
-};
-
 struct spi_gpio_platform_data sdcard_cn9_platform_data = {
 	.sck = GPIO_PTD0,
 	.mosi = GPIO_PTD1,
@@ -410,16 +395,6 @@ static struct platform_device sdcard_cn9_device = {
 	},
 };
 
-static struct platform_device *migor_devices[] __initdata = {
-	&smc91x_eth_device,
-	&sh_keysc_device,
-	&migor_lcdc_device,
-	&migor_ceu_device,
-	&migor_nor_flash_device,
-	&migor_nand_flash_device,
-	&sdcard_cn9_device,
-};
-
 static struct i2c_board_info migor_i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("rs5c372b", 0x32),
@@ -428,16 +403,66 @@ static struct i2c_board_info migor_i2c_devices[] = {
 		I2C_BOARD_INFO("migor_ts", 0x51),
 		.irq = 38, /* IRQ6 */
 	},
+};
+
+static struct i2c_board_info migor_i2c_camera[] = {
 	{
 		I2C_BOARD_INFO("ov772x", 0x21),
-		.platform_data = &ov7725_info.link,
 	},
 	{
 		I2C_BOARD_INFO("tw9910", 0x45),
-		.platform_data = &tw9910_info.link,
 	},
 };
 
+static struct ov772x_camera_info ov7725_info = {
+	.buswidth	= SOCAM_DATAWIDTH_8,
+	.link = {
+		.power		= ov7725_power,
+		.board_info	= &migor_i2c_camera[0],
+		.i2c_adapter_id	= 0,
+		.module_name	= "ov772x",
+	},
+};
+
+static struct tw9910_video_info tw9910_info = {
+	.buswidth	= SOCAM_DATAWIDTH_8,
+	.mpout		= TW9910_MPO_FIELD,
+	.link = {
+		.power		= tw9910_power,
+		.board_info	= &migor_i2c_camera[1],
+		.i2c_adapter_id	= 0,
+		.module_name	= "tw9910",
+	}
+};
+
+static struct platform_device migor_camera[] = {
+	{
+		.name	= "soc-camera-pdrv",
+		.id	= 0,
+		.dev	= {
+			.platform_data = &ov7725_info.link,
+		},
+	}, {
+		.name	= "soc-camera-pdrv",
+		.id	= 1,
+		.dev	= {
+			.platform_data = &tw9910_info.link,
+		},
+	},
+};
+
+static struct platform_device *migor_devices[] __initdata = {
+	&smc91x_eth_device,
+	&sh_keysc_device,
+	&migor_lcdc_device,
+	&migor_ceu_device,
+	&migor_nor_flash_device,
+	&migor_nand_flash_device,
+	&sdcard_cn9_device,
+	&migor_camera[0],
+	&migor_camera[1],
+};
+
 static struct spi_board_info migor_spi_devices[] = {
 	{
 		.modalias = "mmc_spi",
-- 
1.6.2.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/8] ARM: convert pcm990 to the new platform-device soc-camera interface
  2009-04-24 16:40 ` [PATCH 3/8] ARM: convert pcm990 " Guennadi Liakhovetski
@ 2009-04-27  2:57   ` Eric Miao
  2009-04-27  9:55     ` Guennadi Liakhovetski
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Miao @ 2009-04-27  2:57 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: Linux Media Mailing List, Hans Verkuil, Robert Jarzmik, Magnus Damm

It looks to me the change to the platform code is to move the I2C board
info registration into 'struct soc_camera_link'. Are there any specific
reason to do so? I'm assuming the original code works equally well,
and lists all the i2c devices in a central place is straight forward.

On Sat, Apr 25, 2009 at 12:40 AM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>
> For review __ONLY__ for now - will re-submit after I have pushed 1/8
>
>  arch/arm/mach-pxa/pcm990-baseboard.c |   54 +++++++++++++++++++++++++++------
>  1 files changed, 44 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
> index 9ce1ef2..a1ae436 100644
> --- a/arch/arm/mach-pxa/pcm990-baseboard.c
> +++ b/arch/arm/mach-pxa/pcm990-baseboard.c
> @@ -427,25 +427,56 @@ static void pcm990_camera_free_bus(struct soc_camera_link *link)
>        gpio_bus_switch = -EINVAL;
>  }
>
> -static struct soc_camera_link iclink = {
> -       .bus_id = 0, /* Must match with the camera ID above */
> -       .query_bus_param = pcm990_camera_query_bus_param,
> -       .set_bus_param = pcm990_camera_set_bus_param,
> -       .free_bus = pcm990_camera_free_bus,
> -};
> -
>  /* Board I2C devices. */
>  static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
>        {
>                /* Must initialize before the camera(s) */
>                I2C_BOARD_INFO("pca9536", 0x41),
>                .platform_data = &pca9536_data,
> -       }, {
> +       },
> +};
> +
> +static struct i2c_board_info __initdata pcm990_camera_i2c[] = {
> +       {
>                I2C_BOARD_INFO("mt9v022", 0x48),
> -               .platform_data = &iclink, /* With extender */
>        }, {
>                I2C_BOARD_INFO("mt9m001", 0x5d),
> -               .platform_data = &iclink, /* With extender */
> +       },
> +};
> +
> +static struct soc_camera_link iclink[] = {
> +       {
> +               .bus_id                 = 0, /* Must match with the camera ID */
> +               .board_info             = &pcm990_camera_i2c[0],
> +               .i2c_adapter_id         = 0,
> +               .query_bus_param        = pcm990_camera_query_bus_param,
> +               .set_bus_param          = pcm990_camera_set_bus_param,
> +               .free_bus               = pcm990_camera_free_bus,
> +               .module_name            = "mt9v022",
> +       }, {
> +               .bus_id                 = 0, /* Must match with the camera ID */
> +               .board_info             = &pcm990_camera_i2c[1],
> +               .i2c_adapter_id         = 0,
> +               .query_bus_param        = pcm990_camera_query_bus_param,
> +               .set_bus_param          = pcm990_camera_set_bus_param,
> +               .free_bus               = pcm990_camera_free_bus,
> +               .module_name            = "mt9m001",
> +       },
> +};
> +
> +static struct platform_device pcm990_camera[] = {
> +       {
> +               .name   = "soc-camera-pdrv",
> +               .id     = 0,
> +               .dev    = {
> +                       .platform_data = &iclink[0],
> +               },
> +       }, {
> +               .name   = "soc-camera-pdrv",
> +               .id     = 1,
> +               .dev    = {
> +                       .platform_data = &iclink[1],
> +               },
>        },
>  };
>  #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
> @@ -501,6 +532,9 @@ void __init pcm990_baseboard_init(void)
>        pxa_set_camera_info(&pcm990_pxacamera_platform_data);
>
>        i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
> +
> +       platform_device_register(&pcm990_camera[0]);
> +       platform_device_register(&pcm990_camera[1]);
>  #endif
>
>        printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");
> --
> 1.6.2.4
>
>



-- 
Cheers
- eric

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/8] ARM: convert pcm990 to the new platform-device soc-camera interface
  2009-04-27  2:57   ` Eric Miao
@ 2009-04-27  9:55     ` Guennadi Liakhovetski
  2009-04-28  1:30       ` Eric Miao
  0 siblings, 1 reply; 12+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-27  9:55 UTC (permalink / raw)
  To: Eric Miao
  Cc: Linux Media Mailing List, Hans Verkuil, Robert Jarzmik, Magnus Damm

On Mon, 27 Apr 2009, Eric Miao wrote:

> It looks to me the change to the platform code is to move the I2C board
> info registration into 'struct soc_camera_link'. Are there any specific
> reason to do so? I'm assuming the original code works equally well,
> and lists all the i2c devices in a central place is straight forward.

Yes, there are reasons. The first one is, that many i2c camera sensor 
chips switch on their I2C interface only when the camera interface master 
clock is running. Therefore you cannot even probe the chip before the host 
video part has been initialised. So if you load the sensor driver before 
the host camera driver you cannot probe. The current mainline framework 
makes the "first-stage" sensor probe a NOP, in it the sensor driver just 
registers itself with the soc-camera framework and returns success. And 
only when the soc-camera finds a match of a sensor and a host driver it 
requests the host to activate the interface (switch on the master clock) 
and then the second stage sensor probing is called, which now can actually 
read chip version registers etc. The second reason is that this is also 
how v4l2-subdev framework works - there your camera host driver (in our 
case soc-camera core) uses its internal knowledge about present I2C 
devices (in our case it uses platform devices with referenced there i2c 
board info) to register new I2C devices dynamically and load their 
drivers, at which point we have already switched the master clock on so 
the sensor driver can just probe the chip normally.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/8] ARM: convert pcm990 to the new platform-device soc-camera interface
  2009-04-27  9:55     ` Guennadi Liakhovetski
@ 2009-04-28  1:30       ` Eric Miao
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Miao @ 2009-04-28  1:30 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: Linux Media Mailing List, Hans Verkuil, Robert Jarzmik, Magnus Damm

On Mon, Apr 27, 2009 at 5:55 PM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> On Mon, 27 Apr 2009, Eric Miao wrote:
>
>> It looks to me the change to the platform code is to move the I2C board
>> info registration into 'struct soc_camera_link'. Are there any specific
>> reason to do so? I'm assuming the original code works equally well,
>> and lists all the i2c devices in a central place is straight forward.
>
> Yes, there are reasons. The first one is, that many i2c camera sensor
> chips switch on their I2C interface only when the camera interface master
> clock is running. Therefore you cannot even probe the chip before the host
> video part has been initialised. So if you load the sensor driver before
> the host camera driver you cannot probe. The current mainline framework
> makes the "first-stage" sensor probe a NOP, in it the sensor driver just
> registers itself with the soc-camera framework and returns success.

Yes, indeed. The driver has to be carefully written so that no actual I2C
access is made during probe, but this makes no sense.

One workaround to this is to separate the logic of clock enabling from
the camera controller and make a 'struct clk' for it. However, this sounds
to be tricky as well.

> And
> only when the soc-camera finds a match of a sensor and a host driver it
> requests the host to activate the interface (switch on the master clock)
> and then the second stage sensor probing is called, which now can actually
> read chip version registers etc. The second reason is that this is also
> how v4l2-subdev framework works - there your camera host driver (in our
> case soc-camera core) uses its internal knowledge about present I2C
> devices (in our case it uses platform devices with referenced there i2c
> board info) to register new I2C devices dynamically and load their
> drivers, at which point we have already switched the master clock on so
> the sensor driver can just probe the chip normally.
>

Sounds reasonable. I'm then OK with these 3 patches.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-04-28  1:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-24 16:39 [PATCH 0/8] soc-camera: smoothly switch platforms to platform-driver Guennadi Liakhovetski
2009-04-24 16:39 ` [PATCH 1/8] soc-camera: prepare for the platform driver conversion Guennadi Liakhovetski
2009-04-24 16:40 ` [PATCH 2/8] ARM: convert pcm037 to the new platform-device soc-camera interface Guennadi Liakhovetski
2009-04-24 16:40 ` [PATCH 3/8] ARM: convert pcm990 " Guennadi Liakhovetski
2009-04-27  2:57   ` Eric Miao
2009-04-27  9:55     ` Guennadi Liakhovetski
2009-04-28  1:30       ` Eric Miao
2009-04-24 16:40 ` [PATCH 4/8] ARM: convert em-x270 " Guennadi Liakhovetski
2009-04-24 16:40 ` [PATCH 5/8] ARM: convert mioa701 " Guennadi Liakhovetski
2009-04-24 16:40 ` [PATCH 6/8] soc-camera: unify i2c device platform data to point to struct soc_camera_link Guennadi Liakhovetski
2009-04-24 16:40 ` [PATCH 7/8] SH: convert ap325rxa to the new platform-device soc-camera interface Guennadi Liakhovetski
2009-04-24 16:41 ` [PATCH 8/8] SH: convert migor " Guennadi Liakhovetski

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.