Jump to content

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

cmedia CMI8788 8788 sound PCI C-Media kext driver

  • Please log in to reply
40 replies to this topic

#1
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 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 Posted Image

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

#2
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
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.

#3
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
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.

#4
Trex20xx

Trex20xx

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
  • Gender:Male
what is more exactly the linux ALSA driver ?

is the linux version of the driver for these cards ?

#5
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
Yep exactly, ALSA = Advanced Linux Sound Architecture.


#6
Riley Freeman

Riley Freeman

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 920 posts
  • Gender:Male
  • Location:The Streets
It's great to finally see someone working on a driver for this. Maybe I'll finally be able to get my D2 working!

#7
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
D2, D2X support will come once I'll get my D1 to work.
And also, I'm quite busy atm, so the project is on hold for the week to come.

#8
Riley Freeman

Riley Freeman

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 920 posts
  • Gender:Male
  • Location:The Streets
Any sign of progress is welcome. If you want a tester for D2 when the time comes, just let me know.

#9
Trex20xx

Trex20xx

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
  • Gender:Male
hello otak. how's it going? did you manage to make your soundcard work ? how is interacting with mac os ? any quality and frequency response tests ?

#10
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
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 ^^'

#11
Trex20xx

Trex20xx

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
  • Gender:Male
i'm very sorry to hear that. i wish you get healthy (and i think all of insanelymac comunity wishes the same). that are very good news :D . can i ask you what this coding is about ? how does a code part looks like ?

#12
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
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.)

#13
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
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.

#14
Trex20xx

Trex20xx

    InsanelyMac Protégé

  • Members
  • Pip
  • 6 posts
  • Gender:Male
well done, anonymous .. well done otak :D

#15
toxicfusion

toxicfusion

    InsanelyMac Protégé

  • Members
  • Pip
  • 2 posts
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!
:)

#16
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
No worries, we talked about it in private ;)

Update : I'm soon ending up my freelance project, when it'll be done, be sure that I'd dedicate my free time to both my gf and this driver ;)

#17
Gringo Vermelho

Gringo Vermelho

    The Jan Bird fix

  • Supervisors
  • 6,121 posts
  • Gender:Male
  • Location:Brazil
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.

#18
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
Thank you! Great to be considered as such from an InsanelyMac mod :)
Be sure that I'll keep this topic updated as soon as I will have updates for you :)

#19
Subliminal Aura

Subliminal Aura

    InsanelyMac Protégé

  • Members
  • Pip
  • 5 posts
Subscribed and Good luck.

I too write Linux Kernel modules but am a complete OS X noob - would love to get involved with porting

#20
OtaK

OtaK

    InsanelyMac Protégé

  • Members
  • Pip
  • 33 posts
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.)





Also tagged with one or more of these keywords: cmedia, CMI8788, 8788, sound, PCI, C-Media, kext, driver


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy