aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-26 07:57:47 -0500
committerTakashi Iwai <tiwai@suse.de>2015-03-23 08:19:37 -0400
commit01ed3c06c6d5e7e861650ae76117dd4194d87316 (patch)
treed75e171cd46b58c985848cfc46a3e0d3492c2496
parent4d75faa0448a6bb2fd6d56051a3675a3937cbada (diff)
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: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/hdaudio.h20
-rw-r--r--sound/hda/hdac_device.c21
-rw-r--r--sound/pci/hda/hda_codec.h2
3 files changed, 29 insertions, 14 deletions
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 47e20b741c51..ddfcc44970fa 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -105,12 +105,30 @@ int snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd,
105 unsigned int flags, unsigned int *res); 105 unsigned int flags, unsigned int *res);
106int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid, 106int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid,
107 unsigned int verb, unsigned int parm, unsigned int *res); 107 unsigned int verb, unsigned int parm, unsigned int *res);
108int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm); 108int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm,
109 unsigned int *res);
109int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid, 110int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid,
110 hda_nid_t *conn_list, int max_conns); 111 hda_nid_t *conn_list, int max_conns);
111int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid, 112int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid,
112 hda_nid_t *start_id); 113 hda_nid_t *start_id);
113 114
115/**
116 * snd_hdac_read_parm - read a codec parameter
117 * @codec: the codec object
118 * @nid: NID to read a parameter
119 * @parm: parameter to read
120 *
121 * Returns -1 for error. If you need to distinguish the error more
122 * strictly, use _snd_hdac_read_parm() directly.
123 */
124static inline int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid,
125 int parm)
126{
127 unsigned int val;
128
129 return _snd_hdac_read_parm(codec, nid, parm, &val) < 0 ? -1 : val;
130}
131
114#ifdef CONFIG_PM 132#ifdef CONFIG_PM
115void snd_hdac_power_up(struct hdac_device *codec); 133void snd_hdac_power_up(struct hdac_device *codec);
116void snd_hdac_power_down(struct hdac_device *codec); 134void snd_hdac_power_down(struct hdac_device *codec);
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 6e8ee1d6974a..ba9c1fc6e3ea 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -9,6 +9,7 @@
9#include <linux/export.h> 9#include <linux/export.h>
10#include <linux/pm_runtime.h> 10#include <linux/pm_runtime.h>
11#include <sound/hdaudio.h> 11#include <sound/hdaudio.h>
12#include <sound/hda_regmap.h>
12#include "local.h" 13#include "local.h"
13 14
14static void setup_fg_nodes(struct hdac_device *codec); 15static void setup_fg_nodes(struct hdac_device *codec);
@@ -234,23 +235,19 @@ int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid,
234EXPORT_SYMBOL_GPL(snd_hdac_read); 235EXPORT_SYMBOL_GPL(snd_hdac_read);
235 236
236/** 237/**
237 * snd_hdac_read_parm - read a codec parameter 238 * _snd_hdac_read_parm - read a parmeter
238 * @codec: the codec object
239 * @nid: NID to read a parameter
240 * @parm: parameter to read
241 * 239 *
242 * Returns -1 for error. If you need to distinguish the error more 240 * This function returns zero or an error unlike snd_hdac_read_parm().
243 * strictly, use snd_hdac_read() directly.
244 */ 241 */
245int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm) 242int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm,
243 unsigned int *res)
246{ 244{
247 int val; 245 unsigned int cmd;
248 246
249 if (snd_hdac_read(codec, nid, AC_VERB_PARAMETERS, parm, &val)) 247 cmd = snd_hdac_regmap_encode_verb(nid, AC_VERB_PARAMETERS) | parm;
250 return -1; 248 return snd_hdac_regmap_read_raw(codec, cmd, res);
251 return val;
252} 249}
253EXPORT_SYMBOL_GPL(snd_hdac_read_parm); 250EXPORT_SYMBOL_GPL(_snd_hdac_read_parm);
254 251
255/** 252/**
256 * snd_hdac_get_sub_nodes - get start NID and number of subtree nodes 253 * snd_hdac_get_sub_nodes - get start NID and number of subtree nodes
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 0f5749ca1600..135b70f066f1 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -369,7 +369,7 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
369int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, 369int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,
370 unsigned int verb, unsigned int parm); 370 unsigned int verb, unsigned int parm);
371#define snd_hda_param_read(codec, nid, param) \ 371#define snd_hda_param_read(codec, nid, param) \
372 snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param) 372 snd_hdac_read_parm(&(codec)->core, nid, param)
373#define snd_hda_get_sub_nodes(codec, nid, start_nid) \ 373#define snd_hda_get_sub_nodes(codec, nid, start_nid) \
374 snd_hdac_get_sub_nodes(&(codec)->core, nid, start_nid) 374 snd_hdac_get_sub_nodes(&(codec)->core, nid, start_nid)
375int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, 375int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,