PPP patches

This commit is contained in:
Gerben Jan Dijkman 2024-05-28 14:38:29 +02:00
parent 2573b3ea30
commit 6d878e400d
5 changed files with 731 additions and 239 deletions

View File

@ -0,0 +1,23 @@
From 06230f3a02cffdf8b683f85cb32fc256d73615d9 Mon Sep 17 00:00:00 2001
From: kgmt0 <kritphong@teknik.io>
Date: Sat, 2 Jul 2022 12:15:22 +0700
Subject: [PATCH] device: Make mp_device_setup_link() support non-zero pad
indices
---
src/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index b4d5f80..9e2db00 100644
--- a/src/device.c
+++ b/src/device.c
@@ -197,7 +197,7 @@ mp_device_setup_link(MPDevice *device,
g_return_val_if_fail(sink_pad, false);
return mp_device_setup_entity_link(
- device, source_pad->entity_id, sink_pad->entity_id, 0, 0, enabled);
+ device, source_pad->entity_id, sink_pad->entity_id, source_pad->index, sink_pad->index, enabled);
}
bool

View File

@ -0,0 +1,130 @@
From 27a1e606d680295e0b4caceadf74ff5857ac16b2 Mon Sep 17 00:00:00 2001
From: kgmt0 <kritphong@teknik.io>
Date: Thu, 1 Dec 2022 00:09:27 -0600
Subject: [PATCH] Add media-formats and media-crops to the config file format
---
src/camera_config.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
src/camera_config.h | 23 +++++++++++++++++
2 files changed, 84 insertions(+)
diff --git a/src/camera_config.c b/src/camera_config.c
index 6ff74d1..1102354 100644
--- a/src/camera_config.c
+++ b/src/camera_config.c
@@ -184,6 +184,67 @@ config_ini_handler(void *user,
++cc->num_media_links;
}
g_strfreev(linkdefs);
+ } else if (strcmp(name, "media-formats") == 0) {
+ struct mp_camera_config *cc = &cameras[index];
+ char **formatdefs = g_strsplit(value, ",", 0);
+
+ for (int i = 0; i < MP_MAX_FORMATS && formatdefs[i] != NULL;
+ ++i) {
+ char **entry = g_strsplit(formatdefs[i], ":", 5);
+ char *name = entry[0];
+ int pad = strtoint(entry[1], NULL, 10);
+ char *format = entry[2];
+ char *width = entry[3];
+ char *height = entry[4];
+
+ const size_t name_size =
+ sizeof(cc->media_formats[i].name);
+ strncpy(cc->media_formats[i].name,
+ name,
+ name_size );
+
+ cc->media_formats[i].pad = pad;
+
+ cc->media_formats[i].mode.pixel_format =
+ mp_pixel_format_from_str(format);
+ cc->media_formats[i].mode.width =
+ strtoint(width, NULL, 10);
+ cc->media_formats[i].mode.height =
+ strtoint(height, NULL, 10);
+
+ cc->num_media_formats++;
+
+ g_strfreev(entry);
+ }
+ } else if (strcmp(name, "media-crops") == 0) {
+ char **formatdefs = g_strsplit(value, ",", 0);
+
+ for (int i = 0; i < MP_MAX_CROPS && formatdefs[i] != NULL;
+ ++i) {
+ char **entry = g_strsplit(formatdefs[i], ":", 6);
+ char *name = entry[0];
+ int pad = strtoint(entry[1], NULL, 10);
+ int top = strtoint(entry[2], NULL, 10);
+ int left = strtoint(entry[3], NULL, 10);
+ int width = strtoint(entry[4], NULL, 10);
+ int height = strtoint(entry[5], NULL, 10);
+
+ const size_t name_size =
+ sizeof(cc->media_crops[i].name);
+ strncpy(cc->media_crops[i].name,
+ name,
+ name_size );
+
+ cc->media_crops[i].pad = pad;
+ cc->media_crops[i].top = top;
+ cc->media_crops[i].left = left;
+ cc->media_crops[i].width = width;
+ cc->media_crops[i].height = height;
+
+ cc->num_media_crops++;
+
+ g_strfreev(entry);
+ }
} else if (strcmp(name, "colormatrix") == 0) {
sscanf(value,
"%f,%f,%f,%f,%f,%f,%f,%f,%f",
diff --git a/src/camera_config.h b/src/camera_config.h
index d53d36f..b1bd5a5 100644
--- a/src/camera_config.h
+++ b/src/camera_config.h
@@ -7,6 +7,8 @@
#define MP_MAX_CAMERAS 5
#define MP_MAX_LINKS 10
+#define MP_MAX_FORMATS 10
+#define MP_MAX_CROPS 10
struct mp_media_link_config {
char source_name[100];
@@ -15,6 +17,21 @@ struct mp_media_link_config {
int target_port;
};
+struct mp_media_format_config {
+ char name[100];
+ int pad;
+ MPMode mode;
+};
+
+struct mp_media_crop_config {
+ char name[100];
+ int pad;
+ int left;
+ int top;
+ int width;
+ int height;
+};
+
struct mp_camera_config {
size_t index;
@@ -30,6 +47,12 @@ struct mp_camera_config {
struct mp_media_link_config media_links[MP_MAX_LINKS];
int num_media_links;
+ struct mp_media_format_config media_formats[MP_MAX_FORMATS];
+ int num_media_formats;
+
+ struct mp_media_crop_config media_crops[MP_MAX_CROPS];
+ int num_media_crops;
+
float colormatrix[9];
float forwardmatrix[9];
float previewmatrix[9];

View File

@ -0,0 +1,572 @@
From d8b35bc223989cb165ba1b0716ab9f0ca9c43e53 Mon Sep 17 00:00:00 2001
From: kgmt0 <kritphong@teknik.io>
Date: Thu, 1 Dec 2022 00:13:27 -0600
Subject: [PATCH] WIP: Support Pinephone Pro
Both cameras work now but the quality is very poor.
The config file format is extended to include 2 new options
"media-formats" and "media-crops" that can be used to set formats and
crops on a per-pad basis. These are needed to initialize Pinephone Pro's
media controller.
Tested with Linux 6.0.8-1 from Arch Linux ARM (linux-megi).
---
config/motorola,osprey.ini | 1 +
config/pine64,pinephone-pro.ini | 49 +++++++++
config/xiaomi,scorpio.ini | 1 +
meson.build | 1 +
src/camera.c | 10 +-
src/device.c | 101 ++++++++++++++++++
src/device.h | 14 +++
src/io_pipeline.c | 184 ++++++++++++++++++++------------
8 files changed, 288 insertions(+), 73 deletions(-)
create mode 100644 config/pine64,pinephone-pro.ini
diff --git a/config/motorola,osprey.ini b/config/motorola,osprey.ini
index ab8990d..5809a8e 100644
--- a/config/motorola,osprey.ini
+++ b/config/motorola,osprey.ini
@@ -15,3 +15,4 @@ preview-rate=30
preview-fmt=RGGB10P
rotate=270
media-links=msm_csiphy0:1->msm_csid0:0,msm_csid0:1->msm_ispif0:0,msm_ispif0:1->msm_vfe0_rdi0:0
+media-formats=msm_csiphy0:1:RGGB10P:4096:2304,msm_csid0:0:RGGB10P:4096:2304,msm_csid0:1:RGGB10P:4096:2304,msm_ispif0:0:RGGB10P:4096:2304,msm_ispif0:1:RGGB10P:4096:2304,msm_vfe0_rdi0:0:RGGB10P:4096:2304
diff --git a/config/pine64,pinephone-pro.ini b/config/pine64,pinephone-pro.ini
new file mode 100644
index 0000000..bd5cfcd
--- /dev/null
+++ b/config/pine64,pinephone-pro.ini
@@ -0,0 +1,49 @@
+[device]
+make=PINE64
+model=PinePhone
+
+[rear]
+driver=imx258 1-001a
+media-driver=rkisp1
+capture-width=1048
+capture-height=780
+capture-rate=30
+capture-fmt=RGGB8
+preview-width=1048
+preview-height=780
+preview-rate=30
+preview-fmt=RGGB8
+rotate=270
+mirrored=false
+blacklevel=3
+whitelevel=255
+focallength=2.35
+cropfactor=10.81
+fnumber=2.2
+iso-min=100
+iso-max=64000
+flash-path=/sys/class/leds/white:flash
+media-links=imx258 1-001a:0->rkisp1_csi:0,rkisp1_csi:1->rkisp1_isp:0,rkisp1_isp:2->rkisp1_resizer_mainpath:0
+media-formats=imx258 1-001a:0:RGGB10P:1048:780,rkisp1_csi:0:RGGB10P:1048:780,rkisp1_isp:0:RGGB10P:1048:780,rkisp1_isp:2:RGGB8:1048:780,rkisp1_resizer_mainpath:0:RGGB8:1048:780,rkisp1_resizer_mainpath:1:RGGB8:1048:780
+media-crops=rkisp1_isp:0:0:0:1048:780,rkisp1_isp:2:0:0:1048:780,rkisp1_resizer_mainpath:0:0:0:1048:768
+
+[front]
+driver=m00_f_ov8858 1-0036
+media-driver=rkisp1
+capture-width=3264
+capture-height=2448
+capture-rate=30
+capture-fmt=BGGR8
+preview-width=3264
+preview-height=2448
+preview-rate=30
+preview-fmt=BGGR8
+rotate=90
+mirrored=true
+focallength=2.94
+cropfactor=12.7
+fnumber=2.4
+flash-display=true
+media-links=m00_f_ov8858 1-0036:0->rkisp1_csi:0,rkisp1_csi:1->rkisp1_isp:0,rkisp1_isp:2->rkisp1_resizer_mainpath:0,rkisp1_resizer_mainpath:1->rkisp1_mainpath:0
+media-formats=m00_f_ov8858 1-0036:0:BGGR10P:3264:2448,rkisp1_csi:0:BGGR10P:3264:2448,rkisp1_isp:0:BGGR10P:3264:2448,rkisp1_isp:2:BGGR8:3264:2448,rkisp1_resizer_mainpath:0:BGGR8:3264:2448,rkisp1_resizer_mainpath:1:BGGR8:3264:2448
+media-crops=rkisp1_isp:0:0:0:3264:2448,rkisp1_isp:2:0:0:3264:2448,rkisp1_resizer_mainpath:0:0:0:3264:768
diff --git a/config/xiaomi,scorpio.ini b/config/xiaomi,scorpio.ini
index cce6d49..14b7f29 100644
--- a/config/xiaomi,scorpio.ini
+++ b/config/xiaomi,scorpio.ini
@@ -15,3 +15,4 @@ preview-rate=30
preview-fmt=RGGB10P
rotate=90
media-links=imx318 3-001a:0->msm_csiphy0:0,msm_csiphy0:1->msm_csid0:0,msm_csid0:1->msm_ispif0:0,msm_ispif0:1->msm_vfe0_rdi0:0
+media-formats=imx318 3-001a:0:RGGB10P:3840:2160,msm_csiphy0:0:RGGB10P:3840:2160,msm_csiphy0:1:RGGB10P:3840:2160,msm_csid0:0:RGGB10P:3840:2160,msm_csid0:1:RGGB10P:3840:2160,msm_ispif0:0:RGGB10P:3840:2160,msm_ispif0:1:RGGB10P:3840:2160,msm_vfe0_rdi0:0:RGGB10P:3840:2160
diff --git a/meson.build b/meson.build
index 3b98f19..d53dec9 100644
--- a/meson.build
+++ b/meson.build
@@ -72,6 +72,7 @@ install_data(
'config/pine64,pinephone-1.0.ini',
'config/pine64,pinephone-1.1.ini',
'config/pine64,pinephone-1.2.ini',
+ 'config/pine64,pinephone-pro.ini',
'config/pine64,pinetab.ini',
'config/xiaomi,scorpio.ini',
],
diff --git a/src/camera.c b/src/camera.c
index 9a08f56..7368189 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -305,11 +305,11 @@ mp_camera_set_mode(MPCamera *camera, MPMode *mode)
}
// Update the mode
- mode->pixel_format =
- mp_pixel_format_from_v4l_bus_code(fmt.format.code);
- mode->frame_interval = interval.interval;
- mode->width = fmt.format.width;
- mode->height = fmt.format.height;
+ //mode->pixel_format =
+ // mp_pixel_format_from_v4l_bus_code(fmt.format.code);
+ //mode->frame_interval = interval.interval;
+ //mode->width = fmt.format.width;
+ //mode->height = fmt.format.height;
}
// Set the mode for the video device
diff --git a/src/device.c b/src/device.c
index 9e2db00..1161861 100644
--- a/src/device.c
+++ b/src/device.c
@@ -8,6 +8,8 @@
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
+#include <linux/v4l2-subdev.h>
+#include <linux/media.h>
bool
mp_find_device_path(struct media_v2_intf_devnode devnode, char *path, int length)
@@ -183,6 +185,25 @@ mp_device_setup_entity_link(MPDevice *device,
return true;
}
+void
+mp_device_setup_media_link(MPDevice *device,
+ const struct mp_media_link_config *cfg,
+ bool enable)
+{
+ const struct media_v2_entity *source_entity =
+ mp_device_find_entity(device, cfg->source_name);
+
+ const struct media_v2_entity *target_entity =
+ mp_device_find_entity(device, cfg->target_name);
+
+ mp_device_setup_entity_link(device,
+ source_entity->id,
+ target_entity->id,
+ cfg->source_port,
+ cfg->target_port,
+ enable);
+}
+
bool
mp_device_setup_link(MPDevice *device,
uint32_t source_pad_id,
@@ -237,6 +258,73 @@ mp_entity_pad_set_format(MPDevice *device,
return true;
}
+const struct media_v2_pad *
+mp_device_get_pad_at_index_from_entity(const MPDevice *device, uint32_t entity_id, uint32_t index)
+{
+ for (int i = 0; i < device->num_pads; ++i) {
+ if (device->pads[i].entity_id == entity_id && index-- == 0) {
+ return &device->pads[i];
+ }
+ }
+ return NULL;
+}
+
+bool
+mp_device_setup_link_by_name(MPDevice *device,
+ const char *source_entity_name,
+ uint32_t source_pad_index,
+ const char *sink_entity_name,
+ uint32_t sink_pad_index,
+ bool enabled)
+{
+ const struct media_v2_entity *source_entity =
+ mp_device_find_entity
+ (device, source_entity_name);
+ const struct media_v2_entity *sink_entity =
+ mp_device_find_entity
+ (device, sink_entity_name);
+
+ struct media_link_desc link = {};
+ link.flags = enabled ? MEDIA_LNK_FL_ENABLED : 0;
+ link.source.entity = source_entity->id;
+ link.source.index = source_pad_index;
+ link.sink.entity = sink_entity->id;
+ link.sink.index = sink_pad_index;
+ if (xioctl(device->fd, MEDIA_IOC_SETUP_LINK, &link) == -1) {
+ errno_printerr("MEDIA_IOC_SETUP_LINK");
+ return false;
+ }
+
+ return true;
+}
+
+int
+mp_device_get_fd_by_name(const MPDevice *device, const char *driver_name)
+{
+ struct media_entity_desc desc = {};
+
+ desc.id |= MEDIA_ENT_ID_FLAG_NEXT;
+
+ while(true) {
+ desc.id |= MEDIA_ENT_ID_FLAG_NEXT;
+ if(xioctl(device->fd, MEDIA_IOC_ENUM_ENTITIES, &desc) == -1) {
+ errno_printerr("MEDIA_IOC_ENUM_ENTITIES");
+ return -1;
+ }
+
+ if(strncmp(desc.name, driver_name, 32) == 0) {
+ const uint32_t major = desc.dev.major;
+ const uint32_t minor = desc.dev.minor;
+ char path[256];
+ int rc = snprintf(path, 256, "/dev/char/%u:%u", major, minor);
+
+ return rc > 0 ? open(path, O_RDWR) : -1;
+ }
+ }
+
+ return -1;
+}
+
const struct media_v2_entity *
mp_device_find_entity(const MPDevice *device, const char *driver_name)
{
@@ -263,6 +351,19 @@ mp_device_find_entity_type(const MPDevice *device, const uint32_t type)
return NULL;
}
+bool
+mp_xioctl(const MPDevice *device, const char *driver_name, unsigned long request, void *argp)
+{
+ int fd = mp_device_get_fd_by_name(device, driver_name);
+
+ if(fd < 0)
+ {
+ printf("ERROR: device with driver name %s not found\n", driver_name);
+ }
+
+ return fd >= 0 && xioctl(fd, request, argp) != -1;
+}
+
const struct media_device_info *
mp_device_get_info(const MPDevice *device)
{
diff --git a/src/device.h b/src/device.h
index 1894c67..b324e1a 100644
--- a/src/device.h
+++ b/src/device.h
@@ -1,6 +1,7 @@
#pragma once
#include "mode.h"
+#include "camera_config.h"
#include <linux/media.h>
#include <stdbool.h>
@@ -26,6 +27,10 @@ bool mp_device_setup_entity_link(MPDevice *device,
uint32_t sink_index,
bool enabled);
+void mp_device_setup_media_link(MPDevice *device,
+ const struct mp_media_link_config *cfg,
+ bool enable);
+
bool mp_device_setup_link(MPDevice *device,
uint32_t source_pad_id,
uint32_t sink_pad_id,
@@ -36,6 +41,15 @@ bool mp_entity_pad_set_format(MPDevice *device,
uint32_t pad,
MPMode *mode);
+bool mp_xioctl(const MPDevice *device, const char *driver_name, unsigned long request, void *argp);
+
+bool mp_device_setup_link_by_name(MPDevice *device,
+ const char *source_entity_name,
+ uint32_t source_pad_index,
+ const char *sink_entity_name,
+ uint32_t sink_pad_index,
+ bool enabled);
+
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 char *driver_name);
diff --git a/src/io_pipeline.c b/src/io_pipeline.c
index 8434420..598118f 100644
--- a/src/io_pipeline.c
+++ b/src/io_pipeline.c
@@ -47,7 +47,8 @@ struct camera_info {
// int media_fd;
// struct mp_media_link media_links[MP_MAX_LINKS];
- // int num_media_links;
+ struct mp_media_link_config media_links[MP_MAX_LINKS];
+ int num_media_links;
// int gain_ctrl;
};
@@ -100,30 +101,52 @@ static bool want_focus = false;
static MPPipeline *pipeline;
static GSource *capture_source;
+// TODO: move to device.c
+static void
+mp_setup_media_link_pad_crops(struct device_info *dev_info,
+ const struct mp_media_crop_config media_crops[],
+ int num_media_crops)
+{
+ for(int i = 0; i < num_media_crops; i++) {
+ const struct mp_media_crop_config *crop = media_crops + i;
+ struct v4l2_subdev_crop v4l2_crop = {};
+ v4l2_crop.pad = crop->pad;
+ v4l2_crop.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+ v4l2_crop.rect.top = crop->top;
+ v4l2_crop.rect.left = crop->left;
+ v4l2_crop.rect.width = crop->width;
+ v4l2_crop.rect.height = crop->height;
+
+ if(!mp_xioctl(dev_info->device, crop->name, VIDIOC_SUBDEV_S_CROP, &v4l2_crop)) {
+ //errno_printerr("VIDIOC_SUBDEV_S_CROP");
+ }
+ }
+}
+
static void
mp_setup_media_link_pad_formats(struct device_info *dev_info,
- const struct mp_media_link_config media_links[],
- int num_media_links,
- MPMode *mode)
+ const struct mp_media_format_config media_formats[],
+ int num_media_formats)
{
- const struct media_v2_entity *entities[2];
- int ports[2];
- for (int i = 0; i < num_media_links; i++) {
- entities[0] = mp_device_find_entity(
- dev_info->device, (const char *)media_links[i].source_name);
- entities[1] = mp_device_find_entity(
- dev_info->device, (const char *)media_links[i].target_name);
- ports[0] = media_links[i].source_port;
- ports[1] = media_links[i].target_port;
-
- for (int j = 0; j < 2; j++)
- if (!mp_entity_pad_set_format(
- dev_info->device, entities[j], ports[j], mode)) {
- g_printerr("Failed to set %s:%d format\n",
- entities[j]->name,
- ports[j]);
- exit(EXIT_FAILURE);
- }
+ for(int i = 0; i < num_media_formats; i++) {
+ const struct mp_media_format_config *format =
+ media_formats + i;
+ const struct media_v2_entity *entity =
+ mp_device_find_entity
+ (dev_info->device, format->name);
+ MPMode *mode =
+ (MPMode *)
+ &format->mode;
+ bool successful =
+ mp_entity_pad_set_format
+ (dev_info->device, entity, format->pad, mode);
+
+ if(!successful) {
+ g_printerr( "Failed to set %s:%d format\n",
+ entity->name,
+ format->pad );
+ exit(EXIT_FAILURE);
+ }
}
}
@@ -191,6 +214,9 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
struct device_info *dev_info = &devices[device_index];
info->device_index = device_index;
+ info->num_media_links = config->num_media_links;
+
+ memcpy(info->media_links, config->media_links, MP_MAX_LINKS * sizeof(struct mp_media_link_config));
const struct media_v2_entity *entity =
mp_device_find_entity(dev_info->device, config->dev_name);
@@ -205,11 +231,33 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
info->pad_id = pad->id;
- // Make sure the camera starts out as disabled
- mp_device_setup_link(dev_info->device,
- info->pad_id,
- dev_info->interface_pad_id,
- false);
+ // Only disable the camera here if no links are defined in the
+ // config file.
+ if(config->num_media_links == 0)
+ {
+ // Make sure the camera starts out as disabled
+ mp_device_setup_link(dev_info->device,
+ info->pad_id,
+ dev_info->interface_pad_id,
+ false);
+ }
+
+ // If links are defined, disable all of them.
+ const size_t num_links =
+ mp_device_get_num_links(dev_info->device);
+ const struct media_v2_link *links =
+ mp_device_get_links(dev_info->device);
+
+ for(int i = 0; i < num_links; i++) {
+ const struct media_v2_link *link = links + i;
+
+ if(!(link->flags & MEDIA_LNK_FL_IMMUTABLE)) {
+ mp_device_setup_link(dev_info->device,
+ link->source_id,
+ link->sink_id,
+ false);
+ }
+ }
const struct media_v2_interface *interface =
mp_device_find_entity_interface(dev_info->device,
@@ -234,11 +282,14 @@ setup_camera(MPDeviceList **device_list, const struct mp_camera_config *config)
// the ov5640 driver where it won't allow setting the preview
// format initially.
MPMode mode = config->capture_mode;
- if (config->num_media_links)
+ if (config->num_media_formats)
mp_setup_media_link_pad_formats(dev_info,
- config->media_links,
- config->num_media_links,
- &mode);
+ config->media_formats,
+ config->num_media_formats);
+ if (config->num_media_crops)
+ mp_setup_media_link_pad_crops(dev_info,
+ config->media_crops,
+ config->num_media_crops);
mp_camera_set_mode(info->camera, &mode);
// Trigger continuous auto focus if the sensor supports it
@@ -400,9 +451,12 @@ capture(MPPipeline *pipeline, const void *data)
mode = camera->capture_mode;
if (camera->num_media_links)
mp_setup_media_link_pad_formats(dev_info,
- camera->media_links,
- camera->num_media_links,
- &mode);
+ camera->media_formats,
+ camera->num_media_formats);
+ if (camera->num_media_crops)
+ mp_setup_media_link_pad_crops(dev_info,
+ camera->media_crops,
+ camera->num_media_crops);
mp_camera_set_mode(info->camera, &mode);
just_switched_mode = true;
@@ -569,9 +623,13 @@ on_frame(MPBuffer buffer, void *_data)
if (camera->num_media_links)
mp_setup_media_link_pad_formats(
dev_info,
- camera->media_links,
- camera->num_media_links,
- &mode);
+ camera->media_formats,
+ camera->num_media_formats);
+ if (camera->num_media_crops)
+ mp_setup_media_link_pad_crops(
+ dev_info,
+ camera->media_crops,
+ camera->num_media_crops);
mp_camera_set_mode(info->camera, &mode);
just_switched_mode = true;
@@ -587,25 +645,6 @@ on_frame(MPBuffer buffer, void *_data)
}
}
-static void
-mp_setup_media_link(struct device_info *dev_info,
- const struct mp_media_link_config *cfg,
- bool enable)
-{
- const struct media_v2_entity *source_entity =
- mp_device_find_entity(dev_info->device, cfg->source_name);
-
- const struct media_v2_entity *target_entity =
- mp_device_find_entity(dev_info->device, cfg->target_name);
-
- mp_device_setup_entity_link(dev_info->device,
- source_entity->id,
- target_entity->id,
- cfg->source_port,
- cfg->target_port,
- enable);
-}
-
static void
update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
{
@@ -629,8 +668,8 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
// Disable media links
for (int i = 0; i < camera->num_media_links; i++)
- mp_setup_media_link(
- dev_info, &camera->media_links[i], false);
+ mp_device_setup_media_link(
+ dev_info->device, &camera->media_links[i], false);
}
if (capture_source) {
@@ -644,23 +683,32 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
struct camera_info *info = &cameras[camera->index];
struct device_info *dev_info = &devices[info->device_index];
- mp_device_setup_link(dev_info->device,
- info->pad_id,
- dev_info->interface_pad_id,
- true);
+ // Only enable the camera here if no links are defined
+ // in the config file.
+ if(info->num_media_links == 0)
+ {
+ mp_device_setup_link(dev_info->device,
+ info->pad_id,
+ dev_info->interface_pad_id,
+ true);
+ }
- // Enable media links
+ // If links are defined, enable all of them.
for (int i = 0; i < camera->num_media_links; i++)
- mp_setup_media_link(
- dev_info, &camera->media_links[i], true);
+ mp_device_setup_media_link(
+ dev_info->device, &camera->media_links[i], true);
mode = camera->preview_mode;
if (camera->num_media_links)
mp_setup_media_link_pad_formats(
dev_info,
- camera->media_links,
- camera->num_media_links,
- &mode);
+ camera->media_formats,
+ camera->num_media_formats);
+ if (camera->num_media_crops)
+ mp_setup_media_link_pad_crops(
+ dev_info,
+ camera->media_crops,
+ camera->num_media_crops);
mp_camera_set_mode(info->camera, &mode);
mp_camera_start_capture(info->camera);

View File

@ -28,6 +28,12 @@ DEPEND="
media-libs/libmegapixels media-libs/libmegapixels
" "
PATCHES=(
"${FILESDIR}"/06230f3a02cffdf8b683f85cb32fc256d73615d9.patch'
"${FILESDIR}"/27a1e606d680295e0b4caceadf74ff5857ac16b2.patch'
"${FILESDIR}"/d8b35bc223989cb165ba1b0716ab9f0ca9c43e53.patch'
)
RDEPEND="${DEPEND}" RDEPEND="${DEPEND}"
BDEPEND="" BDEPEND=""

View File

@ -1,239 +0,0 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License-2
EAPI=8
CRATES="
autocfg-1.1.0
cfg-if-1.0.0
pin-utils-0.1.0
dlib-0.5.0
field-offset-0.3.5
form_urlencoded-1.1.0
ctor-0.1.26
crypto-common-0.1.6
scoped-tls-1.0.1
cairo-sys-rs-0.17.0
async-recursion-1.0.4
proc-macro-error-1.0.4
serde_repr-0.1.12
version_check-0.9.4
serde_spanned-0.6.1
sha1-0.10.5
gsk4-sys-0.6.3
memoffset-0.8.0
gdk-pixbuf-sys-0.17.0
quote-1.0.26
futures-core-0.3.28
gdk4-wayland-0.6.3
xdg-home-1.0.0
muldiv-1.0.1
thread_local-1.1.7
futures-io-0.3.28
memoffset-0.7.1
graphene-sys-0.17.0
temp-dir-0.1.11
gdk4-x11-sys-0.6.3
async-trait-0.1.68
async-lock-2.7.0
bitflags-1.3.2
tracing-log-0.1.3
tinyvec_macros-0.1.1
rand_chacha-0.3.1
proc-macro-error-attr-1.0.4
downcast-rs-1.2.0
gdk4-wayland-sys-0.6.3
pretty-hex-0.3.0
zbus_names-2.5.0
waker-fn-1.1.0
wayland-sys-0.30.1
event-listener-2.5.3
futures-executor-0.3.28
iana-time-zone-0.1.56
futures-macro-0.3.28
graphene-rs-0.17.1
lazy_static-1.4.0
gstreamer-gl-x11-0.20.0
gobject-sys-0.17.4
hex-0.4.3
zvariant_utils-1.0.0
async-global-executor-2.3.1
zvariant_derive-3.12.0
gstreamer-gl-egl-0.20.0
generic-array-0.14.7
thiserror-impl-1.0.40
parking-2.1.0
concurrent-queue-2.2.0
enumflags2-0.7.7
semver-1.0.17
num-integer-0.1.45
gstreamer-gl-wayland-sys-0.20.0
libloading-0.7.4
version-compare-0.1.1
gstreamer-gl-x11-sys-0.20.0
heck-0.4.1
toml_datetime-0.6.1
locale_config-0.3.0
async-fs-1.6.0
gstreamer-gl-egl-sys-0.20.0
enumflags2_derive-0.7.7
thiserror-1.0.40
static_assertions-1.1.0
gdk-pixbuf-0.17.0
futures-channel-0.3.28
crossbeam-utils-0.8.15
futures-task-0.3.28
indexmap-1.9.3
slab-0.4.8
pin-project-lite-0.2.9
async-channel-1.8.0
byteorder-1.4.3
io-lifetimes-1.0.10
atomic-waker-1.1.1
ordered-stream-0.2.0
ppv-lite86-0.2.17
libadwaita-sys-0.4.1
unicode-ident-1.0.8
pango-sys-0.17.0
nu-ansi-term-0.46.0
gstreamer-base-sys-0.20.0
atomic_refcell-0.1.10
overload-0.1.1
option-operations-0.5.0
serde_derive-1.0.160
toml-0.7.3
digest-0.10.6
num-rational-0.4.1
percent-encoding-2.2.0
socket2-0.4.9
zbus_macros-3.12.0
pkg-config-0.3.26
system-deps-6.0.5
derivative-2.2.0
unicode-bidi-0.3.13
typenum-1.16.0
smallvec-1.10.0
async-io-1.13.0
glib-macros-0.17.9
gstreamer-base-0.20.5
anyhow-1.0.70
getrandom-0.2.9
target-lexicon-0.12.7
once_cell-1.17.1
rand-0.8.5
pango-0.17.4
tracing-attributes-0.1.24
value-bag-1.0.0-alpha.9
memchr-2.5.0
proc-macro-crate-1.3.1
serde-1.0.160
gstreamer-audio-0.20.4
wayland-scanner-0.30.0
polling-2.8.0
gio-sys-0.17.4
wayland-client-0.30.1
paste-1.0.12
gstreamer-pbutils-0.20.5
gstreamer-pbutils-sys-0.20.0
gstreamer-video-sys-0.20.0
gstreamer-sys-0.20.0
gstreamer-gl-0.20.0
gtk4-sys-0.6.3
proc-macro2-1.0.56
tracing-core-0.1.30
hashbrown-0.12.3
glib-sys-0.17.4
async-task-4.4.0
num-traits-0.2.15
cfg-expr-0.15.1
gdk4-sys-0.6.3
wayland-backend-0.1.2
url-2.3.1
cc-1.0.79
libadwaita-0.4.1
futures-lite-1.13.0
tinyvec-1.6.0
sharded-slab-0.1.4
cairo-rs-0.17.0
gstreamer-video-0.20.4
rand_core-0.6.4
gstreamer-gl-sys-0.20.0
tracing-0.1.38
zvariant-3.12.0
ashpd-0.4.0
gdk4-0.6.3
kv-log-macro-1.0.7
gstreamer-audio-sys-0.20.0
gst-plugin-gtk4-0.10.5
futures-sink-0.3.28
toml_edit-0.19.8
async-executor-1.5.1
async-broadcast-0.5.1
blocking-1.3.1
log-0.4.17
gsk4-0.6.3
chrono-0.4.24
gtk4-macros-0.6.6
futures-util-0.3.28
block-buffer-0.10.4
gstreamer-gl-wayland-0.20.0
cpufeatures-0.2.7
rustc_version-0.4.0
unicode-normalization-0.1.22
fastrand-1.9.0
gettext-rs-0.7.0
gio-0.17.9
gst-plugin-version-helper-0.7.5
gdk4-x11-0.6.3
winnow-0.4.1
zbus-3.12.0
idna-0.3.0
aho-corasick-1.0.1
quick-xml-0.23.1
tracing-subscriber-0.3.17
nix-0.26.2
syn-2.0.15
glib-0.17.9
regex-1.8.1
async-std-1.12.0
syn-1.0.109
rustix-0.37.15
regex-syntax-0.7.1
gstreamer-0.20.5
gtk4-0.6.6
libc-0.2.142
linux-raw-sys-0.3.4
gettext-sys-0.21.3
"
inherit cargo gnome2-utils meson toolchain-funcs xdg
DESCRIPTION="Gnome Camera Application"
HOMEPAGE="https://gitlab.gnome.org/GNOME/snapshot"
SRC_URI="https://gitlab.gnome.org/GNOME/snapshot/-/archive/${PV}/snapshot-${PV}.tar.gz"
SRC_URI+=" $(cargo_crate_uris ${CRATES})"
#RESTRICT="network-sandbox"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
DEPEND="
>=x11-libs/gtk+-3.0
>=gui-libs/libadwaita-1.4.0_alpha
>=media-libs/gstreamer-1.20.0
media-video/wireplumber
media-video/pipewire[gstreamer]
"
RDEPEND="${DEPEND}"
BDEPEND=""
pkg_postinst() {
xdg_pkg_postinst
gnome2_schemas_update
}
pkg_postrm() {
xdg_pkg_postrm
gnome2_schemas_update
}