summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2010-11-24 19:53:08 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2010-11-24 19:53:08 +0000
commit8c3ee02366a43845c0621c049a68968560f539b8 (patch)
tree7bc0409687874521551cb5fed60b73ad2da9ef50
parent59c4d01cd37a53bc86ca4f88a1153a8c5a371ed0 (diff)
- use *un*signed byte array for control data
- use UGETW/USETW instead of letoh16/htole16 fixes controls that use two-byte signed data (e.g. brighness and hue) on sparc64
-rw-r--r--sys/dev/usb/uvideo.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 98e2f3cf520..72a28548294 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.146 2010/10/23 15:42:10 jakemsr Exp $ */
+/* $OpenBSD: uvideo.c,v 1.147 2010/11/24 19:53:07 jakemsr Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -3106,8 +3106,8 @@ uvideo_queryctrl(void *v, struct v4l2_queryctrl *qctrl)
break;
case 2:
qctrl->minimum = uvideo_ctrls[i].sig ?
- letoh16(*(int16_t *)ctrl_data) :
- letoh16(*(uint16_t *)ctrl_data);
+ (int16_t)UGETW(ctrl_data) :
+ UGETW(ctrl_data);
break;
}
@@ -3125,8 +3125,8 @@ uvideo_queryctrl(void *v, struct v4l2_queryctrl *qctrl)
break;
case 2:
qctrl->maximum = uvideo_ctrls[i].sig ?
- letoh16(*(int16_t *)ctrl_data) :
- letoh16(*(uint16_t *)ctrl_data);
+ (int16_t)UGETW(ctrl_data) :
+ UGETW(ctrl_data);
break;
}
@@ -3144,8 +3144,8 @@ uvideo_queryctrl(void *v, struct v4l2_queryctrl *qctrl)
break;
case 2:
qctrl->step = uvideo_ctrls[i].sig ?
- letoh16(*(int16_t *)ctrl_data) :
- letoh16(*(uint16_t *)ctrl_data);
+ (int16_t)UGETW(ctrl_data) :
+ UGETW(ctrl_data);
break;
}
@@ -3163,8 +3163,8 @@ uvideo_queryctrl(void *v, struct v4l2_queryctrl *qctrl)
break;
case 2:
qctrl->default_value = uvideo_ctrls[i].sig ?
- letoh16(*(int16_t *)ctrl_data) :
- letoh16(*(uint16_t *)ctrl_data);
+ (int16_t)UGETW(ctrl_data) :
+ UGETW(ctrl_data);
break;
}
@@ -3182,7 +3182,7 @@ uvideo_g_ctrl(void *v, struct v4l2_control *gctrl)
struct uvideo_softc *sc = v;
int i;
usbd_status error;
- int8_t *ctrl_data;
+ uint8_t *ctrl_data;
uint16_t ctrl_len;
i = uvideo_find_ctrl(sc, gctrl->id);
@@ -3214,8 +3214,8 @@ uvideo_g_ctrl(void *v, struct v4l2_control *gctrl)
break;
case 2:
gctrl->value = uvideo_ctrls[i].sig ?
- letoh16(*(int16_t *)ctrl_data) :
- letoh16(*(uint16_t *)ctrl_data);
+ (int16_t)UGETW(ctrl_data) :
+ UGETW(ctrl_data);
break;
}
@@ -3230,7 +3230,7 @@ uvideo_s_ctrl(void *v, struct v4l2_control *sctrl)
struct uvideo_softc *sc = v;
int i;
usbd_status error;
- int8_t *ctrl_data;
+ uint8_t *ctrl_data;
uint16_t ctrl_len;
i = uvideo_find_ctrl(sc, sctrl->id);
@@ -3257,10 +3257,7 @@ uvideo_s_ctrl(void *v, struct v4l2_control *sctrl)
*ctrl_data = sctrl->value;
break;
case 2:
- if (uvideo_ctrls[i].sig)
- *(int16_t *)ctrl_data = htole16(sctrl->value);
- else
- *(uint16_t *)ctrl_data = htole16(sctrl->value);
+ USETW(ctrl_data, sctrl->value);
break;
}
error = uvideo_vc_set_ctrl(sc, ctrl_data, SET_CUR,