Jump to content

[Driver Programming] C-Media CMI8788 (Xonar DX/D1/D2... family)


OtaK
 Share

47 posts in this topic

Recommended Posts

Hello,

 

Due to the lacking support of this sound card, I decided to write a driver, I have quite decent background in C and I/O management to think that I'm able to write one.

 

However, I'm not very familiar with how kexts are working, and the whole process of hooking the code to the kernel.

 

Does anyone have a reference to share about that, maybe some kext on GitHub or whatever, I'll understand by reading the code, it's not a problem. (Already looked at the Apple Reference on kext writing / using IOKit, it doesn't provide much... They don't really like when we have fun with kexts it seems...)

 

As for the technical sheets of the CMI8788, I guess I can get them myself on internet, that including the addresses of each input/output the card has.

 

And if Dogbert could pass by here, I'd be happy to have some help from an expert like him icon_e_smile.gif

 

Feel free to help in any way, you're very welcome, because I'm quite a busy man, so the more help I get, the less time I take ;)

Here are my progresses so far :

 

I guess MacOS can at least see my device, and it seems to try loading AppleHDA for it :

   | +-o PCI0@0  <class ioacpiplatformdevice,="" id="" 0x10000012a,="" registered,="" matched,="" active,="" busy="" 0="" (27444="" ms),="" retain="" 74="">
| | +-o AppleACPIPCI  <class appleacpipci,="" id="" 0x1000001a2,="" registered,="" matched,="" active,="" busy="" 0="" (26989="" ms),="" retain="" 46="">
| |   +-o pci8086,2e20@0  <class iopcidevice,="" id="" 0x1000001a4,="" registered,="" matched,="" active,="" busy="" 0="" (3="" ms),="" retain="" 27="">
| |   +-o pci-bridge@1  <class iopcidevice,="" id="" 0x1000001a5,="" registered,="" matched,="" active,="" busy="" 0="" (10163="" ms),="" retain="" 31="">
| |   | +-o IOPCI2PCIBridge  <class iopci2pcibridge,="" id="" 0x1000001e9,="" registered,="" matched,="" active,="" busy="" 0="" (9756="" ms),="" retain="" 9="">
| |   |   +-o HDEF@0,1  <class iopcidevice,="" id="" 0x1000001a7,="" registered,="" matched,="" active,="" busy="" 0="" (8948="" ms),="" retain="" 29="">
| |   |	 +-o AppleHDAController@0,1  <class applehdacontroller,="" id="" 0x1000002ad,="" registered,="" matched,="" active,="" busy="" 0="" (6435="" ms),="" retain="" 6="">
| |   |	   +-o IOHDACodecDevice@0,1,0  <class iohdacodecdevice,="" id="" 0x1000002b7,="" registered,="" matched,="" active,="" busy="" 0="" (6435="" ms),="" retain="" 6="">
| |   |		 +-o IOHDACodecDriver  <class iohdacodecdriver,="" id="" 0x1000002bc,="" !registered,="" !matched,="" active,="" busy="" 0="" (1677="" ms),="" retain="" 5="">
| |   |		   +-o IOHDACodecFunction@0,1,0,1  <class iohdacodecfunction,="" id="" 0x1000002bd,="" registered,="" matched,="" active,="" busy="" 0="" (1677="" ms),="" retain="" 4="">

 

EDIT : In fact what I saw is my HD4870's HDMI Audio channel

 

Alright. Understood the major concepts behind generic kexts, and looked into most of how IOKit subclasses system works.

 

Gonna start writing the enabler for the card, then the audio engine.

 

Resources :

 

PID match table (source :http://www.alsa-proj..._EEPROM_Failure)

 

 

PCI\VEN_13F6&DEV_8788&SUBSYS_82691043 OK (Xonar D2)

PCI\VEN_13F6&DEV_8788&SUBSYS_82751043 OK (Xonar DX)

PCI\VEN_13F6&DEV_8788&SUBSYS_82B71043 OK (Xonar D2X)

PCI\VEN_13F6&DEV_8788&SUBSYS_83141043 OK (Xonar HDAV1.3)

PCI\VEN_13F6&DEV_8788&SUBSYS_83271043 OK (Xonar DX)

PCI\VEN_13F6&DEV_8788&SUBSYS_834F1043 OK (Xonar D1)

PCI\VEN_13F6&DEV_8788&SUBSYS_835C1043 OK (Xonar Essence STX)

PCI\VEN_13F6&DEV_8788&SUBSYS_835D1043 OK (Xonar Essence ST)

PCI\VEN_13F6&DEV_8788&SUBSYS_835E1043 OK (Xonar HDAV1.3 Slim)

PCI\VEN_13F6&DEV_8788&SUBSYS_838E1043 OK (Xonar DS)

PCI\VEN_13F6&DEV_8788&SUBSYS_84281043 OK (Xonar Xense)

PCI\VEN_13F6&DEV_8788&SUBSYS_84671043 OK (Xonar DG)

PCI\VEN_13F6&DEV_8788&SUBSYS_878813F6 overwritten EEPROM

Link to comment
Share on other sites

Got Dogbert's source, very helpful, I won't pass on mentionning him in the credits !

I'm currently writing enabler/audio engine, and for the technical reference, I'll have to look into Linux ALSA drivers.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Some parts of the driver are done, only writing/reading on/from the chip registers is left, and for that, I'm constantly examining the ALSA driver. I am, in fact, doing a port of Clemens Ladisch's CMI8788 drivers, for now only for Xonar D1, for the rest I'll integrate once I'll have a working one for my own card.

Link to comment
Share on other sites

  • 3 weeks later...

As I said before, I got very busy, and unfortunately, it kept going till I got a burn-out syndrome... So at that very moment, I'm resting. maybe I'll catch up with the driver, interesting and relaxing stuff :)

 

So for now, if I recall correctly, I wrote the power-on code, the rest is just about writing physically on the chip, just small parts of code to insert, the rest should be OK. I planned to support many frequencies / bitrates since the very start. (44,1/48/96/192KHz at both 16/24bits)

 

That's it for now :)

I'm really sorry for the delay, but my body told me to stop working ^^'

Link to comment
Share on other sites

It's about writing some special binary flags at some physical places on the chip to enable/disable/control functionalities.

For example (random example), I'll write a binary addition of GET_POWER and TURN_ON (GET_POWER | TURN_ON) constants to the physical address of the power controller, which will result in the card turning on.

As simple as that, but the real problem is making the sort in the hundreds of constants and addresses that are written in the ALSA drivers, as those support a very wide range of CMI cards. I already extracted a bunch of them, just need to make a code that works for my card, public testing for D1 users, then when it's stable, adaptable code for every card I plan to support :)

 

Anyway, if any of you want to help, I'll be happy to let you use my SVN repo :)

(Just beware, the actual part of the coding is very architecture-low level code and needs a deep understanding of I/O and almost some electronics knowledge)

 

(Anyway, gonna maybe break my OSX install cause of the Messages Beta that got out today, NEED to update to 10.7.3 for this... http://www.apple.com.../messages-beta/ EDIT : didn't break anything, awesome, and Messages is even more awesome.)

Link to comment
Share on other sites

  • 2 weeks later...

Slight update : A member of the forums (I guess he/she wants to remain anonymous) gave me the technical sheet about registers, addresses and such.

The great thing is that I don't have any idea of how he got that document, as it's confidential and under NDA... Let's not ask too much questions !

And of course, I won't attach it here, as it'd be illegal.

Link to comment
Share on other sites

Hi there,

 

I to own a card with the C-Media C8788 chip.. The HT Omega Claro Plus, Love this card. I've recently moved to OSX 10.7.3 Lion, and want to use this card... I'm willing to donate to this project after release of a working driver / kext file.

 

If 2.1 audio and mic-in works - thats OK with me!

:)

Link to comment
Share on other sites

Just popping in to thank you OtaK, this doesn't happen very often, someone appearing out of nowhere writing a driver for unsupported hardware. And it's nice to hear about the valuable anonymous contribution, so another thank you to whoever provided that.

 

You rock! :guitar:

 

Good luck, and keep up the good work.

  • Like 1
Link to comment
Share on other sites

Hmm why not, I'll get in touch with you when I'll get back on the project, maybe. The only part left is the one common with all the Kernel modules, I/O with the physical device. The rest (IOKit Classes / methods) is done already :)

 

I'll see if I can do myself, and why not getting your help with porting more cards :)

(Anyway the project needs a massive refactoring, in the current state, it'd be quite awful to port more cards, but it's in my plans.)

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 4 weeks later...

Hey :)

just posting to ask what is the progress of this?? as I really cannot keep using my Razer Megalodon for sound (as my onboard sound chip blew on my Asus Sabertooth X58) and i really miss listening to music and playing games :L

if you need testers for Xonar DS pass it my way and ill help test driver :)

 

Thankies..

-Stephen-

Link to comment
Share on other sites

 Share

×
×
  • Create New...