2021-12-17 04:57:05 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* HD audio Component Binding Interface
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Cirrus Logic, Inc. and
|
|
|
|
* Cirrus Logic International Semiconductor Ltd.
|
|
|
|
*/
|
|
|
|
|
2024-03-07 04:12:15 -07:00
|
|
|
#ifndef __HDA_COMPONENT_H__
|
|
|
|
#define __HDA_COMPONENT_H__
|
|
|
|
|
2023-09-21 09:28:46 -07:00
|
|
|
#include <linux/acpi.h>
|
2021-12-17 04:57:05 -07:00
|
|
|
#include <linux/component.h>
|
2024-06-17 08:41:05 -07:00
|
|
|
#include <linux/mutex.h>
|
2024-03-07 04:12:16 -07:00
|
|
|
#include <sound/hda_codec.h>
|
2021-12-17 04:57:05 -07:00
|
|
|
|
|
|
|
#define HDA_MAX_COMPONENTS 4
|
|
|
|
#define HDA_MAX_NAME_SIZE 50
|
|
|
|
|
|
|
|
struct hda_component {
|
|
|
|
struct device *dev;
|
|
|
|
char name[HDA_MAX_NAME_SIZE];
|
2023-09-21 09:28:46 -07:00
|
|
|
struct acpi_device *adev;
|
|
|
|
bool acpi_notifications_supported;
|
|
|
|
void (*acpi_notify)(acpi_handle handle, u32 event, struct device *dev);
|
2023-07-21 08:18:12 -07:00
|
|
|
void (*pre_playback_hook)(struct device *dev, int action);
|
2021-12-17 04:57:05 -07:00
|
|
|
void (*playback_hook)(struct device *dev, int action);
|
2023-07-21 08:18:12 -07:00
|
|
|
void (*post_playback_hook)(struct device *dev, int action);
|
2021-12-17 04:57:05 -07:00
|
|
|
};
|
2024-01-24 04:26:07 -07:00
|
|
|
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent {
|
2024-06-17 08:41:05 -07:00
|
|
|
struct mutex mutex;
|
2024-06-17 08:41:04 -07:00
|
|
|
struct hda_codec *codec;
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component comps[HDA_MAX_COMPONENTS];
|
|
|
|
};
|
|
|
|
|
2024-01-24 04:26:07 -07:00
|
|
|
#ifdef CONFIG_ACPI
|
2024-06-17 08:41:02 -07:00
|
|
|
void hda_component_acpi_device_notify(struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
acpi_handle handle, u32 event, void *data);
|
|
|
|
int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
acpi_notify_handler handler, void *data);
|
|
|
|
void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
acpi_notify_handler handler);
|
|
|
|
#else
|
2024-06-17 08:41:02 -07:00
|
|
|
static inline void hda_component_acpi_device_notify(struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
acpi_handle handle,
|
|
|
|
u32 event,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc,
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
acpi_notify_handler handler,
|
|
|
|
void *data)
|
|
|
|
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc,
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
acpi_notify_handler handler)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* ifdef CONFIG_ACPI */
|
|
|
|
|
2024-06-17 08:41:02 -07:00
|
|
|
void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action);
|
2024-01-24 04:26:07 -07:00
|
|
|
|
|
|
|
int hda_component_manager_init(struct hda_codec *cdc,
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent *parent, int count,
|
2024-01-24 04:26:07 -07:00
|
|
|
const char *bus, const char *hid,
|
|
|
|
const char *match_str,
|
|
|
|
const struct component_master_ops *ops);
|
|
|
|
|
2024-08-29 09:11:14 -07:00
|
|
|
void hda_component_manager_free(struct hda_component_parent *parent,
|
2024-01-24 04:26:07 -07:00
|
|
|
const struct component_master_ops *ops);
|
|
|
|
|
2024-06-17 08:41:02 -07:00
|
|
|
int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent);
|
|
|
|
|
|
|
|
static inline struct hda_component *hda_component_from_index(struct hda_component_parent *parent,
|
|
|
|
int index)
|
|
|
|
{
|
|
|
|
if (!parent)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (index < 0 || index >= ARRAY_SIZE(parent->comps))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return &parent->comps[index];
|
|
|
|
}
|
2024-01-24 04:26:07 -07:00
|
|
|
|
|
|
|
static inline void hda_component_manager_unbind(struct hda_codec *cdc,
|
2024-06-17 08:41:02 -07:00
|
|
|
struct hda_component_parent *parent)
|
2024-01-24 04:26:07 -07:00
|
|
|
{
|
2024-06-17 08:41:05 -07:00
|
|
|
mutex_lock(&parent->mutex);
|
2024-06-17 08:41:03 -07:00
|
|
|
component_unbind_all(hda_codec_dev(cdc), parent);
|
2024-06-17 08:41:05 -07:00
|
|
|
mutex_unlock(&parent->mutex);
|
2024-01-24 04:26:07 -07:00
|
|
|
}
|
2024-03-07 04:12:15 -07:00
|
|
|
|
|
|
|
#endif /* ifndef __HDA_COMPONENT_H__ */
|