From 4f7e0248ba8066bdc7885596b485327b2b1812f8 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Thu, 3 Aug 2017 01:54:53 +0300 Subject: [PATCH] Version 1.0.2 sync --- Changelog.md | 8 ++ Manual/FAQ.en.md | 11 +- Manual/FAQ.ru.md | 11 +- Manual/Sample.dsl | 97 +++++++++----- Manual/reference.cpp | 251 +++++++++++++++++++++++++++++++++++ README.md | 5 +- WhateverGreen/kern_model.cpp | 4 +- 7 files changed, 343 insertions(+), 44 deletions(-) create mode 100644 Manual/reference.cpp diff --git a/Changelog.md b/Changelog.md index 575e220b..5afc4497 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,14 @@ WhateverGreen Changelog ======================= +#### v1.0.2 +- Added more GPU models to automatic detection +- Added basic automatic HDMI audio correction +- Fixed WhateverName os version requirements +- Disabled connector ordering by default (use `connector-priority` if needed) +- Changed `connector-priority` default type importance +- Added version info for easier debugging + #### v1.0.1 - Added more GPU models to automatic detection - Disabled DVI transmitter changes by default (use `-raddvi` boot-arg) diff --git a/Manual/FAQ.en.md b/Manual/FAQ.en.md index 63f654b3..cdaf852b 100644 --- a/Manual/FAQ.en.md +++ b/Manual/FAQ.en.md @@ -23,10 +23,11 @@ You could follow [this guide](https://www.techpowerup.com/forums/threads/amd-ati Named framebuffers (Baladi, Futomaki, Lotus, etc.), enabled by "Clover GPU injection" or any other methods should _never ever be used_. This way of GPU injection is a common mistake, preventing automatic configuration of various important GPU parameters. This will inavoidably lead to borked GPU functioning in quite a number of cases. - _When should I use custom connectors?_ -In extremely rare cases VBIOS could (e.g. 290, 290X, 370 GPUs) be incompatible with automatic controller detection written in Apple kexts. WhateverGreen incorporates automatic connector correction for such cases. However, if you discovered that the automatically generated connectors are still wrong (you could find them in debug log), you may specify them as a GPU device property called `connects`, for example, via SSDT. You could pass your connectors in either 24-byte or 16-byte format, they will be automatically adapted to the running system. If you need to provide more or less connectors than it is detected automatically, you are to specify `connector-count` property as well. +In extremely rare cases VBIOS could (e.g. 290, 290X, 370 GPUs) be incompatible with automatic controller detection written in Apple kexts. WhateverGreen incorporates automatic connector correction that can be enabled via `-raddvi` boot argument. However, if you discovered that the automatically generated connectors are still wrong (you could find them in debug log), you may specify them as a GPU device property called `connects`, for example, via SSDT. You could pass your connectors in either 24-byte or 16-byte format, they will be automatically adapted to the running system. If you need to provide more or less connectors than it is detected automatically, you are to specify `connector-count` property as well. - _How can I change display priority?_ -To do so there is no need to use custom connectors with 7xxx GPUs or newer. Add `connector-priority` GPU controller property with sense ids (could be seen in debug log) in the order of their importance. This property may sometimes help with the multi-monitor configurations. +With 7xxx GPUs or newer you could simply add `connector-priority` GPU controller property with sense ids (could be seen in debug log) in the order of their importance. This property may help with black screen issues especially with the multi-monitor configurations. +Without this property specified all the connectors will stay with 0 priority. If there are unspecified connectors they will be ordered by type: LVDS, DVI, HDMI, DP, VGA. Read [SSDT sample](https://github.com/vit9696/WhateverGreen/blob/master/Manual/Sample.dsl) for more details. - _What properties should I inject for my GPU?_ Very few! You should inject an `HDAU` device to your GPU controller, `hda-gfx` properties with a corresponding number to the amount of audio codecs you have, and that is basically all. If you need to mask to an unsupported GPU, additionally add `device-id`. It is also recommended to add some cosmetic properties: `AAPL,slot-name` (displayed slot name in system details), `@X,AAPL,boot-display` (boot logo drawing issues), `model` (GPU display name, if detection failed). @@ -38,6 +39,9 @@ This argument is as a replacement for the original igork's AMDRadeonX4000 Info.p - _How to change my GPU model?_ The controller kext (e.g. AMD6000Controller) replaces GPU model with a generic name (e.g. AMD Radeon HD 6xxx) if it performs the initialisation on its own. Injecting the properties and disabling this will break connector autodetect, and therefore is quite not recommended. WhateverGreen attempts to automatically detect the GPU model name if it is unspecified. If the autodetected model name is not valid (for example, in case of a fake device-id or a new GPU model) please provide a correct one via `model` property. All the questions about automatic GPU model detection correctness should be addressed to [The PCI ID Repository](http://pci-ids.ucw.cz). In special cases you may submit a [patch](https://github.com/vit9696/WhateverGreen/pulls) for [kern_model.cpp](https://github.com/vit9696/WhateverGreen/blob/master/WhateverGreen/kern_model.cpp). GPU model name is absolutely unimportant for GPU functioning. +- _How should I read EFI driver version?_ +This value is by WhateverGreen for debugging reasons. For example, WEAD-102-2017-08-03 stands for WhateverGreen with automatic frame (i.e. RadeonFramebuffer), debug version 1.0.2 compiled on 03.08.2017. Third letter can also be F for fake frame, and B for invalid data. Fourth letter could be R for release builds. + - _What to do when my GPU does not wake until I start typing on the keyboard?_ If this bothers you, either wait a bit longer or try adding `darkwake=0` boot argument. @@ -57,7 +61,8 @@ Generally hardware video decoding is performed by an IGPU, and thus you are requ Several screens may not support 30-bit video output, but the GPU may not detect this. The result will look as distorted blinking colours. To resolve the issue either buy a more powerful display or add `-rad24` boot argument. - _How do I get HDMI audio to work?_ -In general it should be enough to inject the devices and properties mentioned above. In some cases you may also need to add a supported `device-id` property to HDAU and patch the identifier in AppleHDAController. More details are available in this [SSDT sample](https://github.com/vit9696/WhateverGreen/blob/master/Manual/Sample.dsl). +In general it should be enough to rely on WhateverGreen automatic HDAU correction. It renames the device to HDAU, and injects missing layout-id and hda-gfx (starting with onboard-2) properties. This will not work well with two or more cards of different vendors (e.g. NVIDIA and ATI/AMD), please manually inject the properties in such a case. +For identifiers not present in AppleHDAController and AppleHDA you have to add necessary kext patches, see AppleALC [example for 290X](https://github.com/vit9696/AppleALC/commit/cfb8bef310f31fd330aeb4e10623487a6bceb84d#diff-6246954ac288d4f6dd7eb780c006419d). - _May I access the source code?_ Model detection code is [open](https://github.com/vit9696/WhateverGreen/blob/master/WhateverGreen/kern_model.cpp) as well as [Lilu](https://github.com/vit9696/Lilu). If you want to contribute a feature you have an implementation for please contact me. For example, getting better handling of AMD Switchable Graphics or providing more complete research on connector detection would be nice. diff --git a/Manual/FAQ.ru.md b/Manual/FAQ.ru.md index 023aec1a..09e742eb 100644 --- a/Manual/FAQ.ru.md +++ b/Manual/FAQ.ru.md @@ -23,10 +23,11 @@ UEFI без использования CSM. В случае отсутствия Именной фреймбуфер (Baladi, Futomaki, Lotus и др.), включаемый "инжектом Clover" или любым другим способом, не следует использовать _ни при каких обстоятельствах_. Такой способ запуска видеокарты — распространённое заблуждение, приводящее к отключению автоматического конфигурирования множества важных параметров. В результате с высокой долей вероятности видеокарта будет работать неправильно. - _В каких случаях необходимо использовать собственные коннекторы?_ -В редких случаях видеобиос (например, видеокарты 290, 290X, 370) может быть не совместим с автоматическим детектированием коннекторов, реализованном в кекстах Apple. Для этих случаев в WhateverGreen предусмотрена автоматическая коррекция коннекторов. Тем не менее, если сгенерированные коннекторы не подошли (их можно посмотреть в режиме подробного логирования), то существует возможность указать пользовательские коннекторы в качестве свойства контроллера видеокарты `connectors`, например, через SSDT. Указывать коннекторы можно как в 24-байтном, так и в 16-байтном формате, они будут адаптированы под запущенную систему. Если нужно указать число коннектров больше или меньше, чем определяется автоматически, то необходимо также указать свойство `connector-count`. +В редких случаях видеобиос (например, видеокарты 290, 290X, 370) может быть не совместим с автоматическим детектированием коннекторов, реализованном в кекстах Apple. Для этих случаев в WhateverGreen предусмотрена автоматическая коррекция коннекторов, включаемая с помощью аргумента `-raddvi`. Тем не менее, если сгенерированные коннекторы не подошли (их можно посмотреть в режиме подробного логирования), то существует возможность указать пользовательские коннекторы в качестве свойства контроллера видеокарты `connectors`, например, через SSDT. Указывать коннекторы можно как в 24-байтном, так и в 16-байтном формате, они будут адаптированы под запущенную систему. Если нужно указать число коннектров больше или меньше, чем определяется автоматически, то необходимо также указать свойство `connector-count`. - _Как изменить приоритет мониторов?_ -С видеокартами 7xxx и новее для этого нет необходимости использовать собственные коннекторы. Добавьте свойство контроллера видеокарты `connector-priority`, перечислив sense id (можно посмотреть в режиме подробного логирования) в порядке важности. Данное свойство иногда помогает решить проблемы с мультимониторными конфигурациями. +С видеокартами 7xxx достаточно указания свойства `connector-priority`, перечислив sense id (можно посмотреть в режиме подробного логирования) в порядке важности. Данное свойство иногда помогает решить проблему чёрного экрана в особенности на мультимониторных конфигурациях. +Без данного свойства приоритет всех коннекторов остаётся 0. При наличии оставшихся sense id без приоритета коннекторы сортируются по типам: LVDS, DVI, HDMI, DP, VGA. Подробности указаны в [примере SSDT](https://github.com/vit9696/WhateverGreen/blob/master/Manual/Sample.dsl). - _Какие свойства нужно инжектировать для завода видеокарты?_ Минимум необходимых! Добавлять нужно устройство `HDAU` в контроллер видеокарты, свойства `hda-gfx` с соответствующим номером числу имеющихся кодеков аудио, по сути всё. Если требуется маскировка на поддерживаемую видеокарту, указывать следует только `device-id`. Разумно добавлять некоторые косметические свойства: `AAPL,slot-name` (отображаемое имя слота в свойствах системы), `@X,AAPL,boot-display` (частично исправляет лого при загрузке), `model` (название видеокарты, если автоматика не справилась). @@ -41,6 +42,9 @@ UEFI без использования CSM. В случае отсутствия - _Что делать, если видеокарта для просыпания требует нескольких нажатий на клавиатуре?_ Если это действительно беспокоит, можно подождать чуть дольше или попробовать добавить аргумент загрузки `darkwake=0`. +- _Как читать версию драйвера EFI?_ +Данное значение устанавливается WhateverGreen для отладки. Например, WEAD-102-2017-08-03 означает WhateverGreen с автоматическим фреймом (RadeonFramebuffer), DEBUG версия 1.0.2, скомпилированная 03.08.2017. Третья буква может быть F (для фейкового фрейма) и B (для некоторректных значений). Четвёртая буква может быть R для RELEASE версий. + - _Как понять, что видеокарта инициализируется правильно?_ Один из наиболее простых показателей — время загрузки. При неправильном заводе загрузка происходит на 30 секунд дольше. @@ -57,7 +61,8 @@ UEFI без использования CSM. В случае отсутствия На некоторых мониторах нет поддержки 30-битного цвета, при этом видеокарта об этом может не знать. В результате цвета на экране будут мигать с искажениями. Для решения проблемы необходимо либо приобрести другой дисплей, либо добавить аргумент загрузки `-rad24`. - _Как заставить работать HDMI звук?_ -В большинстве случаев инжектирования вышеуказанных устройств и свойств достаточно. В некоторых случаях нужно также добавлять свойство `device-id` с поддерживаемым идентификатором в HDAU и патч AppleHDAController. Подробности описаны в [примере SSDT](https://github.com/vit9696/WhateverGreen/blob/master/Manual/Sample.dsl). +В большинстве случаев достаточно автоматического исправления HDAU в WhateverGreen, производящего переименование устройства в HDAU, и добавляющего отсутствующие свойства layout-id и hda-gfx (начиная с onboard-2). При использовании двух карт разных производителей (например, AMD/ATI и NVIDIA) свойства необходимо прописывать вручную. +В случае отсутствия совместимых идентификаторов в AppleHDAController и AppleHDA необходимо их добавить с помощью патчей ([пример для 290X](https://github.com/vit9696/AppleALC/commit/cfb8bef310f31fd330aeb4e10623487a6bceb84d#diff-6246954ac288d4f6dd7eb780c006419d) из AppleALC). - _Могу ли я получить исходный код?_ Код автодетектирования модели [открыт](https://github.com/vit9696/WhateverGreen/blob/master/WhateverGreen/kern_model.cpp), как и код [Lilu](https://github.com/vit9696/Lilu). Если есть желание и знание, как добавить некоторый функционал, пишите. Например, неплохо бы добавить нормальную совместимость с AMD Switchable Graphics или более подробно разобрать детектирование коннекторов. diff --git a/Manual/Sample.dsl b/Manual/Sample.dsl index b0d6dea5..30b74485 100644 --- a/Manual/Sample.dsl +++ b/Manual/Sample.dsl @@ -24,45 +24,81 @@ DefinitionBlock ("", "SSDT", 2, "APPLE ", "SSDTAMDGPU", 0x00001000) Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method { Store (Package () + { + // Write the preferred GPU index here (1-4) + "AAPL,slot-name", + Buffer () { - // Write the preferred GPU index here (1-4) + "Slot-1" + }, - "AAPL,slot-name", - Buffer () - { - "Slot-1" - }, + // Write the main main monitor index (currently 0) here, the value does not matter + "@0,AAPL,boot-display", + Buffer (Zero) {} - // Make sure not to write the same onboard index for each installed GPU + /* - "hda-gfx", - Buffer () - { - "onboard-1" - }, + // Only use this if your GPU device identifier is not natively supported in macOS kexts + "device-id", + Buffer (0x04) + { + 0x12, 0x34, 0x00, 0x00 + }, - // Only use this if automatic detection fails or may not be used + // Only use this if automatic detection fails or you are faking your GPU device-id + "model", + Buffer () + { + "AMD Radeon HD 6450" + }, - "model", - Buffer () - { - "AMD Radeon HD 6450" - }, + // Only use this if you are not satisfied with automatic HDMI injection + // Make sure not to write the same onboard index for each installed GPU + "hda-gfx", + Buffer () + { + "onboard-1" + }, + + // Only use this if you need special connectors that are incompatible with the automatic connector detection + "connectors", + Buffer () + { + 0x00, 0x04, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x12, 0x04, 0x04, 0x01, + 0x00, 0x08, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x22, 0x05, 0x01, 0x03, + 0x04, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x10, 0x00, 0x05, 0x06, + 0x04, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x11, 0x02, 0x06, 0x05 + }, - // Monitor at index 0 is used as main, the value does not matter + // You may only specify this with connectors property when the amount of connectors differs from autodetected + "connector-count", + Buffer () + { + 0x04, 0x00, 0x00, 0x00 + }, - "@0,AAPL,boot-display", - Buffer (Zero) {} + // Only use this with automatic connector detection when you need manual priority. + // Each value is a sense id to get a higher priority. + // Automatic ordering is done by type: LVDS, DVI, HDMI, DP, VGA. + // You may leave this empty to order all the connectors by type. + // Assume autodetected connectors: 0x03 DP, 0x02 DVI_D, 0x06 HDMI, 0x05 DVI_D, 0x04 VGA + // With the value pri will become: 0x0005 , 0x0001 , 0x0004 , 0x0003 , 0x0002 + "connector-priority", + Buffer () + { + 0x02, 0x04 + } - // You could also put other properties like "connectors", "connector-priority", - // or "device-id" here in case this is required for your setup. - // If you add or remove connectors do not forget to specify "connector-count". - }, Local0) + */ + }, Local0) DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0)) Return (Local0) } } + /* + + // Only use this if you are not satisfied with automatic HDMI injection Device (HDAU) { Name (_ADR, One) // _ADR: Address @@ -91,18 +127,11 @@ DefinitionBlock ("", "SSDT", 2, "APPLE ", "SSDTAMDGPU", 0x00001000) { "onboard-1" } - - // You may need to put "device-id" here in case this is required for your setup. - // Please be aware that that AppleHDAController reads the device-id directly. - // This means that you may have to patch your device-id in AppleHDAController. - // Assume your original device-id is (R9 290X). - // And the id you are faking to is (Pro 460). - // So here you add device-id . - // And AppleHDAController patch is <02 10 e0 aa> -> <02 10 c8 aa>. - // Thanks to Pawel69 for this. }) } } + + */ } // Below goes an example for IGPU injection useful for enabling hardware video decoding and other stuff. diff --git a/Manual/reference.cpp b/Manual/reference.cpp new file mode 100644 index 00000000..3f9f1f23 --- /dev/null +++ b/Manual/reference.cpp @@ -0,0 +1,251 @@ +// +// reference.c +// WhateverGreen +// Explanation of how RadeonFramebuffer connectors are created +// +// Copyright © 2017 vit9696. All rights reserved. +// +// Reverse-engineered from AMDSupport.kext +// Copyright © 2017 Apple Inc. All rights reserved. +// + +/** + * Connectors from AMDSupport since 10.12 + */ +struct ModernConnector { + uint32_t type; + uint32_t flags; + uint16_t features; + uint16_t priority; + uint32_t reserved1; + uint8_t transmitter; + uint8_t encoder; + uint8_t hotplug; + uint8_t sense; + uint32_t reserved2; +}; + +enum ConnectorType { + ConnectorLVDS = 0x2, + ConnectorDigitalDVI = 0x4, + ConnectorSVID = 0x8, + ConnectorVGA = 0x10, + ConnectorDP = 0x400, + ConnectorHDMI = 0x800, + ConnectorAnalogDVI = 0x2000 +}; + +/** + * Internal atom connector struct since 10.13 + */ +struct AtomConnectorInfo { + uint16_t *atomObject; + uint16_t usConnObjectId; + uint16_t usGraphicObjIds; + uint8_t *hpdRecord; + uint8_t *i2cRecord; +}; + +// Definitions taken from asic_reg/ObjectID.h +enum { + /* External Third Party Encoders */ + ENCODER_OBJECT_ID_SI170B = 0x08, + ENCODER_OBJECT_ID_CH7303 = 0x09, + ENCODER_OBJECT_ID_CH7301 = 0x0A, + ENCODER_OBJECT_ID_INTERNAL_DVO1 = 0x0B, /* This belongs to Radeon Class Display Hardware */ + ENCODER_OBJECT_ID_EXTERNAL_SDVOA = 0x0C, + ENCODER_OBJECT_ID_EXTERNAL_SDVOB = 0x0D, + ENCODER_OBJECT_ID_TITFP513 = 0x0E, + ENCODER_OBJECT_ID_INTERNAL_LVTM1 = 0x0F, /* not used for Radeon */ + ENCODER_OBJECT_ID_VT1623 = 0x10, + ENCODER_OBJECT_ID_HDMI_SI1930 = 0x11, + ENCODER_OBJECT_ID_HDMI_INTERNAL = 0x12, + /* Kaleidoscope (KLDSCP) Class Display Hardware (internal) */ + ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1 = 0x13, + ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1 = 0x14, + ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1 = 0x15, + ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2 = 0x16, /* Shared with CV/TV and CRT */ + ENCODER_OBJECT_ID_SI178 = 0X17, /* External TMDS (dual link, no HDCP.) */ + ENCODER_OBJECT_ID_MVPU_FPGA = 0x18, /* MVPU FPGA chip */ + ENCODER_OBJECT_ID_INTERNAL_DDI = 0x19, + ENCODER_OBJECT_ID_VT1625 = 0x1A, + ENCODER_OBJECT_ID_HDMI_SI1932 = 0x1B, + ENCODER_OBJECT_ID_DP_AN9801 = 0x1C, + ENCODER_OBJECT_ID_DP_DP501 = 0x1D, + ENCODER_OBJECT_ID_INTERNAL_UNIPHY = 0x1E, + ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA = 0x1F, + ENCODER_OBJECT_ID_INTERNAL_UNIPHY1 = 0x20, + ENCODER_OBJECT_ID_INTERNAL_UNIPHY2 = 0x21, + ENCODER_OBJECT_ID_ALMOND = 0x22, + ENCODER_OBJECT_ID_NUTMEG = 0x22, + ENCODER_OBJECT_ID_TRAVIS = 0x23, + ENCODER_OBJECT_ID_INTERNAL_VCE = 0x24, + ENCODER_OBJECT_ID_INTERNAL_UNIPHY3 = 0x25, + ENCODER_OBJECT_ID_INTERNAL_AMCLK = 0x27 +}; + +enum { + CONNECTOR_OBJECT_ID_NONE = 0x00, + CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I = 0x01, + CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I = 0x02, + CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D = 0x03, + CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D = 0x04, + CONNECTOR_OBJECT_ID_VGA = 0x05, + CONNECTOR_OBJECT_ID_COMPOSITE = 0x06, + CONNECTOR_OBJECT_ID_SVIDEO = 0x07, + CONNECTOR_OBJECT_ID_YPbPr = 0x08, + CONNECTOR_OBJECT_ID_D_CONNECTOR = 0x09, + CONNECTOR_OBJECT_ID_9PIN_DIN = 0x0A, /* Supports both CV & TV */ + CONNECTOR_OBJECT_ID_SCART = 0x0B, + CONNECTOR_OBJECT_ID_HDMI_TYPE_A = 0x0C, + CONNECTOR_OBJECT_ID_HDMI_TYPE_B = 0x0D, + CONNECTOR_OBJECT_ID_LVDS = 0x0E, + CONNECTOR_OBJECT_ID_7PIN_DIN = 0x0F, + CONNECTOR_OBJECT_ID_PCIE_CONNECTOR = 0x10, + CONNECTOR_OBJECT_ID_CROSSFIRE = 0x11, + CONNECTOR_OBJECT_ID_HARDCODE_DVI = 0x12, + CONNECTOR_OBJECT_ID_DISPLAYPORT = 0x13, + CONNECTOR_OBJECT_ID_eDP = 0x14, + CONNECTOR_OBJECT_ID_MXM = 0x15, + CONNECTOR_OBJECT_ID_LVDS_eDP = 0x16 +}; + +// Initially applecon data is nulled. +IOReturn AtiBiosParser2::translateAtomConnectorInfo(AtiBiosParser2 *parser, AtomConnectorInfo *atomcon, ModernConnector *applecon) { + if (((atomcon->usConnObjectId & OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT) != GRAPH_OBJECT_TYPE_CONNECTOR) + return kIOReturnNotFound; + + uint8_t *i2cRecord = atomcon->i2cRecord; + if (i2cRecord) { + applecon->sense = (i2cRecord[2] & 0xF) + 1; + } else { + applecon->sense = 0; + kprintf("ATOM: %s: ASSERT(NULL != i2cRecord)\n", "uint8_t AtiBiosParser2::getAuxDdcLine(atom_i2c_record *)"); + } + + uint8_t *hpdRecord = (uint8_t *)atomcon->hpdRecord; + if (hpdRecord) { + applecon->hotplug = hpdRecord[2]; + } else { + applecon->hotplug = 0; + kprintf("ATOM: %s: ASSERT(NULL != hpdRecord)\n", "uint8_t AtiBiosParser2::getHotPlugPin(atom_hpd_int_record *)"); + } + + AtiBiosParser2::getOutputInformation(parser, atomcon, applecon); + AtiBiosParser2::getConnectorFeatures(parser, atomcon, applecon); + + if (applecon->flags) { + if ((applecon->flags & 0x704) && applecon->hotplug) + applecon->features |= 0x100; + return kIOReturnSuccess; + } else { + kprintf("ATOM: %s: ASSERT(0 != drvInfo.connections)\n", "IOReturn AtiBiosParser2::translateAtomConnectorInfo(AtiObjectInfoTableInterface_V2::AtomConnectorInfo &, ConnectorInfo &)"); + } + + return kIOReturnNotFound; +} + +IOReturn AtiBiosParser2::getOutputInformation(AtiBiosParser2 *parser, AtomConnectorInfo *atomcon, ModernConnector *applecon) { + if (!atomcon->usGraphicObjIds) { + kprintf("ATOM: %s: ASSERT(0 != objId.u16All)\n", "IOReturn AtiBiosParser2::getOutputInformation(AtiObjectInfoTableInterface_V2::AtomConnectorInfo &, ConnectorInfo &)"); + return kIOReturnBadArgument; + } + + uint8_t encoder = (uint8_t)atomcon->usGraphicObjIds; + bool one = ((atomcon->usGraphicObjIds & ENUM_ID_MASK) >> ENUM_ID_SHIFT) == 1; + + switch (encoder) { + case ENCODER_OBJECT_ID_NUTMEG: + applecon->flags |= 0x10; + return kIOReturnSuccess; + case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: + if (one) { + applecon->transmitter |= 0x10; + } else { + applecon->transmitter |= 0x20; + applecon->encoder |= 0x1; + } + return kIOReturnSuccess; + case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: + if (one) { + applecon->transmitter |= 0x11; + applecon->encoder |= 0x2; + } else { + applecon->transmitter |= 0x21; + applecon->encoder |= 0x3; + } + return kIOReturnSuccess; + case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: + if (one) { + applecon->transmitter |= 0x12; + applecon->encoder |= 0x4; + } else { + applecon->transmitter |= 0x22; + applecon->encoder |= 0x5; + } + return kIOReturnSuccess; + case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3: + if (one) { + applecon->transmitter |= 0x13; + applecon->encoder |= 0x6; + } else { + applecon->transmitter |= 0x23; + applecon->encoder |= 0x7; + } + return kIOReturnSuccess; + } + + return kIOReturnInvalid; +} + +IOReturn AtiBiosParser2::getConnectorFeatures(AtiBiosParser2 *parser, AtomConnectorInfo *atomcon, ModernConnector *applecon) { + if (!atomcon->usConnObjectId) { + kprintf("ATOM: %s: ASSERT(0 != objId.u16All)\n", "IOReturn AtiBiosParser2::getConnectorFeatures(AtiObjectInfoTableInterface_V2::AtomConnectorInfo &, ConnectorInfo &)"); + result = kIOReturnBadArgument; + } + + uint8_t connector = (uint8_t)atomcon->usGraphicObjIds; + + switch (connector) { + case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I: + case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D: + applecon->type = ConnectorDigitalDVI; + applecon->flags |= 4; + // unlock 2k res, causes crashes on R9 290X + // undone by -raddvi + applecon->transmitter &= 0xCF; + return kIOReturnSuccess; + case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I: + case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D: + applecon->type = ConnectorDigitalDVI; + applecon->flags |= 4; + return kIOReturnSuccess; + case CONNECTOR_OBJECT_ID_HDMI_TYPE_A: + case CONNECTOR_OBJECT_ID_HDMI_TYPE_B: + applecon->type = ConnectorHDMI; + applecon->flags |= 0x204; + return kIOReturnSuccess; + case CONNECTOR_OBJECT_ID_VGA: + applecon->type = ConnectorVGA; + applecon->flags |= 0x10; + return kIOReturnSuccess; + case CONNECTOR_OBJECT_ID_LVDS: + applecon->type = ConnectorLVDS; + applecon->flags |= 0x40; + applecon->features |= 0x9; + // unlock 2k res + applecon->transmitter &= 0xCF; + return kIOReturnSuccess; + case CONNECTOR_OBJECT_ID_DISPLAYPORT: + applecon->type = ConnectorDP; + applecon->flags |= 0x304; + return kIOReturnSuccess; + case CONNECTOR_OBJECT_ID_eDP: + applecon->type = ConnectorLVDS; + applecon->flags |= 0x100; + applecon->features |= 0x109; + return kIOReturnSuccess; + } + + return kIOReturnInvalid; +} diff --git a/README.md b/README.md index 74df1382..cae4736e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ WhateverGreen - Fixes boot logo distortion in certain cases (`-radlogo`) - Fixes transmitter/encoder in autodetected connectors for multimonitor support (`-raddvi`) - Fixes certain HD 7xxx initialisation (`radpg=15`) +- Fixes HDMI audio for _natively supported_ devices if not injected manually - Allows enforcing 24-bit mode on unsupported displays (`-rad24`) - Allows booting without video acceleration (`-radvesa`) - Allows automatically setting GPU model name or providing it manually for RadeonFramebuffer @@ -29,8 +30,8 @@ Add `-radoff` to disable WhateverGreen. Add `-radbeta` to enable WhateverGreen on unsupported os versions (10.13 and below are enabled by default). Add `-rad24` to enforce 24-bit display mode. Add `-radlogo` to patch boot logo distortion. -Add `radpg=15` to disable several power-gating modes (see FAQ, required for 7xxx GPUs). -Add `-raddvi` to enable DVI transmitter correction (required for 290X, 370, etc.) +Add `-raddvi` to enable DVI transmitter correction (required for 290X, 370, etc.) +Add `radpg=15` to disable several power-gating modes (see FAQ, required for 7xxx GPUs). #### Credits - [Apple](https://www.apple.com) for macOS diff --git a/WhateverGreen/kern_model.cpp b/WhateverGreen/kern_model.cpp index 73d8f1a3..cdaec666 100644 --- a/WhateverGreen/kern_model.cpp +++ b/WhateverGreen/kern_model.cpp @@ -758,8 +758,8 @@ static constexpr DevicePair devices[] { }; const char *RAD::getModel(uint16_t ven, uint16_t dev, uint16_t rev, uint16_t subven, uint16_t sub) { - // Initially check vendor-id common to all ATI/AMD - if (ven != 0x1002) + // Initially check vendor-id common to all ATI/AMD (0x1002) + if (ven != VendorID::ATIAMD) return nullptr; for (auto &device : devices) {