~martijnbraam/megapixels

ref: 7c218cddd33a02b6683d754eb8cab7a449b392d8 megapixels/tools/list_devices.c -rw-r--r-- 1.9 KiB
7c218cddMartijn Braam Redesign data QR dialog 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "device.h"
#include <linux/media.h>
#include <stdio.h>

int
main(int argc, char *argv[])
{
	MPDeviceList *list = mp_device_list_new();

	while (list) {
		MPDevice *device = mp_device_list_get(list);

		const struct media_device_info *info = mp_device_get_info(device);
		printf("%s (%s) %s\n", info->model, info->driver, info->serial);
		printf("  Bus Info: %s\n", info->bus_info);
		printf("  Media Version: %d\n", info->media_version);
		printf("  HW Revision: %d\n", info->hw_revision);
		printf("  Driver Version: %d\n", info->driver_version);

		const struct media_v2_entity *entities =
			mp_device_get_entities(device);
		size_t num = mp_device_get_num_entities(device);
		printf("  Entities (%ld):\n", num);
		for (int i = 0; i < num; ++i) {
			printf("    %d %s (%d)\n", entities[i].id, entities[i].name,
			       entities[i].function);
		}

		const struct media_v2_interface *interfaces =
			mp_device_get_interfaces(device);
		num = mp_device_get_num_interfaces(device);
		printf("  Interfaces (%ld):\n", num);
		for (int i = 0; i < num; ++i) {
			printf("    %d (%d - %d) devnode %d:%d\n", interfaces[i].id,
			       interfaces[i].intf_type, interfaces[i].flags,
			       interfaces[i].devnode.major,
			       interfaces[i].devnode.minor);
		}

		const struct media_v2_pad *pads = mp_device_get_pads(device);
		num = mp_device_get_num_pads(device);
		printf("  Pads (%ld):\n", num);
		for (int i = 0; i < num; ++i) {
			printf("    %d for device:%d (%d)\n", pads[i].id,
			       pads[i].entity_id, pads[i].flags);
		}

		const struct media_v2_link *links = mp_device_get_links(device);
		num = mp_device_get_num_links(device);
		printf("  Links (%ld):\n", num);
		for (int i = 0; i < num; ++i) {
			printf("    %d from:%d to:%d (%d)\n", links[i].id,
			       links[i].source_id, links[i].sink_id, links[i].flags);
		}

		list = mp_device_list_next(list);
	}

	mp_device_list_free(list);
}