From: Martin Tůma <martin.tuma@xxxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxx> --- drivers/media/pci/mgb4/mgb4_sysfs_out.c | 5 ++++- drivers/media/pci/mgb4/mgb4_vin.c | 19 +------------------ 2 files changed, 5 insertions(+), 19 deletions(-) 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, base-commit: 698b6e3163bafd61e1b7d13572e2c42974ac85ec -- 2.46.2