Search code examples
clinuxaudiokerneldriver

C - Linux create sound in kernel mode


I need o write a kernel mode driver that plays a note when a key is pressed. I can capture keystrokes but I have no idea how to play sound from kernel. What do I have to do to play a sound? I am brand new to creating drivers.


Solution

  • I need o write a kernel mode driver that plays a note when a key is pressed.

    Why?

    Seriously, why. What's the reasoning behind this "need"? What's the true reason for the need to play a sound? Maybe there is a better way.

    Assuming a PC, with the pcspkr module loaded, you can of course call its functions. But if you want to play something through the soundcard, you'll essentially have to "open" an ALSA device (inside the kernel), and call its fops, all along while user space may do the same thing.