Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp726523pxu; Thu, 3 Dec 2020 11:02:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzHfVgMw/ehmoy159knKKJL25xUXNHytv5zuq/a1MFhcFWcj+sh+U6TcF+VACerSV6JLj7 X-Received: by 2002:a50:b205:: with SMTP id o5mr4270160edd.304.1607022169876; Thu, 03 Dec 2020 11:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607022169; cv=none; d=google.com; s=arc-20160816; b=hOZjRtmtDCavBlATsq30JSrLeFsgZ8bvXqVG8fau062UfXZSftOz1b2CkHiA4QbQa7 RD+DMGAXEwZA3Tvd2XIwYwLivr4iqDxRIV/S26S9a5bw8CoNGgrjUNpuniVaw/AFffKI hSQXQOFY7znwXHIgYWVnYXeIZbbOlHf6nOC5HUAHwA5zeF4iqMJBBaj2fWhMFvDobAgw 0d4znU4QE+tjlXNlAvECF0bOudA1huwu2eDpK04N6GO/b+INWTej+T0SXJCS6wwtezO+ r5eRNMnZlX5aIyYO02vIwXG5UvPEzzhFNKNrWg11Z2MzgCx+hhBugYHd/2S3vDcp8FNI Cr6g== 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=OEJFE73+oYlfHwsZTpDTwunmzJNSeyNDOPkWhniYmz0=; b=j+kjWnNqfzLLCPz7iUOxzihYcTokMhHNUcyr4WOpHFzhCAcrCWA8wZtWAu7NyAuGXQ 1Qagzgcu7XAxHzT4Lpi2lDvUOdJFYLdntP4zi2pdy6hCb0jaWA37PYZ+ITghNyQ57VDk M81NNljOcSw41H67P7DBbNPg0cGrGOQ6aGirqBdUlR389T5+adhUHylnrjO58gpLVC6D kxwO+k2PTFBOalefcG/SrL+lP4Fi9dn6mp8sBNFmKy1m7GUHJTEEMmIY8/P9QlSZKm4h uJLtWa/7qbT/oBSIHvboNWCaaK/k0MlPlX/mex22VmOYSW0P+OU7/2XHc1M5k7qWDbF6 xY/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=E2e0oxf2; 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 ec19si1631439ejb.669.2020.12.03.11.02.25; Thu, 03 Dec 2020 11:02:49 -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=E2e0oxf2; 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 S1729462AbgLCTAx (ORCPT + 99 others); Thu, 3 Dec 2020 14:00:53 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:19180 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387618AbgLCTAw (ORCPT ); Thu, 3 Dec 2020 14:00:52 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 03 Dec 2020 11:00:12 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 3 Dec 2020 19:00:07 +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:05 +0000 From: Sowjanya Komatineni To: , , , , , CC: , , , , , Subject: [PATCH v3 05/13] media: tegra-video: Add DV timing support Date: Thu, 3 Dec 2020 10:59:54 -0800 Message-ID: <1607022002-26575-6-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=1607022012; bh=OEJFE73+oYlfHwsZTpDTwunmzJNSeyNDOPkWhniYmz0=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-NVConfidentiality:MIME-Version:Content-Type; b=E2e0oxf28AzDXNlNmIhAf8rCvD9S/owunXGNbGR6ahn5MWdVmHTkn5ldIyzaLC5kK LEl3O3SgK57n/Ptw1oeHWwBH4a68BAiDqJP3gKS6iZXyF+KdF9KkCdDnz8vfnoIswl 55EHkJ9balr+ckbItMyIxFh7IFosHdh4dMLy/EGOkeMI8XBnnquNGCrxQZ1n62HtZt Ud5CptSSkHVzcmLQcW9uYm3NOeOR5c/5X7tvgAnsdCMXDdD9/nrrCvhIQClHQsdZGm j82bHrB0ds8D5sLgZKiUYXh67UXUDALbKtpRrPA7Z1n1hrsJEu2PoxO+SMGOuv2Gtp 53fmaZGH3ncAg== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds below v4l2 DV timing ioctls to support HDMI-to-CSI bridges. Signed-off-by: Sowjanya Komatineni --- drivers/staging/media/tegra-video/vi.c | 99 ++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 525c087..d01e88d 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -720,6 +721,97 @@ static int tegra_channel_s_selection(struct file *file, void *fh, return ret; } +static int tegra_channel_g_dv_timings(struct file *file, void *fh, + struct v4l2_dv_timings *timings) +{ + struct tegra_vi_channel *chan = video_drvdata(file); + struct v4l2_subdev *subdev; + + subdev = tegra_channel_get_remote_source_subdev(chan); + if (!v4l2_subdev_has_op(subdev, video, g_dv_timings)) + return -ENOTTY; + + return v4l2_device_call_until_err(chan->video.v4l2_dev, 0, + video, g_dv_timings, timings); +} + +static int tegra_channel_s_dv_timings(struct file *file, void *fh, + struct v4l2_dv_timings *timings) +{ + struct tegra_vi_channel *chan = video_drvdata(file); + struct v4l2_subdev *subdev; + struct v4l2_bt_timings *bt = &timings->bt; + struct v4l2_dv_timings curr_timings; + int ret; + + subdev = tegra_channel_get_remote_source_subdev(chan); + if (!v4l2_subdev_has_op(subdev, video, s_dv_timings)) + return -ENOTTY; + + ret = tegra_channel_g_dv_timings(file, fh, &curr_timings); + if (ret) + return ret; + + if (v4l2_match_dv_timings(timings, &curr_timings, 0, false)) + return 0; + + if (vb2_is_busy(&chan->queue)) + return -EBUSY; + + ret = v4l2_device_call_until_err(chan->video.v4l2_dev, 0, + video, s_dv_timings, timings); + if (ret) + return ret; + + chan->format.width = bt->width; + chan->format.height = bt->height; + chan->format.bytesperline = bt->width * chan->fmtinfo->bpp; + chan->format.sizeimage = chan->format.bytesperline * bt->height; + tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + + return 0; +} + +static int tegra_channel_query_dv_timings(struct file *file, void *fh, + struct v4l2_dv_timings *timings) +{ + struct tegra_vi_channel *chan = video_drvdata(file); + struct v4l2_subdev *subdev; + + subdev = tegra_channel_get_remote_source_subdev(chan); + if (!v4l2_subdev_has_op(subdev, video, query_dv_timings)) + return -ENOTTY; + + return v4l2_device_call_until_err(chan->video.v4l2_dev, 0, + video, query_dv_timings, timings); +} + +static int tegra_channel_enum_dv_timings(struct file *file, void *fh, + struct v4l2_enum_dv_timings *timings) +{ + struct tegra_vi_channel *chan = video_drvdata(file); + struct v4l2_subdev *subdev; + + subdev = tegra_channel_get_remote_source_subdev(chan); + if (!v4l2_subdev_has_op(subdev, pad, enum_dv_timings)) + return -ENOTTY; + + return v4l2_subdev_call(subdev, pad, enum_dv_timings, timings); +} + +static int tegra_channel_dv_timings_cap(struct file *file, void *fh, + struct v4l2_dv_timings_cap *cap) +{ + struct tegra_vi_channel *chan = video_drvdata(file); + struct v4l2_subdev *subdev; + + subdev = tegra_channel_get_remote_source_subdev(chan); + if (!v4l2_subdev_has_op(subdev, pad, dv_timings_cap)) + return -ENOTTY; + + return v4l2_subdev_call(subdev, pad, dv_timings_cap, cap); +} + static int tegra_channel_enum_input(struct file *file, void *fh, struct v4l2_input *inp) { @@ -732,6 +824,8 @@ static int tegra_channel_enum_input(struct file *file, void *fh, inp->type = V4L2_INPUT_TYPE_CAMERA; subdev = tegra_channel_get_remote_source_subdev(chan); strscpy(inp->name, subdev->name, sizeof(inp->name)); + if (v4l2_subdev_has_op(subdev, pad, dv_timings_cap)) + inp->capabilities = V4L2_IN_CAP_DV_TIMINGS; return 0; } @@ -779,6 +873,11 @@ static const struct v4l2_ioctl_ops tegra_channel_ioctl_ops = { .vidioc_unsubscribe_event = v4l2_event_unsubscribe, .vidioc_g_selection = tegra_channel_g_selection, .vidioc_s_selection = tegra_channel_s_selection, + .vidioc_g_dv_timings = tegra_channel_g_dv_timings, + .vidioc_s_dv_timings = tegra_channel_s_dv_timings, + .vidioc_query_dv_timings = tegra_channel_query_dv_timings, + .vidioc_enum_dv_timings = tegra_channel_enum_dv_timings, + .vidioc_dv_timings_cap = tegra_channel_dv_timings_cap, }; /* -- 2.7.4