[alsa-devel] Tests of the hda-jack branch
Raymond Yau
superquad.vortex2 at gmail.com
Wed Nov 30 03:10:04 CET 2011
2011/11/30 Clemens Ladisch <clemens at ladisch.de>:
> David Henningsson wrote:
>> ... two patches - one adds a "device index" for mapping against pcm
>> devices on HDMI,
>
>> + kctl->id.device = device;
>
> In the general case, there is not always a 1:1 mapping between jacks and
> PCM devices, so I fear that a jack belonging to device 0 cannot be
> distinguished from a jack that has no specific device.
>
> There is a convention that id.device is a valid PCM device number if and
> only if id.iface is IFACE_PCM. However, it might be useful to map
> controls with IFACE_MIXER to PCM devices, so I'd propose a new TLV, like
> in the incomplete patch below.
>
>
> Regards,
> Clemens
>
>
> --- a/include/sound/tlv.h
> +++ b/include/sound/tlv.h
> @@ -37,6 +37,7 @@
> #define SNDRV_CTL_TLVT_DB_RANGE 3 /* dB range container */
> #define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */
> #define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
> +#define SNDRV_CTL_TLVT_PCM_DEVICE 6 /* jack (or other control?) maps to this device */
>
> #define _TLV_ITEM(type, ...) \
> (type), _TLV_LENGTH(__VA_ARGS__), __VA_ARGS__
> @@ -81,4 +82,9 @@
>
> #define TLV_DB_GAIN_MUTE -9999999
>
> +#define TLB_PCM_DEVICE_NUMBER_ITEM(devno) \
> + SNDRV_CTL_TLVT_PCM_DEVICE, 1 * sizeof(unsigned int), (devno)
> +#define DECLARE_TLV_PCM_DEVICE_NUMBER(name, devno) \
> + unsigned int name[] = { TLV_PCM_DEVICE_NUMBER_ITEM(devno) }
> +
> #endif /* __SOUND_TLV_H */
> --- a/sound/pci/hda/hda_jack.c
> +++ b/sound/pci/hda/hda_jack.c
> @@ -15,6 +15,7 @@
> #include <sound/core.h>
> #include <sound/control.h>
> #include <sound/jack.h>
> +#include <sound/tlv.h>
> #include "hda_codec.h"
> #include "hda_local.h"
> #include "hda_jack.h"
> @@ -210,7 +211,7 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_report_sync);
> * will have the given name and index.
> */
> int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
> - const char *name, int idx)
> + const char *name, int idx, int device)
> {
> struct hda_jack_tbl *jack;
> struct snd_kcontrol *kctl;
> @@ -223,6 +224,11 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
> kctl = snd_kctl_jack_new(name, idx, codec);
> if (!kctl)
> return -ENOMEM;
> + jack->tlv[0] = SNDRV_CTL_TLVT_PCM_DEVICE;
> + jack->tlv[1] = 1 * sizeof(unsigned int);
> + jack->tlv[2] = device;
> + kctl->tlv.p = jack->tlv;
> + kctl->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
> if (snd_hda_ctl_add(codec, nid, kctl) < 0)
> return -ENOMEM;
> jack->kctl = kctl;
> @@ -249,7 +255,7 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid,
> return 0;
>
> snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx);
> - err = snd_hda_jack_add_kctl(codec, nid, name, idx);
> + err = snd_hda_jack_add_kctl(codec, nid, name, idx, 0);
> if (err < 0)
> return err;
> return snd_hda_jack_detect_enable(codec, nid, 0);
> --- a/sound/pci/hda/hda_jack.h
> +++ b/sound/pci/hda/hda_jack.h
> @@ -22,6 +22,7 @@ struct hda_jack_tbl {
> unsigned int jack_detect:1; /* capable of jack-detection? */
> unsigned int jack_dirty:1; /* needs to update? */
> struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */
> + unsigned int tlv[3];
> #ifdef CONFIG_SND_HDA_INPUT_JACK
> int type;
> struct snd_jack *jack;
> @@ -76,7 +77,7 @@ static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
> }
>
> int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
> - const char *name, int idx);
> + const char *name, int idx, int device);
> int snd_hda_jack_add_kctls(struct hda_codec *codec,
> const struct auto_pin_cfg *cfg);
>
Does this solve the problem of selecting the correct capture source
when the codec have more than one adc
1) realek codec with two adc , capture and alt_capture device
ARECORD
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: ALC892 Analog [ALC892 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
Simple mixer control 'Input Source',0
Capabilities: cenum
Items: 'Mic' 'Internal Mic' 'Line'
Item0: 'Internal Mic'
Simple mixer control 'Input Source',1
Capabilities: cenum
Items: 'Mic' 'Internal Mic' 'Line'
Item0: 'Mic'
2) ad198x codec with 3 adc and 3 capture subdevices
Line-Out Front Jack
Line-Out Surround Jack
Line-Out CLFE Jack
Line-Out Side Jack
Front Headphone Jack
Front Mic Jack
Rear Mic Jack
Line Jack
card 1: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
Subdevices: 3/3
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Simple mixer control 'Input Source',0
Capabilities: cenum
Items: 'Mix' 'Front Mic' 'Rear Mic' 'Line' 'CD'
Item0: 'Front Mic'
Simple mixer control 'Input Source',1
Capabilities: cenum
Items: 'Mix' 'Front Mic' 'Rear Mic' 'Line' 'CD'
Item0: 'Front Mic'
Simple mixer control 'Input Source',2
Capabilities: cenum
Items: 'Mix' 'Front Mic' 'Rear Mic' 'Line' 'CD'
Item0: 'Line'
More information about the Alsa-devel
mailing list