From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: [RFC] Channel mapping API Date: Tue, 21 Aug 2012 12:31:57 +0200 Message-ID: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 8C25D26505E for ; Tue, 21 Aug 2012 12:31:56 +0200 (CEST) Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 851FD9D938 for ; Tue, 21 Aug 2012 12:31:57 +0200 (CEST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org Hi, this is a progress report of my longstanding TODO, the channel map API implementation. I'm going to cover this at Plumbers audio uconf, so we can discuss details there, too. The channel mapping API provides a method for user-space to query, get and set the channel map of a PCM stream. It's required for assigning channels properly for multi-channel streams. * KERNEL IMPLEMENTATION In my latest attempt, I implemented with control elements. A control element is created for each PCM substream with the corresponding device and substream index. Then it gives a TLV for querying maps, a read op for obtaining the current map, and optionally a write op for setting the map. The obvious merit by this way is that no extra kernel ABI is required. A couple of new helper functions are provided for assigning standard channel maps. Currently, HD-audio and AC97 drivers has some implementation. * ALSA-LIB IMPLEMENTATION The additional alsa-lib API functions look like: int **snd_pcm_query_chmaps(snd_pcm_t *pcm); int *snd_pcm_get_chmap(snd_pcm_t *pcm); int snd_pcm_set_chmap(snd_pcm_t *pcm, const int *map); snd_pcm_query_chmaps() returns the list of channel maps. A channel map is represented by an integer array, beginning with the channel map type, followed by the number of channels, and the position of each channel, e.g. { SND_CHMAP_FIXED, 4, SND_CHMAP_FL, SND_CHMAP_FR, SND_CHMAP_RL, SND_CHMAP_RR } snd_pcm_get_chmap() returns the currently assigned channel map for the given PCM stream. If the PCM is before prepared, it fills UNKNOWN. When a driver allows user to change the channel map, user can call snd_pcm_set_chmap(). For example, HDMI allows you to choose whether it's 4.0 or 3.1 output. * RESOURCES The latest kernel patchset is found in sound-unstable tree topic/tlv-chmap branch. git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable.git topic/tlv-chmap The alsa-lib portion is found in a tree on github topic/chmap branch. git://github.com/tiwai/alsa-lib.git topic/chmap thanks, Takashi