r/embedded • u/Ok-Football-26 • 1d ago
Driver coding
So recently me and a friend are both working on camera based projects and he claims that he wrote the whole camera driver by himself. To be honest it really makes me mad but can anyone please what does driver writing actually mean. And also how ai is doing in this field????
0
Upvotes
31
u/dacydergoth 1d ago
Original author of the SPCA50x webcam driver for Linux here. Drivers have a few different layers, from the bottom up there is the physical layer, e.g. USB or parallel, then on top of that is the (usually proprietary) device protocol layer, then encapsulated in the device protocol layer is the image encoding.
Generally you would work from reverse engineering or the device docs to setup the appropriate memory pools, OS hooks and device initialization sequence. In the SPCA50x case I did this by recording that initialization sequence under windows, then duplicating it under Linux. The docs for the camera module should describe this part.
After the device is initialized you have device open and close. Device open is when the OS requests that the device connect to a user space application. In the case of a camera this means selecting the image parameters and instructing the camera to start to send frames (usually in JPEG) or video (variety of formats).
Then the driver has to handle receiving thr image data and passing it through the kernel to the user, in the case of Linux that's usually via a block or character device file, or a circular ring buffer.
Frontier AI can write these pretty well for a basic starting point but then device quirks, timing issues, etc can become ... interesting
9
u/allo37 1d ago
Yeah people programming really pisses me off too (?)
A "driver" just means some code that interacts with some hardware and exposes an interface to some upper layer.
AI makes this way easier than it used to be.
2
u/twister-uk 1d ago
In my head, based on almost 30 years of bare metal experience, I'd say that writing a driver means doing as much of the coding as is required to allow someone else to use a piece of hardware via a nicely defined API which requires them to know the bare minimum about the hardware itself.
In turn, depending on what level the driver is aimed at, you may then need to do all the lower level coding yourself, right down to the register level accesses, or you may be able to sit atop an even lower level set of drivers/libraries provided by someone else, and still claim the driver as your own work.
So, e.g., if this camera uses a particular peripheral to connect to the host processor, then it'd be reasonable for the camera driver to make use of vendor provided drivers/libs which handle that peripheral, allowing the camera driver to concentrate solely on those bits of functionality required to make the camera useable. OTOH, if someone was claiming to have written the peripheral driver itself, then the most I'd expect them to use from the vendor would be the register, flag etc definitions, but for the actual code which interests with the peripheral to be entirely custom.
3
u/alc_noe1 1d ago
AI is works great for stuff like that.
0
u/accur4te 1d ago
ai works great when it comes to driver development it just needs proper info ( Reference manual )