Chameleon

Chameleon Commit Details

Date:2010-10-24 23:19:26 (8 years 8 months ago)
Author:Evan Lojewski
Commit:611
Parents: 610
Message:HDA codec can now be specified with HDACodec=888 (or another codec)
Changes:
M/branches/meklort/i386/modules/KextPatcher/kext_patcher.c

File differences

branches/meklort/i386/modules/KextPatcher/kext_patcher.c
1111
1212
1313
14
15
1416
1517
1618
......
1820
1921
2022
23
24
25
2126
2227
2328
......
3338
3439
3540
41
42
3643
3744
3845
......
4148
4249
4350
44
51
4552
4653
4754
......
126133
127134
128135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
129152
130153
131154
......
689712
690713
691714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
692732
#include "libsaio.h"
#include "zlib.h"
#include "kext_patcher.h"
#include "boot.h"
#include "bootstruct.h"
#include "pci.h"
#include "drivers.h"
#include "mkext.h"
#include "hex_editor.h"
#define kHDACodec"HDACodec"/* acpi_patcher.c */
#ifndef DEBUG_KEXT_PATCHER
#define DEBUG_KEXT_PATCHER 0
#endif
bool patch_hda_kext(TagPtr plist, char* plistbuffer, void* start);
bool patch_hda_controller(TagPtr plist, char* plistbuffer, void* start);
int chartohex(char c);
static void * z_alloc(void *, u_int items, u_int size);
static void z_free(void *, void *ptr);
// TODO: add detection code / a method for users to enter the id
uint16_t patch_hda_codec = 0;
#define NEEDS_PATCHING(patch_bcm_deviceid || patch_gma_deviceid | patch_hda_codec)
#define NEEDS_PATCHING(patch_bcm_deviceid || patch_gma_deviceid || patch_hda_codec)
typedef struct z_mem {
uint32_t alloc_size;
void mkext_loaded(void* filespec, void* packagetmp, void* lengthtmp, void* arg3)
{
const char* hda_codec;
int len = 0;
if (getValueForKey(kHDACodec, &hda_codec, &len, &bootInfo->bootConfig))
{
int index = 0;
while(len)
{
patch_hda_codec <<= 4;
patch_hda_codec |= chartohex(hda_codec[index]);
len--;
index++;
}
}
if(!NEEDS_PATCHING) return;// No need to apply a patch, hardware doesn't need it
int version = 0;
free(executable);
return true;
}
int chartohex(char c)
{
if(c <= '9' && c >= '0')
{
return c - '0';// c is between 0 and 9
}
else if(c <= 'F' && c >= 'A')
{
return c - 'A' + 10; // c = 10 - 15;
}
else if(c <= 'f' && c >= 'a')
{
return c - 'a' + 10; // c = 10 - 15;
}
return 0;
}

Archive Download the corresponding diff file

Revision: 611