* Tests of the hda-jack branch
@ 2011-11-29 19:43 David Henningsson
2011-11-29 20:03 ` Mark Brown
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: David Henningsson @ 2011-11-29 19:43 UTC (permalink / raw)
To: Takashi Iwai, ALSA Development Mailing List
[-- Attachment #1: Type: text/plain, Size: 393 bytes --]
Hi Takashi,
I've done some more tests of your branch now, and the new names seems to
work for my machine here.
I'm attaching two patches - one adds a "device index" for mapping
against pcm devices on HDMI, the other one is a backport for the
driver-build tree.
What are your thoughts on how to proceed, when do you think this is
ready to be merged into the topic/hda branch?
// David
[-- Attachment #2: 0001-alsa-driver-build-Make-new-jack-API-compile-on-older.patch --]
[-- Type: text/x-patch, Size: 982 bytes --]
>From 0f14d27ffebf72b636c765e95003c780a1cb8c07 Mon Sep 17 00:00:00 2001
From: David Henningsson <david.henningsson@canonical.com>
Date: Tue, 29 Nov 2011 19:41:27 +0100
Subject: [PATCH] alsa-driver-build: Make new jack API compile on older
kernels
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
acore/ctljack.c | 4 ++++
pci/hda/hda_jack.c | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)
create mode 100644 acore/ctljack.c
create mode 100644 pci/hda/hda_jack.c
diff --git a/acore/ctljack.c b/acore/ctljack.c
new file mode 100644
index 0000000..4d9352f
--- /dev/null
+++ b/acore/ctljack.c
@@ -0,0 +1,4 @@
+#define __NO_VERSION__
+#include "adriver.h"
+#include "../alsa-kernel/core/ctljack.c"
+
diff --git a/pci/hda/hda_jack.c b/pci/hda/hda_jack.c
new file mode 100644
index 0000000..160ad73
--- /dev/null
+++ b/pci/hda/hda_jack.c
@@ -0,0 +1,3 @@
+#include "adriver.h"
+#include "../../alsa-kernel/pci/hda/hda_jack.c"
+
--
1.7.5.4
[-- Attachment #3: 0001-ALSA-HDA-Jack-Make-device-indices-for-HDMI.patch --]
[-- Type: text/x-patch, Size: 2637 bytes --]
>From 4b4c17927eb05b460a9788d9dfc9a03ace5d160e Mon Sep 17 00:00:00 2001
From: David Henningsson <david.henningsson@canonical.com>
Date: Tue, 29 Nov 2011 20:19:56 +0100
Subject: [PATCH] ALSA: HDA/Jack: Make device indices for HDMI
Make sure we can associate HDMI Jacks with the correct PCM devices.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
sound/pci/hda/hda_jack.c | 5 +++--
sound/pci/hda/hda_jack.h | 2 +-
sound/pci/hda/patch_hdmi.c | 3 ++-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
index 3949015..0b1f72c 100644
--- a/sound/pci/hda/hda_jack.c
+++ b/sound/pci/hda/hda_jack.c
@@ -210,7 +210,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 +223,7 @@ 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;
+ kctl->id.device = device;
if (snd_hda_ctl_add(codec, nid, kctl) < 0)
return -ENOMEM;
jack->kctl = kctl;
@@ -249,7 +250,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);
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
index f8f97c7..fcca96c 100644
--- a/sound/pci/hda/hda_jack.h
+++ b/sound/pci/hda/hda_jack.h
@@ -76,7 +76,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);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index bb8cfc6..9689c8d 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1277,7 +1277,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
if (err < 0)
return err;
err = snd_hda_jack_add_kctl(codec, per_pin->pin_nid,
- "HDMI", pin_idx);
+ "HDMI", pin_idx,
+ spec->pcm_rec[pin_idx].device);
if (err < 0)
return err;
}
--
1.7.5.4
[-- Attachment #4: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
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-29 20:51 ` Clemens Ladisch
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2011-11-29 20:03 UTC (permalink / raw)
To: David Henningsson; +Cc: Takashi Iwai, ALSA Development Mailing List
On Tue, Nov 29, 2011 at 08:43:06PM +0100, David Henningsson wrote:
> What are your thoughts on how to proceed, when do you think this is
> ready to be merged into the topic/hda branch?
I'm still rather sad that this infrastructure is all totally separate to
the existing jack infrastructure, one of the goals of having common
infrastructure was to insulate drivers from having to deal with changes
in the APIs used for reporting and I certainly don't want to have to
have all the drivers individually reporting via all the APIs (especially
not with the multiswitch API coming along too).
I've not really reviewed the code beyond noticing that, I'd been waiting
for it to turn up on the list.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 19:43 Tests of the hda-jack branch David Henningsson
2011-11-29 20:03 ` Mark Brown
@ 2011-11-29 20:51 ` Clemens Ladisch
2011-11-30 2:10 ` Raymond Yau
` (2 more replies)
2011-11-30 2:43 ` Raymond Yau
2011-11-30 6:31 ` Takashi Iwai
3 siblings, 3 replies; 11+ messages in thread
From: Clemens Ladisch @ 2011-11-29 20:51 UTC (permalink / raw)
To: David Henningsson; +Cc: Takashi Iwai, ALSA Development Mailing List
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);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 20:51 ` Clemens Ladisch
@ 2011-11-30 2:10 ` Raymond Yau
2011-11-30 6:38 ` Clemens Ladisch
2011-11-30 6:46 ` Takashi Iwai
2 siblings, 0 replies; 11+ messages in thread
From: Raymond Yau @ 2011-11-30 2:10 UTC (permalink / raw)
To: ALSA Development Mailing List
2011/11/30 Clemens Ladisch <clemens@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'
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 19:43 Tests of the hda-jack branch David Henningsson
2011-11-29 20:03 ` Mark Brown
2011-11-29 20:51 ` Clemens Ladisch
@ 2011-11-30 2:43 ` Raymond Yau
2011-11-30 8:05 ` David Henningsson
2011-11-30 6:31 ` Takashi Iwai
3 siblings, 1 reply; 11+ messages in thread
From: Raymond Yau @ 2011-11-30 2:43 UTC (permalink / raw)
To: ALSA Development Mailing List
2011/11/30 David Henningsson <david.henningsson@canonical.com>:
> Hi Takashi,
>
> I've done some more tests of your branch now, and the new names seems to
> work for my machine here.
>
> I'm attaching two patches - one adds a "device index" for mapping against
> pcm devices on HDMI, the other one is a backport for the driver-build tree.
>
> What are your thoughts on how to proceed, when do you think this is ready to
> be merged into the topic/hda branch?
>
> // David
>
http://git.alsa-project.org/?p=alsa-kernel.git;a=blob_plain;f=Documentation/sound/alsa/HD-Audio-Controls.txt
Does it handle "Independent HP" ?
VIA codecs
----------
* Independent HP
When this enum control is enabled, the headphone output is routed
from an individual stream (the third PCM such as hw:0,2) instead of
the primary stream. In the case the headphone DAC is shared with a
side or a CLFE-channel DAC, the DAC is switched to the headphone
automatically.
Analog codecs
--------------
* Independent HP
When this enum control is enabled, the headphone output is routed
from an individual stream (the third PCM such as hw:0,2) instead of
the primary stream.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 19:43 Tests of the hda-jack branch David Henningsson
` (2 preceding siblings ...)
2011-11-30 2:43 ` Raymond Yau
@ 2011-11-30 6:31 ` Takashi Iwai
3 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2011-11-30 6:31 UTC (permalink / raw)
To: David Henningsson; +Cc: ALSA Development Mailing List
At Tue, 29 Nov 2011 20:43:06 +0100,
David Henningsson wrote:
>
> Hi Takashi,
>
> I've done some more tests of your branch now, and the new names seems to
> work for my machine here.
>
> I'm attaching two patches - one adds a "device index" for mapping
> against pcm devices on HDMI, the other one is a backport for the
> driver-build tree.
Thanks, the alsa-driver-build one was already found in
alsa-driver-build-unstable tree. Actually the branch is included in
sound-unstable tree, too.
> What are your thoughts on how to proceed, when do you think this is
> ready to be merged into the topic/hda branch?
We still need to think of PCM and control-NID mapping. At least,
decide what to be done.
thanks,
Takashi
>
> // David
>
> [2 0001-alsa-driver-build-Make-new-jack-API-compile-on-older.patch <text/x-patch (7bit)>]
> >From 0f14d27ffebf72b636c765e95003c780a1cb8c07 Mon Sep 17 00:00:00 2001
> From: David Henningsson <david.henningsson@canonical.com>
> Date: Tue, 29 Nov 2011 19:41:27 +0100
> Subject: [PATCH] alsa-driver-build: Make new jack API compile on older
> kernels
>
> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
> ---
> acore/ctljack.c | 4 ++++
> pci/hda/hda_jack.c | 3 +++
> 2 files changed, 7 insertions(+), 0 deletions(-)
> create mode 100644 acore/ctljack.c
> create mode 100644 pci/hda/hda_jack.c
>
> diff --git a/acore/ctljack.c b/acore/ctljack.c
> new file mode 100644
> index 0000000..4d9352f
> --- /dev/null
> +++ b/acore/ctljack.c
> @@ -0,0 +1,4 @@
> +#define __NO_VERSION__
> +#include "adriver.h"
> +#include "../alsa-kernel/core/ctljack.c"
> +
> diff --git a/pci/hda/hda_jack.c b/pci/hda/hda_jack.c
> new file mode 100644
> index 0000000..160ad73
> --- /dev/null
> +++ b/pci/hda/hda_jack.c
> @@ -0,0 +1,3 @@
> +#include "adriver.h"
> +#include "../../alsa-kernel/pci/hda/hda_jack.c"
> +
> --
> 1.7.5.4
>
>
>
> [3 0001-ALSA-HDA-Jack-Make-device-indices-for-HDMI.patch <text/x-patch (7bit)>]
> >From 4b4c17927eb05b460a9788d9dfc9a03ace5d160e Mon Sep 17 00:00:00 2001
> From: David Henningsson <david.henningsson@canonical.com>
> Date: Tue, 29 Nov 2011 20:19:56 +0100
> Subject: [PATCH] ALSA: HDA/Jack: Make device indices for HDMI
>
> Make sure we can associate HDMI Jacks with the correct PCM devices.
>
> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
> ---
> sound/pci/hda/hda_jack.c | 5 +++--
> sound/pci/hda/hda_jack.h | 2 +-
> sound/pci/hda/patch_hdmi.c | 3 ++-
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
> index 3949015..0b1f72c 100644
> --- a/sound/pci/hda/hda_jack.c
> +++ b/sound/pci/hda/hda_jack.c
> @@ -210,7 +210,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 +223,7 @@ 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;
> + kctl->id.device = device;
> if (snd_hda_ctl_add(codec, nid, kctl) < 0)
> return -ENOMEM;
> jack->kctl = kctl;
> @@ -249,7 +250,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);
> diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
> index f8f97c7..fcca96c 100644
> --- a/sound/pci/hda/hda_jack.h
> +++ b/sound/pci/hda/hda_jack.h
> @@ -76,7 +76,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);
>
> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> index bb8cfc6..9689c8d 100644
> --- a/sound/pci/hda/patch_hdmi.c
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -1277,7 +1277,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
> if (err < 0)
> return err;
> err = snd_hda_jack_add_kctl(codec, per_pin->pin_nid,
> - "HDMI", pin_idx);
> + "HDMI", pin_idx,
> + spec->pcm_rec[pin_idx].device);
> if (err < 0)
> return err;
> }
> --
> 1.7.5.4
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 20:51 ` Clemens Ladisch
2011-11-30 2:10 ` Raymond Yau
@ 2011-11-30 6:38 ` Clemens Ladisch
2011-11-30 6:46 ` Takashi Iwai
2 siblings, 0 replies; 11+ messages in thread
From: Clemens Ladisch @ 2011-11-30 6:38 UTC (permalink / raw)
To: David Henningsson; +Cc: Takashi Iwai, ALSA Development Mailing List
Clemens Ladisch wrote:
> 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,
Er, the point was for the TLV to be optional; please ignore the previous
patch. :)
--8<---------------------------------------------------------------->8--
ALSA: hda/jack: add PCM device TLV for jack controls
Allow to add a new TLV to jack kcontrols so that HDMI jacks can be
associated with the correct PCM devices.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
include/sound/tlv.h | 6 ++++++
sound/pci/hda/hda_jack.c | 12 ++++++++++--
sound/pci/hda/hda_jack.h | 3 ++-
sound/pci/hda/patch_hdmi.c | 3 ++-
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/include/sound/tlv.h b/include/sound/tlv.h
index 7067e2d..809b077 100644
--- 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) control maps to this device */
#define TLV_DB_SCALE_MASK 0xffff
#define TLV_DB_SCALE_MUTE 0x10000
@@ -73,4 +74,9 @@
#define TLV_DB_GAIN_MUTE -9999999
+#define TLV_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 */
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
index 3949015..848dd03 100644
--- 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,13 @@ 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;
+ if (device >= 0) {
+ 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->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
+ }
if (snd_hda_ctl_add(codec, nid, kctl) < 0)
return -ENOMEM;
jack->kctl = kctl;
@@ -249,7 +257,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, -1);
if (err < 0)
return err;
return snd_hda_jack_detect_enable(codec, nid, 0);
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
index f8f97c7..a2e69c5 100644
--- 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);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index bb8cfc6..9689c8d 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1277,7 +1277,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
if (err < 0)
return err;
err = snd_hda_jack_add_kctl(codec, per_pin->pin_nid,
- "HDMI", pin_idx);
+ "HDMI", pin_idx,
+ spec->pcm_rec[pin_idx].device);
if (err < 0)
return err;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 20:03 ` Mark Brown
@ 2011-11-30 6:41 ` Takashi Iwai
2011-11-30 9:26 ` Mark Brown
0 siblings, 1 reply; 11+ messages in thread
From: Takashi Iwai @ 2011-11-30 6:41 UTC (permalink / raw)
To: Mark Brown; +Cc: ALSA Development Mailing List, David Henningsson
At Tue, 29 Nov 2011 20:03:51 +0000,
Mark Brown wrote:
>
> On Tue, Nov 29, 2011 at 08:43:06PM +0100, David Henningsson wrote:
>
> > What are your thoughts on how to proceed, when do you think this is
> > ready to be merged into the topic/hda branch?
>
> I'm still rather sad that this infrastructure is all totally separate to
> the existing jack infrastructure, one of the goals of having common
> infrastructure was to insulate drivers from having to deal with changes
> in the APIs used for reporting and I certainly don't want to have to
> have all the drivers individually reporting via all the APIs (especially
> not with the multiswitch API coming along too).
That'll happen later. I haven't done yet just because I couldn't
spend my time for this in these weeks. I need to complete the feature
in HD-audio side at first before breaking all in ASoC.
BTW, how will the multiswitch API look like?
Takashi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-29 20:51 ` Clemens Ladisch
2011-11-30 2:10 ` Raymond Yau
2011-11-30 6:38 ` Clemens Ladisch
@ 2011-11-30 6:46 ` Takashi Iwai
2 siblings, 0 replies; 11+ messages in thread
From: Takashi Iwai @ 2011-11-30 6:46 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: ALSA Development Mailing List, David Henningsson
At Tue, 29 Nov 2011 21:51:45 +0100,
Clemens Ladisch wrote:
>
> 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.
Hm, a good point.
> 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.
Yes, I had a similar idea. My original idea was to implement PCM
mappings like this and dependency-mapping between control elements
(e.g. master -> front -> speaker) via TLV.
Takashi
>
>
> 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);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-30 2:43 ` Raymond Yau
@ 2011-11-30 8:05 ` David Henningsson
0 siblings, 0 replies; 11+ messages in thread
From: David Henningsson @ 2011-11-30 8:05 UTC (permalink / raw)
To: Raymond Yau; +Cc: ALSA Development Mailing List
On 11/30/2011 03:43 AM, Raymond Yau wrote:
> 2011/11/30 David Henningsson<david.henningsson@canonical.com>:
>> Hi Takashi,
>>
>> I've done some more tests of your branch now, and the new names seems to
>> work for my machine here.
>>
>> I'm attaching two patches - one adds a "device index" for mapping against
>> pcm devices on HDMI, the other one is a backport for the driver-build tree.
>>
>> What are your thoughts on how to proceed, when do you think this is ready to
>> be merged into the topic/hda branch?
>>
>> // David
>>
>
> http://git.alsa-project.org/?p=alsa-kernel.git;a=blob_plain;f=Documentation/sound/alsa/HD-Audio-Controls.txt
>
> Does it handle "Independent HP" ?
Not currently, my patch is concerned with HDMI only.
You're correct in that if "Independent HP" is on, it wouldn't hurt for
the Headphone jack to also have such a device index.
--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Tests of the hda-jack branch
2011-11-30 6:41 ` Takashi Iwai
@ 2011-11-30 9:26 ` Mark Brown
0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2011-11-30 9:26 UTC (permalink / raw)
To: Takashi Iwai; +Cc: ALSA Development Mailing List, David Henningsson
On Wed, Nov 30, 2011 at 07:41:04AM +0100, Takashi Iwai wrote:
> BTW, how will the multiswitch API look like?
It's taken the Android switch API as a starting point so the main
reporting mechanism is uevents.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-11-30 9:26 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.