All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] media: mt9m111: media controller support and misc changes
@ 2018-01-03 18:22 Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 1/4] media: mt9m111: create subdevice device node Akinobu Mita
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Akinobu Mita @ 2018-01-03 18:22 UTC (permalink / raw)
  To: linux-media
  Cc: Akinobu Mita, Rob Herring, Sakari Ailus, Mauro Carvalho Chehab

This series adds media controller support and other miscellaneous changes
to the mt9m111 driver. The MT9M111 camera modules are easily available
for the hobbyists.

* Changelog v2
- Fix typo s/meida/media/ in the patch title, noticed by Sakari Ailus
- Improve the wording for "clock-names" property, suggested by Sakari Ailus

Akinobu Mita (4):
  media: mt9m111: create subdevice device node
  media: mt9m111: add media controller support
  media: mt9m111: document missing required clocks property
  media: mt9m111: add V4L2_CID_TEST_PATTERN control

 .../devicetree/bindings/media/i2c/mt9m111.txt      |  4 ++
 drivers/media/i2c/mt9m111.c                        | 51 +++++++++++++++++++++-
 2 files changed, 53 insertions(+), 2 deletions(-)

Cc: Rob Herring <robh@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-- 
2.7.4

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

* [PATCH v2 1/4] media: mt9m111: create subdevice device node
  2018-01-03 18:22 [PATCH v2 0/4] media: mt9m111: media controller support and misc changes Akinobu Mita
@ 2018-01-03 18:22 ` Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 2/4] media: mt9m111: add media controller support Akinobu Mita
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2018-01-03 18:22 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Sakari Ailus, Mauro Carvalho Chehab

Set the V4L2_SUBDEV_FL_HAS_DEVNODE flag for the subdevice so that the
subdevice device node is created.

Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* Changelog v2
- Fix typo s/meida/media/ in the patch title, noticed by Sakari Ailus

 drivers/media/i2c/mt9m111.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index b1665d9..4fa10df 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -951,6 +951,8 @@ static int mt9m111_probe(struct i2c_client *client,
 	mt9m111->ctx = &context_b;
 
 	v4l2_i2c_subdev_init(&mt9m111->subdev, client, &mt9m111_subdev_ops);
+	mt9m111->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+
 	v4l2_ctrl_handler_init(&mt9m111->hdl, 5);
 	v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops,
 			V4L2_CID_VFLIP, 0, 1, 1, 0);
-- 
2.7.4

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

* [PATCH v2 2/4] media: mt9m111: add media controller support
  2018-01-03 18:22 [PATCH v2 0/4] media: mt9m111: media controller support and misc changes Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 1/4] media: mt9m111: create subdevice device node Akinobu Mita
@ 2018-01-03 18:22 ` Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 3/4] media: mt9m111: document missing required clocks property Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 4/4] media: mt9m111: add V4L2_CID_TEST_PATTERN control Akinobu Mita
  3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2018-01-03 18:22 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Sakari Ailus, Mauro Carvalho Chehab

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

Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* Changelog v2
- Fix typo s/meida/media/ in the patch title, noticed by Sakari Ailus

 drivers/media/i2c/mt9m111.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 4fa10df..e1d5032 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -215,6 +215,9 @@ struct mt9m111 {
 	int power_count;
 	const struct mt9m111_datafmt *fmt;
 	int lastpage;	/* PageMap cache value */
+#ifdef CONFIG_MEDIA_CONTROLLER
+	struct media_pad pad;
+#endif
 };
 
 /* Find a data format by a pixel code */
@@ -971,6 +974,14 @@ static int mt9m111_probe(struct i2c_client *client,
 		goto out_clkput;
 	}
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+	mt9m111->pad.flags = MEDIA_PAD_FL_SOURCE;
+	mt9m111->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
+	ret = media_entity_pads_init(&mt9m111->subdev.entity, 1, &mt9m111->pad);
+	if (ret < 0)
+		goto out_hdlfree;
+#endif
+
 	/* Second stage probe - when a capture adapter is there */
 	mt9m111->rect.left	= MT9M111_MIN_DARK_COLS;
 	mt9m111->rect.top	= MT9M111_MIN_DARK_ROWS;
@@ -982,16 +993,20 @@ static int mt9m111_probe(struct i2c_client *client,
 
 	ret = mt9m111_video_probe(client);
 	if (ret < 0)
-		goto out_hdlfree;
+		goto out_entityclean;
 
 	mt9m111->subdev.dev = &client->dev;
 	ret = v4l2_async_register_subdev(&mt9m111->subdev);
 	if (ret < 0)
-		goto out_hdlfree;
+		goto out_entityclean;
 
 	return 0;
 
+out_entityclean:
+#ifdef CONFIG_MEDIA_CONTROLLER
+	media_entity_cleanup(&mt9m111->subdev.entity);
 out_hdlfree:
+#endif
 	v4l2_ctrl_handler_free(&mt9m111->hdl);
 out_clkput:
 	v4l2_clk_put(mt9m111->clk);
@@ -1004,6 +1019,9 @@ static int mt9m111_remove(struct i2c_client *client)
 	struct mt9m111 *mt9m111 = to_mt9m111(client);
 
 	v4l2_async_unregister_subdev(&mt9m111->subdev);
+#ifdef CONFIG_MEDIA_CONTROLLER
+	media_entity_cleanup(&mt9m111->subdev.entity);
+#endif
 	v4l2_clk_put(mt9m111->clk);
 	v4l2_ctrl_handler_free(&mt9m111->hdl);
 
-- 
2.7.4

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

* [PATCH v2 3/4] media: mt9m111: document missing required clocks property
  2018-01-03 18:22 [PATCH v2 0/4] media: mt9m111: media controller support and misc changes Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 1/4] media: mt9m111: create subdevice device node Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 2/4] media: mt9m111: add media controller support Akinobu Mita
@ 2018-01-03 18:22 ` Akinobu Mita
  2018-01-03 18:22 ` [PATCH v2 4/4] media: mt9m111: add V4L2_CID_TEST_PATTERN control Akinobu Mita
  3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2018-01-03 18:22 UTC (permalink / raw)
  To: linux-media
  Cc: Akinobu Mita, Rob Herring, Sakari Ailus, Mauro Carvalho Chehab

The mt9m111 driver requires clocks property for the master clock to the
sensor, but there is no description for that.  This adds it.

Cc: Rob Herring <robh@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* Changelog v2
- Fix typo s/meida/media/ in the patch title, noticed by Sakari Ailus
- Improve the wording for "clock-names" property, suggested by Sakari Ailus

 Documentation/devicetree/bindings/media/i2c/mt9m111.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/mt9m111.txt b/Documentation/devicetree/bindings/media/i2c/mt9m111.txt
index ed5a334..6b91003 100644
--- a/Documentation/devicetree/bindings/media/i2c/mt9m111.txt
+++ b/Documentation/devicetree/bindings/media/i2c/mt9m111.txt
@@ -6,6 +6,8 @@ interface.
 
 Required Properties:
 - compatible: value should be "micron,mt9m111"
+- clocks: reference to the master clock.
+- clock-names: shall be "mclk".
 
 For further reading on port node refer to
 Documentation/devicetree/bindings/media/video-interfaces.txt.
@@ -16,6 +18,8 @@ Example:
 		mt9m111@5d {
 			compatible = "micron,mt9m111";
 			reg = <0x5d>;
+			clocks = <&mclk>;
+			clock-names = "mclk";
 
 			remote = <&pxa_camera>;
 			port {
-- 
2.7.4

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

* [PATCH v2 4/4] media: mt9m111: add V4L2_CID_TEST_PATTERN control
  2018-01-03 18:22 [PATCH v2 0/4] media: mt9m111: media controller support and misc changes Akinobu Mita
                   ` (2 preceding siblings ...)
  2018-01-03 18:22 ` [PATCH v2 3/4] media: mt9m111: document missing required clocks property Akinobu Mita
@ 2018-01-03 18:22 ` Akinobu Mita
  3 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2018-01-03 18:22 UTC (permalink / raw)
  To: linux-media; +Cc: Akinobu Mita, Sakari Ailus, Mauro Carvalho Chehab

The mt9m111 has the test pattern generator features.  This makes use of
it through V4L2_CID_TEST_PATTERN control.

Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
* Changelog v2
- Fix typo s/meida/media/ in the patch title, noticed by Sakari Ailus

 drivers/media/i2c/mt9m111.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index e1d5032..d74f254 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -92,6 +92,7 @@
  */
 #define MT9M111_OPER_MODE_CTRL		0x106
 #define MT9M111_OUTPUT_FORMAT_CTRL	0x108
+#define MT9M111_TPG_CTRL		0x148
 #define MT9M111_REDUCER_XZOOM_B		0x1a0
 #define MT9M111_REDUCER_XSIZE_B		0x1a1
 #define MT9M111_REDUCER_YZOOM_B		0x1a3
@@ -124,6 +125,7 @@
 #define MT9M111_OUTFMT_AVG_CHROMA	(1 << 2)
 #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN	(1 << 1)
 #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B	(1 << 0)
+#define MT9M111_TPG_SEL_MASK		GENMASK(2, 0)
 
 /*
  * Camera control register addresses (0x200..0x2ff not implemented)
@@ -706,6 +708,25 @@ static int mt9m111_set_autowhitebalance(struct mt9m111 *mt9m111, int on)
 	return reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN);
 }
 
+static const char * const mt9m111_test_pattern_menu[] = {
+	"Disabled",
+	"Vertical monochrome gradient",
+	"Flat color type 1",
+	"Flat color type 2",
+	"Flat color type 3",
+	"Flat color type 4",
+	"Flat color type 5",
+	"Color bar",
+};
+
+static int mt9m111_set_test_pattern(struct mt9m111 *mt9m111, int val)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev);
+
+	return mt9m111_reg_mask(client, MT9M111_TPG_CTRL, val,
+				MT9M111_TPG_SEL_MASK);
+}
+
 static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct mt9m111 *mt9m111 = container_of(ctrl->handler,
@@ -724,6 +745,8 @@ static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl)
 		return mt9m111_set_autoexposure(mt9m111, ctrl->val);
 	case V4L2_CID_AUTO_WHITE_BALANCE:
 		return mt9m111_set_autowhitebalance(mt9m111, ctrl->val);
+	case V4L2_CID_TEST_PATTERN:
+		return mt9m111_set_test_pattern(mt9m111, ctrl->val);
 	}
 
 	return -EINVAL;
@@ -968,6 +991,10 @@ static int mt9m111_probe(struct i2c_client *client,
 	v4l2_ctrl_new_std_menu(&mt9m111->hdl,
 			&mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0,
 			V4L2_EXPOSURE_AUTO);
+	v4l2_ctrl_new_std_menu_items(&mt9m111->hdl,
+			&mt9m111_ctrl_ops, V4L2_CID_TEST_PATTERN,
+			ARRAY_SIZE(mt9m111_test_pattern_menu) - 1, 0, 0,
+			mt9m111_test_pattern_menu);
 	mt9m111->subdev.ctrl_handler = &mt9m111->hdl;
 	if (mt9m111->hdl.error) {
 		ret = mt9m111->hdl.error;
-- 
2.7.4

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

end of thread, other threads:[~2018-01-03 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-03 18:22 [PATCH v2 0/4] media: mt9m111: media controller support and misc changes Akinobu Mita
2018-01-03 18:22 ` [PATCH v2 1/4] media: mt9m111: create subdevice device node Akinobu Mita
2018-01-03 18:22 ` [PATCH v2 2/4] media: mt9m111: add media controller support Akinobu Mita
2018-01-03 18:22 ` [PATCH v2 3/4] media: mt9m111: document missing required clocks property Akinobu Mita
2018-01-03 18:22 ` [PATCH v2 4/4] media: mt9m111: add V4L2_CID_TEST_PATTERN control Akinobu Mita

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.