From: Clemens Ladisch <clemens@ladisch.de>
To: David Henningsson <david.henningsson@canonical.com>
Cc: Takashi Iwai <tiwai@suse.de>,
ALSA Development Mailing List <alsa-devel@alsa-project.org>
Subject: Re: Tests of the hda-jack branch
Date: Tue, 29 Nov 2011 21:51:45 +0100 [thread overview]
Message-ID: <4ED545E1.3040409@ladisch.de> (raw)
In-Reply-To: <4ED535CA.1080108@canonical.com>
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);
next prev parent reply other threads:[~2011-11-29 20:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-29 19:43 Tests of the hda-jack branch David Henningsson
2011-11-29 20:03 ` Mark Brown
2011-11-30 6:41 ` Takashi Iwai
2011-11-30 9:26 ` Mark Brown
2011-11-29 20:51 ` Clemens Ladisch [this message]
2011-11-30 2:10 ` Raymond Yau
2011-11-30 6:38 ` Clemens Ladisch
2011-11-30 6:46 ` Takashi Iwai
2011-11-30 2:43 ` Raymond Yau
2011-11-30 8:05 ` David Henningsson
2011-11-30 6:31 ` Takashi Iwai
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=4ED545E1.3040409@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
--cc=david.henningsson@canonical.com \
--cc=tiwai@suse.de \
/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.