mirror of
https://github.com/torvalds/linux.git
synced 2026-06-02 11:33:28 +02:00
ALSA: hda: Move widget capability macros into hdaudio.h
The get_wcaps() and co are used not only by HD-audio core but also other driver code, hence it'd be better to put into the common header instead of local.h. OTOH, there are macros of the same name like get_wcaps() that are still used in sound/pci/hda/* locally, and those conflict with each other. So we need to rename get_wcaps() (to be moved from hda-core) with the proper snd_hdac prefix for avoiding name conflicts, and define in the common hdaudio.h. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250709160434.1859-2-tiwai@suse.de
This commit is contained in:
parent
bee60f0196
commit
ed677858d4
|
|
@ -680,6 +680,30 @@ static inline void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev,
|
|||
}
|
||||
#endif /* CONFIG_SND_HDA_DSP_LOADER */
|
||||
|
||||
/*
|
||||
* Easy macros for widget capabilities
|
||||
*/
|
||||
#define snd_hdac_get_wcaps(codec, nid) \
|
||||
snd_hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP)
|
||||
|
||||
/* get the widget type from widget capability bits */
|
||||
static inline int snd_hdac_get_wcaps_type(unsigned int wcaps)
|
||||
{
|
||||
if (!wcaps)
|
||||
return -1; /* invalid type */
|
||||
return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
|
||||
}
|
||||
|
||||
/* get the number of supported channels */
|
||||
static inline unsigned int snd_hdac_get_wcaps_channels(u32 wcaps)
|
||||
{
|
||||
unsigned int chans;
|
||||
|
||||
chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
|
||||
chans = (chans + 1) * 2;
|
||||
|
||||
return chans;
|
||||
}
|
||||
|
||||
/*
|
||||
* generic array helpers
|
||||
|
|
|
|||
|
|
@ -436,11 +436,11 @@ EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets);
|
|||
/* return CONNLIST_LEN parameter of the given widget */
|
||||
static unsigned int get_num_conns(struct hdac_device *codec, hda_nid_t nid)
|
||||
{
|
||||
unsigned int wcaps = get_wcaps(codec, nid);
|
||||
unsigned int wcaps = snd_hdac_get_wcaps(codec, nid);
|
||||
unsigned int parm;
|
||||
|
||||
if (!(wcaps & AC_WCAP_CONN_LIST) &&
|
||||
get_wcaps_type(wcaps) != AC_WID_VOL_KNB)
|
||||
snd_hdac_get_wcaps_type(wcaps) != AC_WID_VOL_KNB)
|
||||
return 0;
|
||||
|
||||
parm = snd_hdac_read_parm(codec, nid, AC_PAR_CONNLIST_LEN);
|
||||
|
|
@ -854,7 +854,7 @@ static unsigned int query_pcm_param(struct hdac_device *codec, hda_nid_t nid)
|
|||
unsigned int val = 0;
|
||||
|
||||
if (nid != codec->afg &&
|
||||
(get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD))
|
||||
(snd_hdac_get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD))
|
||||
val = snd_hdac_read_parm(codec, nid, AC_PAR_PCM);
|
||||
if (!val || val == -1)
|
||||
val = snd_hdac_read_parm(codec, codec->afg, AC_PAR_PCM);
|
||||
|
|
@ -894,7 +894,7 @@ int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid,
|
|||
{
|
||||
unsigned int i, val, wcaps;
|
||||
|
||||
wcaps = get_wcaps(codec, nid);
|
||||
wcaps = snd_hdac_get_wcaps(codec, nid);
|
||||
val = query_pcm_param(codec, nid);
|
||||
|
||||
if (ratesp) {
|
||||
|
|
|
|||
|
|
@ -161,13 +161,13 @@ static const struct kobj_type widget_ktype = {
|
|||
static ssize_t caps_show(struct hdac_device *codec, hda_nid_t nid,
|
||||
struct widget_attribute *attr, char *buf)
|
||||
{
|
||||
return sysfs_emit(buf, "0x%08x\n", get_wcaps(codec, nid));
|
||||
return sysfs_emit(buf, "0x%08x\n", snd_hdac_get_wcaps(codec, nid));
|
||||
}
|
||||
|
||||
static ssize_t pin_caps_show(struct hdac_device *codec, hda_nid_t nid,
|
||||
struct widget_attribute *attr, char *buf)
|
||||
{
|
||||
if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
|
||||
if (snd_hdac_get_wcaps_type(snd_hdac_get_wcaps(codec, nid)) != AC_WID_PIN)
|
||||
return 0;
|
||||
return sysfs_emit(buf, "0x%08x\n",
|
||||
snd_hdac_read_parm(codec, nid, AC_PAR_PIN_CAP));
|
||||
|
|
@ -178,7 +178,7 @@ static ssize_t pin_cfg_show(struct hdac_device *codec, hda_nid_t nid,
|
|||
{
|
||||
unsigned int val;
|
||||
|
||||
if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
|
||||
if (snd_hdac_get_wcaps_type(snd_hdac_get_wcaps(codec, nid)) != AC_WID_PIN)
|
||||
return 0;
|
||||
if (snd_hdac_read(codec, nid, AC_VERB_GET_CONFIG_DEFAULT, 0, &val))
|
||||
return 0;
|
||||
|
|
@ -189,7 +189,7 @@ static bool has_pcm_cap(struct hdac_device *codec, hda_nid_t nid)
|
|||
{
|
||||
if (nid == codec->afg || nid == codec->mfg)
|
||||
return true;
|
||||
switch (get_wcaps_type(get_wcaps(codec, nid))) {
|
||||
switch (snd_hdac_get_wcaps_type(snd_hdac_get_wcaps(codec, nid))) {
|
||||
case AC_WID_AUD_OUT:
|
||||
case AC_WID_AUD_IN:
|
||||
return true;
|
||||
|
|
@ -219,7 +219,7 @@ static ssize_t pcm_formats_show(struct hdac_device *codec, hda_nid_t nid,
|
|||
static ssize_t amp_in_caps_show(struct hdac_device *codec, hda_nid_t nid,
|
||||
struct widget_attribute *attr, char *buf)
|
||||
{
|
||||
if (nid != codec->afg && !(get_wcaps(codec, nid) & AC_WCAP_IN_AMP))
|
||||
if (nid != codec->afg && !(snd_hdac_get_wcaps(codec, nid) & AC_WCAP_IN_AMP))
|
||||
return 0;
|
||||
return sysfs_emit(buf, "0x%08x\n",
|
||||
snd_hdac_read_parm(codec, nid, AC_PAR_AMP_IN_CAP));
|
||||
|
|
@ -228,7 +228,7 @@ static ssize_t amp_in_caps_show(struct hdac_device *codec, hda_nid_t nid,
|
|||
static ssize_t amp_out_caps_show(struct hdac_device *codec, hda_nid_t nid,
|
||||
struct widget_attribute *attr, char *buf)
|
||||
{
|
||||
if (nid != codec->afg && !(get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
|
||||
if (nid != codec->afg && !(snd_hdac_get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
|
||||
return 0;
|
||||
return sysfs_emit(buf, "0x%08x\n",
|
||||
snd_hdac_read_parm(codec, nid, AC_PAR_AMP_OUT_CAP));
|
||||
|
|
@ -237,7 +237,7 @@ static ssize_t amp_out_caps_show(struct hdac_device *codec, hda_nid_t nid,
|
|||
static ssize_t power_caps_show(struct hdac_device *codec, hda_nid_t nid,
|
||||
struct widget_attribute *attr, char *buf)
|
||||
{
|
||||
if (nid != codec->afg && !(get_wcaps(codec, nid) & AC_WCAP_POWER))
|
||||
if (nid != codec->afg && !(snd_hdac_get_wcaps(codec, nid) & AC_WCAP_POWER))
|
||||
return 0;
|
||||
return sysfs_emit(buf, "0x%08x\n",
|
||||
snd_hdac_read_parm(codec, nid, AC_PAR_POWER_STATE));
|
||||
|
|
|
|||
|
|
@ -6,27 +6,6 @@
|
|||
#ifndef __HDAC_LOCAL_H
|
||||
#define __HDAC_LOCAL_H
|
||||
|
||||
#define get_wcaps(codec, nid) \
|
||||
snd_hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP)
|
||||
|
||||
/* get the widget type from widget capability bits */
|
||||
static inline int get_wcaps_type(unsigned int wcaps)
|
||||
{
|
||||
if (!wcaps)
|
||||
return -1; /* invalid type */
|
||||
return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
|
||||
}
|
||||
|
||||
static inline unsigned int get_wcaps_channels(u32 wcaps)
|
||||
{
|
||||
unsigned int chans;
|
||||
|
||||
chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
|
||||
chans = (chans + 1) * 2;
|
||||
|
||||
return chans;
|
||||
}
|
||||
|
||||
extern const struct attribute_group *hdac_dev_attr_groups[];
|
||||
int hda_widget_sysfs_init(struct hdac_device *codec);
|
||||
int hda_widget_sysfs_reinit(struct hdac_device *codec, hda_nid_t start_nid,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include <sound/hda_i915.h>
|
||||
#include <sound/pcm_drm_eld.h>
|
||||
#include <sound/hda_chmap.h>
|
||||
#include "../../hda/local.h"
|
||||
#include "hdac_hdmi.h"
|
||||
|
||||
#define NAME_SIZE 32
|
||||
|
|
@ -221,8 +220,8 @@ static int hdac_hdmi_get_port_len(struct hdac_device *hdev, hda_nid_t nid)
|
|||
unsigned int caps;
|
||||
unsigned int type, param;
|
||||
|
||||
caps = get_wcaps(hdev, nid);
|
||||
type = get_wcaps_type(caps);
|
||||
caps = snd_hdac_get_wcaps(hdev, nid);
|
||||
type = snd_hdac_get_wcaps_type(caps);
|
||||
|
||||
if (!(caps & AC_WCAP_DIGITAL) || (type != AC_WID_PIN))
|
||||
return 0;
|
||||
|
|
@ -492,10 +491,10 @@ static int hdac_hdmi_query_port_connlist(struct hdac_device *hdev,
|
|||
struct hdac_hdmi_pin *pin,
|
||||
struct hdac_hdmi_port *port)
|
||||
{
|
||||
if (!(get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) {
|
||||
if (!(snd_hdac_get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) {
|
||||
dev_warn(&hdev->dev,
|
||||
"HDMI: pin %d wcaps %#x does not support connection list\n",
|
||||
pin->nid, get_wcaps(hdev, pin->nid));
|
||||
pin->nid, snd_hdac_get_wcaps(hdev, pin->nid));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -660,8 +659,8 @@ hdac_hdmi_query_cvt_params(struct hdac_device *hdev, struct hdac_hdmi_cvt *cvt)
|
|||
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
|
||||
int err;
|
||||
|
||||
chans = get_wcaps(hdev, cvt->nid);
|
||||
chans = get_wcaps_channels(chans);
|
||||
chans = snd_hdac_get_wcaps(hdev, cvt->nid);
|
||||
chans = snd_hdac_get_wcaps_channels(chans);
|
||||
|
||||
cvt->params.channels_min = 2;
|
||||
|
||||
|
|
@ -743,7 +742,7 @@ static void hdac_hdmi_set_power_state(struct hdac_device *hdev,
|
|||
int count;
|
||||
unsigned int state;
|
||||
|
||||
if (get_wcaps(hdev, nid) & AC_WCAP_POWER) {
|
||||
if (snd_hdac_get_wcaps(hdev, nid) & AC_WCAP_POWER) {
|
||||
if (!snd_hdac_check_power_state(hdev, nid, pwr_state)) {
|
||||
for (count = 0; count < 10; count++) {
|
||||
snd_hdac_codec_read(hdev, nid, 0,
|
||||
|
|
@ -761,7 +760,7 @@ static void hdac_hdmi_set_power_state(struct hdac_device *hdev,
|
|||
static void hdac_hdmi_set_amp(struct hdac_device *hdev,
|
||||
hda_nid_t nid, int val)
|
||||
{
|
||||
if (get_wcaps(hdev, nid) & AC_WCAP_OUT_AMP)
|
||||
if (snd_hdac_get_wcaps(hdev, nid) & AC_WCAP_OUT_AMP)
|
||||
snd_hdac_codec_write(hdev, nid, 0,
|
||||
AC_VERB_SET_AMP_GAIN_MUTE, val);
|
||||
}
|
||||
|
|
@ -1648,8 +1647,8 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_device *hdev,
|
|||
unsigned int caps;
|
||||
unsigned int type;
|
||||
|
||||
caps = get_wcaps(hdev, nid);
|
||||
type = get_wcaps_type(caps);
|
||||
caps = snd_hdac_get_wcaps(hdev, nid);
|
||||
type = snd_hdac_get_wcaps_type(caps);
|
||||
|
||||
if (!(caps & AC_WCAP_DIGITAL))
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user