Commit 01ed3c06 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Use regmap for codec parameter reads

Let's start converting the access functions to regmap.
The first one is the simplest, just converting the codec parameter
read helper function snd_hda_param_read().
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 4d75faa0
...@@ -105,12 +105,30 @@ int snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd, ...@@ -105,12 +105,30 @@ int snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd,
unsigned int flags, unsigned int *res); unsigned int flags, unsigned int *res);
int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid, int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid,
unsigned int verb, unsigned int parm, unsigned int *res); unsigned int verb, unsigned int parm, unsigned int *res);
int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm); int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm,
unsigned int *res);
int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid, int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid,
hda_nid_t *conn_list, int max_conns); hda_nid_t *conn_list, int max_conns);
int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid, int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid,
hda_nid_t *start_id); hda_nid_t *start_id);
/**
* snd_hdac_read_parm - read a codec parameter
* @codec: the codec object
* @nid: NID to read a parameter
* @parm: parameter to read
*
* Returns -1 for error. If you need to distinguish the error more
* strictly, use _snd_hdac_read_parm() directly.
*/
static inline int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid,
int parm)
{
unsigned int val;
return _snd_hdac_read_parm(codec, nid, parm, &val) < 0 ? -1 : val;
}
#ifdef CONFIG_PM #ifdef CONFIG_PM
void snd_hdac_power_up(struct hdac_device *codec); void snd_hdac_power_up(struct hdac_device *codec);
void snd_hdac_power_down(struct hdac_device *codec); void snd_hdac_power_down(struct hdac_device *codec);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <sound/hdaudio.h> #include <sound/hdaudio.h>
#include <sound/hda_regmap.h>
#include "local.h" #include "local.h"
static void setup_fg_nodes(struct hdac_device *codec); static void setup_fg_nodes(struct hdac_device *codec);
...@@ -234,23 +235,19 @@ int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid, ...@@ -234,23 +235,19 @@ int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid,
EXPORT_SYMBOL_GPL(snd_hdac_read); EXPORT_SYMBOL_GPL(snd_hdac_read);
/** /**
* snd_hdac_read_parm - read a codec parameter * _snd_hdac_read_parm - read a parmeter
* @codec: the codec object
* @nid: NID to read a parameter
* @parm: parameter to read
* *
* Returns -1 for error. If you need to distinguish the error more * This function returns zero or an error unlike snd_hdac_read_parm().
* strictly, use snd_hdac_read() directly.
*/ */
int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm) int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm,
unsigned int *res)
{ {
int val; unsigned int cmd;
if (snd_hdac_read(codec, nid, AC_VERB_PARAMETERS, parm, &val)) cmd = snd_hdac_regmap_encode_verb(nid, AC_VERB_PARAMETERS) | parm;
return -1; return snd_hdac_regmap_read_raw(codec, cmd, res);
return val;
} }
EXPORT_SYMBOL_GPL(snd_hdac_read_parm); EXPORT_SYMBOL_GPL(_snd_hdac_read_parm);
/** /**
* snd_hdac_get_sub_nodes - get start NID and number of subtree nodes * snd_hdac_get_sub_nodes - get start NID and number of subtree nodes
......
...@@ -369,7 +369,7 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, ...@@ -369,7 +369,7 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,
unsigned int verb, unsigned int parm); unsigned int verb, unsigned int parm);
#define snd_hda_param_read(codec, nid, param) \ #define snd_hda_param_read(codec, nid, param) \
snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param) snd_hdac_read_parm(&(codec)->core, nid, param)
#define snd_hda_get_sub_nodes(codec, nid, start_nid) \ #define snd_hda_get_sub_nodes(codec, nid, start_nid) \
snd_hdac_get_sub_nodes(&(codec)->core, nid, start_nid) snd_hdac_get_sub_nodes(&(codec)->core, nid, start_nid)
int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment