]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'topic/jack' into for-linus
authorTakashi Iwai <tiwai@suse.de>
Mon, 23 Mar 2009 23:35:43 +0000 (00:35 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Mar 2009 23:35:43 +0000 (00:35 +0100)
1  2 
include/linux/input.h
sound/core/jack.c

diff --combined include/linux/input.h
index 1249a0c20a38258f7cf3064ece21f6e54dcbf254,adc13322d1d2a352b1e7a139f873e2b1e5ca78a1..6b28048fc56820152a1f95074b2721e285bab762
@@@ -16,7 -16,7 +16,7 @@@
  #include <sys/time.h>
  #include <sys/ioctl.h>
  #include <sys/types.h>
 -#include <asm/types.h>
 +#include <linux/types.h>
  #endif
  
  /*
@@@ -661,6 -661,7 +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 --combined sound/core/jack.c
index 077a85262c1c2592c8323b6f249fc645aaf5ecc7,43b10d6e522bc0e7b2c62bee63f0a5d94faa2250..c8254c667c6247cef5e402161b0b1ef076782a5e
  #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,
+       SW_VIDEOOUT_INSERT,
+ };
  static int snd_jack_dev_free(struct snd_device *device)
  {
        struct snd_jack *jack = device->device_data;
@@@ -47,7 -55,7 +55,7 @@@ static int snd_jack_dev_register(struc
        int err;
  
        snprintf(jack->name, sizeof(jack->name), "%s %s",
 -               card->longname, jack->id);
 +               card->shortname, jack->id);
        jack->input_dev->name = jack->name;
  
        /* Default to the sound card device. */
@@@ -79,6 -87,7 +87,7 @@@ int snd_jack_new(struct snd_card *card
  {
        struct snd_jack *jack;
        int err;
+       int i;
        static struct snd_device_ops ops = {
                .dev_free = snd_jack_dev_free,
                .dev_register = snd_jack_dev_register,
  
        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 -155,17 +155,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);
  }