world leader in high performance signal processing
Trace: » v4l_blackfin_camera

Blackfin v4l Camera/Video Capture Driver

The Blackfin Cam Driver is a simple v4l driver supporting several CMOS Camera and Video Decoders on multiple platforms.





Configure Kernel

You typically need to enable i2c support and the CMOS Camera driver. The driver utilizes two ping pong buffers to store captured frames. One at the bottom of memory and one inside the un-cached memory area.

  •  Blackfin Processor Options --->
                 [*] Enable DMA Support
                        Uncached SDRAM region (Enable 2M DMA region)  ---> 
  •  Board customizations --->
                 (0x100000) Kernel load address for booting 
  • I2C support:
    # I2C support
    # I2C Hardware Bus support
  • Enable video4linux and a sensor driver:
    <M> Video For Linux
    [*]   Enable Video For Linux API 1 (DEPRECATED)
    ---   Enable Video For Linux API 1 compatible Layer 
          Video Capture Adapters --->
            <M> Blackfin Camera driver
            --- CMOS Camera Sensor Selection
                Target Sensor (VS6524) --->
  • After kernel boot
    root:~> modprobe i2c-bfin-twi
    root:~> modprobe blackfin-cam

User application Interface

User space application should access the camera driver only via video4linux APIs. There are 2 version of V4L APIs. You should choose proper one according to the driver you selected.

  • The document of V4L2 can be found here.
  • And V4L1 here.
  • An simple example can be found here.

Example usage

VS6524 Example

Simple Low Delay MPEG4 WebCam

To setup a streaming video web camera to a specific IP address, you can use ffmpeg directly to perform this operation. You don't need to setup any additional software on the Blackfin Side. You can use broadcast addresses as well as direct udp IP connections. On the far side we use mplayer to display the MPEG4 stream.



# MPEG4 QVGA 320x240 @ 20 fps
# Video Device: /dev/video0
# No Audio / verbose level 0
# Have a constant quality (but a variable bitrate) '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst quality).

ffmpeg -v 0 -f video4linux -r 20 -s 320x240 -i /dev/video0 -an -qscale 2 -f avi udp:



# Turn off fb console cursor blink 
echo 0 > /sys/class/graphics/fbcon/cursor_blink 
# Start MPlayer 
while :;do mplayer -quiet -fps 20 -demuxer mpeg4es udp://;sleep 1;done

See also here: simple_web_cam

ADV7183 Example

  1. Setup the bf561-ezkit or bf533-ezkit
  2. Enable ffmpeg

For the bf561-ezkit use the default configuration.

Connect a Composite Video Source to AVIN5

root:/> modprobe i2c-gpio
i2c-gpio i2c-gpio.0: using pins 1 (SDA) and 0 (SCL)

root:/> modprobe blackfin_cam
driver for ADV7183B get_camops
driver for ADV7183B get_camops
ADV7183B: detecting client on address 0x40
driver for ADV7183B init
ADV7183B: V4L driver Blackfin CMOS Camera now ready
ADV7183B: i2c driver ready

root:/> lsmod
Module                  Size  Used by
blackfin_cam            9148  0
adv7183b                1568  1 blackfin_cam
i2c_gpio                2120  0
i2c_algo_bit            4664  1 i2c_gpio

root:/> cat /proc/cpuinfo
processor       : 0
vendor_id       : Analog Devices
cpu family      : 0x27bb
model name      : ADSP-BF561 600(MHz CCLK) 100(MHz SCLK) (mpu off)
stepping        : 5
cpu MHz         : 600.000/100.000
bogomips        : 1196.03
Calibration     : 598016000 loops
cache size      : 16 KB(L1 icache) 32 KB(L1 dcache-wb) 0 KB(L2 cache)
dbank-A/B       : cache/cache
icache setup    : 4 Sub-banks/4 Ways, 32 Lines/Way
dcache setup    : 2 Super-banks/4 Sub-banks/2 Ways, 64 Lines/Way
L2 SRAM         : 128KB
board name      : ADI BF561-EZKIT
board memory    : 65536 kB (0x00000000 -> 0x04000000)
kernel memory   : 56316 kB (0x00100000 -> 0x037ff000)


root:/> ffmpeg -f video4linux -r 10.0 -s 720×288 -i /dev/video0 -qscale 6 -f mjpeg foo
FFmpeg version SVN-r7786, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/usr --source-path=/home/michael/devel/svn/uclinux-dist-trunk/lib/ffmpeg/build/../ffmpeg-svn-11114 --target-os=Linux --cpu=bfin --arch=bfin --extra-
  libavutil version: 49.5.0
  libavcodec version: 51.48.0
  libavformat version: 52.1.0
  built on Mar  6 2009 09:54:38, gcc: 4.1.2 (ADI svn)
Input #0, video4linux, from '/dev/video0':
  Duration: N/A, start: 1167609755.608000, bitrate: 33177 kb/s
    Stream #0.0: Video: rawvideo, uyvy422, 720x288 [PAR 0:1 DAR 0:1], 33177 kb/s, 10.00 tb(r)
Output #0, mjpeg, to 'foo':
    Stream #0.0: Video: mjpeg, yuvj420p, 720x288 [PAR 0:1 DAR 0:1], q=2-31, 200 kb/s, 10.00 tb(c)
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=  131 fps= 10 q=6.0 size=     484kB time=13.1 bitrate= 302.9kbits/s

root:~> ffmpeg -f video4linux -r 10.0 -s 720x288 -i /dev/video0 -qscale 6 -f mjpeg

On the PC with IP use vlc to view the stream on udp/port 1234:

BF548-EZkit Example

EPPI1 shares the lower data strobes with EPPI0 24-bit – therefore build u-boot with CONFIG_VIDEO_RGB666 defined. Also make sure you load the kernel framebuffer driver with outp_rgb666 = 1

u-boot-1.1.6: Patch to enable EPPI0 LCD framebuffer driver in 18-bit RGB666 Mode:

Index: include/configs/bf548-ezkit.h
--- include/configs/bf548-ezkit.h       (revision 1340)
+++ include/configs/bf548-ezkit.h       (working copy)
@@ -150,6 +150,7 @@
 /* Don't waste time transferring a logo over the UART */
 #  define CONFIG_VIDEO
+#  define CONFIG_VIDEO_RGB666
 # endif

BF548-EZKIT Hardware Setup:

  • SW17 ON ON OFF X (LCD 18-Bit Mode)
  • SW2 ALL OFF (Keypad Switch)
  • SW14.3 OFF
  • Populate JP2 STAMP Enable