18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Digital Beep Input Interface for HD-audio codec
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Matt Ranostay <matt.ranostay@konsulko.com>
68c2ecf20Sopenharmony_ci * Copyright (c) 2008 Embedded Alley Solutions Inc
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __SOUND_HDA_BEEP_H
108c2ecf20Sopenharmony_ci#define __SOUND_HDA_BEEP_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <sound/hda_codec.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define HDA_BEEP_MODE_OFF	0
158c2ecf20Sopenharmony_ci#define HDA_BEEP_MODE_ON	1
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* beep information */
188c2ecf20Sopenharmony_cistruct hda_beep {
198c2ecf20Sopenharmony_ci	struct input_dev *dev;
208c2ecf20Sopenharmony_ci	struct hda_codec *codec;
218c2ecf20Sopenharmony_ci	char phys[32];
228c2ecf20Sopenharmony_ci	int tone;
238c2ecf20Sopenharmony_ci	hda_nid_t nid;
248c2ecf20Sopenharmony_ci	unsigned int registered:1;
258c2ecf20Sopenharmony_ci	unsigned int enabled:1;
268c2ecf20Sopenharmony_ci	unsigned int linear_tone:1;	/* linear tone for IDT/STAC codec */
278c2ecf20Sopenharmony_ci	unsigned int playing:1;
288c2ecf20Sopenharmony_ci	unsigned int keep_power_at_enable:1;	/* set by driver */
298c2ecf20Sopenharmony_ci	struct work_struct beep_work; /* scheduled task for beep event */
308c2ecf20Sopenharmony_ci	struct mutex mutex;
318c2ecf20Sopenharmony_ci	void (*power_hook)(struct hda_beep *beep, bool on);
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#ifdef CONFIG_SND_HDA_INPUT_BEEP
358c2ecf20Sopenharmony_ciint snd_hda_enable_beep_device(struct hda_codec *codec, int enable);
368c2ecf20Sopenharmony_ciint snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
378c2ecf20Sopenharmony_civoid snd_hda_detach_beep_device(struct hda_codec *codec);
388c2ecf20Sopenharmony_ci#else
398c2ecf20Sopenharmony_cistatic inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
408c2ecf20Sopenharmony_ci{
418c2ecf20Sopenharmony_ci	return 0;
428c2ecf20Sopenharmony_ci}
438c2ecf20Sopenharmony_cistatic inline void snd_hda_detach_beep_device(struct hda_codec *codec)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci}
468c2ecf20Sopenharmony_ci#endif
478c2ecf20Sopenharmony_ci#endif
48