Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef __SOUND_JACK_H
0003 #define __SOUND_JACK_H
0004 
0005 /*
0006  *  Jack abstraction layer
0007  *
0008  *  Copyright 2008 Wolfson Microelectronics plc
0009  */
0010 
0011 #include <sound/core.h>
0012 
0013 struct input_dev;
0014 
0015 /**
0016  * enum snd_jack_types - Jack types which can be reported
0017  * @SND_JACK_HEADPHONE: Headphone
0018  * @SND_JACK_MICROPHONE: Microphone
0019  * @SND_JACK_HEADSET: Headset
0020  * @SND_JACK_LINEOUT: Line out
0021  * @SND_JACK_MECHANICAL: Mechanical switch
0022  * @SND_JACK_VIDEOOUT: Video out
0023  * @SND_JACK_AVOUT: AV (Audio Video) out
0024  * @SND_JACK_LINEIN:  Line in
0025  * @SND_JACK_BTN_0: Button 0
0026  * @SND_JACK_BTN_1: Button 1
0027  * @SND_JACK_BTN_2: Button 2
0028  * @SND_JACK_BTN_3: Button 3
0029  * @SND_JACK_BTN_4: Button 4
0030  * @SND_JACK_BTN_5: Button 5
0031  *
0032  * These values are used as a bitmask.
0033  *
0034  * Note that this must be kept in sync with the lookup table in
0035  * sound/core/jack.c.
0036  */
0037 enum snd_jack_types {
0038     SND_JACK_HEADPHONE  = 0x0001,
0039     SND_JACK_MICROPHONE = 0x0002,
0040     SND_JACK_HEADSET    = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
0041     SND_JACK_LINEOUT    = 0x0004,
0042     SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
0043     SND_JACK_VIDEOOUT   = 0x0010,
0044     SND_JACK_AVOUT      = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
0045     SND_JACK_LINEIN     = 0x0020,
0046 
0047     /* Kept separate from switches to facilitate implementation */
0048     SND_JACK_BTN_0      = 0x4000,
0049     SND_JACK_BTN_1      = 0x2000,
0050     SND_JACK_BTN_2      = 0x1000,
0051     SND_JACK_BTN_3      = 0x0800,
0052     SND_JACK_BTN_4      = 0x0400,
0053     SND_JACK_BTN_5      = 0x0200,
0054 };
0055 
0056 /* Keep in sync with definitions above */
0057 #define SND_JACK_SWITCH_TYPES 6
0058 
0059 struct snd_jack {
0060     struct list_head kctl_list;
0061     struct snd_card *card;
0062     const char *id;
0063 #ifdef CONFIG_SND_JACK_INPUT_DEV
0064     struct input_dev *input_dev;
0065     struct mutex input_dev_lock;
0066     int registered;
0067     int type;
0068     char name[100];
0069     unsigned int key[6];   /* Keep in sync with definitions above */
0070 #endif /* CONFIG_SND_JACK_INPUT_DEV */
0071     int hw_status_cache;
0072     void *private_data;
0073     void (*private_free)(struct snd_jack *);
0074 };
0075 
0076 #ifdef CONFIG_SND_JACK
0077 
0078 int snd_jack_new(struct snd_card *card, const char *id, int type,
0079          struct snd_jack **jack, bool initial_kctl, bool phantom_jack);
0080 int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask);
0081 #ifdef CONFIG_SND_JACK_INPUT_DEV
0082 void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
0083 int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
0084              int keytype);
0085 #endif
0086 void snd_jack_report(struct snd_jack *jack, int status);
0087 
0088 #else
0089 static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
0090                    struct snd_jack **jack, bool initial_kctl, bool phantom_jack)
0091 {
0092     return 0;
0093 }
0094 
0095 static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
0096 {
0097     return 0;
0098 }
0099 
0100 static inline void snd_jack_report(struct snd_jack *jack, int status)
0101 {
0102 }
0103 
0104 #endif
0105 
0106 #if !defined(CONFIG_SND_JACK) || !defined(CONFIG_SND_JACK_INPUT_DEV)
0107 static inline void snd_jack_set_parent(struct snd_jack *jack,
0108                        struct device *parent)
0109 {
0110 }
0111 
0112 static inline int snd_jack_set_key(struct snd_jack *jack,
0113                    enum snd_jack_types type,
0114                    int keytype)
0115 {
0116     return 0;
0117 }
0118 #endif /* !CONFIG_SND_JACK || !CONFIG_SND_JACK_INPUT_DEV */
0119 
0120 #endif