Using the RPi5's videodac as a general purpose DAC

Pieter-Tjerk de Boer, PA3FWM web@pa3fwm.nl

The Raspberry Pi 5 board has a composite video output, for driving analog TVs. This page is about using this output as a general-purpose analog output. The DAC (digital to analog converter) driving it, turns out to have 10 bits of resolution and support samplerates well over 100 MHz, with a nominal 1.28 V output swing when driving a 75 ohm load. (Tantalizingly, it seems the chip contains three such DACs, intended for R/G/B analog video, but only one is accessible on the RPi5 board.)

Background

Ever since the first Raspberry Pi, these single-board computers have had a composite video output. In the early models it was made prominently available on an RCA socket. On the current RPi 5, it is only available as soldering islands on the board, presumably because of reduced interest in driving analog TVs.

There is however another important difference between the older RPi:s and the RPi5. In the older versions, the composite video output came out of the main Broadcom System-on-Chip. In the RPi5, the composite video comes out of a separate chip, designed by the Raspberry Pi foundation themselves. This chip's composite output turns out to be more flexible than the Broadcom chip. The Broadcom chip insists on generating synchronisation pulses (which are a normal part of the composite video signal), while in the RP1 chip these can be switched off, leaving a 'pure' analog output.

Much of what I describe here was done based on a short posting on this thread on the Raspberry Pi forum, where Raspberry Pi engineer 'njh' gave some hints for using the composite output as a general purpose output, saying it 'might be possible, with various gotchas'. That sounded rather tentative and speculative, but it actually turned out to be pretty easy to do, as documented below.

Direct writes to the DAC

One way to use the composite output as a general-purpose DAC is very simple: one can just directly write values to it, without further ado. This is possible thanks to the chip having a mode in which the DAC outputs a constant value, completely ignoring the data coming from video memory (presumably intended for testing). You first once write 0x0019ffff to the register at address 0x1f00140004 to enable the DAC, and then 0x40000000+data, where data is your 10 bit data, to the register at address 0x1f00140010. That's it!

The only complexity is actually writing to I/O registers from a regular user-space program; that's done by opening, with root privileges, the special /dev/mem device.
In C, that looks like this:

#include <stdio.h> #include <stdint.h> #include <sys/mman.h> #include <fcntl.h> int main(void) { // preparation int fd=open("/dev/mem",O_RDWR); if (fd<0) { fprintf(stderr,"Can't open /dev/mem; this program needs root privileges!\n"); return 1; } volatile void *videodac_io=mmap(NULL,65536,PROT_READ|PROT_WRITE,MAP_SHARED,fd, 0x1f00140000); // I/O range for controlling the video parts of the RP1 chip if (!videodac_io) { fprintf(stderr,"Can't mmap RP1 I/O range; this program needs root privileges!\n"); return 1; } #define write_io(address,data) { *(volatile uint32_t*)(videodac_io+(address))=(data); } write_io(0x0004, 0x0019ffff); // enable DAC, for 1 channel, bandgap on, 1.28V swing (says rp1_vec_cfg.c) .... // actual data write write_io(0x0010, 0x40000000+data); // enable DAC override (that's the 0x4000000 bit) and write data (lower 10 bits) } And in Python (based on this): from mmap import mmap import struct with open("/dev/mem", "w+b" ) as f: mem = mmap(f.fileno(), 65536, offset=0x1f00140000) mem[0x4:0x8] = struct.pack("<L", 0x0019ffff); # enable DAC, for 1 channel, bandgap on, 1.28V swing (says rp1_vec_cfg.c) .... mem[0x10:0x14] = struct.pack("<L", 0x40000000+data); # enable DAC override (that's the 0x4000000 bit) and write data (lower 10 bits)

Streaming writes to the DAC using the video hardware

If you want to send data to the DAC at high rate and with nicely regular timing, doing direct writes as described above is not efficient or reliable. There is an alternative though: configure the DAC as a video output. After all, the normal use of the video DAC is to send image intensities to the monitor, pixel by pixel from left to right, and line by line from top to bottom, about 60 screenfuls per second. In a normal composite video signal, this stream is briefly interrupted at the end of every line and at the end of every screenful to insert synchronization pulses. Fortunately, it turns out that in the RP1 chip these can be disabled, leaving a continuous, uninterrupted, datastream, repeatedly sending out data from the framebuffer video memory, all by itself, at a constant rate.

I got this to work as follows:

My example code for this is available as rpi5-videodac-20261106.tgz. It consists of a small library in videodac.c, and a demo program demo.c that outputs a sine wave to illustrate how to use the library.

I have to admit that the above approach, piggybacking on the normal video configuration, is a hack. It was easy to get to work, but it has some disadvantages:

Surely, these things can be solved, but that requires more detailed RPi knowledge than I currently have...

Applications

What can this be used for? Some ideas:
Text and pictures on this page are copyright 2026, P.T. de Boer, web@pa3fwm.nl .
Republication is only allowed with my explicit permission.