Wednesday, June 3, 2009

Back to ALSA

Ingenic seems to provide both OSS and ALSA support in their kernel. I went OSS (which is deprecated) instead of ALSA just because I could get no sound output with the later while the former worked out of the box. As a side effect, OSS is lightweight compared to ALSA, which is an advantage in systems with limited RAM, as is the case of the A320.

I've been trying to fix some issues in the OSS driver and today I gave up. The code is the biggest POS I've seen in my whole life. I would write it from scratch if I had the JZ4740 manual, but for some reason beyond me Ingenic hasn't released it, so instead of learing how the hardware works and then write the code I have to understand how the hardware works from studying the code. No way with such a POS.

So I'll start working in getting sound output from ALSA, whose code seems to have an acceptable quality. It's certainly a pity losing the lightweight advantage of OSS. The libasound library that comes with the Ingenic toolchain is about 1MB size (stripped!, for god's sake, what's in there?). I'm not knowledgeable on ALSA internals, so any suggestions on how to get it thinner would be welcome.

UPDATE: confirmed... something is REALLY wrong with the Ingenic OSS driver. It takes nothing short of 3.5MB of memory !!!. Makes no sense (and the used buffers are much smaller).



    This looks like manual to me , or am i wrong ?

  2. Re: memory, after removing OSS from my kernel build I seem to have gained ~3mb extra free memory on boot so maybe the RAM difference won't be as bad as you think.

  3. jz4740_ds.pdf is the *datasheet*. It tells you the features, packaing, pinout, packaging, eletrical characteristics and such, but doesn't say a word on how the integrated peripheals work. To give you an idea, a datasheet for a similar SOC uses to be about 500KB large, and the datasheet uses to be like 8MB or so (plus usually quite a bunch of application notes that further clarify specific features).

    It makes no sense: Ingenic releases the plain code but does not release the manual. It makes development difficult and does not provide any protection on intellectual property (which is the only remotely reasonable reason I can think of for not releasing the manual).

  4. After having spent quite a bunch of hours examining and trying to understand the Ingenic OSS driver code, I can't imagine why it might be using su much RAM, except for one of the many many many bugs sprinkled all over the code.

    I'm still reluctant to forego the OSS simplicity and lightweight. I've examined the uCOS-II code also released by Ingenic and looks like the OSS code is based in an ancient version of it. In theory one could "port" the newer (and presumably working) uCOS-II driver to OSS...

  5. I was surprised by the memory difference too. I just got the ALSA driver working through the OSS emulation layer "cat /dev/urandom > /dev/dsp" + horrible horrible noise through the headphones. You said you got no output at all when you tried?

  6. Awesome. Whatever works. :D

  7. fanoush found the Jz4740 manual, linked on the A320 freeforums in the official linux development thread! (why can't I link it here?)