linux/sound/core/jack.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Jack abstraction layer
 *
 *  Copyright 2008 Wolfson Microelectronics
 */

#include <linux/input.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/ctype.h>
#include <linux/mm.h>
#include <linux/debugfs.h>
#include <sound/jack.h>
#include <sound/core.h>
#include <sound/control.h>

struct snd_jack_kctl {};

#ifdef CONFIG_SND_JACK_INPUT_DEV
static const int jack_switch_types[SND_JACK_SWITCH_TYPES] =;
#endif /* CONFIG_SND_JACK_INPUT_DEV */

static void snd_jack_remove_debugfs(struct snd_jack *jack);

static int snd_jack_dev_disconnect(struct snd_device *device)
{}

static int snd_jack_dev_free(struct snd_device *device)
{}

#ifdef CONFIG_SND_JACK_INPUT_DEV
static int snd_jack_dev_register(struct snd_device *device)
{}
#endif /* CONFIG_SND_JACK_INPUT_DEV */

#ifdef CONFIG_SND_JACK_INJECTION_DEBUG
static void snd_jack_inject_report(struct snd_jack_kctl *jack_kctl, int status)
{}

static ssize_t sw_inject_enable_read(struct file *file,
				     char __user *to, size_t count, loff_t *ppos)
{}

static ssize_t sw_inject_enable_write(struct file *file,
				      const char __user *from, size_t count, loff_t *ppos)
{}

static ssize_t jackin_inject_write(struct file *file,
				   const char __user *from, size_t count, loff_t *ppos)
{}

static ssize_t jack_kctl_id_read(struct file *file,
				 char __user *to, size_t count, loff_t *ppos)
{}

/* the bit definition is aligned with snd_jack_types in jack.h */
static const char * const jack_events_name[] =;

/* the recommended buffer size is 256 */
static int parse_mask_bits(unsigned int mask_bits, char *buf, size_t buf_size)
{}

static ssize_t jack_kctl_mask_bits_read(struct file *file,
					char __user *to, size_t count, loff_t *ppos)
{}

static ssize_t jack_kctl_status_read(struct file *file,
				     char __user *to, size_t count, loff_t *ppos)
{}

#ifdef CONFIG_SND_JACK_INPUT_DEV
static ssize_t jack_type_read(struct file *file,
			      char __user *to, size_t count, loff_t *ppos)
{}

static const struct file_operations jack_type_fops =;
#endif

static const struct file_operations sw_inject_enable_fops =;

static const struct file_operations jackin_inject_fops =;

static const struct file_operations jack_kctl_id_fops =;

static const struct file_operations jack_kctl_mask_bits_fops =;

static const struct file_operations jack_kctl_status_fops =;

static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
					    struct snd_jack_kctl *jack_kctl)
{}

static void snd_jack_remove_debugfs(struct snd_jack *jack)
{}
#else /* CONFIG_SND_JACK_INJECTION_DEBUG */
static int snd_jack_debugfs_add_inject_node(struct snd_jack *jack,
					    struct snd_jack_kctl *jack_kctl)
{
	return 0;
}

static void snd_jack_remove_debugfs(struct snd_jack *jack)
{
}
#endif /* CONFIG_SND_JACK_INJECTION_DEBUG */

static void snd_jack_kctl_private_free(struct snd_kcontrol *kctl)
{}

static void snd_jack_kctl_add(struct snd_jack *jack, struct snd_jack_kctl *jack_kctl)
{}

static struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, const char *name, unsigned int mask)
{}

/**
 * snd_jack_add_new_kctl - Create a new snd_jack_kctl and add it to jack
 * @jack:  the jack instance which the kctl will attaching to
 * @name:  the name for the snd_kcontrol object
 * @mask:  a bitmask of enum snd_jack_type values that can be detected
 *         by this snd_jack_kctl object.
 *
 * Creates a new snd_kcontrol object and adds it to the jack kctl_list.
 *
 * Return: Zero if successful, or a negative error code on failure.
 */
int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
{}
EXPORT_SYMBOL();

/**
 * snd_jack_new - Create a new jack
 * @card:  the card instance
 * @id:    an identifying string for this jack
 * @type:  a bitmask of enum snd_jack_type values that can be detected by
 *         this jack
 * @jjack: Used to provide the allocated jack object to the caller.
 * @initial_kctl: if true, create a kcontrol and add it to the jack list.
 * @phantom_jack: Don't create a input device for phantom jacks.
 *
 * Creates a new jack object.
 *
 * Return: Zero if successful, or a negative error code on failure.
 * On success @jjack will be initialised.
 */
int snd_jack_new(struct snd_card *card, const char *id, int type,
		 struct snd_jack **jjack, bool initial_kctl, bool phantom_jack)
{}
EXPORT_SYMBOL();

#ifdef CONFIG_SND_JACK_INPUT_DEV
/**
 * snd_jack_set_parent - Set the parent device for a jack
 *
 * @jack:   The jack to configure
 * @parent: The device to set as parent for the jack.
 *
 * Set the parent for the jack devices in the device tree.  This
 * function is only valid prior to registration of the jack.  If no
 * parent is configured then the parent device will be the sound card.
 */
void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
{}
EXPORT_SYMBOL();

/**
 * snd_jack_set_key - Set a key mapping on a jack
 *
 * @jack:    The jack to configure
 * @type:    Jack report type for this key
 * @keytype: Input layer key type to be reported
 *
 * Map a SND_JACK_BTN_* button type to an input layer key, allowing
 * reporting of keys on accessories via the jack abstraction.  If no
 * mapping is provided but keys are enabled in the jack type then
 * BTN_n numeric buttons will be reported.
 *
 * If jacks are not reporting via the input API this call will have no
 * effect.
 *
 * Note that this is intended to be use by simple devices with small
 * numbers of keys that can be reported.  It is also possible to
 * access the input device directly - devices with complex input
 * capabilities on accessories should consider doing this rather than
 * using this abstraction.
 *
 * This function may only be called prior to registration of the jack.
 *
 * Return: Zero if successful, or a negative error code on failure.
 */
int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
		     int keytype)
{}
EXPORT_SYMBOL();
#endif /* CONFIG_SND_JACK_INPUT_DEV */

/**
 * snd_jack_report - Report the current status of a jack
 * Note: This function uses mutexes and should be called from a
 * context which can sleep (such as a workqueue).
 *
 * @jack:   The jack to report status for
 * @status: The current status of the jack
 */
void snd_jack_report(struct snd_jack *jack, int status)
{}
EXPORT_SYMBOL();