aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-21 10:03:53 (GMT)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-23 17:57:52 (GMT)
commitaa973596fd61d4e91f66cf53ab51cbed9042be30 (patch)
tree6815e1ceefb698496f35a1d5d7dcf9941d6f5313
parent2a14f1057ec37923a88dc7dea381299a32a22f7f (diff)
Optimize the logic with sets control values
No need to write all controls when just one changes.
-rw-r--r--src/callbacks.c10
-rw-r--r--src/main.c1
-rw-r--r--src/v4l.c18
-rw-r--r--src/v4l.h1
4 files changed, 5 insertions, 25 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index 0a0ee6c..0b193c8 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -641,35 +641,35 @@ void contrast_change (GtkHScale * sc1, cam * cam)
{
cam->contrast = 256 * (int) gtk_range_get_value ((GtkRange *) sc1);
- set_pic_info (cam);
+ v4l2_set_control(cam->dev, V4L2_CID_CONTRAST, cam->contrast);
}
void brightness_change (GtkHScale * sc1, cam * cam)
{
cam->brightness = 256 * (int) gtk_range_get_value ((GtkRange *) sc1);
- set_pic_info (cam);
+ v4l2_set_control(cam->dev, V4L2_CID_BRIGHTNESS, cam->brightness);
}
void colour_change (GtkHScale * sc1, cam * cam)
{
cam->colour = 256 * (int) gtk_range_get_value ((GtkRange *) sc1);
- set_pic_info (cam);
+ v4l2_set_control(cam->dev, V4L2_CID_SATURATION, cam->colour);
}
void hue_change (GtkHScale * sc1, cam * cam)
{
cam->hue = 256 * (int) gtk_range_get_value ((GtkRange *) sc1);
- set_pic_info (cam);
+ v4l2_set_control(cam->dev, V4L2_CID_HUE, cam->hue);
}
void wb_change (GtkHScale * sc1, cam * cam)
{
cam->whiteness = 256 * (int) gtk_range_get_value ((GtkRange *) sc1);
- set_pic_info (cam);
+ v4l2_set_control(cam->dev, V4L2_CID_WHITENESS, cam->whiteness);
}
void help_cb (GtkWidget * widget, gpointer data)
diff --git a/src/main.c b/src/main.c
index 3380b07..2a2bf90 100644
--- a/src/main.c
+++ b/src/main.c
@@ -221,7 +221,6 @@ main(int argc, char *argv[]) {
/* get picture attributes */
get_pic_info (cam);
- set_pic_info (cam);
bufsize = cam->max_width * cam->max_height * cam->depth / 8;
cam->pic_buf = malloc (bufsize);
diff --git a/src/v4l.c b/src/v4l.c
index f0b44de..b6483a4 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -161,24 +161,6 @@ void camera_cap(cam * cam)
}
}
-void
-set_pic_info(cam* cam) {
- int result;
- unsigned int v4l2_pixfmt;
- struct v4l2_format fmt;
-
- char *msg;
- if(cam->debug) {
- g_message("SET PIC");
- }
-
- v4l2_set_control(cam->dev, V4L2_CID_BRIGHTNESS, cam->brightness);
- v4l2_set_control(cam->dev, V4L2_CID_HUE, cam->hue);
- v4l2_set_control(cam->dev, V4L2_CID_CONTRAST, cam->contrast);
- v4l2_set_control(cam->dev, V4L2_CID_SATURATION, cam->colour);
- v4l2_set_control(cam->dev, V4L2_CID_WHITENESS, cam->whiteness);
-}
-
void get_pic_info(cam * cam){
char *msg;
int i;
diff --git a/src/v4l.h b/src/v4l.h
index 017951f..c0abaa3 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -88,7 +88,6 @@ typedef struct camera {
void camera_cap (cam *);
void set_win_info (cam * cam);
void get_pic_info (cam *);
-void set_pic_info (cam *);
void get_win_info (cam *);
void start_streaming(cam * cam);
void capture_buffers(cam * cam, char *outbuf, int len);

Privacy Policy