From nobody Mon Nov 25 02:46:58 2024 Received: from mx.gpxsee.org (mx.gpxsee.org [37.205.14.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08BAD1E7C0A; Wed, 30 Oct 2024 12:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.205.14.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730290506; cv=none; b=AIITliwaNzSUr66+QSQUtM76BwTtSFcxhMMfNfxsqm7uuvlXnBw+YnKlTQ2cFPew1OvH/IUKsIBCkSYa/ragO4Sk3GRrWmuDpcpnWsskgBJgprsOG7HXp6cngvhDHc3mCXVI0pjdJbrVdxjEslT6ThwuX+149xMbp3dBkQut59k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730290506; c=relaxed/simple; bh=UhSiF+V6M9qHwAONR8rQ3KB37XoyLkc3yCdh97dZiGQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=N6CHLUnObQWDh+GsQxQvlu8PjYBKgHUeNG2FBosIWyr5F3+Gsa9+I5pZJtLrUCHEk19iNAHWk6yHv69ufgeUTLdBgmLy10r4RpbjxeHkwBsQp/E5LAdbiup/T5LJkFdgIpEC9xgHQzkI/QILEGwGiLCF9+85bw3y+fQCxGsaxMA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gpxsee.org; spf=pass smtp.mailfrom=gpxsee.org; arc=none smtp.client-ip=37.205.14.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gpxsee.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gpxsee.org Received: from mgb4.. (unknown [62.77.71.229]) by mx.gpxsee.org (Postfix) with ESMTPSA id 3A3386F807; Wed, 30 Oct 2024 13:14:54 +0100 (CET) From: tumic@gpxsee.org To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Martin=20T=C5=AFma?= Subject: [PATCH] media: mgb4: Fix inconsistent input/output alignment in loopback mode Date: Wed, 30 Oct 2024 13:14:46 +0100 Message-ID: <20241030121446.1743-1-tumic@gpxsee.org> X-Mailer: git-send-email 2.46.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Martin T=C5=AFma 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=C5=AFma --- 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/mg= b4/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) =3D=3D 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); + } =20 if (val =3D=3D 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/mgb= 4_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; } =20 -static int fh_release(struct file *file) -{ - struct mgb4_vin_dev *vindev =3D video_drvdata(file); - int rv; - - mutex_lock(&vindev->lock); - - if (v4l2_fh_is_singular_file(file)) - set_loopback_padding(vindev, 0); - - rv =3D _vb2_fop_release(file, NULL); - - mutex_unlock(&vindev->lock); - - return rv; -} - static const struct v4l2_file_operations video_fops =3D { .owner =3D THIS_MODULE, .open =3D fh_open, - .release =3D fh_release, + .release =3D vb2_fop_release, .unlocked_ioctl =3D video_ioctl2, .read =3D vb2_fop_read, .mmap =3D vb2_fop_mmap, base-commit: 698b6e3163bafd61e1b7d13572e2c42974ac85ec --=20 2.46.2