1e76d8ceaSMark Brown #ifndef __SOUND_JACK_H 2e76d8ceaSMark Brown #define __SOUND_JACK_H 3e76d8ceaSMark Brown 4e76d8ceaSMark Brown /* 5e76d8ceaSMark Brown * Jack abstraction layer 6e76d8ceaSMark Brown * 7e76d8ceaSMark Brown * Copyright 2008 Wolfson Microelectronics plc 8e76d8ceaSMark Brown * 9e76d8ceaSMark Brown * 10e76d8ceaSMark Brown * This program is free software; you can redistribute it and/or modify 11e76d8ceaSMark Brown * it under the terms of the GNU General Public License as published by 12e76d8ceaSMark Brown * the Free Software Foundation; either version 2 of the License, or 13e76d8ceaSMark Brown * (at your option) any later version. 14e76d8ceaSMark Brown * 15e76d8ceaSMark Brown * This program is distributed in the hope that it will be useful, 16e76d8ceaSMark Brown * but WITHOUT ANY WARRANTY; without even the implied warranty of 17e76d8ceaSMark Brown * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18e76d8ceaSMark Brown * GNU General Public License for more details. 19e76d8ceaSMark Brown * 20e76d8ceaSMark Brown * You should have received a copy of the GNU General Public License 21e76d8ceaSMark Brown * along with this program; if not, write to the Free Software 22e76d8ceaSMark Brown * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23e76d8ceaSMark Brown * 24e76d8ceaSMark Brown */ 25e76d8ceaSMark Brown 26e76d8ceaSMark Brown #include <sound/core.h> 27e76d8ceaSMark Brown 28e76d8ceaSMark Brown struct input_dev; 29e76d8ceaSMark Brown 30e76d8ceaSMark Brown /** 31e76d8ceaSMark Brown * Jack types which can be reported. These values are used as a 32e76d8ceaSMark Brown * bitmask. 33bd8a71a7SMark Brown * 34bd8a71a7SMark Brown * Note that this must be kept in sync with the lookup table in 35bd8a71a7SMark Brown * sound/core/jack.c. 36e76d8ceaSMark Brown */ 37e76d8ceaSMark Brown enum snd_jack_types { 38e76d8ceaSMark Brown SND_JACK_HEADPHONE = 0x0001, 39e76d8ceaSMark Brown SND_JACK_MICROPHONE = 0x0002, 40e76d8ceaSMark Brown SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, 41a53ccab3SMatthew Ranostay SND_JACK_LINEOUT = 0x0004, 42cdc69364SMark Brown SND_JACK_MECHANICAL = 0x0008, /* If detected separately */ 43d506fc32SJani Nikula SND_JACK_VIDEOOUT = 0x0010, 44d506fc32SJani Nikula SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT, 45*ebb812cbSMark Brown 46*ebb812cbSMark Brown /* Kept separate from switches to facilitate implementation */ 47*ebb812cbSMark Brown SND_JACK_BTN_0 = 0x4000, 48*ebb812cbSMark Brown SND_JACK_BTN_1 = 0x2000, 49*ebb812cbSMark Brown SND_JACK_BTN_2 = 0x1000, 50e76d8ceaSMark Brown }; 51e76d8ceaSMark Brown 52e76d8ceaSMark Brown struct snd_jack { 53e76d8ceaSMark Brown struct input_dev *input_dev; 54e76d8ceaSMark Brown int registered; 55e76d8ceaSMark Brown int type; 56e76d8ceaSMark Brown const char *id; 57e76d8ceaSMark Brown char name[100]; 58*ebb812cbSMark Brown unsigned int key[3]; /* Keep in sync with definitions above */ 599d59065cSTakashi Iwai void *private_data; 609d59065cSTakashi Iwai void (*private_free)(struct snd_jack *); 61e76d8ceaSMark Brown }; 62e76d8ceaSMark Brown 63e76d8ceaSMark Brown #ifdef CONFIG_SND_JACK 64e76d8ceaSMark Brown 65e76d8ceaSMark Brown int snd_jack_new(struct snd_card *card, const char *id, int type, 66e76d8ceaSMark Brown struct snd_jack **jack); 67e76d8ceaSMark Brown void snd_jack_set_parent(struct snd_jack *jack, struct device *parent); 68*ebb812cbSMark Brown int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, 69*ebb812cbSMark Brown int keytype); 70e76d8ceaSMark Brown 71e76d8ceaSMark Brown void snd_jack_report(struct snd_jack *jack, int status); 72e76d8ceaSMark Brown 73e76d8ceaSMark Brown #else 74e76d8ceaSMark Brown 75e76d8ceaSMark Brown static inline int snd_jack_new(struct snd_card *card, const char *id, int type, 76e76d8ceaSMark Brown struct snd_jack **jack) 77e76d8ceaSMark Brown { 78e76d8ceaSMark Brown return 0; 79e76d8ceaSMark Brown } 80e76d8ceaSMark Brown 81e76d8ceaSMark Brown static inline void snd_jack_set_parent(struct snd_jack *jack, 82e76d8ceaSMark Brown struct device *parent) 83e76d8ceaSMark Brown { 84e76d8ceaSMark Brown } 85e76d8ceaSMark Brown 86e76d8ceaSMark Brown static inline void snd_jack_report(struct snd_jack *jack, int status) 87e76d8ceaSMark Brown { 88e76d8ceaSMark Brown } 89e76d8ceaSMark Brown 90e76d8ceaSMark Brown #endif 91e76d8ceaSMark Brown 92e76d8ceaSMark Brown #endif 93