1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00
openmptcprouter/6.12/target/linux/bcm27xx/patches-6.12/950-0452-media-bcm2835-unicam-Add-option-for-a-GPIO-to-reflec.patch
Ycarus (Yannick Chabanois) bdb9b0046f Add bcm27xx 6.12 test support
2024-12-20 14:17:26 +01:00

66 lines
2 KiB
Diff

From be17c7218cdeca01ef54715fbffc7695c6d75ef0 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Wed, 3 Apr 2024 16:06:08 +0100
Subject: [PATCH 452/697] media: bcm2835-unicam: Add option for a GPIO to
reflect FS/FE timing
The legacy stack had an option to have a GPIO track frame start and
end events to give basic synchronisation to the incoming image stream.
https://forums.raspberrypi.com/viewtopic.php?t=190314
Replicate this in the kernel Unicam driver.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
drivers/media/platform/bcm2835/bcm2835-unicam.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
+++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
@@ -49,6 +49,7 @@
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
+#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
@@ -532,6 +533,8 @@ struct unicam_device {
struct v4l2_device v4l2_dev;
struct media_device mdev;
+ struct gpio_desc *sync_gpio;
+
/* parent device */
struct platform_device *pdev;
/* subdevice async Notifier */
@@ -932,6 +935,8 @@ static irqreturn_t unicam_isr(int irq, v
if (fe) {
bool inc_seq = unicam->frame_started;
+ if (unicam->sync_gpio)
+ gpiod_set_value(unicam->sync_gpio, 0);
/*
* Ensure we have swapped buffers already as we can't
* stop the peripheral. If no buffer is available, use a
@@ -992,6 +997,10 @@ static irqreturn_t unicam_isr(int irq, v
* aka frame start.
*/
ts = ktime_get_ns();
+
+ if (unicam->sync_gpio)
+ gpiod_set_value(unicam->sync_gpio, 1);
+
for (i = 0; i < ARRAY_SIZE(unicam->node); i++) {
if (!unicam->node[i].streaming)
continue;
@@ -3396,6 +3405,9 @@ static int unicam_probe(struct platform_
goto err_unicam_put;
}
+ unicam->sync_gpio = devm_gpiod_get_optional(&pdev->dev, "sync",
+ GPIOD_OUT_LOW);
+
ret = platform_get_irq(pdev, 0);
if (ret <= 0) {
dev_err(&pdev->dev, "No IRQ resource\n");