PhycialDisplay (macOS): add support

This commit is contained in:
李通洲
2023-08-09 10:11:24 +08:00
parent bb0279bae1
commit 1d1ce83567
6 changed files with 137 additions and 32 deletions
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#ifndef FASTFETCH_INCLUDED_util_apple_ddcci_h
#include <CoreGraphics/CoreGraphics.h>
// DDC/CI
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) __attribute__((weak_import));
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) __attribute__((weak_import));
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) __attribute__((weak_import));
extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) __attribute__((weak_import));
extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) __attribute__((weak_import));
#endif
+2 -2
View File
@@ -1,13 +1,13 @@
#include "edidHelper.h"
void ffEdidGetPhycialDisplay(uint8_t edid[128], uint32_t* width, uint32_t* height)
void ffEdidGetPhycialDisplay(const uint8_t edid[128], uint32_t* width, uint32_t* height)
{
const int dtd = 54;
*width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2];
*height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5];
}
void ffEdidGetName(uint8_t edid[128], FFstrbuf* name)
void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name)
{
// https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c
for (uint32_t i = 0x36; i < 0x7E; i += 0x12)
+2 -2
View File
@@ -6,7 +6,7 @@
#include <stdint.h>
#include "util/FFstrbuf.h"
void ffEdidGetPhycialDisplay(uint8_t edid[128], uint32_t* width, uint32_t* height);
void ffEdidGetName(uint8_t edid[128], FFstrbuf* name);
void ffEdidGetPhycialDisplay(const uint8_t edid[128], uint32_t* width, uint32_t* height);
void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name);
#endif