[PATCH v4 2/2] Add support for mt9p031 (LI-5M03 module) in Beagleboard xM.

582 views
Skip to first unread message

Javier Martin

unread,
May 30, 2011, 4:37:17 AM5/30/11
to linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, beagl...@googlegroups.com, mch...@yahoo.com.cn, Javier Martin
Since isp clocks have not been exposed yet, this patch
includes a temporal solution for testing mt9p031 driver
in Beagleboard xM.

Signed-off-by: Javier Martin <javier...@vista-silicon.com>
---
arch/arm/mach-omap2/Makefile | 1 +
arch/arm/mach-omap2/board-omap3beagle-camera.c | 88 ++++++++++++++++++++++++
arch/arm/mach-omap2/board-omap3beagle.c | 58 ++++++++++++++++
3 files changed, 147 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/board-omap3beagle-camera.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 512b152..05cd983 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -179,6 +179,7 @@ obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o \
hsmmc.o
obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o
obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \
+ board-omap3beagle-camera.o \
hsmmc.o
obj-$(CONFIG_MACH_DEVKIT8000) += board-devkit8000.o \
hsmmc.o
diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
new file mode 100644
index 0000000..840f8f3
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
@@ -0,0 +1,88 @@
+#include <linux/gpio.h>
+#include <linux/regulator/machine.h>
+
+#include <plat/i2c.h>
+
+#include <media/mt9p031.h>
+
+#include "devices.h"
+#include "../../../drivers/media/video/omap3isp/isp.h"
+
+#define MT9P031_RESET_GPIO 98
+#define MT9P031_XCLK ISP_XCLK_A
+
+static struct regulator *reg_1v8, *reg_2v8;
+
+static int beagle_cam_set_xclk(struct v4l2_subdev *subdev, int hz)
+{
+ struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
+ int ret;
+
+ ret = isp->platform_cb.set_xclk(isp, hz, MT9P031_XCLK);
+ return 0;
+}
+
+static int beagle_cam_reset(struct v4l2_subdev *subdev, int active)
+{
+ /* Set RESET_BAR to !active */
+ gpio_set_value(MT9P031_RESET_GPIO, !active);
+
+ return 0;
+}
+
+static struct mt9p031_platform_data beagle_mt9p031_platform_data = {
+ .set_xclk = beagle_cam_set_xclk,
+ .reset = beagle_cam_reset,
+};
+
+static struct i2c_board_info mt9p031_camera_i2c_device = {
+ I2C_BOARD_INFO("mt9p031", 0x48),
+ .platform_data = &beagle_mt9p031_platform_data,
+};
+
+static struct isp_subdev_i2c_board_info mt9p031_camera_subdevs[] = {
+ {
+ .board_info = &mt9p031_camera_i2c_device,
+ .i2c_adapter_id = 2,
+ },
+ { NULL, 0, },
+};
+
+static struct isp_v4l2_subdevs_group beagle_camera_subdevs[] = {
+ {
+ .subdevs = mt9p031_camera_subdevs,
+ .interface = ISP_INTERFACE_PARALLEL,
+ .bus = {
+ .parallel = {
+ .data_lane_shift = 0,
+ .clk_pol = 1,
+ .bridge = ISPCTRL_PAR_BRIDGE_DISABLE,
+ }
+ },
+ },
+ { },
+};
+
+static struct isp_platform_data beagle_isp_platform_data = {
+ .subdevs = beagle_camera_subdevs,
+};
+
+void __init beagle_camera_init(void)
+{
+ reg_1v8 = regulator_get(NULL, "cam_1v8");
+ if (IS_ERR(reg_1v8))
+ pr_err("%s: cannot get cam_1v8 regulator\n", __func__);
+ else
+ regulator_enable(reg_1v8);
+
+ reg_2v8 = regulator_get(NULL, "cam_2v8");
+ if (IS_ERR(reg_2v8))
+ pr_err("%s: cannot get cam_2v8 regulator\n", __func__);
+ else
+ regulator_enable(reg_2v8);
+
+ omap_register_i2c_bus(2, 100, NULL, 0);
+ gpio_request(MT9P031_RESET_GPIO, "cam_rst");
+ gpio_direction_output(MT9P031_RESET_GPIO, 0);
+ omap3_init_camera(&beagle_isp_platform_data);
+}
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 33007fd..0bdc522 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -24,12 +24,16 @@
#include <linux/input.h>
#include <linux/gpio_keys.h>
#include <linux/opp.h>
+#include <linux/i2c.h>
+#include <linux/mm.h>
+#include <linux/videodev2.h>

#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
#include <linux/mmc/host.h>

+#include <linux/gpio.h>
#include <linux/regulator/machine.h>
#include <linux/i2c/twl.h>

@@ -47,6 +51,7 @@
#include <plat/nand.h>
#include <plat/usb.h>
#include <plat/omap_device.h>
+#include <plat/i2c.h>

#include "mux.h"
#include "hsmmc.h"
@@ -273,6 +278,44 @@ static struct regulator_consumer_supply beagle_vsim_supply = {

static struct gpio_led gpio_leds[];

+static struct regulator_consumer_supply beagle_vaux3_supply = {
+ .supply = "cam_1v8",
+};
+
+static struct regulator_consumer_supply beagle_vaux4_supply = {
+ .supply = "cam_2v8",
+};
+
+/* VAUX3 for CAM_1V8 */
+static struct regulator_init_data beagle_vaux3 = {
+ .constraints = {
+ .min_uV = 1800000,
+ .max_uV = 1800000,
+ .apply_uV = true,
+ .valid_modes_mask = REGULATOR_MODE_NORMAL
+ | REGULATOR_MODE_STANDBY,
+ .valid_ops_mask = REGULATOR_CHANGE_MODE
+ | REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &beagle_vaux3_supply,
+};
+
+/* VAUX4 for CAM_2V8 */
+static struct regulator_init_data beagle_vaux4 = {
+ .constraints = {
+ .min_uV = 1800000,
+ .max_uV = 1800000,
+ .apply_uV = true,
+ .valid_modes_mask = REGULATOR_MODE_NORMAL
+ | REGULATOR_MODE_STANDBY,
+ .valid_ops_mask = REGULATOR_CHANGE_MODE
+ | REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &beagle_vaux4_supply,
+};
+
static int beagle_twl_gpio_setup(struct device *dev,
unsigned gpio, unsigned ngpio)
{
@@ -309,6 +352,15 @@ static int beagle_twl_gpio_setup(struct device *dev,
pr_err("%s: unable to configure EHCI_nOC\n", __func__);
}

+ if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
+ /*
+ * Power on camera interface - only on pre-production, not
+ * needed on production boards
+ */
+ gpio_request(gpio + 2, "CAM_EN");
+ gpio_direction_output(gpio + 2, 1);
+ }
+
/*
* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active
* high / others active low)
@@ -451,6 +503,8 @@ static struct twl4030_platform_data beagle_twldata = {
.vsim = &beagle_vsim,
.vdac = &beagle_vdac,
.vpll2 = &beagle_vpll2,
+ .vaux3 = &beagle_vaux3,
+ .vaux4 = &beagle_vaux4,
};

static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
@@ -654,10 +708,13 @@ static void __init beagle_opp_init(void)
return;
}

+extern void __init beagle_camera_init(void);
+
static void __init omap3_beagle_init(void)
{
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
omap3_beagle_init_rev();
+
omap3_beagle_i2c_init();
platform_add_devices(omap3_beagle_devices,
ARRAY_SIZE(omap3_beagle_devices));
@@ -679,6 +736,7 @@ static void __init omap3_beagle_init(void)

beagle_display_init();
beagle_opp_init();
+ beagle_camera_init();
}

MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
--
1.7.0.4

Koen Kooi

unread,
May 31, 2011, 3:52:05 AM5/31/11
to beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin

Op 30 mei 2011, om 10:37 heeft Javier Martin het volgende geschreven:

> Since isp clocks have not been exposed yet, this patch
> includes a temporal solution for testing mt9p031 driver
> in Beagleboard xM.

When compiling both as Y I get:

[ 4.231628] mt9p031 2-0048: Failed to reset the camera
[ 4.237030] omap3isp omap3isp: Failed to power on: -121
[ 4.242523] mt9p031 2-0048: Failed to power on device: -121
[ 4.248474] isp_register_subdev_group: Unable to register subdev mt9p031

regards,

Koen

Javier Martin

unread,
May 31, 2011, 5:46:50 AM5/31/11
to linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, beagl...@googlegroups.com, mch...@yahoo.com.cn, Javier Martin
Since isp clocks have not been exposed yet, this patch
includes a temporal solution for testing mt9p031 driver
in Beagleboard xM.

Signed-off-by: Javier Martin <javier...@vista-silicon.com>
---
arch/arm/mach-omap2/Makefile | 1 +
arch/arm/mach-omap2/board-omap3beagle-camera.c | 90 ++++++++++++++++++++++++
arch/arm/mach-omap2/board-omap3beagle.c | 55 ++++++++++++++
3 files changed, 146 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/board-omap3beagle-camera.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 512b152..05cd983 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -179,6 +179,7 @@ obj-$(CONFIG_MACH_OMAP_2430SDP) += board-2430sdp.o \
hsmmc.o
obj-$(CONFIG_MACH_OMAP_APOLLON) += board-apollon.o
obj-$(CONFIG_MACH_OMAP3_BEAGLE) += board-omap3beagle.o \
+ board-omap3beagle-camera.o \
hsmmc.o
obj-$(CONFIG_MACH_DEVKIT8000) += board-devkit8000.o \
hsmmc.o
diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
new file mode 100644

index 0000000..04365b2
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
@@ -0,0 +1,90 @@

+static int __init beagle_camera_init(void)


+{
+ reg_1v8 = regulator_get(NULL, "cam_1v8");
+ if (IS_ERR(reg_1v8))
+ pr_err("%s: cannot get cam_1v8 regulator\n", __func__);
+ else
+ regulator_enable(reg_1v8);
+
+ reg_2v8 = regulator_get(NULL, "cam_2v8");
+ if (IS_ERR(reg_2v8))
+ pr_err("%s: cannot get cam_2v8 regulator\n", __func__);
+ else
+ regulator_enable(reg_2v8);
+
+ omap_register_i2c_bus(2, 100, NULL, 0);
+ gpio_request(MT9P031_RESET_GPIO, "cam_rst");
+ gpio_direction_output(MT9P031_RESET_GPIO, 0);
+ omap3_init_camera(&beagle_isp_platform_data);

+ return 0;
+}
+late_initcall(beagle_camera_init);
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 33007fd..c18d21c 100644

@@ -658,6 +712,7 @@ static void __init omap3_beagle_init(void)


{
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
omap3_beagle_init_rev();
+
omap3_beagle_i2c_init();
platform_add_devices(omap3_beagle_devices,
ARRAY_SIZE(omap3_beagle_devices));

--
1.7.0.4

javier Martin

unread,
May 31, 2011, 5:12:51 AM5/31/11
to Koen Kooi, beagleboard@googlegroups.com Board, linux...@vger.kernel.org, Guennadi Liakhovetski, Laurent Pinchart, Chris Rodley, mch...@yahoo.com.cn
On 31 May 2011 09:59, Koen Kooi <ko...@dominion.thruhere.net> wrote:
> I tried on an xM rev A2 and xM rev C, same error on both
>

Crap,
I get the same error here. Sorry for the inconvenience.
I'll send a new version in some minutes.

--
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com

Koen Kooi

unread,
May 31, 2011, 3:59:44 AM5/31/11
to Javier Martin, beagleboard@googlegroups.com Board, linux...@vger.kernel.org, Guennadi Liakhovetski, Laurent Pinchart, Chris Rodley, mch...@yahoo.com.cn

Op 31 mei 2011, om 09:52 heeft Koen Kooi het volgende geschreven:

I tried on an xM rev A2 and xM rev C, same error on both

Koen Kooi

unread,
May 31, 2011, 9:23:40 AM5/31/11
to beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin
Op 31 mei 2011, om 11:46 heeft Javier Martin het volgende geschreven:

> diff --git a/arch/arm/mach-omap2/board-omap3beagle-camera.c b/arch/arm/mach-omap2/board-omap3beagle-camera.c
> new file mode 100644
> index 0000000..04365b2
> --- /dev/null
> +++ b/arch/arm/mach-omap2/board-omap3beagle-camera.c
>

> +static int __init beagle_camera_init(void)
> +{
> + reg_1v8 = regulator_get(NULL, "cam_1v8");
> + if (IS_ERR(reg_1v8))
> + pr_err("%s: cannot get cam_1v8 regulator\n", __func__);
> + else
> + regulator_enable(reg_1v8);
> +
> + reg_2v8 = regulator_get(NULL, "cam_2v8");
> + if (IS_ERR(reg_2v8))
> + pr_err("%s: cannot get cam_2v8 regulator\n", __func__);
> + else
> + regulator_enable(reg_2v8);
> +
> + omap_register_i2c_bus(2, 100, NULL, 0);
> + gpio_request(MT9P031_RESET_GPIO, "cam_rst");
> + gpio_direction_output(MT9P031_RESET_GPIO, 0);
> + omap3_init_camera(&beagle_isp_platform_data);
> + return 0;
> +}
> +late_initcall(beagle_camera_init);

There should probably a if (cpu_is_omap3630()) {} wrapped around that, so the camera doesn't get initted on a 3530 beagle.

regards,

Koen

Koen Kooi

unread,
May 31, 2011, 9:34:03 AM5/31/11
to beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin
root@beagleboardxMC:~# yavta -f SGRBG8 -s 320x240 -n 4 --capture=10 --skip 3 -F `media-ctl -e "OMAP3 ISP CCDC output"`
Device /dev/video2 opened.
Device `OMAP3 ISP CCDC output' on `media' is a video capture device.
Video format set: SGRBG8 (47425247) 320x240 buffer size 76800
Video format: SGRBG8 (47425247) 320x240 buffer size 76800
4 buffers requested.
length: 76800 offset: 0
Buffer 0 mapped at address 0x402cf000.
length: 76800 offset: 77824
Buffer 1 mapped at address 0x402fe000.
length: 76800 offset: 155648
Buffer 2 mapped at address 0x40362000.
length: 76800 offset: 233472
Buffer 3 mapped at address 0x40416000.
0 (0) [-] 4294967295 76800 bytes 167.403289 1306829219.931121 0.002 fps
1 (1) [-] 4294967295 76800 bytes 167.633148 1306829220.160980 4.350 fps
2 (2) [-] 4294967295 76800 bytes 167.744506 1306829220.272308 8.980 fps
3 (3) [-] 4294967295 76800 bytes 167.855865 1306829220.383667 8.980 fps
4 (0) [-] 4294967295 76800 bytes 167.967193 1306829220.495025 8.982 fps
5 (1) [-] 4294967295 76800 bytes 168.078552 1306829220.606384 8.980 fps
6 (2) [-] 4294967295 76800 bytes 168.189910 1306829220.717742 8.980 fps
7 (3) [-] 4294967295 76800 bytes 168.301269 1306829220.829071 8.980 fps
8 (0) [-] 4294967295 76800 bytes 168.412597 1306829220.940429 8.982 fps
9 (1) [-] 4294967295 76800 bytes 168.523956 1306829221.051788 8.980 fps
Captured 10 frames in 1.254212 seconds (7.973134 fps, 612336.670356 B/s).
4 buffers released.

So that seems to be working! I haven't checked the frames yet, but is isn't throwing ISP errors anymore.

Op 31 mei 2011, om 11:46 heeft Javier Martin het volgende geschreven:

> --
> You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> To post to this group, send email to beagl...@googlegroups.com.
> To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
>

Guennadi Liakhovetski

unread,
May 31, 2011, 9:55:04 AM5/31/11
to Koen Kooi, beagl...@googlegroups.com, linux...@vger.kernel.org, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin

...speaking of which - if multiarch kernels are supported by OMAP3 you
probably want to use something like

if (!machine_is_omap3_beagle() || !cpu_is_omap3630())
return;

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

Koen Kooi

unread,
May 31, 2011, 10:01:09 AM5/31/11
to javier Martin, beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn

Op 31 mei 2011, om 15:42 heeft javier Martin het volgende geschreven:

> Great!
> Do you have a monochrome version of the same sensor?

I think I only have the colour version, I got it with my leopard355 board way back.

So what can I do with an unpatched mediactl and unpatched yavta? Is it already possible to point something like mplayer or gstreamer to a v4l2 node and see something? I lost the track of which patch goes where :)

regards,

Koen

javier Martin

unread,
May 31, 2011, 10:07:37 AM5/31/11
to Koen Kooi, beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn

I don't know, I haven't tried.
I'm still using old yavta + Guennadi's patch to enable stdoutput and
"nc" to view images in my PC with mplayer.

Guennadi Liakhovetski

unread,
May 31, 2011, 10:09:02 AM5/31/11
to Koen Kooi, javier Martin, beagl...@googlegroups.com, linux...@vger.kernel.org, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn
On Tue, 31 May 2011, Koen Kooi wrote:

If you're a lucky owner of an LCD on your bb-xM;) you might be able to do
something similar, to what's described here

http://download.open-technology.de/BeagleBoard_xM-MT9P031/BBxM-MT9P031.txt

but both yavta and mplayer on the board, while short-circuiting the
network;) I.e., pipe yavta output directly to mplayer.

javier Martin

unread,
May 31, 2011, 9:42:25 AM5/31/11
to Koen Kooi, beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn
On 31 May 2011 15:34, Koen Kooi <ko...@beagleboard.org> wrote:

Great!


Do you have a monochrome version of the same sensor?

--

Koen Kooi

unread,
May 31, 2011, 11:12:42 AM5/31/11
to Laurent Pinchart, Guennadi Liakhovetski, beagl...@googlegroups.com, linux...@vger.kernel.org, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin

Op 31 mei 2011, om 16:46 heeft Laurent Pinchart het volgende geschreven:

> Shouldn't you check the Beagleboard version instead? The OMAP3530 has an ISP,
> so there's nothing wrong with it per-se.

It has an ISP, but the pins aren't brought out, so you will never be able to use it. We could check the version, but that will look like:

if (omap3_beagle_get_rev() = OMAP3BEAGLE_BOARD_XM || omap3_beagle_get_rev() = OMAP3BEAGLE_BOARD_XMC || omap3_beagle_get_rev() = OMAP3BEAGLE_BOARD_XMD )

or check if you're not on OMAP3BEAGLE_BOARD_AXBX, OMAP3BEAGLE_BOARD_C1_3 or OMAP3BEAGLE_BOARD_C4. I find the 3630 check a lot simpler :)

regards,

Koen

regards,

Koen

Laurent Pinchart

unread,
May 31, 2011, 10:46:59 AM5/31/11
to Guennadi Liakhovetski, Koen Kooi, beagl...@googlegroups.com, linux...@vger.kernel.org, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin
On Tuesday 31 May 2011 15:55:04 Guennadi Liakhovetski wrote:

Shouldn't you check the Beagleboard version instead? The OMAP3530 has an ISP,

so there's nothing wrong with it per-se.

--
Regards,

Laurent Pinchart

Guennadi Liakhovetski

unread,
May 31, 2011, 10:53:25 AM5/31/11
to Laurent Pinchart, Koen Kooi, beagl...@googlegroups.com, linux...@vger.kernel.org, carli...@yahoo.co.nz, mch...@yahoo.com.cn, Javier Martin

No idea whatsoever - in that part I'm just repeating, what the previous
poster has said:)

Koen Kooi

unread,
May 31, 2011, 11:54:23 AM5/31/11
to Guennadi Liakhovetski, javier Martin, beagl...@googlegroups.com, linux...@vger.kernel.org, laurent....@ideasonboard.com, carli...@yahoo.co.nz, mch...@yahoo.com.cn

I tried that and I can say that shining a light into the sensor changes the picture on the screen, but that's about it. Which part needs changing (subdev, isp, mt9p031, beagle-camera, etc) to enable 'standard' access? E.g. opening cheese in gnome.

regards,

Koen

Chris Rodley

unread,
May 31, 2011, 11:21:53 PM5/31/11
to javier...@vista-silicon.com, beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, mch...@yahoo.com.cn, ko...@beagleboard.org
Hi Javier,

Unfortunately still not working for me.
My board is not the BeagleBoard XM but is similar. It is an omap3530 board and power to the camera (VDD and VDD_IO) is controlled by GPIO 57 and 58.

Here is my code for the board-omap3beagle-camera.c file.
Instead of triggering the regulators I set them up in the board file and then turn them on - This approach worked fine in v1 of your patch, but has not worked on any version since - Is there anything you can see as an issue?:

#include <linux/gpio.h>
//#include <linux/regulator/machine.h>

#include <plat/i2c.h>

#include <media/mt9p031.h>

#include "devices.h"
#include "../../../drivers/media/video/omap3isp/isp.h"

#define MT9P031_RESET_GPIO 98
#define MT9P031_XCLK ISP_XCLK_A

//static struct regulator *reg_1v8, *reg_2v8;

static int beagle_cam_set_xclk(struct v4l2_subdev *subdev, int hz)

{


struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);

int ret;

ret = isp->platform_cb.set_xclk(isp, hz, MT9P031_XCLK);

return 0;
}

static int beagle_cam_reset(struct v4l2_subdev *subdev, int active)

{


/* Set RESET_BAR to !active */

gpio_set_value(MT9P031_RESET_GPIO, !active);

return 0;
}

static struct mt9p031_platform_data beagle_mt9p031_platform_data = {
.set_xclk = beagle_cam_set_xclk,
.reset = beagle_cam_reset,
};

static struct i2c_board_info mt9p031_camera_i2c_device = {
I2C_BOARD_INFO("mt9p031", 0x48),
.platform_data = &beagle_mt9p031_platform_data,
};

static struct isp_subdev_i2c_board_info mt9p031_camera_subdevs[] = {
{
.board_info = &mt9p031_camera_i2c_device,
.i2c_adapter_id = 2,
},
{ NULL, 0, },
};

static struct isp_v4l2_subdevs_group beagle_camera_subdevs[] = {
{
.subdevs = mt9p031_camera_subdevs,
.interface = ISP_INTERFACE_PARALLEL,
.bus = {
.parallel = {
.data_lane_shift = 0,
.clk_pol = 1,
.bridge = ISPCTRL_PAR_BRIDGE_DISABLE,
}
},
},
{ },
};

static struct isp_platform_data beagle_isp_platform_data = {
.subdevs = beagle_camera_subdevs,
};

static int __init beagle_camera_init(void)
{
/* New code START */
gpio_set_value(58, 0);
printk(KERN_INFO "Power on 58 1v8 init..\n");

gpio_set_value(57, 0);
printk(KERN_INFO "Power on 57 2v8 init..\n");
/* New code END */

/* ORIG CODE
{


reg_1v8 = regulator_get(NULL, "cam_1v8");

if (IS_ERR(reg_1v8))


pr_err("%s: cannot get cam_1v8 regulator\n", __func__);

else
regulator_enable(reg_1v8);

reg_2v8 = regulator_get(NULL, "cam_2v8");

if (IS_ERR(reg_2v8))


pr_err("%s: cannot get cam_2v8 regulator\n", __func__);

else
regulator_enable(reg_2v8);*/

omap_register_i2c_bus(2, 100, NULL, 0);
gpio_request(MT9P031_RESET_GPIO, "cam_rst");
gpio_direction_output(MT9P031_RESET_GPIO, 0);
omap3_init_camera(&beagle_isp_platform_data);
return 0;
}
late_initcall(beagle_camera_init);


Regards,
Chris

Chris Rodley

unread,
Jun 1, 2011, 6:04:52 PM6/1/11
to javier...@vista-silicon.com, beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, mch...@yahoo.com.cn, ko...@beagleboard.org
Hi Javier, Koen,

On 02/06/11 06:08, Koen Kooi wrote:
>
> Op 1 jun 2011, om 17:36 heeft Javier Martin het volgende geschreven:
>
>> New "version" and "vdd_io" flags have been added.
>>
>> A subtle change now prevents camera from being registered
>> in the wrong platform.
>
> I get a decent picture now with the following:
>
> media-ctl -r -l '"mt9p031 2-0048":0->"OMAP3 ISP CCDC":0[1], "OMAP3 ISP CCDC":1->"OMAP3 ISP CCDC output":0[1]'
> media-ctl -f '"mt9p031 2-0048":0[SGRBG12 320x240], "OMAP3 ISP CCDC":0[SGRBG8 320x240], "OMAP3 ISP CCDC":1[SGRBG8 320x240]'
>
> yavta-nc --stdout -f SGRBG8 -s 320x240 -n 4 --capture=10000 --skip 3 -F $(media-ctl -e "OMAP3 ISP CCDC output") | mplayer-bayer - -demuxer rawvideo -rawvideo w=320:h=240:format=ba81:size=76800 -vo fbdev2 -vf ba81
>
> 720p also seems to work.
>
> It is really, really dark though. Is this due to missing controls or due to the laneshifting?
>
> regards,
>
> Koen

I made changes the same as my last post.
Output is MUCH more encouraging now with v6 patch.

# media-ctl -r -l '"mt9p031 2-0048":0->"OMAP3 ISP CCDC":0[1], "OMAP3 ISP CCDC":1->"OMAP3 ISP CCDC output":0[1]'
Resetting all links to inactive
Setting up link 16:0 -> 5:0 [1]
Setting up link 5:1 -> 6:0 [1]

# media-ctl -f '"mt9p031 2-0048":0[SGRBG12 320x240], "OMAP3 ISP CCDC":0[SGRBG8 320x240], "OMAP3 ISP CCDC":1[SGRBG8 320x240]'
Setting up format SGRBG12 320x240 on pad mt9p031 2-0048/0
Format set: SGRBG12 320x240
Setting up format SGRBG12 320x240 on pad OMAP3 ISP CCDC/0
Format set: SGRBG12 320x240
Setting up format SGRBG8 320x240 on pad OMAP3 ISP CCDC/0
Format set: SGRBG8 320x240
Setting up format SGRBG8 320x240 on pad OMAP3 ISP CCDC/1
Format set: SGRBG8 320x240

# yavta --stdout -f SGRBG8 -s 320x240 -n 4 --capture=100 --skip 3 -F `media-ctl -e "OMAP3 ISP CCDC output"` | nc 10.1.1.16 3000


Device /dev/video2 opened.
Device `OMAP3 ISP CCDC output' on `media' is a video capture device.

Video format set: width: 320 height: 240 buffer size: 76800
Video format: GRBG (47425247) 320x240


4 buffers requested.
length: 76800 offset: 0

Buffer 0 mapped at address 0x40057000.
length: 76800 offset: 77824
Buffer 1 mapped at address 0x400aa000.
length: 76800 offset: 155648
Buffer 2 mapped at address 0x40220000.
length: 76800 offset: 233472
Buffer 3 mapped at address 0x402da000.
0 (0) [-] 4294967295 76800 bytes 457.431406 1306964763.471233 -0.001 fps

Hangs at this point - 'ctrl c'

[ 464.115386] omap3isp omap3isp: CCDC stop timeout!
[ 465.125488] omap3isp omap3isp: Unable to stop OMAP3 ISP CCDC

I can look at the frame - looks like noise on the left hand side only.

Regards,
Chris


Chris Rodley

unread,
Jun 1, 2011, 7:58:41 PM6/1/11
to javier...@vista-silicon.com, beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, mch...@yahoo.com.cn, ko...@beagleboard.org
Hi,

--- On Wed, 1/6/11, Chris Rodley <carli...@yahoo.co.nz> wrote:
> From: Chris Rodley <carli...@yahoo.co.nz>
> Subject: Re: [beagleboard] [PATCH v5 2/2] Add support for mt9p031 (LI-5M03 module) in Beagleboard xM.
> To: javier...@vista-silicon.com
> Cc: beagl...@googlegroups.com, linux...@vger.kernel.org, g.liakh...@gmx.de, laurent....@ideasonboard.com, mch...@yahoo.com.cn, ko...@beagleboard.org
> Received: Wednesday, 1 June, 2011, 3:04 PM

Now producing:


# yavta --stdout -f SGRBG8 -s 320x240 -n 4 --captur
e=100 --skip 3 -F `media-ctl -e "OMAP3 ISP CCDC output"` | nc 10.1.1.16 3000
Device /dev/video2 opened.
Device `OMAP3 ISP CCDC output' on `media' is a video capture device.
Video format set: width: 320 height: 240 buffer size: 76800
Video format: GRBG (47425247) 320x240
4 buffers requested.
length: 76800 offset: 0

Buffer 0 mapped at address 0x40209000.
length: 76800 offset: 77824
Buffer 1 mapped at address 0x402a4000.
length: 76800 offset: 155648
Buffer 2 mapped at address 0x40305000.
length: 76800 offset: 233472
Buffer 3 mapped at address 0x4033d000.
0 (0) [-] 4294967295 76800 bytes 161.364596 1306972315.470868 -0.001 fps
1 (1) [-] 4294967295 76800 bytes 161.847217 1306972315.953520 2.072 fps
2 (2) [-] 4294967295 76800 bytes 162.081111 1306972316.187383 4.275 fps
3 (3) [-] 4294967295 76800 bytes 162.314970 1306972316.421212 4.276 fps
4 (0) [-] 4294967295 76800 bytes 162.548792 1306972316.655095 4.277 fps
5 (1) [-] 4294967295 76800 bytes 162.782648 1306972316.888951 4.276 fps
6 (2) [-] 4294967295 76800 bytes 163.016504 1306972317.122807 4.276 fps
7 (3) [-] 4294967295 76800 bytes 163.250330 1306972317.356633 4.277 fps
8 (0) [-] 4294967295 76800 bytes 163.484186 1306972317.590489 4.276 fps
9 (1) [-] 4294967295 76800 bytes 163.718012 1306972317.824345 4.277 fps
10 (2) [-] 4294967295 76800 bytes 163.951868 1306972318.058171 4.276 fps
11 (3) [-] 4294967295 76800 bytes 164.185694 1306972318.291997 4.277 fps
12 (0) [-] 4294967295 76800 bytes 164.419550 1306972318.525883 4.276 fps
13 (1) [-] 4294967295 76800 bytes 164.653406 1306972318.759709 4.276 fps

Changed mt9p031.c:
#define MT9P031_EXTCLK_FREQ 12000000

I was digging around and found an Aptina driver for 2.6.32:
https://github.com/Aptina/BeagleBoard-xM/blob/master/MT9P031/Angstrom/mt9p031.c

They set it to 12000000 or 24000000 depending.

Mine is very washed out.. opposite to what Koen has observed.

Regards,
Chris

Joel Fernandes

unread,
Jun 24, 2011, 2:22:03 PM6/24/11
to Beagle Board
This is what I see with the 5M and the command that worked for you:

root@beagleboard:~# yavta -f SGRBG8 -s 320x240 -n 4 --capture=10 --
skip 3 -F `media-ctl -e "OMAP3 ISP CCDC output"`
Device /dev/video2 opened.
Device `OMAP3 ISP CCDC output' on `media' is a video capture device.
Video format set: SGRBG8 (47425247) 320x240 buffer size 76800
Video format: SGRBG8 (47425247) 320x240 buffer size 76800
4 buffers requested.
length: 76800 offset: 0
Buffer 0 mapped at address 0x40248000.
length: 76800 offset: 77824
Buffer 1 mapped at address 0x40265000.
length: 76800 offset: 155648
Buffer 2 mapped at address 0x402ce000.
length: 76800 offset: 233472
Buffer 3 mapped at address 0x40334000.
Unable to start streaming: 22.

--

Regards,
Joel.

Koen Kooi

unread,
Jun 24, 2011, 2:29:19 PM6/24/11
to beagl...@googlegroups.com

-ENOTENOUGHINFO

did you run the other commands (e.g. the mediactl ones) as well?

Joel A Fernandes

unread,
Jun 27, 2011, 6:49:05 PM6/27/11
to beagl...@googlegroups.com
Hi Koen,

On Fri, Jun 24, 2011 at 1:29 PM, Koen Kooi <ko...@beagleboard.org> wrote:
>
> did you run the other commands (e.g. the mediactl ones) as well?
>

Thanks a lot, I am able to see some images now :)

Regs,
Joel

Reply all
Reply to author
Forward
0 new messages