diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-15 19:32:27 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-15 19:32:27 +0000 |
commit | 4fd57bbe3fef59592a8664dcc9fa2ab32ae99c69 (patch) | |
tree | 8f41b30e571aa6ed88b53f5471d5e38461136e60 /sys/qcam | |
parent | 9f4226fe55f09cf5809376b467aa3f46dbf7b5c2 (diff) | |
download | gst-plugins-bad-4fd57bbe3fef59592a8664dcc9fa2ab32ae99c69.tar.gz gst-plugins-bad-4fd57bbe3fef59592a8664dcc9fa2ab32ae99c69.tar.bz2 gst-plugins-bad-4fd57bbe3fef59592a8664dcc9fa2ab32ae99c69.zip |
don't mix tabs and spaces
Original commit message from CVS:
don't mix tabs and spaces
Diffstat (limited to 'sys/qcam')
-rw-r--r-- | sys/qcam/dark.c | 104 | ||||
-rw-r--r-- | sys/qcam/exposure.c | 14 | ||||
-rw-r--r-- | sys/qcam/gstqcamsrc.c | 46 | ||||
-rw-r--r-- | sys/qcam/qcam-Linux.c | 14 | ||||
-rw-r--r-- | sys/qcam/qcam-lib.c | 164 | ||||
-rw-r--r-- | sys/qcam/qcam-os.c | 14 |
6 files changed, 179 insertions, 177 deletions
diff --git a/sys/qcam/dark.c b/sys/qcam/dark.c index e15a53c9..416d37bc 100644 --- a/sys/qcam/dark.c +++ b/sys/qcam/dark.c @@ -154,21 +154,21 @@ fixdark (const struct qcam *q, scanbuf * scan) return 0; for (y = 0; y < MAX_HEIGHT; y++) for (x = 0; x < MAX_HEIGHT; x++) - if (master_darkmask1[y][x] < smallest_dm) { - smallest_dm = master_darkmask1[y][x]; + if (master_darkmask1[y][x] < smallest_dm) { + smallest_dm = master_darkmask1[y][x]; #ifdef DEBUG - fprintf (stderr, "Smallest mask is %d at (%d, %d)\n", - smallest_dm, x, y); + fprintf (stderr, "Smallest mask is %d at (%d, %d)\n", + smallest_dm, x, y); #endif - } + } init = 1; } if (brightness < smallest_dm) { #ifdef DEBUG fprintf (stderr, - "Brightness %d (dark current starts at %d), no fixup needed\n", - brightness, smallest_dm); + "Brightness %d (dark current starts at %d), no fixup needed\n", + brightness, smallest_dm); #endif return 1; } @@ -181,16 +181,16 @@ fixdark (const struct qcam *q, scanbuf * scan) for (y = 0; y < max_height; y++) for (x = 0; x < max_width; x++) if (scale == 1) { - darkmask[y][x] = master_darkmask1[y][x]; + darkmask[y][x] = master_darkmask1[y][x]; } else if (scale == 2) { - darkmask[y][x] = master_darkmask2[y][x]; + darkmask[y][x] = master_darkmask2[y][x]; } else if (scale == 4) { - darkmask[y][x] = master_darkmask4[y][x]; + darkmask[y][x] = master_darkmask4[y][x]; } else { #ifdef DEBUG - fprintf (stderr, "Bad transfer_scale in darkmask assignment!\n"); + fprintf (stderr, "Bad transfer_scale in darkmask assignment!\n"); #endif - return 0; + return 0; } do { @@ -202,52 +202,52 @@ fixdark (const struct qcam *q, scanbuf * scan) ccd_x *= 2; ccd_x /= scale; for (x = 0; x < width; x++, ccd_x++) { - val = scan[y * width + x]; - if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */ - new_image[y][x] = val; - } else { /* bad pixel */ - /* look at nearby pixels, average the good values */ - pixelcount = 0; - pixeltotal = 0; - if (x > 0) { /* left */ - if (brightness < darkmask[ccd_y][ccd_x - 1]) { - pixelcount++; - pixeltotal += scan[y * width + x - 1]; - } - } - if (x < width - 1) { /* right */ - if (brightness < darkmask[ccd_y][ccd_x + 1]) { - pixelcount++; - pixeltotal += scan[y * width + x + 1]; - } - } - if (y > 0) { /* above */ - if (brightness < darkmask[ccd_y - 1][ccd_x]) { - pixelcount++; - pixeltotal += scan[(y - 1) * width + x]; - } - } - if (y < height - 1) { /* below */ - if (brightness < darkmask[ccd_y + 1][ccd_x]) { - pixelcount++; - pixeltotal += scan[(y + 1) * width + x]; - } - } + val = scan[y * width + x]; + if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */ + new_image[y][x] = val; + } else { /* bad pixel */ + /* look at nearby pixels, average the good values */ + pixelcount = 0; + pixeltotal = 0; + if (x > 0) { /* left */ + if (brightness < darkmask[ccd_y][ccd_x - 1]) { + pixelcount++; + pixeltotal += scan[y * width + x - 1]; + } + } + if (x < width - 1) { /* right */ + if (brightness < darkmask[ccd_y][ccd_x + 1]) { + pixelcount++; + pixeltotal += scan[y * width + x + 1]; + } + } + if (y > 0) { /* above */ + if (brightness < darkmask[ccd_y - 1][ccd_x]) { + pixelcount++; + pixeltotal += scan[(y - 1) * width + x]; + } + } + if (y < height - 1) { /* below */ + if (brightness < darkmask[ccd_y + 1][ccd_x]) { + pixelcount++; + pixeltotal += scan[(y + 1) * width + x]; + } + } - if (pixelcount == 0) { /* no valid neighbors! */ - again = 1; - } else { - new_image[y][x] = pixeltotal / pixelcount; - /* mark this pixel as valid, so we don't loop forever */ - darkmask[ccd_y][ccd_x] = 255; - } - } + if (pixelcount == 0) { /* no valid neighbors! */ + again = 1; + } else { + new_image[y][x] = pixeltotal / pixelcount; + /* mark this pixel as valid, so we don't loop forever */ + darkmask[ccd_y][ccd_x] = 255; + } + } } } for (y = 0; y < height; y++) for (x = 0; x < width; x++) - scan[y * width + x] = new_image[y][x]; + scan[y * width + x] = new_image[y][x]; } while (loopcount++ < MAX_LOOPS && again); #ifdef DEBUG diff --git a/sys/qcam/exposure.c b/sys/qcam/exposure.c index b63e364f..8f18e488 100644 --- a/sys/qcam/exposure.c +++ b/sys/qcam/exposure.c @@ -223,7 +223,7 @@ qcip_autoexposure (struct qcam *q, scanbuf * scan) /* set target if it has not been explicitly set */ if (luminance_std_target == -1) { - luminance_std_target = q->bpp == 6 ? 10 : 2; + luminance_std_target = q->bpp == 6 ? 10 : 2; } /* Adjust contrast to reach target luminance standard deviation */ @@ -231,15 +231,15 @@ qcip_autoexposure (struct qcam *q, scanbuf * scan) lum_std_max = luminance_std_target + luminance_std_tolerance; if (lum_std < lum_std_min || lum_std > lum_std_max) { - ret = QCIP_XPSR_RSCN; - if (qc_setcontrast (q, - luminance_std_target - lum_std + qc_getcontrast (q))) { - return QCIP_XPSR_ERR; - } + ret = QCIP_XPSR_RSCN; + if (qc_setcontrast (q, + luminance_std_target - lum_std + qc_getcontrast (q))) { + return QCIP_XPSR_ERR; + } } #ifdef DEBUG fprintf (stderr, "Luminance std/target/tolerance: %d/%d/%d\n", - lum_std, luminance_std_target, luminance_std_tolerance); + lum_std, luminance_std_target, luminance_std_tolerance); #endif break; diff --git a/sys/qcam/gstqcamsrc.c b/sys/qcam/gstqcamsrc.c index 0c68ca13..ea6a2c1a 100644 --- a/sys/qcam/gstqcamsrc.c +++ b/sys/qcam/gstqcamsrc.c @@ -73,9 +73,10 @@ gst_autoexp_mode_get_type (void) {AE_NONE, "3", "None"}, {0, NULL, NULL}, }; + if (!autoexp_mode_type) { autoexp_mode_type = - g_enum_register_static ("GstAutoExposureMode", autoexp_modes); + g_enum_register_static ("GstAutoExposureMode", autoexp_modes); } return autoexp_mode_type; } @@ -140,9 +141,10 @@ gst_qcamsrc_get_type (void) (GInstanceInitFunc) gst_qcamsrc_init, NULL }; + qcamsrc_type = - g_type_register_static (GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info, - 0); + g_type_register_static (GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info, + 0); } return qcamsrc_type; } @@ -168,37 +170,37 @@ gst_qcamsrc_class_init (GstQCamSrcClass * klass) g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, g_param_spec_int ("width", "width", "width", - 0, 320, DEF_WIDTH, G_PARAM_READWRITE)); + 0, 320, DEF_WIDTH, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT, g_param_spec_int ("height", "height", "height", - 0, 240, DEF_HEIGHT, G_PARAM_READWRITE)); + 0, 240, DEF_HEIGHT, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BRIGHTNESS, g_param_spec_int ("brightness", "brightness", "brightness", - 0, 255, DEF_BRIGHTNESS, G_PARAM_READWRITE)); + 0, 255, DEF_BRIGHTNESS, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WHITEBAL, g_param_spec_int ("whitebal", "whitebal", "whitebal", - 0, 255, DEF_WHITEBAL, G_PARAM_READWRITE)); + 0, 255, DEF_WHITEBAL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONTRAST, g_param_spec_int ("contrast", "contrast", "contrast", - 0, 255, DEF_CONTRAST, G_PARAM_READWRITE)); + 0, 255, DEF_CONTRAST, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOP, g_param_spec_int ("top", "top", "top", - 0, 240, DEF_TOP, G_PARAM_READWRITE)); + 0, 240, DEF_TOP, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEFT, g_param_spec_int ("left", "left", "left", - 0, 320, DEF_LEFT, G_PARAM_READWRITE)); + 0, 320, DEF_LEFT, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRANSFER_SCALE, g_param_spec_int ("transfer_scale", "transfer_scale", "transfer_scale", - 1, 4, DEF_TRANSFER_SCALE, G_PARAM_READWRITE)); + 1, 4, DEF_TRANSFER_SCALE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEPTH, g_param_spec_int ("depth", "depth", "depth", - 4, 6, DEF_DEPTH, G_PARAM_READWRITE)); + 4, 6, DEF_DEPTH, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT, g_param_spec_int ("port", "port", "port", - 0, G_MAXINT, DEF_PORT, G_PARAM_READWRITE)); + 0, G_MAXINT, DEF_PORT, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AUTOEXP, g_param_spec_enum ("autoexposure", "autoexposure", "autoexposure", - GST_TYPE_AUTOEXP_MODE, DEF_AUTOEXP, G_PARAM_READWRITE)); + GST_TYPE_AUTOEXP_MODE, DEF_AUTOEXP, G_PARAM_READWRITE)); gobject_class->set_property = gst_qcamsrc_set_property; gobject_class->get_property = gst_qcamsrc_get_property; @@ -256,10 +258,10 @@ gst_qcamsrc_get (GstPad * pad) qc_set (qcamsrc->qcam); if (!GST_PAD_CAPS (pad)) { gst_pad_try_set_caps (pad, gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, "I420", - "width", G_TYPE_INT, qcamsrc->qcam->width / scale, - "height", G_TYPE_INT, qcamsrc->qcam->height / scale, - "framerate", G_TYPE_DOUBLE, 10., NULL)); + "format", GST_TYPE_FOURCC, "I420", + "width", G_TYPE_INT, qcamsrc->qcam->width / scale, + "height", G_TYPE_INT, qcamsrc->qcam->height / scale, + "framerate", G_TYPE_DOUBLE, 10., NULL)); } scan = qc_scan (qcamsrc->qcam); @@ -324,7 +326,7 @@ gst_qcamsrc_set_property (GObject * object, guint prop_id, const GValue * value, case ARG_AUTOEXP: src->autoexposure = g_value_get_enum (value); if (src->autoexposure != AE_NONE) - qcip_set_autoexposure_mode (src->autoexposure); + qcip_set_autoexposure_mode (src->autoexposure); break; default: break; @@ -395,8 +397,8 @@ gst_qcamsrc_change_state (GstElement * element) if (!GST_FLAG_IS_SET (element, GST_QCAMSRC_OPEN)) { gst_info ("qcamsrc: opening\n"); if (!gst_qcamsrc_open (GST_QCAMSRC (element))) { - gst_info ("qcamsrc: open failed\n"); - return GST_STATE_FAILURE; + gst_info ("qcamsrc: open failed\n"); + return GST_STATE_FAILURE; } } } @@ -431,7 +433,7 @@ static gboolean plugin_init (GstPlugin * plugin) { if (!gst_element_register (plugin, "qcamsrc", GST_RANK_NONE, - GST_TYPE_QCAMSRC)) + GST_TYPE_QCAMSRC)) return FALSE; return TRUE; diff --git a/sys/qcam/qcam-Linux.c b/sys/qcam/qcam-Linux.c index 2c959e72..41f7046c 100644 --- a/sys/qcam/qcam-Linux.c +++ b/sys/qcam/qcam-Linux.c @@ -82,7 +82,7 @@ int enable_ports (const struct qcam *q) { if (q->port < 0x278) - return 1; /* Better safe than sorry */ + return 1; /* Better safe than sorry */ if (q->port > 0x3bc) return 1; return (ioperm (q->port, 3, 1)); @@ -115,7 +115,7 @@ qc_lock_wait (struct qcam *q, int wait) #if 1 static struct flock sfl; - if (-1 == q->fd) { /* we've yet to open the lock file */ + if (-1 == q->fd) { /* we've yet to open the lock file */ static char lockfile[128]; sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port); @@ -131,7 +131,7 @@ qc_lock_wait (struct qcam *q, int wait) sfl.l_type = F_WRLCK; } #ifdef TESTING - if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */ + if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */ #else if (0 != fcntl (q->fd, wait ? F_SETLKW : F_SETLK, &sfl)) #endif @@ -142,9 +142,9 @@ qc_lock_wait (struct qcam *q, int wait) return 1; fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", - __FILE__, __LINE__, q->fd); + __FILE__, __LINE__, q->fd); - if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */ + if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */ #endif { perror ("fcntl"); @@ -202,7 +202,7 @@ qc_unlock (struct qcam *q) static struct flock sfl; #if 1 - if (-1 == q->fd) { /* port was not locked */ + if (-1 == q->fd) { /* port was not locked */ return 1; } @@ -220,7 +220,7 @@ qc_unlock (struct qcam *q) char lockfile[128]; sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port); - unlink (lockfile); /* What would I do with an error? */ + unlink (lockfile); /* What would I do with an error? */ #endif return 0; diff --git a/sys/qcam/qcam-lib.c b/sys/qcam/qcam-lib.c index e7208cdc..c472e577 100644 --- a/sys/qcam/qcam-lib.c +++ b/sys/qcam/qcam-lib.c @@ -252,8 +252,8 @@ qc_calibrate (struct qcam *q) int count = 0; #endif - qc_command (q, 27); /* AutoAdjustOffset */ - qc_command (q, 0); /* Dummy Parameter, ignored by the camera */ + qc_command (q, 27); /* AutoAdjustOffset */ + qc_command (q, 0); /* Dummy Parameter, ignored by the camera */ /* GetOffset (33) will read 255 until autocalibration */ /* is finished. After that, a value of 1-254 will be */ @@ -294,7 +294,7 @@ qc_init (void) q = malloc (sizeof (struct qcam)); - q->port = 0; /* Port 0 == Autoprobe */ + q->port = 0; /* Port 0 == Autoprobe */ q->port_mode = (QC_ANY | QC_NOTSET); q->width = 160; q->height = 120; @@ -306,11 +306,11 @@ qc_init (void) q->top = 1; q->left = 14; q->mode = -1; - q->fd = -1; /* added initialization of fd member - * BTW, there doesn't seem to be a place to close this fd... - * I think we need a qc_free function. - * - Dave Plonka (plonka@carroll1.cc.edu) - */ + q->fd = -1; /* added initialization of fd member + * BTW, there doesn't seem to be a place to close this fd... + * I think we need a qc_free function. + * - Dave Plonka (plonka@carroll1.cc.edu) + */ return q; } @@ -470,9 +470,9 @@ qc_detect (const struct qcam *q) /* Be liberal in what you accept... */ if (count > 3 && count < 15) - return 1; /* found */ + return 1; /* found */ else - return 0; /* not found */ + return 0; /* not found */ } @@ -498,9 +498,9 @@ qc_reset (struct qcam *q) write_lpdata (q, 0x75); if (read_lpdata (q) != 0x75) { - q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; + q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR; } else { - q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; + q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR; } break; @@ -514,7 +514,7 @@ qc_reset (struct qcam *q) write_lpcontrol (q, 0xb); usleep (250); write_lpcontrol (q, 0xe); - (void) qc_setscanmode (q); /* in case port_mode changed */ + (void) qc_setscanmode (q); /* in case port_mode changed */ } @@ -600,7 +600,7 @@ qc_set (struct qcam *q) } else { val = q->width * q->bpp; val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) * - q->transfer_scale; + q->transfer_scale; } val = (val + val2 - 1) / val2; qc_command (q, 0x13); @@ -639,7 +639,7 @@ qc_readbytes (const struct qcam *q, char buffer[]) } switch (q->port_mode & QC_MODE_MASK) { - case QC_BIDIR: /* Bi-directional Port */ + case QC_BIDIR: /* Bi-directional Port */ write_lpcontrol (q, 0x26); lo = (qc_waithand2 (q, 1) >> 1); hi = (read_lpstatus (q) >> 3) & 0x1f; @@ -647,74 +647,74 @@ qc_readbytes (const struct qcam *q, char buffer[]) lo2 = (qc_waithand2 (q, 0) >> 1); hi2 = (read_lpstatus (q) >> 3) & 0x1f; switch (q->bpp) { - case 4: - buffer[0] = lo & 0xf; - buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3); - buffer[2] = (hi & 0x1e) >> 1; - buffer[3] = lo2 & 0xf; - buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3); - buffer[5] = (hi2 & 0x1e) >> 1; - ret = 6; - break; - case 6: - buffer[0] = lo & 0x3f; - buffer[1] = ((lo & 0x40) >> 6) | (hi << 1); - buffer[2] = lo2 & 0x3f; - buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1); - ret = 4; - break; - default: - fprintf (stderr, "Bad bidir pixel depth %d\n", q->bpp); - ret = -1; - break; + case 4: + buffer[0] = lo & 0xf; + buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3); + buffer[2] = (hi & 0x1e) >> 1; + buffer[3] = lo2 & 0xf; + buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3); + buffer[5] = (hi2 & 0x1e) >> 1; + ret = 6; + break; + case 6: + buffer[0] = lo & 0x3f; + buffer[1] = ((lo & 0x40) >> 6) | (hi << 1); + buffer[2] = lo2 & 0x3f; + buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1); + ret = 4; + break; + default: + fprintf (stderr, "Bad bidir pixel depth %d\n", q->bpp); + ret = -1; + break; } break; - case QC_UNIDIR: /* Unidirectional Port */ + case QC_UNIDIR: /* Unidirectional Port */ write_lpcontrol (q, 6); lo = (qc_waithand (q, 1) & 0xf0) >> 4; write_lpcontrol (q, 0xe); hi = (qc_waithand (q, 0) & 0xf0) >> 4; switch (q->bpp) { - case 4: - buffer[0] = lo; - buffer[1] = hi; - ret = 2; - break; - case 6: - switch (state) { - case 0: - buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); - saved_bits = (hi & 3) << 4; - state = 1; - ret = 1; - break; - case 1: - buffer[0] = lo | saved_bits; - saved_bits = hi << 2; - state = 2; - ret = 1; - break; - case 2: - buffer[0] = ((lo & 0xc) >> 2) | saved_bits; - buffer[1] = ((lo & 3) << 4) | hi; - state = 0; - ret = 2; - break; - default: - fprintf (stderr, "Unidir 6-bit state %d?\n", state); - ret = -1; - break; - } - break; - default: - fprintf (stderr, "Bad unidir pixel depth %d\n", q->bpp); - ret = -1; - break; + case 4: + buffer[0] = lo; + buffer[1] = hi; + ret = 2; + break; + case 6: + switch (state) { + case 0: + buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); + saved_bits = (hi & 3) << 4; + state = 1; + ret = 1; + break; + case 1: + buffer[0] = lo | saved_bits; + saved_bits = hi << 2; + state = 2; + ret = 1; + break; + case 2: + buffer[0] = ((lo & 0xc) >> 2) | saved_bits; + buffer[1] = ((lo & 3) << 4) | hi; + state = 0; + ret = 2; + break; + default: + fprintf (stderr, "Unidir 6-bit state %d?\n", state); + ret = -1; + break; + } + break; + default: + fprintf (stderr, "Bad unidir pixel depth %d\n", q->bpp); + ret = -1; + break; } break; - case QC_SERIAL: /* Serial Interface. Just in case. */ + case QC_SERIAL: /* Serial Interface. Just in case. */ default: fprintf (stderr, "Mode %x not supported\n", q->port_mode); ret = -1; @@ -770,7 +770,7 @@ qc_scan (const struct qcam * q) } if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) { - write_lpcontrol (q, 0x2e); /* turn port around */ + write_lpcontrol (q, 0x2e); /* turn port around */ write_lpcontrol (q, 0x26); (void) qc_waithand (q, 1); write_lpcontrol (q, 0x2e); @@ -801,18 +801,18 @@ qc_scan (const struct qcam * q) bytes = qc_readbytes (q, buffer); assert (bytes > 0); for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) { - assert (buffer[k] <= invert); - assert (buffer[k] >= 0); - if (buffer[k] == 0 && invert == 16) { - /* 4bpp is odd (again) -- inverter is 16, not 15, but output - must be 0-15 -- bls */ - buffer[k] = 16; - } - ret[i * pixels_per_line + pixels_read + k] = invert - buffer[k]; + assert (buffer[k] <= invert); + assert (buffer[k] >= 0); + if (buffer[k] == 0 && invert == 16) { + /* 4bpp is odd (again) -- inverter is 16, not 15, but output + must be 0-15 -- bls */ + buffer[k] = 16; + } + ret[i * pixels_per_line + pixels_read + k] = invert - buffer[k]; } pixels_read += bytes; } - (void) qc_readbytes (q, 0); /* reset state machine */ + (void) qc_readbytes (q, 0); /* reset state machine */ } if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) { diff --git a/sys/qcam/qcam-os.c b/sys/qcam/qcam-os.c index 2c959e72..41f7046c 100644 --- a/sys/qcam/qcam-os.c +++ b/sys/qcam/qcam-os.c @@ -82,7 +82,7 @@ int enable_ports (const struct qcam *q) { if (q->port < 0x278) - return 1; /* Better safe than sorry */ + return 1; /* Better safe than sorry */ if (q->port > 0x3bc) return 1; return (ioperm (q->port, 3, 1)); @@ -115,7 +115,7 @@ qc_lock_wait (struct qcam *q, int wait) #if 1 static struct flock sfl; - if (-1 == q->fd) { /* we've yet to open the lock file */ + if (-1 == q->fd) { /* we've yet to open the lock file */ static char lockfile[128]; sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port); @@ -131,7 +131,7 @@ qc_lock_wait (struct qcam *q, int wait) sfl.l_type = F_WRLCK; } #ifdef TESTING - if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */ + if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */ #else if (0 != fcntl (q->fd, wait ? F_SETLKW : F_SETLK, &sfl)) #endif @@ -142,9 +142,9 @@ qc_lock_wait (struct qcam *q, int wait) return 1; fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", - __FILE__, __LINE__, q->fd); + __FILE__, __LINE__, q->fd); - if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */ + if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */ #endif { perror ("fcntl"); @@ -202,7 +202,7 @@ qc_unlock (struct qcam *q) static struct flock sfl; #if 1 - if (-1 == q->fd) { /* port was not locked */ + if (-1 == q->fd) { /* port was not locked */ return 1; } @@ -220,7 +220,7 @@ qc_unlock (struct qcam *q) char lockfile[128]; sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port); - unlink (lockfile); /* What would I do with an error? */ + unlink (lockfile); /* What would I do with an error? */ #endif return 0; |