blob: 1cef1a27b8bdc8e81f44fb2fe0b8b3081a168b05 [file] [log] [blame]
From 0587faaf5e15a15d622b76154195dc41960ee501 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niklas=20S=C3=B6derlund?=
<niklas.soderlund+renesas@ragnatech.se>
Date: Sat, 14 Apr 2018 07:57:10 -0400
Subject: [PATCH 1296/1795] media: rcar-vin: cache video standard
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
At stream on time the driver should not query the subdevice for which
standard are used. Instead it should be cached when userspace sets the
standard and used at stream on time.
Signed-off-by: Niklas Sรถderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 4f554bde63f94539f7d4cc44e2f1f9f3cb9ccdb3)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/media/platform/rcar-vin/rcar-core.c | 6 ++++++
drivers/media/platform/rcar-vin/rcar-dma.c | 7 ++-----
drivers/media/platform/rcar-vin/rcar-v4l2.c | 10 ++++++++--
drivers/media/platform/rcar-vin/rcar-vin.h | 2 ++
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index b7cce37d78b8..813cf628297a 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -96,6 +96,12 @@ static int rvin_digital_subdevice_attach(struct rvin_dev *vin,
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
return ret;
+ /* Read standard */
+ vin->std = V4L2_STD_UNKNOWN;
+ ret = v4l2_subdev_call(subdev, video, g_std, &vin->std);
+ if (ret < 0 && ret != -ENOIOCTLCMD)
+ return ret;
+
/* Add the controls */
ret = v4l2_ctrl_handler_init(&vin->ctrl_handler, 16);
if (ret < 0)
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index 9233924e5b52..79f4074b931b 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -592,7 +592,6 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
static int rvin_setup(struct rvin_dev *vin)
{
u32 vnmc, dmr, dmr2, interrupts;
- v4l2_std_id std;
bool progressive = false, output_is_yuv = false, input_is_yuv = false;
switch (vin->format.field) {
@@ -606,10 +605,8 @@ static int rvin_setup(struct rvin_dev *vin)
/* Default to TB */
vnmc = VNMC_IM_FULL;
/* Use BT if video standard can be read and is 60 Hz format */
- if (!v4l2_subdev_call(vin_to_source(vin), video, g_std, &std)) {
- if (std & V4L2_STD_525_60)
- vnmc = VNMC_IM_FULL | VNMC_FOC;
- }
+ if (vin->std & V4L2_STD_525_60)
+ vnmc = VNMC_IM_FULL | VNMC_FOC;
break;
case V4L2_FIELD_INTERLACED_TB:
vnmc = VNMC_IM_FULL;
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 84cad5d8c93a..9cdd00391c5c 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -475,6 +475,8 @@ static int rvin_s_std(struct file *file, void *priv, v4l2_std_id a)
if (ret < 0)
return ret;
+ vin->std = a;
+
/* Changing the standard will change the width/height */
return rvin_reset_format(vin);
}
@@ -482,9 +484,13 @@ static int rvin_s_std(struct file *file, void *priv, v4l2_std_id a)
static int rvin_g_std(struct file *file, void *priv, v4l2_std_id *a)
{
struct rvin_dev *vin = video_drvdata(file);
- struct v4l2_subdev *sd = vin_to_source(vin);
- return v4l2_subdev_call(sd, video, g_std, a);
+ if (v4l2_subdev_has_op(vin_to_source(vin), pad, dv_timings_cap))
+ return -ENOIOCTLCMD;
+
+ *a = vin->std;
+
+ return 0;
}
static int rvin_subscribe_event(struct v4l2_fh *fh,
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
index e940366d7e8d..06cec4f8e5ff 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -118,6 +118,7 @@ struct rvin_info {
* @crop: active cropping
* @compose: active composing
* @source: active size of the video source
+ * @std: active video standard of the video source
*/
struct rvin_dev {
struct device *dev;
@@ -146,6 +147,7 @@ struct rvin_dev {
struct v4l2_rect crop;
struct v4l2_rect compose;
struct v4l2_rect source;
+ v4l2_std_id std;
};
#define vin_to_source(vin) ((vin)->digital->subdev)
--
2.19.0