黑苹果

修改CodecCommander.kext 实现睡眠后声音耳机和

2018-03-14  本文已影响5128人  Yao_Fairytale

修改CodecCommander.kext 驱动可以解决耳机有杂音和睡眠唤醒无法自动切换或无声的问题.
步骤:
打开CodecCommander.kext/Contents/里面的info.plist,如下图


info.plist

看到Codec Profiles 之后打开折叠,如下图

Codec Profiles

红色方框内是我根据我surface pro 3 ACL288 声卡改好的

第一红色方块内的参数设定 10ec_0288_HDA_10ec_0191

打开原始的16进制的显卡信息图,提取方法见我帖子https://www.jianshu.com/p/f6b8bc6e69ea
我的显卡信息为

Codec: Realtek ALC288
Address: 0
Vendor Id: 0x10ec0288
Subsystem Id: 0x10ec0191
Revision Id: 0x100003

前面10ec_0288指的是 Vendor ID,后面 10ec_0191是Subsystem Id。 这一项我取名为Realtek ALC288 SP3 这个名字自己随便取,只需要保持和第二个红框中的名称保持一致就行。

第二个红框作用就是修正睡眠唤醒和杂音问题,我其实没有感觉什么杂音困扰。

第一个蓝框Unsolicited Response的设定是为了修正睡眠唤醒耳机和外放切换的问题
Command值的 02170882 为Address+NodeID+708+设定值
查看我的声卡信息中 HP Out at Ext 所在的节点,并且找到节点信息中有Unsolicited: tag=xx, enabled=1 这一行。

Node 0x21 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Headphone Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Headphone Jack", index=0, device=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x0000001c: OUT HP Detect
  Pin Default 0x03211020: [Jack] HP Out at Ext Left
    Conn = 1/8, Color = Black
    DefAssociation = 0x2, Sequence = 0x0
  Pin-ctls: 0xc0: OUT HP
  Unsolicited: tag=01, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 2
     0x0c* 0x0d

0x21 SET_UNSOLICITED_ENABLE 0x82中的0x21为NodeID,0x82中的82为设定值
设定值是8bits的一个数。记作a7 a6 a5 a4 a3 a2 a1 a0.
a7=1,表示enabled。
a6=0,没意义
a5-a0,存放tag,需要将tag的值用6为数的二进制值表示
tag=01(十进制)=000001(二进制)
则a7 a6 a5 a4 a3 a2 a1 a0=10000001
a7 a6 a5 a4=1000(二进制)=8(十进制)
a3 a2 a1 a0=0001(二进制)=1(十进制)
则设定值=81
最后加得到的设定值加1,即82

第二个蓝框 SET_PIN_WIDGET_CONTROL设定是为了修正耳机杂音。需要设定的是 Mic at Ext 所在的节点信息,我的节点信息如下:

Node 0x18 [Pin Complex] wcaps 0x40048b: Stereo Amp-In
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Mic Jack", index=0, device=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00003724: IN Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x03a11030: [Jack] Mic at Ext Left
    Conn = 1/8, Color = Black
    DefAssociation = 0x3, Sequence = 0x0
  Pin-ctls: 0x24: IN VREF_80
  Unsolicited: tag=02, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0

Command 值的01870724为Address+NodeID+707+Pin-ctls
0x18 SET_PIN_WIDGET_CONTROL 0x24中的0x18为NodeID,0x24为Pin-ctls值

最后send delay 的值是 推迟发送命令的时间,单位是ms。如果命令发送太早,有可能导致无法执行。
Sleep Nodes 这项无关紧要,也没有什么危害性。

将改好后CodecCommander.kext放入S/L/E,你的黑苹果睡眠唤醒声音切换就完成了。

现在还有更简单直接的hotpatch方式,将下面代码扔进MaciASL里,生成aml文件扔进patched文件夹,config文件添加读取它就好了。

// This SSDT demonstrates a custom configuration for ALC288.
// It is the same data that is currently in the Info.plist

// If you had a codec that needed the same configuration, you could
// load this SSDT in order to implement it without modifying the kext.
// It will override the defaults specfied by the CodecCommander Info.plist

// Customize to suit your needs.

DefinitionBlock ("", "SSDT", 1, "hack", "ALC288", 0)
{
    External(_SB.PCI0.HDEF, DeviceObj)
    Name(_SB.PCI0.HDEF.RMCF, Package()
    {
        "CodecCommander", Package()
        {
            "Custom Commands", Package()
            {
                Package(){}, // signifies Array instead of Dictionary
                Package()
                {
                    // 0x18 SET_PIN_WIDGET_CONTROL 0x24
                    "Command", Buffer() { 0x01, 0x87, 0x07, 0x24 },
                    "On Init", ">y",
                    "On Sleep", ">n",
                    "On Wake", ">y",
                },
                Package()
                {
                    // 0x21 SET_UNSOLICITED_ENABLE 0x82
                    "Command", Buffer() { 0x02, 0x17, 0x08, 0x82 },
                    "On Init", ">y",
                    "On Sleep", ">n",
                    "On Wake", ">y",
                },
            },
            "Perform Reset", ">n",
            "Send Delay", 10,
            "Sleep Nodes", ">n",
        },
    })
}
//EOF

不推荐hotpatch形式,会导致外置mic无法使用,目前不知道原因。

上一篇下一篇

猜你喜欢

热点阅读