All of lore.kernel.org
 help / color / mirror / Atom feed
* Create a general function for codec jack detection
@ 2017-03-14  5:54 Bard Liao
  2017-04-05 17:29 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Bard Liao @ 2017-03-14  5:54 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: Oder Chiou, alsa-devel, lars, tiwai, xiaoxiang, zhongan, Flove

Mark,

There are many codecs with the capability of jack detection. Usually, we
create a jack on machine driver and call an exported codec function,
like rt5670_set_jack_detect, to use the jack and report the jack type.
Could we create a general function for such exported functions?
The benefit is we don't need to use different function names for each
codecs. So we can have a general machine driver with jack detection
function.

Below is what I am thinking the patch will look like.

diff --git a/include/sound/soc.h b/include/sound/soc.h
index cdfb55f..e5a863a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -434,6 +434,8 @@ int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
                             int source, unsigned int freq, int dir);
 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
                          unsigned int freq_in, unsigned int freq_out);
+int snd_soc_codec_set_jack(struct snd_soc_codec *codec,
+                          struct snd_soc_jack *jack);

 int snd_soc_register_card(struct snd_soc_card *card);
 int snd_soc_unregister_card(struct snd_soc_card *card);
@@ -913,6 +915,7 @@ struct snd_soc_codec_driver {
                          int clk_id, int source, unsigned int freq, int dir);
        int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
                unsigned int freq_in, unsigned int freq_out);
+       int (*set_jack)(struct snd_soc_codec *codec, struct snd_soc_jack *jack);

        /* codec IO */
        struct regmap *(*get_regmap)(struct device *);
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index fbaa1bb..ec49577 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -22,6 +22,23 @@
 #include <trace/events/asoc.h>

 /**
+ * snd_soc_codec_set_jack - configure codec jack.
+ * @codec: CODEC
+ * @jack: structure to use for the jack
+ *
+ * Configures and enables jack detection function.
+ */
+int snd_soc_codec_set_jack(struct snd_soc_codec *codec,
+       struct snd_soc_jack *jack)
+{
+       if (codec->driver->set_jack)
+               return codec->driver->set_jack(codec, jack);
+       else
+               return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack);
+
+/**
  * snd_soc_card_jack_new - Create a new jack
  * @card:  ASoC card
  * @id:    an identifying string for this jack
--

Thanks.

Bard Liao

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Create a general function for codec jack detection
  2017-03-14  5:54 Create a general function for codec jack detection Bard Liao
@ 2017-04-05 17:29 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2017-04-05 17:29 UTC (permalink / raw)
  To: Bard Liao
  Cc: Oder Chiou, alsa-devel, lars, tiwai, lgirdwood, xiaoxiang,
	zhongan, Flove


[-- Attachment #1.1: Type: text/plain, Size: 489 bytes --]

On Tue, Mar 14, 2017 at 05:54:35AM +0000, Bard Liao wrote:

> Below is what I am thinking the patch will look like.

It's better to just write the patch for something like this and present
it as such rather than ask to send the patch - it makes things a lot
easier to handle.

> +int snd_soc_codec_set_jack(struct snd_soc_codec *codec,
> +                          struct snd_soc_jack *jack);

We have enough things that have no meaningful configuration to make this
useful I think so OK.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-05 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14  5:54 Create a general function for codec jack detection Bard Liao
2017-04-05 17:29 ` Mark Brown

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.