1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * HD audio Component Binding Interface 4 * 5 * Copyright (C) 2021 Cirrus Logic, Inc. and 6 * Cirrus Logic International Semiconductor Ltd. 7 */ 8 9 #ifndef __HDA_COMPONENT_H__ 10 #define __HDA_COMPONENT_H__ 11 12 #include <linux/acpi.h> 13 #include <linux/component.h> 14 #include <sound/hda_codec.h> 15 16 #define HDA_MAX_COMPONENTS 4 17 #define HDA_MAX_NAME_SIZE 50 18 19 struct hda_component { 20 struct device *dev; 21 char name[HDA_MAX_NAME_SIZE]; 22 struct hda_codec *codec; 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); 29 }; 30 31 #ifdef CONFIG_ACPI 32 void hda_component_acpi_device_notify(struct hda_component *comps, int num_comps, 33 acpi_handle handle, u32 event, void *data); 34 int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, 35 struct hda_component *comps, int num_comps, 36 acpi_notify_handler handler, void *data); 37 void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, 38 struct hda_component *comps, 39 acpi_notify_handler handler); 40 #else 41 static inline void hda_component_acpi_device_notify(struct hda_component *comps, 42 int num_comps, 43 acpi_handle handle, 44 u32 event, 45 void *data) 46 { 47 } 48 49 static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, 50 struct hda_component *comps, 51 int num_comps, 52 acpi_notify_handler handler, 53 void *data) 54 55 { 56 return 0; 57 } 58 59 static inline void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, 60 struct hda_component *comps, 61 acpi_notify_handler handler) 62 { 63 } 64 #endif /* ifdef CONFIG_ACPI */ 65 66 void hda_component_manager_playback_hook(struct hda_component *comps, int num_comps, 67 int action); 68 69 int hda_component_manager_init(struct hda_codec *cdc, 70 struct hda_component *comps, int count, 71 const char *bus, const char *hid, 72 const char *match_str, 73 const struct component_master_ops *ops); 74 75 void hda_component_manager_free(struct hda_codec *cdc, 76 const struct component_master_ops *ops); 77 78 int hda_component_manager_bind(struct hda_codec *cdc, 79 struct hda_component *comps, int count); 80 81 static inline void hda_component_manager_unbind(struct hda_codec *cdc, 82 struct hda_component *comps) 83 { 84 component_unbind_all(hda_codec_dev(cdc), comps); 85 } 86 87 #endif /* ifndef __HDA_COMPONENT_H__ */ 88