diff options
author | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-26 12:55:08 +0200 |
---|---|---|
committer | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-26 12:55:08 +0200 |
commit | 3c90fa3fdd5124cd269e5ac1798f10c3c3cf34d1 (patch) | |
tree | 0293a3f101f67c3a9bf180ecfa04435458c229ab /v4l2-apps/lib | |
parent | a15825844ed72e4b0f13e10de4b7dd0ce31846ac (diff) | |
download | mediapointer-dvb-s2-3c90fa3fdd5124cd269e5ac1798f10c3c3cf34d1.tar.gz mediapointer-dvb-s2-3c90fa3fdd5124cd269e5ac1798f10c3c3cf34d1.tar.bz2 |
libv4l: Fully handle upside down cam detection in userspace
From: Hans de Goede <j.w.r.degoede@hhs.nl>
libv4l: Fully handle upside down cam detection in userspace
Priority: normal
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Diffstat (limited to 'v4l2-apps/lib')
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h | 11 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 22 |
2 files changed, 23 insertions, 10 deletions
diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h index cd0a781c7..915c33283 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h @@ -59,26 +59,27 @@ #define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R','G','G','B') #endif -#ifndef V4L2_CAP_SENSOR_UPSIDE_DOWN -#define V4L2_CAP_SENSOR_UPSIDE_DOWN 0x10000000 -#endif - #define V4LCONVERT_ERROR_MSG_SIZE 256 #define V4LCONVERT_ERR(...) \ snprintf(data->error_msg, V4LCONVERT_ERROR_MSG_SIZE, \ "v4l-convert: error " __VA_ARGS__) +#define V4LCONVERT_UPSIDE_DOWN 0x01 struct v4lconvert_data { int fd; + int flags; /* bitfield */ int supported_src_formats; /* bitfield */ - unsigned int capabilities; unsigned int no_formats; char error_msg[V4LCONVERT_ERROR_MSG_SIZE]; struct jdec_private *jdec; }; +struct v4lconvert_flags_info { + const char *card; + int flags; +}; void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dst, int width, int height); diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index 0454c8c4c..e708c492f 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -55,6 +55,13 @@ static const unsigned int supported_dst_pixfmts[] = { SUPPORTED_DST_PIXFMTS }; +/* List of cams which need special flags */ +static const struct v4lconvert_flags_info v4lconvert_flags[] = { + { "USB Camera (0471:0325)", V4LCONVERT_UPSIDE_DOWN }, /* SPC200NC */ + { "USB Camera (0471:0326)", V4LCONVERT_UPSIDE_DOWN }, /* SPC300NC */ + { "SPC 200NC ", V4LCONVERT_UPSIDE_DOWN }, + { "SPC 300NC ", V4LCONVERT_UPSIDE_DOWN }, +}; struct v4lconvert_data *v4lconvert_create(int fd) { @@ -86,9 +93,14 @@ struct v4lconvert_data *v4lconvert_create(int fd) data->no_formats = i; - /* Get capabilities */ - if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap) == 0) - data->capabilities = cap.capabilities; + /* Check if this cam has any special flags */ + if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap) == 0) { + for (i = 0; i < ARRAY_SIZE(v4lconvert_flags); i++) + if (!strcmp((const char *)v4lconvert_flags[i].card, (char *)cap.card)) { + data->flags = v4lconvert_flags[i].flags; + break; + } + } return data; } @@ -230,7 +242,7 @@ int v4lconvert_needs_conversion(struct v4lconvert_data *data, if(memcmp(src_fmt, dest_fmt, sizeof(*src_fmt))) return 1; /* Formats differ */ - if (!(data->capabilities & V4L2_CAP_SENSOR_UPSIDE_DOWN)) + if (!(data->flags & V4LCONVERT_UPSIDE_DOWN)) return 0; /* Formats identical and we don't need flip */ /* Formats are identical, but we need flip, do we support the dest_fmt? */ @@ -282,7 +294,7 @@ int v4lconvert_convert(struct v4lconvert_data *data, return -1; } - if (data->capabilities & V4L2_CAP_SENSOR_UPSIDE_DOWN) { + if (data->flags & V4LCONVERT_UPSIDE_DOWN) { rotate = 180; dest = alloca(needed); } |