ALSA: jack: fix a randconfig build issue
PATCH 1/1 ALSA: jack: fix a randconfig build issue
There may be no input_dev for jack(e.g. phantom jack), when CONFIG_INPUT is not selected, building errors such as:
undefined reference to `input_xxx'...
Here add #ifdef judgement to fix the issue.
--- include/sound/jack.h | 2 ++ sound/core/jack.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)
include/sound/jack.h +2 -0
@@ -72,7 +72,9 @@ enum snd_jack_types {#define SND_JACK_SWITCH_TYPES 6struct snd_jack { +#ifdef CONFIG_INPUT struct input_dev *input_dev; +#endif struct list_head kctl_list;struct snd_card *card;int registered;
sound/core/jack.c +26 -14
@@ -32,6 +32,7 @@ struct snd_jack_kctl {unsigned int mask_bits;/* only masked status bits are reported via kctl */ }; +#ifdef CONFIG_INPUT static int jack_switch_types[SND_JACK_SWITCH_TYPES ] = {SW_HEADPHONE_INSERT , SW_MICROPHONE_INSERT,
@@ -40,9 +41,11 @@ static int jack_switch_types[SND_JACK_SWITCH_TYPES] = {SW_VIDEOOUT_INSERT , SW_LINEIN_INSERT, }; +#endif static int snd_jack_dev_disconnect (struct snd_device *device) { +#ifdef CONFIG_INPUT struct snd_jack *jack = device->device_data;if (!jack->input_dev)
@@ -54,7 +57,9 @@ static int snd_jack_dev_disconnect(struct snd_device *device)input_unregister_device (jack->input_dev); else input_free_device(jack->input_dev); + jack->input_dev =NULL ; +#endif return 0 ; }
@@ -83,11 +88,12 @@ static int snd_jack_dev_register(struct snd_device *device) {struct snd_jack *jack = device->device_data;struct snd_card *card = device->card; -int err, i; +int err =0 ;snprintf (jack->name,sizeof (jack->name),"%s %s" , card->shortname, jack->id); +#ifdef CONFIG_INPUT if (!jack->input_dev)return 0 ;
@@ -98,7 +104,7 @@ static int snd_jack_dev_register(struct snd_device *device) jack->input_dev->dev.parent =snd_card_get_device_link (card);/* Add capabilities for any keys that are enabled */ -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (!(jack->type & testbit))
@@ -113,6 +119,7 @@ static int snd_jack_dev_register(struct snd_device *device) err =input_register_device (jack->input_dev);if (err ==0 ) jack->registered =1 ; +#endif return err; }
@@ -209,7 +216,6 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,struct snd_jack *jack;struct snd_jack_kctl *jack_kctl =NULL ;int err; -int i;static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register,
@@ -230,26 +236,31 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,/* don't creat input device for phantom jack */ if (!phantom_jack) { +#ifdef CONFIG_INPUT jack->input_dev =input_allocate_device ();if (jack->input_dev ==NULL ) { err = -ENOMEM ; - goto fail_input; + goto error; } jack->input_dev->phys ="ALSA" ; - jack->type = type; - -for (i =0 ; i <SND_JACK_SWITCH_TYPES ; i++) +for (int i =0 ; i <SND_JACK_SWITCH_TYPES ; i++)if (type & (1 << i))input_set_capability (jack->input_dev,EV_SW , jack_switch_types[i]); +#endif + jack->type = type; } err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops); -if (err <0 ) - goto fail_input; +if (err <0 ) { +#ifdef CONFIG_INPUT +input_free_device (jack->input_dev); +#endif + goto error; + } jack->card = card;INIT_LIST_HEAD (&jack->kctl_list);
@@ -261,8 +272,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,return 0 ; -fail_input: -input_free_device (jack->input_dev); +error:kfree (jack->id);kfree (jack);return err;
@@ -281,11 +291,13 @@ EXPORT_SYMBOL(snd_jack_new);*/ void snd_jack_set_parent (struct snd_jack *jack,struct device *parent) { +#ifdef CONFIG_INPUT WARN_ON (jack->registered);if (!jack->input_dev)return ; jack->input_dev->dev.parent = parent; +#endif }EXPORT_SYMBOL (snd_jack_set_parent);
@@ -340,7 +352,6 @@ EXPORT_SYMBOL(snd_jack_set_key);void snd_jack_report (struct snd_jack *jack,int status) {struct snd_jack_kctl *jack_kctl; -int i;if (!jack)return ;
@@ -349,10 +360,11 @@ void snd_jack_report(struct snd_jack *jack, int status)snd_kctl_jack_report (jack->card, jack_kctl->kctl, status & jack_kctl->mask_bits); +#ifdef CONFIG_INPUT if (!jack->input_dev)return ; -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (jack->type & testbit)
@@ -369,7 +381,7 @@ void snd_jack_report(struct snd_jack *jack, int status) }input_sync (jack->input_dev); - +#endif }EXPORT_SYMBOL (snd_jack_report);
Signature · 1 line
1.9.1
At Fri, 1 May 2015 11:10:29 +0800,
Quoted 6 lines · Jie Yang
There may be no
input_devfor jack(e.g. phantom jack), whenCONFIG_INPUTis not selected, building errors such as:
undefined reference to `input_xxx'...Here add #ifdef judgement to fix the issue.
Well, the standard idiom so far is to enable SND_JACK selectively. Take a look at the comment in sound/core/Kconfig.
# To be effective this also requires INPUT - users should say:
# select SND_JACK if INPUT=y || INPUT=SND
# to avoid having to force INPUT on. config SND_JACK bool
And, looking at sound/pci/hda/Kconfig, there is still SND_HDA_INPUT_JACK.
So, what you need to fix is:
- Remove SND_HDA_INPUT_JACK from sound/pci/hda/Kconfig and the last ifdef in hda_codec.h
- Replace the line "select SND_JACK" with
select SND_JACK if INPUT=y || INPUT=SND_HDA
thanks,
Takashi
Quoted 189 lines
Signed-off-by Jie Yang <[email protected]>--- include/sound/jack.h | 2 ++ sound/core/jack.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)include/sound/jack.h +2
-0@@ -72,7 +72,9 @@ enum snd_jack_types {#define SND_JACK_SWITCH_TYPES 6struct snd_jack { +#ifdef CONFIG_INPUT struct input_dev *input_dev; +#endif struct list_head kctl_list;struct snd_card *card;int registered;sound/core/jack.c +26
-14@@ -32,6 +32,7 @@ struct snd_jack_kctl {unsigned int mask_bits;/* only masked status bits are reported via kctl */ }; +#ifdef CONFIG_INPUT static int jack_switch_types[SND_JACK_SWITCH_TYPES ] = {SW_HEADPHONE_INSERT , SW_MICROPHONE_INSERT,@@ -40,9 +41,11 @@ static int jack_switch_types[SND_JACK_SWITCH_TYPES] = {SW_VIDEOOUT_INSERT , SW_LINEIN_INSERT, }; +#endif static int snd_jack_dev_disconnect (struct snd_device *device) { +#ifdef CONFIG_INPUT struct snd_jack *jack = device->device_data;if (!jack->input_dev)@@ -54,7 +57,9 @@ static int snd_jack_dev_disconnect(struct snd_device *device)input_unregister_device (jack->input_dev); else input_free_device(jack->input_dev); + jack->input_dev =NULL ; +#endif return 0 ; }@@ -83,11 +88,12 @@ static int snd_jack_dev_register(struct snd_device *device) {struct snd_jack *jack = device->device_data;struct snd_card *card = device->card; -int err, i; +int err =0 ;snprintf (jack->name,sizeof (jack->name),"%s %s" , card->shortname, jack->id); +#ifdef CONFIG_INPUT if (!jack->input_dev)return 0 ;@@ -98,7 +104,7 @@ static int snd_jack_dev_register(struct snd_device *device) jack->input_dev->dev.parent =snd_card_get_device_link (card);/* Add capabilities for any keys that are enabled */ -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (!(jack->type & testbit))@@ -113,6 +119,7 @@ static int snd_jack_dev_register(struct snd_device *device) err =input_register_device (jack->input_dev);if (err ==0 ) jack->registered =1 ; +#endif return err; }@@ -209,7 +216,6 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,struct snd_jack *jack;struct snd_jack_kctl *jack_kctl =NULL ;int err; -int i;static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register,@@ -230,26 +236,31 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,/* don't creat input device for phantom jack */ if (!phantom_jack) { +#ifdef CONFIG_INPUT jack->input_dev =input_allocate_device ();if (jack->input_dev ==NULL ) { err = -ENOMEM ; - goto fail_input; + goto error; } jack->input_dev->phys ="ALSA" ; - jack->type = type; - -for (i =0 ; i <SND_JACK_SWITCH_TYPES ; i++) +for (int i =0 ; i <SND_JACK_SWITCH_TYPES ; i++)if (type & (1 << i))input_set_capability (jack->input_dev,EV_SW , jack_switch_types[i]); +#endif + jack->type = type; } err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops); -if (err <0 ) - goto fail_input; +if (err <0 ) { +#ifdef CONFIG_INPUT +input_free_device (jack->input_dev); +#endif + goto error; + } jack->card = card;INIT_LIST_HEAD (&jack->kctl_list);@@ -261,8 +272,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,return 0 ; -fail_input: -input_free_device (jack->input_dev); +error:kfree (jack->id);kfree (jack);return err;@@ -281,11 +291,13 @@ EXPORT_SYMBOL(snd_jack_new);*/ void snd_jack_set_parent (struct snd_jack *jack,struct device *parent) { +#ifdef CONFIG_INPUT WARN_ON (jack->registered);if (!jack->input_dev)return ; jack->input_dev->dev.parent = parent; +#endif }EXPORT_SYMBOL (snd_jack_set_parent);@@ -340,7 +352,6 @@ EXPORT_SYMBOL(snd_jack_set_key);void snd_jack_report (struct snd_jack *jack,int status) {struct snd_jack_kctl *jack_kctl; -int i;if (!jack)return ;@@ -349,10 +360,11 @@ void snd_jack_report(struct snd_jack *jack, int status)snd_kctl_jack_report (jack->card, jack_kctl->kctl, status & jack_kctl->mask_bits); +#ifdef CONFIG_INPUT if (!jack->input_dev)return ; -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (jack->type & testbit)@@ -369,7 +381,7 @@ void snd_jack_report(struct snd_jack *jack, int status) }input_sync (jack->input_dev); - +#endif }EXPORT_SYMBOL (snd_jack_report);Signature · 1 line
1.9.1
Quoted 25 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, May 01, 2015 3:11 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Fri, 1 May 2015 11:10:29 +0800,
Quoted 6 lines · Jie Yang
There may be no
input_devfor jack(e.g. phantom jack), whenCONFIG_INPUTis not selected, building errors such as:
undefined reference to `input_xxx'...Here add #ifdef judgement to fix the issue.
Well, the standard idiom so far is to enable
SND_JACKselectively. Take a look at the comment insound/core/Kconfig.# To be effective this also requires INPUT - users should say:
# selectSND_JACKif INPUT=y || INPUT=SND# to avoid having to force INPUT on. config SND_JACK bool
Quoted 8 lines
And, looking at
sound/pci/hda/Kconfig, there is stillSND_HDA_INPUT_JACK.So, what you need to fix is:
- RemoveSND_HDA_INPUT_JACKfromsound/pci/hda/Kconfigand the last ifdef inhda_codec.h- Replace the line "select
SND_JACK" withselect SND_JACK if INPUT=y || INPUT=SND_HDA
OK, will follow this. What I only concern is that if user want SND_JACk when INPUT=N(e.g. phantom jack?), it becomes impossible.
~Keyon
Quoted 205 lines
thanks,
Takashi
include/sound/jack.h enum snd_jack_types { #define
Quoted 12 lines
Signed-off-by Jie Yang <[email protected]>--- include/sound/jack.h | 2 ++ sound/core/jack.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)include/sound/jack.h index renamed from include/sound/jack.h +0
-023bede1..c1010f9 100644
include/sound/jack.h +0
-0@@ -72,7 +72,9 @@ enum snd_jack_types { #define
SND_JACK_SWITCH_TYPESsound/core/jack.c static int
Quoted 22 lines
6
struct
snd_jack{include/sound/jack.h +2
-0+#ifdef CONFIG_INPUT struct input_dev *input_dev; +#endif struct list_head kctl_list;struct snd_card *card;int registered;sound/core/jack.c index renamed from sound/core/jack.c +0
-0eb66327..3a1901e 100644
sound/core/jack.c +1
-0@@ -32,6 +32,7 @@ struct snd_jack_kctl {unsigned int mask_bits;/* only masked status bits are reported via kctl */ }; +#ifdef CONFIG_INPUT static int jack_switch_types[SND_JACK_SWITCH_TYPES ] = {SW_HEADPHONE_INSERT , SW_MICROPHONE_INSERT,@@ -40,9 +41,11 @@ static intjack_switch_types[SND_JACK_SWITCH_TYPES] = {
sound/core/jack.c static int snd_jack_dev_disconnect(struct snd_device
Quoted 11 lines
sound/core/jack.c +2
-0SW_VIDEOOUT_INSERT , SW_LINEIN_INSERT, }; +#endif static int snd_jack_dev_disconnect (struct snd_device *device) { +#ifdef CONFIG_INPUT struct snd_jack *jack = device->device_data;if (!jack->input_dev)@@ -54,7 +57,9 @@ static int snd_jack_dev_disconnect(struct snd_device*device)
sound/core/jack.c static int snd_jack_dev_register(struct snd_device
Quoted 24 lines
sound/core/jack.c +4
-1input_unregister_device (jack->input_dev); else input_free_device(jack->input_dev); + jack->input_dev =NULL ; +#endif return 0 ; }@@ -83,11 +88,12 @@ static int snd_jack_dev_register(struct snd_device *device) {struct snd_jack *jack = device->device_data;struct snd_card *card = device->card; -int err, i; +int err =0 ;snprintf (jack->name,sizeof (jack->name),"%s %s" , card->shortname, jack->id); +#ifdef CONFIG_INPUT if (!jack->input_dev)return 0 ;@@ -98,7 +104,7 @@ static int snd_jack_dev_register(struct snd_device*device)
sound/core/jack.c static int snd_jack_dev_register(struct snd_device · line 104
Quoted 1 line
sound/core/jack.c +0
-0jack->input_dev->dev.parent =
snd_card_get_device_link(card);sound/core/jack.c static int snd_jack_dev_register(struct snd_device
Quoted 8 lines
sound/core/jack.c +1
-1/* Add capabilities for any keys that are enabled */ -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (!(jack->type & testbit))@@ -113,6 +119,7 @@ static int snd_jack_dev_register(struct snd_device*device)
sound/core/jack.c int snd_jack_new(struct snd_card *card, const char
Quoted 8 lines
sound/core/jack.c +1
-0err =input_register_device (jack->input_dev);if (err ==0 ) jack->registered =1 ; +#endif return err; }@@ -209,7 +216,6 @@ int snd_jack_new(struct snd_card *card, const char*id, int type,
sound/core/jack.c int snd_jack_new(struct snd_card *card, const char *id, int type,
Quoted 7 lines
sound/core/jack.c +0
-1struct snd_jack *jack;struct snd_jack_kctl *jack_kctl =NULL ;int err; -int i;static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register, @@ -230,26 +236,31@@ int
Quoted 10 lines
snd_jack_new(struct
snd_card*card, const char *id, int type,sound/core/jack.c +2
-1/* don't creat input device for phantom jack */ if (!phantom_jack) { +#ifdef CONFIG_INPUT jack->input_dev =input_allocate_device ();if (jack->input_dev ==NULL ) { err = -ENOMEM ; - goto fail_input; + goto error;sound/core/jack.c int snd_jack_new(struct snd_card *card, const char *id, int type,
Quoted 10 lines
sound/core/jack.c +1
-3} jack->input_dev->phys ="ALSA" ; - jack->type = type; - -for (i =0 ; i <SND_JACK_SWITCH_TYPES ; i++) +for (int i =0 ; i <SND_JACK_SWITCH_TYPES ; i++)if (type & (1 << i)) input_set_capability(jack->input_dev,
EV_SW,sound/core/jack.c void snd_jack_report(struct snd_jack *jack, int
Quoted 51 lines
sound/core/jack.c +9
-4jack_switch_types[i]); +#endif + jack->type = type; } err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops); -if (err <0 ) - goto fail_input; +if (err <0 ) { +#ifdef CONFIG_INPUT +input_free_device (jack->input_dev); +#endif + goto error; + } jack->card = card;INIT_LIST_HEAD (&jack->kctl_list);@@ -261,8 +272,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, return 0; -fail_input: -input_free_device (jack->input_dev); +error:kfree (jack->id);kfree (jack);sound/core/jack.c +2
-1return err;@@ -281,11 +291,13 @@ EXPORT_SYMBOL(snd_jack_new);*/ void snd_jack_set_parent (struct snd_jack *jack,struct device *parent) { +#ifdef CONFIG_INPUT WARN_ON (jack->registered);if (!jack->input_dev)return ; jack->input_dev->dev.parent = parent; +#endif }EXPORT_SYMBOL (snd_jack_set_parent);@@ -340,7 +352,6 @@ EXPORT_SYMBOL(snd_jack_set_key); void snd_jack_report(struct snd_jack *jack, int status) {struct snd_jack_kctl *jack_kctl; -int i;if (!jack)return ;@@ -349,10 +360,11 @@ void snd_jack_report(struct snd_jack *jack, intstatus)
sound/core/jack.c void snd_jack_report(struct snd_jack *jack, int
Quoted 13 lines
sound/core/jack.c +2
-1snd_kctl_jack_report (jack->card, jack_kctl->kctl, status & jack_kctl->mask_bits); +#ifdef CONFIG_INPUT if (!jack->input_dev)return ; -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (jack->type & testbit)@@ -369,7 +381,7 @@ void snd_jack_report(struct snd_jack *jack, intstatus)
Quoted 11 lines
sound/core/jack.c +1
-2}input_sync (jack->input_dev); - +#endif }EXPORT_SYMBOL (snd_jack_report); --1.9.1
At Sat, 2 May 2015 04:51:34 +0000,
Quoted 32 lines · Yang
Quoted 32 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, May 01, 2015 3:11 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Fri, 1 May 2015 11:10:29 +0800,
Quoted 6 lines · Jie Yang
There may be no
input_devfor jack(e.g. phantom jack), whenCONFIG_INPUTis not selected, building errors such as:
undefined reference to `input_xxx'...Here add #ifdef judgement to fix the issue.
Well, the standard idiom so far is to enable
SND_JACKselectively. Take a look at the comment insound/core/Kconfig.# To be effective this also requires INPUT - users should say:
# selectSND_JACKif INPUT=y || INPUT=SND# to avoid having to force INPUT on. config SND_JACK boolAnd, looking at
sound/pci/hda/Kconfig, there is stillSND_HDA_INPUT_JACK.So, what you need to fix is:
- RemoveSND_HDA_INPUT_JACKfromsound/pci/hda/Kconfigand the last ifdef inhda_codec.h
Quoted 5 lines
Quoted 2 lines
- Replace the line "select
SND_JACK" withselect SND_JACK if INPUT=y || INPUT=SND_HDAOK, will follow this. What I only concern is that if user want
SND_JACkwhen INPUT=N(e.g. phantom jack?), it becomes impossible.
Right, it's impossible now. But this is the case really no one would care much (who wants the jack detection on a system without any input capability?).
Takashi
Quoted 209 lines
~Keyon
Quoted 205 lines
thanks,
Takashi
include/sound/jack.h enum snd_jack_types { #define
Quoted 12 lines
Signed-off-by Jie Yang <[email protected]>--- include/sound/jack.h | 2 ++ sound/core/jack.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)include/sound/jack.h index renamed from include/sound/jack.h +0
-023bede1..c1010f9 100644
include/sound/jack.h +0
-0@@ -72,7 +72,9 @@ enum snd_jack_types { #define
SND_JACK_SWITCH_TYPESsound/core/jack.c static int
Quoted 22 lines
6
struct
snd_jack{include/sound/jack.h +2
-0+#ifdef CONFIG_INPUT struct input_dev *input_dev; +#endif struct list_head kctl_list;struct snd_card *card;int registered;sound/core/jack.c index renamed from sound/core/jack.c +0
-0eb66327..3a1901e 100644
sound/core/jack.c +1
-0@@ -32,6 +32,7 @@ struct snd_jack_kctl {unsigned int mask_bits;/* only masked status bits are reported via kctl */ }; +#ifdef CONFIG_INPUT static int jack_switch_types[SND_JACK_SWITCH_TYPES ] = {SW_HEADPHONE_INSERT , SW_MICROPHONE_INSERT,@@ -40,9 +41,11 @@ static intjack_switch_types[SND_JACK_SWITCH_TYPES] = {
sound/core/jack.c static int snd_jack_dev_disconnect(struct snd_device
Quoted 11 lines
sound/core/jack.c +2
-0SW_VIDEOOUT_INSERT , SW_LINEIN_INSERT, }; +#endif static int snd_jack_dev_disconnect (struct snd_device *device) { +#ifdef CONFIG_INPUT struct snd_jack *jack = device->device_data;if (!jack->input_dev)@@ -54,7 +57,9 @@ static int snd_jack_dev_disconnect(struct snd_device*device)
sound/core/jack.c static int snd_jack_dev_register(struct snd_device
Quoted 24 lines
sound/core/jack.c +4
-1input_unregister_device (jack->input_dev); else input_free_device(jack->input_dev); + jack->input_dev =NULL ; +#endif return 0 ; }@@ -83,11 +88,12 @@ static int snd_jack_dev_register(struct snd_device *device) {struct snd_jack *jack = device->device_data;struct snd_card *card = device->card; -int err, i; +int err =0 ;snprintf (jack->name,sizeof (jack->name),"%s %s" , card->shortname, jack->id); +#ifdef CONFIG_INPUT if (!jack->input_dev)return 0 ;@@ -98,7 +104,7 @@ static int snd_jack_dev_register(struct snd_device*device)
sound/core/jack.c static int snd_jack_dev_register(struct snd_device · line 104
Quoted 1 line
sound/core/jack.c +0
-0jack->input_dev->dev.parent =
snd_card_get_device_link(card);sound/core/jack.c static int snd_jack_dev_register(struct snd_device
Quoted 8 lines
sound/core/jack.c +1
-1/* Add capabilities for any keys that are enabled */ -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (!(jack->type & testbit))@@ -113,6 +119,7 @@ static int snd_jack_dev_register(struct snd_device*device)
sound/core/jack.c int snd_jack_new(struct snd_card *card, const char
Quoted 8 lines
sound/core/jack.c +1
-0err =input_register_device (jack->input_dev);if (err ==0 ) jack->registered =1 ; +#endif return err; }@@ -209,7 +216,6 @@ int snd_jack_new(struct snd_card *card, const char*id, int type,
sound/core/jack.c int snd_jack_new(struct snd_card *card, const char *id, int type,
Quoted 7 lines
sound/core/jack.c +0
-1struct snd_jack *jack;struct snd_jack_kctl *jack_kctl =NULL ;int err; -int i;static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register, @@ -230,26 +236,31@@ int
Quoted 10 lines
snd_jack_new(struct
snd_card*card, const char *id, int type,sound/core/jack.c +2
-1/* don't creat input device for phantom jack */ if (!phantom_jack) { +#ifdef CONFIG_INPUT jack->input_dev =input_allocate_device ();if (jack->input_dev ==NULL ) { err = -ENOMEM ; - goto fail_input; + goto error;sound/core/jack.c int snd_jack_new(struct snd_card *card, const char *id, int type,
Quoted 10 lines
sound/core/jack.c +1
-3} jack->input_dev->phys ="ALSA" ; - jack->type = type; - -for (i =0 ; i <SND_JACK_SWITCH_TYPES ; i++) +for (int i =0 ; i <SND_JACK_SWITCH_TYPES ; i++)if (type & (1 << i)) input_set_capability(jack->input_dev,
EV_SW,sound/core/jack.c void snd_jack_report(struct snd_jack *jack, int
Quoted 51 lines
sound/core/jack.c +9
-4jack_switch_types[i]); +#endif + jack->type = type; } err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops); -if (err <0 ) - goto fail_input; +if (err <0 ) { +#ifdef CONFIG_INPUT +input_free_device (jack->input_dev); +#endif + goto error; + } jack->card = card;INIT_LIST_HEAD (&jack->kctl_list);@@ -261,8 +272,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, return 0; -fail_input: -input_free_device (jack->input_dev); +error:kfree (jack->id);kfree (jack);sound/core/jack.c +2
-1return err;@@ -281,11 +291,13 @@ EXPORT_SYMBOL(snd_jack_new);*/ void snd_jack_set_parent (struct snd_jack *jack,struct device *parent) { +#ifdef CONFIG_INPUT WARN_ON (jack->registered);if (!jack->input_dev)return ; jack->input_dev->dev.parent = parent; +#endif }EXPORT_SYMBOL (snd_jack_set_parent);@@ -340,7 +352,6 @@ EXPORT_SYMBOL(snd_jack_set_key); void snd_jack_report(struct snd_jack *jack, int status) {struct snd_jack_kctl *jack_kctl; -int i;if (!jack)return ;@@ -349,10 +360,11 @@ void snd_jack_report(struct snd_jack *jack, intstatus)
sound/core/jack.c void snd_jack_report(struct snd_jack *jack, int
Quoted 13 lines
sound/core/jack.c +2
-1snd_kctl_jack_report (jack->card, jack_kctl->kctl, status & jack_kctl->mask_bits); +#ifdef CONFIG_INPUT if (!jack->input_dev)return ; -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (jack->type & testbit)@@ -369,7 +381,7 @@ void snd_jack_report(struct snd_jack *jack, intstatus)
Quoted 11 lines
sound/core/jack.c +1
-2}input_sync (jack->input_dev); - +#endif }EXPORT_SYMBOL (snd_jack_report); --1.9.1
Quoted 44 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, May 02, 2015 3:01 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Sat, 2 May 2015 04:51:34 +0000,
Quoted 21 lines · Yang
Quoted 21 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, May 01, 2015 3:11 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Fri, 1 May 2015 11:10:29 +0800,
Quoted 6 lines · Jie Yang
There may be no
input_devfor jack(e.g. phantom jack), whenCONFIG_INPUTis not selected, building errors such as:
undefined reference to `input_xxx'...Here add #ifdef judgement to fix the issue.
Well, the standard idiom so far is to enable
SND_JACKselectively. Take a look at the comment insound/core/Kconfig.Quoted 7 lines
Quoted 7 lines
# To be effective this also requires INPUT - users should say:
# selectSND_JACKif INPUT=y || INPUT=SND# to avoid having to force INPUT on. config SND_JACK boolAnd, looking at
sound/pci/hda/Kconfig, there is still
SND_HDA_INPUT_JACK.Quoted 3 lines
Quoted 3 lines
So, what you need to fix is:
- RemoveSND_HDA_INPUT_JACKfromsound/pci/hda/Kconfigand thelast
Quoted 2 lines
Quoted 2 lines
ifdef in
hda_codec.h
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
- Replace the line "select
SND_JACK" withselect SND_JACK if INPUT=y || INPUT=SND_HDAOK, will follow this. What I only concern is that if user want
SND_JACkwhen INPUT=N(e.g. phantom jack?), it becomes impossible.Right, it's impossible now. But this is the case really no one would care much (who wants the jack detection on a system without any input capability?).
Got it. Another question here, I found that this change in sound/pci/had/Kconfig doesn't fix the building issue:
select SND_JACK if INPUT=y || INPUT=SND_HDA but this do: select SND_JACK if INPUT=y || INPUT=SND
suppose we should use the latter one, right? Do you know why the former one doesn't fix?(seems here "INPUT=SND..." added for both CONFIG_INPUT=m and SND...=m case?)
Thanks,
~Keyon
Quoted 219 lines
Takashi
Quoted 215 lines
~Keyon
Quoted 211 lines
thanks,
Takashi
include/sound/jack.h enum snd_jack_types { #define
Quoted 12 lines
Signed-off-by Jie Yang <[email protected]>--- include/sound/jack.h | 2 ++ sound/core/jack.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)include/sound/jack.h index renamed from include/sound/jack.h +0
-023bede1..c1010f9 100644
include/sound/jack.h +0
-0@@ -72,7 +72,9 @@ enum snd_jack_types { #define
SND_JACK_SWITCH_TYPESsound/core/jack.c static int
Quoted 22 lines
6
struct
snd_jack{include/sound/jack.h +2
-0+#ifdef CONFIG_INPUT struct input_dev *input_dev; +#endif struct list_head kctl_list;struct snd_card *card;int registered;sound/core/jack.c index renamed from sound/core/jack.c +0
-0eb66327..3a1901e 100644
sound/core/jack.c +1
-0@@ -32,6 +32,7 @@ struct snd_jack_kctl {unsigned int mask_bits;/* only masked status bits are reported via kctl */ }; +#ifdef CONFIG_INPUT static int jack_switch_types[SND_JACK_SWITCH_TYPES ] = {SW_HEADPHONE_INSERT , SW_MICROPHONE_INSERT,@@ -40,9 +41,11 @@ static intjack_switch_types[SND_JACK_SWITCH_TYPES] = {
Quoted 11 lines
sound/core/jack.c +2
-0SW_VIDEOOUT_INSERT , SW_LINEIN_INSERT, }; +#endif static int snd_jack_dev_disconnect (struct snd_device *device) { +#ifdef CONFIG_INPUT struct snd_jack *jack = device->device_data;if (!jack->input_dev)@@ -54,7 +57,9 @@ static int snd_jack_dev_disconnect(structQuoted 1 line
snd_device*device)
Quoted 25 lines
sound/core/jack.c +2
-0input_unregister_device (jack->input_dev); else input_free_device(jack->input_dev); + jack->input_dev =NULL ; +#endif return 0 ; }@@ -83,11 +88,12 @@ static int snd_jack_dev_register(struct
snd_device
*device) {sound/core/jack.c +2
-1struct snd_jack *jack = device->device_data;struct snd_card *card = device->card; -int err, i; +int err =0 ;snprintf (jack->name,sizeof (jack->name),"%s %s" , card->shortname, jack->id); +#ifdef CONFIG_INPUT if (!jack->input_dev)return 0 ;@@ -98,7 +104,7 @@ static int snd_jack_dev_register(structQuoted 1 line
snd_device*device)
Quoted 1 line
jack->input_dev->dev.parent=
snd_card_get_device_link(card);Quoted 9 lines
sound/core/jack.c +1
-1/* Add capabilities for any keys that are enabled */ -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (!(jack->type & testbit))@@ -113,6 +119,7 @@ static int snd_jack_dev_register(struct
snd_device*device)
Quoted 9 lines
sound/core/jack.c +1
-0err =input_register_device (jack->input_dev);if (err ==0 ) jack->registered =1 ; +#endif return err; }@@ -209,7 +216,6 @@ int snd_jack_new(struct snd_card *card, constchar
*id, int type,
sound/core/jack.c int snd_jack_new(struct snd_card *card, const char *id, int type,
Quoted 7 lines
sound/core/jack.c +0
-1struct snd_jack *jack;struct snd_jack_kctl *jack_kctl =NULL ;int err; -int i;static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register, @@ -230,26 +236,31@@ int
Quoted 10 lines
snd_jack_new(struct
snd_card*card, const char *id, int type,sound/core/jack.c +2
-1/* don't creat input device for phantom jack */ if (!phantom_jack) { +#ifdef CONFIG_INPUT jack->input_dev =input_allocate_device ();if (jack->input_dev ==NULL ) { err = -ENOMEM ; - goto fail_input; + goto error;sound/core/jack.c int snd_jack_new(struct snd_card *card, const char *id, int type,
Quoted 10 lines
sound/core/jack.c +1
-3} jack->input_dev->phys ="ALSA" ; - jack->type = type; - -for (i =0 ; i <SND_JACK_SWITCH_TYPES ; i++) +for (int i =0 ; i <SND_JACK_SWITCH_TYPES ; i++)if (type & (1 << i)) input_set_capability(jack->input_dev,
EV_SW,Quoted 50 lines
sound/core/jack.c +8
-2jack_switch_types[i]); +#endif + jack->type = type; } err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops); -if (err <0 ) - goto fail_input; +if (err <0 ) { +#ifdef CONFIG_INPUT +input_free_device (jack->input_dev); +#endif + goto error; + } jack->card = card; INIT_LIST_HEAD(&jack->kctl_list); @@ -261,8 +272,7 @@ intsnd_jack_new(struct
snd_card*card, const char *id, int type,sound/core/jack.c +3
-3return 0 ; -fail_input: -input_free_device (jack->input_dev); +error:kfree (jack->id);kfree (jack);return err;@@ -281,11 +291,13 @@ EXPORT_SYMBOL(snd_jack_new);*/ void snd_jack_set_parent (struct snd_jack *jack,struct device *parent) { +#ifdef CONFIG_INPUT WARN_ON (jack->registered);if (!jack->input_dev)return ; jack->input_dev->dev.parent = parent; +#endif }EXPORT_SYMBOL (snd_jack_set_parent);@@ -340,7 +352,6 @@ EXPORT_SYMBOL(snd_jack_set_key); void snd_jack_report(struct snd_jack *jack, int status) {struct snd_jack_kctl *jack_kctl; -int i;if (!jack)return ;@@ -349,10 +360,11 @@ void snd_jack_report(struct snd_jack *jack,Quoted 1 line
int
status)
Quoted 13 lines
sound/core/jack.c +2
-1snd_kctl_jack_report (jack->card, jack_kctl->kctl, status & jack_kctl->mask_bits); +#ifdef CONFIG_INPUT if (!jack->input_dev)return ; -for (i =0 ; i <ARRAY_SIZE (jack->key); i++) { +for (int i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit =SND_JACK_BTN_0 >> i;if (jack->type & testbit)@@ -369,7 +381,7 @@ void snd_jack_report(struct snd_jack *jack,Quoted 1 line
int
status)
Quoted 11 lines
sound/core/jack.c +1
-2}input_sync (jack->input_dev); - +#endif }EXPORT_SYMBOL (snd_jack_report); --1.9.1
At Sat, 2 May 2015 07:09:50 +0000,
Quoted 54 lines · Yang
Quoted 45 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, May 02, 2015 3:01 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Sat, 2 May 2015 04:51:34 +0000,
Quoted 21 lines · Yang
Quoted 21 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, May 01, 2015 3:11 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Fri, 1 May 2015 11:10:29 +0800,
Quoted 6 lines · Jie Yang
There may be no
input_devfor jack(e.g. phantom jack), whenCONFIG_INPUTis not selected, building errors such as:
undefined reference to `input_xxx'...Here add #ifdef judgement to fix the issue.
Well, the standard idiom so far is to enable
SND_JACKselectively. Take a look at the comment insound/core/Kconfig.Quoted 7 lines
Quoted 7 lines
# To be effective this also requires INPUT - users should say:
# selectSND_JACKif INPUT=y || INPUT=SND# to avoid having to force INPUT on. config SND_JACK boolAnd, looking at
sound/pci/hda/Kconfig, there is still
SND_HDA_INPUT_JACK.Quoted 3 lines
Quoted 3 lines
So, what you need to fix is:
- RemoveSND_HDA_INPUT_JACKfromsound/pci/hda/Kconfigand thelast
Quoted 2 lines
Quoted 2 lines
ifdef in
hda_codec.hQuoted 8 lines
Quoted 5 lines
Quoted 2 lines
- Replace the line "select
SND_JACK" withselect SND_JACK if INPUT=y || INPUT=SND_HDAOK, will follow this. What I only concern is that if user want
SND_JACkwhen INPUT=N(e.g. phantom jack?), it becomes impossible.Right, it's impossible now. But this is the case really no one would care much (who wants the jack detection on a system without any input capability?).
Quoted 7 lines
Got it. Another question here, I found that this change in
sound/pci/had/Kconfigdoesn't fix the building issue:select SND_JACK if INPUT=y || INPUT=SND_HDA but this do: select SND_JACK if INPUT=y || INPUT=SNDsuppose we should use the latter one, right?
Yes, correct.
Quoted 3 lines
Do you know why the former one
doesn't fix?(seems here "INPUT=SND..." added for bothCONFIG_INPUT=mand SND...=m case?)
SND may be y while SND_HDA=m and INPUT=m.
Takashi
Quoted 72 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, May 02, 2015 3:12 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Sat, 2 May 2015 07:09:50 +0000,
Quoted 37 lines · Yang
Quoted 37 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Saturday, May 02, 2015 3:01 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueAt Sat, 2 May 2015 04:51:34 +0000,
Quoted 26 lines · Yang
Quoted 26 lines
-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Friday, May 01, 2015 3:11 PM
To: Jie, Yang
Cc: [email protected]; [email protected]; Girdwood, Liam R
Subject: Re: [PATCH] ALSA: jack: fix a randconfig build issueQuoted 6 lines · Jie Yang
There may be no
input_devfor jack(e.g. phantom jack), whenCONFIG_INPUTis not selected, building errors such as:
undefined reference to `input_xxx'...Here add #ifdef judgement to fix the issue.
Well, the standard idiom so far is to enable
SND_JACKselectively. Take a look at the comment insound/core/Kconfig.# To be effective this also requires INPUT - users should say:
# selectSND_JACKif INPUT=y || INPUT=SND# to avoid having to force INPUT on. config SND_JACK boolQuoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
And, looking at
sound/pci/hda/Kconfig, there is still
SND_HDA_INPUT_JACK.Quoted 3 lines
Quoted 3 lines
So, what you need to fix is:
- RemoveSND_HDA_INPUT_JACKfromsound/pci/hda/Kconfigandthe
Quoted 11 lines
Quoted 11 lines
last
Quoted 7 lines
Quoted 4 lines
ifdef in
hda_codec.h- Replace the line "select
SND_JACK" withselect SND_JACK if INPUT=y || INPUT=SND_HDAOK, will follow this. What I only concern is that if user want
SND_JACkwhen INPUT=N(e.g. phantom jack?), it becomes impossible.Right, it's impossible now. But this is the case really no one would care much (who wants the jack detection on a system without any
input capability?).
Quoted 7 lines
Got it. Another question here, I found that this change in
sound/pci/had/Kconfigdoesn't fix the building issue:select SND_JACK if INPUT=y || INPUT=SND_HDA but this do: select SND_JACK if INPUT=y || INPUT=SNDsuppose we should use the latter one, right?
Quoted 8 lines
Yes, correct.
Quoted 2 lines
Do you know why the former one
doesn't fix?(seems here "INPUT=SND..." added for both
CONFIG_INPUT=mQuoted 1 line
and SND...=m case?)
SND may be y while SND_HDA=m and INPUT=m.
Thanks, will update the patch and send out soon.
~Keyon
Quoted 3 lines
Takashi