Path: blob/master/sound/hda/codecs/side-codecs/hda_component.h
26481 views
/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* HD audio Component Binding Interface3*4* Copyright (C) 2021 Cirrus Logic, Inc. and5* Cirrus Logic International Semiconductor Ltd.6*/78#ifndef __HDA_COMPONENT_H__9#define __HDA_COMPONENT_H__1011#include <linux/acpi.h>12#include <linux/component.h>13#include <linux/mutex.h>14#include <sound/hda_codec.h>1516#define HDA_MAX_COMPONENTS 417#define HDA_MAX_NAME_SIZE 501819struct hda_component {20struct device *dev;21char name[HDA_MAX_NAME_SIZE];22struct acpi_device *adev;23bool acpi_notifications_supported;24void (*acpi_notify)(acpi_handle handle, u32 event, struct device *dev);25void (*pre_playback_hook)(struct device *dev, int action);26void (*playback_hook)(struct device *dev, int action);27void (*post_playback_hook)(struct device *dev, int action);28};2930struct hda_component_parent {31struct mutex mutex;32struct hda_codec *codec;33struct hda_component comps[HDA_MAX_COMPONENTS];34};3536#ifdef CONFIG_ACPI37void hda_component_acpi_device_notify(struct hda_component_parent *parent,38acpi_handle handle, u32 event, void *data);39int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,40struct hda_component_parent *parent,41acpi_notify_handler handler, void *data);42void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,43struct hda_component_parent *parent,44acpi_notify_handler handler);45#else46static inline void hda_component_acpi_device_notify(struct hda_component_parent *parent,47acpi_handle handle,48u32 event,49void *data)50{51}5253static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,54struct hda_component_parent *parent,55acpi_notify_handler handler,56void *data)5758{59return 0;60}6162static inline void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,63struct hda_component_parent *parent,64acpi_notify_handler handler)65{66}67#endif /* ifdef CONFIG_ACPI */6869void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action);7071int hda_component_manager_init(struct hda_codec *cdc,72struct hda_component_parent *parent, int count,73const char *bus, const char *hid,74const char *match_str,75const struct component_master_ops *ops);7677void hda_component_manager_free(struct hda_component_parent *parent,78const struct component_master_ops *ops);7980int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent);8182static inline struct hda_component *hda_component_from_index(struct hda_component_parent *parent,83int index)84{85if (!parent)86return NULL;8788if (index < 0 || index >= ARRAY_SIZE(parent->comps))89return NULL;9091return &parent->comps[index];92}9394static inline void hda_component_manager_unbind(struct hda_codec *cdc,95struct hda_component_parent *parent)96{97mutex_lock(&parent->mutex);98component_unbind_all(hda_codec_dev(cdc), parent);99mutex_unlock(&parent->mutex);100}101102#endif /* ifndef __HDA_COMPONENT_H__ */103104105