linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] [media] ov5645: Set media entity function
@ 2017-07-05  8:44 Todor Tomov
  2017-07-05  8:44 ` [PATCH 2/3] [media] ov5645: Add control to export pixel clock frequency Todor Tomov
  2017-07-05  8:44 ` [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency Todor Tomov
  0 siblings, 2 replies; 4+ messages in thread
From: Todor Tomov @ 2017-07-05  8:44 UTC (permalink / raw)
  To: mchehab, sakari.ailus, hansverk; +Cc: linux-media, linux-kernel, Todor Tomov

Set media entity function to MEDIA_ENT_F_CAM_SENSOR.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
---
 drivers/media/i2c/ov5645.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index d1e844f..bb3dd0d 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1229,6 +1229,7 @@ static int ov5645_probe(struct i2c_client *client,
 	ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	ov5645->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ov5645->sd.dev = &client->dev;
+	ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
 	ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad);
 	if (ret < 0) {
-- 
1.9.1

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

* [PATCH 2/3] [media] ov5645: Add control to export pixel clock frequency
  2017-07-05  8:44 [PATCH 1/3] [media] ov5645: Set media entity function Todor Tomov
@ 2017-07-05  8:44 ` Todor Tomov
  2017-07-05  8:44 ` [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency Todor Tomov
  1 sibling, 0 replies; 4+ messages in thread
From: Todor Tomov @ 2017-07-05  8:44 UTC (permalink / raw)
  To: mchehab, sakari.ailus, hansverk; +Cc: linux-media, linux-kernel, Todor Tomov

Add suport for standard V4L2_CID_PIXEL_RATE control. The pixel clock
frequency value is specific for each sensor mode so the sensor mode
structure is extended to add this. The control is read-only and its
value is updated when the sensor mode is changed - on set_format.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
---
 drivers/media/i2c/ov5645.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index bb3dd0d..4583f66 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -80,6 +80,7 @@ struct ov5645_mode_info {
 	u32 height;
 	const struct reg_value *data;
 	u32 data_size;
+	u32 pixel_clock;
 };
 
 struct ov5645 {
@@ -99,6 +100,7 @@ struct ov5645 {
 	const struct ov5645_mode_info *current_mode;
 
 	struct v4l2_ctrl_handler ctrls;
+	struct v4l2_ctrl *pixel_clock;
 
 	/* Cached register values */
 	u8 aec_pk_manual;
@@ -510,19 +512,22 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd)
 		.width = 1280,
 		.height = 960,
 		.data = ov5645_setting_sxga,
-		.data_size = ARRAY_SIZE(ov5645_setting_sxga)
+		.data_size = ARRAY_SIZE(ov5645_setting_sxga),
+		.pixel_clock = 111440000
 	},
 	{
 		.width = 1920,
 		.height = 1080,
 		.data = ov5645_setting_1080p,
-		.data_size = ARRAY_SIZE(ov5645_setting_1080p)
+		.data_size = ARRAY_SIZE(ov5645_setting_1080p),
+		.pixel_clock = 167160000
 	},
 	{
 		.width = 2592,
 		.height = 1944,
 		.data = ov5645_setting_full,
-		.data_size = ARRAY_SIZE(ov5645_setting_full)
+		.data_size = ARRAY_SIZE(ov5645_setting_full),
+		.pixel_clock = 167160000
 	},
 };
 
@@ -969,6 +974,7 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
 	struct v4l2_mbus_framefmt *__format;
 	struct v4l2_rect *__crop;
 	const struct ov5645_mode_info *new_mode;
+	int ret;
 
 	__crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad,
 			format->which);
@@ -978,8 +984,14 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
 	__crop->width = new_mode->width;
 	__crop->height = new_mode->height;
 
-	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
+	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
+		ret = v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock,
+					     new_mode->pixel_clock);
+		if (ret < 0)
+			return ret;
+
 		ov5645->current_mode = new_mode;
+	}
 
 	__format = __ov5645_get_pad_format(ov5645, cfg, format->pad,
 			format->which);
@@ -1197,7 +1209,7 @@ static int ov5645_probe(struct i2c_client *client,
 
 	mutex_init(&ov5645->power_lock);
 
-	v4l2_ctrl_handler_init(&ov5645->ctrls, 7);
+	v4l2_ctrl_handler_init(&ov5645->ctrls, 8);
 	v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
 			  V4L2_CID_SATURATION, -4, 4, 1, 0);
 	v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
@@ -1215,6 +1227,10 @@ static int ov5645_probe(struct i2c_client *client,
 				     V4L2_CID_TEST_PATTERN,
 				     ARRAY_SIZE(ov5645_test_pattern_menu) - 1,
 				     0, 0, ov5645_test_pattern_menu);
+	ov5645->pixel_clock = v4l2_ctrl_new_std(&ov5645->ctrls,
+						&ov5645_ctrl_ops,
+						V4L2_CID_PIXEL_RATE,
+						1, INT_MAX, 1, 1);
 
 	ov5645->sd.ctrl_handler = &ov5645->ctrls;
 
-- 
1.9.1

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

* [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency
  2017-07-05  8:44 [PATCH 1/3] [media] ov5645: Set media entity function Todor Tomov
  2017-07-05  8:44 ` [PATCH 2/3] [media] ov5645: Add control to export pixel clock frequency Todor Tomov
@ 2017-07-05  8:44 ` Todor Tomov
  2017-07-05 23:14   ` Sakari Ailus
  1 sibling, 1 reply; 4+ messages in thread
From: Todor Tomov @ 2017-07-05  8:44 UTC (permalink / raw)
  To: mchehab, sakari.ailus, hansverk; +Cc: linux-media, linux-kernel, Todor Tomov

Add suport for standard integer menu V4L2_CID_LINK_FREQ control.
The CSI2 link frequency value is specific for each sensor mode so the
sensor mode structure is extended to add this. The control is made
read-only and its value is updated when the sensor mode is changed -
on set_format.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
---
 drivers/media/i2c/ov5645.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index 4583f66..85622e4 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -81,6 +81,7 @@ struct ov5645_mode_info {
 	const struct reg_value *data;
 	u32 data_size;
 	u32 pixel_clock;
+	u32 link_freq;
 };
 
 struct ov5645 {
@@ -101,6 +102,7 @@ struct ov5645 {
 
 	struct v4l2_ctrl_handler ctrls;
 	struct v4l2_ctrl *pixel_clock;
+	struct v4l2_ctrl *link_freq;
 
 	/* Cached register values */
 	u8 aec_pk_manual;
@@ -507,27 +509,35 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd)
 	{ 0x4202, 0x00 }
 };
 
+static const s64 link_freq[] = {
+	222880000,
+	334320000
+};
+
 static const struct ov5645_mode_info ov5645_mode_info_data[] = {
 	{
 		.width = 1280,
 		.height = 960,
 		.data = ov5645_setting_sxga,
 		.data_size = ARRAY_SIZE(ov5645_setting_sxga),
-		.pixel_clock = 111440000
+		.pixel_clock = 111440000,
+		.link_freq = 0 /* an index in link_freq[] */
 	},
 	{
 		.width = 1920,
 		.height = 1080,
 		.data = ov5645_setting_1080p,
 		.data_size = ARRAY_SIZE(ov5645_setting_1080p),
-		.pixel_clock = 167160000
+		.pixel_clock = 167160000,
+		.link_freq = 1 /* an index in link_freq[] */
 	},
 	{
 		.width = 2592,
 		.height = 1944,
 		.data = ov5645_setting_full,
 		.data_size = ARRAY_SIZE(ov5645_setting_full),
-		.pixel_clock = 167160000
+		.pixel_clock = 167160000,
+		.link_freq = 1 /* an index in link_freq[] */
 	},
 };
 
@@ -990,6 +1000,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
 		if (ret < 0)
 			return ret;
 
+		ret = v4l2_ctrl_s_ctrl(ov5645->link_freq,
+				       new_mode->link_freq);
+		if (ret < 0)
+			return ret;
+
 		ov5645->current_mode = new_mode;
 	}
 
@@ -1209,7 +1224,7 @@ static int ov5645_probe(struct i2c_client *client,
 
 	mutex_init(&ov5645->power_lock);
 
-	v4l2_ctrl_handler_init(&ov5645->ctrls, 8);
+	v4l2_ctrl_handler_init(&ov5645->ctrls, 9);
 	v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
 			  V4L2_CID_SATURATION, -4, 4, 1, 0);
 	v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
@@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client,
 						&ov5645_ctrl_ops,
 						V4L2_CID_PIXEL_RATE,
 						1, INT_MAX, 1, 1);
+	ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls,
+						   &ov5645_ctrl_ops,
+						   V4L2_CID_LINK_FREQ,
+						   ARRAY_SIZE(link_freq) - 1,
+						   0, link_freq);
+	if(ov5645->link_freq)
+		ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
 	ov5645->sd.ctrl_handler = &ov5645->ctrls;
 
-- 
1.9.1

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

* Re: [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency
  2017-07-05  8:44 ` [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency Todor Tomov
@ 2017-07-05 23:14   ` Sakari Ailus
  0 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2017-07-05 23:14 UTC (permalink / raw)
  To: Todor Tomov; +Cc: mchehab, sakari.ailus, hansverk, linux-media, linux-kernel

On Wed, Jul 05, 2017 at 11:44:49AM +0300, Todor Tomov wrote:
> @@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client,
>  						&ov5645_ctrl_ops,
>  						V4L2_CID_PIXEL_RATE,
>  						1, INT_MAX, 1, 1);
> +	ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls,
> +						   &ov5645_ctrl_ops,
> +						   V4L2_CID_LINK_FREQ,
> +						   ARRAY_SIZE(link_freq) - 1,
> +						   0, link_freq);
> +	if(ov5645->link_freq)

Thanks!

Applied the set, with the above typo fixed (i.e. space added).

> +		ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>  
>  	ov5645->sd.ctrl_handler = &ov5645->ctrls;
>  

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

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

end of thread, other threads:[~2017-07-05 23:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-05  8:44 [PATCH 1/3] [media] ov5645: Set media entity function Todor Tomov
2017-07-05  8:44 ` [PATCH 2/3] [media] ov5645: Add control to export pixel clock frequency Todor Tomov
2017-07-05  8:44 ` [PATCH 3/3] [media] ov5645: Add control to export CSI2 link frequency Todor Tomov
2017-07-05 23:14   ` Sakari Ailus

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