* [PATCH] ARM: mach-shmobile: Mackerel VGA camera support
@ 2010-12-22 14:47 Magnus Damm
2010-12-24 4:03 ` Paul Mundt
2010-12-24 22:52 ` Guennadi Liakhovetski
0 siblings, 2 replies; 3+ messages in thread
From: Magnus Damm @ 2010-12-22 14:47 UTC (permalink / raw)
To: linux-sh
From: Magnus Damm <damm@opensource.se>
Add VGA camera support to the Mackerel board
using soc_camera_platform.
The VGA camera module is hooked up using the
8-bit CEU bus, and it is constantly bursting
out frames in fixed video mode setting. The
camera module does not allow any I2C control.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
arch/arm/mach-shmobile/board-mackerel.c | 126 ++++++++++++++++++++++++++++++-
1 file changed, 125 insertions(+), 1 deletion(-)
--- 0001/arch/arm/mach-shmobile/board-mackerel.c
+++ work/arch/arm/mach-shmobile/board-mackerel.c 2010-12-22 23:31:15.000000000 +0900
@@ -44,7 +44,9 @@
#include <linux/usb/r8a66597.h>
#include <video/sh_mobile_lcdc.h>
-
+#include <media/sh_mobile_ceu.h>
+#include <media/soc_camera.h>
+#include <media/soc_camera_platform.h>
#include <sound/sh_fsi.h>
#include <mach/common.h>
@@ -595,6 +597,111 @@ static struct platform_device sh_mmcif_d
.resource = sh_mmcif_resources,
};
+
+static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
+static void mackerel_camera_del(struct soc_camera_link *icl);
+
+static int camera_set_capture(struct soc_camera_platform_info *info,
+ int enable)
+{
+ return 0; /* camera sensor always enabled */
+}
+
+static struct soc_camera_platform_info camera_info = {
+ .format_name = "UYVY",
+ .format_depth = 16,
+ .format = {
+ .code = V4L2_MBUS_FMT_UYVY8_2X8,
+ .colorspace = V4L2_COLORSPACE_SMPTE170M,
+ .field = V4L2_FIELD_NONE,
+ .width = 640,
+ .height = 480,
+ },
+ .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
+ SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
+ SOCAM_DATA_ACTIVE_HIGH,
+ .set_capture = camera_set_capture,
+};
+
+static struct soc_camera_link camera_link = {
+ .bus_id = 0,
+ .add_device = mackerel_camera_add,
+ .del_device = mackerel_camera_del,
+ .module_name = "soc_camera_platform",
+ .priv = &camera_info,
+};
+
+static void dummy_release(struct device *dev)
+{
+}
+
+static struct platform_device camera_device = {
+ .name = "soc_camera_platform",
+ .dev = {
+ .platform_data = &camera_info,
+ .release = dummy_release,
+ },
+};
+
+static int mackerel_camera_add(struct soc_camera_link *icl,
+ struct device *dev)
+{
+ if (icl != &camera_link)
+ return -ENODEV;
+
+ camera_info.dev = dev;
+
+ return platform_device_register(&camera_device);
+}
+
+static void mackerel_camera_del(struct soc_camera_link *icl)
+{
+ if (icl != &camera_link)
+ return;
+
+ platform_device_unregister(&camera_device);
+ memset(&camera_device.dev.kobj, 0,
+ sizeof(camera_device.dev.kobj));
+}
+
+static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
+ .flags = SH_CEU_FLAG_USE_8BIT_BUS,
+};
+
+static struct resource ceu_resources[] = {
+ [0] = {
+ .name = "CEU",
+ .start = 0xfe910000,
+ .end = 0xfe91009f,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = intcs_evt2irq(0x880),
+ .flags = IORESOURCE_IRQ,
+ },
+ [2] = {
+ /* place holder for contiguous memory */
+ },
+};
+
+static struct platform_device ceu_device = {
+ .name = "sh_mobile_ceu",
+ .id = 0, /* "ceu0" clock */
+ .num_resources = ARRAY_SIZE(ceu_resources),
+ .resource = ceu_resources,
+ .dev = {
+ .platform_data = &sh_mobile_ceu_info,
+ },
+};
+
+static struct platform_device mackerel_camera = {
+ .name = "soc-camera-pdrv",
+ .id = 0,
+ .dev = {
+ .platform_data = &camera_link,
+ },
+};
+
static struct platform_device *mackerel_devices[] __initdata = {
&nor_flash_device,
&smc911x_device,
@@ -609,6 +716,8 @@ static struct platform_device *mackerel_
#endif
&sdhi2_device,
&sh_mmcif_device,
+ &ceu_device,
+ &mackerel_camera,
};
/* Keypad Initialization */
@@ -811,6 +920,21 @@ static void __init mackerel_init(void)
gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
+ /* CEU */
+ gpio_request(GPIO_FN_VIO_CLK, NULL);
+ gpio_request(GPIO_FN_VIO_VD, NULL);
+ gpio_request(GPIO_FN_VIO_HD, NULL);
+ gpio_request(GPIO_FN_VIO_FIELD, NULL);
+ gpio_request(GPIO_FN_VIO_CKO, NULL);
+ gpio_request(GPIO_FN_VIO_D7, NULL);
+ gpio_request(GPIO_FN_VIO_D6, NULL);
+ gpio_request(GPIO_FN_VIO_D5, NULL);
+ gpio_request(GPIO_FN_VIO_D4, NULL);
+ gpio_request(GPIO_FN_VIO_D3, NULL);
+ gpio_request(GPIO_FN_VIO_D2, NULL);
+ gpio_request(GPIO_FN_VIO_D1, NULL);
+ gpio_request(GPIO_FN_VIO_D0, NULL);
+
i2c_register_board_info(0, i2c0_devices,
ARRAY_SIZE(i2c0_devices));
i2c_register_board_info(1, i2c1_devices,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: mach-shmobile: Mackerel VGA camera support
2010-12-22 14:47 [PATCH] ARM: mach-shmobile: Mackerel VGA camera support Magnus Damm
@ 2010-12-24 4:03 ` Paul Mundt
2010-12-24 22:52 ` Guennadi Liakhovetski
1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2010-12-24 4:03 UTC (permalink / raw)
To: linux-sh
On Wed, Dec 22, 2010 at 11:47:40PM +0900, Magnus Damm wrote:
> +static struct soc_camera_link camera_link = {
> + .bus_id = 0,
> + .add_device = mackerel_camera_add,
> + .del_device = mackerel_camera_del,
> + .module_name = "soc_camera_platform",
> + .priv = &camera_info,
> +};
> +
> +static void dummy_release(struct device *dev)
> +{
> +}
> +
> +static struct platform_device camera_device = {
> + .name = "soc_camera_platform",
> + .dev = {
> + .platform_data = &camera_info,
> + .release = dummy_release,
> + },
> +};
> +
> +static int mackerel_camera_add(struct soc_camera_link *icl,
> + struct device *dev)
> +{
> + if (icl != &camera_link)
> + return -ENODEV;
> +
> + camera_info.dev = dev;
> +
> + return platform_device_register(&camera_device);
> +}
> +
I guess we should probably have the resource request doing here and
tidied up after in the ->release()? The ordering here is pretty magical.
> +static void mackerel_camera_del(struct soc_camera_link *icl)
> +{
> + if (icl != &camera_link)
> + return;
> +
> + platform_device_unregister(&camera_device);
> + memset(&camera_device.dev.kobj, 0,
> + sizeof(camera_device.dev.kobj));
> +}
> +
Any time a board needs to touch a device's kobject resources there's
something horribly horribly wrong. If the kobject is left particually
constructed after unregistration and causing corruption when the camera
is re-attached, then this needs to be corrected in the driver model, not
here.
The camera_link checks also look pretty bogus. This will only be called
in to for non-i2c devices, which already establish the reference to
&camera_link in the platform device's private data.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: mach-shmobile: Mackerel VGA camera support
2010-12-22 14:47 [PATCH] ARM: mach-shmobile: Mackerel VGA camera support Magnus Damm
2010-12-24 4:03 ` Paul Mundt
@ 2010-12-24 22:52 ` Guennadi Liakhovetski
1 sibling, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2010-12-24 22:52 UTC (permalink / raw)
To: linux-sh
On Fri, 24 Dec 2010, Paul Mundt wrote:
> On Wed, Dec 22, 2010 at 11:47:40PM +0900, Magnus Damm wrote:
> > +static struct soc_camera_link camera_link = {
> > + .bus_id = 0,
> > + .add_device = mackerel_camera_add,
> > + .del_device = mackerel_camera_del,
> > + .module_name = "soc_camera_platform",
> > + .priv = &camera_info,
> > +};
> > +
> > +static void dummy_release(struct device *dev)
> > +{
> > +}
> > +
> > +static struct platform_device camera_device = {
> > + .name = "soc_camera_platform",
> > + .dev = {
> > + .platform_data = &camera_info,
> > + .release = dummy_release,
> > + },
> > +};
> > +
> > +static int mackerel_camera_add(struct soc_camera_link *icl,
> > + struct device *dev)
> > +{
> > + if (icl != &camera_link)
> > + return -ENODEV;
> > +
> > + camera_info.dev = dev;
> > +
> > + return platform_device_register(&camera_device);
> > +}
> > +
> I guess we should probably have the resource request doing here and
> tidied up after in the ->release()? The ordering here is pretty magical.
>
> > +static void mackerel_camera_del(struct soc_camera_link *icl)
> > +{
> > + if (icl != &camera_link)
> > + return;
> > +
> > + platform_device_unregister(&camera_device);
> > + memset(&camera_device.dev.kobj, 0,
> > + sizeof(camera_device.dev.kobj));
> > +}
> > +
> Any time a board needs to touch a device's kobject resources there's
> something horribly horribly wrong. If the kobject is left particually
> constructed after unregistration and causing corruption when the camera
> is re-attached, then this needs to be corrected in the driver model, not
> here.
Been there many times before... The official reply from Greg is: device
objects _must_ be allocated dynamically and must _not_ be reused. No,
soc-camera is not obeying to this yet.
> The camera_link checks also look pretty bogus. This will only be called
> in to for non-i2c devices, which already establish the reference to
> &camera_link in the platform device's private data.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-24 22:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-22 14:47 [PATCH] ARM: mach-shmobile: Mackerel VGA camera support Magnus Damm
2010-12-24 4:03 ` Paul Mundt
2010-12-24 22:52 ` Guennadi Liakhovetski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox