diff mbox series

media: mgb4: Fix inconsistent input/output alignment in loopback mode

Message ID 20241030121446.1743-1-tumic@gpxsee.org
State New
Headers show
Series media: mgb4: Fix inconsistent input/output alignment in loopback mode | expand

Commit Message

Martin Tůma Oct. 30, 2024, 12:14 p.m. UTC
From: Martin Tůma <martin.tuma@digiteqautomotive.com>

Fixes broken output due to different input/output alignment in loopback
mode when the (last) input device is closed. Instead of on device close,
do the alignment synchronisation when enabling the loopback.

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
---
 drivers/media/pci/mgb4/mgb4_sysfs_out.c |  5 ++++-
 drivers/media/pci/mgb4/mgb4_vin.c       | 19 +------------------
 2 files changed, 5 insertions(+), 19 deletions(-)


base-commit: 698b6e3163bafd61e1b7d13572e2c42974ac85ec
diff mbox series

Patch

diff --git a/drivers/media/pci/mgb4/mgb4_sysfs_out.c b/drivers/media/pci/mgb4/mgb4_sysfs_out.c
index 573aa61c69d4..88429d400ce3 100644
--- a/drivers/media/pci/mgb4/mgb4_sysfs_out.c
+++ b/drivers/media/pci/mgb4/mgb4_sysfs_out.c
@@ -122,9 +122,12 @@  static ssize_t video_source_store(struct device *dev,
 	if (loopin_old && loopin_cnt(loopin_old) == 1)
 		mgb4_mask_reg(&mgbdev->video, loopin_old->config->regs.config,
 			      0x2, 0x0);
-	if (loopin_new)
+	if (loopin_new) {
 		mgb4_mask_reg(&mgbdev->video, loopin_new->config->regs.config,
 			      0x2, 0x2);
+		mgb4_write_reg(&mgbdev->video, voutdev->config->regs.padding,
+			       loopin_new->padding);
+	}
 
 	if (val == voutdev->config->id + MGB4_VIN_DEVICES)
 		mgb4_write_reg(&mgbdev->video, voutdev->config->regs.config,
diff --git a/drivers/media/pci/mgb4/mgb4_vin.c b/drivers/media/pci/mgb4/mgb4_vin.c
index 185fb28226b6..1fb28dd443fa 100644
--- a/drivers/media/pci/mgb4/mgb4_vin.c
+++ b/drivers/media/pci/mgb4/mgb4_vin.c
@@ -331,27 +331,10 @@  static int fh_open(struct file *file)
 	return rv;
 }
 
-static int fh_release(struct file *file)
-{
-	struct mgb4_vin_dev *vindev = video_drvdata(file);
-	int rv;
-
-	mutex_lock(&vindev->lock);
-
-	if (v4l2_fh_is_singular_file(file))
-		set_loopback_padding(vindev, 0);
-
-	rv = _vb2_fop_release(file, NULL);
-
-	mutex_unlock(&vindev->lock);
-
-	return rv;
-}
-
 static const struct v4l2_file_operations video_fops = {
 	.owner = THIS_MODULE,
 	.open = fh_open,
-	.release = fh_release,
+	.release = vb2_fop_release,
 	.unlocked_ioctl = video_ioctl2,
 	.read = vb2_fop_read,
 	.mmap = vb2_fop_mmap,