Creating a WM8991 driver

Thought it might be interesting for people to take a peek at how we work.

As I stated in the previous blog post, it's necessary for us to figure out the WM8991 audio codec before we can call from the baseband (or listen to music). This is an interesting task because while there are datasheets for the WM8991 codec, and a Linux driver for it, those cannot be used immediately since it doesn't tell us where the inputs and outputs of the chip are connected to, and what protocol and clock divider settings the iPhone uses to talk to the chip (and must be configured on the chip). Those things are purely implementation specific.

In order to extract those settings, we need to be able to see those settings while the iPhone OS kernel is up and running and sound is playing. The chip does not use MMIO, so the register settings cannot be directly peeked at through /dev/kmem... but we're on the right track. Instead, I2C is used to communicate with the codec for setting those registers. It turns out that since some Wolfson codecs do not allow reading from the codec registers (only writing), the operating system has to "remember" what values registers are currently set to. That is, they are cached by operating system?

Where are they cached? Well, a quick look at the disassembly shows us some code that does the following (in pseudo-C)


if register > *(this + 0xA0)
return 0

return *((uint16_t*)(*(this + 0xA8) + register * 2))


Basically, we see that the class member at offset 0xA0 contains the total number of registers accessible on the Wolfson codec, while member 0xA8 is a pointer to an array of 16-bit values that represent the current values of those registers!

Now we seem to be home free... except for the fact that IO Kit C++ objects are dynamically allocated on the heap at runtime and there is no way to tell using static analysis where they will be during a particular boot of an operating system. How will we find the location of this C++ class (AppleWM8991Audio) so that we can peek at those values?

The answer is that every object in the IOKit subsystem is anchored to the IORegistry tree. You can actually take a peek at the tree from userland with the ioreg -l command. Every single node you see corresponds to a C++ object. However, the trouble is that there is no userland call to extract the in-kernel addresses of those objects... and that's what we need to be able to use /dev/kmem to peek at the right places.

Fortunately, the root of the IORegistry is pointed to by a constant, and it is possible to traverse the IORegistry manually from the root (provided you know the layout of all the C++ classes!). This is exactly what I wrote a utility called spelunk to perform: use /dev/kmem to manually traverse the IORegistry and find the in-memory instance, instance size, and vtable location of all of the objects in the IORegistry. Armed with this information, one can use dd and /dev/kmem to peek at the state of any of the objects inside kernel memory.

I made a series of dumps: registers-call-headphones, registers-call-speakers, registers-max-headphones, registers-max-speakers, registers-min-headphones, registers-min-speakers. Here is a diff of min-speakers and max-speakers, just to show you what we're looking for:


--- hex-registers-min-speakers 2010-05-04 15:44:19.000000000 -0700
+++ hex-registers-max-speakers 2010-05-04 15:45:39.000000000 -0700
@@ -2,7 +2,7 @@
00000010 20 80 20 80 00 00 c0 00 c0 01 00 00 00 01 c0 00 | . .............|
00000020 c0 00 00 00 01 00 00 17 00 10 40 10 00 00 04 08 |..........@.....|
00000030 8b 00 8b 00 8b 00 8b 00 b0 00 b0 01 66 00 22 00 |............f.".|
-00000040 f9 00 f9 01 00 00 03 01 57 00 00 01 ec 01 00 00 |........W.......|
+00000040 f9 00 f9 01 00 00 03 01 57 00 00 01 ff 01 00 00 |........W.......|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 00 00 80 01 00 00 00 00 03 00 00 00 |................|
00000070 00 00 08 00 00 00 00 00 87 00 85 00 fc 00 00 00 |................|


So it's fairly obvious how volume control for the speakers are done. Anyway, hopefully we can plug in these values, use the current i2s drivers, and audio will work!

Taking the Android Show on the Road

[This spring, the Android Developer Relations team (where I work, too) went on the road round the world with boxes of phones, their laptops bulging with slide-ware. Here we’ve combined write-ups from Billy Rutledge (who leads the Android evangelism team at Google HQ) and Reto Meier, who has a desk in London and wrote the book on Android. Featuring Europe is a little unfair, there are a ton of stories from Asia and North America too, but we wanted to keep this reasonably short. - Tim Bray]

Introduction

Billy: The Android Developer Lab (ADL) events are sponsored by Google to help drive developer interest in the Android platform and increase the quality, as well as quantity of creative, innovative applications in Android Market. This Android Developer Relations tour covered 18 locations around the world; we met with over five thousand enthusiastic Android developers and were thrilled to see the energy and creativity behind your applications.

Reto: The European leg of the Android Developer Lab World Tour consisted of me, Billy, and intrepid local volunteers covering eight labs in eleven days across six countries.

Some of the venues weren't like some of the others.

The goal of the tour was to meet and support local Android communities around the world, get developers excited about Android, and inspire them to create the next generation of innovative mobile applications.

Billy: In these sessions, we tried to help new and experienced developers move forward with their application plans. The core topics included:

  • Status of the Mobile Web

  • Android Opportunity for Developers

  • Android Market Overview

  • Android SDK Key Features

  • Code Labs ranging from HelloWorld to Threads to LiveWallpaper

Reto: The odyssey began in the London Google office, three labs over two days that played host to nearly 200 developers. Our surprise gifts arrived minutes after our first session started - a close enough call that our “there’s a package you need to sign for - any idea what it is?” charade was unscripted and only partially contrived. The heart palpitations were entirely real. London is home to some great Android developers including the teams behind ADC2 winners PlinkArt and BuzzDeck.

After London we battled ice and snow in Stockholm, where Anders Bond told us why Android is a good match for Spotify, and enjoyed the sound of 100 Swedes spontaneously erupting in applause.

In Paris 200 experienced community members joined us for two events at La Cantine. Speakers from FRAndroid, Sfeir, and Diotasoft covered everything from OpenGL development using the SDK to using AppEngine to create scalablends for your Android apps.

The Berlin event was huge, with over 150 developers travelling in from all across Germany. We saw demos including multi-touch pong, a Live Wallpaper of the changing Berlin skyline, and an app that showed us where to find (and rate!) the nearest public toilets. The night ended (in the small hours) with a private tour of c-base, an experience not to be missed.

Universidad Rey Juan Carlos made us feel very welcome in Madrid. Over 200 developers from across Spain (and Portugal) were in attendance including more winners of ADC1 (Biowallet) and ADC2 (SweetDreams).

Lessons Learned

Billy: Developers have matured to the point where they don't need to be convinced, they hunger for more technical details. While the intro level topics were well received, most developers have advanced beyond this point and seek guidance on more in-depth topics.

Reto:

  • It’s possible for one person to carry up to four boxes each containing ten Nexus Ones at a time.

  • You should not try to carry more than three boxes of Nexus Ones if the conditions are icy. Right Billy?

    Billy: Absolutely!!! :)

  • Announcing free smartphones to a room of developers always results in a spontaneous round of applause.

  • European mobile developers are smart, enthusiastic, and already building the next generation of epic apps for Android.

Billy: Post event series, we opened a volunteer survey to help us guide future efforts:

  • 78% of developers rated the event 4+ stars (of 5 stars)

  • 79% of developers say having Google engineers on hand is "extremely important"

  • 69% of developers say it is "extremely important" to see more test devices at future events

Looking Forward

[These are still at the planning stage, nothing here is a promise. - Tim]

Billy: The Android Developer Relations team plans to lead future Android Developer Lab events in 2010, building on the feedback from the February events. These future events will focus on deeper technical subjects, expecting the attendees to have a basic understanding of the Android platform. We will post the beginner material on-line as a prerequisite.

While it's impossible for us to reach all locations, we'll look to cover the key locations where Android devices are available.

Reto: I hadn’t even made it back to London when the requests started to roll in. Given the success of this tour I don’t imagine it will be too long.

It’s always a great experience meeting the Android developer community, we look forward to seeing you again soon!

Orange and Vodka - mixing mobile networks

Orange and Vodka - mixing mobile networks(shaken, not stirred).Good title for a book or article that heading. I thought this would be a useful post regarding the unusual occurrence of roaming onto a forbidden UK network from the home UK network.These screenshots record an event that happened on my wireless broadband. In the area I was located at the time Orange provided GPRS at 56K but download

Cell network association and SMS on iPhone 3G

This is just a small, incremental update. It looks like we're currently blocked on a driver for the WM8991 codec. This is because instead of sound data that should come out of the speakers directly to the baseband, the Wolfson codec now controls the speaker as well on the 3G. This is a significantly more sane design than what the 2G had, but it causes us some complications.

First, now a WM8991 driver has to be written before we can get any sound out of the device. This is contrary to the 2G where we can test the i2s functionality of the SoC relatively independently.

Second, in order to make or receive calls with the iPhone 3G, the WM8991 driver must be written and cooperating with the baseband. This is a significantly more complex arrangement than on the 2G, where that functionality can be controlled entirely through the baseband.

However, this is still all not very hard. If we had a timetable, I'd say we're "on track". But we don't so don't ask. :P

Also, as a result of this investigation, I can associate to the cell network and send and receive text messages from the 3G now. Of course, I had to port ultrasn0w into openiboot to do it... I had forgotten all about the fact that my phone was unlocked by ultrasn0w until now. :)

Lala Shutting Down

Interesting strategy Apple, buy out a competitor and shut 'em down.
I'm sure there is a deeper story behind all o this; atleast they are
offering credits!

Source:
Lala music service shutting down
http://usat.me?90471

Sent from my iPhone

Mobile Best Practice in Usability

Lately, I have been spending a good chunk of time at my 9-to-5 job researching and gathering the best mobile web practices in preparation of our own mobile website launch.  Its quite eye opening to see how creative and smart some of the top internet retailers is able to present an excellent mobile experience to their loyal customers.

In my own practice, I have been going down the path of visiting top retailers' websites and jolt down notes on things I liked, my overall consensus has been studying my desktop website metrics and present the most relevant and useful features to the mobile website with larger/finger friendly UI design.  The folks at Usability Sciences have 1-up me on this topic; they are offering  free Webinars around these topics; the latest one I attended was called "Mobile Best Practice in Usability" and what a great webinar it turned out to be. The presenter broke down the topic into smaller, but informative sessions (homepage, navigation, search, listing results) and showed examples of the good and the bad. It definitely reinforced my own thoughts and helped me think about the entire process in a much structured format. If you are tasked to mobilize your website, check out Usability Sciences free webinar series, I know I will.

(The screenshot is taken from Hotels.com, one of the mobile websites that I found to be very good at creating a solid mobile experience.  It seems like they have a solid understanding of their customer's needs and only presented what is the most useful and intuitive design - large buttons with good contrast in visual design, major functions like "Find a Hotel", "View Reservation" and "Customer Care" is presented clearly on the homepage.)

Casio Men's PAW1500Y-1 Pathfinder (Reverse LCD)

A while back, I reviewed the Casio PAW1300Y (exclusively only from Amazon) and I loved it.  Just this morning, I stumbled across its bigger cousin, the PAW1500Y from Amazon, once again, exclusively. If you are familiar with the pathfinder family, the PAW1500 is the larger of the two model available in North America; they are otherwise known as Pro Trek series in other parts of the world.  This exclusive model which ends with the letter "Y" has a unique reverse LCD which displays a white text over black.  Of course, being a pathfinder, it includes a tons of features for the outdoorsman:

* Solar powered (no battery required)
* Multi-band Atomic Radio (self adjusts time, always accurate)
* Moon phase, Tide phase, Thermometer
* Timer, stop watch, alarm(multi), etc.
* And a ton more features, check out this review here

I'm guessing Amazon must have had great success and demand for the PAW-1300Y model so they are now able to get a deal to sell the special PAW-1500Y model exclusively.  For around $300, its comparable to the regular PAW-1500 models.  Definitely a watch worthy of consideration for the gadget folks!