Adding file naming and indexing
[AGL/documentation.git] / docs / 4_Developer_Guides / 5_General_setup.md
1 ---
2 title: Generic devices setup
3 ---
4
5 ## Camera setup on RPi4
6
7 This assumes that you'll be using the Raspberry Pi Camera Module, which can
8 easily hooked on the board using the LVDS connector. Further more information
9 about how to connect it, could be found at
10 [Installing a Raspberry Pi camera](https://www.raspberrypi.com/documentation/accessories/camera.html#installing-a-raspberry-pi-camera)
11
12 With the camera installed, you'll need to enable it by editing /boot/config.txt
13 file (if you're booting an AGL image over a sd-card it will be there by
14 default, otherwise -- in case of doing netboot, you'll have to create
15 manually) and add the following entry:
16
17
18         ## start_x
19         ##     Set to "1" to enable the camera module.
20         ##
21         ##     Enabling the camera requires gpu_mem option to be specified with a value
22         ##     of at least 128.
23         ##
24         ##     Default 0
25         ##
26         start_x=1
27
28 And reboot your device. Afterwards, after logging it, make sure that you have
29 the /dev/video0 device created. You could also use v4l2-ctl to verify
30 that is indeed usable as a capture device:
31
32         $ v4l2-ctl -d /dev/video0 --all
33
34 In order to test out video playback, use the following gstreamer pipeline:
35
36         $ gst-launch-1.0 v4l2src device=/dev/video0 ! \
37                                                 video/x-raw,width=640,height=480 ! waylandsink fullscreen=true
38
39 Alternatively, using [camera-gstreamer](https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps/camera-gstreamer.git;a=summary)
40 application could might be another possibility, but you'll have to build it
41 yourself and add it in the image.
42
43 This includes an example on how to create a xdg-toplevel surface and create a
44 gstreamer pipeline, instead of relaying on waylandsink to create one for you,
45 in a programmatic fashion.
46
47 ## Display setup on RPi4
48
49 This assumes that you'll be using the Raspberry Pi 7'' display. Installation
50 can be found at [Rpi Display page](https://www.raspberrypi.com/documentation/accessories/display.html).
51
52 If booting over the network, the dtb should already contain the ft5406 dtb,
53 while booting over sd-card the following show be in the /boot/config.txt
54 file:
55
56         dtoverlay=rpi-ft5406-overlay
57
58 Once the board boots up, you should get a rainbow like effect and afterwards
59 booting up would display debug scrolling over. You'll need to adjust the
60 orientation as the 800x480 is in portrait.  Edit /etc/xdg/weston/weston.ini and
61 add a new output entry, like the following:
62
63         [output]
64         name=DSI-1
65         transform=90
66
67 Note that for the Qt platform, the homescreen application, together with the
68 other demo applications, is tailored specifically for a 1080p display and it
69 will display incorrectly on such a smaller display.
70
71 ## Testing out video camera without a real device
72
73 While the above requires having a real video camera device, one can use out
74 the [vivid module](https://docs.kernel.org/admin-guide/media/vivid.html?highlight=vivid#the-virtual-video-test-driver-vivid)
75 to try out your custom application or just testing out camera functionality in AGL.
76
77 You should normally have the module present, not loaded, for either **rpi4** or for
78 **h3ulcb** boards. Load the module, like in the following command:
79
80         modprobe vivid allocators=0x1
81
82 Have a look at the kernel ring buffer to see what capture devices are created
83 and use as source:
84
85         $ gst-launch-1.0 v4l2src device=/dev/videoXX ! \
86                                 video/x-raw,width=640,height=480 ! waylandsink fullscreen=true
87
88 making sure to replace /dev/videoXX with correct capture device. You can check
89 that easily using the v4l2-ctl mentioned above.
90
91 Note that using camera-gstreamer will attempt to find the first available
92 capture device, so if you happen to have to another one before the one created
93 by this module it might not work. You can bypass that, by just making a symlink
94 from /dev/videoXX to /dev/video0 to make first available capture device.