Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp653761pxu; Fri, 11 Dec 2020 10:55:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIUi7/Eb/gcjAVi9VJGRZ6iUGNpNHELI4A8MKON5ZkR5S+/uQaIeFGp4BaThbba1bDyACe X-Received: by 2002:a17:906:30d2:: with SMTP id b18mr12156883ejb.109.1607712924038; Fri, 11 Dec 2020 10:55:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607712924; cv=none; d=google.com; s=arc-20160816; b=gFY/egl250Me2QJOzGK0C1YSC/k/afGRau2r9hIUEhMo13oCVjV3tlSc/lkdQbYpiO ZJvUWA/yTFFe5Sxt0Jveq1yLWuQr/Ys+MXFFB4tfLXeocVmj284+LtYZA2GJ4c5/v8cY vtHvVqNz04ykk7m2o/RMY3OWHPvtaiF79o/8Ub8kc4YZ4hA9ps2wwR4JCQx9HHcZjZ55 PTMQt5IozPWY2hMM3teL0BYrPAI42KLQZCRzd/nsC/XVZDmNGubuYcCIR7pEgPUV8Jdr TM0CFFuXQALTRwmqXhnUZUEaK0vAQKJ8M9cBwV6v7QgFXmk4FOJ1lqvCTqQJ4GYG9z8w B6Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=ncGsj+Oy+F4Lel7edOJaT66wM9yPnydfWvWB30dUNxo=; b=ud9Lh1W/C04q/nVEajwmQ02ko1Y6H7NVQeh92grtu5EzBxyPqZX2eW00F16aru/3X5 ivFHJAcOn0dzklP7sCMTqMVt7az5bm5YgFjZI1kPEC2UDNitzz8Sz2AcMjxE2nhRnJhF qaBqCY280Uvf1RKLsUfz47P5z92KLiooNAj4shuPHb+4WSH+kRQNwaPGiyAIyY3dYG+J eYqo/3op7GP6hbFa1raEUduRX9px0TH6Hkm4/mDdz2Yqp4SrCh08jX+lUlbM9VmKI3z1 lvzZvpqrkOOksfCCLzI6Ed0dTc8kZNqRqyAaRxK9QC0naloAixHLhGZfSC7a0JCy2vjc jRTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=pRkNbvPB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si4986423edb.389.2020.12.11.10.54.57; Fri, 11 Dec 2020 10:55:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=pRkNbvPB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394076AbgLKRE5 (ORCPT + 99 others); Fri, 11 Dec 2020 12:04:57 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:5412 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405403AbgLKREe (ORCPT ); Fri, 11 Dec 2020 12:04:34 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 11 Dec 2020 09:02:53 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 11 Dec 2020 17:02:53 +0000 Received: from skomatineni-linux.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Fri, 11 Dec 2020 17:02:52 +0000 From: Sowjanya Komatineni To: , , , , , CC: , , , , Subject: [PATCH v4 09/13] media: tegra-video: Implement V4L2 device notify callback Date: Fri, 11 Dec 2020 09:02:38 -0800 Message-ID: <1607706162-1548-10-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607706162-1548-1-git-send-email-skomatineni@nvidia.com> References: <1607706162-1548-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1607706173; bh=ncGsj+Oy+F4Lel7edOJaT66wM9yPnydfWvWB30dUNxo=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-NVConfidentiality:MIME-Version:Content-Type; b=pRkNbvPBYVQEx/xrYcvJvEkT7V/3iOamjH60r5h3ipSq0E8VSgLA9Zz9AfHnUy4nH djyaqbNHpJ0Xb7feGOoNHi1gLLE6v49yqS0Mtlkn6XZh31qM8aw7hIXtncGprYq3rG igLRQzpPZm7oMP9yulUxd7y1xwENtiPA61zjMXR6bxQxyPOLTiJJIJAEjUCTmMhLSt kZ+zK/tbYL8Yj/4rFL0U1P3X4xXZMyr7/uodULb4yQB+t1qm0Sx6vpohpdZHAqeq9y 24SdrHO0qxixdr8HsmOhxGDFw/6klt4/bCktTGvIOBs3K9/bHhlSBYSHCjqF/LtuT+ QME9b+6OPFybQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement V4L2 device notify callback to handle V4L2_EVENT_SOURCE_CHANGE event from subdevices. HDMI-to-CSI bridge drivers trigger V4L2_EVENT_SOURCE_CHANGE when source DV timing changes are detected or when HDMI hotplug happens. Runtime source parameter changes during active streaming is not allowed and Tegra video driver calls vb2_queue_error to signal a fatal error if a notification of this event happens during an active streaming. Signed-off-by: Sowjanya Komatineni --- drivers/staging/media/tegra-video/vi.c | 3 +++ drivers/staging/media/tegra-video/video.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 0a85e52..d42a218 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1636,6 +1636,9 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) v4l2_set_subdev_hostdata(subdev, chan); + subdev = tegra_channel_get_remote_source_subdev(chan); + v4l2_set_subdev_hostdata(subdev, chan); + return 0; unregister_video: diff --git a/drivers/staging/media/tegra-video/video.c b/drivers/staging/media/tegra-video/video.c index e50bd70..d966b31 100644 --- a/drivers/staging/media/tegra-video/video.c +++ b/drivers/staging/media/tegra-video/video.c @@ -7,6 +7,8 @@ #include #include +#include + #include "video.h" static void tegra_v4l2_dev_release(struct v4l2_device *v4l2_dev) @@ -24,6 +26,21 @@ static void tegra_v4l2_dev_release(struct v4l2_device *v4l2_dev) kfree(vid); } +static void tegra_v4l2_dev_notify(struct v4l2_subdev *sd, + unsigned int notification, void *arg) +{ + struct tegra_vi_channel *chan; + const struct v4l2_event *ev = arg; + + if (notification != V4L2_DEVICE_NOTIFY_EVENT) + return; + + chan = v4l2_get_subdev_hostdata(sd); + v4l2_event_queue(&chan->video, arg); + if (ev->type == V4L2_EVENT_SOURCE_CHANGE && vb2_is_streaming(&chan->queue)) + vb2_queue_error(&chan->queue); +} + static int host1x_video_probe(struct host1x_device *dev) { struct tegra_video_device *vid; @@ -49,6 +66,7 @@ static int host1x_video_probe(struct host1x_device *dev) vid->v4l2_dev.mdev = &vid->media_dev; vid->v4l2_dev.release = tegra_v4l2_dev_release; + vid->v4l2_dev.notify = tegra_v4l2_dev_notify; ret = v4l2_device_register(&dev->dev, &vid->v4l2_dev); if (ret < 0) { dev_err(&dev->dev, -- 2.7.4