Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 148431
b: refs/heads/master
c: aa2936f
h: refs/heads/master
i:
  148429: 404a741
  148427: 640e0f9
  148423: 9b164c6
  148415: b135325
v: v3
  • Loading branch information
Takashi Iwai committed May 26, 2009
1 parent ffcfbf2 commit 5e2c9e3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 53 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8174086167d43d0fd7b21928074145ae1d15bbab
refs/heads/master: aa2936f5fe060e95ae06685149645b234085a468
113 changes: 61 additions & 52 deletions trunk/sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,38 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,
return val;
}

/*
* Send and receive a verb
*/
static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
unsigned int *res)
{
struct hda_bus *bus = codec->bus;
int err, repeated = 0;

if (res)
*res = -1;
snd_hda_power_up(codec);
mutex_lock(&bus->cmd_mutex);
again:
err = bus->ops.command(bus, cmd);
if (!err) {
if (res) {
*res = bus->ops.get_response(bus);
if (*res == -1 && bus->rirb_error) {
if (repeated++ < 1) {
snd_printd(KERN_WARNING "hda_codec: "
"Trying verb 0x%08x again\n", cmd);
goto again;
}
}
}
}
mutex_unlock(&bus->cmd_mutex);
snd_hda_power_down(codec);
return err;
}

/**
* snd_hda_codec_read - send a command and get the response
* @codec: the HDA codec
Expand All @@ -174,31 +206,18 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
int direct,
unsigned int verb, unsigned int parm)
{
struct hda_bus *bus = codec->bus;
unsigned int cmd, res;
int repeated = 0;

cmd = make_codec_cmd(codec, nid, direct, verb, parm);
snd_hda_power_up(codec);
mutex_lock(&bus->cmd_mutex);
again:
if (!bus->ops.command(bus, cmd)) {
res = bus->ops.get_response(bus);
if (res == -1 && bus->rirb_error) {
if (repeated++ < 1) {
snd_printd(KERN_WARNING "hda_codec: "
"Trying verb 0x%08x again\n", cmd);
goto again;
}
}
} else
res = (unsigned int)-1;
mutex_unlock(&bus->cmd_mutex);
snd_hda_power_down(codec);
unsigned cmd = make_codec_cmd(codec, nid, direct, verb, parm);
unsigned int res;
codec_exec_verb(codec, cmd, &res);
return res;
}
EXPORT_SYMBOL_HDA(snd_hda_codec_read);

/* Define the below to send and receive verbs synchronously.
* If you often get any codec communication errors, this is worth to try.
*/
/* #define SND_HDA_SUPPORT_SYNC_WRITE */

/**
* snd_hda_codec_write - send a single command without waiting for response
* @codec: the HDA codec
Expand All @@ -214,17 +233,13 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_read);
int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
unsigned int verb, unsigned int parm)
{
struct hda_bus *bus = codec->bus;
unsigned int cmd = make_codec_cmd(codec, nid, direct, verb, parm);
#ifdef SND_HDA_SUPPORT_SYNC_WRITE
unsigned int res;
int err;

res = make_codec_cmd(codec, nid, direct, verb, parm);
snd_hda_power_up(codec);
mutex_lock(&bus->cmd_mutex);
err = bus->ops.command(bus, res);
mutex_unlock(&bus->cmd_mutex);
snd_hda_power_down(codec);
return err;
return codec_exec_verb(codec, cmd, &res);
#else
return codec_exec_verb(codec, cmd, NULL);
#endif
}
EXPORT_SYMBOL_HDA(snd_hda_codec_write);

Expand Down Expand Up @@ -2281,28 +2296,22 @@ EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls);
int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
int direct, unsigned int verb, unsigned int parm)
{
struct hda_bus *bus = codec->bus;
unsigned int res;
int err;
int err = snd_hda_codec_write(codec, nid, direct, verb, parm);
struct hda_cache_head *c;
u32 key;

res = make_codec_cmd(codec, nid, direct, verb, parm);
snd_hda_power_up(codec);
mutex_lock(&bus->cmd_mutex);
err = bus->ops.command(bus, res);
if (!err) {
struct hda_cache_head *c;
u32 key;
/* parm may contain the verb stuff for get/set amp */
verb = verb | (parm >> 8);
parm &= 0xff;
key = build_cmd_cache_key(nid, verb);
c = get_alloc_hash(&codec->cmd_cache, key);
if (c)
c->val = parm;
}
mutex_unlock(&bus->cmd_mutex);
snd_hda_power_down(codec);
return err;
if (err < 0)
return err;
/* parm may contain the verb stuff for get/set amp */
verb = verb | (parm >> 8);
parm &= 0xff;
key = build_cmd_cache_key(nid, verb);
mutex_lock(&codec->bus->cmd_mutex);
c = get_alloc_hash(&codec->cmd_cache, key);
if (c)
c->val = parm;
mutex_unlock(&codec->bus->cmd_mutex);
return 0;
}
EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache);

Expand Down

0 comments on commit 5e2c9e3

Please sign in to comment.