Here is the project: getcrankshaft.com

It makes a Pi an Android Auto head unit. Google expects the head unit to have a microphone to support voice input. Although technically the phone can use its microphones, but we can't expect Google to help us lifting that (artificial) limitation. It's a RE'd protocol and app. What will we say to them? We made this Frankenstein totally-unauthorized reverse-engineered distro that sorts of encouraging people to DIY their car hardware so they can use Android Auto and it totally won't cause you troubles if anything happens to the users. Please help us by allowing the phone to take microphone input for OK Google on Android Auto?

So, in short, we need a microphone for the head unit. The Pi doesn't have built-in support for microphones. So I wanted to support the Adafruit MEMS mic which is a very simple and cheap mic that works on the I2S bus. Otherwise, we would have to buy a USB microphone/an expensive DAC and waste another USB port to achieve the "OK Google" functionality.

Using the USB mic/dac means we can't realistically use a Raspberry A+ and Zero either, because we have to use the only available port for the phone connection, not the mic. That I2S mic is $6, the BOm is perhaps $2 and thus can be easily integrated into other boards.

The problem: Low volume. It needs something called the ALSA softvol which boosts the volume level for it to work. But I couldn't figure out how to implement a volume boost for the mic. I have documented the behavior here: https://github.com/htruong/snd-i2s_rpi. Adafruit's solution to boost the volume for ALSA programs: https://learn.adafruit.com/adafruit-i2s-mems-microphone-brea.... Too bad it doesn't work with applications that expect the microphone to work out of the box, and anything that uses pulseaudio doesn't work either. Without a configuration that works out of the box for Pulse, we can't say we support that configuration. We can't design a cheap hardware that will have the mic integrated.

I have tried to look at the kernel module code and see what I could do. I have looked at a number of other sound cards to see how they implemented it to fix it from the source -- and still got stuck. Along the way, I made the module DKMS-compatible, planning to push the code upstream to the RPi kernel. I have bought additional DACs to see if I could learn anything from them, and see if is there any way I could come up with a simpler/cheaper DAC hardware. I have asked for help. I have emailed people to see if anyone knows the answer.

I tried fixing ALSA.conf for like 10 hours to make it take the "boosted microphone" as the default mic. It sort-of worked for ALSA programs, but it broke Pulse. Which means I got back to square 0.

Turns out I can neither easily fix the hardware nor the kernel driver nor ALSA.conf. It's just Pulseaudio that needs two lines of code for it to use the mic with boosted volume.

2-lines solution: https://github.com/htruong/crankshaft/blob/master/hardware_s...

Looking back, fixing Pulse seems like the obvious solution to take, but somehow it didn't seem that way to me when I faced it. For me, to discover every single paragraph I wrote above, it took me at least 5-10 hours each. The hindsight is 20/20, and you can say someone who knows Pulse would know that's the obvious answer. But I didn't know Pulse - I needed to learn linux driver, i2s, rpi, alsa, kernel, pulse all at the same time to come up with that answer.

If I ever get to 1000 people on this planet to adopt my software, then I think that'd be somewhat worthy. I'd argue that I will save each of them at least $4 compared to buying a USB DAC+mic, so that's $4000 saved. Which gets me to $40/hour rate... :)