# Patch Apple HDA

## Tải file

B1: Tải xcode

B2: Tải trình edit file `xml`

> Một số app khuyến khích
>
> * [Propertree](https://github.com/corpnewt/ProperTree)
> * [Plist Edit Pro](https://www.fshare.vn/file/B7S51H1DGZDL?token=1691513785)

B3: Tải [Pin Configurator](https://github.com/benbaker76/PinConfigurator/releases)

B4: Tải [graphviz.pkg](https://www.mediafire.com/file/x6gkjnwoyddyn4v/graphviz-2.32.0.pkg/file) và cài đặt [python2](https://www.python.org/downloads/release/python-2718/)

{% hint style="info" %}
Nếu như file cài đặt đã cũ và bạn không thể cài đặt thì hãy nhập các lệnh sau
{% endhint %}

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew install graphviz

#Copy từng dòng 1 vào terminal không copy cùng lúc
```

B5: Tải [codecgraph](https://www.mediafire.com/file/zz7jm3pjo9on3do/codecgraph.zip/file)

> Sau kkhi giải nén thì hãy xoá những file sau&#x20;
>
> ![](/files/NVtnaRZT5qRZIGKSfQPg)

B6: Git Clone các file sau về và để ở desktop

> * <https://github.com/acidanthera/Lilu>
> * <https://github.com/acidanthera/AppleALC>
> * <https://github.com/acidanthera/MacKernelSDK>

B7: Tải các file layout và platform.

> * [Realtek layout](https://www.mediafire.com/file/gj53lm8f1twslpr/layout11.xml_.zip/file)
> * [Conexant, IDTConexant và IDT layout](https://www.mediafire.com/file/7n1ukc4vicojlw0/layout26.xml_.zip/file)
> * [Platform no linein](https://www.mediafire.com/file/7dcf93uojlvs3qi/Platforms.xml_.zip/file)
> * [Platform with linein](https://www.mediafire.com/file/awhk8q8pckqr2zc/Platformsxx.xml/file)

B8: Tải ISO của  linux&#x20;

> Một số distro khuyến khích
>
> * [Ubuntu](https://ubuntu.com/)
> * [Pop OS](https://pop.system76.com/)
> * [Kali linux ](https://www.kali.org/)

{% hint style="warning" %}
Toàn bộ những file cần tải ở trên để đảm bảo an toàn mình đều sẽ backup lại [ở đây](https://drive.heavietnam.com/d/s/zL9Db596keMwzTkE417y6TR6BedBqH77/lgbHIWxrK2Y8cgyd80iVWPhd2xNCs5US-NLLAxUQahgs)

> Các bạn có thể truy cập để tải về nếu những link bị hỏng hoặc tải những link trên quá lâu thì có thể tải cả folder này về
> {% endhint %}

{% hint style="danger" %}
Chú ý:

Trên MacOS Monterey apple đã loại bỏ `python2` ra khỏi `/usr/bin` do đó khi chạy script bạn sẽ gặp lỗi như sau\
![](/files/DbbH9GUVjAnpuNUZu2Xz)

Các khắc phục là sửa đổi file `codecgraph.py`<br>
{% endhint %}

<details>

<summary>Các sửa file <code>codecgraph.py</code></summary>

Chỉ áp dụng khi gặp lỗi&#x20;

B1: Mở file `codecgraph.py` bằng xcode hay bất kì một trình edit text nào bạn biết

B2: Tìm đến dòng đầu tiên `#!/usr/bin/python` sửa đổi lại thành `#!/usr/local/bin/python`&#x20;

Nếu lỗi thì đổi thành `#!/usr/local/bin/python2`

Before:

&#x20;![](/files/Hqk3KLnc581YHP4tgEia)

After:

![](/files/53PJMWAMoLzRJRyynwV2)

B3: Save lại

Như vậy là done rồi

</details>

## Chuẩn bị

B1: Tạo 1 chiếc usb live linux

> Có thể dùng [Rufus](https://rufus.ie/en/) hoặc [ventoy](https://www.ventoy.net/en/download.html)

B2: Boot vào linux live usb và nhập lệnh sau vào terminal&#x20;

```bash
cd ~/Desktop && mkdir CodecDump && for c in /proc/asound/card*/codec#*; do f="${c/\/*card/card}"; cat "$c" > CodecDump/${f//\//-}.txt; done && zip -r CodecDump.zip CodecDump
```

Sau khi chạy file xong tiến hành copy file `codecdump.zip` ở Desktop vào một nơi nào đó rồi reboot lại macos

B3: Giải nén file ra thông thường ta nhận được 2 file&#x20;

> * card0-codec#0.txt
> * card1-codec#0.txt

Ta sẽ mở thử từng file và nhìn vào mục codec giữ file có codec đúng với codec bạn cần patch và xoá file còn lại đi

<figure><img src="/files/XQJt5HlEWCixjOKAn9Tb" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/RqqmXe4NaZyI3kGMAM7V" alt=""><figcaption></figcaption></figure>

B4: Ta sẽ tiếp tục xoá dòng `AFG Function Id: 0x1 (unsol 1)` đi&#x20;

<figure><img src="/files/UUU8GCqwuAsR0Jn3z5hf" alt=""><figcaption></figcaption></figure>

B5: Rename file thành `codec_dump.txt`

> Nếu bạn làm đúng hết tất cả bạn sẽ có 1 folder như sau

<figure><img src="/files/lTR6pHUOiaG3D4KJ9505" alt=""><figcaption></figcaption></figure>

B6: Bạn mở terminal ra rồi kéo file `Scrip Patch Codec by HoangThanh` vào và nhấn enter

{% hint style="info" %}
Hãy nhớ để chạy được file này bạn phải cài đặt `graphviz` nếu không sẽ gặp lỗi như sau

![](/files/nCRnJm2jBFyNrAOryy7q)
{% endhint %}

<figure><img src="/files/QMa3ln3bt0DeZpbfVZVJ" alt=""><figcaption></figcaption></figure>

## Chỉnh sửa **codecverbs**

B1: mở file `finalverbs.txt` lên ta sẽ có như sau

```

Verbs from Linux Codec Dump File: codec_dump.txt

Codec: Realtek ALC283   Address: 0   DevID: 283902595 (0x10ec0283)

   Jack   Color  Description                  Node     PinDefault             Original Verbs
--------------------------------------------------------------------------------------------------------
Digital Unknown  Mic at Int N/A              18 0x12   0x90a601a0   01271ca0 01271d01 01271ea6 01271f90
 Analog Unknown  Speaker at Int N/A          20 0x14   0x90170110   01471c10 01471d01 01471e17 01471f90
    1/4 Unknown  Line Out at Ext N/A         23 0x17   0x40020008   01771c08 01771d00 01771e02 01771f40
    1/8   Black  Speaker at Ext Rear         24 0x18   0x411111f0   01871cf0 01871d11 01871e11 01871f41
    1/8   Black  Speaker at Ext Rear         25 0x19   0x411111f0   01971cf0 01971d11 01971e11 01971f41
    1/8   Black  Speaker at Ext Rear         26 0x1a   0x411111f0   01a71cf0 01a71d11 01a71e11 01a71f41
 Speaker at Ext Rear    0x1b 0x1b                        1091637744 01b71cf0 01b71d11     01b71e11 01b71f41  
Unknown Unknown  Reserved at Ext N/A         29 0x1d   0x40e00001   01d71c01 01d71d00 01d71ee0 01d71f40
    1/8   Black  Speaker at Ext Rear         30 0x1e   0x411111f0   01e71cf0 01e71d11 01e71e11 01e71f41
    1/8   Black  HP Out at Ext Left          33 0x21   0x0321101f   02171c1f 02171d10 02171e21 02171f03
--------------------------------------------------------------------------------------------------------


   Jack   Color  Description                  Node     PinDefault             Modified Verbs
--------------------------------------------------------------------------------------------------------
Digital Unknown  Mic at Int N/A              18 0x12   0x90a601a0   01271ca0 01271d00 01271ea6 01271f90
 Analog Unknown  Speaker at Int N/A          20 0x14   0x90170110   01471c10 01471d00 01471e17 01471f90
    1/4 Unknown  Line Out at Ext N/A         23 0x17   0x40020008   01771c20 01771d00 01771e02 01771f40
Unknown Unknown  Reserved at Ext N/A         29 0x1d   0x40e00001   01d71c30 01d71d00 01d71ee0 01d71f40
    1/8   Black  HP Out at Ext Left          33 0x21   0x0321101f   02171c40 02171d10 02171e21 02171f00
--------------------------------------------------------------------------------------------------------
```

B2: Hãy chú ý vào mục `Modified Verbs` và copy chúng thành 1 file&#x20;

```
01271ca0 01271d00 01271ea6 01271f90 01471c10 01471d00 01471e17 01471f90 01771c20 01771d00 01771e02 01771f40 01d71c30 01d71d00 01d71ee0 01d71f40 02171c40 02171d10 02171e21 02171f00
```

B3: Copy toàn bộ file vừa tạo vào clipboard sau đó mở tool Pin Configurator&#x20;

B4: Chọn `import --> clipboard`

<figure><img src="/files/cyHqHs0W70CSuHhazbb0" alt=""><figcaption></figcaption></figure>

Nếu như bạn làm đúng các bước thì ta sẽ có như sau

<figure><img src="/files/yALoTGL2RodlffRwWw60" alt=""><figcaption></figcaption></figure>

B5: Ở đây ta thấy có rất nhiều cột nhưng bạn chỉ cần chú ý vào các cột sau

* Nid: nó chỉnh là dạng decimal của các node&#x20;
* Device: Thiết bị âm thanh
* Connector: Cổng kết nối của thiết bị
* Port: Thông tin jack cắm
* Gross Location: thông tin port internal hay external
* Geometric Location: Chỉ vị trị của port
* Color: Màu của cổng âm thanh
* MISC: Thông tin kênh xuất ra để mặc định
* EAPD: Kích hoạt tính năng switch giữa speaker và headphones

> Cái này cho các bạn biết thêm thôi không cần quá để tâm vì nó đều có ghi ở file codec\_dump.txt

{% hint style="info" %}
Tiếp theo chúng ta sẽ tiến hành chỉnh các Nid

> `finalverbs.txt` là một file đã được script patch từ file codec dump của các bạn. Nên nó sẽ chuẩn đối với hầu hết laptop và phải chỉnh lại rất ít
> {% endhint %}

{% hint style="info" %}
Được rồi bây giờ ta sẽ tiến hành patch nid đầu tiên là 20
{% endhint %}

Đầu tiên hãy click vào nid 20 ta sẽ được như sau

<figure><img src="/files/ksczpeKIRgR6VzPEJqsQ" alt=""><figcaption></figcaption></figure>

> Bây giờ bạn sẽ tiến hành search node id dạng hex ở đây là 0x14 ở file codec\_dump.txt

```
Node 0x14 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Speaker Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x00010014: OUT EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x90170110: [Fixed] Speaker at Int N/A
    Conn = Analog, Color = Unknown
    DefAssociation = 0x1, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 1
     0x0c
```

Ta cần chú ý vào dòng

```
  Pin Default 0x90170110: [Fixed] Speaker at Int N/A
  Conn = Analog, Color = Unknown
  EAPD 0x2: EAPD
  Pin-ctls: 0x40: OUT
```

Ở đây ta sẽ phân tích được là&#x20;

* Device: Speaker
* Connector: Analog
* Color: Unknown
* EAPD: EAPD
* Port: Fixed
* Gross Location: Int
* Geometric Location: N/A

Và đây là những gì hiển thị trong app sau khi đã chỉnh

<figure><img src="/files/FKueSpysT2WgYdkDw4FX" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Tiếp theo ta sẽ chỉnh tiếp tới nid 23&#x20;
{% endhint %}

```
Node 0x17 [Pin Complex] wcaps 0x40050c: Mono Amp-Out
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80]
  Pincap 0x00000010: OUT
  Pin Default 0x40020008: [N/A] Line Out at Ext N/A
    Conn = 1/4, Color = Unknown
    DefAssociation = 0x0, Sequence = 0x8
  Pin-ctls: 0x00: OUT
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 1
     0x0f
```

Tương tự ở trên thì mọi thông tin cần thiết của ta đều có ở đây

```
  Pin Default 0x40020008: [N/A] Line Out at Ext N/A
    Conn = 1/4, Color = Unknown
    Pin-ctls: 0x00: OUT
```

Ở đây ta cũng sẽ có tương tự như trên

* Device: Line Out&#x20;
* Connector: 1/4&#x20;
* Color: Unknown&#x20;
* EAPD: NO&#x20;
* Port: N/A&#x20;
* Gross Location: Ext&#x20;
* Geometric Location: N/A

<figure><img src="/files/0bfwAffI1OwMjjjyw0cm" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Tiếp theo ta hãy đến với nid 29 nào&#x20;
{% endhint %}

```
Node 0x1d [Pin Complex] wcaps 0x400400: Mono
  Pincap 0x00000020: IN
  Pin Default 0x40e00001: [N/A] Reserved at Ext N/A
    Conn = Unknown, Color = Unknown
    DefAssociation = 0x0, Sequence = 0x1
  Pin-ctls: 0x20: IN
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
```

Tương tự như các phần trước ta cũng sẽ có cần phần hiển thị thông tin&#x20;

```
 Pin Default 0x40e00001: [N/A] Reserved at Ext N/A
    Conn = Unknown, Color = Unknown
```

<figure><img src="/files/RimsqXFk5tz7294oLv5H" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Ta sẽ chỉnh tiếp nid 33
{% endhint %}

```
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
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80 0x80]
  Pincap 0x0001001c: OUT HP EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x0321101f: [Jack] HP Out at Ext Left
    Conn = 1/8, Color = Black
    DefAssociation = 0x1, Sequence = 0xf
  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*
```

Tương tự như các phần trên ta cũng sẽ có các mục hiển thị thông tin

```
Pin Default 0x0321101f: [Jack] HP Out at Ext Left
    Conn = 1/8, Color = Black
 Pin-ctls: 0xc0: OUT HP
```

* Device: HP Out
* Connector: 1/8
* Color: Black&#x20;
* EAPD: NO&#x20;
* Port: Jack
* Gross Location: Ext&#x20;
* Geometric Location: Left

<figure><img src="/files/8HEwRxdpVPg0u3wbeE6z" alt=""><figcaption></figcaption></figure>

> Nếu như bạn đã đến được đây thì bạn hãy cố gắng lên nhé chúng ta sắp hoàn thành patch codec verbs rồi

{% hint style="info" %}
Rồi bây giờ chúng ta hãy tiếp tục chỉnh nid 18
{% endhint %}

```
Node 0x12 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x2f, mute=0
  Amp-In vals:  [0x03 0x03]
  Pincap 0x00000020: IN
  Pin Default 0x90a601a0: [Fixed] Mic at Int N/A
    Conn = Digital, Color = Unknown
    DefAssociation = 0xa, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x20: IN
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
```

Tiếp theo ta cũng hãy phân tích dựa trên dữ liệu trên sẽ có là&#x20;

```
  Pin Default 0x90a601a0: [Fixed] Mic at Int N/A
     Conn = Digital, Color = Unknown
  Pin-ctls: 0x20: IN
```

* Device: Mic
* Connector: Digital
* Color: Unknown&#x20;
* EAPD: NO&#x20;
* Port: Fixed
* Gross Location: Int&#x20;
* Geometric Location: N/A

<figure><img src="/files/UEMFbDZAwozXQp1fBTNj" alt=""><figcaption></figcaption></figure>

Và sau những quá trình phía trên ta có được như sau

<figure><img src="/files/j1QUZM4YO92JM38QfaX5" alt=""><figcaption></figcaption></figure>

B6: Ấn `Get ConfigData` và copy chuỗi ký tự vừa được dump ra một file nào đó&#x20;

<figure><img src="/files/sEvQhJZUx6o0EC6TXR1I" alt=""><figcaption></figcaption></figure>

> Và đây là thành quả của chúng ta

```
<01471C10 01471D00 01471E17 01471F90 01470C02 01771C20 01771D00 01771E02 01771F40 01D71C30 01D71D00 01D71EE0 01D71F40 02171C40 02171D10 02171E21 02171F03 01271CA0 01271D00 01271EA6 01271F90>
```

## Xác định pathmap

B1: Ta sẽ mở file `codec_dump_dec.txt.svg`

<figure><img src="/files/mf5jxlw53Tyi4twtMHtl" alt=""><figcaption></figcaption></figure>

> Nhìn có giống cái mạng nhện không nào :joy: Nhưng đừng lo nó rất đơn giản việc của bạn chỉ là đọc thật kỹ mà thôi

{% hint style="info" %}
Trước hết chúng ta hãy cùng nhau tìm hiểu các ký hiệu này nhé
{% endhint %}

<figure><img src="/files/GGk89BglYaX6tILgt9pV" alt=""><figcaption></figcaption></figure>

Và để cho các bạn đỡ bỡ ngỡ thì đây là hình ảnh path map của các loại codec Conexant và IDT

<figure><img src="/files/lloridoQXFtL9QZRS6TP" alt=""><figcaption></figcaption></figure>

Còn đây là path map của Realtek cũng như là của mình

<figure><img src="/files/AUaIh2vv36Qa3l1xeguD" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
Hãy nhớ rằng cái `Pin Complex` nào mà có ký tự `[N/A]` thì trực tiếp bỏ qua nó và chuyển sang các `Pin Complex` khác
{% endhint %}

### Output

Đây là quy tắc đọc của Output&#x20;

<figure><img src="/files/pljTwNlhwHoildJgtRuW" alt=""><figcaption></figcaption></figure>

Tuân theo quy tắc này chúng ta sẽ có thể xác định được như sau

<figure><img src="/files/HXAr5DVMhAurCFztBXVF" alt=""><figcaption></figcaption></figure>

Ta sẽ có Path Map như sau:

* Speaker: 20 -> 12 -> 2
* Hp Out: 33 -> 13 -> 3

### Input

Quy tắc xác định pathmap input

<figure><img src="/files/wAP3UU6BvW2clN5SMUx1" alt=""><figcaption></figcaption></figure>

Tuân theo quy tắc này chúng ta sẽ có như sau

<figure><img src="/files/J2W8CwRuhJzD9wL0laGy" alt=""><figcaption></figcaption></figure>

Ta sẽ có Path Map như sau:

* Mic In: 17 -> 18

Như vậy là ta đã xác định được hết các path map

## Patch Platforms.xml và layoutxx.xml

### layoutxx.xml

B1: Mở file layoutxx.xml bằng trình edit xml&#x20;

> Như ở đây mình sẽ sử dụng propertree

<figure><img src="/files/nPjUVPUiup3CcHmcIdjM" alt=""><figcaption></figcaption></figure>

B2: Ta sẽ tiến hành chỉ như sau:

* LayoutID: bạn thay đổi hoặc giữ nguyên tuỳ thích, đây mình sẽ thay thành 3
* CodecID: bạn cần thay bằng `DevID` ở file `finalverbs.txt`
* Inputs: tuỳ vào codec của bạn có LineIn hay không, nếu không có thì xoá dòng linein đi
* PatchMapID: bạn có thể cho vào đây tên codec bạn patch hoặc bất kì số nào bạn thích

<figure><img src="/files/hWrAgcUURcl3yu0JoI3f" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Kb6nRyud0fstWStE9OIt" alt=""><figcaption></figcaption></figure>

### Platformsxx.xml

B1: Mở file Platformsxx.xml bằng trình edit xml&#x20;

> Như ở đây mình sẽ sử dụng propertree

<figure><img src="/files/EE0bXXvhF6ARTWd59jNy" alt=""><figcaption></figcaption></figure>

B2: Ta sẽ tiến hành chỉ như sau:

* PathMaps -> 0 -> PathMap -> 0 -> 0 là Mic
* PathMaps -> 0 -> PathMap -> 0 -> 1 là LineIn
  * Nếu như đã xoá linein ở file layoutxx.xml thì cũng sẽ xoá dòng linein ở đây&#x20;
* PathMaps -> 0 -> PathMap -> 1 -> 0 là HP
* PathMaps -> 0 -> PathMap -> 1 -> 1 là Speaker
* PathMaps -> 0 -> PathMap -> PathMapID: ở đây bạn cần điền số giống với PathMapID ở layout#.xml.

Sau khi chỉnh sửa ta sẽ được:

<figure><img src="/files/LehpHexbG3tylM1P61Lb" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
Nếu trường hợp không có Audio Mixer/Selector thì bạn xoá đi key 1, chỉ điền vào key 0 và key 2 thôi nhé!
{% endhint %}

## Binary Patch

{% hint style="info" %}
Hãy chắc rằng bạn đã git clone các repo ở phần [tải file](#tai-file)&#x20;

> Nhớ là git clone không phải download zip
> {% endhint %}

B1: Các bạn copy folder `MacKernelSDK` vào folder `Lilu`

<figure><img src="/files/cgu0WwapjGHHCJ4Ol9WI" alt=""><figcaption></figcaption></figure>

B2: Mở file `Lilu.xcodeproj` bằng xcode

B3: Build kext Lilu như hình

<figure><img src="/files/WiX8cW7CeBQsHleb53y4" alt=""><figcaption></figcaption></figure>

B4: Sau khi build thành công bạn sẽ có như ảnh

<figure><img src="/files/tlNO7TJsn6l40F1YWjyH" alt=""><figcaption></figcaption></figure>

B5: Chuột phải vào file lilu chọn `Show in finder`

<figure><img src="/files/rSLn2VI9Gi6Nt2wquODK" alt=""><figcaption></figcaption></figure>

B6: Cho kext `lilu`  vừa build  và folder `MacKernelSDK` vào folder `Apple ALC`

<figure><img src="/files/T22zUjQCWCxsIpk5BKMJ" alt=""><figcaption></figcaption></figure>

B7: Vào folder `Resources` xoá hết các codec thừa đi chừa lại codec đang patch mà thôi như của mình là `ALC 283`

<figure><img src="/files/UeaxUPw7NTJNnEQFGNXG" alt=""><figcaption></figcaption></figure>

B8: Vào folder codec và xoá đi tất cả chi chừa lại file `info.plist` sau đó copy hay file layoutxx.xml và Platforms.xxxml

<figure><img src="/files/Q1LYhYYNIS0JxfhDb2Nj" alt=""><figcaption></figcaption></figure>

B9: Rename 2 file layoutxx và platformsxx thành layout và platforms với layout id mà bạn đã chọn ở trên như của mình là&#x20;

* layout3.xml
* platforms3.xml

B10: Mở file `AppleALC.xcodeproj` bằng xcode

B11: Mở `AppleALC.xcodeproj -> PinConfigs -> Info.plist -> IOKitPersonalities -> as.vit9696.AppleALC-> HDAConfigDefault`

> Bạn có thể tự tạo hoặc edit 1 cái có sẵn

<figure><img src="/files/eDYmjgWg9BH5p6Ba4IFQ" alt=""><figcaption></figcaption></figure>

Các bạn cần chỉnh 1 số thứ sau:

* Codec/Comment: thay đổi tuỳ thích
* CodecID: thay bằng DevID của codec ở file `finalverbs.txt`
* ConfigData: bạn copy codec verb đã chuẩn bị đưa vào đây
* LayoutID: nhập layout-id bạn đã chọn để patch ở trên

<figure><img src="/files/eAOaFAlSzyNsG7ExJRc5" alt=""><figcaption></figcaption></figure>

B12: Mở `AppleALC.xcodeproj -> Resources -> (tên codec bạn đang patch) -> Info.plist -> Information Property List -> Files`

<figure><img src="/files/z9WVISkEKgbafPctWQ2y" alt=""><figcaption></figcaption></figure>

B13: Xoá các dòng bên dưới 2 dòng

* Layouts
* Platforms

Sao cho chỉ chừa 1 item bên dưới 2 dòng này

<figure><img src="/files/nDBoVM9hfIdbJ1FpCyaI" alt=""><figcaption></figcaption></figure>

Ta cần chỉnh một số thứ như sau

* Comment: Điền tuỳ thích
* Id: Điền layout-id của bạn đã chọn ở trên như của mình là 3
* Path: Điền tên của 2 file layout và platforms của bạn như của mình là&#x20;
  * layout3.xml.zlib
  * Platforms3.xml.zlib

<figure><img src="/files/87IVrlSqmmOmxw7pknfP" alt=""><figcaption></figcaption></figure>

B14: Ấn `Command + S`

B15: Ấn `Build`

<figure><img src="/files/tA9BEQ3hI0bEaUpoVNZk" alt=""><figcaption></figcaption></figure>

B16: Nếu như bạn làm đùng tất cả thì sẽ có được như hình

<figure><img src="/files/zQA4raG31U5BfXysMjGe" alt=""><figcaption></figcaption></figure>

> Và như vậy là đã patch xong rồi

## Cài đặt&#x20;

B1: Chuột phải vào kext apple ALC chọn `show in Finder`

<figure><img src="/files/KD268fC6DrNM7gMTrCna" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bJU9nrcSl6NThEUgtosD" alt=""><figcaption></figcaption></figure>

B2: Thêm kext Apple ALC vào EFI --> OC --> kext và tiến hành snapshot

> Nếu là clover thì copy kext vào EFI --> Clover --> Kext --> Other

B3: Reboot và tận hưởng thôi

{% hint style="warning" %}
Như vậy là xong rồi

> Tuy nhiên một số máy sau khi patch xong lần đầu khởi động có thể sẽ cực kì chậm khuyến khích bạn nên bật verbose và hãy kiên nhẫn&#x20;
> {% endhint %}

{% hint style="info" %}
Source Tham khảo: <https://hackintosh.vn/hackintosh/cai-hackintosh/patch-applehda-cho-cac-laptop-chay-hackintosh> | <http://trungnguyenblogs.blogspot.com/2015/10/huong-dan-patch-applehda-cho-cac-laptop.html> | <https://blog.daliansky.net/Use-AppleALC-sound-card-to-drive-the-correct-posture-of-AppleHDA.html>
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://advance.heavietnam.com/audio/patch-apple-hda.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
