18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci#ifndef __SOUND_JACK_H 38c2ecf20Sopenharmony_ci#define __SOUND_JACK_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Jack abstraction layer 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright 2008 Wolfson Microelectronics plc 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <sound/core.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct input_dev; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/** 168c2ecf20Sopenharmony_ci * enum snd_jack_types - Jack types which can be reported 178c2ecf20Sopenharmony_ci * @SND_JACK_HEADPHONE: Headphone 188c2ecf20Sopenharmony_ci * @SND_JACK_MICROPHONE: Microphone 198c2ecf20Sopenharmony_ci * @SND_JACK_HEADSET: Headset 208c2ecf20Sopenharmony_ci * @SND_JACK_LINEOUT: Line out 218c2ecf20Sopenharmony_ci * @SND_JACK_MECHANICAL: Mechanical switch 228c2ecf20Sopenharmony_ci * @SND_JACK_VIDEOOUT: Video out 238c2ecf20Sopenharmony_ci * @SND_JACK_AVOUT: AV (Audio Video) out 248c2ecf20Sopenharmony_ci * @SND_JACK_LINEIN: Line in 258c2ecf20Sopenharmony_ci * @SND_JACK_BTN_0: Button 0 268c2ecf20Sopenharmony_ci * @SND_JACK_BTN_1: Button 1 278c2ecf20Sopenharmony_ci * @SND_JACK_BTN_2: Button 2 288c2ecf20Sopenharmony_ci * @SND_JACK_BTN_3: Button 3 298c2ecf20Sopenharmony_ci * @SND_JACK_BTN_4: Button 4 308c2ecf20Sopenharmony_ci * @SND_JACK_BTN_5: Button 5 318c2ecf20Sopenharmony_ci * 328c2ecf20Sopenharmony_ci * These values are used as a bitmask. 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * Note that this must be kept in sync with the lookup table in 358c2ecf20Sopenharmony_ci * sound/core/jack.c. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_cienum snd_jack_types { 388c2ecf20Sopenharmony_ci SND_JACK_HEADPHONE = 0x0001, 398c2ecf20Sopenharmony_ci SND_JACK_MICROPHONE = 0x0002, 408c2ecf20Sopenharmony_ci SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, 418c2ecf20Sopenharmony_ci SND_JACK_LINEOUT = 0x0004, 428c2ecf20Sopenharmony_ci SND_JACK_MECHANICAL = 0x0008, /* If detected separately */ 438c2ecf20Sopenharmony_ci SND_JACK_VIDEOOUT = 0x0010, 448c2ecf20Sopenharmony_ci SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT, 458c2ecf20Sopenharmony_ci SND_JACK_LINEIN = 0x0020, 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci /* Kept separate from switches to facilitate implementation */ 488c2ecf20Sopenharmony_ci SND_JACK_BTN_0 = 0x4000, 498c2ecf20Sopenharmony_ci SND_JACK_BTN_1 = 0x2000, 508c2ecf20Sopenharmony_ci SND_JACK_BTN_2 = 0x1000, 518c2ecf20Sopenharmony_ci SND_JACK_BTN_3 = 0x0800, 528c2ecf20Sopenharmony_ci SND_JACK_BTN_4 = 0x0400, 538c2ecf20Sopenharmony_ci SND_JACK_BTN_5 = 0x0200, 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* Keep in sync with definitions above */ 578c2ecf20Sopenharmony_ci#define SND_JACK_SWITCH_TYPES 6 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct snd_jack { 608c2ecf20Sopenharmony_ci struct list_head kctl_list; 618c2ecf20Sopenharmony_ci struct snd_card *card; 628c2ecf20Sopenharmony_ci const char *id; 638c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_JACK_INPUT_DEV 648c2ecf20Sopenharmony_ci struct input_dev *input_dev; 658c2ecf20Sopenharmony_ci struct mutex input_dev_lock; 668c2ecf20Sopenharmony_ci int registered; 678c2ecf20Sopenharmony_ci int type; 688c2ecf20Sopenharmony_ci char name[100]; 698c2ecf20Sopenharmony_ci unsigned int key[6]; /* Keep in sync with definitions above */ 708c2ecf20Sopenharmony_ci#endif /* CONFIG_SND_JACK_INPUT_DEV */ 718c2ecf20Sopenharmony_ci void *private_data; 728c2ecf20Sopenharmony_ci void (*private_free)(struct snd_jack *); 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_JACK 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciint snd_jack_new(struct snd_card *card, const char *id, int type, 788c2ecf20Sopenharmony_ci struct snd_jack **jack, bool initial_kctl, bool phantom_jack); 798c2ecf20Sopenharmony_ciint snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask); 808c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_JACK_INPUT_DEV 818c2ecf20Sopenharmony_civoid snd_jack_set_parent(struct snd_jack *jack, struct device *parent); 828c2ecf20Sopenharmony_ciint snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, 838c2ecf20Sopenharmony_ci int keytype); 848c2ecf20Sopenharmony_ci#endif 858c2ecf20Sopenharmony_civoid snd_jack_report(struct snd_jack *jack, int status); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#else 888c2ecf20Sopenharmony_cistatic inline int snd_jack_new(struct snd_card *card, const char *id, int type, 898c2ecf20Sopenharmony_ci struct snd_jack **jack, bool initial_kctl, bool phantom_jack) 908c2ecf20Sopenharmony_ci{ 918c2ecf20Sopenharmony_ci return 0; 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci return 0; 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic inline void snd_jack_report(struct snd_jack *jack, int status) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci} 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#endif 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#if !defined(CONFIG_SND_JACK) || !defined(CONFIG_SND_JACK_INPUT_DEV) 1068c2ecf20Sopenharmony_cistatic inline void snd_jack_set_parent(struct snd_jack *jack, 1078c2ecf20Sopenharmony_ci struct device *parent) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci} 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistatic inline int snd_jack_set_key(struct snd_jack *jack, 1128c2ecf20Sopenharmony_ci enum snd_jack_types type, 1138c2ecf20Sopenharmony_ci int keytype) 1148c2ecf20Sopenharmony_ci{ 1158c2ecf20Sopenharmony_ci return 0; 1168c2ecf20Sopenharmony_ci} 1178c2ecf20Sopenharmony_ci#endif /* !CONFIG_SND_JACK || !CONFIG_SND_JACK_INPUT_DEV */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#endif 120