linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] media: ov7670: add media controller support
@ 2017-10-12 16:21 Akinobu Mita
  2017-10-12 16:21 ` [PATCH 1/4] media: ov7670: create subdevice device node Akinobu Mita
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Akinobu Mita @ 2017-10-12 16:21 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Jonathan Corbet, Mauro Carvalho Chehab

This series adds media controller support and other related changes to the
OV7670 which is cheap and highly available CMOS image sensor for hobbyists.

This enables to control a video pipeline system with the OV7670.  I've
tested this with the xilinx video IP pipeline.

Akinobu Mita (4):
  media: ov7670: create subdevice device node
  media: ov7670: use v4l2_async_unregister_subdev()
  media: ov7670: add media controller support
  media: ov7670: add get_fmt() pad ops callback

 drivers/media/i2c/ov7670.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] media: ov7670: create subdevice device node
  2017-10-12 16:21 [PATCH 0/4] media: ov7670: add media controller support Akinobu Mita
@ 2017-10-12 16:21 ` Akinobu Mita
  2017-10-12 16:21 ` [PATCH 2/4] media: ov7670: use v4l2_async_unregister_subdev() Akinobu Mita
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Akinobu Mita @ 2017-10-12 16:21 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Jonathan Corbet, Mauro Carvalho Chehab

Set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so it is
possible to create a subdevice device node.

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 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index e88549f..d3f7d61 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1585,6 +1585,7 @@ static int ov7670_probe(struct i2c_client *client,
 		return -ENOMEM;
 	sd = &info->sd;
 	v4l2_i2c_subdev_init(sd, client, &ov7670_ops);
+	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	info->clock_speed = 30; /* default: a guess */
 	if (client->dev.platform_data) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] media: ov7670: use v4l2_async_unregister_subdev()
  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 ` Akinobu Mita
  2017-10-12 16:21 ` [PATCH 3/4] media: ov7670: add media controller support Akinobu Mita
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Akinobu Mita @ 2017-10-12 16:21 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Jonathan Corbet, Mauro Carvalho Chehab

The sub-device for ov7670 is registered by v4l2_async_register_subdev().
So it should be unregistered by v4l2_async_unregister_subdev() instead of
v4l2_device_unregister_subdev().

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index d3f7d61..4f89a51 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -19,6 +19,7 @@
 #include <linux/videodev2.h>
 #include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
+#include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-mediabus.h>
@@ -1710,7 +1711,7 @@ static int ov7670_remove(struct i2c_client *client)
 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
 	struct ov7670_info *info = to_state(sd);
 
-	v4l2_device_unregister_subdev(sd);
+	v4l2_async_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&info->hdl);
 	clk_disable_unprepare(info->clk);
 	return 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] media: ov7670: add media controller support
  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 ` Akinobu Mita
  2017-10-12 16:21 ` [PATCH 4/4] media: ov7670: add get_fmt() pad ops callback Akinobu Mita
  2017-10-13 20:48 ` [PATCH 0/4] media: ov7670: add media controller support Sakari Ailus
  4 siblings, 0 replies; 7+ messages in thread
From: Akinobu Mita @ 2017-10-12 16:21 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Jonathan Corbet, Mauro Carvalho Chehab

Create a source pad and set the media controller type to the sensor.

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 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 4f89a51..38e1876 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -214,6 +214,9 @@ struct ov7670_devtype {
 struct ov7670_format_struct;  /* coming later */
 struct ov7670_info {
 	struct v4l2_subdev sd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+	struct media_pad pad;
+#endif
 	struct v4l2_ctrl_handler hdl;
 	struct {
 		/* gain cluster */
@@ -1654,6 +1657,14 @@ static int ov7670_probe(struct i2c_client *client,
 	if (info->pclk_hb_disable)
 		ov7670_write(sd, REG_COM10, COM10_PCLK_HB);
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+	info->pad.flags = MEDIA_PAD_FL_SOURCE;
+	sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
+	ret = media_entity_pads_init(&sd->entity, 1, &info->pad);
+	if (ret)
+		goto clk_disable;
+#endif
+
 	v4l2_ctrl_handler_init(&info->hdl, 10);
 	v4l2_ctrl_new_std(&info->hdl, &ov7670_ctrl_ops,
 			V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
@@ -1700,6 +1711,9 @@ static int ov7670_probe(struct i2c_client *client,
 
 hdl_free:
 	v4l2_ctrl_handler_free(&info->hdl);
+#ifdef CONFIG_MEDIA_CONTROLLER
+	media_entity_cleanup(&sd->entity);
+#endif
 clk_disable:
 	clk_disable_unprepare(info->clk);
 	return ret;
@@ -1713,6 +1727,9 @@ static int ov7670_remove(struct i2c_client *client)
 
 	v4l2_async_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&info->hdl);
+#ifdef CONFIG_MEDIA_CONTROLLER
+	media_entity_cleanup(&sd->entity);
+#endif
 	clk_disable_unprepare(info->clk);
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] media: ov7670: add get_fmt() pad ops callback
  2017-10-12 16:21 [PATCH 0/4] media: ov7670: add media controller support Akinobu Mita
                   ` (2 preceding siblings ...)
  2017-10-12 16:21 ` [PATCH 3/4] media: ov7670: add media controller support Akinobu Mita
@ 2017-10-12 16:21 ` Akinobu Mita
  2017-10-13 20:48 ` [PATCH 0/4] media: ov7670: add media controller support Sakari Ailus
  4 siblings, 0 replies; 7+ messages in thread
From: Akinobu Mita @ 2017-10-12 16:21 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Jonathan Corbet, Mauro Carvalho Chehab

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] media: ov7670: add media controller support
  2017-10-12 16:21 [PATCH 0/4] media: ov7670: add media controller support Akinobu Mita
                   ` (3 preceding siblings ...)
  2017-10-12 16:21 ` [PATCH 4/4] media: ov7670: add get_fmt() pad ops callback Akinobu Mita
@ 2017-10-13 20:48 ` Sakari Ailus
  2017-10-16  3:11   ` Yang, Wenyou
  4 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2017-10-13 20:48 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-media, Jonathan Corbet, Mauro Carvalho Chehab, Wenyou Yang

Hi Akinobu,

On Fri, Oct 13, 2017 at 01:21:13AM +0900, Akinobu Mita wrote:
> This series adds media controller support and other related changes to the
> OV7670 which is cheap and highly available CMOS image sensor for hobbyists.
> 
> This enables to control a video pipeline system with the OV7670.  I've
> tested this with the xilinx video IP pipeline.
> 
> Akinobu Mita (4):
>   media: ov7670: create subdevice device node
>   media: ov7670: use v4l2_async_unregister_subdev()
>   media: ov7670: add media controller support
>   media: ov7670: add get_fmt() pad ops callback
> 
>  drivers/media/i2c/ov7670.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 54 insertions(+), 1 deletion(-)

I understand Wenyou has submitted a set with similar functionality +
runtime PM as well, but it has issues. There hasn't been updated for some
time on that. Wenyou, what's the status of your patchset?

The set was submitted on the list under subject "[PATCH v5 0/3] media:
ov7670: Add entity init and power operation"

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] media: ov7670: add media controller support
  2017-10-13 20:48 ` [PATCH 0/4] media: ov7670: add media controller support Sakari Ailus
@ 2017-10-16  3:11   ` Yang, Wenyou
  0 siblings, 0 replies; 7+ messages in thread
From: Yang, Wenyou @ 2017-10-16  3:11 UTC (permalink / raw)
  To: Sakari Ailus, Akinobu Mita
  Cc: linux-media, Jonathan Corbet, Mauro Carvalho Chehab

Hi Sakari,


On 2017/10/14 4:48, Sakari Ailus wrote:
> Hi Akinobu,
>
> On Fri, Oct 13, 2017 at 01:21:13AM +0900, Akinobu Mita wrote:
>> This series adds media controller support and other related changes to the
>> OV7670 which is cheap and highly available CMOS image sensor for hobbyists.
>>
>> This enables to control a video pipeline system with the OV7670.  I've
>> tested this with the xilinx video IP pipeline.
>>
>> Akinobu Mita (4):
>>    media: ov7670: create subdevice device node
>>    media: ov7670: use v4l2_async_unregister_subdev()
>>    media: ov7670: add media controller support
>>    media: ov7670: add get_fmt() pad ops callback
>>
>>   drivers/media/i2c/ov7670.c | 55 +++++++++++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 54 insertions(+), 1 deletion(-)
> I understand Wenyou has submitted a set with similar functionality +
> runtime PM as well, but it has issues. There hasn't been updated for some
> time on that. Wenyou, what's the status of your patchset?
Sorry for I missed your previous mail.

I will update the patchset soon.
> The set was submitted on the list under subject "[PATCH v5 0/3] media:
> ov7670: Add entity init and power operation"
>

Best Regards,
Wenyou Yang

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-16  3:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 4/4] media: ov7670: add get_fmt() pad ops callback Akinobu Mita
2017-10-13 20:48 ` [PATCH 0/4] media: ov7670: add media controller support Sakari Ailus
2017-10-16  3:11   ` Yang, Wenyou

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).