-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdev.c
More file actions
113 lines (104 loc) · 3.45 KB
/
Copy pathdev.c
File metadata and controls
113 lines (104 loc) · 3.45 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Copyright (C) 2025 Calvin Owens <calvin@wbinvd.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "dev.h"
#include <stddef.h>
#include <linux/videodev2.h>
#include <libavutil/pixfmt.h>
#include "v4l2.h"
static const struct ircam_desc supported_descs[] = {
/*
* TOPDON TC001
* A-BF RX-450
* InfiRay P2 Pro
*
* The device is a simple uvcvideo camera. It claims to provide 256x384
* YUYV (yuyv422) video, but it actually gives you two different views
* of the same 16-bit 256x192 image data concatenated together.
*
* The first bitmap isn't actually YUV: it's really just an 8-bit
* grayscale bitmap with a garbage byte inserted between each real byte.
* The garbage byte is 0x80, so treating it as though it is YUYV or YVYU
* and converting it to RGB will waste CPU but ultimately give you a
* grayscale image. It is dynamically scaled, and contains a strict
* subset of the data in the second bitmap. We can just ignore it.
*
* The second bitmap is all we actually need: a true unscaled Y16 bitmap
* of the raw temperature values detected by the IR camera sensor.
*/
{
.width = 256,
.height = 192,
.fps = 25,
.isize = 256 * 192 * 2, // gray16le
.iskip = 256 * 192 * 2, // Skip 8-bit image (see above)
.vsize = 256 * 192 * 4, // RGBA
.v4l2_width = 256,
.v4l2_height = 384,
.v4l2_fmt = V4L2_PIX_FMT_YUYV,
.ff_raw_fmt = AV_PIX_FMT_GRAY16LE,
.name = "TOPDON TC001 or compatible",
},
/*
* Thermal Master P2
*
* The device is functionally similar to above TOPDON TC001 with
* two added pixel-rows for some meta information that must be skipped
* (updated .iskip and .v4l2_height)
*/
{
.width = 256,
.height = 192,
.fps = 25,
.isize = 256 * 192 * 2, // gray16le
.iskip = 256 * 194 * 2, // Skip 8-bit image + 2 rows (see above)
.vsize = 256 * 192 * 4, // RGBA
.v4l2_width = 256,
.v4l2_height = 386, // Contains 2 additional rows metadata
.v4l2_fmt = V4L2_PIX_FMT_YUYV,
.ff_raw_fmt = AV_PIX_FMT_GRAY16LE,
.name = "Thermal Master P2 or compatible",
},
};
static unsigned int nr_camera_descs(void)
{
return sizeof(supported_descs) / sizeof(supported_descs[0]);
}
/**
* default_camera() - XXX - Don't add more callers of this function.
* Return: Pointer to an arbitrary camera descriptor (right now, the only one).
*/
const struct ircam_desc *default_camera(void)
{
return &supported_descs[0];
}
/**
* lookup_camera_desc() - Return a descriptor matching the specified V4L2 dev.
* @param path Path to the V4L2 device to attempt to open.
*
* Return the driver descriptor for the V4L2 device.
*
* Return: Pointer to matching camera descriptor, or NULL if no match is found.
*/
const struct ircam_desc *lookup_camera_desc(const char *path)
{
unsigned int i;
for (i = 0; i < nr_camera_descs(); i++) {
if (v4l2_matches_desc(path, &supported_descs[i]))
return &supported_descs[i];
}
return NULL;
}