Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created March 25, 2021 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuowei/223e449a90a32eefd2c3244e252818d1 to your computer and use it in GitHub Desktop.
Save zhuowei/223e449a90a32eefd2c3244e252818d1 to your computer and use it in GitHub Desktop.
#pragma once
@import Darwin;
@import Foundation;
typedef mach_port_t io_object_t;
typedef io_object_t io_service_t;
typedef CFTypeRef IOAVServiceRef;
typedef CFTypeRef IOAVDeviceRef;
typedef kern_return_t IOReturn;
// allocator: must be kCFAllocatorDefault
// Note that this defaults to grabbing the external IOAVService:
// iOS 12.4:
// {
// IOProviderClass = IOAVService;
// Location = External;
// }
// iOS 14.1:
// {
// IOPropertyMatch = {
// IOAVServiceUserInterfaceSupported = 1;
// };
// Location = External;
// }
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service);
#define IOAVLocationExternal 0
#define IOAVLocationEmbedded 1
extern IOAVServiceRef IOAVServiceCreateWithLocation(CFAllocatorRef allocator, uint32_t location);
#define IOAVServiceI2CArg4Max (1 << 12)
// w4 must be less than (1 << 12) or it returns kIOReturnBadArgument
extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t w1, uint32_t w2, void* w3,
uint32_t w4);
extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t w1, uint32_t w2, void* w3,
uint32_t w4);
extern IOReturn IOAVServiceSetVirtualEDIDMode(IOAVServiceRef service, void* x1_possibly_unused,
CFDataRef x2);
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x1);
// not sure what a device does that a service can't??
extern IOAVDeviceRef IOAVServiceGetDevice(IOAVServiceRef service);
extern IOAVDeviceRef IOAVDeviceCreateWithService(CFAllocatorRef allocator, io_service_t service);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment