From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-media@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Mauro Carvalho Chehab <mchehab@s-opensource.com>
Subject: [PATCH 4/4] media: ov7670: add get_fmt() pad ops callback
Date: Fri, 13 Oct 2017 01:21:17 +0900 [thread overview]
Message-ID: <1507825277-18364-5-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1507825277-18364-1-git-send-email-akinobu.mita@gmail.com>
This enables to print the current format on the source pad of the ov7670
subdev by media-ctl.
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
drivers/media/i2c/ov7670.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 38e1876..9fe99c5 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -234,6 +234,7 @@ struct ov7670_info {
struct v4l2_ctrl *hue;
};
struct ov7670_format_struct *fmt; /* Current format */
+ struct ov7670_win_size *wsize; /* Current format */
struct clk *clk;
struct gpio_desc *resetb_gpio;
struct gpio_desc *pwdn_gpio;
@@ -875,6 +876,36 @@ static int ov7670_set_framerate_legacy(struct v4l2_subdev *sd,
return ov7670_write(sd, REG_CLKRC, info->clkrc);
}
+static int ov7670_get_fmt(struct v4l2_subdev *sd,
+ struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_format *fmt)
+{
+ struct ov7670_info *info = to_state(sd);
+
+ if (fmt->pad)
+ return -EINVAL;
+
+ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
+ struct v4l2_mbus_framefmt *mf;
+
+ mf = v4l2_subdev_get_try_format(sd, cfg, 0);
+ fmt->format = *mf;
+ return 0;
+#else
+ return -ENOTTY;
+#endif
+ }
+
+ fmt->format.colorspace = info->fmt->colorspace;
+ fmt->format.code = info->fmt->mbus_code;
+ fmt->format.field = V4L2_FIELD_NONE;
+ fmt->format.width = info->wsize->width;
+ fmt->format.height = info->wsize->height;
+
+ return 0;
+}
+
/*
* Store a set of start/stop values into the camera.
*/
@@ -1026,6 +1057,7 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
if (wsize->regs)
ret = ov7670_write_array(sd, wsize->regs);
info->fmt = ovfmt;
+ info->wsize = wsize;
/*
* If we're running RGB565, we must rewrite clkrc after setting
@@ -1529,6 +1561,7 @@ static const struct v4l2_subdev_pad_ops ov7670_pad_ops = {
.enum_frame_interval = ov7670_enum_frame_interval,
.enum_frame_size = ov7670_enum_frame_size,
.enum_mbus_code = ov7670_enum_mbus_code,
+ .get_fmt = ov7670_get_fmt,
.set_fmt = ov7670_set_fmt,
};
@@ -1647,6 +1680,7 @@ static int ov7670_probe(struct i2c_client *client,
info->devtype = &ov7670_devdata[id->driver_data];
info->fmt = &ov7670_formats[0];
+ info->wsize = &info->devtype->win_sizes[0];
info->clkrc = 0;
/* Set default frame rate to 30 fps */
--
2.7.4
next prev parent reply other threads:[~2017-10-12 16:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 16:21 [PATCH 0/4] media: ov7670: add media controller support Akinobu Mita
2017-10-12 16:21 ` [PATCH 1/4] media: ov7670: create subdevice device node Akinobu Mita
2017-10-12 16:21 ` [PATCH 2/4] media: ov7670: use v4l2_async_unregister_subdev() Akinobu Mita
2017-10-12 16:21 ` [PATCH 3/4] media: ov7670: add media controller support Akinobu Mita
2017-10-12 16:21 ` Akinobu Mita [this message]
2017-10-13 20:48 ` [PATCH 0/4] " Sakari Ailus
2017-10-16 3:11 ` Yang, Wenyou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1507825277-18364-5-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@s-opensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).