All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Wurmsdobler <peter@wurmsdobler.org>
To: alsa-devel@alsa-project.org
Subject: From snd_kcontrol_new_t to amixer
Date: Tue, 13 May 2008 19:12:06 +0100	[thread overview]
Message-ID: <4829D9F6.205@wurmsdobler.org> (raw)

Hello,

I am puzzled by an observation that runs against my common sense. The 
pmic-alsa-mixer.c provides 6 (six) snd_kcontrol_new_t controls with 
their callback functions, name and other members, then registers 
themusing snd_ctl_add(...). However, amixer shows only 5 (five), and all 
with different names. What is the process of generating these names if 
not from the kernel structures?

By looking through the mixer related code in alsa-utils and alsa-libs, I 
see that somehow the library loads the mixer controls and possibly 
retrieves all the information provided by them, including their names. 
Either some piece of code shortens the names defined in the driver, or 
it maps them to some generic controls. Any suggestions?

The system I am working on uses a Freescale imx27 in conjunction with an 
MC13783 power management IC, also responsible for audio (it provides a 
voice codec and a stereo dac). The kernel used is a 2.6.19.2 as part of 
ltib from Freescale. amixer tells me:

mx27# amixer
Simple mixer control 'Master',0
   Capabilities: pvolume pvolume-joined cvolume
   Playback channels: Mono
   Capture channels: Mono
   Limits: Playback 0 - 100 Capture 0 - 100
   Mono: Playback 0 [0%] Capture 0 [0%]
Simple mixer control 'Master Balance',0
   Capabilities: pvolume pvolume-joined
   Playback channels: Mono
   Limits: Playback 0 - 100
   Mono: Playback 50 [50%]
Simple mixer control 'Master Input',0
   Capabilities: cvolume
   Capture channels: Mono
   Limits: Capture 0 - 7
   Mono: Capture 1 [14%]
Simple mixer control 'Master Monoconfig',0
   Capabilities: pvolume pvolume-joined
   Playback channels: Mono
   Limits: Playback 0 - 3
   Mono: Playback 0 [0%]
Simple mixer control 'Master Output',0
   Capabilities: pvolume pvolume-joined
   Playback channels: Mono
   Limits: Playback 0 - 15
   Mono: Playback 12 [80%]


snd_kcontrol_new_t pmic_control_pb_vol __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Playback Volume",
	.index = 0x00,
	.info = pmic_pb_volume_info,
	.get = pmic_pb_volume_get,
	.put = pmic_pb_volume_put,
	.private_value = 0xffab1,
};

snd_kcontrol_new_t pmic_control_pb_bal __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Balance Playback Volume",
	.index = 0x00,
	.info = pmic_pb_balance_info,
	.get = pmic_pb_balance_get,
	.put = pmic_pb_balance_put,
	.private_value = 0xffab2,
};
snd_kcontrol_new_t pmic_control_pb_mono __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Monoconfig Playback Volume",
	.index = 0x00,
	.info = pmic_pb_monoconfig_info,
	.get = pmic_pb_monoconfig_get,
	.put = pmic_pb_monoconfig_put,
	.private_value = 0xffab2,
};
snd_kcontrol_new_t pmic_control_op_sw __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Output Playback Volume",
	.index = 0x00,
	.info = pmic_mixer_output_info,
	.get = pmic_mixer_output_get,
	.put = pmic_mixer_output_put,
	.private_value = 0xffab4,
};

snd_kcontrol_new_t pmic_control_cap_vol __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Capture Volume",
	.index = 0x00,
	.info = pmic_cap_volume_info,
	.get = pmic_cap_volume_get,
	.put = pmic_cap_volume_put,
	.private_value = 0xffab5,
};
snd_kcontrol_new_t pmic_control_ip_sw __devinitdata = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Input Capture Volume",
	.index = 0x00,
	.info = pmic_cap_input_info,
	.get = pmic_cap_input_get,
	.put = pmic_cap_input_put,
	.private_value = 0xffab5,
};

int mxc_alsa_create_ctl(snd_card_t * card, void *p_value)
{
	int err = 0;

	if ((err = snd_ctl_add(card,
		snd_ctl_new1(&pmic_control_op_sw, p_value))) < 0)
		return err;

	if ((err = snd_ctl_add(card,
		snd_ctl_new1(&pmic_control_pb_vol, p_value))) < 0)
		return err;
	
	if ((err = snd_ctl_add(card,
		snd_ctl_new1(&pmic_control_pb_mono, p_value))) < 0)
		return err;
	
	if ((err = snd_ctl_add(card,
		snd_ctl_new1(&pmic_control_pb_bal, p_value))) < 0)
		return err;
	
	if ((err = snd_ctl_add(card,
		snd_ctl_new1(&pmic_control_cap_vol, p_value))) < 0)
		return err;
	
	if ((err = snd_ctl_add(card,
		snd_ctl_new1(&pmic_control_ip_sw, p_value))) < 0)
		return err;

	return 0;
}

Cheers,
peter

             reply	other threads:[~2008-05-13 18:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13 18:12 Peter Wurmsdobler [this message]
2008-05-14  9:08 ` From snd_kcontrol_new_t to amixer Clemens Ladisch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4829D9F6.205@wurmsdobler.org \
    --to=peter@wurmsdobler.org \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.