[alsa-devel] [PATCH] ALSA: Add support for TV-out to the jack reporting API
Add support for reporting new jack types SND_JACK_TVOUT and SND_JACK_AVOUT (a combination of LINEOUT and TVOUT) to the jack reporting API.
Also add the corresponding SW_TVOUT_INSERT switch to the input system header.
Signed-off-by: Jani Nikula ext-jani.1.nikula@nokia.com --- include/linux/input.h | 1 + include/sound/jack.h | 2 ++ sound/core/jack.c | 6 ++++++ 3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/linux/input.h b/include/linux/input.h index abd223b..ea5b224 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -646,6 +646,7 @@ struct input_absinfo { #define SW_DOCK 0x05 /* set = plugged into dock */ #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ +#define SW_TVOUT_INSERT 0x08 /* set = inserted */ #define SW_MAX 0x0f #define SW_CNT (SW_MAX+1)
diff --git a/include/sound/jack.h b/include/sound/jack.h index 2e0315c..69fc1f0 100644 --- a/include/sound/jack.h +++ b/include/sound/jack.h @@ -37,6 +37,8 @@ enum snd_jack_types { SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, SND_JACK_LINEOUT = 0x0004, SND_JACK_MECHANICAL = 0x0008, /* If detected separately */ + SND_JACK_TVOUT = 0x0010, + SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_TVOUT, };
struct snd_jack { diff --git a/sound/core/jack.c b/sound/core/jack.c index 7ca905c..23c3f3e 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -105,6 +105,9 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, if (type & SND_JACK_LINEOUT) input_set_capability(jack->input_dev, EV_SW, SW_LINEOUT_INSERT); + if (type & SND_JACK_TVOUT) + input_set_capability(jack->input_dev, EV_SW, + SW_TVOUT_INSERT); if (type & SND_JACK_MICROPHONE) input_set_capability(jack->input_dev, EV_SW, SW_MICROPHONE_INSERT); @@ -162,6 +165,9 @@ void snd_jack_report(struct snd_jack *jack, int status) if (jack->type & SND_JACK_LINEOUT) input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, status & SND_JACK_LINEOUT); + if (jack->type & SND_JACK_TVOUT) + input_report_switch(jack->input_dev, SW_TVOUT_INSERT, + status & SND_JACK_TVOUT); if (jack->type & SND_JACK_MICROPHONE) input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT, status & SND_JACK_MICROPHONE);
At Wed, 17 Dec 2008 14:04:33 +0200, Jani Nikula wrote:
Add support for reporting new jack types SND_JACK_TVOUT and SND_JACK_AVOUT (a combination of LINEOUT and TVOUT) to the jack reporting API.
Also add the corresponding SW_TVOUT_INSERT switch to the input system header.
Well, the patch itself looks good to me, but I'm slowly getting nervous about such an addition.
If any more new jack type will come, it'd be the time to consider a better mapping between SW_*_INSERT and SND_JACK_*...
Takashi
Signed-off-by: Jani Nikula ext-jani.1.nikula@nokia.com
include/linux/input.h | 1 + include/sound/jack.h | 2 ++ sound/core/jack.c | 6 ++++++ 3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/linux/input.h b/include/linux/input.h index abd223b..ea5b224 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -646,6 +646,7 @@ struct input_absinfo { #define SW_DOCK 0x05 /* set = plugged into dock */ #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ +#define SW_TVOUT_INSERT 0x08 /* set = inserted */ #define SW_MAX 0x0f #define SW_CNT (SW_MAX+1)
diff --git a/include/sound/jack.h b/include/sound/jack.h index 2e0315c..69fc1f0 100644 --- a/include/sound/jack.h +++ b/include/sound/jack.h @@ -37,6 +37,8 @@ enum snd_jack_types { SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, SND_JACK_LINEOUT = 0x0004, SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
- SND_JACK_TVOUT = 0x0010,
- SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_TVOUT,
};
struct snd_jack { diff --git a/sound/core/jack.c b/sound/core/jack.c index 7ca905c..23c3f3e 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -105,6 +105,9 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, if (type & SND_JACK_LINEOUT) input_set_capability(jack->input_dev, EV_SW, SW_LINEOUT_INSERT);
- if (type & SND_JACK_TVOUT)
input_set_capability(jack->input_dev, EV_SW,
if (type & SND_JACK_MICROPHONE) input_set_capability(jack->input_dev, EV_SW, SW_MICROPHONE_INSERT);SW_TVOUT_INSERT);
@@ -162,6 +165,9 @@ void snd_jack_report(struct snd_jack *jack, int status) if (jack->type & SND_JACK_LINEOUT) input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, status & SND_JACK_LINEOUT);
- if (jack->type & SND_JACK_TVOUT)
input_report_switch(jack->input_dev, SW_TVOUT_INSERT,
if (jack->type & SND_JACK_MICROPHONE) input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT, status & SND_JACK_MICROPHONE);status & SND_JACK_TVOUT);
-- 1.6.0.4
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
On Wed, Dec 17, 2008 at 02:13:34PM +0100, Takashi Iwai wrote:
Jani Nikula wrote:
Add support for reporting new jack types SND_JACK_TVOUT and
This might be better as "video" rather than "TV", identifying the type of video with the descriptive text in the label.
Well, the patch itself looks good to me, but I'm slowly getting nervous about such an addition.
If any more new jack type will come, it'd be the time to consider a better mapping between SW_*_INSERT and SND_JACK_*...
Hrm. Difficult given that the input side has incrementing numbers rather than the bitmask...
At Wed, 17 Dec 2008 14:34:00 +0000, Mark Brown wrote:
On Wed, Dec 17, 2008 at 02:13:34PM +0100, Takashi Iwai wrote:
Jani Nikula wrote:
Add support for reporting new jack types SND_JACK_TVOUT and
This might be better as "video" rather than "TV", identifying the type of video with the descriptive text in the label.
Well, the patch itself looks good to me, but I'm slowly getting nervous about such an addition.
If any more new jack type will come, it'd be the time to consider a better mapping between SW_*_INSERT and SND_JACK_*...
Hrm. Difficult given that the input side has incrementing numbers rather than the bitmask...
Can't we use a simple bit shift? But, hum, it's not 1:1 mapping.
Simplifying the code like below might be still worth, though...
Takashi
---
diff --git a/sound/core/jack.c b/sound/core/jack.c index dd4a12d..c6e34f4 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -23,6 +23,11 @@ #include <sound/jack.h> #include <sound/core.h>
+static int jack_types[] = { + SW_HEADPHONE_INSERT, SW_MICROPHONE_INSERT, SW_LINEOUT_INSERT, + SW_JACK_PHYSICAL_INSERT, +}; + static int snd_jack_dev_free(struct snd_device *device) { struct snd_jack *jack = device->device_data; @@ -78,7 +83,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, struct snd_jack **jjack) { struct snd_jack *jack; - int err; + int i, err; static struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, .dev_register = snd_jack_dev_register, @@ -100,18 +105,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
jack->type = type;
- if (type & SND_JACK_HEADPHONE) - input_set_capability(jack->input_dev, EV_SW, - SW_HEADPHONE_INSERT); - if (type & SND_JACK_LINEOUT) - input_set_capability(jack->input_dev, EV_SW, - SW_LINEOUT_INSERT); - if (type & SND_JACK_MICROPHONE) - input_set_capability(jack->input_dev, EV_SW, - SW_MICROPHONE_INSERT); - if (type & SND_JACK_MECHANICAL) - input_set_capability(jack->input_dev, EV_SW, - SW_JACK_PHYSICAL_INSERT); + for (i = 0; i < ARRAY_SIZE(jack_types); i++) + if (type & (1 << i)) + input_set_capability(jack->input_dev, EV_SW, + jack_types[i]);
err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); if (err < 0) @@ -154,21 +151,17 @@ EXPORT_SYMBOL(snd_jack_set_parent); */ void snd_jack_report(struct snd_jack *jack, int status) { + int i; + if (!jack) return;
- if (jack->type & SND_JACK_HEADPHONE) - input_report_switch(jack->input_dev, SW_HEADPHONE_INSERT, - status & SND_JACK_HEADPHONE); - if (jack->type & SND_JACK_LINEOUT) - input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, - status & SND_JACK_LINEOUT); - if (jack->type & SND_JACK_MICROPHONE) - input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT, - status & SND_JACK_MICROPHONE); - if (jack->type & SND_JACK_MECHANICAL) - input_report_switch(jack->input_dev, SW_JACK_PHYSICAL_INSERT, - status & SND_JACK_MECHANICAL); + for (i = 0; i < ARRAY_SIZE(jack_types); i++) { + int testbit = 1 << i; + if (jack->type & testbit) + input_report_switch(jack->input_dev, jack_types[i], + status & testbit); + }
input_sync(jack->input_dev); }
On Wed, Dec 17, 2008 at 03:48:38PM +0100, Takashi Iwai wrote:
Can't we use a simple bit shift? But, hum, it's not 1:1 mapping.
We could always use a bit shift and cope with the missing values.
Simplifying the code like below might be still worth, though...
...
+static int jack_types[] = {
- SW_HEADPHONE_INSERT, SW_MICROPHONE_INSERT, SW_LINEOUT_INSERT,
- SW_JACK_PHYSICAL_INSERT,
+};
Yeah, I was trying to think of something that could end up in the header more directly.
At Wed, 17 Dec 2008 15:06:36 +0000, Mark Brown wrote:
On Wed, Dec 17, 2008 at 03:48:38PM +0100, Takashi Iwai wrote:
Can't we use a simple bit shift? But, hum, it's not 1:1 mapping.
We could always use a bit shift and cope with the missing values.
If we need to change SND_JACK_* values, then we should do it now since 2.6.29 will be the first kernel that uses this API (it exists in 2.6.28 but not used).
Takashi
On Wed, Dec 17, 2008 at 04:12:07PM +0100, Takashi Iwai wrote:
If we need to change SND_JACK_* values, then we should do it now since 2.6.29 will be the first kernel that uses this API (it exists in 2.6.28 but not used).
Ideally, though since this ABI isn't exposed to user space it's not so critical. I'm not coming up with any better ideas than yours, though, so at the minute no change anyway.
On Wed, 2008-12-17 at 14:34 +0000, ext Mark Brown wrote:
This might be better as "video" rather than "TV", identifying the type of video with the descriptive text in the label.
Will resend with s/TVOUT/VIDEOOUT/g.
Jani.
Add support for reporting new jack types SND_JACK_VIDEOOUT and SND_JACK_AVOUT (a combination of LINEOUT and VIDEOOUT) to the jack reporting API.
Also add the corresponding SW_VIDEOOUT_INSERT switch to the input system header.
Signed-off-by: Jani Nikula ext-jani.1.nikula@nokia.com --- include/linux/input.h | 1 + include/sound/jack.h | 2 ++ sound/core/jack.c | 6 ++++++ 3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/linux/input.h b/include/linux/input.h index 9a6355f..adc1332 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -661,6 +661,7 @@ struct input_absinfo { #define SW_DOCK 0x05 /* set = plugged into dock */ #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ +#define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ #define SW_MAX 0x0f #define SW_CNT (SW_MAX+1)
diff --git a/include/sound/jack.h b/include/sound/jack.h index 2e0315c..283c975 100644 --- a/include/sound/jack.h +++ b/include/sound/jack.h @@ -37,6 +37,8 @@ enum snd_jack_types { SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, SND_JACK_LINEOUT = 0x0004, SND_JACK_MECHANICAL = 0x0008, /* If detected separately */ + SND_JACK_VIDEOOUT = 0x0010, + SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT, };
struct snd_jack { diff --git a/sound/core/jack.c b/sound/core/jack.c index dd4a12d..e1de195 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -106,6 +106,9 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, if (type & SND_JACK_LINEOUT) input_set_capability(jack->input_dev, EV_SW, SW_LINEOUT_INSERT); + if (type & SND_JACK_VIDEOOUT) + input_set_capability(jack->input_dev, EV_SW, + SW_VIDEOOUT_INSERT); if (type & SND_JACK_MICROPHONE) input_set_capability(jack->input_dev, EV_SW, SW_MICROPHONE_INSERT); @@ -163,6 +166,9 @@ void snd_jack_report(struct snd_jack *jack, int status) if (jack->type & SND_JACK_LINEOUT) input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, status & SND_JACK_LINEOUT); + if (jack->type & SND_JACK_VIDEOOUT) + input_report_switch(jack->input_dev, SW_VIDEOOUT_INSERT, + status & SND_JACK_VIDEOOUT); if (jack->type & SND_JACK_MICROPHONE) input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT, status & SND_JACK_MICROPHONE);
participants (3)
-
Jani Nikula
-
Mark Brown
-
Takashi Iwai