Skip to content

Commit 6a0ae67

Browse files
6by9pelwell
authored andcommitted
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 <[email protected]>
1 parent 017f788 commit 6a0ae67

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/media/platform/bcm2835/bcm2835-unicam.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/device.h>
5050
#include <linux/dma-mapping.h>
5151
#include <linux/err.h>
52+
#include <linux/gpio/consumer.h>
5253
#include <linux/init.h>
5354
#include <linux/interrupt.h>
5455
#include <linux/io.h>
@@ -543,6 +544,8 @@ struct unicam_device {
543544
struct v4l2_device v4l2_dev;
544545
struct media_device mdev;
545546

547+
struct gpio_desc *sync_gpio;
548+
546549
/* parent device */
547550
struct platform_device *pdev;
548551
/* subdevice async Notifier */
@@ -943,6 +946,8 @@ static irqreturn_t unicam_isr(int irq, void *dev)
943946
if (fe) {
944947
bool inc_seq = unicam->frame_started;
945948

949+
if (unicam->sync_gpio)
950+
gpiod_set_value(unicam->sync_gpio, 0);
946951
/*
947952
* Ensure we have swapped buffers already as we can't
948953
* stop the peripheral. If no buffer is available, use a
@@ -1003,6 +1008,10 @@ static irqreturn_t unicam_isr(int irq, void *dev)
10031008
* aka frame start.
10041009
*/
10051010
ts = ktime_get_ns();
1011+
1012+
if (unicam->sync_gpio)
1013+
gpiod_set_value(unicam->sync_gpio, 1);
1014+
10061015
for (i = 0; i < ARRAY_SIZE(unicam->node); i++) {
10071016
if (!unicam->node[i].streaming)
10081017
continue;
@@ -3407,6 +3416,9 @@ static int unicam_probe(struct platform_device *pdev)
34073416
goto err_unicam_put;
34083417
}
34093418

3419+
unicam->sync_gpio = devm_gpiod_get_optional(&pdev->dev, "sync",
3420+
GPIOD_OUT_LOW);
3421+
34103422
ret = platform_get_irq(pdev, 0);
34113423
if (ret <= 0) {
34123424
dev_err(&pdev->dev, "No IRQ resource\n");

0 commit comments

Comments
 (0)