Jump to content

ASI120 cameras on Linux


JamesF

Recommended Posts

After a fair bit of digging on google last night I discovered that Aptiva have written open source drivers for both the AR0130 and MT9M034. I've not looked at them in detail yet, but it strikes me as entirely possible that these might work with the ASI120 cameras.

The down-side is that the code is for the v3.1 series kernels (or possibly even 2.6) and much of the V4L2 code appears to have been refactored somewhere around the v3.5 series, so they won't easily port to my Mint 14 install. I'm definitely going to see if I can build a 3.1 kernel and get it to work.

James

Link to comment
Share on other sites

Might be interesting for the QHY5L-II mono which also uses the Aptiva MT9M034 CMOS - I'm currently running Ubuntu 12.04 LTS Precise Pangolin 3.2.0-41-generic-pae Kernel, so might be worth a go. I checked the Aptina site, but could not find the details - would you mind posting the link.

Thanks - Jake

Link to comment
Share on other sites

I discovered I have my Mum's old Aspire One that I installed Ubuntu 12.04 on when she offered it to me, so I'm giving that a whirl as well. Just updating everything now. It's surprising how slowing a machine with only 512M RAM runs these day :)

The MT9M034 driver is on github somewhere. I'll find it in a moment. I believe some applications do already support the QHY5 cameras on Linux, but using bespoke controller code in the application. I guess because it's easier to write something to talk to the USB interface than it is to learn the V4L2 spec, write a kernel driver and get it accepted into the kernel.

James

Link to comment
Share on other sites

Hah! It was still in my browser history :) Here it is:

https://github.com/Aptina/BeagleBoard-xM/tree/master/MT9M034

I've not looked at this one in detail yet. Because it's from the BeagleBoard it may be that it needs more work to get it to function correctly with a "normal" PC. I've no idea how the I2C interface works on the BeagleBoard. I believe the code suggests it's heavily based on a driver that is already in the kernel though, so if it can be made to compile perhaps it will "just work".

James

Link to comment
Share on other sites

Looks like 3.2 might be more viable. The AR0130 build fails on 3.5 because some functions such as v4l2_subdev_get_try_format() are missing. They're defined in the headers on 3.2, but in 3.5 there's this lovely piece of work instead:


#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \
static inline struct rtype * \
v4l2_subdev_get_try_##fun_name(struct v4l2_subdev_fh *fh, \
unsigned int pad) \
{ \
BUG_ON(unlikely(pad >= vdev_to_v4l2_subdev( \
fh->vfh.vdev)->entity.num_pads)); \
return &fh->pad[pad].field_name; \
}

__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, format, try_fmt)
__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, crop, try_compose)
__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, compose, try_compose)
#endif

It does look like I ought to be able to get that to work as well, but I can't see what's going wrong at the moment.

James

Link to comment
Share on other sites

I think that's the limit of my progress for this evening. I appear to have caught a streaming cold from my daughter. I think it's time to go and try to sleep it off.

James

Link to comment
Share on other sites

If you need the driver for the QHY5L-II on Linux, contact lzr at lzr@qhyccd.com

He gave me the drivers the other day and I was able to compile it on my Wheezy machine.

Link to comment
Share on other sites

Looks like getting the modules to build is quite tricky.

Thus far I've had to go back to the kernel config and enable the experimental media controller and the "V4L2 sub-device userspace API" to even stand a chance of getting things to compile. That in turn means rebuilding the entire V4L2 subsystem because these two new experimental bits aren't loadable modules.

James

Link to comment
Share on other sites

And now I have both modules build against the 3.2 kernel, but I'm not convinced they will work. The AR0130 module uses a number of variables that no longer appear to be defined in the V4L2 headers and the MT9M034 module gives a couple of undefined function errors for media_entity_init and media_entity_cleanup.

I think I can fix the MT9M034 module if I rebuild more of the kernel tree, but the AR0130 module may require dropping back to 3.1

James

Link to comment
Share on other sites

Ok, so "rebuilding more of the kernel tree" appears to be "rebuilding the entire kernel" for the MT9M034...

Takes a while on a 1.6GHz Atom CPU. When did the kernel get so big? When I started playing with Linux the entire source tree would fit on a 3.5" floppy.

James

Link to comment
Share on other sites

The kernel build is still running, so I've been having a look at the AR0130 driver issues. It appears that this driver may actually have been coded against a version of the kernel that was never released. It calls functions in the V4L2 interface that I can find in patches submitted for the kernel, but not in any released kernel from 2.6 to 3.9. Obviously that makes things rather more tricky. I'm going to comment out those bits as I think they may only support "nice to have" functionality rather than stuff that's fundamental to creating images. If it builds then I can see how it goes.

James

Link to comment
Share on other sites

Oh, that's so typical:


LD vmlinux.o
ld: final link failed: No space left on device
make: *** [vmlinux.o] Error 1

This being my Mum's old Aspire One I'd never really looked at how much disk space it has. Turns out it has an 8GB SSD.

James

Link to comment
Share on other sites

James - you're really going through it on this, but showing some dogged determination. Afraid I got sucked in to trying to collimate/diagnose my refractor this evening so haven't got as far as downloading the source yet. Is it worth quick e-mail to Gonzo's link - lzr@qhyccd.com for some confirmation of how far they've progressed with this - they do seem to be pretty responsive looking through the QHY forums.

Otherwise I think something so experimental may be best done on a spare machine from work and a virgin install.

Link to comment
Share on other sites

Well, the disk space issue has me beaten, so I've plugged in an old USB disk and I'm transferring everything to that at the moment.

It might well be interesting to see what QHY are up to. I know there was a libusb-based QHY driver, but whilst that kind of "gets you out of a hole" it's probably not the desirable long-term solution. The problem with that approach is that every software writer who wants to support such cameras has to write bespoke code for each camera's interface. There's no standard interface (that I'm aware of) for provision of a camera interface via libusb. Given a V4L2-compliant driver the application writer doesn't even have to know what camera might be plugged in. If they write to the interface then any camera will "just work" -- plug in your SPC or QHY5 or ASI120 or DFK21 and the driver will give the application enough information to reconfigure itself as required for that camera and away you go.

The down-side of creating V4L2 drivers is that from time to time the kernel structure changes and the driver needs to track those changes to continue to work. Perhaps what might be helpful is a user-space camera interface API that anyone who wants to write a user-space interface for their camera can stick to, ideally mirroring the V4L2 interface as closely as possible to make minimal work for application developers.

James

Link to comment
Share on other sites

Oh, [removed word]!


Kernel: arch/x86/boot/bzImage is ready (#2)
Building modules, stage 2.
MODPOST 3532 modules
ERROR: "media_entity_init" [drivers/media/video/mt9m034.ko] undefined!
ERROR: "media_entity_cleanup" [drivers/media/video/mt9m034.ko] undefined!

For some reason it doesn't seem to want to build the media controller. Can't see why because it appears to be configured to build it, but none of the sources get compiled.

James

Link to comment
Share on other sites

Woohoo! I have a kernel built and booted and with both modules installed:


# lsmod | head -3
Module Size Used by
mt9m034 17671 0
ar0130 12433 0

Now for the scary bit... :D

James

Link to comment
Share on other sites

Well, I think the MT9M034 as implemented is a non-starter. It looks like it's meant to control a sensor directly on the I2C bus rather than "I2C over USB". I might have a look at one of the other MT9M... modules that does use USB to see how it's done there. Could be possible to munge the two together to produce something that works.

James

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.