Older blog entries for broonie (starting at number 106)

ASoC updates in 3.1

Linus released version 3.1 of the kernel at Kernel Summit this morning. This has been another fairly quiet release for the framework with a few nice power optimizations, a range of driver enhancements and a fairly small set of new drivers.

  • Lots of cleanups to the register cache code in preparation for moving the code to the regmap API.
  • Support for maintaining lower power when in mostly idle states like microphone detection.
  • Support for weak DAPM routes, enabling better pop/click performance for paths like sidetones.
  • New CODEC drivers for Analog Devices ADAV80x, Sigmatel STA32x and Wolfson WM8728 and WM8983.

Posted from Prague, Prague, Czech Republic.

Syndicated 2011-10-24 09:36:56 from Technicalities

regmap – a register map abstraction for the Linux kernel

A good proportion of I2C and SPI device drivers in the kernel contain some very similar code for accessing the register maps of hardware connected to those buses – most hardware designers have solved the problem of providing very similar ways. Linux 3.1 introduces a new kernel API called regmap which factors out this code from the drivers, saving code and making it much easier to share infrastructure. There’s been an implementation of this in ASoC for some time now, the regmap API makes it available to all drivers.

The version of this API in version 3.1 is very simple, just factoring out the simplest level of physical I/O from the devices. Devices register with the regmap API by providing a struct regmap_config (which currently only allows the sizes of the register addresses and values to be specified) and the bus-specific structure to it. They can then use simple read and write operations on the device:

int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);

The API handles everything to do with formatting the data for transmission and parsing data coming back from the device. Block functions are also provided to allow multiple registers to be read or written simultaneously. Even with this basic level of support we end up saving quite a bit of code as drivers are converted to use the API.

The changes sitting in -next for version 3.2 take this a step further, adding support for more variations on SPI registers, a debugfs interface for dumping the device registers, register cache support courtesy of my colleague Dimitris Papastamos and trace points for dynamic instrumentation of the system.

Posted from Santa Rosa, California, United States.

Syndicated 2011-09-30 12:46:54 from Technicalities

Making patches easy to review

One of the big things that seems to cause a learning curve for many new contributors for Linux and other projects that make a big effort with code review is the process of putting patches together in a way that makes the code review process more smoothly. This is a fairly straightforward thing but it takes a bit of getting used to for people who aren’t used to the idea of patches and commits as a means of communication rather than just a mechanical thing you do to get changes into the codebase. In cases I’ve seen the difficulty . I’m mostly going to talk about this in the Linux context where patches are reviewed by e-mail but the same ideas apply if you’re using a tool like gerrit to do the reviews; it’s also mostly focused on detailed review rather than design level review.

The basic idea is fairly simple – the goal is to make it as easy as possible for someone to read and understand the change that’s being made.

  • Make sure the code matches the coding style of the code being modified.
  • Make patches as small and self contained as possible – having many patches is much easier than having complicated patches.
  • Provide a changelog clearly describing everything that’s going on in the patch.

The result here should be something that’s easy for people to review. Keeping in line with the coding style is just a generally good idea for code legibility which is obviously a key thing for people reading the code to review it. Having a clear description of the change means that the reviewer knows what the patch is supposed to do and can verify that the patch does that rather than having to spend effort figuring out if whatever the code is doing is intentional. Making changes small and simple makes them much easier to think about – the idea itself is easier to keep in your head and there’s fewer things to check so the process of validating things is easier.

It’s not just about making life easier for reviewers. The process of making simple changes and describing them clearly can be really helpful for spotting issues when writing code; it forces you to think through what’s being done much more clearly than might happen otherwise. There’s also an ongoing benefit to anyone working with the code in the future. Since each change ends up including at least some explanation of what the code is supposed to do and since revision control systems generally have some equivalent of git annotate it’s usually reasonably straightforward to find the changes that introduced the code that you’re looking at. Small changes with good changelog entries mean it’s much more likely that the changelog will provide a useful explanation as to what the author was thinking and explain why the code is the way that it is. It’s much harder for documentation to go missing from the SCM than it is for it to go missing elsewhere, and it’s much more likely that documentation in the commit is going to be up to date than external documentation, especially prewritten design documentation.

In the context of large scale reviews the usual technique is to combine reviews of individual changes with a read through of the final code after all the individual changes have been applied. Often the build up of the code through incremental changes is a enough to show the overall design but a read through of the final code can be helpful in allowing people to understand where things are going.

Posted from Santa Rosa, California, United States.

Syndicated 2011-09-09 10:44:33 from Technicalities

ASoC updates in 3.0

Linux 3.0 was released today – another fairly quiet release for the ASoC core, plus the usual collection of new drivers:

  • Support DAPM controls that affect multiple paths – mainly used for single register bits that affect the routing for a stereo pair of audio streams.
  • Simplifications in the cache infrastructure.
  • New machine drivers for iPAQ hx4700, PCM hookup for WM8580 on Samsung reference platforms and Wolfson Speyside, plus a generalization of the Tegra Harmony driver to cover a range of other platforms based off a similar reference design.
  • New CODEC drivers for AK4641, MAX98095 and WM8996.

Posted from Edinburgh, Scotland, United Kingdom.

Syndicated 2011-07-22 08:49:47 from Technicalities

I know that place

One slightly unexpected effect of all the travel I’ve been doing recently is that I get a real, visceral sense of place from some slightly surprising places when I see them on the big screen. Having an idea of how the place really is, how people behave, how the air feels, how the food tastes, how it smells, a sense of what’s around the corner and beyond the camera. A sense of memory, not of imagination or of an idea of what a place should be.

San Francisco is one place this happens for and is perhaps not so surprising – it is a pretty distinctive place after all and the imagery was already familiar from countless movies and TV shows before I ever went there. What was a bit more surprising was a random suburban area in South Korea; Korea has had a real building boom amid all the growth it’s had which has resulted in a certain look and feel to the architecture and the cities being very common though not distinctive of any once place. That’s the space where a lot of the more “real world” Korean films are set, and it’s the one I recognise. Don’t think I’ve ever seen a film that ventured into Itaewon (이태원동), mind you.

It’s a much stronger feeling of recognition than I get with anywhere in the UK, I think purely due to the surprise factor. Having a good picture of Edinburgh isn’t a great surprise, finding how quickly I’ve built one up of places on other continents much more so.

Syndicated 2011-06-25 23:36:55 from Technicalities

ASoC updates in 2.6.39

Linux 2.6.39 was released earlier today. This release includes a few updates, the main user visible one being that machine drivers can now be registered as regular devices rather than using the soc-audio device.

  • Support for registering machine drivers as first class devices rather than using the soc-audio device. Support for the soc-audio device will be removed at some point in the future.
  • Support for ordering widget power changes within widget types, helping with large CODECs and multi-stage amplifiers.
  • Support for waiting for multiple slow events to complete during DAPM sequences, making it easier to handle things like DC offset correction on multiple outputs.
  • CPU support for Intel Medfield and nVidia Tegra2.
  • CODEC support for Cirrus CS4271, Freescale SGTL5000, Maxim MAX8950, National Semiconductors LM4857, TI SN95031 and Wolfson WM8991
  • Machine support for Intel Medfield MID reference platforms, nVidia Harmony, and Visstrim M10.

Syndicated 2011-05-19 21:26:18 from Technicalities

ASoC conference 2011 – Edinburgh, 4-5th May

There will be an ASoC conference in Edinburgh 4th-5th May this year, held in the Scotch Malt Whisky Society in Edinburgh. Full details are in the announcement – if you’ve got an interest in embedded audio on Linux I recommend you attend, there’s a lot of development going on in this area right now and it promises to be a great opportunity to coordinate development plans and make sure things work well for everyone. Having met quite a few of the attendees who’ve signed up already I can also say that it should be an opportunity to meet some really excellent people.

Syndicated 2011-03-26 00:20:06 from Technicalities

ASoC updates in 2.6.38

Linux 2.6.38 was just released, with another big update to ASoC including:

  • Enhancements to multi-component from Jarkko Nikula allowing multiple devices of the same type to be included in one system (and handling other overlaps between devices) and support cross device DAPM.
  • Support from Dimitris Papastamos for compressing the register cache in memory using either an rbtree or LZO, giving substantial memory savings on CODECs with large register maps, especially those that are sparse. This is especially beneficial to modern devices with integrated DSPs. This can be enabled by machine drivers, though CODECs can also provide defaults.
  • Addition of trace points around DAPM and register I/O operation, allowing very low overhead logging without interfering with the main system log, useful for collecting verbose diagnostics without interfering with system operation and for always enabled flight recorder style tracking for intermittent problems. I blogged about ASoC trace points in more detail at the time.
  • Restructuring of the Samsung CPU support from Jassi Brar, including a number of really good usability improvements. This supports features of more modern CPUs such as the ability to run two audio streams to a single I2S port and includes a number of API simplifications which should also make developing drivers for Samsung systems much easier.
  • New CODEC drivers for ALC5621/2/3, WM8737, WM8770 and WM8958.
  • Machine support for HP iPAQ H1940, HP t5325 thin clients and OpenRC Ultimate.

Syndicated 2011-03-15 12:58:48 from Technicalities

Changing core code

One of the biggest differences between working on most other OSs and working upstream on drivers for the Linux kernel is that elsewhere the core is usually a fixed thing that has been released and can’t really be changed, even if source is available (which may not even be the case). If whatever subsystem you’re working in can’t cope with the thing you’re trying to express then one of the things it’s really useful to be good at is working out ways to implement the behaviour that’s required behind the back of the subsystem. It’s very common to see such code in drivers submitted by hardware vendors, particularly those that are new to Linux, as this is such a big mindset shift.

With kernel development the approach is much more to make sure that the core can cope with whatever needs expressing. It’s not always done in the core – for example, sometimes the issue is due to unusually limited hardware and very likely to never come up again – but it’s very unusual to see code merged that doesn’t at least fit in with the design of the subsystem.

This post is inspired by a brief exchange with Thomas Gleixner on linux-kernel who articulated the advantages of doing things this way very well:

 - It's usually simpler and faster as the core code has all the
   necessary information. So that's even an argument which managers
   might understand.

 - Such workarounds, when not caught, tend to spread themself
   magically because driver writers checkout the existing code of
   similar devices and copy/paste/modify^Wuglify them over and over.

 - In the worst case such workarounds make the core maintainence
   harder and in some cases impossible, because they silently imply
   semantics on the core w/o the core maintainer knowing about them.

The last point is the most important one to me as a subsystem maintainer – I really don’t want to be merging code that is going to create issues with ongoing development of the subsystem. This is all another facet of the policy on stable APIs: APIs are only worth working around if they’re fixed, and the assumptions that end up embedded in a workaroud are as much part of the API as the explicit interfaces.

It’s things like this that make Linux such a pleasure to work on.

Syndicated 2011-03-13 21:12:10 from Technicalities

Updating the kernel on the Nexus S

Building the kernel for the Nexus S is straightforward – the kernel is public as one would expect so it’s simply a matter of building it using the standard Linux build system (the machine is called herring in the code). There is one gotcha, though – the driver for the BCM4329 WiFi controller is a loadable kernel module rather than being built into the image. This means you need to copy it onto the device filesystem separately to flashing the kernel itself if you’re only updating the kernel. The procedure I use for this is below – it’s straightforward but I’m posting it here to make it a bit more discoverable.

First we make the system partition writable:

adb root
adb remount

Then copy the BCM4329 driver over (the path to the driver here is running from the root of the kernel tree:

adb push drivers/net/wireless/bcm4329/bcm4329.ko /system/modules

Finally, reboot into the bootloader and flash the actual kernel:

adb reboot bootloader
fastboot flash zimage arch/arm/boot/zImage
fastboot reboot

Note that some of these commands may return before the operation they’ve started has completed so you may need to wait for the phone at various points.

As with updating the main system firmware the above requires an unlocked device which voids your warranty.

Syndicated 2011-02-14 13:12:15 from Technicalities

97 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!