Skip to contentSkip to conversation

V4L2 subdev and sensor control changes, SMIA++ driver and N9 camera board code

PATCH Superseded Sakari Ailus 5 participants 47 messages Feb 2, 2012 – Feb 16, 2012

Subsystems (6)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover V4L2 subdev and sensor control changes, SMIA++ driver and N9 camera board code

Hi everyone,

This the second version of my patchset that contains:

- Integer menu controls [2],
- Selection IOCTL for subdevs [3],
- Sensor control changes [5,7],
- link_validate() media entity and V4L2 subdev pad ops,
- OMAP 3 ISP driver improvements [4],
- SMIA++ sensor driver,
- rm680/rm696 board code (a.k.a Nokia N9 and N950) and
- Other V4L2 and media improvements (see individual patches)

My proposal on the selection / property API is that the V4L2 subdev interface will have the selection API. The property API should be targeted to the media controller interface instead. The selection API will provide real, required features required by SMIA++ driver as well as many other driver such as the OMAP 3 ISP driver. The property API is not well understood nor discussed in the community and it will take likely at least half a year before it will be usable. Drivers implementing the property API would use generic wrapper functions to provide the selection API.

Changes to version 1 [8] include:

- OMAP 3 ISP driver
- Swapped order of csi receiver's lane definitions
- Rewrote omap 3 isp link validation patches almost completely
- Information on connected external entity collected to isp_pipeline
- Information collected during link checking and used at streamon

- Media entity link validation
- Error handling fixes

- SMIA++ driver
- Selection API bugfixes
- Report correct pixel order right from boot
- Move link rate control to subdev connected to subdev external to the sensor (e.g. ISP's CSI-2 receiver)
- Introduce proper serialisation
- Deny changing some controls when streaming (flipping and link rate)
- Control handler setup moved from streamon time to first subdev open
- There is no source compose target
- Bugfixes

- Media bus pixel codes
- Documentation fix for dpcm compressed formats
- Added patch for 4CC guidelines (raw bayer only for now)

- Selections
- Improved selections documentation
- Added more selections examples
- Compose target is not available on source pads anymore [9]
- Dropped default targets

- V4L2
- Add documentation on link_validate()
- link_validate() and relater functions depends on CONFIG_MEDIA_CONTROLLER
- Skip link validation for links on which stream_count was non-zero
- Do not validate link if entity's stream count is non-zero
- Use v4l2_subdev_link_validate_default() if no link_validate pad op is set
- Allow changing control handler mutex: this enables a driver to provide multiple subdevs but use only one mutex. Default mutex (part of struct v4l2_ctrl_handler) is set in v4l2_ctrl_handler_init().
- Split image source class into two: image source and image processing

Changes to the RFC v1 [6] include:

- Integer controls:
- Target Linux 3.4 instead of 3.3
- Proper control type check in querymenu
- vivi compile fixes

- Subdev selections
- Pad try fields combined to single struct
- Correctly set sel.which based on crop->which in crop fall-back

- Subdev selection documentation
- Better explanation on image processing in subdevs
- Added a diagram to visualise subdev configuration
- Fixed DocBook syntax issues
- Mark VIDIOC_SUBDEV_S_CROP and VIDIOC_SUBDEV_G_CROP obsolete

- Pixel rate
- Pixel rate is now a 64-bit control, not part of v4l2_mbus_framefmt
- Unit for pixel rate is pixels / second
- Pixel rate is read-only

- Link frequency is now in Hz --- documented as such also

- Link validation instead of pipeline validation
- Each link is validated by calling link_validate op
- Added link validation op to media_entity_ops
- Link validation op in pad ops makes this easy for subdev drivers
- media_entity_pipeline_start() may return an error code now
- This might affect other drivers, but will warn in compilation. No adverse effects are caused if the driver does not use link_validate().

- OMAP 3 ISP
- Make lanecfg as part of the platform data structure, not pointer
- Document lane configuration structures
- Link validation moved to respective subdev drivers from ispvideo.c
- isp_validate_pipeline() removed

- SMIA++ driver
- Update pixel order based on vflip and hflip
- Cleanups in the main driver, register definitions and PLL code
- Depend on V4L2_V4L2_SUBDEV_API and MEDIA_CONTROLLER
- Use pr_* macros instead of printk
- Improved error handling for i2c_transfer()
- Removed useless definitions
- Don't access try crop / compose directly but use helper functions
- Add xshutdown to platform data
- Move driver under smiapp directory

- rm680 board code
- Use REGULATOR_SUPPLY() where possible
- Removed printk()'s
- Don't include private smiapp headers

References:

[1] http://www.spinics.net/lists/linux-omap/msg61295.html

[2] http://www.spinics.net/lists/linux-media/msg40796.html

[3] http://www.spinics.net/lists/linux-media/msg41503.html

[4] http://www.spinics.net/lists/linux-media/msg41542.html

[5] http://www.spinics.net/lists/linux-media/msg40861.html

[6] http://www.spinics.net/lists/linux-media/msg41765.html

[7] http://www.spinics.net/lists/linux-media/msg42848.html

[8] http://www.spinics.net/lists/linux-media/msg42991.html

[9] http://www.spinics.net/lists/linux-media/msg43810.html

Kind regards,

Signature · 2 lines
Sakari Ailus
[email protected]
#1 lore raw

PATCH v2 1/31 v4l: Introduce integer menu controls

Create a new control type called V4L2_CTRL_TYPE_INTEGER_MENU. Integer menu controls are just like menu controls but the menu items are 64-bit integers rather than strings.

---
 drivers/media/video/v4l2-ctrls.c |   74 +++++++++++++++++++++++++++++---------
 include/linux/videodev2.h        |    6 +++-
 include/media/v4l2-ctrls.h       |    6 +++-
 3 files changed, 67 insertions(+), 19 deletions(-)
drivers/media/video/v4l2-ctrls.c +57 -17
index cccd42b..139ba42 100644
@@ -805,7 +805,8 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 change
 		ev->u.ctrl.value64 = ctrl->cur.val64;
 	ev->u.ctrl.minimum = ctrl->minimum;
 	ev->u.ctrl.maximum = ctrl->maximum;
-	if (ctrl->type == V4L2_CTRL_TYPE_MENU)
+	if (ctrl->type == V4L2_CTRL_TYPE_MENU
+	    || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU)
 		ev->u.ctrl.step = 1;
 	else
 		ev->u.ctrl.step = ctrl->step;
@@ -1036,10 +1037,13 @@ static int validate_new_int(const struct v4l2_ctrl *ctrl, s32 *pval)
 		return 0;
 
 	case V4L2_CTRL_TYPE_MENU:
+	case V4L2_CTRL_TYPE_INTEGER_MENU:
 		if (val < ctrl->minimum || val > ctrl->maximum)
 			return -ERANGE;
-		if (ctrl->qmenu[val][0] == '\0' ||
-		    (ctrl->menu_skip_mask & (1 << val)))
+		if (ctrl->menu_skip_mask & (1 << val))
+			return -EINVAL;
+		if (ctrl->type == V4L2_CTRL_TYPE_MENU &&
+		    ctrl->qmenu[val][0] == '\0')
 			return -EINVAL;
 		return 0;
 
@@ -1067,6 +1071,7 @@ static int validate_new(const struct v4l2_ctrl *ctrl, struct v4l2_ext_control *c
 	case V4L2_CTRL_TYPE_INTEGER:
 	case V4L2_CTRL_TYPE_BOOLEAN:
 	case V4L2_CTRL_TYPE_MENU:
+	case V4L2_CTRL_TYPE_INTEGER_MENU:
 	case V4L2_CTRL_TYPE_BITMASK:
 	case V4L2_CTRL_TYPE_BUTTON:
 	case V4L2_CTRL_TYPE_CTRL_CLASS:
@@ -1296,7 +1301,8 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 			const struct v4l2_ctrl_ops *ops,
 			u32 id, const char *name, enum v4l2_ctrl_type type,
 			s32 min, s32 max, u32 step, s32 def,
-			u32 flags, const char * const *qmenu, void *priv)
+			u32 flags, const char * const *qmenu,
+			const s64 *qmenu_int, void *priv)
 {
 	struct v4l2_ctrl *ctrl;
 	unsigned sz_extra = 0;
@@ -1309,6 +1315,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 	    (type == V4L2_CTRL_TYPE_INTEGER && step == 0) ||
 	    (type == V4L2_CTRL_TYPE_BITMASK && max == 0) ||
 	    (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) ||
+	    (type == V4L2_CTRL_TYPE_INTEGER_MENU && qmenu_int == NULL) ||
 	    (type == V4L2_CTRL_TYPE_STRING && max == 0)) {
 		handler_set_err(hdl, -ERANGE);
 		return NULL;
@@ -1319,6 +1326,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 	}
 	if ((type == V4L2_CTRL_TYPE_INTEGER ||
 	     type == V4L2_CTRL_TYPE_MENU ||
+	     type == V4L2_CTRL_TYPE_INTEGER_MENU ||
 	     type == V4L2_CTRL_TYPE_BOOLEAN) &&
 	    (def < min || def > max)) {
 		handler_set_err(hdl, -ERANGE);
@@ -1353,7 +1361,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 	ctrl->minimum = min;
 	ctrl->maximum = max;
 	ctrl->step = step;
-	ctrl->qmenu = qmenu;
+	if (type == V4L2_CTRL_TYPE_MENU)
+		ctrl->qmenu = qmenu;
+	else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
+		ctrl->qmenu_int = qmenu_int;
 	ctrl->priv = priv;
 	ctrl->cur.val = ctrl->val = ctrl->default_value = def;
 
@@ -1380,6 +1391,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
 	struct v4l2_ctrl *ctrl;
 	const char *name = cfg->name;
 	const char * const *qmenu = cfg->qmenu;
+	const s64 *qmenu_int = cfg->qmenu_int;
 	enum v4l2_ctrl_type type = cfg->type;
 	u32 flags = cfg->flags;
 	s32 min = cfg->min;
@@ -1391,18 +1403,24 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
 		v4l2_ctrl_fill(cfg->id, &name, &type, &min, &max, &step,
 								&def, &flags);
 
-	is_menu = (cfg->type == V4L2_CTRL_TYPE_MENU);
+	is_menu = (cfg->type == V4L2_CTRL_TYPE_MENU ||
+		   cfg->type == V4L2_CTRL_TYPE_INTEGER_MENU);
 	if (is_menu)
 		WARN_ON(step);
 	else
 		WARN_ON(cfg->menu_skip_mask);
-	if (is_menu && qmenu == NULL)
+	if (cfg->type == V4L2_CTRL_TYPE_MENU && qmenu == NULL)
 		qmenu = v4l2_ctrl_get_menu(cfg->id);
+	else if (cfg->type == V4L2_CTRL_TYPE_INTEGER_MENU &&
+		 qmenu_int == NULL) {
+		handler_set_err(hdl, -EINVAL);
+		return NULL;
+	}
 
 	ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->id, name,
 			type, min, max,
 			is_menu ? cfg->menu_skip_mask : step,
-			def, flags, qmenu, priv);
+			def, flags, qmenu, qmenu_int, priv);
 	if (ctrl)
 		ctrl->is_private = cfg->is_private;
 	return ctrl;
@@ -1419,12 +1437,13 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
 	u32 flags;
 
 	v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags);
-	if (type == V4L2_CTRL_TYPE_MENU) {
+	if (type == V4L2_CTRL_TYPE_MENU
+	    || type == V4L2_CTRL_TYPE_INTEGER_MENU) {
 		handler_set_err(hdl, -EINVAL);
 		return NULL;
 	}
 	return v4l2_ctrl_new(hdl, ops, id, name, type,
-				    min, max, step, def, flags, NULL, NULL);
+			     min, max, step, def, flags, NULL, NULL, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std);
 
@@ -1446,7 +1465,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
 		return NULL;
 	}
 	return v4l2_ctrl_new(hdl, ops, id, name, type,
-				    0, max, mask, def, flags, qmenu, NULL);
+			     0, max, mask, def, flags, qmenu, NULL, NULL);
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
 
@@ -1610,6 +1629,9 @@ static void log_ctrl(const struct v4l2_ctrl *ctrl,
 	case V4L2_CTRL_TYPE_MENU:
 		printk(KERN_CONT "%s", ctrl->qmenu[ctrl->cur.val]);
 		break;
+	case V4L2_CTRL_TYPE_INTEGER_MENU:
+		printk(KERN_CONT "%lld", ctrl->qmenu_int[ctrl->cur.val]);
+		break;
 	case V4L2_CTRL_TYPE_BITMASK:
 		printk(KERN_CONT "0x%08x", ctrl->cur.val);
 		break;
@@ -1746,7 +1768,8 @@ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc)
 	qc->minimum = ctrl->minimum;
 	qc->maximum = ctrl->maximum;
 	qc->default_value = ctrl->default_value;
-	if (ctrl->type == V4L2_CTRL_TYPE_MENU)
+	if (ctrl->type == V4L2_CTRL_TYPE_MENU
+	    || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU)
 		qc->step = 1;
 	else
 		qc->step = ctrl->step;
@@ -1776,16 +1799,33 @@ int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm)
 
 	qm->reserved = 0;
 	/* Sanity checks */
-	if (ctrl->qmenu == NULL ||
-	    i < ctrl->minimum || i > ctrl->maximum)
+	switch (ctrl->type) {
+	case V4L2_CTRL_TYPE_MENU:
+		if (ctrl->qmenu == NULL)
+			return -EINVAL;
+		break;
+	case V4L2_CTRL_TYPE_INTEGER_MENU:
+		if (ctrl->qmenu_int == NULL)
+			return -EINVAL;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (i < ctrl->minimum || i > ctrl->maximum)
 		return -EINVAL;
+
 	/* Use mask to see if this menu item should be skipped */
 	if (ctrl->menu_skip_mask & (1 << i))
 		return -EINVAL;
 	/* Empty menu items should also be skipped */
-	if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0')
-		return -EINVAL;
-	strlcpy(qm->name, ctrl->qmenu[i], sizeof(qm->name));
+	if (ctrl->type == V4L2_CTRL_TYPE_MENU) {
+		if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0')
+			return -EINVAL;
+		strlcpy(qm->name, ctrl->qmenu[i], sizeof(qm->name));
+	} else {
+		qm->value = ctrl->qmenu_int[i];
+	}
 	return 0;
 }
 EXPORT_SYMBOL(v4l2_querymenu);
include/linux/videodev2.h +5 -1
index 0db0503..a80c03d 100644
@@ -1150,6 +1150,7 @@ enum v4l2_ctrl_type {
 	V4L2_CTRL_TYPE_CTRL_CLASS    = 6,
 	V4L2_CTRL_TYPE_STRING        = 7,
 	V4L2_CTRL_TYPE_BITMASK       = 8,
+	V4L2_CTRL_TYPE_INTEGER_MENU = 9,
 };
 
 /*  Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
@@ -1169,7 +1170,10 @@ struct v4l2_queryctrl {
 struct v4l2_querymenu {
 	__u32		id;
 	__u32		index;
-	__u8		name[32];	/* Whatever */
+	union {
+		__u8	name[32];	/* Whatever */
+		__s64	value;
+	};
 	__u32		reserved;
 };
 
include/media/v4l2-ctrls.h +5 -1
index eeb3df6..f7819e7 100644
@@ -129,7 +129,10 @@ struct v4l2_ctrl {
 		u32 step;
 		u32 menu_skip_mask;
 	};
-	const char * const *qmenu;
+	union {
+		const char * const *qmenu;
+		const s64 *qmenu_int;
+	};
 	unsigned long flags;
 	union {
 		s32 val;
@@ -219,6 +222,7 @@ struct v4l2_ctrl_config {
 	u32 flags;
 	u32 menu_skip_mask;
 	const char * const *qmenu;
+	const s64 *qmenu_int;
 	unsigned int is_private:1;
 };
 
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH v2 2/31 v4l: Document integer menu controls

In reply to Sakari Ailus
---
 Documentation/DocBook/media/v4l/compat.xml         |   10 +++++
 Documentation/DocBook/media/v4l/v4l2.xml           |    6 +++
 .../DocBook/media/v4l/vidioc-queryctrl.xml         |   39 +++++++++++++++++++-
 3 files changed, 53 insertions(+), 2 deletions(-)
Documentation/DocBook/media/v4l/compat.xml +10 -0
index c93298f..8cd5c96 100644
@@ -2400,6 +2400,16 @@ details.</para>
       </orderedlist>
     </section>
 
+    <section>
+      <title>V4L2 in Linux 3.4</title>
+      <orderedlist>
+        <listitem>
+	  <para>Added integer menus, the new type will be
+	  V4L2_CTRL_TYPE_INTEGER_MENU.</para>
+        </listitem>
+      </orderedlist>
+    </section>
+
     <section id="other">
       <title>Relation of V4L2 to other Linux multimedia APIs</title>
 
Documentation/DocBook/media/v4l/v4l2.xml +6 -0
index dce3fef..3b857d5 100644
@@ -128,6 +128,12 @@ structs, ioctls) must be noted in more detail in the history chapter
 applications. -->
 
       <revision>
+	<revnumber>3.4</revnumber>
+	<date>2012-01-26</date>
+	<authorinitials>sa</authorinitials>
+	<revremark>Added V4L2_CTRL_TYPE_INTEGER_MENU.</revremark>
+      </revision>
+      <revision>
 	<revnumber>3.3</revnumber>
 	<date>2012-01-11</date>
 	<authorinitials>hv</authorinitials>
Documentation/DocBook/media/v4l/vidioc-queryctrl.xml +37 -2
index 36660d3..505f020 100644
@@ -215,11 +215,12 @@ the array to zero.</entry>
 
     <table pgwide="1" frame="none" id="v4l2-querymenu">
       <title>struct <structname>v4l2_querymenu</structname></title>
-      <tgroup cols="3">
+      <tgroup cols="4">
 	&cs-str;
 	<tbody valign="top">
 	  <row>
 	    <entry>__u32</entry>
+	    <entry></entry>
 	    <entry><structfield>id</structfield></entry>
 	    <entry>Identifies the control, set by the application
 from the respective &v4l2-queryctrl;
@@ -227,18 +228,38 @@ from the respective &v4l2-queryctrl;
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
+	    <entry></entry>
 	    <entry><structfield>index</structfield></entry>
 	    <entry>Index of the menu item, starting at zero, set by
 	    the application.</entry>
 	  </row>
 	  <row>
+	    <entry>union</entry>
+	    <entry></entry>
+	    <entry></entry>
+	    <entry></entry>
+	  </row>
+	  <row>
+	    <entry></entry>
 	    <entry>__u8</entry>
 	    <entry><structfield>name</structfield>[32]</entry>
 	    <entry>Name of the menu item, a NUL-terminated ASCII
-string. This information is intended for the user.</entry>
+string. This information is intended for the user. This field is valid
+for <constant>V4L2_CTRL_FLAG_MENU</constant> type controls.</entry>
+	  </row>
+	  <row>
+	    <entry></entry>
+	    <entry>__s64</entry>
+	    <entry><structfield>value</structfield></entry>
+	    <entry>
+              Value of the integer menu item. This field is valid for
+              <constant>V4L2_CTRL_FLAG_INTEGER_MENU</constant> type
+              controls.
+            </entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
+	    <entry></entry>
 	    <entry><structfield>reserved</structfield></entry>
 	    <entry>Reserved for future extensions. Drivers must set
 the array to zero.</entry>
@@ -292,6 +313,20 @@ the menu items can be enumerated with the
 <constant>VIDIOC_QUERYMENU</constant> ioctl.</entry>
 	  </row>
 	  <row>
+	    <entry><constant>V4L2_CTRL_TYPE_INTEGER_MENU</constant></entry>
+	    <entry>&ge; 0</entry>
+	    <entry>1</entry>
+	    <entry>N-1</entry>
+	    <entry>
+              The control has a menu of N choices. The values of the
+              menu items can be enumerated with the
+              <constant>VIDIOC_QUERYMENU</constant> ioctl. This is
+              similar to <constant>V4L2_CTRL_TYPE_MENU</constant>
+              except that instead of strings, the menu items are
+              signed 64-bit integers.
+            </entry>
+	  </row>
+	  <row>
 	    <entry><constant>V4L2_CTRL_TYPE_BITMASK</constant></entry>
 	    <entry>0</entry>
 	    <entry>n/a</entry>
Signature · 1 line
1.7.2.5
#3 lore raw

PATCH v2 3/31 vivi: Add an integer menu test control

In reply to Sakari Ailus

Add an integer menu test control for the vivi driver.

---
 drivers/media/video/vivi.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
drivers/media/video/vivi.c +22 -0
index 84ea88d..b58a2d8 100644
@@ -177,6 +177,7 @@ struct vivi_dev {
 	struct v4l2_ctrl	   *menu;
 	struct v4l2_ctrl	   *string;
 	struct v4l2_ctrl	   *bitmask;
+	struct v4l2_ctrl	   *int_menu;
 
 	spinlock_t                 slock;
 	struct mutex		   mutex;
@@ -503,6 +504,10 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
 			dev->boolean->cur.val,
 			dev->menu->qmenu[dev->menu->cur.val],
 			dev->string->cur.string);
+	snprintf(str, sizeof(str), " integer_menu %lld, value %d ",
+			dev->int_menu->qmenu_int[dev->int_menu->cur.val],
+			dev->int_menu->cur.val);
+	gen_text(dev, vbuf, line++ * 16, 16, str);
 	mutex_unlock(&dev->ctrl_handler.lock);
 	gen_text(dev, vbuf, line++ * 16, 16, str);
 	if (dev->button_pressed) {
@@ -1184,6 +1189,22 @@ static const struct v4l2_ctrl_config vivi_ctrl_bitmask = {
 	.step = 0,
 };
 
+static const s64 vivi_ctrl_int_menu_values[] = {
+	1, 1, 2, 3, 5, 8, 13, 21, 42,
+};
+
+static const struct v4l2_ctrl_config vivi_ctrl_int_menu = {
+	.ops = &vivi_ctrl_ops,
+	.id = VIVI_CID_CUSTOM_BASE + 7,
+	.name = "Integer menu",
+	.type = V4L2_CTRL_TYPE_INTEGER_MENU,
+	.min = 1,
+	.max = 8,
+	.def = 4,
+	.menu_skip_mask = 0x02,
+	.qmenu_int = vivi_ctrl_int_menu_values,
+};
+
 static const struct v4l2_file_operations vivi_fops = {
 	.owner		= THIS_MODULE,
 	.open           = v4l2_fh_open,
@@ -1294,6 +1315,7 @@ static int __init vivi_create_instance(int inst)
 	dev->menu = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_menu, NULL);
 	dev->string = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_string, NULL);
 	dev->bitmask = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_bitmask, NULL);
+	dev->int_menu = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int_menu, NULL);
 	if (hdl->error) {
 		ret = hdl->error;
 		goto unreg_dev;
Signature · 1 line
1.7.2.5
#4 lore raw

PATCH v2 4/31 v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs

In reply to Sakari Ailus

Add support for VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs. They replace functionality provided by VIDIOC_SUBDEV_S_CROP and VIDIOC_SUBDEV_G_CROP IOCTLs and also add new functionality (composing).

VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP continue to be supported.

---
 drivers/media/video/v4l2-subdev.c |   34 +++++++++++++++++++++---------
 include/linux/v4l2-subdev.h       |   41 +++++++++++++++++++++++++++++++++++++
 include/media/v4l2-subdev.h       |   21 +++++++++++++++---
 3 files changed, 82 insertions(+), 14 deletions(-)
drivers/media/video/v4l2-subdev.c +24 -10
index 41d118e..6bc5039 100644
@@ -35,14 +35,9 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-	/* Allocate try format and crop in the same memory block */
-	fh->try_fmt = kzalloc((sizeof(*fh->try_fmt) + sizeof(*fh->try_crop))
-			      * sd->entity.num_pads, GFP_KERNEL);
-	if (fh->try_fmt == NULL)
+	fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
+	if (fh->pad == NULL)
 		return -ENOMEM;
-
-	fh->try_crop = (struct v4l2_rect *)
-		(fh->try_fmt + sd->entity.num_pads);
 #endif
 	return 0;
 }
@@ -50,9 +45,8 @@ static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 static void subdev_fh_free(struct v4l2_subdev_fh *fh)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-	kfree(fh->try_fmt);
-	fh->try_fmt = NULL;
-	fh->try_crop = NULL;
+	kfree(fh->pad);
+	fh->pad = NULL;
 #endif
 }
 
@@ -285,6 +279,26 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 		return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh,
 					fie);
 	}
+
+	case VIDIOC_SUBDEV_G_SELECTION: {
+		struct v4l2_subdev_selection *sel = arg;
+
+		if (sel->pad >= sd->entity.num_pads)
+			return -EINVAL;
+
+		return v4l2_subdev_call(
+			sd, pad, get_selection, subdev_fh, sel);
+	}
+
+	case VIDIOC_SUBDEV_S_SELECTION: {
+		struct v4l2_subdev_selection *sel = arg;
+
+		if (sel->pad >= sd->entity.num_pads)
+			return -EINVAL;
+
+		return v4l2_subdev_call(
+			sd, pad, set_selection, subdev_fh, sel);
+	}
 #endif
 	default:
 		return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
include/linux/v4l2-subdev.h +41 -0

52 lines not on this page · raw message

include/media/v4l2-subdev.h +17 -4
index f0f3358..feab950 100644
@@ -466,6 +466,10 @@ struct v4l2_subdev_pad_ops {
 		       struct v4l2_subdev_crop *crop);
 	int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 		       struct v4l2_subdev_crop *crop);
+	int (*get_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+			     struct v4l2_subdev_selection *sel);
+	int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
+			     struct v4l2_subdev_selection *sel);
 };
 
 struct v4l2_subdev_ops {
@@ -549,8 +553,11 @@ struct v4l2_subdev {
 struct v4l2_subdev_fh {
 	struct v4l2_fh vfh;
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-	struct v4l2_mbus_framefmt *try_fmt;
-	struct v4l2_rect *try_crop;
+	struct {
+		struct v4l2_mbus_framefmt try_fmt;
+		struct v4l2_rect try_crop;
+		struct v4l2_rect try_compose;
+	} *pad;
 #endif
 };
 
@@ -561,13 +568,19 @@ struct v4l2_subdev_fh {
 static inline struct v4l2_mbus_framefmt *
 v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)
 {
-	return &fh->try_fmt[pad];
+	return &fh->pad[pad].try_fmt;
 }
 
 static inline struct v4l2_rect *
 v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad)
 {
-	return &fh->try_crop[pad];
+	return &fh->pad[pad].try_crop;
+}
+
+static inline struct v4l2_rect *
+v4l2_subdev_get_try_compose(struct v4l2_subdev_fh *fh, unsigned int pad)
+{
+	return &fh->pad[pad].try_compose;
 }
 #endif
 
Signature · 1 line
1.7.2.5
#5 lore raw

Re: [PATCH v2 04/31] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs

Quoted 13 lines · Sakari Ailus

Add support for VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs. They replace functionality provided by VIDIOC_SUBDEV_S_CROP and VIDIOC_SUBDEV_G_CROP IOCTLs and also add new functionality (composing).

VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP continue to be supported.

---
  drivers/media/video/v4l2-subdev.c |   34 +++++++++++++++++++++---------
  include/linux/v4l2-subdev.h       |   41 +++++++++++++++++++++++++++++++++++++
  include/media/v4l2-subdev.h       |   21 +++++++++++++++---
  3 files changed, 82 insertions(+), 14 deletions(-)

...

Quoted 6 lines
include/linux/v4l2-subdev.h +0 -0
index ed29cbb..192993a 100644
@@ -123,6 +123,43 @@ struct v4l2_subdev_frame_interval_enum {
  	__u32 reserved[9];

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 133

Quoted 10 lines
include/linux/v4l2-subdev.h +8 -0
  };
 
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE			(1<<  0)
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE			(1<<  1)
+#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG		(1<<  2)
+
+/* active cropping area */
+#define V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE			0
+/* cropping bounds */
+#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS			2

You've dropped the DEFAULT targets but the target numbers stayed unchanged. How about using hex numbers ? e.g.

#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTIVE 0x0100
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS 0x0101

?

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 146

Quoted 13 lines
include/linux/v4l2-subdev.h +13 -0
+/* current composing area */
+#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTIVE		256
+/* composing bounds */
+#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS		258
+
+
+/**
+ * struct v4l2_subdev_selection - selection info
+ *
+ * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
+ * @pad: pad number, as reported by the media API
+ * @target: selection target, used to choose one of possible rectangles
+ * @flags: constraints flags

s/constraints/constraint ?

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 147

Quoted 1 line
include/linux/v4l2-subdev.h +1 -0
+ * @r: coordinates of selection window

s/selection/ the selection ?

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 150

Quoted 3 lines
include/linux/v4l2-subdev.h +3 -0
+ * @reserved: for future use, rounds structure size to 64 bytes, set to zero
+ *
+ * Hardware may use multiple helper window to process a video stream.

s/window/windows ?

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 162

Quoted 12 lines
include/linux/v4l2-subdev.h +12 -0
+ * The structure is used to exchange this selection areas between
+ * an application and a driver.
+ */
+struct v4l2_subdev_selection {
+	__u32 which;
+	__u32 pad;
+	__u32 target;
+	__u32 flags;
+	struct v4l2_rect r;
+	__u32 reserved[8];
+};
+

--

Regards,
Sylwester

#6 lore raw

Re: [PATCH v2 04/31] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs

Hi Sylwester,

Thanks for the comments!!

Quoted 35 lines · Sylwester Nawrocki
Quoted 13 lines · Sakari Ailus

Add support for VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs. They replace functionality provided by VIDIOC_SUBDEV_S_CROP and VIDIOC_SUBDEV_G_CROP IOCTLs and also add new functionality (composing).

VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP continue to be supported.

---
  drivers/media/video/v4l2-subdev.c |   34 +++++++++++++++++++++---------
  include/linux/v4l2-subdev.h       |   41 +++++++++++++++++++++++++++++++++++++
  include/media/v4l2-subdev.h       |   21 +++++++++++++++---
  3 files changed, 82 insertions(+), 14 deletions(-)

...

Quoted 6 lines
include/linux/v4l2-subdev.h +0 -0
index ed29cbb..192993a 100644
@@ -123,6 +123,43 @@ struct v4l2_subdev_frame_interval_enum {
  	__u32 reserved[9];

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 133

Quoted 10 lines
include/linux/v4l2-subdev.h +8 -0
  };
 
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE			(1<<  0)
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE			(1<<  1)
+#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG		(1<<  2)
+
+/* active cropping area */
+#define V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE			0
+/* cropping bounds */
+#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS			2

You've dropped the DEFAULT targets but the target numbers stayed unchanged. How about using hex numbers ? e.g.

Quoted 2 lines

#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTIVE 0x0100
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS 0x0101

Fine for me. Changed for the next revision.

I wanted to keep the target numbers the same since we're still using exactly the same as the V4L2.

Quoted 16 lines

?

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 146

Quoted 13 lines
include/linux/v4l2-subdev.h +13 -0
+/* current composing area */
+#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTIVE		256
+/* composing bounds */
+#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS		258
+
+
+/**
+ * struct v4l2_subdev_selection - selection info
+ *
+ * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
+ * @pad: pad number, as reported by the media API
+ * @target: selection target, used to choose one of possible rectangles
+ * @flags: constraints flags

s/constraints/constraint ?

Fixed.

Quoted 9 lines

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 147

Quoted 1 line
include/linux/v4l2-subdev.h +1 -0
+ * @r: coordinates of selection window

s/selection/ the selection ?

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 150

Quoted 3 lines
include/linux/v4l2-subdev.h +3 -0
+ * @reserved: for future use, rounds structure size to 64 bytes, set to zero
+ *
+ * Hardware may use multiple helper window to process a video stream.

s/window/windows ?

Same for these two.

Quoted 4 lines
Quoted 4 lines
include/linux/v4l2-subdev.h +4 -0
+ * The structure is used to exchange this selection areas between
+ * an application and a driver.
+ */
+struct v4l2_subdev_selection {
Quoted 8 lines

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 162

Quoted 8 lines
include/linux/v4l2-subdev.h +8 -0
+	__u32 which;
+	__u32 pad;
+	__u32 target;
+	__u32 flags;
+	struct v4l2_rect r;
+	__u32 reserved[8];
+};
+

Cheers,

Signature · 2 lines
Sakari Ailus
[email protected]
#7 lore raw

Re: [PATCH v2 04/31] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs

Hi Sakari,

Quoted 12 lines · Sakari Ailus
Quoted 12 lines

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 133

Quoted 8 lines
include/linux/v4l2-subdev.h +8 -0
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE			(1<<   0)
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE			(1<<   1)
+#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG		(1<<   2)
+
+/* active cropping area */
+#define V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE			0
+/* cropping bounds */
+#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS			2

You've dropped the DEFAULT targets but the target numbers stayed unchanged. How about using hex numbers ? e.g.

Quoted 7 lines
Quoted 2 lines

#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTIVE 0x0100
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS 0x0101

Fine for me. Changed for the next revision.

I wanted to keep the target numbers the same since we're still using exactly the same as the V4L2.

You're right, keeping the numbers same for subdevs and regular video nodes may be important. I'm wondering whether we should use same definitions for subdevs, rather than inventing new ones ? In case we associate the selection targets with controls some target identifiers must not actually be different. Whether the control belongs directly to a video node control handler or is inherited from a sub-device the selection target would have to be same. I'm referring here to an auto focus rectangle selection target base for instance.
I guess including videodev2.h from v4l2-subdev.h is not an option, if at all necessary ?

--

Thanks,
Sylwester

#8 lore raw

Re: [PATCH v2 04/31] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs

Hi Sylwester,

Quoted 21 lines · Sylwester Nawrocki
Quoted 12 lines · Sakari Ailus
Quoted 12 lines

include/linux/v4l2-subdev.h struct v4l2_subdev_frame_interval_enum { · line 133

Quoted 8 lines
include/linux/v4l2-subdev.h +8 -0
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE			(1<<   0)
+#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE			(1<<   1)
+#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG		(1<<   2)
+
+/* active cropping area */
+#define V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE			0
+/* cropping bounds */
+#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS			2

You've dropped the DEFAULT targets but the target numbers stayed unchanged. How about using hex numbers ? e.g.

Quoted 7 lines
Quoted 2 lines

#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTIVE 0x0100
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS 0x0101

Fine for me. Changed for the next revision.

I wanted to keep the target numbers the same since we're still using exactly the same as the V4L2.

Quoted 10 lines

You're right, keeping the numbers same for subdevs and regular video nodes may be important. I'm wondering whether we should use same definitions for subdevs, rather than inventing new ones ? In case we associate the selection targets with controls some target identifiers must not actually be different. Whether the control belongs directly to a video node control handler or is inherited from a sub-device the selection target would have to be same. I'm referring here to an auto focus rectangle selection target base for instance.
I guess including videodev2.h from v4l2-subdev.h is not an option, if at all necessary ?

I think you're right; there would be advantages of using the same definitions. On the other hand, there may be subtle and not so subtle differences what these rectangles actually mean between the two interfaces.

The interface is quite similar to controls but the purpose it is used for is quite different: not many interdependencies are expected with controls whereas selections have many. The reason for this is we're using them to control various kinds of image processing functionality which might not be even similar on V4L2 subdev nodes and V4L2 nodes: the former is a superset of the latter.

I'd like to have Laurent's opinion on this.

Regards,

Signature · 2 lines
Sakari Ailus
e-mail: [email protected]	jabber/XMPP/Gmail: [email protected]
#9 lore raw

Re: [PATCH v2 04/31] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs

Hi Sakari,

Quoted 14 lines · Sakari Ailus
Quoted 13 lines
Quoted 2 lines

I wanted to keep the target numbers the same since we're still using exactly the same as the V4L2.

You're right, keeping the numbers same for subdevs and regular video nodes may be important. I'm wondering whether we should use same definitions for subdevs, rather than inventing new ones ? In case we associate the selection targets with controls some target identifiers must not actually be different. Whether the control belongs directly to a video node control handler or is inherited from a sub-device the selection target would have to be same. I'm referring here to an auto focus rectangle selection target base for instance.
I guess including videodev2.h from v4l2-subdev.h is not an option, if at all necessary ?

Quoted 3 lines

I think you're right; there would be advantages of using the same definitions. On the other hand, there may be subtle and not so subtle differences what these rectangles actually mean between the two interfaces.

Until now those analogous rectangles mean different things for subdevs and for video devnodes. It then doesn't matter that much what numbers identify them, or even the numbers should be made distinct by design to make any attempts to use them interchangeably fail right away.

A little worrying is that with this approach we diverge from a situation where a selection target id _do_ actually mean the same for the two interfaces.

Ideally I would see all the targets defined centrally with definitions that would be telling explicitly what is different and what is not for both interfaces.

Quoted 6 lines

The interface is quite similar to controls but the purpose it is used for is quite different: not many interdependencies are expected with controls whereas selections have many. The reason for this is we're using them to control various kinds of image processing functionality which might not be even similar on V4L2 subdev nodes and V4L2 nodes: the former is a superset of the latter.

I see your point. Maybe using selections with controls is a Bad Idea(tm) ? :) However inventing a new ioctls for auto exposure/focus/wb seems a bit pointless..

Quoted 1 line

I'd like to have Laurent's opinion on this.

--

Regards,
Sylwester

#10 lore raw

PATCH v2 5/31 v4l: Support s_crop and g_crop through s/g_selection

In reply to Sakari Ailus

Fall back to s_selection if s_crop isn't implemented by a driver. Same for g_selection / g_crop.

---
 drivers/media/video/v4l2-subdev.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)
drivers/media/video/v4l2-subdev.c +35 -2
index 6bc5039..2c8d467 100644
@@ -220,6 +220,8 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 
 	case VIDIOC_SUBDEV_G_CROP: {
 		struct v4l2_subdev_crop *crop = arg;
+		struct v4l2_subdev_selection sel;
+		int rval;
 
 		if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
 		    crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
@@ -228,11 +230,27 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 		if (crop->pad >= sd->entity.num_pads)
 			return -EINVAL;
 
-		return v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop);
+		rval = v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop);
+		if (rval != -ENOIOCTLCMD)
+			return rval;
+
+		memset(&sel, 0, sizeof(sel));
+		sel.which = crop->which;
+		sel.pad = crop->pad;
+		sel.target = V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE;
+
+		rval = v4l2_subdev_call(
+			sd, pad, get_selection, subdev_fh, &sel);
+
+		crop->rect = sel.r;
+
+		return rval;
 	}
 
 	case VIDIOC_SUBDEV_S_CROP: {
 		struct v4l2_subdev_crop *crop = arg;
+		struct v4l2_subdev_selection sel;
+		int rval;
 
 		if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
 		    crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
@@ -241,7 +259,22 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 		if (crop->pad >= sd->entity.num_pads)
 			return -EINVAL;
 
-		return v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop);
+		rval = v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop);
+		if (rval != -ENOIOCTLCMD)
+			return rval;
+
+		memset(&sel, 0, sizeof(sel));
+		sel.which = crop->which;
+		sel.pad = crop->pad;
+		sel.target = V4L2_SUBDEV_SEL_TGT_CROP_ACTIVE;
+		sel.r = crop->rect;
+
+		rval = v4l2_subdev_call(
+			sd, pad, set_selection, subdev_fh, &sel);
+
+		crop->rect = sel.r;
+
+		return rval;
 	}
 
 	case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
Signature · 1 line
1.7.2.5
#11 lore raw

PATCH v2 6/31 v4l: Add subdev selections documentation: svg and dia files

In reply to Sakari Ailus

Add svga and dia files for V4L2 subdev selections documentation.

---
 .../media/v4l/subdev-image-processing-crop.dia     |  719 ++++++++
 .../media/v4l/subdev-image-processing-crop.svg     |   71 +
 .../media/v4l/subdev-image-processing-full.dia     | 1888 ++++++++++++++++++++
 .../media/v4l/subdev-image-processing-full.svg     |  172 ++
 ...ubdev-image-processing-scaling-multi-source.dia | 1407 +++++++++++++++
 ...ubdev-image-processing-scaling-multi-source.svg |  130 ++
 6 files changed, 4387 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/subdev-image-processing-crop.dia
 create mode 100644 Documentation/DocBook/media/v4l/subdev-image-processing-crop.svg
 create mode 100644 Documentation/DocBook/media/v4l/subdev-image-processing-full.dia
 create mode 100644 Documentation/DocBook/media/v4l/subdev-image-processing-full.svg
 create mode 100644 Documentation/DocBook/media/v4l/subdev-image-processing-scaling-multi-source.dia
 create mode 100644 Documentation/DocBook/media/v4l/subdev-image-processing-scaling-multi-source.svg
Documentation/DocBook/media/v4l/subdev-image-processing-crop.dia new file +719 -0
new file mode 100644
index 0000000..5c467ec
@@ -0,0 +1,719 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dia:diagram xmlns:dia="http://www.lysator.liu.se/~alla/dia/">
+  <dia:diagramdata>
+    <dia:attribute name="background">
+      <dia:color val="#ffffff"/>
+    </dia:attribute>
+    <dia:attribute name="pagebreak">
+      <dia:color val="#000099"/>
+    </dia:attribute>
+    <dia:attribute name="paper">
+      <dia:composite type="paper">
+        <dia:attribute name="name">
+          <dia:string>#A4#</dia:string>
+        </dia:attribute>
+        <dia:attribute name="tmargin">
+          <dia:real val="2.8222000598907471"/>
+        </dia:attribute>
+        <dia:attribute name="bmargin">
+          <dia:real val="2.8222000598907471"/>
+        </dia:attribute>
+        <dia:attribute name="lmargin">
+          <dia:real val="2.8222000598907471"/>
+        </dia:attribute>
+        <dia:attribute name="rmargin">
+          <dia:real val="2.8222000598907471"/>
+        </dia:attribute>
+        <dia:attribute name="is_portrait">
+          <dia:boolean val="false"/>
+        </dia:attribute>
+        <dia:attribute name="scaling">
+          <dia:real val="0.49000000953674316"/>
+        </dia:attribute>
+        <dia:attribute name="fitto">
+          <dia:boolean val="false"/>
+        </dia:attribute>
+      </dia:composite>
+    </dia:attribute>
+    <dia:attribute name="grid">
+      <dia:composite type="grid">
+        <dia:attribute name="width_x">
+          <dia:real val="1"/>
+        </dia:attribute>
+        <dia:attribute name="width_y">
+          <dia:real val="1"/>
+        </dia:attribute>
+        <dia:attribute name="visible_x">
+          <dia:int val="1"/>
+        </dia:attribute>
+        <dia:attribute name="visible_y">
+          <dia:int val="1"/>
+        </dia:attribute>
+        <dia:composite type="color"/>
+      </dia:composite>
+    </dia:attribute>
+    <dia:attribute name="color">
+      <dia:color val="#d8e5e5"/>
+    </dia:attribute>
+    <dia:attribute name="guides">
+      <dia:composite type="guides">
+        <dia:attribute name="hguides"/>
+        <dia:attribute name="vguides"/>
+      </dia:composite>
+    </dia:attribute>
+  </dia:diagramdata>
+  <dia:layer name="Background" visible="true" active="true">
+    <dia:object type="Standard - Box" version="0" id="O0">
+      <dia:attribute name="obj_pos">
+        <dia:point val="-0.4,6.5"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="-0.45,6.45;23.1387,16.2"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="-0.4,6.5"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="23.48871579904775"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="9.6500000000000004"/>
+      </dia:attribute>
+      <dia:attribute name="border_width">
+        <dia:real val="0.10000000149011612"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="false"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Box" version="0" id="O1">
+      <dia:attribute name="obj_pos">
+        <dia:point val="0.225,9.45"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="0.175,9.4;8.225,14.7"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="0.225,9.45"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="7.9499999999999975"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="5.1999999999999975"/>
+      </dia:attribute>
+      <dia:attribute name="border_width">
+        <dia:real val="0.10000000149011612"/>
+      </dia:attribute>
+      <dia:attribute name="border_color">
+        <dia:color val="#a52a2a"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="true"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Box" version="0" id="O2">
+      <dia:attribute name="obj_pos">
+        <dia:point val="10.625,11.35"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="10.575,11.3;15.375,15.25"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="10.625,11.35"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="4.6999999999999975"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="3.8499999999999979"/>
+      </dia:attribute>
+      <dia:attribute name="border_width">
+        <dia:real val="0.10000000149011612"/>
+      </dia:attribute>
+      <dia:attribute name="border_color">
+        <dia:color val="#0000ff"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="true"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Box" version="0" id="O3">
+      <dia:attribute name="obj_pos">
+        <dia:point val="2.915,9.75"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="2.865,9.7;7.665,13.65"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="2.915,9.75"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="4.6999999999999975"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="3.8499999999999979"/>
+      </dia:attribute>
+      <dia:attribute name="border_width">
+        <dia:real val="0.10000000149011612"/>
+      </dia:attribute>
+      <dia:attribute name="border_color">
+        <dia:color val="#0000ff"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="true"/>
+      </dia:attribute>
+      <dia:attribute name="line_style">
+        <dia:enum val="4"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O4">
+      <dia:attribute name="obj_pos">
+        <dia:point val="10.625,15.2"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="2.85588,13.5409;10.6841,15.2591"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="10.625,15.2"/>
+        <dia:point val="2.915,13.6"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O2" connection="5"/>
+        <dia:connection handle="1" to="O3" connection="5"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O5">
+      <dia:attribute name="obj_pos">
+        <dia:point val="10.625,11.35"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="2.85588,9.69088;10.6841,11.4091"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="10.625,11.35"/>
+        <dia:point val="2.915,9.75"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O2" connection="0"/>
+        <dia:connection handle="1" to="O3" connection="0"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O6">
+      <dia:attribute name="obj_pos">
+        <dia:point val="15.325,15.2"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="7.55588,13.5409;15.3841,15.2591"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="15.325,15.2"/>
+        <dia:point val="7.615,13.6"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O2" connection="7"/>
+        <dia:connection handle="1" to="O3" connection="7"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O7">
+      <dia:attribute name="obj_pos">
+        <dia:point val="15.325,11.35"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="7.55588,9.69088;15.3841,11.4091"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="15.325,11.35"/>
+        <dia:point val="7.615,9.75"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O2" connection="2"/>
+        <dia:connection handle="1" to="O3" connection="2"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Text" version="1" id="O8">
+      <dia:attribute name="obj_pos">
+        <dia:point val="10.625,7.65"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="10.625,7.055;13.5025,9.4025"/>
+      </dia:attribute>
+      <dia:attribute name="text">
+        <dia:composite type="text">
+          <dia:attribute name="string">
+            <dia:string>#sink
+crop
+selection#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="font">
+            <dia:font family="sans" style="0" name="Helvetica"/>
+          </dia:attribute>
+          <dia:attribute name="height">
+            <dia:real val="0.80000000000000004"/>
+          </dia:attribute>
+          <dia:attribute name="pos">
+            <dia:point val="10.625,7.65"/>
+          </dia:attribute>
+          <dia:attribute name="color">
+            <dia:color val="#0000ff"/>
+          </dia:attribute>
+          <dia:attribute name="alignment">
+            <dia:enum val="0"/>
+          </dia:attribute>
+        </dia:composite>
+      </dia:attribute>
+      <dia:attribute name="valign">
+        <dia:enum val="3"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Text" version="1" id="O9">
+      <dia:attribute name="obj_pos">
+        <dia:point val="1.475,7.9"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="1.475,7.305;1.475,8.0525"/>
+      </dia:attribute>
+      <dia:attribute name="text">
+        <dia:composite type="text">
+          <dia:attribute name="string">
+            <dia:string>##</dia:string>
+          </dia:attribute>
+          <dia:attribute name="font">
+            <dia:font family="sans" style="0" name="Helvetica"/>
+          </dia:attribute>
+          <dia:attribute name="height">
+            <dia:real val="0.80000000000000004"/>
+          </dia:attribute>
+          <dia:attribute name="pos">
+            <dia:point val="1.475,7.9"/>
+          </dia:attribute>
+          <dia:attribute name="color">
+            <dia:color val="#000000"/>
+          </dia:attribute>
+          <dia:attribute name="alignment">
+            <dia:enum val="0"/>
+          </dia:attribute>
+        </dia:composite>
+      </dia:attribute>
+      <dia:attribute name="valign">
+        <dia:enum val="3"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Text" version="1" id="O10">
+      <dia:attribute name="obj_pos">
+        <dia:point val="0.426918,7.89569"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="0.426918,7.30069;3.90942,8.84819"/>
+      </dia:attribute>
+      <dia:attribute name="text">
+        <dia:composite type="text">
+          <dia:attribute name="string">
+            <dia:string>#sink media
+bus format#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="font">
+            <dia:font family="sans" style="0" name="Helvetica"/>
+          </dia:attribute>
+          <dia:attribute name="height">
+            <dia:real val="0.80000000000000004"/>
+          </dia:attribute>
+          <dia:attribute name="pos">
+            <dia:point val="0.426918,7.89569"/>
+          </dia:attribute>
+          <dia:attribute name="color">
+            <dia:color val="#a52a2a"/>
+          </dia:attribute>
+          <dia:attribute name="alignment">
+            <dia:enum val="0"/>
+          </dia:attribute>
+        </dia:composite>
+      </dia:attribute>
+      <dia:attribute name="valign">
+        <dia:enum val="3"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Text" version="1" id="O11">
+      <dia:attribute name="obj_pos">
+        <dia:point val="17.4887,7.75"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="17.4887,7.155;21.8112,8.7025"/>
+      </dia:attribute>
+      <dia:attribute name="text">
+        <dia:composite type="text">
+          <dia:attribute name="string">
+            <dia:string>#source media
+bus format#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="font">
+            <dia:font family="sans" style="0" name="Helvetica"/>
+          </dia:attribute>
+          <dia:attribute name="height">
+            <dia:real val="0.80000000000000004"/>
+          </dia:attribute>
+          <dia:attribute name="pos">
+            <dia:point val="17.4887,7.75"/>
+          </dia:attribute>
+          <dia:attribute name="color">
+            <dia:color val="#8b6914"/>
+          </dia:attribute>
+          <dia:attribute name="alignment">
+            <dia:enum val="0"/>
+          </dia:attribute>
+        </dia:composite>
+      </dia:attribute>
+      <dia:attribute name="valign">
+        <dia:enum val="3"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Box" version="0" id="O12">
+      <dia:attribute name="obj_pos">
+        <dia:point val="17.5244,9.5417"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="17.4744,9.4917;22.2387,13.35"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="17.5244,9.5417"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="4.6643157990477508"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="3.758300000000002"/>
+      </dia:attribute>
+      <dia:attribute name="border_width">
+        <dia:real val="0.10000000149011612"/>
+      </dia:attribute>
+      <dia:attribute name="border_color">
+        <dia:color val="#8b6914"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="true"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O13">
+      <dia:attribute name="obj_pos">
+        <dia:point val="17.5244,13.3"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="10.5635,13.2385;17.5859,15.2615"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="17.5244,13.3"/>
+        <dia:point val="10.625,15.2"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O12" connection="5"/>
+        <dia:connection handle="1" to="O2" connection="5"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O14">
+      <dia:attribute name="obj_pos">
+        <dia:point val="17.5244,9.5417"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="10.564,9.48066;17.5854,11.411"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="17.5244,9.5417"/>
+        <dia:point val="10.625,11.35"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O12" connection="0"/>
+        <dia:connection handle="1" to="O2" connection="0"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O15">
+      <dia:attribute name="obj_pos">
+        <dia:point val="22.1887,13.3"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="15.2635,13.2385;22.2502,15.2615"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="22.1887,13.3"/>
+        <dia:point val="15.325,15.2"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O12" connection="7"/>
+        <dia:connection handle="1" to="O2" connection="7"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O16">
+      <dia:attribute name="obj_pos">
+        <dia:point val="22.1887,9.5417"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="15.2639,9.48061;22.2498,11.4111"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="22.1887,9.5417"/>
+        <dia:point val="15.325,11.35"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="line_color">
+        <dia:color val="#e60505"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O12" connection="2"/>
+        <dia:connection handle="1" to="O2" connection="2"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Geometric - Perfect Circle" version="1" id="O17">
+      <dia:attribute name="obj_pos">
+        <dia:point val="23.23,10.5742"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="23.18,10.5242;24.13,11.4742"/>
+      </dia:attribute>
+      <dia:attribute name="meta">
+        <dia:composite type="dict"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="23.23,10.5742"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="0.84999999999999787"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="0.84999999999999787"/>
+      </dia:attribute>
+      <dia:attribute name="line_width">
+        <dia:real val="0.10000000000000001"/>
+      </dia:attribute>
+      <dia:attribute name="line_colour">
+        <dia:color val="#000000"/>
+      </dia:attribute>
+      <dia:attribute name="fill_colour">
+        <dia:color val="#ffffff"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="true"/>
+      </dia:attribute>
+      <dia:attribute name="line_style">
+        <dia:enum val="0"/>
+        <dia:real val="1"/>
+      </dia:attribute>
+      <dia:attribute name="flip_horizontal">
+        <dia:boolean val="false"/>
+      </dia:attribute>
+      <dia:attribute name="flip_vertical">
+        <dia:boolean val="false"/>
+      </dia:attribute>
+      <dia:attribute name="subscale">
+        <dia:real val="1"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O18">
+      <dia:attribute name="obj_pos">
+        <dia:point val="24.08,10.9992"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="24.03,10.6388;32.4953,11.3624"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="24.08,10.9992"/>
+        <dia:point val="32.3835,11.0007"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="end_arrow">
+        <dia:enum val="22"/>
+      </dia:attribute>
+      <dia:attribute name="end_arrow_length">
+        <dia:real val="0.5"/>
+      </dia:attribute>
+      <dia:attribute name="end_arrow_width">
+        <dia:real val="0.5"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="0" to="O17" connection="3"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Text" version="1" id="O19">
+      <dia:attribute name="obj_pos">
+        <dia:point val="25.3454,10.49"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="25.3454,9.895;29.9904,10.6425"/>
+      </dia:attribute>
+      <dia:attribute name="text">
+        <dia:composite type="text">
+          <dia:attribute name="string">
+            <dia:string>#pad 1 (source)#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="font">
+            <dia:font family="sans" style="0" name="Helvetica"/>
+          </dia:attribute>
+          <dia:attribute name="height">
+            <dia:real val="0.80000000000000004"/>
+          </dia:attribute>
+          <dia:attribute name="pos">
+            <dia:point val="25.3454,10.49"/>
+          </dia:attribute>
+          <dia:attribute name="color">
+            <dia:color val="#000000"/>
+          </dia:attribute>
+          <dia:attribute name="alignment">
+            <dia:enum val="0"/>
+          </dia:attribute>
+        </dia:composite>
+      </dia:attribute>
+      <dia:attribute name="valign">
+        <dia:enum val="3"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Geometric - Perfect Circle" version="1" id="O20">
+      <dia:attribute name="obj_pos">
+        <dia:point val="-1.44491,11.6506"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="-1.49491,11.6006;-0.544912,12.5506"/>
+      </dia:attribute>
+      <dia:attribute name="meta">
+        <dia:composite type="dict"/>
+      </dia:attribute>
+      <dia:attribute name="elem_corner">
+        <dia:point val="-1.44491,11.6506"/>
+      </dia:attribute>
+      <dia:attribute name="elem_width">
+        <dia:real val="0.84999999999999787"/>
+      </dia:attribute>
+      <dia:attribute name="elem_height">
+        <dia:real val="0.84999999999999787"/>
+      </dia:attribute>
+      <dia:attribute name="line_width">
+        <dia:real val="0.10000000000000001"/>
+      </dia:attribute>
+      <dia:attribute name="line_colour">
+        <dia:color val="#000000"/>
+      </dia:attribute>
+      <dia:attribute name="fill_colour">
+        <dia:color val="#ffffff"/>
+      </dia:attribute>
+      <dia:attribute name="show_background">
+        <dia:boolean val="true"/>
+      </dia:attribute>
+      <dia:attribute name="line_style">
+        <dia:enum val="0"/>
+        <dia:real val="1"/>
+      </dia:attribute>
+      <dia:attribute name="flip_horizontal">
+        <dia:boolean val="false"/>
+      </dia:attribute>
+      <dia:attribute name="flip_vertical">
+        <dia:boolean val="false"/>
+      </dia:attribute>
+      <dia:attribute name="subscale">
+        <dia:real val="1"/>
+      </dia:attribute>
+    </dia:object>
+    <dia:object type="Standard - Line" version="0" id="O21">
+      <dia:attribute name="obj_pos">
+        <dia:point val="-9.61991,12.09"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="-9.67,11.7149;-1.33311,12.4385"/>
+      </dia:attribute>
+      <dia:attribute name="conn_endpoints">
+        <dia:point val="-9.61991,12.09"/>
+        <dia:point val="-1.44491,12.0756"/>
+      </dia:attribute>
+      <dia:attribute name="numcp">
+        <dia:int val="1"/>
+      </dia:attribute>
+      <dia:attribute name="end_arrow">
+        <dia:enum val="22"/>
+      </dia:attribute>
+      <dia:attribute name="end_arrow_length">
+        <dia:real val="0.5"/>
+      </dia:attribute>
+      <dia:attribute name="end_arrow_width">
+        <dia:real val="0.5"/>
+      </dia:attribute>
+      <dia:connections>
+        <dia:connection handle="1" to="O20" connection="2"/>
+      </dia:connections>
+    </dia:object>
+    <dia:object type="Standard - Text" version="1" id="O22">
+      <dia:attribute name="obj_pos">
+        <dia:point val="-7.39291,11.49"/>
+      </dia:attribute>
+      <dia:attribute name="obj_bb">
+        <dia:rectangle val="-7.39291,10.895;-3.58791,11.6425"/>
+      </dia:attribute>
+      <dia:attribute name="text">
+        <dia:composite type="text">
+          <dia:attribute name="string">
+            <dia:string>#pad 0 (sink)#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="font">
+            <dia:font family="sans" style="0" name="Helvetica"/>
+          </dia:attribute>
+          <dia:attribute name="height">
+            <dia:real val="0.80000000000000004"/>
+          </dia:attribute>
+          <dia:attribute name="pos">
+            <dia:point val="-7.39291,11.49"/>
+          </dia:attribute>
+          <dia:attribute name="color">
+            <dia:color val="#000000"/>
+          </dia:attribute>
+          <dia:attribute name="alignment">
+            <dia:enum val="0"/>
+          </dia:attribute>
+        </dia:composite>
+      </dia:attribute>
+      <dia:attribute name="valign">
+        <dia:enum val="3"/>
+      </dia:attribute>
+    </dia:object>
+  </dia:layer>
+</dia:diagram>
Documentation/DocBook/media/v4l/subdev-image-processing-crop.svg new file +71 -0

71 lines not on this page · raw message

Documentation/DocBook/media/v4l/subdev-image-processing-full.dia new file +1888 -0

1,888 lines not on this page · raw message

Documentation/DocBook/media/v4l/subdev-image-processing-full.svg new file +172 -0

172 lines not on this page · raw message

Documentation/DocBook/media/v4l/subdev-image-processing-scaling-multi-source.dia new file +1407 -0

150 lines not on this page · raw message

Documentation/DocBook/media/v4l/subdev-image-processing-scaling-multi-source.svg new file +130 -0

130 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.2.5

Part of the diff is not shown here. View the raw message.

#12 lore raw

PATCH v2 7/31 v4l: Add subdev selections documentation

In reply to Sakari Ailus

Add documentation for V4L2 subdev selection API. This changes also experimental V4L2 subdev API so that scaling now works through selection API only.

---
 Documentation/DocBook/media/Makefile               |    2 +-
 Documentation/DocBook/media/v4l/compat.xml         |    3 +
 Documentation/DocBook/media/v4l/dev-subdev.xml     |  188 +++++++++++++++--
 Documentation/DocBook/media/v4l/v4l2.xml           |   17 ++-
 .../media/v4l/vidioc-subdev-g-selection.xml        |  222 ++++++++++++++++++++
 5 files changed, 405 insertions(+), 27 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml
Documentation/DocBook/media/Makefile +1 -1
index 6628b4b..729f840 100644
@@ -193,7 +193,7 @@ DVB_DOCUMENTED = \
 #
 
 install_media_images = \
-	$(Q)cp $(OBJIMGFILES) $(MEDIA_OBJ_DIR)/media_api
+	$(Q)cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api
 
 $(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64
 	$(Q)base64 -d $< >$@
Documentation/DocBook/media/v4l/compat.xml +3 -0
index 8cd5c96..0c498db 100644
@@ -2407,6 +2407,9 @@ details.</para>
 	  <para>Added integer menus, the new type will be
 	  V4L2_CTRL_TYPE_INTEGER_MENU.</para>
         </listitem>
+        <listitem>
+	  <para>Added selection API for V4L2 subdev interface.</para>
+        </listitem>
       </orderedlist>
     </section>
 
Documentation/DocBook/media/v4l/dev-subdev.xml +164 -24

212 lines not on this page · raw message

Documentation/DocBook/media/v4l/v4l2.xml +15 -2
index 3b857d5..83248ef 100644
@@ -96,6 +96,17 @@ Remote Controller chapter.</contrib>
 	  </address>
 	</affiliation>
       </author>
+
+      <author>
+	<firstname>Sakari</firstname>
+	<surname>Ailus</surname>
+	<contrib>Subdev selections API.</contrib>
+	<affiliation>
+	  <address>
+	    <email>[email protected]</email>
+	  </address>
+	</affiliation>
+      </author>
     </authorgroup>
 
     <copyright>
@@ -129,9 +140,10 @@ applications. -->
 
       <revision>
 	<revnumber>3.4</revnumber>
-	<date>2012-01-26</date>
+	<date>2012-02-02</date>
 	<authorinitials>sa</authorinitials>
-	<revremark>Added V4L2_CTRL_TYPE_INTEGER_MENU.</revremark>
+	<revremark>Added V4L2_CTRL_TYPE_INTEGER_MENU. Added V4L2 subdev
+		   selections API.</revremark>
       </revision>
       <revision>
 	<revnumber>3.3</revnumber>
@@ -536,6 +548,7 @@ and discussions on the V4L mailing list.</revremark>
     &sub-subdev-g-crop;
     &sub-subdev-g-fmt;
     &sub-subdev-g-frame-interval;
+    &sub-subdev-g-selection;
     &sub-subscribe-event;
     <!-- End of ioctls. -->
     &sub-mmap;
Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml new file +222 -0

222 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#13 lore raw

PATCH v2 8/31 v4l: Mark VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP obsolete

In reply to Sakari Ailus

These two IOCTLS are obsoleted by VIDIOC_SUBDEV_G_SELECTION and VIDIOC_SUBDEV_S_SELECTION. Mark them obsolete.

---
 Documentation/DocBook/media/v4l/compat.xml         |    7 +++++++
 .../DocBook/media/v4l/vidioc-subdev-g-crop.xml     |    9 ++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
Documentation/DocBook/media/v4l/compat.xml +7 -0
index 0c498db..da9b3bd 100644
@@ -2541,6 +2541,13 @@ interfaces and should not be implemented in new drivers.</para>
 <constant>VIDIOC_S_MPEGCOMP</constant> ioctls. Use Extended Controls,
 <xref linkend="extended-controls" />.</para>
         </listitem>
+        <listitem>
+	  <para><constant>VIDIOC_SUBDEV_G_CROP</constant> and
+	  <constant>VIDIOC_SUBDEV_S_CROP</constant> ioctls. Use
+	  <constant>VIDIOC_SUBDEV_G_SELECTION</constant> and
+	  <constant>VIDIOC_SUBDEV_S_SELECTION</constant>, <xref
+	  linkend="vidioc-subdev-g-selection" />.</para>
+        </listitem>
       </itemizedlist>
     </section>
   </section>
Documentation/DocBook/media/v4l/vidioc-subdev-g-crop.xml +6 -3
index 0619732..4cddd78 100644
@@ -58,9 +58,12 @@
     <title>Description</title>
 
     <note>
-      <title>Experimental</title>
-      <para>This is an <link linkend="experimental">experimental</link>
-      interface and may change in the future.</para>
+      <title>Obsolete</title>
+
+      <para>This is an <link linkend="obsolete">obsolete</link>
+      interface and may be removed in the future. It is superseded by
+      <link linkend="vidioc-subdev-g-selection">the selection
+      API</link>.</para>
     </note>
 
     <para>To retrieve the current crop rectangle applications set the
Signature · 1 line
1.7.2.5
#14 lore raw

PATCH v2 9/31 v4l: Image source control class

In reply to Sakari Ailus

Add image source control class. This control class is intended to contain low level controls which deal with control of the image capture process --- the A/D converter in image sensors, for example.

---
 Documentation/DocBook/media/v4l/controls.xml       |   86 ++++++++++++++++++++
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml       |    6 ++
 drivers/media/video/v4l2-ctrls.c                   |    7 ++
 include/linux/videodev2.h                          |    9 ++
 4 files changed, 108 insertions(+), 0 deletions(-)
Documentation/DocBook/media/v4l/controls.xml +86 -0
index a1be378..6842e80 100644
@@ -3379,4 +3379,90 @@ interface and may change in the future.</para>
       </table>
 
     </section>
+
+    <section id="image-source-controls">
+      <title>Image Source Control Reference</title>
+
+      <note>
+	<title>Experimental</title>
+
+	<para>This is an <link
+	linkend="experimental">experimental</link> interface and may
+	change in the future.</para>
+      </note>
+
+      <para>
+	The Image Source control class is intended for low-level
+	control of image source devices such as image sensors. The
+	devices feature an analogue to digital converter and a bus
+	transmitter to transmit the image data out of the device.
+      </para>
+
+      <table pgwide="1" frame="none" id="image-source-control-id">
+      <title>Image Source Control IDs</title>
+
+      <tgroup cols="4">
+	<colspec colname="c1" colwidth="1*" />
+	<colspec colname="c2" colwidth="6*" />
+	<colspec colname="c3" colwidth="2*" />
+	<colspec colname="c4" colwidth="6*" />
+	<spanspec namest="c1" nameend="c2" spanname="id" />
+	<spanspec namest="c2" nameend="c4" spanname="descr" />
+	<thead>
+	  <row>
+	    <entry spanname="id" align="left">ID</entry>
+	    <entry align="left">Type</entry>
+	  </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+	  </row>
+	</thead>
+	<tbody valign="top">
+	  <row><entry></entry></row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_CLASS</constant></entry>
+	    <entry>class</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">The IMAGE_SOURCE class descriptor.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_VBLANK</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Vertical blanking. The idle
+	    preriod after every frame during which no image data is
+	    produced. The unit of vertical blanking is a line. Every
+	    line has length of the image width plus horizontal
+	    blanking at the pixel clock specified by struct
+	    v4l2_mbus_framefmt <xref linkend="v4l2-mbus-framefmt"
+	    />.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_HBLANK</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Horizontal blanking. The idle
+	    preriod after every line of image data during which no
+	    image data is produced. The unit of horizontal blanking is
+	    pixels.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Analogue gain is gain affecting
+	    all colour components in the pixel matrix. The gain
+	    operation is performed in the analogue domain before A/D
+	    conversion.
+	    </entry>
+	  </row>
+	  <row><entry></entry></row>
+	</tbody>
+      </tgroup>
+      </table>
+
+    </section>
+
 </section>
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +6 -0
index b17a7aa..f420034 100644
@@ -265,6 +265,12 @@ These controls are described in <xref
 These controls are described in <xref
 		linkend="flash-controls" />.</entry>
 	  </row>
+	  <row>
+	    <entry><constant>V4L2_CTRL_CLASS_IMAGE_SOURCE</constant></entry>
+	    <entry>0x9d0000</entry> <entry>The class containing image
+	    source controls. These controls are described in <xref
+	    linkend="image-source-controls" />.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
drivers/media/video/v4l2-ctrls.c +7 -0
index 139ba42..37249b7 100644
@@ -607,6 +607,12 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_FLASH_CHARGE:		return "Charge";
 	case V4L2_CID_FLASH_READY:		return "Ready to Strobe";
 
+	/* Image source controls */
+	case V4L2_CID_IMAGE_SOURCE_CLASS:	return "Image source controls";
+	case V4L2_CID_IMAGE_SOURCE_VBLANK:	return "Vertical blanking";
+	case V4L2_CID_IMAGE_SOURCE_HBLANK:	return "Horizontal blanking";
+	case V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN: return "Analogue gain";
+
 	default:
 		return NULL;
 	}
@@ -704,6 +710,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_CLASS:
 	case V4L2_CID_FM_TX_CLASS:
 	case V4L2_CID_FLASH_CLASS:
+	case V4L2_CID_IMAGE_SOURCE_CLASS:
 		*type = V4L2_CTRL_TYPE_CTRL_CLASS;
 		/* You can neither read not write these */
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
include/linux/videodev2.h +9 -0
index a80c03d..277aa5c 100644
@@ -1136,6 +1136,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_CAMERA 0x009a0000	/* Camera class controls */
 #define V4L2_CTRL_CLASS_FM_TX 0x009b0000	/* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c0000	/* Camera flash controls */
+#define V4L2_CTRL_CLASS_IMAGE_SOURCE 0x009d0000	/* Image source controls */
 
 #define V4L2_CTRL_ID_MASK      	  (0x0fffffff)
 #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)
@@ -1749,6 +1750,14 @@ enum v4l2_flash_strobe_source {
 #define V4L2_CID_FLASH_CHARGE			(V4L2_CID_FLASH_CLASS_BASE + 11)
 #define V4L2_CID_FLASH_READY			(V4L2_CID_FLASH_CLASS_BASE + 12)
 
+/* Image source controls */
+#define V4L2_CID_IMAGE_SOURCE_CLASS_BASE	(V4L2_CTRL_CLASS_IMAGE_SOURCE | 0x900)
+#define V4L2_CID_IMAGE_SOURCE_CLASS		(V4L2_CTRL_CLASS_IMAGE_SOURCE | 1)
+
+#define V4L2_CID_IMAGE_SOURCE_VBLANK		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 1)
+#define V4L2_CID_IMAGE_SOURCE_HBLANK		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2)
+#define V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN	(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 3)
+
 /*
  *	T U N I N G
  */
Signature · 1 line
1.7.2.5
#15 lore raw

Re: [PATCH v2 09/31] v4l: Image source control class

Hi Sakari,

Quoted 66 lines · Sakari Ailus

Add image source control class. This control class is intended to contain low level controls which deal with control of the image capture process --- the A/D converter in image sensors, for example.

---
  Documentation/DocBook/media/v4l/controls.xml       |   86 ++++++++++++++++++++
  .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml       |    6 ++
  drivers/media/video/v4l2-ctrls.c                   |    7 ++
  include/linux/videodev2.h                          |    9 ++
  4 files changed, 108 insertions(+), 0 deletions(-)
Documentation/DocBook/media/v4l/controls.xml +46 -0
index a1be378..6842e80 100644
@@ -3379,4 +3379,90 @@ interface and may change in the future.</para>
        </table>
 
      </section>
+
+<section id="image-source-controls">
+<title>Image Source Control Reference</title>
+
+<note>
+	<title>Experimental</title>
+
+	<para>This is an<link
+	linkend="experimental">experimental</link>  interface and may
+	change in the future.</para>
+</note>
+
+<para>
+	The Image Source control class is intended for low-level
+	control of image source devices such as image sensors. The
+	devices feature an analogue to digital converter and a bus
+	transmitter to transmit the image data out of the device.
+</para>
+
+<table pgwide="1" frame="none" id="image-source-control-id">
+<title>Image Source Control IDs</title>
+
+<tgroup cols="4">
+	<colspec colname="c1" colwidth="1*" />
+	<colspec colname="c2" colwidth="6*" />
+	<colspec colname="c3" colwidth="2*" />
+	<colspec colname="c4" colwidth="6*" />
+	<spanspec namest="c1" nameend="c2" spanname="id" />
+	<spanspec namest="c2" nameend="c4" spanname="descr" />
+	<thead>
+	<row>
+	<entry spanname="id" align="left">ID</entry>
+	<entry align="left">Type</entry>
+	</row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+	</row>
+	</thead>
+	<tbody valign="top">
+	<row><entry></entry></row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_CLASS</constant></entry>
+	<entry>class</entry>
+	</row>
+	<row>
+	<entry spanname="descr">The IMAGE_SOURCE class descriptor.</entry>
+	</row>
+	<row>

Documentation/DocBook/media/v4l/controls.xml interface and may change in the future.</para> · line 3437

Quoted 10 lines
Documentation/DocBook/media/v4l/controls.xml +10 -0
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_VBLANK</constant></entry>
+	<entry>integer</entry>
+	</row>
+	<row>
+	<entry spanname="descr">Vertical blanking. The idle
+	    preriod after every frame during which no image data is
+	    produced. The unit of vertical blanking is a line. Every
+	    line has length of the image width plus horizontal
+	    blanking at the pixel clock specified by struct
+	    v4l2_mbus_framefmt<xref linkend="v4l2-mbus-framefmt"

The pixel clock is no longer specified by struct v4l2_mbus_framefmt, it's now determined by V4L2_CID_IMAGE_PROC_LINK_FREQ controls, right ?

When you drop the class name from the control names, it is perhaps better to just use V4L2_CID_LINK_FREQUENCY name.

Documentation/DocBook/media/v4l/controls.xml interface and may change in the future.</para> · line 3446

Quoted 9 lines
Documentation/DocBook/media/v4l/controls.xml +9 -0
+	    />.</entry>
+	</row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_HBLANK</constant></entry>
+	<entry>integer</entry>
+	</row>
+	<row>
+	<entry spanname="descr">Horizontal blanking. The idle
+	    preriod after every line of image data during which no

s/preriod/period

Quoted 44 lines
Documentation/DocBook/media/v4l/controls.xml +21 -0
+	    image data is produced. The unit of horizontal blanking is
+	    pixels.</entry>
+	</row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN</constant></entry>
+	<entry>integer</entry>
+	</row>
+	<row>
+	<entry spanname="descr">Analogue gain is gain affecting
+	    all colour components in the pixel matrix. The gain
+	    operation is performed in the analogue domain before A/D
+	    conversion.
+	</entry>
+	</row>
+	<row><entry></entry></row>
+	</tbody>
+</tgroup>
+</table>
+
+</section>
+
  </section>
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +6 -0
index b17a7aa..f420034 100644
@@ -265,6 +265,12 @@ These controls are described in<xref
  These controls are described in<xref
  		linkend="flash-controls" />.</entry>
  	</row>
+	<row>
+	<entry><constant>V4L2_CTRL_CLASS_IMAGE_SOURCE</constant></entry>
+	<entry>0x9d0000</entry>  <entry>The class containing image
+	    source controls. These controls are described in<xref
+	    linkend="image-source-controls" />.</entry>
+	</row>
  	</tbody>
        </tgroup>
      </table>
drivers/media/video/v4l2-ctrls.c +0 -0
index 139ba42..37249b7 100644

drivers/media/video/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 614

Quoted 8 lines
drivers/media/video/v4l2-ctrls.c +5 -0
@@ -607,6 +607,12 @@ const char *v4l2_ctrl_get_name(u32 id)
  	case V4L2_CID_FLASH_CHARGE:		return "Charge";
  	case V4L2_CID_FLASH_READY:		return "Ready to Strobe";
 
+	/* Image source controls */
+	case V4L2_CID_IMAGE_SOURCE_CLASS:	return "Image source controls";
+	case V4L2_CID_IMAGE_SOURCE_VBLANK:	return "Vertical blanking";
+	case V4L2_CID_IMAGE_SOURCE_HBLANK:	return "Horizontal blanking";
+	case V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN: return "Analogue gain";

All words in control descriptions need to be capitalized. :-)

--

Regards,
Sylwester

#16 lore raw

Re: [PATCH v2 09/31] v4l: Image source control class

Hi Sylwester,

Thanks for the review!

Quoted 72 lines · Sylwester Nawrocki
Quoted 71 lines · Sakari Ailus

Add image source control class. This control class is intended to contain low level controls which deal with control of the image capture process --- the A/D converter in image sensors, for example.

---
  Documentation/DocBook/media/v4l/controls.xml       |   86 ++++++++++++++++++++
  .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml       |    6 ++
  drivers/media/video/v4l2-ctrls.c                   |    7 ++
  include/linux/videodev2.h                          |    9 ++
  4 files changed, 108 insertions(+), 0 deletions(-)
Documentation/DocBook/media/v4l/controls.xml +51 -0
index a1be378..6842e80 100644
@@ -3379,4 +3379,90 @@ interface and may change in the future.</para>
        </table>
 
      </section>
+
+<section id="image-source-controls">
+<title>Image Source Control Reference</title>
+
+<note>
+	<title>Experimental</title>
+
+	<para>This is an<link
+	linkend="experimental">experimental</link>  interface and may
+	change in the future.</para>
+</note>
+
+<para>
+	The Image Source control class is intended for low-level
+	control of image source devices such as image sensors. The
+	devices feature an analogue to digital converter and a bus
+	transmitter to transmit the image data out of the device.
+</para>
+
+<table pgwide="1" frame="none" id="image-source-control-id">
+<title>Image Source Control IDs</title>
+
+<tgroup cols="4">
+	<colspec colname="c1" colwidth="1*" />
+	<colspec colname="c2" colwidth="6*" />
+	<colspec colname="c3" colwidth="2*" />
+	<colspec colname="c4" colwidth="6*" />
+	<spanspec namest="c1" nameend="c2" spanname="id" />
+	<spanspec namest="c2" nameend="c4" spanname="descr" />
+	<thead>
+	<row>
+	<entry spanname="id" align="left">ID</entry>
+	<entry align="left">Type</entry>
+	</row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+	</row>
+	</thead>
+	<tbody valign="top">
+	<row><entry></entry></row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_CLASS</constant></entry>
+	<entry>class</entry>
+	</row>
+	<row>
+	<entry spanname="descr">The IMAGE_SOURCE class descriptor.</entry>
+	</row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_VBLANK</constant></entry>
+	<entry>integer</entry>
+	</row>
+	<row>
+	<entry spanname="descr">Vertical blanking. The idle
Quoted 8 lines

Documentation/DocBook/media/v4l/controls.xml interface and may change in the future.</para>

Quoted 5 lines
Documentation/DocBook/media/v4l/controls.xml +5 -0
+	    preriod after every frame during which no image data is
+	    produced. The unit of vertical blanking is a line. Every
+	    line has length of the image width plus horizontal
+	    blanking at the pixel clock specified by struct
+	    v4l2_mbus_framefmt<xref linkend="v4l2-mbus-framefmt"

The pixel clock is no longer specified by struct v4l2_mbus_framefmt, it's now determined by V4L2_CID_IMAGE_PROC_LINK_FREQ controls, right ?

I've had so many references to the pixel rate in the media bus frame format that it was inevitable some must have been left. :-o

The V4L2_CID_IMAGE_PROC_PIXEL_RATE control will replace this.

Quoted 2 lines

When you drop the class name from the control names, it is perhaps better to just use V4L2_CID_LINK_FREQUENCY name.

I'll do that to the next patch.set.

Quoted 11 lines

Documentation/DocBook/media/v4l/controls.xml interface and may change in the future.</para> · line 3446

Quoted 9 lines
Documentation/DocBook/media/v4l/controls.xml +9 -0
+	    />.</entry>
+	</row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_HBLANK</constant></entry>
+	<entry>integer</entry>
+	</row>
+	<row>
+	<entry spanname="descr">Horizontal blanking. The idle
+	    preriod after every line of image data during which no

s/preriod/period

Fixed.

Quoted 47 lines
Quoted 47 lines
Documentation/DocBook/media/v4l/controls.xml +21 -0
+	    image data is produced. The unit of horizontal blanking is
+	    pixels.</entry>
+	</row>
+	<row>
+	<entry spanname="id"><constant>V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN</constant></entry>
+	<entry>integer</entry>
+	</row>
+	<row>
+	<entry spanname="descr">Analogue gain is gain affecting
+	    all colour components in the pixel matrix. The gain
+	    operation is performed in the analogue domain before A/D
+	    conversion.
+	</entry>
+	</row>
+	<row><entry></entry></row>
+	</tbody>
+</tgroup>
+</table>
+
+</section>
+
  </section>
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +6 -0
index b17a7aa..f420034 100644
@@ -265,6 +265,12 @@ These controls are described in<xref
  These controls are described in<xref
  		linkend="flash-controls" />.</entry>
  	</row>
+	<row>
+	<entry><constant>V4L2_CTRL_CLASS_IMAGE_SOURCE</constant></entry>
+	<entry>0x9d0000</entry>  <entry>The class containing image
+	    source controls. These controls are described in<xref
+	    linkend="image-source-controls" />.</entry>
+	</row>
  	</tbody>
        </tgroup>
      </table>
drivers/media/video/v4l2-ctrls.c +0 -0
index 139ba42..37249b7 100644
@@ -607,6 +607,12 @@ const char *v4l2_ctrl_get_name(u32 id)
  	case V4L2_CID_FLASH_CHARGE:		return "Charge";
  	case V4L2_CID_FLASH_READY:		return "Ready to Strobe";
 
Quoted 7 lines

drivers/media/video/v4l2-ctrls.c const char *v4l2_ctrl_get_name(u32 id) · line 614

Quoted 5 lines
drivers/media/video/v4l2-ctrls.c +5 -0
+	/* Image source controls */
+	case V4L2_CID_IMAGE_SOURCE_CLASS:	return "Image source controls";
+	case V4L2_CID_IMAGE_SOURCE_VBLANK:	return "Vertical blanking";
+	case V4L2_CID_IMAGE_SOURCE_HBLANK:	return "Horizontal blanking";
+	case V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN: return "Analogue gain";

All words in control descriptions need to be capitalized. :-)

Fixed.

Kind regards,

Signature · 2 lines
Sakari Ailus
[email protected]
#17 lore raw

PATCH v2 10/31 v4l: Image processing control class

In reply to Sakari Ailus

Add control class for image processing controls. The control class deals with controls processing image, for example digital gain or noise filtering, which can be present in any part of the pipeline.

---
 Documentation/DocBook/media/v4l/controls.xml       |   82 ++++++++++++++++++++
 .../DocBook/media/v4l/vidioc-g-ext-ctrls.xml       |    6 ++
 drivers/media/video/v4l2-ctrls.c                   |   13 +++
 include/linux/videodev2.h                          |    8 ++
 4 files changed, 109 insertions(+), 0 deletions(-)
Documentation/DocBook/media/v4l/controls.xml +82 -0
index 6842e80..b79a744 100644
@@ -3465,4 +3465,86 @@ interface and may change in the future.</para>
 
     </section>
 
+    <section id="image-process-controls">
+      <title>Image Process Control Reference</title>
+
+      <note>
+	<title>Experimental</title>
+
+	<para>This is an <link
+	linkend="experimental">experimental</link> interface and may
+	change in the future.</para>
+      </note>
+
+      <para>
+	The Image Source control class is intended for low-level control of
+	image processing functions. Unlike
+	<constant>V4L2_CID_IMAGE_SOURCE_CLASS</constant>, the controls in
+	this class affect processing the image, and do not control capturing
+	of it.
+      </para>
+
+      <table pgwide="1" frame="none" id="image-process-control-id">
+      <title>Image Source Control IDs</title>
+
+      <tgroup cols="4">
+	<colspec colname="c1" colwidth="1*" />
+	<colspec colname="c2" colwidth="6*" />
+	<colspec colname="c3" colwidth="2*" />
+	<colspec colname="c4" colwidth="6*" />
+	<spanspec namest="c1" nameend="c2" spanname="id" />
+	<spanspec namest="c2" nameend="c4" spanname="descr" />
+	<thead>
+	  <row>
+	    <entry spanname="id" align="left">ID</entry>
+	    <entry align="left">Type</entry>
+	  </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+	  </row>
+	</thead>
+	<tbody valign="top">
+	  <row><entry></entry></row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_PROC_CLASS</constant></entry>
+	    <entry>class</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">The IMAGE_PROC class descriptor.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_PROC_LINK_FREQ</constant></entry>
+	    <entry>integer menu</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Data bus frequency. Together with the
+	    media bus pixel code, bus type (clock cycles per sample), the
+	    data bus frequency defines the pixel rate
+	    (<constant>V4L2_CID_IMAGE_PROC_PIXEL_RATE</constant>) in the
+	    pixel array (or possibly elsewhere, if the device is not an
+	    image sensor). The frame rate can be calculated from the pixel
+	    clock, image width and height and horizontal and vertical
+	    blanking. While the pixel rate control may be defined elsewhere
+	    than in the subdev containing the pixel array, the frame rate
+	    cannot be obtained from that information. This is because only
+	    on the pixel array it can be assumed that the vertical and
+	    horizontal blanking information is exact: no other blanking is
+	    allowed in the pixel array. The selection of frame rate is
+	    performed by selecting the desired horizontal and vertical
+	    blanking. The unit of this control is Hz. </entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_IMAGE_PROC_PIXEL_RATE</constant></entry>
+	    <entry>64-bit integer</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Pixel rate in the source pads of
+	    the subdev. This control is read-only and its unit is
+	    pixels / second.
+	    </entry>
+	  </row>
+	  <row><entry></entry></row>
+	</tbody>
+      </tgroup>
+      </table>
+
+    </section>
 </section>
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +6 -0
index f420034..f41a2f5 100644
@@ -271,6 +271,12 @@ These controls are described in <xref
 	    source controls. These controls are described in <xref
 	    linkend="image-source-controls" />.</entry>
 	  </row>
+	  <row>
+	    <entry><constant>V4L2_CTRL_CLASS_IMAGE_PROC</constant></entry>
+	    <entry>0x9e0000</entry> <entry>The class containing image
+	    processing controls. These controls are described in <xref
+	    linkend="image-process-controls" />.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
drivers/media/video/v4l2-ctrls.c +13 -0
index 37249b7..6860fa0 100644
@@ -613,6 +613,11 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_IMAGE_SOURCE_HBLANK:	return "Horizontal blanking";
 	case V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN: return "Analogue gain";
 
+	/* Image processing controls */
+	case V4L2_CID_IMAGE_PROC_CLASS:		return "Image processing controls";
+	case V4L2_CID_IMAGE_PROC_LINK_FREQ:	return "Link frequency";
+	case V4L2_CID_IMAGE_PROC_PIXEL_RATE:	return "Pixel rate";
+
 	default:
 		return NULL;
 	}
@@ -701,6 +706,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
 		*type = V4L2_CTRL_TYPE_MENU;
 		break;
+	case V4L2_CID_IMAGE_PROC_LINK_FREQ:
+		*type = V4L2_CTRL_TYPE_INTEGER_MENU;
+		break;
 	case V4L2_CID_RDS_TX_PS_NAME:
 	case V4L2_CID_RDS_TX_RADIO_TEXT:
 		*type = V4L2_CTRL_TYPE_STRING;
@@ -711,6 +719,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_FM_TX_CLASS:
 	case V4L2_CID_FLASH_CLASS:
 	case V4L2_CID_IMAGE_SOURCE_CLASS:
+	case V4L2_CID_IMAGE_PROC_CLASS:
 		*type = V4L2_CTRL_TYPE_CTRL_CLASS;
 		/* You can neither read not write these */
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
@@ -731,6 +740,10 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 		*type = V4L2_CTRL_TYPE_INTEGER;
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
 		break;
+	case V4L2_CID_IMAGE_PROC_PIXEL_RATE:
+		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
+		*type = V4L2_CTRL_TYPE_INTEGER64;
+		break;
 	default:
 		*type = V4L2_CTRL_TYPE_INTEGER;
 		break;
include/linux/videodev2.h +8 -0
index 277aa5c..ed56c5c 100644
@@ -1137,6 +1137,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_FM_TX 0x009b0000	/* FM Modulator control class */
 #define V4L2_CTRL_CLASS_FLASH 0x009c0000	/* Camera flash controls */
 #define V4L2_CTRL_CLASS_IMAGE_SOURCE 0x009d0000	/* Image source controls */
+#define V4L2_CTRL_CLASS_IMAGE_PROC 0x009e0000	/* Image processing controls */
 
 #define V4L2_CTRL_ID_MASK      	  (0x0fffffff)
 #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)
@@ -1758,6 +1759,13 @@ enum v4l2_flash_strobe_source {
 #define V4L2_CID_IMAGE_SOURCE_HBLANK		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 2)
 #define V4L2_CID_IMAGE_SOURCE_ANALOGUE_GAIN	(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 3)
 
+/* Image processing controls */
+#define V4L2_CID_IMAGE_PROC_CLASS_BASE		(V4L2_CTRL_CLASS_IMAGE_PROC | 0x900)
+#define V4L2_CID_IMAGE_PROC_CLASS		(V4L2_CTRL_CLASS_IMAGE_PROC | 1)
+
+#define V4L2_CID_IMAGE_PROC_LINK_FREQ		(V4L2_CID_IMAGE_PROC_CLASS_BASE + 1)
+#define V4L2_CID_IMAGE_PROC_PIXEL_RATE		(V4L2_CID_IMAGE_PROC_CLASS_BASE + 2)
+
 /*
  *	T U N I N G
  */
Signature · 1 line
1.7.2.5
#18 lore raw

PATCH v2 11/31 v4l: Document raw bayer 4CC codes

In reply to Sakari Ailus

Document guidelines how 4CC codes should be named. Only raw bayer is included currently. Other formats should be documented later on.

---
 Documentation/video4linux/4CCs.txt |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/4CCs.txt
Documentation/video4linux/4CCs.txt new file +32 -0
new file mode 100644
index 0000000..bb4a97d
@@ -0,0 +1,32 @@
+Guidelines for Linux4Linux pixel format 4CCs
+============================================
+
+Guidelines for Video4Linux 4CC codes defined using v4l2_fourcc() are
+specified in this document. First of the characters defines the nature of
+the pixel format, compression and colour space. The interpretation of the
+other three characters depends on the first one.
+
+Existing 4CCs may not obey these guidelines.
+
+Formats
+=======
+
+Raw bayer
+---------
+
+The following first charcters are used by raw bayer formats:
+
+	B: raw bayer, uncompressed
+	b: raw bayer, DPCM compressed
+	a: A-law compressed
+	u: u-law compressed
+
+2nd character: pixel order
+	B: BGGR
+	G: GBRG
+	g: GRBG
+	R: RGGB
+
+3rd character: uncompressed bits-per-pixel 0--9, A--
+
+4th character: compressed bits-per-pixel 0--9, A--
Signature · 1 line
1.7.2.5
#19 lore raw

Re: [PATCH v2 11/31] v4l: Document raw bayer 4CC codes

Sakari,

Thanks for the patch.

Quoted 23 lines · Sakari Ailus

Document guidelines how 4CC codes should be named. Only raw bayer is included currently. Other formats should be documented later on.

---
 Documentation/video4linux/4CCs.txt |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/video4linux/4CCs.txt
Documentation/video4linux/4CCs.txt new file +7 -0
new file mode 100644
index 0000000..bb4a97d
@@ -0,0 +1,32 @@
+Guidelines for Linux4Linux pixel format 4CCs
+============================================
+
+Guidelines for Video4Linux 4CC codes defined using v4l2_fourcc() are
+specified in this document. First of the characters defines the nature of
+the pixel format, compression and colour space. The interpretation of the
+other three characters depends on the first one.

Documentation/video4linux/4CCs.txt line 17

Quoted 10 lines
Documentation/video4linux/4CCs.txt new file +10 -0
+
+Existing 4CCs may not obey these guidelines.
+
+Formats
+=======
+
+Raw bayer
+---------
+
+The following first charcters are used by raw bayer formats:

A small spelling mistake 'charcters', just pointing out since its a
documentation file :-)

Regards,
--Prabhakar Lad

Quoted 23 lines
Documentation/video4linux/4CCs.txt new file +15 -1
+
+	B: raw bayer, uncompressed
+	b: raw bayer, DPCM compressed
+	a: A-law compressed
+	u: u-law compressed
+
+2nd character: pixel order
+	B: BGGR
+	G: GBRG
+	g: GRBG
+	R: RGGB
+
+3rd character: uncompressed bits-per-pixel 0--9, A--
+
+4th character: compressed bits-per-pixel 0--9, A--
--

1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

Re: [PATCH v2 11/31] v4l: Document raw bayer 4CC codes

Hi Prabhakar,

Quoted 6 lines · Prabhakar Lad
Quoted 1 line

+The following first charcters are used by raw bayer formats:

A small spelling mistake 'charcters', just pointing out since its a
documentation file :-)

Regards,
--Prabhakar Lad

Thanks; fixed for the next version of the patchset.

Cheers,

Signature · 2 lines
Sakari Ailus
[email protected]
#21 lore raw

PATCH v2 12/31 v4l: Add DPCM compressed formats

In reply to Sakari Ailus

Add three other colour orders for 10-bit to 8-bit DPCM compressed formats.

---
 Documentation/DocBook/media/v4l/pixfmt-srggb10.xml |    2 +-
 .../DocBook/media/v4l/pixfmt-srggb10dpcm8.xml      |   29 ++++++++++++++++++++
 Documentation/DocBook/media/v4l/pixfmt.xml         |    1 +
 include/linux/videodev2.h                          |    3 ++
 4 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/pixfmt-srggb10dpcm8.xml
Documentation/DocBook/media/v4l/pixfmt-srggb10.xml +1 -1
index 7b27409..c1c62a9 100644
@@ -1,4 +1,4 @@
-    <refentry>
+    <refentry id="pixfmt-srggb10">
       <refmeta>
 	<refentrytitle>V4L2_PIX_FMT_SRGGB10 ('RG10'),
 	 V4L2_PIX_FMT_SGRBG10 ('BA10'),
Documentation/DocBook/media/v4l/pixfmt-srggb10dpcm8.xml new file +29 -0
new file mode 100644
index 0000000..40455f1
@@ -0,0 +1,29 @@
+    <refentry>
+      <refmeta>
+	<refentrytitle>
+	 V4L2_PIX_FMT_SRGGB10DPCM8 ('bBA8'),
+	 V4L2_PIX_FMT_SGBRG10DPCM8 ('bGA8'),
+	 V4L2_PIX_FMT_SGRBG10DPCM8 ('BD10'),
+	 V4L2_PIX_FMT_SBGGR10DPCM8 ('bRA8'),
+	 </refentrytitle>
+	&manvol;
+      </refmeta>
+      <refnamediv>
+	<refname id="V4L2-PIX-FMT-SRGGB10DPCM8"><constant>V4L2_PIX_FMT_SRGGB10DPCM8</constant></refname>
+	<refname id="V4L2-PIX-FMT-SGRBG10DPCM8"><constant>V4L2_PIX_FMT_SGRBG10DPCM8</constant></refname>
+	<refname id="V4L2-PIX-FMT-SGBRG10DPCM8"><constant>V4L2_PIX_FMT_SGBRG10DPCM8</constant></refname>
+	<refname id="V4L2-PIX-FMT-SBGGR10DPCM8"><constant>V4L2_PIX_FMT_SBGGR10DPCM8</constant></refname>
+	<refpurpose>10-bit Bayer formats compressed to 8 bits</refpurpose>
+      </refnamediv>
+      <refsect1>
+	<title>Description</title>
+
+	<para>The following four pixel formats are raw sRGB / Bayer formats
+	with 10 bits per colour compressed to 8 bits each, using DPCM
+	compression. DPCM, differential pulse-code modulation, is lossy.
+	Each colour component consumes 8 bits of memory. In other respects
+	this format is similar to <xref
+	linkend="pixfmt-srggb10">.</xref></para>
+
+      </refsect1>
+    </refentry>
Documentation/DocBook/media/v4l/pixfmt.xml +1 -0
index 31eaae2..74d4fcd 100644
@@ -673,6 +673,7 @@ access the palette, this must be done with ioctls of the Linux framebuffer API.<
     &sub-srggb8;
     &sub-sbggr16;
     &sub-srggb10;
+    &sub-srggb10dpcm8;
     &sub-srggb12;
   </section>
 
include/linux/videodev2.h +3 -0
index ed56c5c..dbade0e 100644
@@ -378,7 +378,10 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12  GRGR.. BGBG.. */
 #define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12  RGRG.. GBGB.. */
 	/* 10bit raw bayer DPCM compressed to 8 bits */
+#define V4L2_PIX_FMT_SBGGR10DPCM8 v4l2_fourcc('b', 'B', 'A', '8')
+#define V4L2_PIX_FMT_SGBRG10DPCM8 v4l2_fourcc('b', 'G', 'A', '8')
 #define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
+#define V4L2_PIX_FMT_SRGGB10DPCM8 v4l2_fourcc('b', 'R', 'A', '8')
 	/*
 	 * 10bit raw bayer, expanded to 16 bits
 	 * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
Signature · 1 line
1.7.2.5
#22 lore raw

PATCH v2 13/31 media: Add link_validate() op to check links to the sink pad

In reply to Sakari Ailus

The purpose of the link_validate() op is to allow an entity driver to ensure that the properties of the pads at the both ends of the link are suitable for starting the pipeline. link_validate is called on sink pads on active links which belong to the active part of the graph.

---
 Documentation/media-framework.txt |   19 +++++++++++++
 drivers/media/media-entity.c      |   53 +++++++++++++++++++++++++++++++++++-
 include/media/media-entity.h      |    5 ++-
 3 files changed, 73 insertions(+), 4 deletions(-)
Documentation/media-framework.txt +19 -0
index 3a0f879..0e90169 100644
@@ -335,6 +335,9 @@ the media_entity pipe field.
 Calls to media_entity_pipeline_start() can be nested. The pipeline pointer must
 be identical for all nested calls to the function.
 
+media_entity_pipeline_start() may return an error. In that case, it will
+clean up any the changes it did by itself.
+
 When stopping the stream, drivers must notify the entities with
 
 	media_entity_pipeline_stop(struct media_entity *entity);
@@ -351,3 +354,19 @@ If other operations need to be disallowed on streaming entities (such as
 changing entities configuration parameters) drivers can explicitly check the
 media_entity stream_count field to find out if an entity is streaming. This
 operation must be done with the media_device graph_mutex held.
+
+
+Link validation
+---------------
+
+Link validation is performed from media_entity_pipeline_start() for any
+entity which has sink pads in the pipeline. The
+media_entity::link_validate() callback is used for that purpose. In
+link_validate() callback, entity driver should check that the properties of
+the source pad of the connected entity and its own sink pad match. It is up
+to the type of the entity (and in the end, the properties of the hardware)
+what matching actually means.
+
+Subsystems should facilitate link validation by providing subsystem specific
+helper functions to provide easy access for commonly needed information, and
+in the end provide a way to use driver-specific callbacks.
drivers/media/media-entity.c +51 -2

74 lines not on this page · raw message

include/media/media-entity.h +3 -2
index 29e7bba..0c16f51 100644
@@ -46,6 +46,7 @@ struct media_entity_operations {
 	int (*link_setup)(struct media_entity *entity,
 			  const struct media_pad *local,
 			  const struct media_pad *remote, u32 flags);
+	int (*link_validate)(struct media_link *link);
 };
 
 struct media_entity {
@@ -140,8 +141,8 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph,
 		struct media_entity *entity);
 struct media_entity *
 media_entity_graph_walk_next(struct media_entity_graph *graph);
-void media_entity_pipeline_start(struct media_entity *entity,
-		struct media_pipeline *pipe);
+__must_check int media_entity_pipeline_start(struct media_entity *entity,
+					     struct media_pipeline *pipe);
 void media_entity_pipeline_stop(struct media_entity *entity);
 
 #define media_entity_call(entity, operation, args...)			\
Signature · 1 line
1.7.2.5
#23 lore raw

PATCH v2 14/31 v4l: Improve sub-device documentation for pad ops

In reply to Sakari Ailus

Document that format related configuration is done through pad ops in case the driver does use the media framework.

---
 Documentation/video4linux/v4l2-framework.txt |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Documentation/video4linux/v4l2-framework.txt +9 -0
index 659b2ba..f06c563 100644
@@ -262,11 +262,16 @@ struct v4l2_subdev_video_ops {
 	...
 };
 
+struct v4l2_subdev_pad_ops {
+	...
+};
+
 struct v4l2_subdev_ops {
 	const struct v4l2_subdev_core_ops  *core;
 	const struct v4l2_subdev_tuner_ops *tuner;
 	const struct v4l2_subdev_audio_ops *audio;
 	const struct v4l2_subdev_video_ops *video;
+	const struct v4l2_subdev_pad_ops *video;
 };
 
 The core ops are common to all subdevs, the other categories are implemented
@@ -303,6 +308,10 @@ Don't forget to cleanup the media entity before the sub-device is destroyed:
 
 	media_entity_cleanup(&sd->entity);
 
+If the subdev driver intends to process video and integrate with the media
+framework, it must implement format related functionality using
+v4l2_subdev_pad_ops instead of v4l2_subdev_video_ops.
+
 A device (bridge) driver needs to register the v4l2_subdev with the
 v4l2_device:
 
Signature · 1 line
1.7.2.5
#24 lore raw

PATCH v2 15/31 v4l: Implement v4l2_subdev_link_validate()

In reply to Sakari Ailus

v4l2_subdev_link_validate() is the default op for validating a link. In V4L2 subdev context, it is used to call a pad op which performs the proper link check without much extra work.

---
 Documentation/video4linux/v4l2-framework.txt |   12 +++++
 drivers/media/video/v4l2-subdev.c            |   69 ++++++++++++++++++++++++++
 include/media/v4l2-subdev.h                  |   10 ++++
 3 files changed, 91 insertions(+), 0 deletions(-)
Documentation/video4linux/v4l2-framework.txt +12 -0
index f06c563..9d341bc 100644
@@ -312,6 +312,18 @@ If the subdev driver intends to process video and integrate with the media
 framework, it must implement format related functionality using
 v4l2_subdev_pad_ops instead of v4l2_subdev_video_ops.
 
+In that case, the subdev driver may set the link_validate field to provide
+its own link validation function. The link validation function is called for
+every link in the pipeline where both of the ends of the links are V4L2
+sub-devices. The driver is still responsible for validating the correctness
+of the format configuration between sub-devices and video nodes.
+
+If link_validate op is not set, the default function
+v4l2_subdev_link_validate_default() is used instead. This function ensures
+that width, height and the media bus pixel code are equal on both source and
+sink of the link. Subdev drivers are also free to use this function to
+perform the checks mentioned above in addition to their own checks.
+
 A device (bridge) driver needs to register the v4l2_subdev with the
 v4l2_device:
 
drivers/media/video/v4l2-subdev.c +69 -0

75 lines not on this page · raw message

include/media/v4l2-subdev.h +10 -0
index feab950..436e6f4 100644
@@ -470,6 +470,11 @@ struct v4l2_subdev_pad_ops {
 			     struct v4l2_subdev_selection *sel);
 	int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 			     struct v4l2_subdev_selection *sel);
+#ifdef CONFIG_MEDIA_CONTROLLER
+	int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
+			     struct v4l2_subdev_format *source_fmt,
+			     struct v4l2_subdev_format *sink_fmt);
+#endif /* CONFIG_MEDIA_CONTROLLER */
 };
 
 struct v4l2_subdev_ops {
@@ -606,6 +611,11 @@ static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
 	return sd->host_priv;
 }
 
+int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
+				      struct media_link *link,
+				      struct v4l2_subdev_format *source_fmt,
+				      struct v4l2_subdev_format *sink_fmt);
+int v4l2_subdev_link_validate(struct media_link *link);
 void v4l2_subdev_init(struct v4l2_subdev *sd,
 		      const struct v4l2_subdev_ops *ops);
 
Signature · 1 line
1.7.2.5
#25 lore raw

PATCH v2 16/31 v4l: Allow changing control handler lock

In reply to Sakari Ailus

Allow choosing the lock used by the control handler. This may be handy sometimes when a driver providing multiple subdevs does not want to use several locks to serialise its functions.

---
 drivers/media/video/adp1653.c    |    8 +++---
 drivers/media/video/v4l2-ctrls.c |   39 +++++++++++++++++++------------------
 drivers/media/video/vivi.c       |    4 +-
 include/media/v4l2-ctrls.h       |    9 +++++--
 4 files changed, 32 insertions(+), 28 deletions(-)
drivers/media/video/adp1653.c +4 -4
index 12eedf4..becaba4 100644
@@ -283,19 +283,19 @@ adp1653_init_device(struct adp1653_flash *flash)
 		return -EIO;
 	}
 
-	mutex_lock(&flash->ctrls.lock);
+	mutex_lock(flash->ctrls.lock);
 	/* Reset faults before reading new ones. */
 	flash->fault = 0;
 	rval = adp1653_get_fault(flash);
-	mutex_unlock(&flash->ctrls.lock);
+	mutex_unlock(flash->ctrls.lock);
 	if (rval > 0) {
 		dev_err(&client->dev, "faults detected: 0x%1.1x\n", rval);
 		return -EIO;
 	}
 
-	mutex_lock(&flash->ctrls.lock);
+	mutex_lock(flash->ctrls.lock);
 	rval = adp1653_update_hw(flash);
-	mutex_unlock(&flash->ctrls.lock);
+	mutex_unlock(flash->ctrls.lock);
 	if (rval) {
 		dev_err(&client->dev,
 			"adp1653_update_hw failed at %s\n", __func__);
drivers/media/video/v4l2-ctrls.c +20 -19
index 6860fa0..7e6a891 100644
@@ -1130,7 +1130,8 @@ static inline int handler_set_err(struct v4l2_ctrl_handler *hdl, int err)
 int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl,
 			   unsigned nr_of_controls_hint)
 {
-	mutex_init(&hdl->lock);
+	hdl->lock = &hdl->_lock;
+	mutex_init(hdl->lock);
 	INIT_LIST_HEAD(&hdl->ctrls);
 	INIT_LIST_HEAD(&hdl->ctrl_refs);
 	hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8;
@@ -1151,7 +1152,7 @@ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
 	if (hdl == NULL || hdl->buckets == NULL)
 		return;
 
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 	/* Free all nodes */
 	list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) {
 		list_del(&ref->node);
@@ -1168,7 +1169,7 @@ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl)
 	hdl->buckets = NULL;
 	hdl->cached = NULL;
 	hdl->error = 0;
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 }
 EXPORT_SYMBOL(v4l2_ctrl_handler_free);
 
@@ -1233,9 +1234,9 @@ static struct v4l2_ctrl_ref *find_ref_lock(
 	struct v4l2_ctrl_ref *ref = NULL;
 
 	if (hdl) {
-		mutex_lock(&hdl->lock);
+		mutex_lock(hdl->lock);
 		ref = find_ref(hdl, id);
-		mutex_unlock(&hdl->lock);
+		mutex_unlock(hdl->lock);
 	}
 	return ref;
 }
@@ -1282,7 +1283,7 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl,
 
 	INIT_LIST_HEAD(&new_ref->node);
 
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 
 	/* Add immediately at the end of the list if the list is empty, or if
 	   the last element in the list has a lower ID.
@@ -1312,7 +1313,7 @@ insert_in_hash:
 	hdl->buckets[bucket] = new_ref;
 
 unlock:
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 	return 0;
 }
 
@@ -1398,9 +1399,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 		kfree(ctrl);
 		return NULL;
 	}
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 	list_add_tail(&ctrl->node, &hdl->ctrls);
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 	return ctrl;
 }
 
@@ -1517,7 +1518,7 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
 		return 0;
 	if (hdl->error)
 		return hdl->error;
-	mutex_lock(&add->lock);
+	mutex_lock(add->lock);
 	list_for_each_entry(ctrl, &add->ctrls, node) {
 		/* Skip handler-private controls. */
 		if (ctrl->is_private)
@@ -1529,7 +1530,7 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
 		if (ret)
 			break;
 	}
-	mutex_unlock(&add->lock);
+	mutex_unlock(add->lock);
 	return ret;
 }
 EXPORT_SYMBOL(v4l2_ctrl_add_handler);
@@ -1693,11 +1694,11 @@ void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
 	len = strlen(prefix);
 	if (len && prefix[len - 1] != ' ')
 		colon = ": ";
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 	list_for_each_entry(ctrl, &hdl->ctrls, node)
 		if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED))
 			log_ctrl(ctrl, prefix, colon);
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 }
 EXPORT_SYMBOL(v4l2_ctrl_handler_log_status);
 
@@ -1709,7 +1710,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
 
 	if (hdl == NULL)
 		return 0;
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 	list_for_each_entry(ctrl, &hdl->ctrls, node)
 		ctrl->done = false;
 
@@ -1734,7 +1735,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
 		if (ret)
 			break;
 	}
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 	return ret;
 }
 EXPORT_SYMBOL(v4l2_ctrl_handler_setup);
@@ -1749,7 +1750,7 @@ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc)
 	if (hdl == NULL)
 		return -EINVAL;
 
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 
 	/* Try to find it */
 	ref = find_ref(hdl, id);
@@ -1774,7 +1775,7 @@ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc)
 					break;
 		}
 	}
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 	if (!ref)
 		return -EINVAL;
 
@@ -1951,7 +1952,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
 	   belong to the same cluster. */
 
 	/* This has to be done with the handler lock taken. */
-	mutex_lock(&hdl->lock);
+	mutex_lock(hdl->lock);
 
 	/* First zero the helper field in the master control references */
 	for (i = 0; i < cs->count; i++)
@@ -1973,7 +1974,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
 		/* Point the mref helper to the current helper struct. */
 		mref->helper = h;
 	}
-	mutex_unlock(&hdl->lock);
+	mutex_unlock(hdl->lock);
 	return 0;
 }
 
drivers/media/video/vivi.c +2 -2
index b58a2d8..a3f6537 100644
@@ -485,7 +485,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
 	gen_text(dev, vbuf, line++ * 16, 16, str);
 
 	gain = v4l2_ctrl_g_ctrl(dev->gain);
-	mutex_lock(&dev->ctrl_handler.lock);
+	mutex_lock(dev->ctrl_handler.lock);
 	snprintf(str, sizeof(str), " brightness %3d, contrast %3d, saturation %3d, hue %d ",
 			dev->brightness->cur.val,
 			dev->contrast->cur.val,
@@ -508,7 +508,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
 			dev->int_menu->qmenu_int[dev->int_menu->cur.val],
 			dev->int_menu->cur.val);
 	gen_text(dev, vbuf, line++ * 16, 16, str);
-	mutex_unlock(&dev->ctrl_handler.lock);
+	mutex_unlock(dev->ctrl_handler.lock);
 	gen_text(dev, vbuf, line++ * 16, 16, str);
 	if (dev->button_pressed) {
 		dev->button_pressed--;
include/media/v4l2-ctrls.h +6 -3
index f7819e7..9cb55fe 100644
@@ -167,7 +167,9 @@ struct v4l2_ctrl_ref {
 /** struct v4l2_ctrl_handler - The control handler keeps track of all the
   * controls: both the controls owned by the handler and those inherited
   * from other handlers.
+  * @_lock:	Default for "lock".
   * @lock:	Lock to control access to this handler and its controls.
+  *		May be replaced by the user right after init.
   * @ctrls:	The list of controls owned by this handler.
   * @ctrl_refs:	The list of control references.
   * @cached:	The last found control reference. It is common that the same
@@ -178,7 +180,8 @@ struct v4l2_ctrl_ref {
   * @error:	The error code of the first failed control addition.
   */
 struct v4l2_ctrl_handler {
-	struct mutex lock;
+	struct mutex _lock;
+	struct mutex *lock;
 	struct list_head ctrls;
 	struct list_head ctrl_refs;
 	struct v4l2_ctrl_ref *cached;
@@ -455,7 +458,7 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
   */
 static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
 {
-	mutex_lock(&ctrl->handler->lock);
+	mutex_lock(ctrl->handler->lock);
 }
 
 /** v4l2_ctrl_lock() - Helper function to unlock the handler
@@ -464,7 +467,7 @@ static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
   */
 static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
 {
-	mutex_unlock(&ctrl->handler->lock);
+	mutex_unlock(ctrl->handler->lock);
 }
 
 /** v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver.
Signature · 1 line
1.7.2.5
#26 lore raw

PATCH v2 17/31 omap3isp: Support additional in-memory compressed bayer formats

In reply to Sakari Ailus

This also prevents accessing NULL pointer in csi2_try_format().

---
 drivers/media/video/omap3isp/ispvideo.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/media/video/omap3isp/ispvideo.c +13 -0
index b020700..c191f13 100644
@@ -46,6 +46,10 @@
  * Helper functions
  */
 
+/*
+ * NOTE: When adding new media bus codes, always remember to add
+ * corresponding in-memory formats to the table below!!!
+ */
 static struct isp_format_info formats[] = {
 	{ V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
 	  V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
@@ -68,9 +72,18 @@ static struct isp_format_info formats[] = {
 	{ V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
 	  V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
 	  V4L2_PIX_FMT_SRGGB8, 8, },
+	{ V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8,
+	  V4L2_MBUS_FMT_SBGGR10_1X10, 0,
+	  V4L2_PIX_FMT_SBGGR10DPCM8, 8, },
+	{ V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8,
+	  V4L2_MBUS_FMT_SGBRG10_1X10, 0,
+	  V4L2_PIX_FMT_SGBRG10DPCM8, 8, },
 	{ V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
 	  V4L2_MBUS_FMT_SGRBG10_1X10, 0,
 	  V4L2_PIX_FMT_SGRBG10DPCM8, 8, },
+	{ V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8,
+	  V4L2_MBUS_FMT_SRGGB10_1X10, 0,
+	  V4L2_PIX_FMT_SRGGB10DPCM8, 8, },
 	{ V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10,
 	  V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR8_1X8,
 	  V4L2_PIX_FMT_SBGGR10, 10, },
Signature · 1 line
1.7.2.5
#27 lore raw

PATCH v2 18/31 omap3isp: Move definitions required by board code under include/media.

In reply to Sakari Ailus

XCLK definitions are often required by the board code. Move them to public include file.

---
 drivers/media/video/omap3isp/isp.h |    4 ----
 include/media/omap3isp.h           |    4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/video/omap3isp/isp.h +0 -4
index d96603e..2e78041 100644
@@ -237,10 +237,6 @@ void omap3isp_configure_bridge(struct isp_device *isp,
 			       const struct isp_parallel_platform_data *pdata,
 			       unsigned int shift);
 
-#define ISP_XCLK_NONE			0
-#define ISP_XCLK_A			1
-#define ISP_XCLK_B			2
-
 struct isp_device *omap3isp_get(struct isp_device *isp);
 void omap3isp_put(struct isp_device *isp);
 
include/media/omap3isp.h +4 -0
index 042849a..3f4928d 100644
@@ -29,6 +29,10 @@
 struct i2c_board_info;
 struct isp_device;
 
+#define ISP_XCLK_NONE			0
+#define ISP_XCLK_A			1
+#define ISP_XCLK_B			2
+
 enum isp_interface_type {
 	ISP_INTERFACE_PARALLEL,
 	ISP_INTERFACE_CSI2A_PHY2,
Signature · 1 line
1.7.2.5
#28 lore raw

PATCH v2 19/31 omap3: add definition for CONTROL_CAMERA_PHY_CTRL

In reply to Sakari Ailus

This register is available only in OMAP3630.

The original patch was submitted by Vimarsh Zutshi.

---
 arch/arm/mach-omap2/control.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/control.h +1 -0
index 0ba68d3..f3acf09 100644
@@ -183,6 +183,7 @@
 #define OMAP3630_CONTROL_FUSE_OPP120_VDD1       (OMAP2_CONTROL_GENERAL + 0x0120)
 #define OMAP3630_CONTROL_FUSE_OPP50_VDD2        (OMAP2_CONTROL_GENERAL + 0x0128)
 #define OMAP3630_CONTROL_FUSE_OPP100_VDD2       (OMAP2_CONTROL_GENERAL + 0x012C)
+#define OMAP3630_CONTROL_CAMERA_PHY_CTRL	(OMAP2_CONTROL_GENERAL + 0x02f0)
 
 /* OMAP44xx control efuse offsets */
 #define OMAP44XX_CONTROL_FUSE_IVA_OPP50		0x22C
Signature · 1 line
1.7.2.5
#29 lore raw

PATCH v2 20/31 omap3isp: Assume media_entity_pipeline_start may fail

In reply to Sakari Ailus

Since media_entity_pipeline_start() now does link validation, it may actually fail. Perform the error handling.

---
 drivers/media/video/omap3isp/ispvideo.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/media/video/omap3isp/ispvideo.c +12 -8
index c191f13..17522db 100644
@@ -993,14 +993,16 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 	 */
 	pipe = video->video.entity.pipe
 	     ? to_isp_pipeline(&video->video.entity) : &video->pipe;
-	media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
+	ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
+	if (ret < 0)
+		goto err_media_entity_pipeline_start;
 
 	/* Verify that the currently configured format matches the output of
 	 * the connected subdev.
 	 */
 	ret = isp_video_check_format(video, vfh);
 	if (ret < 0)
-		goto error;
+		goto err_isp_video_check_format;
 
 	video->bpl_padding = ret;
 	video->bpl_value = vfh->format.fmt.pix.bytesperline;
@@ -1017,7 +1019,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 	} else {
 		if (far_end == NULL) {
 			ret = -EPIPE;
-			goto error;
+			goto err_isp_video_check_format;
 		}
 
 		state = ISP_PIPELINE_STREAM_INPUT | ISP_PIPELINE_IDLE_INPUT;
@@ -1032,7 +1034,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 	/* Validate the pipeline and update its state. */
 	ret = isp_video_validate_pipeline(pipe);
 	if (ret < 0)
-		goto error;
+		goto err_isp_video_check_format;
 
 	pipe->error = false;
 
@@ -1054,7 +1056,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 
 	ret = omap3isp_video_queue_streamon(&vfh->queue);
 	if (ret < 0)
-		goto error;
+		goto err_isp_video_check_format;
 
 	/* In sensor-to-memory mode, the stream can be started synchronously
 	 * to the stream on command. In memory-to-memory mode, it will be
@@ -1064,19 +1066,21 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 		ret = omap3isp_pipeline_set_stream(pipe,
 					      ISP_PIPELINE_STREAM_CONTINUOUS);
 		if (ret < 0)
-			goto error;
+			goto err_omap3isp_set_stream;
 		spin_lock_irqsave(&video->queue->irqlock, flags);
 		if (list_empty(&video->dmaqueue))
 			video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
 		spin_unlock_irqrestore(&video->queue->irqlock, flags);
 	}
 
-error:
 	if (ret < 0) {
+err_omap3isp_set_stream:
 		omap3isp_video_queue_streamoff(&vfh->queue);
+err_isp_video_check_format:
+		media_entity_pipeline_stop(&video->video.entity);
+err_media_entity_pipeline_start:
 		if (video->isp->pdata->set_constraints)
 			video->isp->pdata->set_constraints(video->isp, false);
-		media_entity_pipeline_stop(&video->video.entity);
 		/* The DMA queue must be emptied here, otherwise CCDC interrupts
 		 * that will get triggered the next time the CCDC is powered up
 		 * will try to access buffers that might have been freed but
Signature · 1 line
1.7.2.5
#30 lore raw

PATCH v2 21/31 omap3isp: Add lane configuration to platform data

In reply to Sakari Ailus

Add lane configuration (order of clock and data lane) to platform data on both CCP2 and CSI-2.

---
 drivers/media/video/omap3isp/ispcsiphy.h |   15 ++-------------
 include/media/omap3isp.h                 |   25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 13 deletions(-)
drivers/media/video/omap3isp/ispcsiphy.h +2 -13
index 9596dc6..e93a661 100644
@@ -27,22 +27,11 @@
 #ifndef OMAP3_ISP_CSI_PHY_H
 #define OMAP3_ISP_CSI_PHY_H
 
+#include <media/omap3isp.h>
+
 struct isp_csi2_device;
 struct regulator;
 
-struct csiphy_lane {
-	u8 pos;
-	u8 pol;
-};
-
-#define ISP_CSIPHY2_NUM_DATA_LANES	2
-#define ISP_CSIPHY1_NUM_DATA_LANES	1
-
-struct isp_csiphy_lanes_cfg {
-	struct csiphy_lane data[ISP_CSIPHY2_NUM_DATA_LANES];
-	struct csiphy_lane clk;
-};
-
 struct isp_csiphy_dphy_cfg {
 	u8 ths_term;
 	u8 ths_settle;
include/media/omap3isp.h +25 -0
index 3f4928d..4d94be5 100644
@@ -91,6 +91,29 @@ enum {
 };
 
 /**
+ * struct isp_csiphy_lane: CCP2/CSI2 lane position and polarity
+ * @pos: position of the lane
+ * @pol: polarity of the lane
+ */
+struct isp_csiphy_lane {
+	u8 pos;
+	u8 pol;
+};
+
+#define ISP_CSIPHY1_NUM_DATA_LANES	1
+#define ISP_CSIPHY2_NUM_DATA_LANES	2
+
+/**
+ * struct isp_csiphy_lanes_cfg - CCP2/CSI2 lane configuration
+ * @data: Configuration of one or two data lanes
+ * @clk: Clock lane configuration
+ */
+struct isp_csiphy_lanes_cfg {
+	struct isp_csiphy_lane data[ISP_CSIPHY2_NUM_DATA_LANES];
+	struct isp_csiphy_lane clk;
+};
+
+/**
  * struct isp_ccp2_platform_data - CCP2 interface platform data
  * @strobe_clk_pol: Strobe/clock polarity
  *		0 - Non Inverted, 1 - Inverted
@@ -109,6 +132,7 @@ struct isp_ccp2_platform_data {
 	unsigned int ccp2_mode:1;
 	unsigned int phy_layer:1;
 	unsigned int vpclk_div:2;
+	struct isp_csiphy_lanes_cfg lanecfg;
 };
 
 /**
@@ -119,6 +143,7 @@ struct isp_ccp2_platform_data {
 struct isp_csi2_platform_data {
 	unsigned crc:1;
 	unsigned vpclk_div:2;
+	struct isp_csiphy_lanes_cfg lanecfg;
 };
 
 struct isp_subdev_i2c_board_info {
Signature · 1 line
1.7.2.5
#31 lore raw

PATCH v2 22/31 omap3isp: Add information on external subdev to struct isp_pipeline

In reply to Sakari Ailus

Add pointer to external subdev, pixel rate of the external subdev and bpp of the format to struct isp_pipeline.

---
 drivers/media/video/omap3isp/ispvideo.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/media/video/omap3isp/ispvideo.h +3 -0
index d91bdb91..b198723 100644
@@ -102,6 +102,9 @@ struct isp_pipeline {
 	bool do_propagation; /* of frame number */
 	bool error;
 	struct v4l2_fract max_timeperframe;
+	struct v4l2_subdev *external;
+	unsigned int external_rate;
+	int external_bpp;
 };
 
 #define to_isp_pipeline(__e) \
Signature · 1 line
1.7.2.5
#32 lore raw

PATCH v2 23/31 omap3isp: Introduce omap3isp_get_external_info()

In reply to Sakari Ailus

omap3isp_get_external_info() will retrieve external subdev's bits-per-pixel and pixel rate for the use of other ISP subdevs at streamon time. omap3isp_get_external_info() is used during pipeline validation.

---
 drivers/media/video/omap3isp/isp.c |   48 ++++++++++++++++++++++++++++++++++++
 drivers/media/video/omap3isp/isp.h |    3 ++
 2 files changed, 51 insertions(+), 0 deletions(-)
drivers/media/video/omap3isp/isp.c +48 -0
index d4e0905..ae67f49 100644
@@ -353,6 +353,54 @@ void omap3isp_hist_dma_done(struct isp_device *isp)
 	}
 }
 
+int omap3isp_get_external_info(struct isp_pipeline *pipe,
+			       struct media_link *link)
+{
+	struct isp_device *isp =
+		container_of(pipe, struct isp_video, pipe)->isp;
+	struct v4l2_subdev_format fmt;
+	struct v4l2_ext_controls ctrls;
+	struct v4l2_ext_control ctrl;
+	int ret;
+
+	if (!pipe->external)
+		return 0;
+
+	if (pipe->external_rate)
+		return 0;
+
+	memset(&fmt, 0, sizeof(fmt));
+
+	fmt.pad = link->source->index;
+	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+	ret = v4l2_subdev_call(media_entity_to_v4l2_subdev(link->sink->entity),
+			       pad, get_fmt, NULL, &fmt);
+	if (ret < 0)
+		return -EPIPE;
+
+	pipe->external_bpp = omap3isp_video_format_info(fmt.format.code)->bpp;
+
+	memset(&ctrls, 0, sizeof(ctrls));
+	memset(&ctrl, 0, sizeof(ctrl));
+
+	ctrl.id = V4L2_CID_IMAGE_PROC_PIXEL_RATE;
+
+	ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(ctrl.id);
+	ctrls.count = 1;
+	ctrls.controls = &ctrl;
+
+	ret = v4l2_g_ext_ctrls(pipe->external->ctrl_handler, &ctrls);
+	if (ret < 0) {
+		dev_warn(isp->dev, "no pixel rate control in subdev %s\n",
+			 pipe->external->name);
+		return ret;
+	}
+
+	pipe->external_rate = ctrl.value64;
+
+	return 0;
+}
+
 static inline void isp_isr_dbg(struct isp_device *isp, u32 irqstatus)
 {
 	static const char *name[] = {
drivers/media/video/omap3isp/isp.h +3 -0
index 2e78041..8b0bc2d 100644
@@ -222,6 +222,9 @@ struct isp_device {
 
 void omap3isp_hist_dma_done(struct isp_device *isp);
 
+int omap3isp_get_external_info(struct isp_pipeline *pipe,
+			       struct media_link *link);
+
 void omap3isp_flush(struct isp_device *isp);
 
 int omap3isp_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
Signature · 1 line
1.7.2.5
#33 lore raw

PATCH v2 24/31 omap3isp: Default link validation for ccp2, csi2, preview and resizer

In reply to Sakari Ailus

Use default link validation for ccp2, csi2, preview and resizer. On ccp2, csi2 and ccdc we also collect information on external subdevs as one may be connected to those entities.

The CCDC link validation still must be done separately.

Also set pipe->external correctly as we go

---
 drivers/media/video/omap3isp/ispccdc.c    |   23 +++++++++++++++++++++++
 drivers/media/video/omap3isp/ispccp2.c    |   20 ++++++++++++++++++++
 drivers/media/video/omap3isp/ispcsi2.c    |   19 +++++++++++++++++++
 drivers/media/video/omap3isp/isppreview.c |    2 ++
 drivers/media/video/omap3isp/ispresizer.c |    2 ++
 drivers/media/video/omap3isp/ispvideo.c   |    4 ++++
 6 files changed, 70 insertions(+), 0 deletions(-)
drivers/media/video/omap3isp/ispccdc.c +23 -0
index a74a797..6aff241 100644
@@ -1999,6 +1999,27 @@ static int ccdc_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 	return 0;
 }
 
+static int ccdc_link_validate(struct v4l2_subdev *sd,
+			      struct media_link *link,
+			      struct v4l2_subdev_format *source_fmt,
+			      struct v4l2_subdev_format *sink_fmt)
+{
+	struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
+	struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity);
+	int rval;
+
+	/* We've got a parallel sensor here. */
+	if (ccdc->input == CCDC_INPUT_PARALLEL) {
+		pipe->external =
+			media_entity_to_v4l2_subdev(link->source->entity);
+		rval = omap3isp_get_external_info(pipe, link);
+		if (rval < 0)
+			return 0;
+	}
+
+	return 0;
+}
+
 /*
  * ccdc_init_formats - Initialize formats on all pads
  * @sd: ISP CCDC V4L2 subdevice
@@ -2041,6 +2062,7 @@ static const struct v4l2_subdev_pad_ops ccdc_v4l2_pad_ops = {
 	.enum_frame_size = ccdc_enum_frame_size,
 	.get_fmt = ccdc_get_format,
 	.set_fmt = ccdc_set_format,
+	.link_validate = ccdc_link_validate,
 };
 
 /* V4L2 subdev operations */
@@ -2150,6 +2172,7 @@ static int ccdc_link_setup(struct media_entity *entity,
 /* media operations */
 static const struct media_entity_operations ccdc_media_ops = {
 	.link_setup = ccdc_link_setup,
+	.link_validate = v4l2_subdev_link_validate,
 };
 
 void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc)
drivers/media/video/omap3isp/ispccp2.c +20 -0
index 70ddbf3..4fb34ee 100644
@@ -819,6 +819,24 @@ static int ccp2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 	return 0;
 }
 
+static int ccp2_link_validate(struct v4l2_subdev *sd, struct media_link *link,
+			      struct v4l2_subdev_format *source_fmt,
+			      struct v4l2_subdev_format *sink_fmt)
+{
+	struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
+	struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity);
+	int rval;
+
+	pipe->external = media_entity_to_v4l2_subdev(link->source->entity);
+	rval = omap3isp_get_external_info(pipe, link);
+	if (rval < 0)
+		return rval;
+
+	return v4l2_subdev_link_validate_default(sd, link, source_fmt,
+						 sink_fmt);
+}
+
+
 /*
  * ccp2_init_formats - Initialize formats on all pads
  * @sd: ISP CCP2 V4L2 subdevice
@@ -925,6 +943,7 @@ static const struct v4l2_subdev_pad_ops ccp2_sd_pad_ops = {
 	.enum_frame_size = ccp2_enum_frame_size,
 	.get_fmt = ccp2_get_format,
 	.set_fmt = ccp2_set_format,
+	.link_validate = ccp2_link_validate,
 };
 
 /* subdev operations */
@@ -1021,6 +1040,7 @@ static int ccp2_link_setup(struct media_entity *entity,
 /* media operations */
 static const struct media_entity_operations ccp2_media_ops = {
 	.link_setup = ccp2_link_setup,
+	.link_validate = v4l2_subdev_link_validate,
 };
 
 /*
drivers/media/video/omap3isp/ispcsi2.c +19 -0
index fcb5168..9313f7c 100644
@@ -1012,6 +1012,23 @@ static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 	return 0;
 }
 
+static int csi2_link_validate(struct v4l2_subdev *sd, struct media_link *link,
+			      struct v4l2_subdev_format *source_fmt,
+			      struct v4l2_subdev_format *sink_fmt)
+{
+	struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
+	struct isp_pipeline *pipe = to_isp_pipeline(&csi2->subdev.entity);
+	int rval;
+
+	pipe->external = media_entity_to_v4l2_subdev(link->source->entity);
+	rval = omap3isp_get_external_info(pipe, link);
+	if (rval < 0)
+		return rval;
+
+	return v4l2_subdev_link_validate_default(sd, link, source_fmt,
+						 sink_fmt);
+}
+
 /*
  * csi2_init_formats - Initialize formats on all pads
  * @sd: ISP CSI2 V4L2 subdevice
@@ -1107,6 +1124,7 @@ static const struct v4l2_subdev_pad_ops csi2_pad_ops = {
 	.enum_frame_size = csi2_enum_frame_size,
 	.get_fmt = csi2_get_format,
 	.set_fmt = csi2_set_format,
+	.link_validate = csi2_link_validate,
 };
 
 /* subdev operations */
@@ -1181,6 +1199,7 @@ static int csi2_link_setup(struct media_entity *entity,
 /* media operations */
 static const struct media_entity_operations csi2_media_ops = {
 	.link_setup = csi2_link_setup,
+	.link_validate = v4l2_subdev_link_validate,
 };
 
 void omap3isp_csi2_unregister_entities(struct isp_csi2_device *csi2)
drivers/media/video/omap3isp/isppreview.c +2 -0
index 6d0fb2c..c2bf500 100644
@@ -1981,6 +1981,7 @@ static const struct v4l2_subdev_pad_ops preview_v4l2_pad_ops = {
 	.set_fmt = preview_set_format,
 	.get_crop = preview_get_crop,
 	.set_crop = preview_set_crop,
+	.link_validate = v4l2_subdev_link_validate_default,
 };
 
 /* subdev operations */
@@ -2076,6 +2077,7 @@ static int preview_link_setup(struct media_entity *entity,
 /* media operations */
 static const struct media_entity_operations preview_media_ops = {
 	.link_setup = preview_link_setup,
+	.link_validate = v4l2_subdev_link_validate,
 };
 
 void omap3isp_preview_unregister_entities(struct isp_prev_device *prev)
drivers/media/video/omap3isp/ispresizer.c +2 -0
index 6958a9e..6ce2349 100644
@@ -1532,6 +1532,7 @@ static const struct v4l2_subdev_pad_ops resizer_v4l2_pad_ops = {
 	.set_fmt = resizer_set_format,
 	.get_crop = resizer_g_crop,
 	.set_crop = resizer_s_crop,
+	.link_validate = v4l2_subdev_link_validate_default,
 };
 
 /* subdev operations */
@@ -1603,6 +1604,7 @@ static int resizer_link_setup(struct media_entity *entity,
 /* media operations */
 static const struct media_entity_operations resizer_media_ops = {
 	.link_setup = resizer_link_setup,
+	.link_validate = v4l2_subdev_link_validate,
 };
 
 void omap3isp_resizer_unregister_entities(struct isp_res_device *res)
drivers/media/video/omap3isp/ispvideo.c +4 -0
index 17522db..f1c68ca 100644
@@ -993,6 +993,10 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 	 */
 	pipe = video->video.entity.pipe
 	     ? to_isp_pipeline(&video->video.entity) : &video->pipe;
+	pipe->external = NULL;
+	pipe->external_rate = 0;
+	pipe->external_bpp = 0;
+
 	ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
 	if (ret < 0)
 		goto err_media_entity_pipeline_start;
Signature · 1 line
1.7.2.5
#34 lore raw

PATCH v2 25/31 omap3isp: Implement proper CCDC link validation, check pixel rate

In reply to Sakari Ailus

Implement correct link validation for the CCDC. Use external_rate from isp_pipeline to configurat vp divisor and check that external_rate does not exceed our data rate limitations.

---
 drivers/media/video/omap3isp/ispccdc.c |   69 +++++++++++++++++++++++++++++--
 1 files changed, 64 insertions(+), 5 deletions(-)
drivers/media/video/omap3isp/ispccdc.c +64 -5
index 6aff241..1555891 100644
@@ -836,8 +836,8 @@ static void ccdc_config_vp(struct isp_ccdc_device *ccdc)
 
 	if (pipe->input)
 		div = DIV_ROUND_UP(l3_ick, pipe->max_rate);
-	else if (ccdc->vpcfg.pixelclk)
-		div = l3_ick / ccdc->vpcfg.pixelclk;
+	else if (pipe->external_rate)
+		div = l3_ick / pipe->external_rate;
 
 	div = clamp(div, 2U, max_div);
 	fmtcfg_vp |= (div - 2) << ISPCCDC_FMTCFG_VPIF_FRQ_SHIFT;
@@ -1749,7 +1749,18 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	switch (enable) {
-	case ISP_PIPELINE_STREAM_CONTINUOUS:
+	case ISP_PIPELINE_STREAM_CONTINUOUS: {
+		struct isp_pipeline *pipe = to_isp_pipeline(&sd->entity);
+		unsigned int rate = UINT_MAX;
+
+		/*
+		 * Check that maximum allowed rate isn't exceeded by
+		 * the pixel rate.
+		 */
+		omap3isp_ccdc_max_rate(&isp->isp_ccdc, &rate);
+		if (pipe->external_rate > rate)
+			return -ENOSPC;
+
 		if (ccdc->output & CCDC_OUTPUT_MEMORY)
 			omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CCDC_WRITE);
 
@@ -1758,6 +1769,7 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable)
 
 		ccdc->underrun = 0;
 		break;
+	}
 
 	case ISP_PIPELINE_STREAM_SINGLESHOT:
 		if (ccdc->output & CCDC_OUTPUT_MEMORY &&
@@ -1999,6 +2011,37 @@ static int ccdc_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 	return 0;
 }
 
+/*
+ * Decide whether desired output pixel code can be obtained with
+ * the lane shifter by shifting the input pixel code.
+ * @in: input pixelcode to shifter
+ * @out: output pixelcode from shifter
+ * @additional_shift: # of bits the sensor's LSB is offset from CAMEXT[0]
+ *
+ * return true if the combination is possible
+ * return false otherwise
+ */
+static bool ccdc_is_shiftable(enum v4l2_mbus_pixelcode in,
+			      enum v4l2_mbus_pixelcode out,
+			      unsigned int additional_shift)
+{
+	const struct isp_format_info *in_info, *out_info;
+
+	if (in == out)
+		return true;
+
+	in_info = omap3isp_video_format_info(in);
+	out_info = omap3isp_video_format_info(out);
+
+	if ((in_info->flavor == 0) || (out_info->flavor == 0))
+		return false;
+
+	if (in_info->flavor != out_info->flavor)
+		return false;
+
+	return in_info->bpp - out_info->bpp + additional_shift <= 6;
+}
+
 static int ccdc_link_validate(struct v4l2_subdev *sd,
 			      struct media_link *link,
 			      struct v4l2_subdev_format *source_fmt,
@@ -2008,13 +2051,31 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,
 	struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity);
 	int rval;
 
+	/* Check if the two ends match */
+	if (source_fmt->format.width != sink_fmt->format.width ||
+	    source_fmt->format.height != sink_fmt->format.height)
+		return -EPIPE;
+
 	/* We've got a parallel sensor here. */
 	if (ccdc->input == CCDC_INPUT_PARALLEL) {
+		struct isp_parallel_platform_data *pdata =
+			&((struct isp_v4l2_subdevs_group *)
+			  media_entity_to_v4l2_subdev(link->source->entity)
+			  ->host_priv)->bus.parallel;
+		unsigned long parallel_shift = pdata->data_lane_shift * 2;
+		/* Lane shifter may be used to drop bits on CCDC sink pad */
+		if (!ccdc_is_shiftable(source_fmt->format.code,
+				       sink_fmt->format.code, parallel_shift))
+			return -EPIPE;
+
 		pipe->external =
 			media_entity_to_v4l2_subdev(link->source->entity);
 		rval = omap3isp_get_external_info(pipe, link);
 		if (rval < 0)
 			return 0;
+	} else {
+		if (source_fmt->format.code != sink_fmt->format.code)
+			return -EPIPE;
 	}
 
 	return 0;
@@ -2299,8 +2360,6 @@ int omap3isp_ccdc_init(struct isp_device *isp)
 	ccdc->clamp.oblen = 0;
 	ccdc->clamp.dcsubval = 0;
 
-	ccdc->vpcfg.pixelclk = 0;
-
 	ccdc->update = OMAP3ISP_CCDC_BLCLAMP;
 	ccdc_apply_controls(ccdc);
 
Signature · 1 line
1.7.2.5
#35 lore raw

PATCH v2 26/31 omap3isp: Move setting constaints above media_entity_pipeline_start

In reply to Sakari Ailus
---
 drivers/media/video/omap3isp/ispvideo.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
drivers/media/video/omap3isp/ispvideo.c +5 -6
index f1c68ca..2e4786d 100644
@@ -304,8 +304,6 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
 	struct v4l2_subdev *subdev;
 	int ret;
 
-	pipe->max_rate = pipe->l3_ick;
-
 	subdev = isp_video_remote_subdev(pipe->output, NULL);
 	if (subdev == NULL)
 		return -EPIPE;
@@ -997,6 +995,11 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 	pipe->external_rate = 0;
 	pipe->external_bpp = 0;
 
+	if (video->isp->pdata->set_constraints)
+		video->isp->pdata->set_constraints(video->isp, true);
+	pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]);
+	pipe->max_rate = pipe->l3_ick;
+
 	ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
 	if (ret < 0)
 		goto err_media_entity_pipeline_start;
@@ -1031,10 +1034,6 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 		pipe->output = far_end;
 	}
 
-	if (video->isp->pdata->set_constraints)
-		video->isp->pdata->set_constraints(video->isp, true);
-	pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]);
-
 	/* Validate the pipeline and update its state. */
 	ret = isp_video_validate_pipeline(pipe);
 	if (ret < 0)
Signature · 1 line
1.7.2.5
#36 lore raw

PATCH v2 27/31 omap3isp: Configure CSI-2 phy based on platform data

In reply to Sakari Ailus

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/ispcsi2.c   |   10 +++-
 drivers/media/video/omap3isp/ispcsiphy.c |   78 ++++++++++++++++++++++++++----
 drivers/media/video/omap3isp/ispcsiphy.h |    2 +
 3 files changed, 78 insertions(+), 12 deletions(-)
drivers/media/video/omap3isp/ispcsi2.c +8 -2
index 9313f7c..e2e3d63 100644
@@ -1068,7 +1068,13 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
 	struct isp_video *video_out = &csi2->video_out;
 
 	switch (enable) {
-	case ISP_PIPELINE_STREAM_CONTINUOUS:
+	case ISP_PIPELINE_STREAM_CONTINUOUS: {
+		int ret;
+
+		ret = omap3isp_csiphy_config(isp, sd);
+		if (ret < 0)
+			return ret;
+
 		if (omap3isp_csiphy_acquire(csi2->phy) < 0)
 			return -ENODEV;
 		csi2->use_fs_irq = pipe->do_propagation;
@@ -1092,7 +1098,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
 		csi2_if_enable(isp, csi2, 1);
 		isp_video_dmaqueue_flags_clr(video_out);
 		break;
-
+	}
 	case ISP_PIPELINE_STREAM_STOPPED:
 		if (csi2->state == ISP_PIPELINE_STREAM_STOPPED)
 			return 0;
drivers/media/video/omap3isp/ispcsiphy.c +68 -10

107 lines not on this page · raw message

drivers/media/video/omap3isp/ispcsiphy.h +2 -0
index e93a661..a404b10 100644
@@ -56,6 +56,8 @@ struct isp_csiphy {
 	struct isp_csiphy_dphy_cfg dphy;
 };
 
+int omap3isp_csiphy_config(struct isp_device *isp,
+			   struct v4l2_subdev *csi2_subdev);
 int omap3isp_csiphy_acquire(struct isp_csiphy *phy);
 void omap3isp_csiphy_release(struct isp_csiphy *phy);
 int omap3isp_csiphy_init(struct isp_device *isp);
Signature · 1 line
1.7.2.5
#37 lore raw

Re: [PATCH v2 27/31] omap3isp: Configure CSI-2 phy based on platform data

Hi Sakari,

Quoted 78 lines · Sakari Ailus

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/ispcsi2.c   |   10 +++- drivers/media/video/omap3isp/ispcsiphy.c |   78 ++++++++++++++++++++++++++---- drivers/media/video/omap3isp/ispcsiphy.h |    2 +

 3 files changed, 78 insertions(+), 12 deletions(-)
drivers/media/video/omap3isp/ispcsi2.c +8 -2
index 9313f7c..e2e3d63 100644
@@ -1068,7 +1068,13 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
        struct isp_video *video_out = &csi2->video_out;
 
        switch (enable) {
-       case ISP_PIPELINE_STREAM_CONTINUOUS:
+       case ISP_PIPELINE_STREAM_CONTINUOUS: {
+               int ret;
+
+               ret = omap3isp_csiphy_config(isp, sd);
+               if (ret < 0)
+                       return ret;
+
                if (omap3isp_csiphy_acquire(csi2->phy) < 0)
                        return -ENODEV;
                csi2->use_fs_irq = pipe->do_propagation;
@@ -1092,7 +1098,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
                csi2_if_enable(isp, csi2, 1);
                isp_video_dmaqueue_flags_clr(video_out);
                break;
-
+       }

       case ISP_PIPELINE_STREAM_STOPPED:
               if (csi2->state == ISP_PIPELINE_STREAM_STOPPED) return 0;

drivers/media/video/omap3isp/ispcsiphy.c +17 -3
index 5be37ce..5d7a6ab 100644
@@ -28,6 +28,8 @@
  #include <linux/device.h>
  #include <linux/regulator/consumer.h>
 
+#include "../../../../arch/arm/mach-omap2/control.h"
+
  #include "isp.h"
  #include "ispreg.h"
  #include "ispcsiphy.h"
@@ -138,15 +140,73 @@ static void csiphy_dphy_config(struct isp_csiphy *phy)
        isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
  }
 
-static int csiphy_config(struct isp_csiphy *phy,
-                        struct isp_csiphy_dphy_cfg *dphy,
-                        struct isp_csiphy_lanes_cfg *lanes)
+/*
+ * TCLK values are OK at their reset values
+ */
+#define TCLK_TERM      0
+#define TCLK_MISS      1
+#define TCLK_SETTLE    14
+
+int omap3isp_csiphy_config(struct isp_device *isp,
+                          struct v4l2_subdev *csi2_subdev)
  {
+       struct isp_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
+       struct isp_pipeline *pipe = to_isp_pipeline(&csi2_subdev->entity);
+       struct isp_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
+       struct isp_csiphy_dphy_cfg csi2phy;
+       int csi2_ddrclk_khz;
+       struct isp_csiphy_lanes_cfg *lanes;
        unsigned int used_lanes = 0;
        unsigned int i;
 

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 171

Quoted 10 lines
drivers/media/video/omap3isp/ispcsiphy.c +10 -0
+       if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
+           || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+               lanes = &subdevs->bus.ccp2.lanecfg;
+       else
+               lanes = &subdevs->bus.csi2.lanecfg;
+
+       /* FIXME: Do 34xx / 35xx require something here? */
+       if (cpu_is_omap3630()) {
+               u32 cam_phy_ctrl = omap_readl(
+                       OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

How about:

		u32 cam_phy_ctrl = omap_ctrl_readl(OMAP3630_CONTROL_CAMERA_PHY_CTRL);

?

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 182

Quoted 11 lines
drivers/media/video/omap3isp/ispcsiphy.c +11 -0
+
+               /*
+                * SCM.CONTROL_CAMERA_PHY_CTRL
+                * - bit[4]    : CSIPHY1 data sent to CSIB
+                * - bit [3:2] : CSIPHY1 config: 00 d-phy, 01/10 ccp2
+                * - bit [1:0] : CSIPHY2 config: 00 d-phy, 01/10 ccp2
+                */
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1)
+                       cam_phy_ctrl |= 1 << 2;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2C_PHY1)
+                       cam_phy_ctrl &= 1 << 2;

Shouldn't this be:
                      cam_phy_ctrl &= ~(1 << 2);
?

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 187

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+                       cam_phy_ctrl |= 1;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2A_PHY2)
+                       cam_phy_ctrl &= 1;

... and:
                      cam_phy_ctrl &= ~1;

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 191

Quoted 4 lines
drivers/media/video/omap3isp/ispcsiphy.c +4 -0
+
+               omap_writel(cam_phy_ctrl,
+                           OMAP343X_CTRL_BASE
+                           + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Again:

		omap_ctrl_writel(cam_phy_ctrl, OMAP3630_CONTROL_CAMERA_PHY_CTRL);

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 196

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+       }
+
+       csi2_ddrclk_khz = pipe->external_rate / 1000
+               / (2 * csi2->phy->num_data_lanes)
+               * pipe->external_bpp;

Can you please explain how did you came up with this formula?

For example, if I keep the pixel_rate, yet I change the number of lanes my sensor is using,
this result is unaltered, as phy->num_data_lanes is always equal to the maximum number
of lanes available in the interface. (for OMAP4, that's 4 datalanes for CSI2-A).

Meanwhile, in theory, if I keep the same pixels per second, and use less datalanes, the
DDR frequency should at least double.

Now, this brings me to another question, How can the sensor tell how many lanes is using from the total?

Regards,
Sergio

Quoted 61 lines
drivers/media/video/omap3isp/ispcsiphy.c +16 -7
+
+       /*
+        * THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1.
+        * THS_SETTLE: Programmed value = ceil(90 ns/DDRClk period) + 3.
+        */
+       csi2phy.ths_term = DIV_ROUND_UP(25 * csi2_ddrclk_khz, 2000000) - 1;
+       csi2phy.ths_settle = DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3;
+       csi2phy.tclk_term = TCLK_TERM;
+       csi2phy.tclk_miss = TCLK_MISS;
+       csi2phy.tclk_settle = TCLK_SETTLE;
+
        /* Clock and data lanes verification */
-       for (i = 0; i < phy->num_data_lanes; i++) {
+       for (i = 0; i < csi2->phy->num_data_lanes; i++) {
                if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3)
                        return -EINVAL;
 
@@ -162,10 +222,10 @@ static int csiphy_config(struct isp_csiphy *phy,
        if (lanes->clk.pos == 0 || used_lanes & (1 << lanes->clk.pos))
                return -EINVAL;
 
-       mutex_lock(&phy->mutex);
-       phy->dphy = *dphy;
-       phy->lanes = *lanes;
-       mutex_unlock(&phy->mutex);
+       mutex_lock(&csi2->phy->mutex);
+       csi2->phy->dphy = csi2phy;
+       csi2->phy->lanes = *lanes;
+       mutex_unlock(&csi2->phy->mutex);
 
        return 0;
  }
@@ -225,8 +285,6 @@ int omap3isp_csiphy_init(struct isp_device *isp)
        struct isp_csiphy *phy1 = &isp->isp_csiphy1;
        struct isp_csiphy *phy2 = &isp->isp_csiphy2;
 
-       isp->platform_cb.csiphy_config = csiphy_config;
-
        phy2->isp = isp;
        phy2->csi2 = &isp->isp_csi2a;
        phy2->num_data_lanes = ISP_CSIPHY2_NUM_DATA_LANES;
drivers/media/video/omap3isp/ispcsiphy.h +2 -1
index e93a661..a404b10 100644
@@ -56,6 +56,8 @@ struct isp_csiphy {
        struct isp_csiphy_dphy_cfg dphy;
  };
 
+int omap3isp_csiphy_config(struct isp_device *isp,
+                          struct v4l2_subdev *csi2_subdev);
  int omap3isp_csiphy_acquire(struct isp_csiphy *phy);
  void omap3isp_csiphy_release(struct isp_csiphy *phy);
  int omap3isp_csiphy_init(struct isp_device *isp);
--

1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#38 lore raw

Re: [PATCH v2 27/31] omap3isp: Configure CSI-2 phy based on platform data

Hi Sergio,

Thanks for the review!

Quoted 91 lines · Sergio
Quoted 78 lines · Sakari Ailus

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/ispcsi2.c   |   10 +++-
 drivers/media/video/omap3isp/ispcsiphy.c |   78 ++++++++++++++++++++++++++----
 drivers/media/video/omap3isp/ispcsiphy.h |    2 +
 3 files changed, 78 insertions(+), 12 deletions(-)
drivers/media/video/omap3isp/ispcsi2.c +8 -2
index 9313f7c..e2e3d63 100644
@@ -1068,7 +1068,13 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
       struct isp_video *video_out = &csi2->video_out;
 
       switch (enable) {
-       case ISP_PIPELINE_STREAM_CONTINUOUS:
+       case ISP_PIPELINE_STREAM_CONTINUOUS: {
+               int ret;
+
+               ret = omap3isp_csiphy_config(isp, sd);
+               if (ret < 0)
+                       return ret;
+
               if (omap3isp_csiphy_acquire(csi2->phy) < 0)
                       return -ENODEV;
               csi2->use_fs_irq = pipe->do_propagation;
@@ -1092,7 +1098,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
               csi2_if_enable(isp, csi2, 1);
               isp_video_dmaqueue_flags_clr(video_out);
               break;
-
+       }
       case ISP_PIPELINE_STREAM_STOPPED:
               if (csi2->state == ISP_PIPELINE_STREAM_STOPPED)
                       return 0;
drivers/media/video/omap3isp/ispcsiphy.c +17 -3
index 5be37ce..5d7a6ab 100644
@@ -28,6 +28,8 @@
 #include <linux/device.h>
 #include <linux/regulator/consumer.h>
 
+#include "../../../../arch/arm/mach-omap2/control.h"
+
 #include "isp.h"
 #include "ispreg.h"
 #include "ispcsiphy.h"
@@ -138,15 +140,73 @@ static void csiphy_dphy_config(struct isp_csiphy *phy)
       isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
 }
 
-static int csiphy_config(struct isp_csiphy *phy,
-                        struct isp_csiphy_dphy_cfg *dphy,
-                        struct isp_csiphy_lanes_cfg *lanes)
+/*
+ * TCLK values are OK at their reset values
+ */
+#define TCLK_TERM      0
+#define TCLK_MISS      1
+#define TCLK_SETTLE    14
+
+int omap3isp_csiphy_config(struct isp_device *isp,
+                          struct v4l2_subdev *csi2_subdev)
 {
+       struct isp_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
+       struct isp_pipeline *pipe = to_isp_pipeline(&csi2_subdev->entity);
+       struct isp_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
+       struct isp_csiphy_dphy_cfg csi2phy;
+       int csi2_ddrclk_khz;
+       struct isp_csiphy_lanes_cfg *lanes;
       unsigned int used_lanes = 0;
       unsigned int i;
 

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 171

Quoted 10 lines
drivers/media/video/omap3isp/ispcsiphy.c +10 -0
+       if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
+           || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+               lanes = &subdevs->bus.ccp2.lanecfg;
+       else
+               lanes = &subdevs->bus.csi2.lanecfg;
+
+       /* FIXME: Do 34xx / 35xx require something here? */
+       if (cpu_is_omap3630()) {
+               u32 cam_phy_ctrl = omap_readl(
+                       OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

How about:

Quoted 2 lines
		u32 cam_phy_ctrl = omap_ctrl_readl(OMAP3630_CONTROL_CAMERA_PHY_CTRL);

?

Fine for me.

Quoted 12 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 182

Quoted 11 lines
drivers/media/video/omap3isp/ispcsiphy.c +11 -0
+
+               /*
+                * SCM.CONTROL_CAMERA_PHY_CTRL
+                * - bit[4]    : CSIPHY1 data sent to CSIB
+                * - bit [3:2] : CSIPHY1 config: 00 d-phy, 01/10 ccp2
+                * - bit [1:0] : CSIPHY2 config: 00 d-phy, 01/10 ccp2
+                */
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1)
+                       cam_phy_ctrl |= 1 << 2;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2C_PHY1)
+                       cam_phy_ctrl &= 1 << 2;
Quoted 3 lines

Shouldn't this be:

                       cam_phy_ctrl &= ~(1 << 2);

?

Probably yes. This has come directly as it was in the original board code and might not be entirely correct. It works on the N9 at least.

Quoted 9 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 187

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+                       cam_phy_ctrl |= 1;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2A_PHY2)
+                       cam_phy_ctrl &= 1;

... and:

                       cam_phy_ctrl &= ~1;
Quoted 7 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 191

Quoted 4 lines
drivers/media/video/omap3isp/ispcsiphy.c +4 -0
+
+               omap_writel(cam_phy_ctrl,
+                           OMAP343X_CTRL_BASE
+                           + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Again:

		omap_ctrl_writel(cam_phy_ctrl, OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Will fix.

Quoted 6 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 196

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+       }
+
+       csi2_ddrclk_khz = pipe->external_rate / 1000
+               / (2 * csi2->phy->num_data_lanes)
+               * pipe->external_bpp;
Quoted 7 lines

Can you please explain how did you came up with this formula?

For example, if I keep the pixel_rate, yet I change the number of lanes my sensor is using,
this result is unaltered, as phy->num_data_lanes is always equal to the maximum number
of lanes available in the interface. (for OMAP4, that's 4 datalanes for CSI2-A).

The number of lanes is specified in the board code (in the future, DT) and is thus specific to the board. The clock rate is per-lane whereas the pipe->external_rate is the total pixel rate on all lanes.

Quoted 6 lines

Meanwhile, in theory, if I keep the same pixels per second, and use less datalanes, the
DDR frequency should at least double.

Now, this brings me to another question, How can the sensor tell how many lanes is using from the total?

We might consider making the number of lanes used dynamic but that's currently static. I can't think of any major benefits right now in making this dynamically configurable.

Does this answer to your questions? :-)

Kind regards,

Signature · 2 lines
Sakari Ailus
[email protected]
#39 lore raw

Re: [PATCH v2 27/31] omap3isp: Configure CSI-2 phy based on platform data

Hi Sakari,

Quoted 161 lines · Sakari Ailus

Hi Sergio,

Thanks for the review!

Quoted 79 lines · Sergio
Quoted 78 lines · Sakari Ailus

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/ispcsi2.c   |   10 +++- drivers/media/video/omap3isp/ispcsiphy.c |   78 ++++++++++++++++++++++++++---- drivers/media/video/omap3isp/ispcsiphy.h |    2 +

 3 files changed, 78 insertions(+), 12 deletions(-)
drivers/media/video/omap3isp/ispcsi2.c +8 -2
index 9313f7c..e2e3d63 100644
@@ -1068,7 +1068,13 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
        struct isp_video *video_out = &csi2->video_out;
 
        switch (enable) {
-       case ISP_PIPELINE_STREAM_CONTINUOUS:
+       case ISP_PIPELINE_STREAM_CONTINUOUS: {
+               int ret;
+
+               ret = omap3isp_csiphy_config(isp, sd);
+               if (ret < 0)
+                       return ret;
+
                if (omap3isp_csiphy_acquire(csi2->phy) < 0)
                        return -ENODEV;
                csi2->use_fs_irq = pipe->do_propagation;
@@ -1092,7 +1098,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
                csi2_if_enable(isp, csi2, 1);
                isp_video_dmaqueue_flags_clr(video_out);
                break;
-
+       }

       case ISP_PIPELINE_STREAM_STOPPED:
               if (csi2->state == ISP_PIPELINE_STREAM_STOPPED) return 0;

drivers/media/video/omap3isp/ispcsiphy.c +17 -3
index 5be37ce..5d7a6ab 100644
@@ -28,6 +28,8 @@
  #include <linux/device.h>
  #include <linux/regulator/consumer.h>
 
+#include "../../../../arch/arm/mach-omap2/control.h"
+
  #include "isp.h"
  #include "ispreg.h"
  #include "ispcsiphy.h"
@@ -138,15 +140,73 @@ static void csiphy_dphy_config(struct isp_csiphy *phy)
        isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
  }
 
-static int csiphy_config(struct isp_csiphy *phy,
-                        struct isp_csiphy_dphy_cfg *dphy,
-                        struct isp_csiphy_lanes_cfg *lanes)
+/*
+ * TCLK values are OK at their reset values
+ */
+#define TCLK_TERM      0
+#define TCLK_MISS      1
+#define TCLK_SETTLE    14
+
+int omap3isp_csiphy_config(struct isp_device *isp,
+                          struct v4l2_subdev *csi2_subdev)
  {
+       struct isp_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
+       struct isp_pipeline *pipe = to_isp_pipeline(&csi2_subdev->entity);
+       struct isp_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
+       struct isp_csiphy_dphy_cfg csi2phy;
+       int csi2_ddrclk_khz;
+       struct isp_csiphy_lanes_cfg *lanes;
        unsigned int used_lanes = 0;
        unsigned int i;
 
Quoted 14 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 171

Quoted 10 lines
drivers/media/video/omap3isp/ispcsiphy.c +10 -0
+       if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
+           || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+               lanes = &subdevs->bus.ccp2.lanecfg;
+       else
+               lanes = &subdevs->bus.csi2.lanecfg;
+
+       /* FIXME: Do 34xx / 35xx require something here? */
+       if (cpu_is_omap3630()) {
+               u32 cam_phy_ctrl = omap_readl(
+                       OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

How about:
              u32 cam_phy_ctrl = omap_ctrl_readl(OMAP3630_CONTROL_CAMERA_PHY_CTRL); ?

Fine for me.

Quoted 12 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 182

Quoted 11 lines
drivers/media/video/omap3isp/ispcsiphy.c +11 -0
+
+               /*
+                * SCM.CONTROL_CAMERA_PHY_CTRL
+                * - bit[4]    : CSIPHY1 data sent to CSIB
+                * - bit [3:2] : CSIPHY1 config: 00 d-phy, 01/10 ccp2
+                * - bit [1:0] : CSIPHY2 config: 00 d-phy, 01/10 ccp2
+                */
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1)
+                       cam_phy_ctrl |= 1 << 2;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2C_PHY1)
+                       cam_phy_ctrl &= 1 << 2;
Quoted 3 lines

Shouldn't this be:
                       cam_phy_ctrl &= ~(1 << 2);
?

Probably yes. This has come directly as it was in the original board code and might not be entirely correct. It works on the N9 at least.

Quoted 9 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 187

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+                       cam_phy_ctrl |= 1;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2A_PHY2)
+                       cam_phy_ctrl &= 1;

... and:
                       cam_phy_ctrl &= ~1;

Quoted 7 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 191

Quoted 4 lines
drivers/media/video/omap3isp/ispcsiphy.c +4 -0
+
+               omap_writel(cam_phy_ctrl,
+                           OMAP343X_CTRL_BASE
+                           + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Again:
              omap_ctrl_writel(cam_phy_ctrl, OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Will fix.

Quoted 6 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 196

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+       }
+
+       csi2_ddrclk_khz = pipe->external_rate / 1000
+               / (2 * csi2->phy->num_data_lanes)
+               * pipe->external_bpp;
Quoted 7 lines

Can you please explain how did you came up with this formula?

For example, if I keep the pixel_rate, yet I change the number of lanes my sensor is using,
this result is unaltered, as phy->num_data_lanes is always equal to the maximum number
of lanes available in the interface. (for OMAP4, that's 4 datalanes for CSI2-A).

The number of lanes is specified in the board code (in the future, DT) and is thus specific to the board. The clock rate is per-lane whereas the pipe->external_rate is the total pixel rate on all lanes.

Quoted 4 lines

Meanwhile, in theory, if I keep the same pixels per second, and use less datalanes, the
DDR frequency should at least double.

Quoted 8 lines
Quoted 2 lines

Now, this brings me to another question, How can the sensor tell how many lanes is using from the total?

We might consider making the number of lanes used dynamic but that's currently static. I can't think of any major benefits right now in making this dynamically configurable.

Does this answer to your questions? :-)

Sorry, I think I didn't made my point clear properly, so I'm proposing a patch to
expose and fix this wrong calculation i'm telling you about:

<<<<<<<< PATCH START
From: Sergio Aguirre <[email protected]>
Date: Sat, 11 Feb 2012 10:53:01 -0600
Subject: [PATCH] omap3isp: phy: get ddrclk based on sensor lanecount

This will allow csi2_ddrclk_khz be calculated correctly, by observing the sensor lane count, and not the interface lane count.

An example of erratic calculation is, if you have a sensor which only has 1 data lane for output, yet the interface has 2 lanes available, the rate still is split in half:

pixel_rate = 96000000
bpp = 10
sensor_data_lanes = 1
phy_data_lanes = 2

Current formula pretty much says:

csi2_ddrclk_khz = pixel_rate / 1000

		/ (2 * phy_data_lanes)
		* bpp;

Explained is:

bits/second(bps) = pixels/second(pixel_rate) * bits/pixel(bpp) cycles/second(Hz) = bits/second / 2 bits/cycle cycles/datalane = cycles/second / num

Which is you use 2 in last line, would be wrong for a single datalane sensor, so this patch attemote to collect the sensor lane count, and use that instead in the formula.

NOTE: This is tested on omap4iss driver, which is in development.

---
 drivers/media/video/omap3isp/ispcsiphy.c |   41 ++++++++++++++++--------------
 drivers/media/video/omap3isp/ispcsiphy.h |    3 +-
 2 files changed, 24 insertions(+), 20 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/omap3isp/ispcsiphy.c
index 5d7a6ab..03c5749 100644

drivers/media/video/omap3isp/ispcsiphy.c +22 -19

79 lines not on this page · raw message

(quoted diff) +0 -0

b/drivers/media/video/omap3isp/ispcsiphy.h
index a404b10..3401bbd 100644

drivers/media/video/omap3isp/ispcsiphy.h +2 -1
@@ -51,7 +51,8 @@ struct isp_csiphy {
 	unsigned int cfg_regs;
 	unsigned int phy_regs;
 
-	u8 num_data_lanes;	/* number of CSI2 Data Lanes supported */
+	u8 max_data_lanes;	/* number of CSI2 Data Lanes supported */
+	u8 used_data_lanes;	/* number of CSI2 Data Lanes used */
 	struct isp_csiphy_lanes_cfg lanes;
 	struct isp_csiphy_dphy_cfg dphy;
 };
Signature · 1 line
1.7.7.4
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

PATCH END

I hope this clarifies my point.

Regards,
Sergio

Quoted 6 lines

Kind regards,

--
Sakari Ailus
[email protected]

#40 lore raw

Re: [PATCH v2 27/31] omap3isp: Configure CSI-2 phy based on platform data

Quoted 258 lines · Sergio

Hi Sakari,

Quoted 161 lines · Sakari Ailus

Hi Sergio,

Thanks for the review!

Quoted 79 lines · Sergio
Quoted 78 lines · Sakari Ailus

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/ispcsi2.c   |   10 +++- drivers/media/video/omap3isp/ispcsiphy.c |   78 ++++++++++++++++++++++++++---- drivers/media/video/omap3isp/ispcsiphy.h |    2 +

 3 files changed, 78 insertions(+), 12 deletions(-)
drivers/media/video/omap3isp/ispcsi2.c +8 -2
index 9313f7c..e2e3d63 100644
@@ -1068,7 +1068,13 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
        struct isp_video *video_out = &csi2->video_out;
 
        switch (enable) {
-       case ISP_PIPELINE_STREAM_CONTINUOUS:
+       case ISP_PIPELINE_STREAM_CONTINUOUS: {
+               int ret;
+
+               ret = omap3isp_csiphy_config(isp, sd);
+               if (ret < 0)
+                       return ret;
+
                if (omap3isp_csiphy_acquire(csi2->phy) < 0)
                        return -ENODEV;
                csi2->use_fs_irq = pipe->do_propagation;
@@ -1092,7 +1098,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
                csi2_if_enable(isp, csi2, 1);
                isp_video_dmaqueue_flags_clr(video_out);
                break;
-
+       }

       case ISP_PIPELINE_STREAM_STOPPED:
               if (csi2->state == ISP_PIPELINE_STREAM_STOPPED) return 0;

drivers/media/video/omap3isp/ispcsiphy.c +17 -3
index 5be37ce..5d7a6ab 100644
@@ -28,6 +28,8 @@
  #include <linux/device.h>
  #include <linux/regulator/consumer.h>
 
+#include "../../../../arch/arm/mach-omap2/control.h"
+
  #include "isp.h"
  #include "ispreg.h"
  #include "ispcsiphy.h"
@@ -138,15 +140,73 @@ static void csiphy_dphy_config(struct isp_csiphy *phy)
        isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
  }
 
-static int csiphy_config(struct isp_csiphy *phy,
-                        struct isp_csiphy_dphy_cfg *dphy,
-                        struct isp_csiphy_lanes_cfg *lanes)
+/*
+ * TCLK values are OK at their reset values
+ */
+#define TCLK_TERM      0
+#define TCLK_MISS      1
+#define TCLK_SETTLE    14
+
+int omap3isp_csiphy_config(struct isp_device *isp,
+                          struct v4l2_subdev *csi2_subdev)
  {
+       struct isp_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
+       struct isp_pipeline *pipe = to_isp_pipeline(&csi2_subdev->entity);
+       struct isp_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
+       struct isp_csiphy_dphy_cfg csi2phy;
+       int csi2_ddrclk_khz;
+       struct isp_csiphy_lanes_cfg *lanes;
        unsigned int used_lanes = 0;
        unsigned int i;
 
Quoted 14 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 171

Quoted 10 lines
drivers/media/video/omap3isp/ispcsiphy.c +10 -0
+       if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
+           || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+               lanes = &subdevs->bus.ccp2.lanecfg;
+       else
+               lanes = &subdevs->bus.csi2.lanecfg;
+
+       /* FIXME: Do 34xx / 35xx require something here? */
+       if (cpu_is_omap3630()) {
+               u32 cam_phy_ctrl = omap_readl(
+                       OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

How about:
              u32 cam_phy_ctrl = omap_ctrl_readl(OMAP3630_CONTROL_CAMERA_PHY_CTRL); ?

Fine for me.

Quoted 12 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 182

Quoted 11 lines
drivers/media/video/omap3isp/ispcsiphy.c +11 -0
+
+               /*
+                * SCM.CONTROL_CAMERA_PHY_CTRL
+                * - bit[4]    : CSIPHY1 data sent to CSIB
+                * - bit [3:2] : CSIPHY1 config: 00 d-phy, 01/10 ccp2
+                * - bit [1:0] : CSIPHY2 config: 00 d-phy, 01/10 ccp2
+                */
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1)
+                       cam_phy_ctrl |= 1 << 2;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2C_PHY1)
+                       cam_phy_ctrl &= 1 << 2;
Quoted 3 lines

Shouldn't this be:
                       cam_phy_ctrl &= ~(1 << 2);
?

Probably yes. This has come directly as it was in the original board code and might not be entirely correct. It works on the N9 at least.

Quoted 9 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 187

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+                       cam_phy_ctrl |= 1;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2A_PHY2)
+                       cam_phy_ctrl &= 1;

... and:
                       cam_phy_ctrl &= ~1;

Quoted 7 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 191

Quoted 4 lines
drivers/media/video/omap3isp/ispcsiphy.c +4 -0
+
+               omap_writel(cam_phy_ctrl,
+                           OMAP343X_CTRL_BASE
+                           + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Again:
              omap_ctrl_writel(cam_phy_ctrl, OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Will fix.

Quoted 6 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 196

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+       }
+
+       csi2_ddrclk_khz = pipe->external_rate / 1000
+               / (2 * csi2->phy->num_data_lanes)
+               * pipe->external_bpp;
Quoted 7 lines

Can you please explain how did you came up with this formula?

For example, if I keep the pixel_rate, yet I change the number of lanes my sensor is using,
this result is unaltered, as phy->num_data_lanes is always equal to the maximum number
of lanes available in the interface. (for OMAP4, that's 4 datalanes for CSI2-A).

The number of lanes is specified in the board code (in the future, DT) and is thus specific to the board. The clock rate is per-lane whereas the pipe->external_rate is the total pixel rate on all lanes.

Quoted 4 lines

Meanwhile, in theory, if I keep the same pixels per second, and use less datalanes, the
DDR frequency should at least double.

Quoted 8 lines
Quoted 2 lines

Now, this brings me to another question, How can the sensor tell how many lanes is using from the total?

We might consider making the number of lanes used dynamic but that's currently static. I can't think of any major benefits right now in making this dynamically configurable.

Does this answer to your questions? :-)

Sorry, I think I didn't made my point clear properly, so I'm proposing a patch to
expose and fix this wrong calculation i'm telling you about:

<<<<<<<< PATCH START
From: Sergio Aguirre <[email protected]>
Date: Sat, 11 Feb 2012 10:53:01 -0600
Subject: [PATCH] omap3isp: phy: get ddrclk based on sensor lanecount

This will allow csi2_ddrclk_khz be calculated correctly, by observing the sensor lane count, and not the interface lane count.

An example of erratic calculation is, if you have a sensor which only has 1 data lane for output, yet the interface has 2 lanes available, the rate still is split in half:

pixel_rate = 96000000
bpp = 10
sensor_data_lanes = 1
phy_data_lanes = 2

Current formula pretty much says:

csi2_ddrclk_khz = pixel_rate / 1000
               / (2 * phy_data_lanes)
               * bpp;

Explained is:

bits/second(bps) = pixels/second(pixel_rate) * bits/pixel(bpp) cycles/second(Hz) = bits/second / 2 bits/cycle cycles/datalane = cycles/second / num

Which is you use 2 in last line, would be wrong for a single datalane sensor, so this patch attemote to collect the sensor lane count, and use that instead in the formula.

NOTE: This is tested on omap4iss driver, which is in development.

---
 drivers/media/video/omap3isp/ispcsiphy.c |   41 ++++++++++++++++-------------- drivers/media/video/omap3isp/ispcsiphy.h |    3 +-

 2 files changed, 24 insertions(+), 20 deletions(-)
drivers/media/video/omap3isp/ispcsiphy.c +1 -1
index 5d7a6ab..03c5749 100644
@@ -47,7 +47,7 @@ static void csiphy_lanes_config(struct isp_csiphy *phy)
 
        reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG);
 
-       for (i = 0; i < phy->num_data_lanes; i++) {
+       for (i = 0; i < phy->max_data_lanes; i++) {

               reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) | ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1)); reg |= (phy->lanes.data[i].pol <<

drivers/media/video/omap3isp/ispcsiphy.c +1 -15
@@ -191,22 +191,8 @@ int omap3isp_csiphy_config(struct isp_device *isp,
                            + OMAP3630_CONTROL_CAMERA_PHY_CTRL);
        }
 
-       csi2_ddrclk_khz = pipe->external_rate / 1000
-               / (2 * csi2->phy->num_data_lanes)
-               * pipe->external_bpp;
-
-       /*
-        * THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1.
-        * THS_SETTLE: Programmed value = ceil(90 ns/DDRClk period) + 3.
-        */
-       csi2phy.ths_term = DIV_ROUND_UP(25 * csi2_ddrclk_khz, 2000000) - 1;
-       csi2phy.ths_settle = DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3;
-       csi2phy.tclk_term = TCLK_TERM;
-       csi2phy.tclk_miss = TCLK_MISS;
-       csi2phy.tclk_settle = TCLK_SETTLE;
-
        /* Clock and data lanes verification */
-       for (i = 0; i < csi2->phy->num_data_lanes; i++) {
+       for (i = 0; i < csi2->phy->max_data_lanes; i++) {
                if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3)
                        return -EINVAL;
 

drivers/media/video/omap3isp/ispcsiphy.c int omap3isp_csiphy_config(struct isp_device *isp, · line 206

Quoted 8 lines
drivers/media/video/omap3isp/ispcsiphy.c +2 -1
@@ -214,14 +200,29 @@ int omap3isp_csiphy_config(struct isp_device *isp,
                        return -EINVAL;
 
                used_lanes |= 1 << lanes->data[i].pos;
+               csi2->phy->used_data_lanes++;
        }
 
-       if (lanes->clk.pol > 1 || lanes->clk.pos > 3)
+       if (lanes->clk.pol > 1 || lanes->clk.pos > csi2->phy->max_data_lanes)

Oops, above should be:

      if (lanes->clk.pol > 1 || lanes->clk.pos >
(csi2->phy->max_data_lanes + 1))

To correctly allow a position in between 1 and 3, as there's 3 lanes in total, 1 for clock and max_data_lanes for data.

Apologies for the confusion

Regards,
Sergio

Quoted 72 lines
drivers/media/video/omap3isp/ispcsiphy.c +18 -2
                return -EINVAL;
 
        if (lanes->clk.pos == 0 || used_lanes & (1 << lanes->clk.pos))
                return -EINVAL;
 
+       csi2_ddrclk_khz = pipe->external_rate / 1000
+               / (2 * csi2->phy->used_data_lanes)
+               * pipe->external_bpp;
+
+       /*
+        * THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1.
+        * THS_SETTLE: Programmed value = ceil(90 ns/DDRClk period) + 3.
+        */
+       csi2phy.ths_term = DIV_ROUND_UP(25 * csi2_ddrclk_khz, 2000000) - 1;
+       csi2phy.ths_settle = DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3;
+       csi2phy.tclk_term = TCLK_TERM;
+       csi2phy.tclk_miss = TCLK_MISS;
+       csi2phy.tclk_settle = TCLK_SETTLE;
+
        mutex_lock(&csi2->phy->mutex);
        csi2->phy->dphy = csi2phy;
        csi2->phy->lanes = *lanes;
@@ -287,7 +288,8 @@ int omap3isp_csiphy_init(struct isp_device *isp)
 
        phy2->isp = isp;
        phy2->csi2 = &isp->isp_csi2a;
-       phy2->num_data_lanes = ISP_CSIPHY2_NUM_DATA_LANES;
+       phy2->max_data_lanes = ISP_CSIPHY2_NUM_DATA_LANES;
+       phy2->used_data_lanes = 0;
        phy2->cfg_regs = OMAP3_ISP_IOMEM_CSI2A_REGS1;
        phy2->phy_regs = OMAP3_ISP_IOMEM_CSIPHY2;
        mutex_init(&phy2->mutex);
@@ -295,7 +297,8 @@ int omap3isp_csiphy_init(struct isp_device *isp)
        if (isp->revision == ISP_REVISION_15_0) {
                phy1->isp = isp;
                phy1->csi2 = &isp->isp_csi2c;
-               phy1->num_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES;
+               phy1->max_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES;
+               phy1->used_data_lanes = 0;
                phy1->cfg_regs = OMAP3_ISP_IOMEM_CSI2C_REGS1;
                phy1->phy_regs = OMAP3_ISP_IOMEM_CSIPHY1;
                mutex_init(&phy1->mutex);
drivers/media/video/omap3isp/ispcsiphy.h +2 -2
index a404b10..3401bbd 100644
@@ -51,7 +51,8 @@ struct isp_csiphy {
        unsigned int cfg_regs;
        unsigned int phy_regs;
 
-       u8 num_data_lanes;      /* number of CSI2 Data Lanes supported */
+       u8 max_data_lanes;      /* number of CSI2 Data Lanes supported */
+       u8 used_data_lanes;     /* number of CSI2 Data Lanes used */
        struct isp_csiphy_lanes_cfg lanes;
        struct isp_csiphy_dphy_cfg dphy;
  };
--

1.7.7.4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

PATCH END

I hope this clarifies my point.

Regards,
Sergio

Quoted 6 lines

Kind regards,

--
Sakari Ailus
[email protected]

#41 lore raw

Re: [PATCH v2 27/31] omap3isp: Configure CSI-2 phy based on platform data

Hi Sergio,

Quoted 138 lines · Sergio
Quoted 137 lines · Sergio

Hi Sakari,

Quoted 134 lines · Sakari Ailus

Hi Sergio,

Thanks for the review!

Quoted 91 lines · Sergio
Quoted 78 lines · Sakari Ailus

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/ispcsi2.c   |   10 +++-
 drivers/media/video/omap3isp/ispcsiphy.c |   78 ++++++++++++++++++++++++++----
 drivers/media/video/omap3isp/ispcsiphy.h |    2 +
 3 files changed, 78 insertions(+), 12 deletions(-)
drivers/media/video/omap3isp/ispcsi2.c +8 -2
index 9313f7c..e2e3d63 100644
@@ -1068,7 +1068,13 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
       struct isp_video *video_out = &csi2->video_out;
 
       switch (enable) {
-       case ISP_PIPELINE_STREAM_CONTINUOUS:
+       case ISP_PIPELINE_STREAM_CONTINUOUS: {
+               int ret;
+
+               ret = omap3isp_csiphy_config(isp, sd);
+               if (ret < 0)
+                       return ret;
+
               if (omap3isp_csiphy_acquire(csi2->phy) < 0)
                       return -ENODEV;
               csi2->use_fs_irq = pipe->do_propagation;
@@ -1092,7 +1098,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
               csi2_if_enable(isp, csi2, 1);
               isp_video_dmaqueue_flags_clr(video_out);
               break;
-
+       }
       case ISP_PIPELINE_STREAM_STOPPED:
               if (csi2->state == ISP_PIPELINE_STREAM_STOPPED)
                       return 0;
drivers/media/video/omap3isp/ispcsiphy.c +17 -3
index 5be37ce..5d7a6ab 100644
@@ -28,6 +28,8 @@
 #include <linux/device.h>
 #include <linux/regulator/consumer.h>
 
+#include "../../../../arch/arm/mach-omap2/control.h"
+
 #include "isp.h"
 #include "ispreg.h"
 #include "ispcsiphy.h"
@@ -138,15 +140,73 @@ static void csiphy_dphy_config(struct isp_csiphy *phy)
       isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
 }
 
-static int csiphy_config(struct isp_csiphy *phy,
-                        struct isp_csiphy_dphy_cfg *dphy,
-                        struct isp_csiphy_lanes_cfg *lanes)
+/*
+ * TCLK values are OK at their reset values
+ */
+#define TCLK_TERM      0
+#define TCLK_MISS      1
+#define TCLK_SETTLE    14
+
+int omap3isp_csiphy_config(struct isp_device *isp,
+                          struct v4l2_subdev *csi2_subdev)
 {
+       struct isp_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
+       struct isp_pipeline *pipe = to_isp_pipeline(&csi2_subdev->entity);
+       struct isp_v4l2_subdevs_group *subdevs = pipe->external->host_priv;
+       struct isp_csiphy_dphy_cfg csi2phy;
+       int csi2_ddrclk_khz;
+       struct isp_csiphy_lanes_cfg *lanes;
       unsigned int used_lanes = 0;
       unsigned int i;
 

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 171

Quoted 10 lines
drivers/media/video/omap3isp/ispcsiphy.c +10 -0
+       if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
+           || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+               lanes = &subdevs->bus.ccp2.lanecfg;
+       else
+               lanes = &subdevs->bus.csi2.lanecfg;
+
+       /* FIXME: Do 34xx / 35xx require something here? */
+       if (cpu_is_omap3630()) {
+               u32 cam_phy_ctrl = omap_readl(
+                       OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL);

How about:

Quoted 2 lines
              u32 cam_phy_ctrl = omap_ctrl_readl(OMAP3630_CONTROL_CAMERA_PHY_CTRL);

?

Fine for me.

Quoted 12 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 182

Quoted 11 lines
drivers/media/video/omap3isp/ispcsiphy.c +11 -0
+
+               /*
+                * SCM.CONTROL_CAMERA_PHY_CTRL
+                * - bit[4]    : CSIPHY1 data sent to CSIB
+                * - bit [3:2] : CSIPHY1 config: 00 d-phy, 01/10 ccp2
+                * - bit [1:0] : CSIPHY2 config: 00 d-phy, 01/10 ccp2
+                */
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1)
+                       cam_phy_ctrl |= 1 << 2;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2C_PHY1)
+                       cam_phy_ctrl &= 1 << 2;
Quoted 3 lines

Shouldn't this be:

                       cam_phy_ctrl &= ~(1 << 2);

?

Probably yes. This has come directly as it was in the original board code and might not be entirely correct. It works on the N9 at least.

Quoted 14 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 187

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+
+               if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
+                       cam_phy_ctrl |= 1;
+               else if (subdevs->interface == ISP_INTERFACE_CSI2A_PHY2)
+                       cam_phy_ctrl &= 1;

... and:

                       cam_phy_ctrl &= ~1;
Quoted 4 lines
drivers/media/video/omap3isp/ispcsiphy.c +4 -0
+
+               omap_writel(cam_phy_ctrl,
+                           OMAP343X_CTRL_BASE
+                           + OMAP3630_CONTROL_CAMERA_PHY_CTRL);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Again:

              omap_ctrl_writel(cam_phy_ctrl, OMAP3630_CONTROL_CAMERA_PHY_CTRL);

Will fix.

Actually not. omap_ctrl_writel() is defined in mach/control.c but it's not exported, which I believe is correct. Accessing these registers in the ISP driver is a bit of a hack, and should be eventually replaced by a proper solution. My understanding is that such is in preparation.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines

drivers/media/video/omap3isp/ispcsiphy.c static void csiphy_dphy_config(struct isp_csiphy *phy) · line 196

Quoted 5 lines
drivers/media/video/omap3isp/ispcsiphy.c +5 -0
+       }
+
+       csi2_ddrclk_khz = pipe->external_rate / 1000
+               / (2 * csi2->phy->num_data_lanes)
+               * pipe->external_bpp;
Quoted 7 lines

Can you please explain how did you came up with this formula?

For example, if I keep the pixel_rate, yet I change the number of lanes my sensor is using,
this result is unaltered, as phy->num_data_lanes is always equal to the maximum number
of lanes available in the interface. (for OMAP4, that's 4 datalanes for CSI2-A).

The number of lanes is specified in the board code (in the future, DT) and is thus specific to the board. The clock rate is per-lane whereas the pipe->external_rate is the total pixel rate on all lanes.

Quoted 6 lines

Meanwhile, in theory, if I keep the same pixels per second, and use less datalanes, the
DDR frequency should at least double.

Now, this brings me to another question, How can the sensor tell how many lanes is using from the total?

We might consider making the number of lanes used dynamic but that's currently static. I can't think of any major benefits right now in making this dynamically configurable.

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

Does this answer to your questions? :-)

Sorry, I think I didn't made my point clear properly, so I'm proposing a patch to
expose and fix this wrong calculation i'm telling you about:

Right; I thought this information already was there but it was the number of lanes related to the CSI-2 interface instead.

Quoted 91 lines
Quoted 80 lines

<<<<<<<< PATCH START
From: Sergio Aguirre <[email protected]>
Date: Sat, 11 Feb 2012 10:53:01 -0600
Subject: [PATCH] omap3isp: phy: get ddrclk based on sensor lanecount

This will allow csi2_ddrclk_khz be calculated correctly, by observing the sensor lane count, and not the interface lane count.

An example of erratic calculation is, if you have a sensor which only has 1 data lane for output, yet the interface has 2 lanes available, the rate still is split in half:

pixel_rate = 96000000
bpp = 10
sensor_data_lanes = 1
phy_data_lanes = 2

Current formula pretty much says:

csi2_ddrclk_khz = pixel_rate / 1000
/ (2 * phy_data_lanes)
* bpp;

Explained is:

bits/second(bps) = pixels/second(pixel_rate) * bits/pixel(bpp) cycles/second(Hz) = bits/second / 2 bits/cycle cycles/datalane = cycles/second / num

Which is you use 2 in last line, would be wrong for a single datalane sensor, so this patch attemote to collect the sensor lane count, and use that instead in the formula.

NOTE: This is tested on omap4iss driver, which is in development.

---
 drivers/media/video/omap3isp/ispcsiphy.c |   41 ++++++++++++++++--------------
 drivers/media/video/omap3isp/ispcsiphy.h |    3 +-
 2 files changed, 24 insertions(+), 20 deletions(-)
drivers/media/video/omap3isp/ispcsiphy.c +2 -16
index 5d7a6ab..03c5749 100644
@@ -47,7 +47,7 @@ static void csiphy_lanes_config(struct isp_csiphy *phy)
 
       reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG);
 
-       for (i = 0; i < phy->num_data_lanes; i++) {
+       for (i = 0; i < phy->max_data_lanes; i++) {
               reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
                        ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
               reg |= (phy->lanes.data[i].pol <<
@@ -191,22 +191,8 @@ int omap3isp_csiphy_config(struct isp_device *isp,
                           + OMAP3630_CONTROL_CAMERA_PHY_CTRL);
       }
 
-       csi2_ddrclk_khz = pipe->external_rate / 1000
-               / (2 * csi2->phy->num_data_lanes)
-               * pipe->external_bpp;
-
-       /*
-        * THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1.
-        * THS_SETTLE: Programmed value = ceil(90 ns/DDRClk period) + 3.
-        */
-       csi2phy.ths_term = DIV_ROUND_UP(25 * csi2_ddrclk_khz, 2000000) - 1;
-       csi2phy.ths_settle = DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3;
-       csi2phy.tclk_term = TCLK_TERM;
-       csi2phy.tclk_miss = TCLK_MISS;
-       csi2phy.tclk_settle = TCLK_SETTLE;
-
       /* Clock and data lanes verification */
-       for (i = 0; i < csi2->phy->num_data_lanes; i++) {
+       for (i = 0; i < csi2->phy->max_data_lanes; i++) {
               if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3)
                       return -EINVAL;
 

drivers/media/video/omap3isp/ispcsiphy.c int omap3isp_csiphy_config(struct isp_device *isp, · line 206

Quoted 8 lines
drivers/media/video/omap3isp/ispcsiphy.c +2 -1
@@ -214,14 +200,29 @@ int omap3isp_csiphy_config(struct isp_device *isp,
                       return -EINVAL;
 
               used_lanes |= 1 << lanes->data[i].pos;
+               csi2->phy->used_data_lanes++;
       }
 
-       if (lanes->clk.pol > 1 || lanes->clk.pos > 3)
+       if (lanes->clk.pol > 1 || lanes->clk.pos > csi2->phy->max_data_lanes)

Oops, above should be:

Quoted 7 lines
       if (lanes->clk.pol > 1 || lanes->clk.pos >

(csi2->phy->max_data_lanes + 1))

To correctly allow a position in between 1 and 3, as there's 3 lanes in total, 1 for clock and max_data_lanes for data.

Apologies for the confusion

After looking at the code for CSI2 phy configuration previously, I decided it needed a cleanup. I'll send a fixed patch later on.

Cheers,

Signature · 2 lines
Sakari Ailus
[email protected]
#42 lore raw

PATCH 1/1 omap3isp: Configure CSI-2 phy based on platform data

In reply to Aguirre, Sergio

From: Sakari Ailus <[email protected]>

Configure CSI-2 phy based on platform data in the ISP driver. For that, the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same was configured from the board code.

---
 drivers/media/video/omap3isp/isp.h       |    3 -
 drivers/media/video/omap3isp/ispcsiphy.c |  168 +++++++++++++++++-------------
 drivers/media/video/omap3isp/ispcsiphy.h |   10 --
 3 files changed, 97 insertions(+), 84 deletions(-)
drivers/media/video/omap3isp/isp.h +0 -3
index 8b0bc2d..43a1b16 100644
@@ -126,9 +126,6 @@ struct isp_reg {
 
 struct isp_platform_callback {
 	u32 (*set_xclk)(struct isp_device *isp, u32 xclk, u8 xclksel);
-	int (*csiphy_config)(struct isp_csiphy *phy,
-			     struct isp_csiphy_dphy_cfg *dphy,
-			     struct isp_csiphy_lanes_cfg *lanes);
 	void (*set_pixel_clock)(struct isp_device *isp, unsigned int pixelclk);
 };
 
drivers/media/video/omap3isp/ispcsiphy.c +97 -71

210 lines not on this page · raw message

drivers/media/video/omap3isp/ispcsiphy.h +0 -10
index e93a661..14551fd 100644
@@ -32,14 +32,6 @@
 struct isp_csi2_device;
 struct regulator;
 
-struct isp_csiphy_dphy_cfg {
-	u8 ths_term;
-	u8 ths_settle;
-	u8 tclk_term;
-	unsigned tclk_miss:1;
-	u8 tclk_settle;
-};
-
 struct isp_csiphy {
 	struct isp_device *isp;
 	struct mutex mutex;	/* serialize csiphy configuration */
@@ -52,8 +44,6 @@ struct isp_csiphy {
 	unsigned int phy_regs;
 
 	u8 num_data_lanes;	/* number of CSI2 Data Lanes supported */
-	struct isp_csiphy_lanes_cfg lanes;
-	struct isp_csiphy_dphy_cfg dphy;
 };
 
 int omap3isp_csiphy_acquire(struct isp_csiphy *phy);
Signature · 1 line
1.7.2.5
#43 lore raw

PATCH v2 28/31 omap3isp: Add resizer data rate configuration to resizer_set_stream

In reply to Sakari Ailus
---
 drivers/media/video/omap3isp/ispresizer.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/media/video/omap3isp/ispresizer.c +4 -0
index 6ce2349..81e1bc4 100644
@@ -1147,9 +1147,13 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable)
 	struct device *dev = to_device(res);
 
 	if (res->state == ISP_PIPELINE_STREAM_STOPPED) {
+		struct isp_pipeline *pipe = to_isp_pipeline(&sd->entity);
+
 		if (enable == ISP_PIPELINE_STREAM_STOPPED)
 			return 0;
 
+		omap3isp_resizer_max_rate(res, &pipe->max_rate);
+
 		omap3isp_subclk_enable(isp, OMAP3_ISP_SUBCLK_RESIZER);
 		resizer_configure(res);
 		resizer_print_status(res);
Signature · 1 line
1.7.2.5
#44 lore raw

PATCH v2 29/31 omap3isp: Remove isp_validate_pipeline and other old stuff

In reply to Sakari Ailus

Remove isp_set_pixel_clock().

Remove set_pixel_clock() callback from platform callbacks since the same information is now passed to the ISP driver by other means.

Remove struct ispccdc_vp since the only field in this structure, pixelclk, is no longer used.

Remove isp_video_is_shiftable() --- this will live on as ccdc_is_shiftable in ispccdc.c.

Remove isp_video_validate_pipeline(). Pipeline validation is now split into appropriate subdevs, so this can be removed.

---
 drivers/media/video/omap3isp/isp.c      |   14 ---
 drivers/media/video/omap3isp/ispccdc.h  |   10 --
 drivers/media/video/omap3isp/ispvideo.c |  139 -------------------------------
 3 files changed, 0 insertions(+), 163 deletions(-)
drivers/media/video/omap3isp/isp.c +0 -14
index ae67f49..ea34075 100644
@@ -329,19 +329,6 @@ void omap3isp_configure_bridge(struct isp_device *isp,
 	isp_reg_writel(isp, ispctrl_val, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL);
 }
 
-/**
- * isp_set_pixel_clock - Configures the ISP pixel clock
- * @isp: OMAP3 ISP device
- * @pixelclk: Average pixel clock in Hz
- *
- * Set the average pixel clock required by the sensor. The ISP will use the
- * lowest possible memory bandwidth settings compatible with the clock.
- **/
-static void isp_set_pixel_clock(struct isp_device *isp, unsigned int pixelclk)
-{
-	isp->isp_ccdc.vpcfg.pixelclk = pixelclk;
-}
-
 void omap3isp_hist_dma_done(struct isp_device *isp)
 {
 	if (omap3isp_ccdc_busy(&isp->isp_ccdc) ||
@@ -2118,7 +2105,6 @@ static int isp_probe(struct platform_device *pdev)
 
 	isp->autoidle = autoidle;
 	isp->platform_cb.set_xclk = isp_set_xclk;
-	isp->platform_cb.set_pixel_clock = isp_set_pixel_clock;
 
 	mutex_init(&isp->isp_mutex);
 	spin_lock_init(&isp->stat_lock);
drivers/media/video/omap3isp/ispccdc.h +0 -10
index 6d0264b..e570abe 100644
@@ -80,14 +80,6 @@ struct ispccdc_syncif {
 	u8 bt_r656_en;
 };
 
-/*
- * struct ispccdc_vp - Structure for Video Port parameters
- * @pixelclk: Input pixel clock in Hz
- */
-struct ispccdc_vp {
-	unsigned int pixelclk;
-};
-
 enum ispccdc_lsc_state {
 	LSC_STATE_STOPPED = 0,
 	LSC_STATE_STOPPING = 1,
@@ -161,7 +153,6 @@ struct ispccdc_lsc {
  * @update: Bitmask of controls to update during the next interrupt
  * @shadow_update: Controls update in progress by userspace
  * @syncif: Interface synchronization configuration
- * @vpcfg: Video port configuration
  * @underrun: A buffer underrun occurred and a new buffer has been queued
  * @state: Streaming state
  * @lock: Serializes shadow_update with interrupt handler
@@ -190,7 +181,6 @@ struct isp_ccdc_device {
 	unsigned int shadow_update;
 
 	struct ispccdc_syncif syncif;
-	struct ispccdc_vp vpcfg;
 
 	unsigned int underrun:1;
 	enum isp_pipeline_stream_state state;
drivers/media/video/omap3isp/ispvideo.c +0 -139

157 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#45 lore raw

PATCH v2 30/31 smiapp: Add driver.

In reply to Sakari Ailus

From: Sakari Ailus <[email protected]>

Add driver for SMIA++/SMIA image sensors. The driver exposes the sensor as three subdevs, pixel array, binner and scaler --- in case the device has a scaler.

Currently it relies on the board code for external clock handling. There is no fast way out of this dependency before the ISP drivers (omap3isp) among others will be able to export that clock through the clock framework instead.

---
 drivers/media/video/Kconfig                  |    2 +
 drivers/media/video/Makefile                 |    1 +
 drivers/media/video/smiapp/Kconfig           |   12 +
 drivers/media/video/smiapp/Makefile          |    3 +
 drivers/media/video/smiapp/smiapp-core.c     | 2729 ++++++++++++++++++++++++++
 drivers/media/video/smiapp/smiapp-debug.h    |   32 +
 drivers/media/video/smiapp/smiapp-limits.c   |  132 ++
 drivers/media/video/smiapp/smiapp-limits.h   |  128 ++
 drivers/media/video/smiapp/smiapp-pll.c      |  581 ++++++
 drivers/media/video/smiapp/smiapp-quirk.c    |  264 +++
 drivers/media/video/smiapp/smiapp-quirk.h    |   72 +
 drivers/media/video/smiapp/smiapp-reg-defs.h |  503 +++++
 drivers/media/video/smiapp/smiapp-reg.h      |  122 ++
 drivers/media/video/smiapp/smiapp-regs.c     |  230 +++
 drivers/media/video/smiapp/smiapp-regs.h     |   46 +
 drivers/media/video/smiapp/smiapp.h          |  268 +++
 include/media/smiapp.h                       |   83 +
 17 files changed, 5208 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/smiapp/Kconfig
 create mode 100644 drivers/media/video/smiapp/Makefile
 create mode 100644 drivers/media/video/smiapp/smiapp-core.c
 create mode 100644 drivers/media/video/smiapp/smiapp-debug.h
 create mode 100644 drivers/media/video/smiapp/smiapp-limits.c
 create mode 100644 drivers/media/video/smiapp/smiapp-limits.h
 create mode 100644 drivers/media/video/smiapp/smiapp-pll.c
 create mode 100644 drivers/media/video/smiapp/smiapp-quirk.c
 create mode 100644 drivers/media/video/smiapp/smiapp-quirk.h
 create mode 100644 drivers/media/video/smiapp/smiapp-reg-defs.h
 create mode 100644 drivers/media/video/smiapp/smiapp-reg.h
 create mode 100644 drivers/media/video/smiapp/smiapp-regs.c
 create mode 100644 drivers/media/video/smiapp/smiapp-regs.h
 create mode 100644 drivers/media/video/smiapp/smiapp.h
 create mode 100644 include/media/smiapp.h
drivers/media/video/Kconfig +2 -0
index 9adada0..6033cff 100644
@@ -524,6 +524,8 @@ config VIDEO_S5K6AA
 	  This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M
 	  camera sensor with an embedded SoC image signal processor.
 
+source "drivers/media/video/smiapp/Kconfig"
+
 comment "Flash devices"
 
 config VIDEO_ADP1653
drivers/media/video/Makefile +1 -0
index 3541388..e4c9e16 100644
@@ -73,6 +73,7 @@ obj-$(CONFIG_VIDEO_SR030PC30)	+= sr030pc30.o
 obj-$(CONFIG_VIDEO_NOON010PC30)	+= noon010pc30.o
 obj-$(CONFIG_VIDEO_M5MOLS)	+= m5mols/
 obj-$(CONFIG_VIDEO_S5K6AA)	+= s5k6aa.o
+obj-$(CONFIG_VIDEO_SMIAPP)	+= smiapp/
 obj-$(CONFIG_VIDEO_ADP1653)	+= adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)	+= as3645a.o
 
drivers/media/video/smiapp/Kconfig new file +12 -0
new file mode 100644
index 0000000..3f98e8e
@@ -0,0 +1,12 @@
+config VIDEO_SMIAPP
+	tristate "SMIA++/SMIA sensor support"
+	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
+	---help---
+	  This is a generic driver for SMIA++/SMIA camera modules.
+
+config VIDEO_SMIAPP_DEBUG
+	bool "Enable debugging for the generic SMIA++/SMIA driver"
+	depends on VIDEO_SMIAPP
+	---help---
+	  Enable debugging output in the generic SMIA++/SMIA driver. If you
+	  are developing the driver you might want to enable this.
drivers/media/video/smiapp/Makefile new file +3 -0
new file mode 100644
index 0000000..83dc0d1
@@ -0,0 +1,3 @@
+smiapp-objs			+= smiapp-core.o smiapp-regs.o smiapp-pll.o \
+				   smiapp-quirk.o smiapp-limits.o
+obj-$(CONFIG_VIDEO_SMIAPP)	+= smiapp.o
drivers/media/video/smiapp/smiapp-core.c new file +2729 -0

2,729 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-debug.h new file +32 -0
new file mode 100644
index 0000000..011bf53
@@ -0,0 +1,32 @@
+/*
+ * drivers/media/video/smiapp-debug.h
+ *
+ * Generic driver for SMIA/SMIA++ compliant camera modules
+ *
+ * Copyright (C) 2011--2012 Nokia Corporation
+ * Contact: Sakari Ailus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef SMIAPP_DEBUG_H
+#define SMIAPP_DEBUG_H
+
+#ifdef CONFIG_VIDEO_SMIAPP_DEBUG
+#define DEBUG
+#endif
+
+#endif
drivers/media/video/smiapp/smiapp-limits.c new file +132 -0

132 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-limits.h new file +128 -0

77 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-pll.c new file +581 -0

581 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-quirk.c new file +264 -0

264 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-quirk.h new file +72 -0

72 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-reg-defs.h new file +503 -0

503 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-reg.h new file +122 -0

122 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-regs.c new file +230 -0

230 lines not on this page · raw message

drivers/media/video/smiapp/smiapp-regs.h new file +46 -0

46 lines not on this page · raw message

drivers/media/video/smiapp/smiapp.h new file +268 -0

268 lines not on this page · raw message

include/media/smiapp.h new file +83 -0

83 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.2.5

Part of the diff is not shown here. View the raw message.

#46 lore raw

PATCH v2 31/31 rm680: Add camera init

In reply to Sakari Ailus

From: Sakari Ailus <[email protected]>

This currently introduces an extra file to the arch/arm/mach-omap2
directory: board-rm680-camera.c. Keeping the device tree in mind, the context of the file could be represented as static data with one exception:
the external clock to the sensor.

This external clock is provided by the OMAP 3 SoC and required by the sensor. The issue is that the clock originates from the ISP and not from PRCM block as the other clocks and thus is not supported by the clock framework. Otherwise the sensor driver could just clk_get() and clk_enable() it, just like the regulators and gpios.

---
 arch/arm/mach-omap2/Makefile             |    3 +-
 arch/arm/mach-omap2/board-rm680-camera.c |  375 ++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/board-rm680.c        |   38 +++
 3 files changed, 415 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-rm680-camera.c
arch/arm/mach-omap2/Makefile +2 -1
index fc9b238..f92cc92 100644
@@ -206,7 +206,8 @@ obj-$(CONFIG_MACH_OMAP3_PANDORA)	+= board-omap3pandora.o
 obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o
 obj-$(CONFIG_MACH_NOKIA_N8X0)		+= board-n8x0.o
 obj-$(CONFIG_MACH_NOKIA_RM680)		+= board-rm680.o \
-					   sdram-nokia.o
+					   sdram-nokia.o \
+					   board-rm680-camera.o
 obj-$(CONFIG_MACH_NOKIA_RX51)		+= board-rx51.o \
 					   sdram-nokia.o \
 					   board-rx51-peripherals.o \
arch/arm/mach-omap2/board-rm680-camera.c new file +375 -0

375 lines not on this page · raw message

arch/arm/mach-omap2/board-rm680.c +38 -0
index fdeef9b..75d6d94 100644
@@ -66,6 +66,39 @@ static struct platform_device rm680_vemmc_device = {
 	},
 };
 
+#define REGULATOR_INIT_DATA(_name, _min, _max, _apply, _ops_mask) \
+	static struct regulator_init_data _name##_data = { \
+		.constraints = { \
+			.name                   = #_name, \
+			.min_uV                 = _min, \
+			.max_uV                 = _max, \
+			.apply_uV               = _apply, \
+			.valid_modes_mask       = REGULATOR_MODE_NORMAL | \
+						REGULATOR_MODE_STANDBY, \
+			.valid_ops_mask         = _ops_mask, \
+		}, \
+		.num_consumer_supplies  = ARRAY_SIZE(_name##_consumers), \
+		.consumer_supplies      = _name##_consumers, \
+}
+#define REGULATOR_INIT_DATA_FIXED(_name, _voltage) \
+	REGULATOR_INIT_DATA(_name, _voltage, _voltage, true, \
+				REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE)
+
+static struct regulator_consumer_supply rm680_vaux2_consumers[] = {
+	REGULATOR_SUPPLY("VDD_CSIPHY1", "omap3isp"),	/* OMAP ISP */
+	REGULATOR_SUPPLY("VDD_CSIPHY2", "omap3isp"),	/* OMAP ISP */
+	REGULATOR_SUPPLY("vaux2", NULL),
+};
+REGULATOR_INIT_DATA_FIXED(rm680_vaux2, 1800000);
+
+static struct regulator_consumer_supply rm680_vaux3_consumers[] = {
+	REGULATOR_SUPPLY("VANA", "2-0037"),	/* Main Camera Sensor */
+	REGULATOR_SUPPLY("VANA", "2-000e"),	/* Main Camera Lens */
+	REGULATOR_SUPPLY("VANA", "2-0010"),	/* Front Camera */
+	REGULATOR_SUPPLY("vaux3", NULL),
+};
+REGULATOR_INIT_DATA_FIXED(rm680_vaux3, 2800000);
+
 static struct platform_device *rm680_peripherals_devices[] __initdata = {
 	&rm680_vemmc_device,
 };
@@ -82,6 +115,8 @@ static struct twl4030_gpio_platform_data rm680_gpio_data = {
 static struct twl4030_platform_data rm680_twl_data = {
 	.gpio			= &rm680_gpio_data,
 	/* add rest of the children here */
+	.vaux2			= &rm680_vaux2_data,
+	.vaux3			= &rm680_vaux3_data,
 };
 
 static void __init rm680_i2c_init(void)
@@ -129,6 +164,8 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
+void rm680_camera_init(void);
+
 static void __init rm680_init(void)
 {
 	struct omap_sdrc_params *sdrc_params;
@@ -141,6 +178,7 @@ static void __init rm680_init(void)
 
 	usb_musb_init(NULL);
 	rm680_peripherals_init();
+	rm680_camera_init();
 }
 
 MACHINE_START(NOKIA_RM680, "Nokia RM-680 board")
Signature · 1 line
1.7.2.5