Make clang-format more aggressive
clang-format always manages to mix spaces into tab-based indentation. Since we already require an exact tab-width of 8 it makes more sense to use spaces.
This commit is contained in:
@@ -13,7 +13,7 @@ AccessModifierOffset: -4
|
|||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AlignConsecutiveAssignments: false
|
AlignConsecutiveAssignments: false
|
||||||
AlignConsecutiveDeclarations: false
|
AlignConsecutiveDeclarations: false
|
||||||
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
|
AlignEscapedNewlines: Right
|
||||||
AlignOperands: true
|
AlignOperands: true
|
||||||
AlignTrailingComments: false
|
AlignTrailingComments: false
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
@@ -26,8 +26,8 @@ AlwaysBreakAfterDefinitionReturnType: All
|
|||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
AlwaysBreakTemplateDeclarations: false
|
AlwaysBreakTemplateDeclarations: false
|
||||||
BinPackArguments: true
|
BinPackArguments: false
|
||||||
BinPackParameters: true
|
BinPackParameters: false
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
AfterClass: false
|
AfterClass: false
|
||||||
AfterControlStatement: false
|
AfterControlStatement: false
|
||||||
@@ -37,24 +37,24 @@ BraceWrapping:
|
|||||||
AfterObjCDeclaration: false
|
AfterObjCDeclaration: false
|
||||||
AfterStruct: false
|
AfterStruct: false
|
||||||
AfterUnion: false
|
AfterUnion: false
|
||||||
#AfterExternBlock: false # Unknown to clang-format-5.0
|
AfterExternBlock: false
|
||||||
BeforeCatch: false
|
BeforeCatch: false
|
||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
#SplitEmptyFunction: true # Unknown to clang-format-4.0
|
SplitEmptyFunction: true
|
||||||
#SplitEmptyRecord: true # Unknown to clang-format-4.0
|
SplitEmptyRecord: true
|
||||||
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
|
SplitEmptyNamespace: true
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
|
BreakBeforeInheritanceComma: false
|
||||||
BreakBeforeTernaryOperators: false
|
BreakBeforeTernaryOperators: false
|
||||||
BreakConstructorInitializersBeforeComma: false
|
BreakConstructorInitializersBeforeComma: false
|
||||||
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
|
BreakConstructorInitializers: BeforeComma
|
||||||
BreakAfterJavaFieldAnnotations: false
|
BreakAfterJavaFieldAnnotations: false
|
||||||
BreakStringLiterals: false
|
BreakStringLiterals: false
|
||||||
ColumnLimit: 85
|
ColumnLimit: 85
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
#CompactNamespaces: false # Unknown to clang-format-4.0
|
CompactNamespaces: false
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
ConstructorInitializerIndentWidth: 8
|
ConstructorInitializerIndentWidth: 8
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 8
|
||||||
@@ -62,7 +62,7 @@ Cpp11BracedListStyle: false
|
|||||||
DerivePointerAlignment: false
|
DerivePointerAlignment: false
|
||||||
DisableFormat: false
|
DisableFormat: false
|
||||||
ExperimentalAutoDetectBinPacking: false
|
ExperimentalAutoDetectBinPacking: false
|
||||||
#FixNamespaceComments: false # Unknown to clang-format-4.0
|
FixNamespaceComments: false
|
||||||
|
|
||||||
# Taken from:
|
# Taken from:
|
||||||
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
|
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
|
||||||
@@ -494,13 +494,13 @@ ForEachMacros:
|
|||||||
- 'xbc_node_for_each_key_value'
|
- 'xbc_node_for_each_key_value'
|
||||||
- 'zorro_for_each_dev'
|
- 'zorro_for_each_dev'
|
||||||
|
|
||||||
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
|
IncludeBlocks: Preserve
|
||||||
IncludeCategories:
|
IncludeCategories:
|
||||||
- Regex: '.*'
|
- Regex: '.*'
|
||||||
Priority: 1
|
Priority: 1
|
||||||
IncludeIsMainRegex: '(Test)?$'
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
IndentCaseLabels: false
|
IndentCaseLabels: false
|
||||||
#IndentPPDirectives: None # Unknown to clang-format-5.0
|
IndentPPDirectives: None
|
||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
JavaScriptQuotes: Leave
|
JavaScriptQuotes: Leave
|
||||||
@@ -510,31 +510,31 @@ MacroBlockBegin: ''
|
|||||||
MacroBlockEnd: ''
|
MacroBlockEnd: ''
|
||||||
MaxEmptyLinesToKeep: 1
|
MaxEmptyLinesToKeep: 1
|
||||||
NamespaceIndentation: None
|
NamespaceIndentation: None
|
||||||
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
|
ObjCBinPackProtocolList: Auto
|
||||||
ObjCBlockIndentWidth: 8
|
ObjCBlockIndentWidth: 8
|
||||||
ObjCSpaceAfterProperty: true
|
ObjCSpaceAfterProperty: true
|
||||||
ObjCSpaceBeforeProtocolList: true
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
|
||||||
# Taken from git's rules
|
# Taken from git's rules
|
||||||
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
|
#PenaltyBreakAssignment: 10
|
||||||
PenaltyBreakBeforeFirstCallParameter: 30
|
#PenaltyBreakBeforeFirstCallParameter: 30
|
||||||
PenaltyBreakComment: 10
|
#PenaltyBreakComment: 10
|
||||||
PenaltyBreakFirstLessLess: 0
|
#PenaltyBreakFirstLessLess: 0
|
||||||
PenaltyBreakString: 10
|
#PenaltyBreakString: 10
|
||||||
PenaltyExcessCharacter: 100
|
#PenaltyExcessCharacter: 100
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
#PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
|
||||||
PointerAlignment: Right
|
PointerAlignment: Right
|
||||||
ReflowComments: false
|
ReflowComments: true
|
||||||
SortIncludes: false
|
SortIncludes: true
|
||||||
#SortUsingDeclarations: false # Unknown to clang-format-4.0
|
SortUsingDeclarations: false
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
SpaceAfterTemplateKeyword: true
|
SpaceAfterTemplateKeyword: true
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
|
SpaceBeforeCtorInitializerColon: true
|
||||||
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
|
SpaceBeforeInheritanceColon: true
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
SpaceInEmptyParentheses: false
|
SpaceInEmptyParentheses: false
|
||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 1
|
||||||
SpacesInAngles: false
|
SpacesInAngles: false
|
||||||
@@ -544,5 +544,5 @@ SpacesInParentheses: false
|
|||||||
SpacesInSquareBrackets: false
|
SpacesInSquareBrackets: false
|
||||||
Standard: Cpp03
|
Standard: Cpp03
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: Always
|
UseTab: Never
|
||||||
...
|
...
|
||||||
|
@@ -1,9 +1,3 @@
|
|||||||
.build_template: &build_definition
|
|
||||||
script:
|
|
||||||
- meson build
|
|
||||||
- ninja -C build
|
|
||||||
- ninja -C build test
|
|
||||||
|
|
||||||
build:debian:
|
build:debian:
|
||||||
image: debian:bookworm-slim
|
image: debian:bookworm-slim
|
||||||
before_script:
|
before_script:
|
||||||
|
@@ -25,7 +25,8 @@ main()
|
|||||||
// for each pixel, there's room here to do some better debayering.
|
// for each pixel, there's room here to do some better debayering.
|
||||||
vec3 color = vec3(samples.w, (samples.y + samples.z) / 2.0, samples.x);
|
vec3 color = vec3(samples.w, (samples.y + samples.z) / 2.0, samples.x);
|
||||||
|
|
||||||
// Some crude blacklevel correction to make the preview a bit nicer, this should be an uniform
|
// Some crude blacklevel correction to make the preview a bit nicer, this
|
||||||
|
// should be an uniform
|
||||||
vec3 corrected = color - 0.02;
|
vec3 corrected = color - 0.02;
|
||||||
|
|
||||||
// Apply the color matrices
|
// Apply the color matrices
|
||||||
|
53
src/camera.c
53
src/camera.c
@@ -277,7 +277,8 @@ mp_camera_new(int video_fd, int subdev_fd)
|
|||||||
camera->has_set_mode = false;
|
camera->has_set_mode = false;
|
||||||
camera->num_buffers = 0;
|
camera->num_buffers = 0;
|
||||||
camera->use_mplane = use_mplane;
|
camera->use_mplane = use_mplane;
|
||||||
memset(camera->child_bg_pids, 0,
|
memset(camera->child_bg_pids,
|
||||||
|
0,
|
||||||
sizeof(camera->child_bg_pids[0]) * MAX_BG_TASKS);
|
sizeof(camera->child_bg_pids[0]) * MAX_BG_TASKS);
|
||||||
return camera;
|
return camera;
|
||||||
}
|
}
|
||||||
@@ -306,9 +307,11 @@ mp_camera_add_bg_task(MPCamera *camera, pid_t pid)
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// error == -1, still running == 0
|
// error == -1, still running == 0
|
||||||
if (waitpid(camera->child_bg_pids[i], &status,
|
if (waitpid(camera->child_bg_pids[i],
|
||||||
|
&status,
|
||||||
WNOHANG) <= 0)
|
WNOHANG) <= 0)
|
||||||
continue; // consider errored wait still running
|
continue; // consider errored wait still
|
||||||
|
// running
|
||||||
|
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
// replace exited
|
// replace exited
|
||||||
@@ -453,7 +456,8 @@ mp_camera_set_mode(MPCamera *camera, MPCameraMode *mode)
|
|||||||
struct v4l2_subdev_frame_interval interval = {};
|
struct v4l2_subdev_frame_interval interval = {};
|
||||||
interval.pad = 0;
|
interval.pad = 0;
|
||||||
interval.interval = mode->frame_interval;
|
interval.interval = mode->frame_interval;
|
||||||
if (xioctl(camera->subdev_fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
if (xioctl(camera->subdev_fd,
|
||||||
|
VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
||||||
&interval) == -1) {
|
&interval) == -1) {
|
||||||
errno_printerr("VIDIOC_SUBDEV_S_FRAME_INTERVAL");
|
errno_printerr("VIDIOC_SUBDEV_S_FRAME_INTERVAL");
|
||||||
return false;
|
return false;
|
||||||
@@ -477,13 +481,14 @@ mp_camera_set_mode(MPCamera *camera, MPCameraMode *mode)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some drivers like ov5640 don't allow you to set the frame format with
|
// Some drivers like ov5640 don't allow you to set the frame format
|
||||||
// too high a frame-rate, but that means the frame-rate won't be set
|
// with too high a frame-rate, but that means the frame-rate won't be
|
||||||
// after the format change. So we need to try again here if we didn't
|
// set after the format change. So we need to try again here if we
|
||||||
// succeed before. Ideally we'd be able to set both at once.
|
// didn't succeed before. Ideally we'd be able to set both at once.
|
||||||
if (!did_set_frame_rate) {
|
if (!did_set_frame_rate) {
|
||||||
interval.interval = mode->frame_interval;
|
interval.interval = mode->frame_interval;
|
||||||
if (xioctl(camera->subdev_fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
if (xioctl(camera->subdev_fd,
|
||||||
|
VIDIOC_SUBDEV_S_FRAME_INTERVAL,
|
||||||
&interval) == -1) {
|
&interval) == -1) {
|
||||||
errno_printerr("VIDIOC_SUBDEV_S_FRAME_INTERVAL");
|
errno_printerr("VIDIOC_SUBDEV_S_FRAME_INTERVAL");
|
||||||
}
|
}
|
||||||
@@ -561,14 +566,20 @@ mp_camera_start_capture(MPCamera *camera)
|
|||||||
|
|
||||||
if (camera->use_mplane) {
|
if (camera->use_mplane) {
|
||||||
camera->buffers[i].length = planes[0].length;
|
camera->buffers[i].length = planes[0].length;
|
||||||
camera->buffers[i].data =
|
camera->buffers[i].data = mmap(NULL,
|
||||||
mmap(NULL, planes[0].length, PROT_READ, MAP_SHARED,
|
planes[0].length,
|
||||||
camera->video_fd, planes[0].m.mem_offset);
|
PROT_READ,
|
||||||
|
MAP_SHARED,
|
||||||
|
camera->video_fd,
|
||||||
|
planes[0].m.mem_offset);
|
||||||
} else {
|
} else {
|
||||||
camera->buffers[i].length = buf.length;
|
camera->buffers[i].length = buf.length;
|
||||||
camera->buffers[i].data =
|
camera->buffers[i].data = mmap(NULL,
|
||||||
mmap(NULL, buf.length, PROT_READ, MAP_SHARED,
|
buf.length,
|
||||||
camera->video_fd, buf.m.offset);
|
PROT_READ,
|
||||||
|
MAP_SHARED,
|
||||||
|
camera->video_fd,
|
||||||
|
buf.m.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (camera->buffers[i].data == MAP_FAILED) {
|
if (camera->buffers[i].data == MAP_FAILED) {
|
||||||
@@ -792,7 +803,8 @@ get_subdev_modes(MPCamera *camera, bool (*check)(MPCamera *, MPCameraMode *))
|
|||||||
frame.pad = 0;
|
frame.pad = 0;
|
||||||
frame.code = fmt.code;
|
frame.code = fmt.code;
|
||||||
frame.which = V4L2_SUBDEV_FORMAT_TRY;
|
frame.which = V4L2_SUBDEV_FORMAT_TRY;
|
||||||
if (xioctl(camera->subdev_fd, VIDIOC_SUBDEV_ENUM_FRAME_SIZE,
|
if (xioctl(camera->subdev_fd,
|
||||||
|
VIDIOC_SUBDEV_ENUM_FRAME_SIZE,
|
||||||
&frame) == -1) {
|
&frame) == -1) {
|
||||||
if (errno != EINVAL) {
|
if (errno != EINVAL) {
|
||||||
errno_printerr(
|
errno_printerr(
|
||||||
@@ -875,7 +887,8 @@ get_video_modes(MPCamera *camera, bool (*check)(MPCamera *, MPCameraMode *))
|
|||||||
struct v4l2_frmsizeenum frame = {};
|
struct v4l2_frmsizeenum frame = {};
|
||||||
frame.index = frame_index;
|
frame.index = frame_index;
|
||||||
frame.pixel_format = fmt.pixelformat;
|
frame.pixel_format = fmt.pixelformat;
|
||||||
if (xioctl(camera->video_fd, VIDIOC_ENUM_FRAMESIZES,
|
if (xioctl(camera->video_fd,
|
||||||
|
VIDIOC_ENUM_FRAMESIZES,
|
||||||
&frame) == -1) {
|
&frame) == -1) {
|
||||||
if (errno != EINVAL) {
|
if (errno != EINVAL) {
|
||||||
errno_printerr("VIDIOC_ENUM_FRAMESIZES");
|
errno_printerr("VIDIOC_ENUM_FRAMESIZES");
|
||||||
@@ -1199,7 +1212,8 @@ mp_camera_list_controls(MPCamera *camera)
|
|||||||
};
|
};
|
||||||
|
|
||||||
strcpy(control.name, ctrl.name);
|
strcpy(control.name, ctrl.name);
|
||||||
memcpy(control.dimensions, ctrl.dims,
|
memcpy(control.dimensions,
|
||||||
|
ctrl.dims,
|
||||||
sizeof(uint32_t) * V4L2_CTRL_MAX_DIMS);
|
sizeof(uint32_t) * V4L2_CTRL_MAX_DIMS);
|
||||||
|
|
||||||
MPControlList *new_item = malloc(sizeof(MPControlList));
|
MPControlList *new_item = malloc(sizeof(MPControlList));
|
||||||
@@ -1261,7 +1275,8 @@ mp_camera_query_control(MPCamera *camera, uint32_t id, MPControl *control)
|
|||||||
control->element_size = ctrl.elem_size;
|
control->element_size = ctrl.elem_size;
|
||||||
control->element_count = ctrl.elems;
|
control->element_count = ctrl.elems;
|
||||||
control->dimensions_count = ctrl.nr_of_dims;
|
control->dimensions_count = ctrl.nr_of_dims;
|
||||||
memcpy(control->dimensions, ctrl.dims,
|
memcpy(control->dimensions,
|
||||||
|
ctrl.dims,
|
||||||
sizeof(uint32_t) * V4L2_CTRL_MAX_DIMS);
|
sizeof(uint32_t) * V4L2_CTRL_MAX_DIMS);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <linux/v4l2-subdev.h>
|
#include <linux/v4l2-subdev.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MP_PIXEL_FMT_UNSUPPORTED,
|
MP_PIXEL_FMT_UNSUPPORTED,
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
#include "camera_config.h"
|
#include "camera_config.h"
|
||||||
|
|
||||||
#include "ini.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "ini.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <glib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
static struct mp_camera_config cameras[MP_MAX_CAMERAS];
|
static struct mp_camera_config cameras[MP_MAX_CAMERAS];
|
||||||
static size_t num_cameras = 0;
|
static size_t num_cameras = 0;
|
||||||
@@ -37,8 +37,10 @@ find_config(char *conffile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for a config file in XDG_CONFIG_HOME
|
// Check for a config file in XDG_CONFIG_HOME
|
||||||
sprintf(conffile, "%s/megapixels/config/%s.ini",
|
sprintf(conffile,
|
||||||
g_get_user_config_dir(), buf);
|
"%s/megapixels/config/%s.ini",
|
||||||
|
g_get_user_config_dir(),
|
||||||
|
buf);
|
||||||
if (access(conffile, F_OK) != -1) {
|
if (access(conffile, F_OK) != -1) {
|
||||||
printf("Found config file at %s\n", conffile);
|
printf("Found config file at %s\n", conffile);
|
||||||
return true;
|
return true;
|
||||||
@@ -80,7 +82,9 @@ strtoint(const char *nptr, char **endptr, int base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
config_handle_camera_mode(const char *prefix, MPCameraMode *mode, const char *name,
|
config_handle_camera_mode(const char *prefix,
|
||||||
|
MPCameraMode *mode,
|
||||||
|
const char *name,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
int prefix_length = strlen(prefix);
|
int prefix_length = strlen(prefix);
|
||||||
@@ -109,7 +113,9 @@ config_handle_camera_mode(const char *prefix, MPCameraMode *mode, const char *na
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
config_ini_handler(void *user, const char *section, const char *name,
|
config_ini_handler(void *user,
|
||||||
|
const char *section,
|
||||||
|
const char *name,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
if (strcmp(section, "device") == 0) {
|
if (strcmp(section, "device") == 0) {
|
||||||
@@ -144,10 +150,10 @@ config_ini_handler(void *user, const char *section, const char *name,
|
|||||||
|
|
||||||
struct mp_camera_config *cc = &cameras[index];
|
struct mp_camera_config *cc = &cameras[index];
|
||||||
|
|
||||||
if (config_handle_camera_mode("capture-", &cc->capture_mode, name,
|
if (config_handle_camera_mode(
|
||||||
value)) {
|
"capture-", &cc->capture_mode, name, value)) {
|
||||||
} else if (config_handle_camera_mode("preview-", &cc->preview_mode,
|
} else if (config_handle_camera_mode(
|
||||||
name, value)) {
|
"preview-", &cc->preview_mode, name, value)) {
|
||||||
} else if (strcmp(name, "rotate") == 0) {
|
} else if (strcmp(name, "rotate") == 0) {
|
||||||
cc->rotate = strtoint(value, NULL, 10);
|
cc->rotate = strtoint(value, NULL, 10);
|
||||||
} else if (strcmp(name, "mirrored") == 0) {
|
} else if (strcmp(name, "mirrored") == 0) {
|
||||||
@@ -179,18 +185,28 @@ config_ini_handler(void *user, const char *section, const char *name,
|
|||||||
}
|
}
|
||||||
g_strfreev(linkdefs);
|
g_strfreev(linkdefs);
|
||||||
} else if (strcmp(name, "colormatrix") == 0) {
|
} else if (strcmp(name, "colormatrix") == 0) {
|
||||||
sscanf(value, "%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
sscanf(value,
|
||||||
cc->colormatrix + 0, cc->colormatrix + 1,
|
"%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||||
cc->colormatrix + 2, cc->colormatrix + 3,
|
cc->colormatrix + 0,
|
||||||
cc->colormatrix + 4, cc->colormatrix + 5,
|
cc->colormatrix + 1,
|
||||||
cc->colormatrix + 6, cc->colormatrix + 7,
|
cc->colormatrix + 2,
|
||||||
|
cc->colormatrix + 3,
|
||||||
|
cc->colormatrix + 4,
|
||||||
|
cc->colormatrix + 5,
|
||||||
|
cc->colormatrix + 6,
|
||||||
|
cc->colormatrix + 7,
|
||||||
cc->colormatrix + 8);
|
cc->colormatrix + 8);
|
||||||
} else if (strcmp(name, "forwardmatrix") == 0) {
|
} else if (strcmp(name, "forwardmatrix") == 0) {
|
||||||
sscanf(value, "%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
sscanf(value,
|
||||||
cc->forwardmatrix + 0, cc->forwardmatrix + 1,
|
"%f,%f,%f,%f,%f,%f,%f,%f,%f",
|
||||||
cc->forwardmatrix + 2, cc->forwardmatrix + 3,
|
cc->forwardmatrix + 0,
|
||||||
cc->forwardmatrix + 4, cc->forwardmatrix + 5,
|
cc->forwardmatrix + 1,
|
||||||
cc->forwardmatrix + 6, cc->forwardmatrix + 7,
|
cc->forwardmatrix + 2,
|
||||||
|
cc->forwardmatrix + 3,
|
||||||
|
cc->forwardmatrix + 4,
|
||||||
|
cc->forwardmatrix + 5,
|
||||||
|
cc->forwardmatrix + 6,
|
||||||
|
cc->forwardmatrix + 7,
|
||||||
cc->forwardmatrix + 8);
|
cc->forwardmatrix + 8);
|
||||||
} else if (strcmp(name, "whitelevel") == 0) {
|
} else if (strcmp(name, "whitelevel") == 0) {
|
||||||
cc->whitelevel = strtoint(value, NULL, 10);
|
cc->whitelevel = strtoint(value, NULL, 10);
|
||||||
|
@@ -12,7 +12,10 @@ bool
|
|||||||
mp_find_device_path(struct media_v2_intf_devnode devnode, char *path, int length)
|
mp_find_device_path(struct media_v2_intf_devnode devnode, char *path, int length)
|
||||||
{
|
{
|
||||||
char uevent_path[256];
|
char uevent_path[256];
|
||||||
snprintf(uevent_path, 256, "/sys/dev/char/%d:%d/uevent", devnode.major,
|
snprintf(uevent_path,
|
||||||
|
256,
|
||||||
|
"/sys/dev/char/%d:%d/uevent",
|
||||||
|
devnode.major,
|
||||||
devnode.minor);
|
devnode.minor);
|
||||||
|
|
||||||
FILE *f = fopen(uevent_path, "r");
|
FILE *f = fopen(uevent_path, "r");
|
||||||
@@ -151,7 +154,9 @@ mp_device_close(MPDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
mp_device_setup_link(MPDevice *device, uint32_t source_pad_id, uint32_t sink_pad_id,
|
mp_device_setup_link(MPDevice *device,
|
||||||
|
uint32_t source_pad_id,
|
||||||
|
uint32_t sink_pad_id,
|
||||||
bool enabled)
|
bool enabled)
|
||||||
{
|
{
|
||||||
const struct media_v2_pad *source_pad =
|
const struct media_v2_pad *source_pad =
|
||||||
|
10
src/device.h
10
src/device.h
@@ -5,8 +5,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
bool mp_find_device_path(struct media_v2_intf_devnode devnode, char *path,
|
bool
|
||||||
int length);
|
mp_find_device_path(struct media_v2_intf_devnode devnode, char *path, int length);
|
||||||
|
|
||||||
typedef struct _MPDevice MPDevice;
|
typedef struct _MPDevice MPDevice;
|
||||||
|
|
||||||
@@ -15,8 +15,10 @@ MPDevice *mp_device_open(const char *path);
|
|||||||
MPDevice *mp_device_new(int fd);
|
MPDevice *mp_device_new(int fd);
|
||||||
void mp_device_close(MPDevice *device);
|
void mp_device_close(MPDevice *device);
|
||||||
|
|
||||||
bool mp_device_setup_link(MPDevice *device, uint32_t source_pad_id,
|
bool mp_device_setup_link(MPDevice *device,
|
||||||
uint32_t sink_pad_id, bool enabled);
|
uint32_t source_pad_id,
|
||||||
|
uint32_t sink_pad_id,
|
||||||
|
bool enabled);
|
||||||
|
|
||||||
const struct media_device_info *mp_device_get_info(const MPDevice *device);
|
const struct media_device_info *mp_device_get_info(const MPDevice *device);
|
||||||
const struct media_v2_entity *mp_device_find_entity(const MPDevice *device,
|
const struct media_v2_entity *mp_device_find_entity(const MPDevice *device,
|
||||||
|
44
src/flash.c
44
src/flash.c
@@ -1,10 +1,10 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
#include "gtk/gtk.h"
|
#include "gtk/gtk.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FLASH_TYPE_LED,
|
FLASH_TYPE_LED,
|
||||||
@@ -68,11 +68,15 @@ dbus_brightness_init(GObject *src, GAsyncResult *res, gpointer *user_data)
|
|||||||
void
|
void
|
||||||
mp_flash_gtk_init(GDBusConnection *conn)
|
mp_flash_gtk_init(GDBusConnection *conn)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_new(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
|
g_dbus_proxy_new(conn,
|
||||||
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
|
NULL,
|
||||||
"org.gnome.SettingsDaemon.Power",
|
"org.gnome.SettingsDaemon.Power",
|
||||||
"/org/gnome/SettingsDaemon/Power",
|
"/org/gnome/SettingsDaemon/Power",
|
||||||
"org.gnome.SettingsDaemon.Power.Screen", NULL,
|
"org.gnome.SettingsDaemon.Power.Screen",
|
||||||
(GAsyncReadyCallback)dbus_brightness_init, NULL);
|
NULL,
|
||||||
|
(GAsyncReadyCallback)dbus_brightness_init,
|
||||||
|
NULL);
|
||||||
|
|
||||||
// Create a full screen full white window as a flash
|
// Create a full screen full white window as a flash
|
||||||
GtkWidget *window = gtk_window_new();
|
GtkWidget *window = gtk_window_new();
|
||||||
@@ -120,11 +124,17 @@ mp_flash_free(MPFlash *flash)
|
|||||||
static void
|
static void
|
||||||
set_display_brightness(int brightness)
|
set_display_brightness(int brightness)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_call(
|
g_dbus_proxy_call(dbus_brightness_proxy,
|
||||||
dbus_brightness_proxy, "org.freedesktop.DBus.Properties.Set",
|
"org.freedesktop.DBus.Properties.Set",
|
||||||
g_variant_new("(ssv)", "org.gnome.SettingsDaemon.Power.Screen",
|
g_variant_new("(ssv)",
|
||||||
"Brightness", g_variant_new("i", brightness)),
|
"org.gnome.SettingsDaemon.Power.Screen",
|
||||||
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
|
"Brightness",
|
||||||
|
g_variant_new("i", brightness)),
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
-1,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -162,12 +172,16 @@ show_display_flash(MPFlash *flash)
|
|||||||
if (!dbus_brightness_proxy)
|
if (!dbus_brightness_proxy)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_dbus_proxy_call(
|
g_dbus_proxy_call(dbus_brightness_proxy,
|
||||||
dbus_brightness_proxy, "org.freedesktop.DBus.Properties.Get",
|
"org.freedesktop.DBus.Properties.Get",
|
||||||
g_variant_new("(ss)", "org.gnome.SettingsDaemon.Power.Screen",
|
g_variant_new("(ss)",
|
||||||
|
"org.gnome.SettingsDaemon.Power.Screen",
|
||||||
"Brightness"),
|
"Brightness"),
|
||||||
G_DBUS_CALL_FLAGS_NONE, -1, NULL,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
(GAsyncReadyCallback)brightness_received, NULL);
|
-1,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)brightness_received,
|
||||||
|
NULL);
|
||||||
|
|
||||||
set_display_brightness(100);
|
set_display_brightness(100);
|
||||||
|
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
#include "gl_util.h"
|
#include "gl_util.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <gdk/gdk.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <gmodule.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <gio/gio.h>
|
|
||||||
#include <gmodule.h>
|
|
||||||
#include <gdk/gdk.h>
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gl_util_check_error(const char *file, int line)
|
gl_util_check_error(const char *file, int line)
|
||||||
@@ -43,7 +43,9 @@ gl_util_check_error(const char *file, int line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLuint
|
GLuint
|
||||||
gl_util_load_shader(const char *resource, GLenum type, const char **extra_sources,
|
gl_util_load_shader(const char *resource,
|
||||||
|
GLenum type,
|
||||||
|
const char **extra_sources,
|
||||||
size_t num_extra)
|
size_t num_extra)
|
||||||
{
|
{
|
||||||
GdkGLContext *context = gdk_gl_context_get_current();
|
GdkGLContext *context = gdk_gl_context_get_current();
|
||||||
@@ -65,9 +67,13 @@ gl_util_load_shader(const char *resource, GLenum type, const char **extra_source
|
|||||||
int major, minor;
|
int major, minor;
|
||||||
gdk_gl_context_get_version(context, &major, &minor);
|
gdk_gl_context_get_version(context, &major, &minor);
|
||||||
char context_info_buf[128];
|
char context_info_buf[128];
|
||||||
snprintf(context_info_buf, 128,
|
snprintf(context_info_buf,
|
||||||
|
128,
|
||||||
"#define %s\n#define GL_%d\n#define GL_%d_%d\n",
|
"#define %s\n#define GL_%d\n#define GL_%d_%d\n",
|
||||||
is_es ? "GL_ES" : "GL_NO_ES", major, major, minor);
|
is_es ? "GL_ES" : "GL_NO_ES",
|
||||||
|
major,
|
||||||
|
major,
|
||||||
|
minor);
|
||||||
|
|
||||||
gsize glib_size = 0;
|
gsize glib_size = 0;
|
||||||
const GLchar *source = g_bytes_get_data(bytes, &glib_size);
|
const GLchar *source = g_bytes_get_data(bytes, &glib_size);
|
||||||
@@ -187,7 +193,9 @@ gl_util_new_quad()
|
|||||||
glGenBuffers(1, &buffer);
|
glGenBuffers(1, &buffer);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(quad_data), quad_data,
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
|
sizeof(quad_data),
|
||||||
|
quad_data,
|
||||||
GL_STATIC_DRAW);
|
GL_STATIC_DRAW);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
@@ -205,13 +213,17 @@ gl_util_bind_quad(GLuint buffer)
|
|||||||
assert(context);
|
assert(context);
|
||||||
|
|
||||||
if (gdk_gl_context_get_use_es(context)) {
|
if (gdk_gl_context_get_use_es(context)) {
|
||||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT, 0, 0,
|
glVertexAttribPointer(
|
||||||
quad_data);
|
GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT, 0, 0, quad_data);
|
||||||
check_gl();
|
check_gl();
|
||||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE, 2, GL_FLOAT, 0, 0,
|
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE,
|
||||||
|
2,
|
||||||
|
GL_FLOAT,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
quad_data + 8);
|
quad_data + 8);
|
||||||
check_gl();
|
check_gl();
|
||||||
glEnableVertexAttribArray(GL_UTIL_TEX_COORD_ATTRIBUTE);
|
glEnableVertexAttribArray(GL_UTIL_TEX_COORD_ATTRIBUTE);
|
||||||
@@ -220,13 +232,17 @@ gl_util_bind_quad(GLuint buffer)
|
|||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT,
|
glVertexAttribPointer(
|
||||||
GL_FALSE, 0, 0);
|
GL_UTIL_VERTEX_ATTRIBUTE, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE, 2, GL_FLOAT,
|
glVertexAttribPointer(GL_UTIL_TEX_COORD_ATTRIBUTE,
|
||||||
GL_FALSE, 0, (void *)(8 * sizeof(float)));
|
2,
|
||||||
|
GL_FLOAT,
|
||||||
|
GL_FALSE,
|
||||||
|
0,
|
||||||
|
(void *)(8 * sizeof(float)));
|
||||||
glEnableVertexAttribArray(GL_UTIL_TEX_COORD_ATTRIBUTE);
|
glEnableVertexAttribArray(GL_UTIL_TEX_COORD_ATTRIBUTE);
|
||||||
check_gl();
|
check_gl();
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,10 @@
|
|||||||
#define check_gl() gl_util_check_error(__FILE__, __LINE__)
|
#define check_gl() gl_util_check_error(__FILE__, __LINE__)
|
||||||
void gl_util_check_error(const char *file, int line);
|
void gl_util_check_error(const char *file, int line);
|
||||||
|
|
||||||
GLuint gl_util_load_shader(const char *resource, GLenum type,
|
GLuint gl_util_load_shader(const char *resource,
|
||||||
const char **extra_sources, size_t num_extra);
|
GLenum type,
|
||||||
|
const char **extra_sources,
|
||||||
|
size_t num_extra);
|
||||||
GLuint gl_util_link_program(GLuint *shaders, size_t num_shaders);
|
GLuint gl_util_link_program(GLuint *shaders, size_t num_shaders);
|
||||||
|
|
||||||
GLuint gl_util_new_quad();
|
GLuint gl_util_new_quad();
|
||||||
|
@@ -31,9 +31,13 @@ gles2_debayer_new(MPPixelFormat format)
|
|||||||
|
|
||||||
GLuint shaders[] = {
|
GLuint shaders[] = {
|
||||||
gl_util_load_shader("/org/postmarketos/Megapixels/debayer.vert",
|
gl_util_load_shader("/org/postmarketos/Megapixels/debayer.vert",
|
||||||
GL_VERTEX_SHADER, NULL, 0),
|
GL_VERTEX_SHADER,
|
||||||
|
NULL,
|
||||||
|
0),
|
||||||
gl_util_load_shader("/org/postmarketos/Megapixels/debayer.frag",
|
gl_util_load_shader("/org/postmarketos/Megapixels/debayer.frag",
|
||||||
GL_FRAGMENT_SHADER, NULL, 0),
|
GL_FRAGMENT_SHADER,
|
||||||
|
NULL,
|
||||||
|
0),
|
||||||
};
|
};
|
||||||
|
|
||||||
GLuint program = gl_util_link_program(shaders, 2);
|
GLuint program = gl_util_link_program(shaders, 2);
|
||||||
@@ -77,10 +81,14 @@ gles2_debayer_use(GLES2Debayer *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
gles2_debayer_configure(GLES2Debayer *self,
|
||||||
const uint32_t dst_height, const uint32_t src_width,
|
const uint32_t dst_width,
|
||||||
const uint32_t src_height, const uint32_t rotation,
|
const uint32_t dst_height,
|
||||||
const bool mirrored, const float *colormatrix,
|
const uint32_t src_width,
|
||||||
|
const uint32_t src_height,
|
||||||
|
const uint32_t rotation,
|
||||||
|
const bool mirrored,
|
||||||
|
const float *colormatrix,
|
||||||
const uint8_t blacklevel)
|
const uint8_t blacklevel)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, dst_width, dst_height);
|
glViewport(0, 0, dst_width, dst_height);
|
||||||
@@ -113,8 +121,8 @@ gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
|||||||
for (int j = 0; j < 3; ++j)
|
for (int j = 0; j < 3; ++j)
|
||||||
transposed[i + j * 3] = colormatrix[j + i * 3];
|
transposed[i + j * 3] = colormatrix[j + i * 3];
|
||||||
|
|
||||||
glUniformMatrix3fv(self->uniform_color_matrix, 1, GL_FALSE,
|
glUniformMatrix3fv(
|
||||||
transposed);
|
self->uniform_color_matrix, 1, GL_FALSE, transposed);
|
||||||
} else {
|
} else {
|
||||||
static const GLfloat identity[9] = {
|
static const GLfloat identity[9] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@@ -123,8 +131,8 @@ gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
|||||||
0, 0, 1,
|
0, 0, 1,
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
glUniformMatrix3fv(self->uniform_color_matrix, 1, GL_FALSE,
|
glUniformMatrix3fv(
|
||||||
identity);
|
self->uniform_color_matrix, 1, GL_FALSE, identity);
|
||||||
}
|
}
|
||||||
check_gl();
|
check_gl();
|
||||||
}
|
}
|
||||||
@@ -134,8 +142,8 @@ gles2_debayer_process(GLES2Debayer *self, GLuint dst_id, GLuint source_id)
|
|||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, self->frame_buffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, self->frame_buffer);
|
||||||
glBindTexture(GL_TEXTURE_2D, dst_id);
|
glBindTexture(GL_TEXTURE_2D, dst_id);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(
|
||||||
dst_id, 0);
|
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_id, 0);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
|
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
|
||||||
|
@@ -10,10 +10,14 @@ void gles2_debayer_free(GLES2Debayer *self);
|
|||||||
|
|
||||||
void gles2_debayer_use(GLES2Debayer *self);
|
void gles2_debayer_use(GLES2Debayer *self);
|
||||||
|
|
||||||
void gles2_debayer_configure(GLES2Debayer *self, const uint32_t dst_width,
|
void gles2_debayer_configure(GLES2Debayer *self,
|
||||||
const uint32_t dst_height, const uint32_t src_width,
|
const uint32_t dst_width,
|
||||||
const uint32_t src_height, const uint32_t rotation,
|
const uint32_t dst_height,
|
||||||
const bool mirrored, const float *colormatrix,
|
const uint32_t src_width,
|
||||||
|
const uint32_t src_height,
|
||||||
|
const uint32_t rotation,
|
||||||
|
const bool mirrored,
|
||||||
|
const float *colormatrix,
|
||||||
const uint8_t blacklevel);
|
const uint8_t blacklevel);
|
||||||
|
|
||||||
void gles2_debayer_process(GLES2Debayer *self, GLuint dst_id, GLuint source_id);
|
void gles2_debayer_process(GLES2Debayer *self, GLuint dst_id, GLuint source_id);
|
||||||
|
@@ -147,7 +147,8 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
|||||||
|
|
||||||
info->video_fd = open(dev_name, O_RDWR);
|
info->video_fd = open(dev_name, O_RDWR);
|
||||||
if (info->video_fd == -1) {
|
if (info->video_fd == -1) {
|
||||||
g_printerr("Could not open %s: %s\n", dev_name,
|
g_printerr("Could not open %s: %s\n",
|
||||||
|
dev_name,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -175,8 +176,10 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
|||||||
info->pad_id = pad->id;
|
info->pad_id = pad->id;
|
||||||
|
|
||||||
// Make sure the camera starts out as disabled
|
// Make sure the camera starts out as disabled
|
||||||
mp_device_setup_link(dev_info->device, info->pad_id,
|
mp_device_setup_link(dev_info->device,
|
||||||
dev_info->interface_pad_id, false);
|
info->pad_id,
|
||||||
|
dev_info->interface_pad_id,
|
||||||
|
false);
|
||||||
|
|
||||||
const struct media_v2_interface *interface =
|
const struct media_v2_interface *interface =
|
||||||
mp_device_find_entity_interface(dev_info->device,
|
mp_device_find_entity_interface(dev_info->device,
|
||||||
@@ -189,7 +192,8 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
|||||||
|
|
||||||
info->fd = open(info->dev_fname, O_RDWR);
|
info->fd = open(info->dev_fname, O_RDWR);
|
||||||
if (info->fd == -1) {
|
if (info->fd == -1) {
|
||||||
g_printerr("Could not open %s: %s\n", info->dev_fname,
|
g_printerr("Could not open %s: %s\n",
|
||||||
|
info->dev_fname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -203,14 +207,14 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
|
|||||||
mp_camera_set_mode(info->camera, &mode);
|
mp_camera_set_mode(info->camera, &mode);
|
||||||
|
|
||||||
// Trigger continuous auto focus if the sensor supports it
|
// Trigger continuous auto focus if the sensor supports it
|
||||||
if (mp_camera_query_control(info->camera, V4L2_CID_FOCUS_AUTO,
|
if (mp_camera_query_control(
|
||||||
NULL)) {
|
info->camera, V4L2_CID_FOCUS_AUTO, NULL)) {
|
||||||
info->has_auto_focus_continuous = true;
|
info->has_auto_focus_continuous = true;
|
||||||
mp_camera_control_set_bool_bg(info->camera,
|
mp_camera_control_set_bool_bg(
|
||||||
V4L2_CID_FOCUS_AUTO, true);
|
info->camera, V4L2_CID_FOCUS_AUTO, true);
|
||||||
}
|
}
|
||||||
if (mp_camera_query_control(info->camera, V4L2_CID_AUTO_FOCUS_START,
|
if (mp_camera_query_control(
|
||||||
NULL)) {
|
info->camera, V4L2_CID_AUTO_FOCUS_START, NULL)) {
|
||||||
info->has_auto_focus_start = true;
|
info->has_auto_focus_start = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,8 +347,8 @@ capture(MPPipeline *pipeline, const void *data)
|
|||||||
|
|
||||||
// Disable the autogain/exposure while taking the burst
|
// Disable the autogain/exposure while taking the burst
|
||||||
mp_camera_control_set_int32(info->camera, V4L2_CID_AUTOGAIN, 0);
|
mp_camera_control_set_int32(info->camera, V4L2_CID_AUTOGAIN, 0);
|
||||||
mp_camera_control_set_int32(info->camera, V4L2_CID_EXPOSURE_AUTO,
|
mp_camera_control_set_int32(
|
||||||
V4L2_EXPOSURE_MANUAL);
|
info->camera, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
|
||||||
|
|
||||||
// Change camera mode for capturing
|
// Change camera mode for capturing
|
||||||
mp_process_pipeline_sync();
|
mp_process_pipeline_sync();
|
||||||
@@ -383,8 +387,10 @@ release_buffer(MPPipeline *pipeline, const uint32_t *buffer_index)
|
|||||||
void
|
void
|
||||||
mp_io_pipeline_release_buffer(uint32_t buffer_index)
|
mp_io_pipeline_release_buffer(uint32_t buffer_index)
|
||||||
{
|
{
|
||||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)release_buffer,
|
mp_pipeline_invoke(pipeline,
|
||||||
&buffer_index, sizeof(uint32_t));
|
(MPPipelineCallback)release_buffer,
|
||||||
|
&buffer_index,
|
||||||
|
sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pid_t focus_continuous_task = 0;
|
static pid_t focus_continuous_task = 0;
|
||||||
@@ -422,19 +428,21 @@ update_controls()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (current_controls.gain_is_manual != desired_controls.gain_is_manual) {
|
if (current_controls.gain_is_manual != desired_controls.gain_is_manual) {
|
||||||
mp_camera_control_set_bool_bg(info->camera, V4L2_CID_AUTOGAIN,
|
mp_camera_control_set_bool_bg(info->camera,
|
||||||
|
V4L2_CID_AUTOGAIN,
|
||||||
!desired_controls.gain_is_manual);
|
!desired_controls.gain_is_manual);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desired_controls.gain_is_manual &&
|
if (desired_controls.gain_is_manual &&
|
||||||
current_controls.gain != desired_controls.gain) {
|
current_controls.gain != desired_controls.gain) {
|
||||||
mp_camera_control_set_int32_bg(info->camera, info->gain_ctrl,
|
mp_camera_control_set_int32_bg(
|
||||||
desired_controls.gain);
|
info->camera, info->gain_ctrl, desired_controls.gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_controls.exposure_is_manual !=
|
if (current_controls.exposure_is_manual !=
|
||||||
desired_controls.exposure_is_manual) {
|
desired_controls.exposure_is_manual) {
|
||||||
mp_camera_control_set_int32_bg(info->camera, V4L2_CID_EXPOSURE_AUTO,
|
mp_camera_control_set_int32_bg(info->camera,
|
||||||
|
V4L2_CID_EXPOSURE_AUTO,
|
||||||
desired_controls.exposure_is_manual ?
|
desired_controls.exposure_is_manual ?
|
||||||
V4L2_EXPOSURE_MANUAL :
|
V4L2_EXPOSURE_MANUAL :
|
||||||
V4L2_EXPOSURE_AUTO);
|
V4L2_EXPOSURE_AUTO);
|
||||||
@@ -442,8 +450,8 @@ update_controls()
|
|||||||
|
|
||||||
if (desired_controls.exposure_is_manual &&
|
if (desired_controls.exposure_is_manual &&
|
||||||
current_controls.exposure != desired_controls.exposure) {
|
current_controls.exposure != desired_controls.exposure) {
|
||||||
mp_camera_control_set_int32_bg(info->camera, V4L2_CID_EXPOSURE,
|
mp_camera_control_set_int32_bg(
|
||||||
desired_controls.exposure);
|
info->camera, V4L2_CID_EXPOSURE, desired_controls.exposure);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_controls = desired_controls;
|
current_controls = desired_controls;
|
||||||
@@ -494,7 +502,8 @@ on_frame(MPBuffer buffer, void *_data)
|
|||||||
// Restore the auto exposure and gain if needed
|
// Restore the auto exposure and gain if needed
|
||||||
if (!current_controls.exposure_is_manual) {
|
if (!current_controls.exposure_is_manual) {
|
||||||
mp_camera_control_set_int32_bg(
|
mp_camera_control_set_int32_bg(
|
||||||
info->camera, V4L2_CID_EXPOSURE_AUTO,
|
info->camera,
|
||||||
|
V4L2_CID_EXPOSURE_AUTO,
|
||||||
V4L2_EXPOSURE_AUTO);
|
V4L2_EXPOSURE_AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,8 +548,10 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
|||||||
|
|
||||||
mp_process_pipeline_sync();
|
mp_process_pipeline_sync();
|
||||||
mp_camera_stop_capture(info->camera);
|
mp_camera_stop_capture(info->camera);
|
||||||
mp_device_setup_link(dev_info->device, info->pad_id,
|
mp_device_setup_link(dev_info->device,
|
||||||
dev_info->interface_pad_id, false);
|
info->pad_id,
|
||||||
|
dev_info->interface_pad_id,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capture_source) {
|
if (capture_source) {
|
||||||
@@ -554,8 +565,10 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
|||||||
struct camera_info *info = &cameras[camera->index];
|
struct camera_info *info = &cameras[camera->index];
|
||||||
struct device_info *dev_info = &devices[info->device_index];
|
struct device_info *dev_info = &devices[info->device_index];
|
||||||
|
|
||||||
mp_device_setup_link(dev_info->device, info->pad_id,
|
mp_device_setup_link(dev_info->device,
|
||||||
dev_info->interface_pad_id, true);
|
info->pad_id,
|
||||||
|
dev_info->interface_pad_id,
|
||||||
|
true);
|
||||||
|
|
||||||
mode = camera->preview_mode;
|
mode = camera->preview_mode;
|
||||||
mp_camera_set_mode(info->camera, &mode);
|
mp_camera_set_mode(info->camera, &mode);
|
||||||
@@ -599,7 +612,8 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
|||||||
desired_controls.exposure = state->exposure;
|
desired_controls.exposure = state->exposure;
|
||||||
|
|
||||||
has_changed = has_changed ||
|
has_changed = has_changed ||
|
||||||
memcmp(&previous_desired, &desired_controls,
|
memcmp(&previous_desired,
|
||||||
|
&desired_controls,
|
||||||
sizeof(struct control_state)) != 0 ||
|
sizeof(struct control_state)) != 0 ||
|
||||||
flash_enabled != state->flash_enabled;
|
flash_enabled != state->flash_enabled;
|
||||||
|
|
||||||
@@ -614,6 +628,8 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
|
|||||||
void
|
void
|
||||||
mp_io_pipeline_update_state(const struct mp_io_pipeline_state *state)
|
mp_io_pipeline_update_state(const struct mp_io_pipeline_state *state)
|
||||||
{
|
{
|
||||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)update_state, state,
|
mp_pipeline_invoke(pipeline,
|
||||||
|
(MPPipelineCallback)update_state,
|
||||||
|
state,
|
||||||
sizeof(struct mp_io_pipeline_state));
|
sizeof(struct mp_io_pipeline_state));
|
||||||
}
|
}
|
||||||
|
247
src/main.c
247
src/main.c
@@ -154,8 +154,11 @@ mp_main_update_state(const struct mp_main_state *state)
|
|||||||
struct mp_main_state *state_copy = malloc(sizeof(struct mp_main_state));
|
struct mp_main_state *state_copy = malloc(sizeof(struct mp_main_state));
|
||||||
*state_copy = *state;
|
*state_copy = *state;
|
||||||
|
|
||||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
g_main_context_invoke_full(g_main_context_default(),
|
||||||
(GSourceFunc)update_state, state_copy, free);
|
G_PRIORITY_DEFAULT_IDLE,
|
||||||
|
(GSourceFunc)update_state,
|
||||||
|
state_copy,
|
||||||
|
free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -178,8 +181,11 @@ set_zbar_result(MPZBarScanResult *result)
|
|||||||
void
|
void
|
||||||
mp_main_set_zbar_result(MPZBarScanResult *result)
|
mp_main_set_zbar_result(MPZBarScanResult *result)
|
||||||
{
|
{
|
||||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
g_main_context_invoke_full(g_main_context_default(),
|
||||||
(GSourceFunc)set_zbar_result, result, NULL);
|
G_PRIORITY_DEFAULT_IDLE,
|
||||||
|
(GSourceFunc)set_zbar_result,
|
||||||
|
result,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -196,8 +202,11 @@ set_preview(MPProcessPipelineBuffer *buffer)
|
|||||||
void
|
void
|
||||||
mp_main_set_preview(MPProcessPipelineBuffer *buffer)
|
mp_main_set_preview(MPProcessPipelineBuffer *buffer)
|
||||||
{
|
{
|
||||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
g_main_context_invoke_full(g_main_context_default(),
|
||||||
(GSourceFunc)set_preview, buffer, NULL);
|
G_PRIORITY_DEFAULT_IDLE,
|
||||||
|
(GSourceFunc)set_preview,
|
||||||
|
buffer,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct capture_completed_args {
|
struct capture_completed_args {
|
||||||
@@ -229,8 +238,11 @@ mp_main_capture_completed(GdkTexture *thumb, const char *fname)
|
|||||||
malloc(sizeof(struct capture_completed_args));
|
malloc(sizeof(struct capture_completed_args));
|
||||||
args->thumb = thumb;
|
args->thumb = thumb;
|
||||||
args->fname = g_strdup(fname);
|
args->fname = g_strdup(fname);
|
||||||
g_main_context_invoke_full(g_main_context_default(), G_PRIORITY_DEFAULT_IDLE,
|
g_main_context_invoke_full(g_main_context_default(),
|
||||||
(GSourceFunc)capture_completed, args, free);
|
G_PRIORITY_DEFAULT_IDLE,
|
||||||
|
(GSourceFunc)capture_completed,
|
||||||
|
args,
|
||||||
|
free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLuint blit_program;
|
static GLuint blit_program;
|
||||||
@@ -259,9 +271,13 @@ preview_realize(GtkGLArea *area)
|
|||||||
|
|
||||||
GLuint blit_shaders[] = {
|
GLuint blit_shaders[] = {
|
||||||
gl_util_load_shader("/org/postmarketos/Megapixels/blit.vert",
|
gl_util_load_shader("/org/postmarketos/Megapixels/blit.vert",
|
||||||
GL_VERTEX_SHADER, NULL, 0),
|
GL_VERTEX_SHADER,
|
||||||
|
NULL,
|
||||||
|
0),
|
||||||
gl_util_load_shader("/org/postmarketos/Megapixels/blit.frag",
|
gl_util_load_shader("/org/postmarketos/Megapixels/blit.frag",
|
||||||
GL_FRAGMENT_SHADER, NULL, 0),
|
GL_FRAGMENT_SHADER,
|
||||||
|
NULL,
|
||||||
|
0),
|
||||||
};
|
};
|
||||||
|
|
||||||
blit_program = gl_util_link_program(blit_shaders, 2);
|
blit_program = gl_util_link_program(blit_shaders, 2);
|
||||||
@@ -274,9 +290,13 @@ preview_realize(GtkGLArea *area)
|
|||||||
|
|
||||||
GLuint solid_shaders[] = {
|
GLuint solid_shaders[] = {
|
||||||
gl_util_load_shader("/org/postmarketos/Megapixels/solid.vert",
|
gl_util_load_shader("/org/postmarketos/Megapixels/solid.vert",
|
||||||
GL_VERTEX_SHADER, NULL, 0),
|
GL_VERTEX_SHADER,
|
||||||
|
NULL,
|
||||||
|
0),
|
||||||
gl_util_load_shader("/org/postmarketos/Megapixels/solid.frag",
|
gl_util_load_shader("/org/postmarketos/Megapixels/solid.frag",
|
||||||
GL_FRAGMENT_SHADER, NULL, 0),
|
GL_FRAGMENT_SHADER,
|
||||||
|
NULL,
|
||||||
|
0),
|
||||||
};
|
};
|
||||||
|
|
||||||
solid_program = gl_util_link_program(solid_shaders, 2);
|
solid_program = gl_util_link_program(solid_shaders, 2);
|
||||||
@@ -409,18 +429,28 @@ preview_draw(GtkGLArea *area, GdkGLContext *ctx, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_gl_area_get_use_es(area)) {
|
if (gtk_gl_area_get_use_es(area)) {
|
||||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2,
|
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE,
|
||||||
GL_FLOAT, 0, 0, vertices);
|
2,
|
||||||
|
GL_FLOAT,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
vertices);
|
||||||
check_gl();
|
check_gl();
|
||||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||||
check_gl();
|
check_gl();
|
||||||
} else {
|
} else {
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
vertices, GL_STREAM_DRAW);
|
sizeof(vertices),
|
||||||
|
vertices,
|
||||||
|
GL_STREAM_DRAW);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE, 2,
|
glVertexAttribPointer(GL_UTIL_VERTEX_ATTRIBUTE,
|
||||||
GL_FLOAT, GL_FALSE, 0, 0);
|
2,
|
||||||
|
GL_FLOAT,
|
||||||
|
GL_FALSE,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
glEnableVertexAttribArray(GL_UTIL_VERTEX_ATTRIBUTE);
|
||||||
check_gl();
|
check_gl();
|
||||||
}
|
}
|
||||||
@@ -467,7 +497,8 @@ run_open_last_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
|||||||
}
|
}
|
||||||
sprintf(uri, "file://%s", last_path);
|
sprintf(uri, "file://%s", last_path);
|
||||||
if (!g_app_info_launch_default_for_uri(uri, NULL, &error)) {
|
if (!g_app_info_launch_default_for_uri(uri, NULL, &error)) {
|
||||||
g_printerr("Could not launch image viewer for '%s': %s\n", uri,
|
g_printerr("Could not launch image viewer for '%s': %s\n",
|
||||||
|
uri,
|
||||||
error->message);
|
error->message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,12 +525,21 @@ run_capture_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
|||||||
void
|
void
|
||||||
run_about_action(GSimpleAction *action, GVariant *param, GApplication *app)
|
run_about_action(GSimpleAction *action, GVariant *param, GApplication *app)
|
||||||
{
|
{
|
||||||
gtk_show_about_dialog(NULL, "program-name", "Megapixels", "title",
|
gtk_show_about_dialog(NULL,
|
||||||
"Megapixels", "logo-icon-name",
|
"program-name",
|
||||||
"org.postmarketos.Megapixels", "comments",
|
"Megapixels",
|
||||||
"The postmarketOS camera application", "website",
|
"title",
|
||||||
"https://sr.ht/~martijnbraam/megapixels", "version",
|
"Megapixels",
|
||||||
VERSION, "license-type", GTK_LICENSE_GPL_3_0_ONLY,
|
"logo-icon-name",
|
||||||
|
"org.postmarketos.Megapixels",
|
||||||
|
"comments",
|
||||||
|
"The postmarketOS camera application",
|
||||||
|
"website",
|
||||||
|
"https://sr.ht/~martijnbraam/megapixels",
|
||||||
|
"version",
|
||||||
|
VERSION,
|
||||||
|
"license-type",
|
||||||
|
GTK_LICENSE_GPL_3_0_ONLY,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,24 +604,35 @@ on_zbar_code_tapped(GtkWidget *widget, const MPZBarCode *code)
|
|||||||
|
|
||||||
if (data_is_url) {
|
if (data_is_url) {
|
||||||
dialog = gtk_message_dialog_new(
|
dialog = gtk_message_dialog_new(
|
||||||
GTK_WINDOW(gtk_widget_get_root(widget)), flags,
|
GTK_WINDOW(gtk_widget_get_root(widget)),
|
||||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
|
flags,
|
||||||
"Found a URL '%s' encoded in a %s.", code->data, code->type);
|
GTK_MESSAGE_QUESTION,
|
||||||
gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Open URL",
|
GTK_BUTTONS_NONE,
|
||||||
GTK_RESPONSE_YES, NULL);
|
"Found a URL '%s' encoded in a %s.",
|
||||||
|
code->data,
|
||||||
|
code->type);
|
||||||
|
gtk_dialog_add_buttons(
|
||||||
|
GTK_DIALOG(dialog), "_Open URL", GTK_RESPONSE_YES, NULL);
|
||||||
} else {
|
} else {
|
||||||
dialog = gtk_message_dialog_new(
|
dialog = gtk_message_dialog_new(
|
||||||
GTK_WINDOW(gtk_widget_get_root(widget)), flags,
|
GTK_WINDOW(gtk_widget_get_root(widget)),
|
||||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
|
flags,
|
||||||
"Found data encoded in a %s.", code->type);
|
GTK_MESSAGE_QUESTION,
|
||||||
|
GTK_BUTTONS_NONE,
|
||||||
|
"Found data encoded in a %s.",
|
||||||
|
code->type);
|
||||||
gtk_message_dialog_format_secondary_markup(
|
gtk_message_dialog_format_secondary_markup(
|
||||||
GTK_MESSAGE_DIALOG(dialog), "<small>%s</small>", code->data);
|
GTK_MESSAGE_DIALOG(dialog), "<small>%s</small>", code->data);
|
||||||
}
|
}
|
||||||
gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Copy", GTK_RESPONSE_ACCEPT,
|
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
|
||||||
"_Cancel", GTK_RESPONSE_CANCEL, NULL);
|
"_Copy",
|
||||||
|
GTK_RESPONSE_ACCEPT,
|
||||||
|
"_Cancel",
|
||||||
|
GTK_RESPONSE_CANCEL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
g_signal_connect(dialog, "response", G_CALLBACK(on_zbar_dialog_response),
|
g_signal_connect(
|
||||||
data);
|
dialog, "response", G_CALLBACK(on_zbar_dialog_response), data);
|
||||||
|
|
||||||
gtk_widget_show(GTK_WIDGET(dialog));
|
gtk_widget_show(GTK_WIDGET(dialog));
|
||||||
}
|
}
|
||||||
@@ -607,7 +658,9 @@ preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
|
|||||||
for (uint8_t i = 0; i < zbar_result->size; ++i) {
|
for (uint8_t i = 0; i < zbar_result->size; ++i) {
|
||||||
MPZBarCode *code = &zbar_result->codes[i];
|
MPZBarCode *code = &zbar_result->codes[i];
|
||||||
|
|
||||||
if (check_point_inside_bounds(zbar_x, zbar_y, code->bounds_x,
|
if (check_point_inside_bounds(zbar_x,
|
||||||
|
zbar_y,
|
||||||
|
code->bounds_x,
|
||||||
code->bounds_y)) {
|
code->bounds_y)) {
|
||||||
on_zbar_code_tapped(widget, code);
|
on_zbar_code_tapped(widget, code);
|
||||||
return;
|
return;
|
||||||
@@ -685,9 +738,14 @@ update_scale(GtkToggleButton *button, GtkScale *scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_controls(GtkWidget *parent, const char *title_name, double min_value,
|
open_controls(GtkWidget *parent,
|
||||||
double max_value, double current, bool auto_enabled,
|
const char *title_name,
|
||||||
void (*set_fn)(double), void (*set_auto_fn)(bool))
|
double min_value,
|
||||||
|
double max_value,
|
||||||
|
double current,
|
||||||
|
bool auto_enabled,
|
||||||
|
void (*set_fn)(double),
|
||||||
|
void (*set_auto_fn)(bool))
|
||||||
{
|
{
|
||||||
GtkBuilder *builder = gtk_builder_new_from_resource(
|
GtkBuilder *builder = gtk_builder_new_from_resource(
|
||||||
"/org/postmarketos/Megapixels/controls-popover.ui");
|
"/org/postmarketos/Megapixels/controls-popover.ui");
|
||||||
@@ -711,12 +769,16 @@ open_controls(GtkWidget *parent, const char *title_name, double min_value,
|
|||||||
gtk_toggle_button_set_active(auto_button, auto_enabled);
|
gtk_toggle_button_set_active(auto_button, auto_enabled);
|
||||||
update_scale(auto_button, scale);
|
update_scale(auto_button, scale);
|
||||||
|
|
||||||
g_signal_connect(adjustment, "value-changed",
|
g_signal_connect(adjustment,
|
||||||
G_CALLBACK(on_controls_scale_changed), set_fn);
|
"value-changed",
|
||||||
g_signal_connect(adjustment, "value-changed", G_CALLBACK(update_value),
|
G_CALLBACK(on_controls_scale_changed),
|
||||||
value_label);
|
set_fn);
|
||||||
g_signal_connect(auto_button, "toggled",
|
g_signal_connect(
|
||||||
G_CALLBACK(on_auto_controls_toggled), set_auto_fn);
|
adjustment, "value-changed", G_CALLBACK(update_value), value_label);
|
||||||
|
g_signal_connect(auto_button,
|
||||||
|
"toggled",
|
||||||
|
G_CALLBACK(on_auto_controls_toggled),
|
||||||
|
set_auto_fn);
|
||||||
g_signal_connect(auto_button, "toggled", G_CALLBACK(update_scale), scale);
|
g_signal_connect(auto_button, "toggled", G_CALLBACK(update_scale), scale);
|
||||||
|
|
||||||
gtk_widget_set_parent(GTK_WIDGET(popover), parent);
|
gtk_widget_set_parent(GTK_WIDGET(popover), parent);
|
||||||
@@ -745,7 +807,13 @@ set_gain_auto(bool is_auto)
|
|||||||
static void
|
static void
|
||||||
open_iso_controls(GtkWidget *button, gpointer user_data)
|
open_iso_controls(GtkWidget *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
open_controls(button, "ISO", 0, gain_max, gain, !gain_is_manual, set_gain,
|
open_controls(button,
|
||||||
|
"ISO",
|
||||||
|
0,
|
||||||
|
gain_max,
|
||||||
|
gain,
|
||||||
|
!gain_is_manual,
|
||||||
|
set_gain,
|
||||||
set_gain_auto);
|
set_gain_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,8 +839,14 @@ set_shutter_auto(bool is_auto)
|
|||||||
static void
|
static void
|
||||||
open_shutter_controls(GtkWidget *button, gpointer user_data)
|
open_shutter_controls(GtkWidget *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
open_controls(button, "Shutter", 1.0, 360.0, exposure, !exposure_is_manual,
|
open_controls(button,
|
||||||
set_shutter, set_shutter_auto);
|
"Shutter",
|
||||||
|
1.0,
|
||||||
|
360.0,
|
||||||
|
exposure,
|
||||||
|
!exposure_is_manual,
|
||||||
|
set_shutter,
|
||||||
|
set_shutter_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -881,17 +955,28 @@ display_config_received(GDBusConnection *conn, GAsyncResult *res, gpointer user_
|
|||||||
static void
|
static void
|
||||||
update_screen_rotation(GDBusConnection *conn)
|
update_screen_rotation(GDBusConnection *conn)
|
||||||
{
|
{
|
||||||
g_dbus_connection_call(conn, "org.gnome.Mutter.DisplayConfig",
|
g_dbus_connection_call(conn,
|
||||||
|
"org.gnome.Mutter.DisplayConfig",
|
||||||
"/org/gnome/Mutter/DisplayConfig",
|
"/org/gnome/Mutter/DisplayConfig",
|
||||||
"org.gnome.Mutter.DisplayConfig", "GetResources",
|
"org.gnome.Mutter.DisplayConfig",
|
||||||
NULL, NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL,
|
"GetResources",
|
||||||
(GAsyncReadyCallback)display_config_received, NULL);
|
NULL,
|
||||||
|
NULL,
|
||||||
|
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||||
|
-1,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)display_config_received,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_screen_rotate(GDBusConnection *conn, const gchar *sender_name,
|
on_screen_rotate(GDBusConnection *conn,
|
||||||
const gchar *object_path, const gchar *interface_name,
|
const gchar *sender_name,
|
||||||
const gchar *signal_name, GVariant *parameters, gpointer user_data)
|
const gchar *object_path,
|
||||||
|
const gchar *interface_name,
|
||||||
|
const gchar *signal_name,
|
||||||
|
GVariant *parameters,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
update_screen_rotation(conn);
|
update_screen_rotation(conn);
|
||||||
}
|
}
|
||||||
@@ -899,8 +984,10 @@ on_screen_rotate(GDBusConnection *conn, const gchar *sender_name,
|
|||||||
static void
|
static void
|
||||||
activate(GtkApplication *app, gpointer data)
|
activate(GtkApplication *app, gpointer data)
|
||||||
{
|
{
|
||||||
g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme",
|
g_object_set(gtk_settings_get_default(),
|
||||||
TRUE, NULL);
|
"gtk-application-prefer-dark-theme",
|
||||||
|
TRUE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
GdkDisplay *display = gdk_display_get_default();
|
GdkDisplay *display = gdk_display_get_default();
|
||||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display(display);
|
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display(display);
|
||||||
@@ -910,7 +997,8 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
gtk_css_provider_load_from_resource(
|
gtk_css_provider_load_from_resource(
|
||||||
provider, "/org/postmarketos/Megapixels/camera.css");
|
provider, "/org/postmarketos/Megapixels/camera.css");
|
||||||
gtk_style_context_add_provider_for_display(
|
gtk_style_context_add_provider_for_display(
|
||||||
display, GTK_STYLE_PROVIDER(provider),
|
display,
|
||||||
|
GTK_STYLE_PROVIDER(provider),
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
GtkBuilder *builder = gtk_builder_new_from_resource(
|
GtkBuilder *builder = gtk_builder_new_from_resource(
|
||||||
@@ -947,19 +1035,19 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
gtk_widget_add_controller(preview, GTK_EVENT_CONTROLLER(click));
|
gtk_widget_add_controller(preview, GTK_EVENT_CONTROLLER(click));
|
||||||
|
|
||||||
g_signal_connect(iso_button, "clicked", G_CALLBACK(open_iso_controls), NULL);
|
g_signal_connect(iso_button, "clicked", G_CALLBACK(open_iso_controls), NULL);
|
||||||
g_signal_connect(shutter_button, "clicked",
|
g_signal_connect(
|
||||||
G_CALLBACK(open_shutter_controls), NULL);
|
shutter_button, "clicked", G_CALLBACK(open_shutter_controls), NULL);
|
||||||
g_signal_connect(flash_button, "clicked", G_CALLBACK(flash_button_clicked),
|
g_signal_connect(
|
||||||
NULL);
|
flash_button, "clicked", G_CALLBACK(flash_button_clicked), NULL);
|
||||||
|
|
||||||
// Setup actions
|
// Setup actions
|
||||||
create_simple_action(app, "capture", G_CALLBACK(run_capture_action));
|
create_simple_action(app, "capture", G_CALLBACK(run_capture_action));
|
||||||
create_simple_action(app, "switch-camera",
|
create_simple_action(
|
||||||
G_CALLBACK(run_camera_switch_action));
|
app, "switch-camera", G_CALLBACK(run_camera_switch_action));
|
||||||
create_simple_action(app, "open-settings",
|
create_simple_action(
|
||||||
G_CALLBACK(run_open_settings_action));
|
app, "open-settings", G_CALLBACK(run_open_settings_action));
|
||||||
create_simple_action(app, "close-settings",
|
create_simple_action(
|
||||||
G_CALLBACK(run_close_settings_action));
|
app, "close-settings", G_CALLBACK(run_close_settings_action));
|
||||||
create_simple_action(app, "open-last", G_CALLBACK(run_open_last_action));
|
create_simple_action(app, "open-last", G_CALLBACK(run_open_last_action));
|
||||||
create_simple_action(app, "open-photos", G_CALLBACK(run_open_photos_action));
|
create_simple_action(app, "open-photos", G_CALLBACK(run_open_photos_action));
|
||||||
create_simple_action(app, "about", G_CALLBACK(run_about_action));
|
create_simple_action(app, "about", G_CALLBACK(run_about_action));
|
||||||
@@ -974,7 +1062,10 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
|
|
||||||
// Setup settings
|
// Setup settings
|
||||||
settings = g_settings_new("org.postmarketos.Megapixels");
|
settings = g_settings_new("org.postmarketos.Megapixels");
|
||||||
g_settings_bind(settings, "save-raw", setting_dng_button, "active",
|
g_settings_bind(settings,
|
||||||
|
"save-raw",
|
||||||
|
setting_dng_button,
|
||||||
|
"active",
|
||||||
G_SETTINGS_BIND_DEFAULT);
|
G_SETTINGS_BIND_DEFAULT);
|
||||||
|
|
||||||
setting_save_dng = g_settings_get_boolean(settings, "save-raw");
|
setting_save_dng = g_settings_get_boolean(settings, "save-raw");
|
||||||
@@ -982,10 +1073,16 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
// Listen for phosh rotation
|
// Listen for phosh rotation
|
||||||
GDBusConnection *conn =
|
GDBusConnection *conn =
|
||||||
g_application_get_dbus_connection(G_APPLICATION(app));
|
g_application_get_dbus_connection(G_APPLICATION(app));
|
||||||
g_dbus_connection_signal_subscribe(
|
g_dbus_connection_signal_subscribe(conn,
|
||||||
conn, NULL, "org.gnome.Mutter.DisplayConfig", "MonitorsChanged",
|
NULL,
|
||||||
"/org/gnome/Mutter/DisplayConfig", NULL, G_DBUS_SIGNAL_FLAGS_NONE,
|
"org.gnome.Mutter.DisplayConfig",
|
||||||
&on_screen_rotate, NULL, NULL);
|
"MonitorsChanged",
|
||||||
|
"/org/gnome/Mutter/DisplayConfig",
|
||||||
|
NULL,
|
||||||
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
|
&on_screen_rotate,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
update_screen_rotation(conn);
|
update_screen_rotation(conn);
|
||||||
|
|
||||||
// Initialize display flash
|
// Initialize display flash
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "camera_config.h"
|
#include "camera_config.h"
|
||||||
#include "zbar_pipeline.h"
|
|
||||||
#include "process_pipeline.h"
|
|
||||||
#include "gtk/gtk.h"
|
#include "gtk/gtk.h"
|
||||||
|
#include "process_pipeline.h"
|
||||||
|
#include "zbar_pipeline.h"
|
||||||
|
|
||||||
struct mp_main_state {
|
struct mp_main_state {
|
||||||
const struct mp_camera_config *camera;
|
const struct mp_camera_config *camera;
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
#include "pipeline.h"
|
#include "pipeline.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <glib-unix.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <glib-unix.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
struct _MPPipeline {
|
struct _MPPipeline {
|
||||||
GMainContext *main_context;
|
GMainContext *main_context;
|
||||||
@@ -45,8 +45,10 @@ invoke_impl(struct invoke_args *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mp_pipeline_invoke(MPPipeline *pipeline, MPPipelineCallback callback,
|
mp_pipeline_invoke(MPPipeline *pipeline,
|
||||||
const void *data, size_t size)
|
MPPipelineCallback callback,
|
||||||
|
const void *data,
|
||||||
|
size_t size)
|
||||||
{
|
{
|
||||||
if (pthread_self() != pipeline->thread) {
|
if (pthread_self() != pipeline->thread) {
|
||||||
struct invoke_args *args = malloc(sizeof(struct invoke_args) + size);
|
struct invoke_args *args = malloc(sizeof(struct invoke_args) + size);
|
||||||
@@ -59,7 +61,9 @@ mp_pipeline_invoke(MPPipeline *pipeline, MPPipelineCallback callback,
|
|||||||
|
|
||||||
g_main_context_invoke_full(pipeline->main_context,
|
g_main_context_invoke_full(pipeline->main_context,
|
||||||
G_PRIORITY_DEFAULT,
|
G_PRIORITY_DEFAULT,
|
||||||
(GSourceFunc)invoke_impl, args, free);
|
(GSourceFunc)invoke_impl,
|
||||||
|
args,
|
||||||
|
free);
|
||||||
} else {
|
} else {
|
||||||
callback(pipeline, data);
|
callback(pipeline, data);
|
||||||
}
|
}
|
||||||
@@ -79,8 +83,11 @@ mp_pipeline_sync(MPPipeline *pipeline)
|
|||||||
g_mutex_init(&mutex);
|
g_mutex_init(&mutex);
|
||||||
g_mutex_lock(&mutex);
|
g_mutex_lock(&mutex);
|
||||||
|
|
||||||
g_main_context_invoke_full(pipeline->main_context, G_PRIORITY_LOW,
|
g_main_context_invoke_full(pipeline->main_context,
|
||||||
(GSourceFunc)unlock_mutex, &mutex, NULL);
|
G_PRIORITY_LOW,
|
||||||
|
(GSourceFunc)unlock_mutex,
|
||||||
|
&mutex,
|
||||||
|
NULL);
|
||||||
g_mutex_lock(&mutex);
|
g_mutex_lock(&mutex);
|
||||||
g_mutex_unlock(&mutex);
|
g_mutex_unlock(&mutex);
|
||||||
|
|
||||||
@@ -118,8 +125,10 @@ on_capture(int fd, GIOCondition condition, struct capture_source_args *args)
|
|||||||
|
|
||||||
// Not thread safe
|
// Not thread safe
|
||||||
GSource *
|
GSource *
|
||||||
mp_pipeline_add_capture_source(MPPipeline *pipeline, MPCamera *camera,
|
mp_pipeline_add_capture_source(MPPipeline *pipeline,
|
||||||
void (*callback)(MPBuffer, void *), void *user_data)
|
MPCamera *camera,
|
||||||
|
void (*callback)(MPBuffer, void *),
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
int video_fd = mp_camera_get_video_fd(camera);
|
int video_fd = mp_camera_get_video_fd(camera);
|
||||||
GSource *video_source = g_unix_fd_source_new(video_fd, G_IO_IN);
|
GSource *video_source = g_unix_fd_source_new(video_fd, G_IO_IN);
|
||||||
|
@@ -9,12 +9,15 @@ typedef struct _MPPipeline MPPipeline;
|
|||||||
typedef void (*MPPipelineCallback)(MPPipeline *, const void *);
|
typedef void (*MPPipelineCallback)(MPPipeline *, const void *);
|
||||||
|
|
||||||
MPPipeline *mp_pipeline_new();
|
MPPipeline *mp_pipeline_new();
|
||||||
void mp_pipeline_invoke(MPPipeline *pipeline, MPPipelineCallback callback,
|
void mp_pipeline_invoke(MPPipeline *pipeline,
|
||||||
const void *data, size_t size);
|
MPPipelineCallback callback,
|
||||||
|
const void *data,
|
||||||
|
size_t size);
|
||||||
// Wait until all pending tasks have completed
|
// Wait until all pending tasks have completed
|
||||||
void mp_pipeline_sync(MPPipeline *pipeline);
|
void mp_pipeline_sync(MPPipeline *pipeline);
|
||||||
void mp_pipeline_free(MPPipeline *pipeline);
|
void mp_pipeline_free(MPPipeline *pipeline);
|
||||||
|
|
||||||
GSource *mp_pipeline_add_capture_source(MPPipeline *pipeline, MPCamera *camera,
|
GSource *mp_pipeline_add_capture_source(MPPipeline *pipeline,
|
||||||
|
MPCamera *camera,
|
||||||
void (*callback)(MPBuffer, void *),
|
void (*callback)(MPBuffer, void *),
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
#include "process_pipeline.h"
|
#include "process_pipeline.h"
|
||||||
|
|
||||||
#include "pipeline.h"
|
|
||||||
#include "zbar_pipeline.h"
|
|
||||||
#include "io_pipeline.h"
|
|
||||||
#include "main.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gles2_debayer.h"
|
#include "gles2_debayer.h"
|
||||||
#include <tiffio.h>
|
#include "io_pipeline.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "pipeline.h"
|
||||||
|
#include "zbar_pipeline.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <tiffio.h>
|
||||||
|
|
||||||
#include "gl_util.h"
|
#include "gl_util.h"
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@@ -59,12 +59,19 @@ static void
|
|||||||
register_custom_tiff_tags(TIFF *tif)
|
register_custom_tiff_tags(TIFF *tif)
|
||||||
{
|
{
|
||||||
static const TIFFFieldInfo custom_fields[] = {
|
static const TIFFFieldInfo custom_fields[] = {
|
||||||
{ TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
|
{ TIFFTAG_FORWARDMATRIX1,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
TIFF_SRATIONAL,
|
||||||
|
FIELD_CUSTOM,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
"ForwardMatrix1" },
|
"ForwardMatrix1" },
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add missing dng fields
|
// Add missing dng fields
|
||||||
TIFFMergeFieldInfo(tif, custom_fields,
|
TIFFMergeFieldInfo(tif,
|
||||||
|
custom_fields,
|
||||||
sizeof(custom_fields) / sizeof(custom_fields[0]));
|
sizeof(custom_fields) / sizeof(custom_fields[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,14 +245,18 @@ init_gl(MPPipeline *pipeline, GdkSurface **surface)
|
|||||||
int major, minor;
|
int major, minor;
|
||||||
gdk_gl_context_get_version(context, &major, &minor);
|
gdk_gl_context_get_version(context, &major, &minor);
|
||||||
|
|
||||||
printf("Initialized %s %d.%d\n", is_es ? "OpenGL ES" : "OpenGL", major,
|
printf("Initialized %s %d.%d\n",
|
||||||
|
is_es ? "OpenGL ES" : "OpenGL",
|
||||||
|
major,
|
||||||
minor);
|
minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mp_process_pipeline_init_gl(GdkSurface *surface)
|
mp_process_pipeline_init_gl(GdkSurface *surface)
|
||||||
{
|
{
|
||||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)init_gl, &surface,
|
mp_pipeline_invoke(pipeline,
|
||||||
|
(MPPipelineCallback)init_gl,
|
||||||
|
&surface,
|
||||||
sizeof(GdkSurface *));
|
sizeof(GdkSurface *));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,12 +294,19 @@ process_image_for_preview(const uint8_t *image)
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, mode.width, mode.height, 0,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE, image);
|
0,
|
||||||
|
GL_LUMINANCE,
|
||||||
|
mode.width,
|
||||||
|
mode.height,
|
||||||
|
0,
|
||||||
|
GL_LUMINANCE,
|
||||||
|
GL_UNSIGNED_BYTE,
|
||||||
|
image);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
gles2_debayer_process(gles2_debayer, output_buffer->texture_id,
|
gles2_debayer_process(
|
||||||
input_texture);
|
gles2_debayer, output_buffer->texture_id, input_texture);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
glFinish();
|
glFinish();
|
||||||
@@ -320,8 +338,13 @@ process_image_for_preview(const uint8_t *image)
|
|||||||
|
|
||||||
uint32_t *data = g_malloc_n(size, 1);
|
uint32_t *data = g_malloc_n(size, 1);
|
||||||
|
|
||||||
glReadPixels(0, 0, output_buffer_width, output_buffer_height,
|
glReadPixels(0,
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
0,
|
||||||
|
output_buffer_width,
|
||||||
|
output_buffer_height,
|
||||||
|
GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE,
|
||||||
|
data);
|
||||||
check_gl();
|
check_gl();
|
||||||
|
|
||||||
// Flip vertically
|
// Flip vertically
|
||||||
@@ -337,10 +360,12 @@ process_image_for_preview(const uint8_t *image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thumb = gdk_memory_texture_new(
|
thumb = gdk_memory_texture_new(output_buffer_width,
|
||||||
output_buffer_width, output_buffer_height,
|
output_buffer_height,
|
||||||
GDK_MEMORY_R8G8B8A8, g_bytes_new_take(data, size),
|
GDK_MEMORY_R8G8B8A8,
|
||||||
output_buffer_width * sizeof(uint32_t));
|
g_bytes_new_take(data, size),
|
||||||
|
output_buffer_width *
|
||||||
|
sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
return thumb;
|
return thumb;
|
||||||
@@ -397,7 +422,9 @@ process_image_for_capture(const uint8_t *image, int count)
|
|||||||
TIFFSetField(tif, TIFFTAG_DNGVERSION, "\001\001\0\0");
|
TIFFSetField(tif, TIFFTAG_DNGVERSION, "\001\001\0\0");
|
||||||
TIFFSetField(tif, TIFFTAG_DNGBACKWARDVERSION, "\001\0\0\0");
|
TIFFSetField(tif, TIFFTAG_DNGBACKWARDVERSION, "\001\0\0\0");
|
||||||
char uniquecameramodel[255];
|
char uniquecameramodel[255];
|
||||||
sprintf(uniquecameramodel, "%s %s", mp_get_device_make(),
|
sprintf(uniquecameramodel,
|
||||||
|
"%s %s",
|
||||||
|
mp_get_device_make(),
|
||||||
mp_get_device_model());
|
mp_get_device_model());
|
||||||
TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, uniquecameramodel);
|
TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, uniquecameramodel);
|
||||||
if (camera->colormatrix[0]) {
|
if (camera->colormatrix[0]) {
|
||||||
@@ -426,7 +453,8 @@ process_image_for_capture(const uint8_t *image, int count)
|
|||||||
TIFFSetField(tif, TIFFTAG_SUBFILETYPE, 0);
|
TIFFSetField(tif, TIFFTAG_SUBFILETYPE, 0);
|
||||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, mode.width);
|
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, mode.width);
|
||||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, mode.height);
|
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, mode.height);
|
||||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE,
|
TIFFSetField(tif,
|
||||||
|
TIFFTAG_BITSPERSAMPLE,
|
||||||
mp_pixel_format_bits_per_pixel(mode.pixel_format));
|
mp_pixel_format_bits_per_pixel(mode.pixel_format));
|
||||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA);
|
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA);
|
||||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
|
||||||
@@ -458,7 +486,8 @@ process_image_for_capture(const uint8_t *image, int count)
|
|||||||
(void *)image +
|
(void *)image +
|
||||||
(row * mp_pixel_format_width_to_bytes(
|
(row * mp_pixel_format_width_to_bytes(
|
||||||
mode.pixel_format, mode.width)),
|
mode.pixel_format, mode.width)),
|
||||||
row, 0);
|
row,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
TIFFWriteDirectory(tif);
|
TIFFWriteDirectory(tif);
|
||||||
|
|
||||||
@@ -471,13 +500,14 @@ process_image_for_capture(const uint8_t *image, int count)
|
|||||||
TIFFSetField(tif, EXIFTAG_EXPOSUREPROGRAM, 1);
|
TIFFSetField(tif, EXIFTAG_EXPOSUREPROGRAM, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIFFSetField(tif, EXIFTAG_EXPOSURETIME,
|
TIFFSetField(tif,
|
||||||
|
EXIFTAG_EXPOSURETIME,
|
||||||
(mode.frame_interval.numerator /
|
(mode.frame_interval.numerator /
|
||||||
(float)mode.frame_interval.denominator) /
|
(float)mode.frame_interval.denominator) /
|
||||||
((float)mode.height / (float)exposure));
|
((float)mode.height / (float)exposure));
|
||||||
if (camera->iso_min && camera->iso_max) {
|
if (camera->iso_min && camera->iso_max) {
|
||||||
uint16_t isospeed = remap(gain - 1, 0, gain_max, camera->iso_min,
|
uint16_t isospeed = remap(
|
||||||
camera->iso_max);
|
gain - 1, 0, gain_max, camera->iso_min, camera->iso_max);
|
||||||
TIFFSetField(tif, EXIFTAG_ISOSPEEDRATINGS, 1, &isospeed);
|
TIFFSetField(tif, EXIFTAG_ISOSPEEDRATINGS, 1, &isospeed);
|
||||||
}
|
}
|
||||||
TIFFSetField(tif, EXIFTAG_FLASH, 0);
|
TIFFSetField(tif, EXIFTAG_FLASH, 0);
|
||||||
@@ -491,7 +521,8 @@ process_image_for_capture(const uint8_t *image, int count)
|
|||||||
TIFFSetField(tif, EXIFTAG_FOCALLENGTH, camera->focallength);
|
TIFFSetField(tif, EXIFTAG_FOCALLENGTH, camera->focallength);
|
||||||
}
|
}
|
||||||
if (camera->focallength && camera->cropfactor) {
|
if (camera->focallength && camera->cropfactor) {
|
||||||
TIFFSetField(tif, EXIFTAG_FOCALLENGTHIN35MMFILM,
|
TIFFSetField(tif,
|
||||||
|
EXIFTAG_FOCALLENGTHIN35MMFILM,
|
||||||
(short)(camera->focallength * camera->cropfactor));
|
(short)(camera->focallength * camera->cropfactor));
|
||||||
}
|
}
|
||||||
uint64_t exif_offset = 0;
|
uint64_t exif_offset = 0;
|
||||||
@@ -540,14 +571,19 @@ process_capture_burst(GdkTexture *thumb)
|
|||||||
strftime(timestamp, 30, "%Y%m%d%H%M%S", &tim);
|
strftime(timestamp, 30, "%Y%m%d%H%M%S", &tim);
|
||||||
|
|
||||||
if (g_get_user_special_dir(G_USER_DIRECTORY_PICTURES) != NULL) {
|
if (g_get_user_special_dir(G_USER_DIRECTORY_PICTURES) != NULL) {
|
||||||
sprintf(capture_fname, "%s/IMG%s",
|
sprintf(capture_fname,
|
||||||
|
"%s/IMG%s",
|
||||||
g_get_user_special_dir(G_USER_DIRECTORY_PICTURES),
|
g_get_user_special_dir(G_USER_DIRECTORY_PICTURES),
|
||||||
timestamp);
|
timestamp);
|
||||||
} else if (getenv("XDG_PICTURES_DIR") != NULL) {
|
} else if (getenv("XDG_PICTURES_DIR") != NULL) {
|
||||||
sprintf(capture_fname, "%s/IMG%s", getenv("XDG_PICTURES_DIR"),
|
sprintf(capture_fname,
|
||||||
|
"%s/IMG%s",
|
||||||
|
getenv("XDG_PICTURES_DIR"),
|
||||||
timestamp);
|
timestamp);
|
||||||
} else {
|
} else {
|
||||||
sprintf(capture_fname, "%s/Pictures/IMG%s", getenv("HOME"),
|
sprintf(capture_fname,
|
||||||
|
"%s/Pictures/IMG%s",
|
||||||
|
getenv("HOME"),
|
||||||
timestamp);
|
timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,12 +593,18 @@ process_capture_burst(GdkTexture *thumb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start post-processing the captured burst
|
// Start post-processing the captured burst
|
||||||
g_print("Post process %s to %s.ext (save-dng %s)\n", burst_dir,
|
g_print("Post process %s to %s.ext (save-dng %s)\n",
|
||||||
capture_fname, save_dng_s);
|
burst_dir,
|
||||||
|
capture_fname,
|
||||||
|
save_dng_s);
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GSubprocess *proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_PIPE, &error,
|
GSubprocess *proc = g_subprocess_new(G_SUBPROCESS_FLAGS_STDOUT_PIPE,
|
||||||
processing_script, burst_dir,
|
&error,
|
||||||
capture_fname, save_dng_s, NULL);
|
processing_script,
|
||||||
|
burst_dir,
|
||||||
|
capture_fname,
|
||||||
|
save_dng_s,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (!proc) {
|
if (!proc) {
|
||||||
g_printerr("Failed to spawn postprocess process: %s\n",
|
g_printerr("Failed to spawn postprocess process: %s\n",
|
||||||
@@ -587,9 +629,12 @@ process_image(MPPipeline *pipeline, const MPBuffer *buffer)
|
|||||||
memcpy(image, buffer->data, size);
|
memcpy(image, buffer->data, size);
|
||||||
mp_io_pipeline_release_buffer(buffer->index);
|
mp_io_pipeline_release_buffer(buffer->index);
|
||||||
|
|
||||||
MPZBarImage *zbar_image =
|
MPZBarImage *zbar_image = mp_zbar_image_new(image,
|
||||||
mp_zbar_image_new(image, mode.pixel_format, mode.width, mode.height,
|
mode.pixel_format,
|
||||||
camera_rotation, camera->mirrored);
|
mode.width,
|
||||||
|
mode.height,
|
||||||
|
camera_rotation,
|
||||||
|
camera->mirrored);
|
||||||
mp_zbar_pipeline_process_image(mp_zbar_image_ref(zbar_image));
|
mp_zbar_pipeline_process_image(mp_zbar_image_ref(zbar_image));
|
||||||
|
|
||||||
#ifdef PROFILE_PROCESS
|
#ifdef PROFILE_PROCESS
|
||||||
@@ -641,7 +686,9 @@ mp_process_pipeline_process_image(MPBuffer buffer)
|
|||||||
|
|
||||||
++frames_received;
|
++frames_received;
|
||||||
|
|
||||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)process_image, &buffer,
|
mp_pipeline_invoke(pipeline,
|
||||||
|
(MPPipelineCallback)process_image,
|
||||||
|
&buffer,
|
||||||
sizeof(MPBuffer));
|
sizeof(MPBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,16 +731,27 @@ on_output_changed()
|
|||||||
|
|
||||||
for (size_t i = 0; i < NUM_BUFFERS; ++i) {
|
for (size_t i = 0; i < NUM_BUFFERS; ++i) {
|
||||||
glBindTexture(GL_TEXTURE_2D, output_buffers[i].texture_id);
|
glBindTexture(GL_TEXTURE_2D, output_buffers[i].texture_id);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, output_buffer_width,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
output_buffer_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
0,
|
||||||
|
GL_RGBA,
|
||||||
|
output_buffer_width,
|
||||||
|
output_buffer_height,
|
||||||
|
0,
|
||||||
|
GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
gles2_debayer_configure(
|
gles2_debayer_configure(
|
||||||
gles2_debayer, output_buffer_width, output_buffer_height, mode.width,
|
gles2_debayer,
|
||||||
mode.height, camera->rotate, camera->mirrored,
|
output_buffer_width,
|
||||||
|
output_buffer_height,
|
||||||
|
mode.width,
|
||||||
|
mode.height,
|
||||||
|
camera->rotate,
|
||||||
|
camera->mirrored,
|
||||||
camera->previewmatrix[0] == 0 ? NULL : camera->previewmatrix,
|
camera->previewmatrix[0] == 0 ? NULL : camera->previewmatrix,
|
||||||
camera->blacklevel);
|
camera->blacklevel);
|
||||||
}
|
}
|
||||||
@@ -757,7 +815,9 @@ update_state(MPPipeline *pipeline, const struct mp_process_pipeline_state *state
|
|||||||
void
|
void
|
||||||
mp_process_pipeline_update_state(const struct mp_process_pipeline_state *new_state)
|
mp_process_pipeline_update_state(const struct mp_process_pipeline_state *new_state)
|
||||||
{
|
{
|
||||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)update_state, new_state,
|
mp_pipeline_invoke(pipeline,
|
||||||
|
(MPPipelineCallback)update_state,
|
||||||
|
new_state,
|
||||||
sizeof(struct mp_process_pipeline_state));
|
sizeof(struct mp_process_pipeline_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
#include "zbar_pipeline.h"
|
#include "zbar_pipeline.h"
|
||||||
|
|
||||||
#include "pipeline.h"
|
|
||||||
#include "main.h"
|
|
||||||
#include "io_pipeline.h"
|
#include "io_pipeline.h"
|
||||||
#include <zbar.h>
|
#include "main.h"
|
||||||
|
#include "pipeline.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <zbar.h>
|
||||||
|
|
||||||
struct _MPZBarImage {
|
struct _MPZBarImage {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
@@ -102,7 +102,9 @@ map_coords(int *x, int *y, int width, int height, int rotation, bool mirrored)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static MPZBarCode
|
static MPZBarCode
|
||||||
process_symbol(const MPZBarImage *image, int width, int height,
|
process_symbol(const MPZBarImage *image,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
const zbar_symbol_t *symbol)
|
const zbar_symbol_t *symbol)
|
||||||
{
|
{
|
||||||
if (image->rotation == 90 || image->rotation == 270) {
|
if (image->rotation == 90 || image->rotation == 270) {
|
||||||
@@ -147,8 +149,12 @@ process_symbol(const MPZBarImage *image, int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 4; ++i) {
|
for (uint8_t i = 0; i < 4; ++i) {
|
||||||
map_coords(&code.bounds_x[i], &code.bounds_y[i], width, height,
|
map_coords(&code.bounds_x[i],
|
||||||
image->rotation, image->mirrored);
|
&code.bounds_y[i],
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
image->rotation,
|
||||||
|
image->mirrored);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *data = zbar_symbol_get_data(symbol);
|
const char *data = zbar_symbol_get_data(symbol);
|
||||||
@@ -187,7 +193,9 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
|
|||||||
zbar_image_t *zbar_image = zbar_image_create();
|
zbar_image_t *zbar_image = zbar_image_create();
|
||||||
zbar_image_set_format(zbar_image, zbar_fourcc('Y', '8', '0', '0'));
|
zbar_image_set_format(zbar_image, zbar_fourcc('Y', '8', '0', '0'));
|
||||||
zbar_image_set_size(zbar_image, width, height);
|
zbar_image_set_size(zbar_image, width, height);
|
||||||
zbar_image_set_data(zbar_image, data, width * height * sizeof(uint8_t),
|
zbar_image_set_data(zbar_image,
|
||||||
|
data,
|
||||||
|
width * height * sizeof(uint8_t),
|
||||||
zbar_image_free_data);
|
zbar_image_free_data);
|
||||||
|
|
||||||
int res = zbar_scan_image(scanner, zbar_image);
|
int res = zbar_scan_image(scanner, zbar_image);
|
||||||
@@ -227,13 +235,19 @@ mp_zbar_pipeline_process_image(MPZBarImage *image)
|
|||||||
|
|
||||||
++frames_received;
|
++frames_received;
|
||||||
|
|
||||||
mp_pipeline_invoke(pipeline, (MPPipelineCallback)process_image, &image,
|
mp_pipeline_invoke(pipeline,
|
||||||
|
(MPPipelineCallback)process_image,
|
||||||
|
&image,
|
||||||
sizeof(MPZBarImage *));
|
sizeof(MPZBarImage *));
|
||||||
}
|
}
|
||||||
|
|
||||||
MPZBarImage *
|
MPZBarImage *
|
||||||
mp_zbar_image_new(uint8_t *data, MPPixelFormat pixel_format, int width, int height,
|
mp_zbar_image_new(uint8_t *data,
|
||||||
int rotation, bool mirrored)
|
MPPixelFormat pixel_format,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int rotation,
|
||||||
|
bool mirrored)
|
||||||
{
|
{
|
||||||
MPZBarImage *image = malloc(sizeof(MPZBarImage));
|
MPZBarImage *image = malloc(sizeof(MPZBarImage));
|
||||||
image->data = data;
|
image->data = data;
|
||||||
|
@@ -21,7 +21,11 @@ void mp_zbar_pipeline_stop();
|
|||||||
|
|
||||||
void mp_zbar_pipeline_process_image(MPZBarImage *image);
|
void mp_zbar_pipeline_process_image(MPZBarImage *image);
|
||||||
|
|
||||||
MPZBarImage *mp_zbar_image_new(uint8_t *data, MPPixelFormat pixel_format, int width,
|
MPZBarImage *mp_zbar_image_new(uint8_t *data,
|
||||||
int height, int rotation, bool mirrored);
|
MPPixelFormat pixel_format,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int rotation,
|
||||||
|
bool mirrored);
|
||||||
MPZBarImage *mp_zbar_image_ref(MPZBarImage *image);
|
MPZBarImage *mp_zbar_image_ref(MPZBarImage *image);
|
||||||
void mp_zbar_image_unref(MPZBarImage *image);
|
void mp_zbar_image_unref(MPZBarImage *image);
|
||||||
|
@@ -94,8 +94,8 @@ main(int argc, char *argv[])
|
|||||||
const struct media_v2_pad *pad =
|
const struct media_v2_pad *pad =
|
||||||
mp_device_get_pad_from_entity(
|
mp_device_get_pad_from_entity(
|
||||||
device, entities[i].id);
|
device, entities[i].id);
|
||||||
mp_device_setup_link(device, pad->id, sink_pad->id,
|
mp_device_setup_link(
|
||||||
false);
|
device, pad->id, sink_pad->id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,8 +134,10 @@ main(int argc, char *argv[])
|
|||||||
list = mp_control_list_next(list)) {
|
list = mp_control_list_next(list)) {
|
||||||
MPControl *c = mp_control_list_get(list);
|
MPControl *c = mp_control_list_get(list);
|
||||||
|
|
||||||
printf(" %32s id:%s type:%s default:%d\n", c->name,
|
printf(" %32s id:%s type:%s default:%d\n",
|
||||||
mp_control_id_to_str(c->id), mp_control_type_to_str(c->type),
|
c->name,
|
||||||
|
mp_control_id_to_str(c->id),
|
||||||
|
mp_control_type_to_str(c->type),
|
||||||
c->default_value);
|
c->default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +152,11 @@ main(int argc, char *argv[])
|
|||||||
for (MPCameraModeList *list = modes; list;
|
for (MPCameraModeList *list = modes; list;
|
||||||
list = mp_camera_mode_list_next(list)) {
|
list = mp_camera_mode_list_next(list)) {
|
||||||
MPCameraMode *m = mp_camera_mode_list_get(list);
|
MPCameraMode *m = mp_camera_mode_list_get(list);
|
||||||
printf(" %dx%d interval:%d/%d fmt:%s\n", m->width, m->height,
|
printf(" %dx%d interval:%d/%d fmt:%s\n",
|
||||||
m->frame_interval.numerator, m->frame_interval.denominator,
|
m->width,
|
||||||
|
m->height,
|
||||||
|
m->frame_interval.numerator,
|
||||||
|
m->frame_interval.denominator,
|
||||||
mp_pixel_format_to_str(m->pixel_format));
|
mp_pixel_format_to_str(m->pixel_format));
|
||||||
|
|
||||||
// Skip really slow framerates
|
// Skip really slow framerates
|
||||||
|
@@ -22,7 +22,9 @@ main(int argc, char *argv[])
|
|||||||
size_t num = mp_device_get_num_entities(device);
|
size_t num = mp_device_get_num_entities(device);
|
||||||
printf(" Entities (%ld):\n", num);
|
printf(" Entities (%ld):\n", num);
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
printf(" %d %s (%d)\n", entities[i].id, entities[i].name,
|
printf(" %d %s (%d)\n",
|
||||||
|
entities[i].id,
|
||||||
|
entities[i].name,
|
||||||
entities[i].function);
|
entities[i].function);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,8 +33,10 @@ main(int argc, char *argv[])
|
|||||||
num = mp_device_get_num_interfaces(device);
|
num = mp_device_get_num_interfaces(device);
|
||||||
printf(" Interfaces (%ld):\n", num);
|
printf(" Interfaces (%ld):\n", num);
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
printf(" %d (%d - %d) devnode %d:%d\n", interfaces[i].id,
|
printf(" %d (%d - %d) devnode %d:%d\n",
|
||||||
interfaces[i].intf_type, interfaces[i].flags,
|
interfaces[i].id,
|
||||||
|
interfaces[i].intf_type,
|
||||||
|
interfaces[i].flags,
|
||||||
interfaces[i].devnode.major,
|
interfaces[i].devnode.major,
|
||||||
interfaces[i].devnode.minor);
|
interfaces[i].devnode.minor);
|
||||||
}
|
}
|
||||||
@@ -41,16 +45,21 @@ main(int argc, char *argv[])
|
|||||||
num = mp_device_get_num_pads(device);
|
num = mp_device_get_num_pads(device);
|
||||||
printf(" Pads (%ld):\n", num);
|
printf(" Pads (%ld):\n", num);
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
printf(" %d for device:%d (%d)\n", pads[i].id,
|
printf(" %d for device:%d (%d)\n",
|
||||||
pads[i].entity_id, pads[i].flags);
|
pads[i].id,
|
||||||
|
pads[i].entity_id,
|
||||||
|
pads[i].flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct media_v2_link *links = mp_device_get_links(device);
|
const struct media_v2_link *links = mp_device_get_links(device);
|
||||||
num = mp_device_get_num_links(device);
|
num = mp_device_get_num_links(device);
|
||||||
printf(" Links (%ld):\n", num);
|
printf(" Links (%ld):\n", num);
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
printf(" %d from:%d to:%d (%d)\n", links[i].id,
|
printf(" %d from:%d to:%d (%d)\n",
|
||||||
links[i].source_id, links[i].sink_id, links[i].flags);
|
links[i].id,
|
||||||
|
links[i].source_id,
|
||||||
|
links[i].sink_id,
|
||||||
|
links[i].flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
list = mp_device_list_next(list);
|
list = mp_device_list_next(list);
|
||||||
|
Reference in New Issue
Block a user