Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp728179pxu; Thu, 3 Dec 2020 11:04:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUAm4bQT0gKqmIyQEJQCZaTXT8w0ueO/wvOXdOaoJMG5V/cr1IxPtY9i26MdMem6RUwlhp X-Received: by 2002:aa7:c892:: with SMTP id p18mr4272709eds.64.1607022287115; Thu, 03 Dec 2020 11:04:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607022287; cv=none; d=google.com; s=arc-20160816; b=EvXZLKtIvYYggNtLj+7vjGvKr5WAIQfFdBQwpl2Y3EZ8B9MZZFxtFiglLA7o1pd5yu OEbtGE1iuksIv4xSHswE4A+PebwpNG6VJL3VBLOEwvKG1s5LJO9EWgYKvMuamKl8DsAE Of+8YINA1lI8ZKcqC0ywcFKT3ycmSX3hgyOenaBzQqBCgmUjbhFktjV3U2Kr525Qv6rp +8Sg9343L2hEri7WmP/ZW9bHLyIbboCEVv4mjWrQy7TUsaye3BPkoEkzhJPPIi1JQ9Nl i5K9s86NtsqHf3jSVbUrC85d68f5cIwLNolbmZXT7DfOv3EXH0AMQByTskmml67kkVb+ RJAA== 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=SrSLhK2JLDi3nW2+49yf1NU0cTHOXWRVgLENEsyrEdIgz2MKWhKivl1mDhkDawT7Vg RH/2V+/RrTpW5MiIGRZXVxBVtjU2DFKgFTwxpeTn5m1o5Jf9JEex64c0UBQkb6yhu2yk ntwLBGMG97e61JNhkpu+10ScArZCKsPVZKSXt1+s7VPXclN2AuggeGW/gkFGahOU8VvT aD5v8AR4k532REXqEg1/lr/QY8NpamYUlHuZfU3LqX+nuciCerL5Iq9IYHlg5akoRX8Z vzmBaFOIeSwzl66h0aL0r+F9NvYgWGHmjnhojBFl3HB/ubvYpUpB+bg85EAiJseei9hj QbVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=WEyVYfyI; 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 eb5si1470192edb.393.2020.12.03.11.04.23; Thu, 03 Dec 2020 11:04:47 -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=WEyVYfyI; 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 S1731794AbgLCTB2 (ORCPT + 99 others); Thu, 3 Dec 2020 14:01:28 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:18455 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729136AbgLCTB1 (ORCPT ); Thu, 3 Dec 2020 14:01:27 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 03 Dec 2020 11:00:13 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 3 Dec 2020 19:00:12 +0000 Received: from skomatineni-linux.nvidia.com (172.20.13.39) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 3 Dec 2020 19:00:11 +0000 From: Sowjanya Komatineni To: , , , , , CC: , , , , , Subject: [PATCH v3 09/13] media: tegra-video: Implement V4L2 device notify callback Date: Thu, 3 Dec 2020 10:59:58 -0800 Message-ID: <1607022002-26575-10-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607022002-26575-1-git-send-email-skomatineni@nvidia.com> References: <1607022002-26575-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=1607022013; 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=WEyVYfyIIsgLrAqCLF63w9FK9845+8mOPDGODnA7EHYE7gmcVooNheCVZ+Up+5N1r WmGEa1MDx2hm1YjP5AyxBokfwRVMEw3IgXaP1aqFc2Ra9q9jl5iBHI+Kz3tCzzbe8b Ci9Vf1BYTnf6qqpPS7rdJi9ycSHInjLeQ1hAYSQW3ct+4NkOkngSp9XckjzZBhcTMX f40prPcZRxs3hqPqsqfxTJ4Xzqx4ucFrhxF4eteSd64uRNEYif4HXLcmO+vdG/maPJ bEHAiRYshZmzt9Dym0yaGyv8WYUHsuMZjjI9y6hv0HccYoopPNGORx9ZrleDm2EVHj 04tqMmhTd9/dg== 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