Note: To decode HDAudio PinConfig Value

執行結果

PinComplex

這主要是學習 Azalia/HDAudio Verb Table 設定的小產出

畫面上面的值, 是從某個Pin Configuration 得來, 這個Pin Configuraiton 在Verb Table, 實際如下

0x30471C10
0x30471D00
0x30471E56
0x30471F58

這上面格式按 HDAudio spec. 可以得知 0x3 是 CAd(Codec Address), 0x04代表NID(Node ID, Refer Section 7.1.2 Node Addressing, HDAudio v1.0 spec.), 而 0x71C ~ 0x71F(Set Pin Configuration, Refer Section 7.3.3.31 Configuration Default in HDAudio v1.0 spec.)

而該pin configuration value 就是 0x58560010了,  透過該Configuration 的格式去解出該pin 實際的硬體電路狀態, 但這里並沒有將 32bit 格式全部解出, 只解出跟電路構成有關的部份!

Source code 如下

// ExtHDAudioPinComplex.cpp : Defines the entry point for the console application.
//

#include “stdafx.h"

void proceConnectivity(unsigned val)
{
unsigned connectivity = val >> 30;
const TCHAR* sa[] = {
_T(“The PinComplex is connected to a Jack"),
_T(“Not physical connection for Port"),
_T(“A fixed function device(Integrated speack/mic etc.)"),
_T(“Both a jack and an internal device are attached"),
};
_tprintf(_T(“Connectivity: %sn"), sa[connectivity]);
}

void procLocation(unsigned val)
{
unsigned gross = (val >> 28) & 0x3;
unsigned geometric = (val >> 24) & 0xF;
int pi = -1;

if (0 == gross)
{
if(7 == geometric) {
pi = 0;
} else if ( 8 == geometric) {
pi = 1;
}
} else if (1 == gross)
{
if (7 == geometric)    {
pi = 2;
} else if (8 == geometric)    {
pi = 3;
} else if (9 == geometric)    {
pi = 4;
}
} else if (3 == gross)
{
if (7 == geometric)    {
pi = 5;
} else if (8 == geometric)    {
pi = 6;
}
}

const TCHAR* sa0[] = {
_T(“Rear Panel"),
_T(“Drive Bay"),
_T(“Riser"),
_T(“HDMI"),
_T(“ATAPI"),
_T(“Mobile Lid-Inside"),
_T(“Mobile Lid-Outside"),
};

const TCHAR* sa1[] = {
_T(“External"),
_T(“Internal"),
_T(“Separate"),
_T(“Others"),

};

const TCHAR* sa2[] = {
_T(“N/A"),
_T(“Rear"),
_T(“Front"),
_T(“Left"),
_T(“Right"),
_T(“Top"),
_T(“Bottom"),
_T(“Special"),
_T(“Special"),
_T(“Special"),
_T(“Resvered"),
};

if (geometric > 9 ) geometric = 9;
if (-1 != pi)
{
_tprintf(_T(“Location: %sn"), sa0[pi]);
}
else
{
_tprintf(_T(“Location: %s, %sn"), sa1[gross], sa2[geometric]);
}
}

void procDevice(unsigned val)
{
val = (val>>20) & 0xF;
const TCHAR* strArray[] = {
_T(“Line Out"),
_T(“Speak"),
_T(“HP Out"),
_T(“CD"),
_T(“SPDIF Out"),
_T(“Digital Other Out"),
_T(“Modem Line Side"),
_T(“Modem Handset Side"),
_T(“Line In"),
_T(“AUX"),
_T(“Mic In"),
_T(“Telephony"),
_T(“SPDIF In"),
_T(“Digital Other In"),
_T(“Reserved"),
_T(“Other")
};

_tprintf(_T(“Device: %sn"), strArray[val]);
}

void printHelp(void)
{
_tprintf(_T(“Dump HDAudio PinComplexn"));
_tprintf(_T(“ttype ‘DHDPC hex’ n"));
}

int _tmain(int argc, _TCHAR* argv[])
{

unsigned dwPinWidget = 0x411111F0;
if (argc < 2)
{
printHelp();
return -1;
}
_stscanf_l(argv[1], _T(“%X"), 0, &dwPinWidget);

_tprintf(_T(“PinWidget : 0x%08Xn"), dwPinWidget);
proceConnectivity(dwPinWidget);
procLocation(dwPinWidget);
procDevice(dwPinWidget);
return 0;
}

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: