Changeset 9bae8b8 in mainline for uspace/drv/audio/hdaudio/codec.c


Ignore:
Timestamp:
2014-08-26T19:42:40Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2f6b916
Parents:
1e92bc3
Message:

Dump connection lists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/hdaudio/codec.c

    r1e92bc3 r9bae8b8  
    4949{
    5050        uint32_t verb;
     51        uint32_t myresp;
     52
     53        if (resp == NULL)
     54                resp = &myresp;
    5155
    5256        verb = (codec->address << 28) | (node << 20) | (vid << 8) | payload;
    53         return hda_cmd(codec->hda, verb, resp);
     57        int rc = hda_cmd(codec->hda, verb, resp);
     58        if (resp != NULL) {
     59                ddf_msg(LVL_NOTE, "verb 0x%" PRIx32 " -> 0x%" PRIx32, verb,
     60                    *resp);
     61        } else {
     62                ddf_msg(LVL_NOTE, "verb 0x%" PRIx32, verb);
     63        }
     64        return rc;
    5465}
    5566
     
    95106}
    96107
     108static int hda_get_clist_len(hda_codec_t *codec, int node, bool *longform,
     109    int *items)
     110{
     111        int rc;
     112        uint32_t resp;
     113
     114        rc = hda_get_parameter(codec, node, hda_clist_len, &resp);
     115        if (rc != EOK)
     116                return rc;
     117
     118//      ddf_msg(LVL_NOTE, "hda_get_clist_len: resp=0x%x", resp);
     119        *longform = resp & BIT_V(uint32_t, cll_longform);
     120        *items = resp & BIT_RANGE_EXTRACT(uint32_t, cll_len_h, cll_len_l, resp);
     121        return EOK;
     122}
     123
     124static int hda_get_clist_entry(hda_codec_t *codec, int node, int n, uint32_t *resp)
     125{
     126        return hda_ccmd(codec, node, hda_clist_entry_get, n, resp);
     127}
     128
    97129/** Get Suppported PCM Size, Rates */
    98130static int hda_get_supp_rates(hda_codec_t *codec, int node, uint32_t *rates)
     
    144176}
    145177
     178static int hda_get_conn_sel(hda_codec_t *codec, int node, uint32_t *conn)
     179{
     180        return hda_ccmd(codec, node, hda_conn_sel_get, 0, conn);
     181}
     182
    146183/** Get Amplifier Gain / Mute  */
    147184static int hda_get_amp_gain_mute(hda_codec_t *codec, int node, uint16_t payload,
    148185    uint32_t *resp)
    149186{
    150         return hda_ccmd(codec, node, hda_amp_gain_mute_get, payload, resp);
     187//      ddf_msg(LVL_NOTE, "hda_get_amp_gain_mute(codec, %d, %x)",
     188//          node, payload);
     189        int rc = hda_ccmd(codec, node, hda_amp_gain_mute_get, payload, resp);
     190//      ddf_msg(LVL_NOTE, "hda_get_amp_gain_mute(codec, %d, %x, resp=%x)",
     191//          node, payload, *resp);
     192        return rc;
    151193}
    152194
    153195static int hda_set_amp_gain_mute(hda_codec_t *codec, int node, uint16_t payload)
    154196{
     197//      ddf_msg(LVL_NOTE, "hda_set_amp_gain_mute(codec, %d, %x)",
     198//          node, payload);
    155199        return hda_ccmd(codec, node, hda_amp_gain_mute_set, payload, NULL);
    156200}
     
    176220                goto error;
    177221
    178         ddf_msg(LVL_NOTE, "out amp caps 0x%x "
     222        offset = ampcaps & 0x7f;
     223        ddf_msg(LVL_NOTE, "out amp caps 0x%x (offset=0x%x)"
    179224            "gain/mute: L:0x%x R:0x%x",
    180             ampcaps, gmleft, gmright);
    181         offset = ampcaps & 0x7f;
     225            ampcaps, offset, gmleft, gmright);
    182226
    183227        rc = hda_set_amp_gain_mute(codec, aw, 0xb000 + offset);
     
    203247                goto error;
    204248
    205         ddf_msg(LVL_NOTE, "in amp caps 0x%x ", ampcaps);
    206249        offset = ampcaps & 0x7f;
     250        ddf_msg(LVL_NOTE, "in amp caps 0x%x (offset=0x%x)", ampcaps, offset);
    207251
    208252        for (i = 0; i < 15; i++) {
     
    225269        return EOK;
    226270error:
     271        return rc;
     272}
     273
     274static int hda_clist_dump(hda_codec_t *codec, uint8_t aw)
     275{
     276        int rc;
     277        bool longform;
     278        int len;
     279        uint32_t resp;
     280        uint32_t mask;
     281        uint32_t cidx;
     282        int shift;
     283        int epresp;
     284        int i, j;
     285
     286        ddf_msg(LVL_NOTE, "Connections for widget %d:", aw);
     287
     288        rc = hda_get_clist_len(codec, aw, &longform, &len);
     289        if (rc != EOK) {
     290                ddf_msg(LVL_ERROR, "Failed getting connection list length.");
     291                return rc;
     292        }
     293
     294        if (len > 1) {
     295                rc = hda_get_conn_sel(codec, aw, &cidx);
     296                if (rc != EOK) {
     297                        ddf_msg(LVL_ERROR, "Failed getting connection select");
     298                        return rc;
     299                }
     300        } else {
     301                cidx = 0;
     302        }
     303
     304//      ddf_msg(LVL_NOTE, "longform:%d len:%d", longform, len);
     305
     306        if (longform) {
     307                epresp = 2;
     308                mask = 0xffff;
     309                shift = 16;
     310        } else {
     311                epresp = 4;
     312                mask = 0xff;
     313                shift = 8;
     314        }
     315
     316        i = 0;
     317        while (i < len) {
     318                rc = hda_get_clist_entry(codec, aw, i, &resp);
     319                if (rc != EOK) {
     320                        ddf_msg(LVL_ERROR, "Failed getting connection list entry.");
     321                        return rc;
     322                }
     323
     324                for (j = 0; j < epresp && i < len; j++) {
     325                        ddf_msg(LVL_NOTE, "<- %d%s", resp & mask,
     326                            (int)cidx == i ? " *** current *** " : "");
     327                        resp = resp << shift;
     328                        ++i;
     329                }
     330
     331        }
     332
    227333        return rc;
    228334}
     
    281387                            aw, awtype, awcaps);
    282388
     389                        switch (awtype) {
     390                        case awt_audio_input:
     391                        case awt_audio_mixer:
     392                        case awt_audio_selector:
     393                        case awt_pin_complex:
     394                        case awt_power_widget:
     395                                rc = hda_clist_dump(codec, aw);
     396                                if (rc != EOK)
     397                                        goto error;
     398                                break;
     399                        default:
     400                                break;
     401                        }
     402
    283403                        if (awtype == awt_pin_complex) {
    284404                                rc = hda_get_cfg_def(codec, aw, &cfgdef);
     
    293413                        }
    294414
     415if (0) {
    295416                        if ((awcaps & BIT_V(uint32_t, awc_out_amp_present)) != 0)
    296417                                hda_set_out_amp_max(codec, aw);
     
    298419                        if ((awcaps & BIT_V(uint32_t, awc_in_amp_present)) != 0)
    299420                                hda_set_in_amp_max(codec, aw);
     421}
    300422                }
    301423        }
Note: See TracChangeset for help on using the changeset viewer.