1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * HD audio Component Binding Interface
5 * Copyright (C) 2021 Cirrus Logic, Inc. and
6 * Cirrus Logic International Semiconductor Ltd.
9 #ifndef __HDA_COMPONENT_H__
10 #define __HDA_COMPONENT_H__
12 #include <linux/acpi.h>
13 #include <linux/component.h>
14 #include <linux/mutex.h>
15 #include <sound/hda_codec.h>
17 #define HDA_MAX_COMPONENTS 4
18 #define HDA_MAX_NAME_SIZE 50
20 struct hda_component {
22 char name[HDA_MAX_NAME_SIZE];
23 struct acpi_device *adev;
24 bool acpi_notifications_supported;
25 void (*acpi_notify)(acpi_handle handle, u32 event, struct device *dev);
26 void (*pre_playback_hook)(struct device *dev, int action);
27 void (*playback_hook)(struct device *dev, int action);
28 void (*post_playback_hook)(struct device *dev, int action);
31 struct hda_component_parent {
33 struct hda_codec *codec;
34 struct hda_component comps[HDA_MAX_COMPONENTS];
38 void hda_component_acpi_device_notify(struct hda_component_parent *parent,
39 acpi_handle handle, u32 event, void *data);
40 int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,
41 struct hda_component_parent *parent,
42 acpi_notify_handler handler, void *data);
43 void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,
44 struct hda_component_parent *parent,
45 acpi_notify_handler handler);
47 static inline void hda_component_acpi_device_notify(struct hda_component_parent *parent,
54 static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,
55 struct hda_component_parent *parent,
56 acpi_notify_handler handler,
63 static inline void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,
64 struct hda_component_parent *parent,
65 acpi_notify_handler handler)
68 #endif /* ifdef CONFIG_ACPI */
70 void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action);
72 int hda_component_manager_init(struct hda_codec *cdc,
73 struct hda_component_parent *parent, int count,
74 const char *bus, const char *hid,
75 const char *match_str,
76 const struct component_master_ops *ops);
78 void hda_component_manager_free(struct hda_component_parent *parent,
79 const struct component_master_ops *ops);
81 int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent);
83 static inline struct hda_component *hda_component_from_index(struct hda_component_parent *parent,
89 if (index < 0 || index >= ARRAY_SIZE(parent->comps))
92 return &parent->comps[index];
95 static inline void hda_component_manager_unbind(struct hda_codec *cdc,
96 struct hda_component_parent *parent)
98 mutex_lock(&parent->mutex);
99 component_unbind_all(hda_codec_dev(cdc), parent);
100 mutex_unlock(&parent->mutex);
103 #endif /* ifndef __HDA_COMPONENT_H__ */