In a directory where you want to do your kernel stuff, run
apt source linux-kernel-`uname -r`
apt source linux-modules-`uname -r`
Not sure if I want to know the difference between these two 
Typo. First one was supposed to be
linux-image-`uname -r`, containing the stuff needed (later on) if you want to sign the kernel. The latter obtains the Linux source tree.
Note that I was not writing about "how you can fix your ca0132 hda codec kernel module", I'm writing about how to go about it in general.
Even if you switch from the kernel to some application or service, there's very little one needs to change.
I'm sure you prefer simple recipes that are unique to each package that do nothing extra, but I just don't care to memorize such crap.
And yes, I do do Linux kernel development myself. It's just that each Linux distribution varies a bit on exactly how to duplicate already installed kernels; although all Debian variants share the basic procedure.
You know, magic, you come across as quite the asshole. No matter how good work you might do (which, well, based on your attitude, is unlikely –– I'm sure you're capable; I just don't think you actually ever really bother), I for sure would not like to work with you, ever. You somehow manage to be very annoying, even when you try to help. Are you a teenager? That would explain a lot.
install all development packages you might need when building the kernel and/or modules. (There's a lot of stuff, including Java Runtime, probably due to OpenJade used in some documentation generation options.)
LOL.
Alternatively, just run make and if it fails, install the missing program or two. Realistically, you need make, gcc and maybe a few basic Linux utilities that are likely already installed on your system, or should be anyway if they aren't yet.
That depends. If you feel comfortable walking blind in the dark and hope that fixing whatever errors you get will get you there, be my guest. I do not.
And in general, I'm not the type that tells people to install packages until something works, I prefer to tell them how to install the set that the distribution maintainers have deemed relevant.
Then, in the same kernel root directory as you cd'd to above, run
make sound/pci/hda/
make sound/pci/hda/snd-hda-codec-ca0132.ko
IIRC, the first line will just build everything in the HDA driver directory. I don't think it's necessary or useful.
It is intentional, and useful. Although kernel configuration is tested by compile farms in random configurations, it is quite possible for a specific kernel module that depends on other kernel modules to not compile solo cleanly, unless those others are compiled first. (Because the Makefiles are written by humans who often make rather funny assumptions.) In this case, snd-hda-codec-ca0132.ko does compile cleanly alone.
IIRC, you can install modules in some special subdirectories other than /kernel/ and in some cases your module may even shadow the one in /kernel/, without deleting it.
Yes, and no. Yes, you can do that by modifying modprobe config (see
man 5 modprobe.d) but it won't affect things like initrd creation (if you happen to do your own configuration and have the driver loaded there, say if you need the machine to make (yuk!) startup noise).
You can trivially make
rmmod snd-hda-codec-ca0132 ; insmod /path/to/snd-hda-codec-ca0132.ko into a systemd init module, so it's run at boot time, too.
Just replacing the existing one (assuming a typical unsigned kernel module) is easier. If you want to revert it, all you need to do is run
apt reinstall $(dpkg-query -S /lib/modules/`uname -r`/kernel/sound/pci/hda/snd-hda-codec-ca0132.ko | cut -d ':' -f 1)where the
dpkg-query -S path-to-file | cut -d ':' -f 1 provides the package name that "owns" the specified file. In this case, it will be
linux-modules-extra-`uname -r`. So, it's not like overwriting the existing module file is somehow irreversible.
If one wanted to (re)build the entire (unsigned) kernel and modules, there are three options. One is to run
fakeroot debian/rules binaryin the kernel directory (that my short guide cd'd into). This can be used to build
.deb packages whenever the project does contain the Debian tooling in
debian/. The second is to use
debuild from the Debian devscripts package,
debuild -b -uc -usto build only the binary packages, unsigned, for the package corresponding to the current directory. It basically runs the former as one step, but also does stuff like change the package info to match the build user and so on. This is the command I normally reach for in Debian derivatives. The third is to run
make deb-pkgsince the kernel Makefile contains the
deb-pkg target needed.
In any case, one should do a small modification when copying over the current configuration:
cp /boot/config-`uname -r` .config sed -e 's|^\(CONFIG_MODULE_SIG[_A-Z0-9]*\)=y$|\1=n|' -e 's|^\(CONFIG_MODULE_SIG[_A-Z0-9]*\)=".*$|\1=""|' -i .configto disable module signing, and
sed -e '/debian/ s|^\(CONFIG_SYSTEM_[A-Z]*_KEYS\)=.*$|\1=""|' -i .configto remove the canonical certificate list (
debian/canonical-certs.pem) and revoked certificates list (
debian/canonical-revoked-certs.pem) from being embedded in the kernel, since they are not included in the kernel sources, and the build will fail in one of the
certs/ targets otherwise.
You can run e.g.
diff -U 0 /boot/config-`uname -r` .config to see exactly what changes the above does.
The packages will appear in the parent directory. (These commands are always run in the topmost directory belonging to the sources, the topmost one extracted when the sources are downloaded and patches applied; i.e. in
linux-5.4.0/ for example.)