All of lore.kernel.org
 help / color / mirror / Atom feed
* [REVIEWv2 PATCH 37/34] v4l2-ctrls: set elem_size for all types handled by std_type_ops
@ 2014-02-15 12:03 Hans Verkuil
  0 siblings, 0 replies; only message in thread
From: Hans Verkuil @ 2014-02-15 12:03 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Ricardo Ribalda Delgado

It makes sense to have elem_size prefilled for types that the control
framework knows about.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 23febc4..bc30c50 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1821,12 +1821,25 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
 		rows = 1;
 	is_matrix = cols > 1 || rows > 1;
 
-	if (type == V4L2_CTRL_TYPE_INTEGER64)
+	/* Prefill elem_size for all types handled by std_type_ops */
+	switch (type) {
+	case V4L2_CTRL_TYPE_INTEGER64:
 		elem_size = sizeof(s64);
-	else if (type == V4L2_CTRL_TYPE_STRING)
+		break;
+	case V4L2_CTRL_TYPE_STRING:
 		elem_size = max + 1;
-	else if (type < V4L2_CTRL_COMPLEX_TYPES)
-		elem_size = sizeof(s32);
+		break;
+	case V4L2_CTRL_TYPE_U8:
+		elem_size = sizeof(u8);
+		break;
+	case V4L2_CTRL_TYPE_U16:
+		elem_size = sizeof(u16);
+		break;
+	default:
+		if (type < V4L2_CTRL_COMPLEX_TYPES)
+			elem_size = sizeof(s32);
+		break;
+	}
 	tot_ctrl_size = elem_size * cols * rows;
 
 	/* Sanity checks */
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-15 12:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-15 12:03 [REVIEWv2 PATCH 37/34] v4l2-ctrls: set elem_size for all types handled by std_type_ops Hans Verkuil

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