There's https://openipc.org/ , if open source camera firmware is of interest to you. I actually ordered a few supported IP camera modules (basically complete IP cameras but without the case) from Aliexpress and tested that I'm able to compile a firmware, I shall see if I get it working once they arrive.
It's not quite clear to me what the firmware is actually able to do, though. Apparently its motion detection is very basic, though, so you'd need to use e.g. Frigate for that.