From 50dfb69d1bb0062e2811547525c73e9a45a423e9 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Mon, 26 May 2014 14:34:36 +0300 Subject: ASoC: jack: Basic GPIO descriptor conversion This patch does basic GPIO descriptor conversion to soc-jack. Even the GPIOs are still passed and requested using legacy GPIO numbers the driver internals are converted to use GPIO descriptor API. Motivation for this is to prepare soc-jack so that it will allow registering jack GPIO pins using both GPIO descriptors and legacy GPIO numbers. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..c6bd40f2c40b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -606,6 +606,7 @@ struct snd_soc_jack_gpio { struct snd_soc_jack *jack; struct delayed_work work; + struct gpio_desc *desc; void *data; int (*jack_status_check)(void *data); -- cgit v1.2.3 From f025d3b9c64e1f7feb75a559d4a12f5f8c6a4a25 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Mon, 26 May 2014 14:34:37 +0300 Subject: ASoC: jack: Add support for GPIO descriptor defined jack pins Allow jack GPIO pins be defined also using GPIO descriptor-based interface in addition to legacy GPIO numbers. This is done by adding two new fields to struct snd_soc_jack_gpio: idx and gpiod_dev. Legacy GPIO numbers are used only when GPIO consumer device gpiod_dev is NULL and otherwise idx is the descriptor index within the GPIO consumer device. New function snd_soc_jack_add_gpiods() is added for typical cases where all GPIO descriptor jack pins belong to same GPIO consumer device. For other cases the caller must set the gpiod_dev in struct snd_soc_jack_gpio before calling snd_soc_jack_add_gpios(). Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- include/sound/soc.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index c6bd40f2c40b..61bea882a74b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -453,6 +453,9 @@ int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); #ifdef CONFIG_GPIOLIB int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios); +int snd_soc_jack_add_gpiods(struct device *gpiod_dev, + struct snd_soc_jack *jack, + int count, struct snd_soc_jack_gpio *gpios); void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios); #else @@ -462,6 +465,13 @@ static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, return 0; } +int snd_soc_jack_add_gpiods(struct device *gpiod_dev, + struct snd_soc_jack *jack, + int count, struct snd_soc_jack_gpio *gpios) +{ + return 0; +} + static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios) { @@ -586,7 +596,9 @@ struct snd_soc_jack_zone { /** * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection * - * @gpio: gpio number + * @gpio: legacy gpio number + * @idx: gpio descriptor index within the GPIO consumer device + * @gpiod_dev GPIO consumer device * @name: gpio name * @report: value to report when jack detected * @invert: report presence in low state @@ -598,6 +610,8 @@ struct snd_soc_jack_zone { */ struct snd_soc_jack_gpio { unsigned int gpio; + unsigned int idx; + struct device *gpiod_dev; const char *name; int report; int invert; -- cgit v1.2.3 From 83ad152d03b594b6a3fb9f3d313622b491cd6168 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Tue, 27 May 2014 13:54:18 +0300 Subject: ASoC: jack: Clarify GPIO descriptor lookup in struct snd_soc_jack_gpio doc Clarify struct snd_soc_jack_gpio documentation for the idx and name fields. Because name is passed as connection ID to gpiod_get_index() when using GPIO descriptor defined jack pins it is not only used as a label in debugfs but also as function name lookup in systems that support functions names for GPIOs. Clarify also idx since the index is within the function of the GPIO consumer device and not within the device itself only. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- include/sound/soc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 61bea882a74b..a2408a5b96a7 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -597,9 +597,11 @@ struct snd_soc_jack_zone { * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection * * @gpio: legacy gpio number - * @idx: gpio descriptor index within the GPIO consumer device + * @idx: gpio descriptor index within the function of the GPIO + * consumer device * @gpiod_dev GPIO consumer device - * @name: gpio name + * @name: gpio name. Also as connection ID for the GPIO consumer + * device function name lookup * @report: value to report when jack detected * @invert: report presence in low state * @debouce_time: debouce time in ms -- cgit v1.2.3 From e667487b67d96fc2471529e3a5b404f51dc52b39 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Tue, 27 May 2014 10:39:57 +0300 Subject: ASoC: jack: Fix multiple definition of `snd_soc_jack_add_gpiods' Commit f025d3b9c64e ("ASoC: jack: Add support for GPIO descriptor defined jack pins") caused build error when CONFIG_GPIOLIB is not set: sound/include/sound/soc.h:470: multiple definition of `snd_soc_jack_add_gpiods' sound/soc/soc-core.o:sound/include/sound/soc.h:470: first defined here make[2]: *** [sound/soc/snd-soc-core.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [sound/soc] Error 2 make: *** [sound] Error 2 Fix this by marking snd_soc_jack_add_gpiods() as static inline in soc.h. Reported-by: kbuild test robot Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- include/sound/soc.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index a2408a5b96a7..ac21cc22c4e9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -465,9 +465,10 @@ static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, return 0; } -int snd_soc_jack_add_gpiods(struct device *gpiod_dev, - struct snd_soc_jack *jack, - int count, struct snd_soc_jack_gpio *gpios) +static inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev, + struct snd_soc_jack *jack, + int count, + struct snd_soc_jack_gpio *gpios) { return 0; } -- cgit v1.2.3