PDA

View Full Version : [kubuntu] [HOW-TO] Upside-down image from UVC webcam


arjos85
June 23rd, 2008, 09:37 AM
Hi everybody,
it's a very quick how-to that will help you to solve the problem of those webcams who give back upside-down images/videos!!!
This help is intended only for those who have a UVC capable webcam.
But it will be usefull only if your webcam supports YUV image format and the applications that use your webcam request YUV format to your webcam!!! I've tested it and it works with:
skype, amsn, kopete, luvcview, mplayer!!

So...let's start!!!!

In order to know if your webcam is UVC capable you just need to open your shell and run:
lsusb
you will get something like this:
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 002: ID xxxx:yyyy "Your_Webcam_Model"
Bus 001 Device 001: ID 0000:0000Then type:
sudo lsusb -d xxxx:yyyy -v | grep "14 Video"
If you get something like the following, your webcam is UVC capable:
bFunctionClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video

If your webcam passes this test, you can go on reading. Otherwise, your camera needs to use propertary driver, because it doesn't use standard protocol/command.

Well,
now you need to donwload the UVCVIDEO driver sources, but they are on a SVN repository, so you need to install the SVN client:
sudo apt-get install subversionand now you can download the sources:
svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
The sources will be saved into a folder called "Trunk" in the path from where you run the previous command.

Now there are 2 solutions, please try both and tell me which one you think is the best!!

Now for both solutions there are two patches: the former gives back mirrored images, the latter NOT mirrored images.
You have to copy one of them into "Trunk" folder in a file (called for example "uvc_video_solution1.patch"), and then from terminal go into the "Trunk" folder and do:
patch < uvc_video_solution1.patchWARNING: each of the following patch refers to the original "uvc_video.c" file, so before applying a new patch be sure that the "uvc_video.c" file in "Trunk" folder is the original one. So please remember to backup the original file.

WARNING:
YOU HAVE TO ADD A BLANK LINE AT THE END OF EACH PATCH IN ORDER TO SUCCEED THE PATCHING!!

NEWS:
NOW YOU CAN DOWNLOAD THE PATCHES AND DON'T NEED ANY MORE TO ADD A NEW LINE!!!
TAKE A LOOK AT THE BOTTOM OF THIS HOW-TO, YOU WILL FIND 4 PATCHES, JUST CHOOSE THE ONE YOU PREFER AND DONWLOAD IT!! ;)

FIRST SOLUTION (MIRRORED IMAGES)
# modified June 26, 2008
diff -uN UVCVIDEO_v0.1.0/uvc_video.c UVCVIDEO_patched/uvc_video.c
--- UVCVIDEO_v0.1.0/uvc_video.c 2008-06-26 10:41:01.000000000 +0200
+++ UVCVIDEO_patched/uvc_video.c 2008-06-26 15:33:33.000000000 +0200
@@ -371,23 +371,92 @@
return data[0];
}

+/* This patched function allows to overturn video images from an upside-down
+ * orientation to a normal one with mirrored effect. The conversion simply
+ * consists in reversing the order of the rows of imagines.
+ * This patch performs its job just once for each frame and only when current
+ * frame is completed, but each time it is required to allocate memory in order
+ * to store a copy of that frame.
+ * This patch should work with all YUV image formats.
+ */
static void uvc_video_decode_data(struct uvc_video_device *video,
struct uvc_buffer *buf, const __u8 *data, int len)
{
struct uvc_video_queue *queue = &video->queue;
unsigned int maxlen, nbytes;
void *mem;
+ /* Patch variables */
+ __u8 *mem_tmp, *ptr_tmp;
+ int i, k, row_size;

if (len <= 0)
return;

/* Copy the video data to the buffer. */
+ /* How many bytes are needed to complete the buffer? */
maxlen = buf->buf.length - buf->buf.bytesused;
+ /* Where do pixels stored in "data" have to be copied? */
mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
+ /* How many bytes really can be copied into "mem"? */
nbytes = min((unsigned int)len, maxlen);
+ /* "nbytes" are copied from "data" to "mem" buffer.
+ * "data" stores a sequence of pixels coming from the video source.
+ * This sequence is not a full frame or a full row of pixel, but just an
+ * ordered vector of pixels (from top-left to bottom-right), whose
+ * represents just an area of the current frame.
+ * This function has to be called hundreds of times before a frame is
+ * completed and "nbytes" is not constant! Each time "data" contains the
+ * next part of the frame. At the end data stored in "mem" buffer will
+ * be used by the application who requested the video stream.
+ */
memcpy(mem, data, nbytes);
buf->buf.bytesused += nbytes;

+ /* Have the last copied bytes completed the current frame? */
+ if (nbytes == maxlen) {
+ /* Area where to save the upper half part of the original frame
+ * (just half in order to speed up the patch) before reversing.
+ */
+ mem_tmp = (__u8 *) kmalloc(buf->buf.bytesused / 2, GFP_ATOMIC);
+ if (mem_tmp != NULL ) {
+ /* Copy top-half part of frame in a temporary buffer */
+ memcpy(mem_tmp, queue->mem + buf->buf.m.offset,
+ buf->buf.bytesused / 2);
+ /* "row_size" does not depend only on the width of the
+ * frame, but also on the pixel color depth (bpp).
+ */
+ row_size = video->streaming->cur_frame->wWidth *
+ video->streaming->format->bpp / 8;
+ /* The following cycle just copy full frame rows from
+ * the last one stored in "mem" (and going up) to the
+ * first one (and going down) stored in "mem" itself.
+ */
+ ptr_tmp = queue->mem + buf->buf.m.offset
+ + buf->buf.bytesused / 2;
+ /* When the top-half of the frame has been reversed,
+ * rows are copied from the last one stored in "mem_tmp"
+ * (and going up) into the bottom half part of "mem"
+ * buffer.
+ */
+ for (i = 0, k = buf->buf.bytesused / 2 - row_size;
+ i < buf->buf.bytesused;
+ i += row_size, k -= row_size) {
+ /* If the top-half of the frame has been
+ * revesed, then it is needed to split the
+ * source buffer from "mem" to "mem_tmp".
+ */
+ if (i == buf->buf.bytesused / 2) {
+ ptr_tmp = mem_tmp;
+ k = buf->buf.bytesused / 2 - row_size;
+ }
+ memcpy(queue->mem + buf->buf.m.offset + i,
+ ptr_tmp + k,
+ row_size);
+ }
+ /* For this frame "mem_tmp" is not needed any more. */
+ kfree(mem_tmp);
+ }
+ }
/* Complete the current frame if the buffer size was exceeded. */
if (len > maxlen) {
uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");



FIRST SOLUTION (NOT MIRRORED IMAGES)
# modified June 26, 2008

diff -uN UVCVIDEO_v0.1.0/uvc_video.c UVCVIDEO_patched/uvc_video.c
--- UVCVIDEO_v0.1.0/uvc_video.c 2008-06-26 10:41:01.000000000 +0200
+++ UVCVIDEO_patched/uvc_video.c 2008-06-26 15:33:33.000000000 +0200
@@ -371,23 +371,105 @@
return data[0];
}

+/* This patch should work ONLY with YUY2 image formats, also known as YUYV or
+ * YUV422 formats.
+ * This patched function allows to overturn video images from an upside-down
+ * orientation to a normal one. The conversion consists in copying 4 bytes at a
+ * time (Y0,U0,Y1,V0) corresponding to 2 pixels, in a bottom-up direction, from
+ * the frame (coming from the video source) to the buffer that will be used by
+ * the application requesting the video stream. But in order to satisfy the YUY2
+ * image format byte has to be copied in this way: Y1 U0 Y0 VO.
+ * This patch performs its job just once for each frame and only when current
+ * frame is completed, but each time it is required to allocate memory in order
+ * to store a copy of that frame.
+ */
static void uvc_video_decode_data(struct uvc_video_device *video,
struct uvc_buffer *buf, const __u8 *data, int len)
{
struct uvc_video_queue *queue = &video->queue;
unsigned int maxlen, nbytes;
void *mem;
+ /* Patch variables */
+ __u8 *mem_tmp, *ptr_tmp;
+ int i, k, pixel_size;

if (len <= 0)
return;

/* Copy the video data to the buffer. */
+ /* How many bytes are needed to complete the buffer? */
maxlen = buf->buf.length - buf->buf.bytesused;
+ /* Where do pixels stored in "data" have to be copied? */
mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
+ /* How many bytes really can be copied into "mem"? */
nbytes = min((unsigned int)len, maxlen);
+ /* "nbytes" are copied from "data" to "mem" buffer.
+ * "data" stores a sequence of pixels coming from the video source.
+ * This sequence is not a full frame or a full row of pixel, but just
+ * an ordered vector of pixels (from top-left to bottom-right), whose
+ * represents just an area of the current frame.
+ * This function has to be called hundreds of times before a frame is
+ * completed and "nbytes" is not constant! Each time "data" contains the
+ * next part of the frame. At the end data stored in "mem" buffer will
+ * be used by the application who requested the video stream.
+ */
memcpy(mem, data, nbytes);
buf->buf.bytesused += nbytes;

+ /* Have the last copied bytes completed the current frame? */
+ if (nbytes == maxlen) {
+ /* Area where to save the original frame before manipulation. */
+ mem_tmp = (__u8 *) kmalloc(buf->buf.bytesused / 2, GFP_ATOMIC);
+ if (mem_tmp != NULL ) {
+ /* Copy the original frame in a temporary buffer. */
+ memcpy(mem_tmp, queue->mem + buf->buf.m.offset,
+ buf->buf.bytesused / 2);
+ /* "pixel_size" depens on the pixel color depth (bpp),
+ * but in YUY2 image format is constant and equal to 2.
+ */
+ pixel_size = video->streaming->format->bpp / 8;
+ /* The following loop copy 2 pixels at a time (4 bytes
+ * in YUY2 format) from the last two stored in "mem"
+ * (and going back) to the first two (and going on)
+ * stored in "mem" itself following a sort of YUY2
+ * algorithm.
+ */
+ ptr_tmp = queue->mem + buf->buf.m.offset
+ + buf->buf.bytesused / 2;
+ /* When the top-half of the frame has been reversed,
+ * rows are copied from the last one stored in "mem_tmp"
+ * (and going up) into the bottom half part of "mem"
+ * buffer.
+ */
+ for (i = 0, k = buf->buf.bytesused / 2 - 2 * pixel_size;
+ i < buf->buf.bytesused;
+ i += 2 * pixel_size, k -= 2 * pixel_size){
+ /* If the top-half of the frame has been
+ * revesed, then it is needed to split the
+ * source buffer from "mem" to "mem_tmp".
+ */
+ if (i == buf->buf.bytesused / 2) {
+ ptr_tmp = mem_tmp;
+ k = buf->buf.bytesused / 2
+ - 2 * pixel_size;
+ }
+ /* The order of copied bytes is changed from
+ * (Y0 U0 Y1 V1) to (Y1 U0 Y0 V1), i.e. from
+ * (#0 #1 #2 #3) to (#2 #1 #0 #3).
+ */
+ ((__u8 *)(queue->mem+buf->buf.m.offset + i))[0] =
+ ((__u8 *)(ptr_tmp + k))[2];
+ ((__u8 *)(queue->mem+buf->buf.m.offset + i))[1] =
+ ((__u8 *)(ptr_tmp + k))[1];
+ ((__u8 *)(queue->mem+buf->buf.m.offset + i))[2] =
+ ((__u8 *)(ptr_tmp + k))[0];
+ ((__u8 *)(queue->mem+buf->buf.m.offset + i))[3] =
+ ((__u8 *)(ptr_tmp + k))[3];
+ }
+ /* For this frame "mem_tmp" is not needed any more. */
+ kfree(mem_tmp);
+ }
+ }
/* Complete the current frame if the buffer size was exceeded. */
if (len > maxlen) {
uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");



SECOND SOLUTION (MIRRORED IMAGES)
# modified June 26, 2008

diff -uN UVCVIDEO_v0.1.0/uvc_video.c UVCVIDEO_patched/uvc_video.c
--- UVCVIDEO_v0.1.0/uvc_video.c 2008-06-26 10:41:01.000000000 +0200
+++ UVCVIDEO_patched/uvc_video.c 2008-06-26 14:03:58.000000000 +0200
@@ -371,23 +371,91 @@
return data[0];
}

+/* This patched function allows to overturn video images from an upside-down
+ * orientation to a normal one with mirrored effect. The conversion consists in
+ * reversing the order of the rows of imagines.
+ * "data" stores a sequence of pixels coming from the video source.
+ * This sequence is not a full frame or a full row of pixel, but just an
+ * ordered vector of pixels (from top-left to bottom-right), whose
+ * represents just an area of the current frame and which size ("nbytes") is
+ * not constant. In fact this function has to be called hundreds of times
+ * before a frame is completed. Each time "data" contains the next part of the
+ * current frame (upside-down). At the end data stored in "mem" buffer will be
+ * used by the application who requested the video stream.
+ * No memory allocation is needed because pixel order is modified directly
+ * while copying from "data" into "mem" buffer (i.e. in each call of this
+ * function), and not just once when the frame is already completed.
+ * This patch should work with all YUV image formats.
+ */
static void uvc_video_decode_data(struct uvc_video_device *video,
struct uvc_buffer *buf, const __u8 *data, int len)
{
struct uvc_video_queue *queue = &video->queue;
unsigned int maxlen, nbytes;
void *mem;
+ /* Patch variables */
+ unsigned int row_size, to_be_copied, shift_right;

if (len <= 0)
return;

/* Copy the video data to the buffer. */
+ /* How many bytes are needed to complete the buffer? */
maxlen = buf->buf.length - buf->buf.bytesused;
+ /* Where do pixels stored in "data" have to be copied? */
mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
+ /* How many bytes really can be copied into "mem"? */
nbytes = min((unsigned int)len, maxlen);
- memcpy(mem, data, nbytes);
- buf->buf.bytesused += nbytes;

+ /* "row_size" is the number of bytes required to store a full row of
+ * the frame.
+ */
+ row_size = video->streaming->cur_frame->wWidth *
+ video->streaming->format->bpp / 8;
+ /* Each loop "nbytes" is decremented of the number of bytes just copied.
+ * So are there any other bytes to be copied?
+ */
+ while (nbytes > 0) {
+ /* As the rows of modified frames have to be fulfilled from
+ * bottom-left to top-right, each cycle tries to complete a
+ * single row.
+ * In this cycle where is it needed to start to store bytes
+ * within the selected row? From the beginning or shifted
+ * right? Because other bytes could have been already stored in
+ * that row without completing it, so it could be needed a right
+ * shift.
+ */
+ shift_right = buf->buf.bytesused % row_size;
+ /* In this cycle how many byte can we copy in the selected row?
+ */
+ if (nbytes > row_size - shift_right)
+ to_be_copied = row_size - shift_right ;
+ else
+ to_be_copied = nbytes;
+ /* "queue->mem + buf->buf.m.offset" is the base-address where to
+ * start to store the current frame. This address refers to a
+ * preallocated area (just for a sigle frame) taking part in a
+ * circular buffer, where to store a fixed number of sequent
+ * frames.
+ */
+ memcpy(queue->mem + buf->buf.m.offset
+ /* Go to the end of this frame. */
+ + row_size * video->streaming->cur_frame->wHeight
+ /* Go back for the number of bytes corrisponding to the
+ * already fully completed rows.
+ */
+ - (buf->buf.bytesused - shift_right)
+ /* Go back at the starting point of the upper row. */
+ - row_size
+ /* Shift right on this row if it is needed. */
+ + shift_right,
+ data,
+ to_be_copied );
+ /* Update "data", "byteused" and "nbytes" values. */
+ data += to_be_copied;
+ buf->buf.bytesused += to_be_copied ;
+ nbytes -= to_be_copied;
+ }
/* Complete the current frame if the buffer size was exceeded. */
if (len > maxlen) {
uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");



SECOND SOLUTION (NOT MIRRORED IMAGES)
# modified June 26, 2008

diff -uN UVCVIDEO_v0.1.0/uvc_video.c UVCVIDEO_patched/uvc_video.c
--- UVCVIDEO_v0.1.0/uvc_video.c 2008-06-26 10:41:01.000000000 +0200
+++ UVCVIDEO_patched/uvc_video.c 2008-06-26 14:03:58.000000000 +0200
@@ -371,23 +371,81 @@
return data[0];
}

+/* This patch should work ONLY with YUY2 image formats, also known as YUYV or
+ * YUV422 formats.
+ * This patched function allows to overturn video images from an upside-down
+ * orientation to a normal one. The conversion consists in copying 4 bytes at a
+ * time (Y0,U0,Y1,V0) corresponding to 2 pixels from the frame (coming from the
+ * video source) to the buffer that will be used by the application requesting
+ * the video stream. But in order to satisfy the YUY2 image format byte has to
+ * be copied in this way: Y1 U0 Y0 VO. Bytes are copied in a bottom-up
+ * direction into the reversed frame.
+ * "data" stores a sequence of pixels coming from the video source.
+ * This sequence is not a full frame or a full row of pixel, but just an
+ * ordered vector of pixels (from top-left to bottom-right), whose
+ * represents just an area of the current frame and which size ("nbytes") is
+ * not constant. In fact this function has to be called hundreds of times
+ * before a frame is completed. Each time "data" contains the next part of the
+ * current frame (upside-down). At the end data stored in "mem" buffer will be
+ * used by the application who requested the video stream.
+ * No memory allocation is needed because pixel order is modified directly
+ * while copying from "data" into "mem" buffer (i.e. in each call of this
+ * function), and not just once when the frame is already completed.
+ */
static void uvc_video_decode_data(struct uvc_video_device *video,
struct uvc_buffer *buf, const __u8 *data, int len)
{
struct uvc_video_queue *queue = &video->queue;
unsigned int maxlen, nbytes;
void *mem;
+ /* Patch variables */
+ unsigned int i, pixel_size;
+ __u8 *ptr_tmp;

if (len <= 0)
return;

/* Copy the video data to the buffer. */
+ /* How many bytes are needed to complete the buffer? */
maxlen = buf->buf.length - buf->buf.bytesused;
+ /* Where do pixels stored in "data" have to be copied? */
mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
+ /* How many bytes really can be copied into "mem"? */
nbytes = min((unsigned int)len, maxlen);
- memcpy(mem, data, nbytes);
- buf->buf.bytesused += nbytes;

+ /* "pixel_size" depens on the pixel color depth (bpp),
+ * but in YUY2 image format is constant and equal to 2.
+ */
+ pixel_size = video->streaming->format->bpp / 8;
+ /* In each loop 4 bytes are modified and copied into "mem" buffer. */
+ for (i = 0; i < nbytes; i += 2 * pixel_size) {
+ /* "queue->mem + buf->buf.m.offset" is the base-address
+ * where to start to store the current frame. This
+ * address refers to a preallocated area (just for a
+ * sigle frame) taking part in a circular buffer, where
+ * to store a fixed number of sequent frames.
+ */
+ ptr_tmp = (__u8 *)(queue->mem + buf->buf.m.offset
+ /* Go to the end of this frame. */
+ + video->streaming->cur_frame->wWidth * pixel_size
+ * video->streaming->cur_frame->wHeight
+ /* Go back for the number of already copied bytes. */
+ - buf->buf.bytesused
+ /* Go back for the number of bytes (4 bytes) to be
+ * copied in this cycle.
+ */
+ - 2 * pixel_size);
+ /* The order of copied bytes is changed from
+ * (Y0 U0 Y1 V1) to (Y1 U0 Y0 V1), i.e. from
+ * (#0 #1 #2 #3) to (#2 #1 #0 #3).
+ */
+ ptr_tmp[0] = ((__u8 *)(data + i))[2];
+ ptr_tmp[1] = ((__u8 *)(data + i))[1];
+ ptr_tmp[2] = ((__u8 *)(data + i))[0];
+ ptr_tmp[3] = ((__u8 *)(data + i))[3];
+ /* Update "byteused" value. */
+ buf->buf.bytesused += 2 * pixel_size;
+ }
/* Complete the current frame if the buffer size was exceeded. */
if (len > maxlen) {
uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~

Well, now the worst part has been done!!!
We just need to compile our modded file and to install the new driver, so from shell you have to go to the "Trunk" directory and type:
makethere shouldn't be errors!!

Then, ONLY if you are using one of the Ubuntu distributions (ubuntu, kubuntu, etc.), open with you editor the "Makefile" and change the following line:
INSTALL_MOD_DIR := usb/mediawith
INSTALL_MOD_DIR := ubuntu/media/usbvideoNow we just need to remove uvcvideo module (if you have previously installed it):
sudo modprobe -r uvcvideoThen:

sudo make install
sudo modprobe uvcvideo
Now everything should work!!!

Let me know!!

And please try both solutions..
in case you don't see any difference just use the SECOND solution (mirrored or not, has you prefer), it should be the safest!!

Good luck,
enjoy your webcam!! ;)

Arjos85 :guitar:

ps. excuse me for this too quick HOW-TO, without good explainations, but really just right now I haven't time to do it more verbose!!!
pps. excuse me also in case I made some mistakes!!!

Bazilio
June 23rd, 2008, 11:26 AM
wrong:

Then type:
sudo lsusb -d xxxx:yyyy -v | grep "14 video"

right:
sudo lsusb -d xxxx:yyyy -v | grep "14 Video"
"V" in "Video" in upper case

arjos85
June 23rd, 2008, 11:42 AM
Really thank you Brazilio!!! ;)
I've just modified the HOW-TO!!!

ciao

Bazilio
June 25th, 2008, 03:03 AM
SECOND SOLUTION (NOT MIRRORED IMAGES)
# added June 24th, 2008
Perfect job!
Thank you, Marko!
Not mirrored image, not upside-down, with good quality!
I am very happi with it patch!

Thank you!

arjos85
June 25th, 2008, 04:16 AM
Perfect job!
Thank you, Marko!
Not mirrored image, not upside-down, with good quality!
I am very happi with it patch!

Thank you!


Thank you for having tried my patches..... :guitar:
it's a kind of test session....
for examplle someone has some problem with the second solution (not mirrored)!!

Which "not mirrored" solution have you tried?
The first or the second? ;)

Bazilio
June 25th, 2008, 04:25 AM
i wrote in quote: SECOND SOLUTION (NOT MIRRORED IMAGES)

before i used SECOND SOLUTION (MIRRORED IMAGES)

arjos85
June 25th, 2008, 04:39 AM
Ah ok...
excuse me I'm still sleeping!! ;)

arjos85
June 26th, 2008, 10:12 AM
Hey guys,
I just want to inform you that I have modified the HOW-TO:
added patches and speed up the 2 versions of the first solution.

Let me know if you think there are any mistakes!!

Thanks a lot!!

Ciao Ciao

Arjos85

neandertal
June 27th, 2008, 05:42 AM
Hi arjos85,
thank you for this how to. Every time I try to apply any of the four patches in the trunk folder I get an error message: Hunk #1 FAILED at 371 1 out of 1 hunk FAILED -- saving rejects to file uvc_video.c.rej.

arjos85
June 27th, 2008, 06:00 AM
Hi arjos85,
thank you for this how to. Every time I try to apply any of the four patches in the trunk folder I get an error message: Hunk #1 FAILED at 371 1 out of 1 hunk FAILED -- saving rejects to file uvc_video.c.rej.

Please check if you have also copied the last blank line of the patch..it should be necessary to succeed the patching ;)

arjos85
June 27th, 2008, 06:16 AM
Excuse me I didn't mention it in the HOW-TO...
just for now ADD A BLANK LINE AT THE END OF EACH PATCH before applying it!!

:P

neandertal
June 27th, 2008, 06:50 AM
I couldn't find any blank line so I tried to insert one but it didn't work.I am not very good with this patching stuff. I then decided to copy the line of code line by line to the uvc_vido.c (with removing all the + signs) and it worked!!!
I still have to check stability and quality but the webcam image is no longer up side down. Thank you so much Arjos. Very good job.

arjos85
June 27th, 2008, 07:05 AM
I couldn't find any blank line so I tried to insert one but it didn't work.
You are right...it's not possible to add a blank line at the end of a of a quote/code test.
I am not very good with this patching stuff. I then decided to copy the line of code line by line to the uvc_vido.c (with removing all the + signs) and it worked!!!
I still have to check stability and quality but the webcam image is no longer up side down. Thank you so much Arjos. Very good job.GREAT!!!
I m very happy my patch works also for you!!
Which patch have you tried?

However it should be a good thing if you try also the other 3 patches!!
Now you can simply donwload them in the Trunk folder because I've attached them at the end of the HOW-TO...
then with the shell go to inside the Trunk folder and do:
patch < the_patch_you_want Please let me know about the performance of the all 4 patches!!
Thank you very much!! ;)

Ciao ciao
Arjos

napalm brain
June 28th, 2008, 06:33 PM
So if you don't have a proprietary driver, this is worthless? I also have an inverted webcam but I've had absolutely not luck correcting the problem. I have an UVC webcam but yeah.

arjos85
June 28th, 2008, 07:11 PM
So if you don't have a proprietary driver, this is worthless? I also have an inverted webcam but I've had absolutely not luck correcting the problem. I have an UVC webcam but yeah.


Excuse me , I'm Italian and I'm not very good in English!! :S
What are you talking about when you said "this is worthless"?
I don't have a proprietary driver in the sense that it is not a SONIX driver (since my webcam is a SONIX one), but I'm using an open source driver: UVCVIDEO.
You said you also have an UVC webcam mounted upside-down...
have you tried one of my 4 solutions?
What do you need? Can I help you in some way?

Let me know...and please try to be more clear you can...
thank you.

Excuse me for my English!! ;)

arjos

arjos85
June 29th, 2008, 03:55 PM
Perfect job!
Thank you, Marko!
Not mirrored image, not upside-down, with good quality!
I am very happi with it patch!

Thank you!



Ehy Brazilio,
I've just find out you have talked about this how-to at bugs.launchpad.net ...
thank you very much...
it is very important for the linux/opensource community to disseminate information like that!!
also if it is not a real kernel/driver bug, you have helped all those people who think it is and go to bugs.launchpad.net!!

good job!! ;)

napalm brain
June 29th, 2008, 06:33 PM
Excuse me , I'm Italian and I'm not very good in English!! :S
What are you talking about when you said "this is worthless"?
I don't have a proprietary driver in the sense that it is not a SONIX driver (since my webcam is a SONIX one), but I'm using an open source driver: UVCVIDEO.
You said you also have an UVC webcam mounted upside-down...
have you tried one of my 4 solutions?
What do you need? Can I help you in some way?

Let me know...and please try to be more clear you can...
thank you.

Excuse me for my English!! ;)

arjos

Ah, sorry. I was worried about that being misconstrued. I meant, I can't use your tutorial if I don't have a proprietary driver? It would be unfortunate but this would be the way to solve the issue. Although, yes I do have a UVC webcam also. Oddly enough, when I restart, sometimes, the webcam is fine. A bit unpredictable but if I can't use this, I will live.

:)

arjos85
June 29th, 2008, 06:46 PM
Ah, sorry. I was worried about that being misconstrued. I meant, I can't use your tutorial if I don't have a proprietary driver? It would be unfortunate but this would be the way to solve the issue. Although, yes I do have a UVC webcam also. Oddly enough, when I restart, sometimes, the webcam is fine. A bit unpredictable but if I can't use this, I will live.

:)

If I understood well...you have two webcams, the former is NOT uvc capable the latter is uvc capable.
Is it right?
Well...for the first one you have to look for some other solution...I don't know if the vendor released driver for you webcam, just try to look for it in the vendor website. Maybe someone of the opensource community has developed a driver for your webcam.

Please can you tell me the model of your webcams?

Thank you very much!!

ps.
where are you writing from?

leo_ietres
July 10th, 2008, 04:01 AM
Ok, I corroborate that the first patch works perfectly on the PACKARD BELL BG45-P-025 laptop.

here is the lsusb command on my laptop for users that could have the same one:

leonardo@leo-portatil:~$ lsusb
Bus 007 Device 002: ID 04f2:b012 Chicony Electronics Co., Ltd
Bus 007 Device 001: ID 0000:0000
Bus 003 Device 002: ID 0bda:0158 Realtek Semiconductor Corp.
Bus 003 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 002: ID 046d:c03f Logitech, Inc. UltraX Optical Mouse
Bus 004 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

arjos85
July 10th, 2008, 04:11 AM
Hi leo_ietres,
Ok, I corroborate that the first patch works perfectly on the PACKARD BELL BG45-P-025 laptop.

leonardo@leo-portatil:~$ lsusb
Bus 007 Device 002: ID 04f2:b012 Chicony Electronics Co., Ltd


Why don't you try also the second patch?
It should be more stable and faster!!

Thank you for having tried my patch!!
Enjoy your webcam!!

Ciao ciao

WillyLinux
July 15th, 2008, 05:39 PM
Ok, I corroborate that the first patch works perfectly on the PACKARD BELL BG45-P-025 laptop.

here is the lsusb command on my laptop for users that could have the same one:

leonardo@leo-portatil:~$ lsusb
Bus 007 Device 002: ID 04f2:b012 Chicony Electronics Co., Ltd
Bus 007 Device 001: ID 0000:0000
Bus 003 Device 002: ID 0bda:0158 Realtek Semiconductor Corp.
Bus 003 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 002: ID 046d:c03f Logitech, Inc. UltraX Optical Mouse
Bus 004 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
leo_ietres, can you tell me specifically how you did that?

I also have a Packard Bell Easynote BG45-P-025 and cannot solve the problem.

I'm running Ubuntu 8.04 64bits.
Image is seen in the right position in cheese (but too dark). Ekiga and Skype still show upside down. (I've tried all 4 solutions).

Thanks

arjos85
July 15th, 2008, 07:04 PM
leo_ietres, can you tell me specifically how you did that?
I also have a Packard Bell Easynote BG45-P-025 and cannot solve the problem.
I'm running Ubuntu 8.04 64bits.

Hi WillyLinux,
are you getting any error while installing the patch/module?

It seems that the patch isn't applied and used...try to restart your system!!

Regards,
arjos85

WillyLinux
July 16th, 2008, 12:50 AM
hi arjos85,
everythink seems to be working (at least I don't receive any warning or error).

Steps:
1.download files
2.change files makefile INSTALL_MOD_DIR := usb/media/usbvideo
3.download patch and copy to trunk folder
4.patch < filename

guillermo@rtpc:~/descargas/trunk$ patch < patch_solution1_mirrored.txt
patching file uvc_video.c
guillermo@rtpc:~/descargas/trunk$

(no error message. seems to be ok).

5.make

guillermo@rtpc:~/descargas/trunk$ make
Building USB Video Class driver...
make[1]: se ingresa al directorio `/usr/src/linux-headers-2.6.24-19-generic'
CC [M] /home/guillermo/descargas/trunk/uvc_driver.o
CC [M] /home/guillermo/descargas/trunk/uvc_video.o
LD [M] /home/guillermo/descargas/trunk/uvcvideo.o
Building modules, stage 2.
MODPOST 1 modules
LD [M] /home/guillermo/descargas/trunk/uvcvideo.ko
make[1]: se sale del directorio `/usr/src/linux-headers-2.6.24-19-generic'
guillermo@rtpc:~/descargas/trunk$

(seems to be no error)

6.7.8.

guillermo@rtpc:~/descargas/trunk$ sudo modprobe -r uvcvideo
[sudo] password for guillermo:
guillermo@rtpc:~/descargas/trunk$ sudo make install
Installing USB Video Class driver...
make[1]: se ingresa al directorio `/usr/src/linux-headers-2.6.24-19-generic'
INSTALL /home/guillermo/descargas/trunk/uvcvideo.ko
DEPMOD 2.6.24-19-generic
make[1]: se sale del directorio `/usr/src/linux-headers-2.6.24-19-generic'
guillermo@rtpc:~/descargas/trunk$ sudo modprobe uvcvideo
guillermo@rtpc:~/descargas/trunk$


Something has been solved as in the camera software "cheese" the image has turned to normal position (but dark). In the other software there's no change at all.

Perhaps I'm forgetting something or applying something wrong?
rebooting the system doesn't change anything.

thanks!

arjos85
July 16th, 2008, 02:19 AM
hi arjos85,
everythink seems to be working (at least I don't receive any warning or error).


well... I really don't know!!

Try this steps:
sudo find /lib/modules/ -name uvcvideo.ko (give me the output)
sudo modprobe -r uvcvideo
sudo rm `find /lib/modules/2.6.24-19-generic/ -name uvcvideo.ko`
sudo make install
sudo cp uvcvideo.ko /lib/modules/2.6.24-19-generic/usb/media/
sudo depmod -ae
sudo modprobe -f uvcvideoLet me know,
thank you!!

Regards,

arjos85

WillyLinux
July 16th, 2008, 03:09 AM
It worked!

I've tried what you suggested and it worked (Ekiga works fine and Skype can transmit video properly -even tough I cannot see my own video in Skype, but this is a Skype matter I guess) another comment: cheese is not working after the changes, I removed it.

I don't know if the output you requested is useful now, but here it is:
/lib/modules/2.6.24-16-generic/ubuntu/media/usbvideo/uvcvideo.ko
/lib/modules/2.6.24-19-generic/usb/media/uvcvideo.ko
/lib/modules/2.6.24-19-generic/usb/media/usbvideo/uvcvideo.ko

Well, thanks a lot!
Regards

arjos85
July 16th, 2008, 09:31 AM
It worked!

I've tried what you suggested and it worked [..]

Well, thanks a lot!
Regards

Thank you very much for having tried my patch..
thank yuo for having warned me about this problem...
i will update the HOW-TO!!

enjoy your webcam!! :D

Regards,
arjos85

jacortijo
July 20th, 2008, 08:29 AM
congratulations man!!! it works perfectly... now no need to have windows vista any more just for the webcam... ;-)
only the speed is very slow but I guess this will be improved in the general driver!

thanks a lot once more.

Jose

arjos85
July 20th, 2008, 08:42 AM
congratulations man!!! it works perfectly... now no need to have windows vista any more just for the webcam... ;-)
only the speed is very slow but I guess this will be improved in the general driver!

thanks a lot once more.

Jose

Ciao jacortijo,
very happy my patches works also with you!!

What webcam do you have ?
Which of the 4 patches have you applied?

let me know!! ;)
Regards

Ripichip
July 26th, 2008, 04:34 AM
Great work!! =D 2 image mirror patch work for me!! !THANKS!!! =D
Packard Bell Easynote BG45-U-033 Ubuntu Hardy x64
Bus 007 Device 002: ID 04f2:b012 Chicony Electronics Co., Ltd

arjos85
July 26th, 2008, 05:59 AM
Great work!! =D 2 image mirror patch work for me!! !THANKS!!! =D
Packard Bell Easynote BG45-U-033 Ubuntu Hardy x64
Bus 007 Device 002: ID 04f2:b012 Chicony Electronics Co., Ltd


Thank you for informing me about your configuration...
have you tried the other patches? ;)

Ripichip
July 26th, 2008, 06:34 PM
I probe de first and second patch image mirror, but de second patch work fine that the other, because the second i have one image more fluid... (Sorry mi bad english xD)
My test i did in the program Cheese.

arjos85
July 26th, 2008, 06:52 PM
I probe de first and second patch image mirror, but de second patch work fine that the other, because the second i have one image more fluid... (Sorry mi bad english xD)
My test i did in the program Cheese.

ah ah :D
don t worry for your English!!! :P
where are you from?

However thank you for reporting me your test details!!

ciao ciao
arjos85
;)

Bazilio
July 30th, 2008, 03:26 AM
I updated my system and image becam upside-down again, and colors becam bad.
I desided to update uvc driver from svn.
Then I aplied pach (2 not mirrored) image not upside-down, but colors steel bad.
Any ideas?

arjos85
July 30th, 2008, 03:59 AM
I updated my system and image becam upside-down again, and colors becam bad.
I desided to update uvc driver from svn.
Then I aplied pach (2 not mirrored) image not upside-down, but colors steel bad.
Any ideas?

Well I don't know...
try also the other 3 patches...and report me what you get!!

;)

Bazilio
July 31st, 2008, 12:54 AM
This is translate for russian users: http://forum.ubuntu.ru/index.php?topic=23660.msg233306#msg233306

arjos85
July 31st, 2008, 08:58 AM
This is translate for russian users: http://forum.ubuntu.ru/index.php?topic=23660.msg233306#msg233306


Thank you Brazilio for making my patches more popular!! ;)
Have you solved the problems you got after last installation??

CIao Ciao
Marco

Bazilio
July 31st, 2008, 10:43 PM
Thank you Brazilio for making my patches more popular!! ;)
Have you solved the problems you got after last installation??

CIao Ciao
Marco
no, the problem still exists. no red color.
but it can be solved by tune some settings. in kopete it works, in skype i don't have any settings...

P.S. People solving the problem, Your patch works, thank you!

arjos85
August 2nd, 2008, 03:30 AM
no, the problem still exists. no red color.
but it can be solved by tune some settings. in kopete it works, in skype i don't have any settings...

P.S. People solving the problem, Your patch works, thank you!

Just right now I've compared my patch with the last version of uvcvideo driver. The file I've modified (uvc_video.c) is now changed, but the function I've modded is unchanded.
So please try to apply the patch manually and not with "patch" command.

I hope this could help...

ciao

Marco

Bazilio
August 4th, 2008, 12:28 AM
it was false alarm :)
in skype, cheese and kopete image looks good now.. but I did nothing.. just updated nvidia drivers... magic...

Update:
Oh, I know, what it was! I ajusted colors in kopete settings and it aplied to all applications - in skype, cheese, both kopete (kde3, kde4).
If I change settings in kopete it change some global settings.
(I hope you understand me, sorry for my english)

arjos85
August 4th, 2008, 03:48 AM
it was false alarm :)
in skype, cheese and kopete image looks good now.. but I did nothing.. just updated nvidia drivers... magic...

Update:
Oh, I know, what it was! I ajusted colors in kopete settings and it aplied to all applications - in skype, cheese, both kopete (kde3, kde4).
If I change settings in kopete it change some global settings.
(I hope you understand me, sorry for my english)

WOW..
I did't know about this issue, thank you for reporting me.
However don't worry, your English is good...also my English is not perfect!!

Ciao
marco

amsterbran
August 4th, 2008, 01:29 PM
hi! thanks for all your work...

however, my system hangs when installing the patches. specifically, i believe it hangs on the main for loop you have added.

i'm running ubuntu 8.04 on a lenovo ideapad y510. there is an integrated "lenovo easy camera", and the image is upside down in every application i've tried. it is a uvc based webcam. someone else with my computer apparently had the same problem..see the link below, post #24.

http://ubuntuforums.org/showthread.php?t=870681&page=3


any ideas or help would be appreciated!! thanks again!!

arjos85
August 4th, 2008, 01:50 PM
hi! thanks for all your work...

however, my system hangs when installing the patches. specifically, i believe it hangs on the main for loop you have added.

i'm running ubuntu 8.04 on a lenovo ideapad y510. there is an integrated "lenovo easy camera", and the image is upside down in every application i've tried. it is a uvc based webcam. someone else with my computer apparently had the same problem..see the link below, post #24.

http://ubuntuforums.org/showthread.php?t=870681&page=3


any ideas or help would be appreciated!! thanks again!!

Well...
have you tried all the 4 patches?
Let try and let me know!!

Regards,
Marco

pbouf
August 9th, 2008, 12:25 AM
I've tried all 4 and get a system freeze when I start Cheese each time.

How can I get back to whatever I had before--upside down webcam was better than a frozen system. :)

arjos85
August 9th, 2008, 05:13 AM
I've tried all 4 and get a system freeze when I start Cheese each time.

How can I get back to whatever I had before--upside down webcam was better than a frozen system. :)

I'm really sorry that you have this kind of problem.
have you tried to patch your uvcvideo.c by hand?
It could be possible that you have downloaded the last version of the uvc driver and maybe the uvcvideo.c file has been modified, so that my patch can't be applied correctly.
However if I remember well, Cheese doesn't work at all with uvcvideo driver.
Have you tried other programs, i.e. "luvcview", "skype", msn?
To take your system back, just download the last version of uvc driver and install it.

Regards,

Marco

benidelaserena
August 9th, 2008, 06:28 PM
Work both solutions.
Hardy Heron.
Asus GS2
Camera in... Bus 006 Device 002: ID 174f:5a35

pbouf
August 9th, 2008, 09:55 PM
Skype also freezes after the patch--both Skype and Cheese seemed to work okay except upside-down before. I haven't tried the other two you mention. I downloaded the latest available (SVN r242) uvc driver; what rev did you use? I think I'd rather just patch the exact same sources as you did rather than try to patch manually.

Thanks for your help, hopefully almost there.. In a couple of days, I have to pass this laptop along to folks who definitely wont be applying patchfiles and such, and I won't be able to access it remotely either.
Cheers.

arjos85
August 9th, 2008, 10:26 PM
Skype also freezes after the patch--both Skype and Cheese seemed to work okay except upside-down before. I haven't tried the other two you mention. I downloaded the latest available (SVN r242) uvc driver; what rev did you use? I think I'd rather just patch the exact same sources as you did rather than try to patch manually.

Thanks for your help, hopefully almost there.. In a couple of days, I have to pass this laptop along to folks who definitely wont be applying patchfiles and such, and I won't be able to access it remotely either.
Cheers.

OK..
but please try just this 4 steps:
1) download a fresh new copy of the driver;
2) open "uvcvideo.c" file and substitute the whole "uvc_video_decode_data()" function with these lines:

static void uvc_video_decode_data(struct uvc_video_device *video,
struct uvc_buffer *buf, const __u8 *data, int len)
{
struct uvc_video_queue *queue = &video->queue;
unsigned int maxlen, nbytes;
void *mem;

unsigned int i, pixel_size;
__u8 *ptr_tmp;

if (len <= 0)
return;

maxlen = buf->buf.length - buf->buf.bytesused;
mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
nbytes = min((unsigned int)len, maxlen);

pixel_size = video->streaming->format->bpp / 8;
for (i = 0; i < nbytes; i += 2 * pixel_size) {
ptr_tmp = (__u8 *)(queue->mem + buf->buf.m.offset

+ video->streaming->cur_frame->wWidth * pixel_size
* video->streaming->cur_frame->wHeight
- buf->buf.bytesused
- 2 * pixel_size);
ptr_tmp[0] = ((__u8 *)(data + i))[2];
ptr_tmp[1] = ((__u8 *)(data + i))[1];
ptr_tmp[2] = ((__u8 *)(data + i))[0];
ptr_tmp[3] = ((__u8 *)(data + i))[3];
buf->buf.bytesused += 2 * pixel_size;
}
if (len > maxlen) {
uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");
buf->state = UVC_BUF_STATE_DONE;
}
}

3) Install again the driver with the following commands from the shell:
- move into the folder in which you saved the new copy of the driver (and where there is the uvcvideo.c file you modified just in the step before)
$ sudo modprobe -r uvcvideo
$ make
$ sudo make install
$ sudo cp uvcvideo.ko /lib/modules/`uname -r`/ubuntu/media/usbvideo/
$ sudo cp uvcvideo.ko /lib/modules/`uname -r`/usb/media/
$ sudo depmod -ae
$ sudo modprobe -f uvcvideo

4) Install LUVCVIEW from your packages manager and try these commands:
$ luvcview
$ luvcview -f yuv
Report me what you get!!

I hope these few steps can solve your problem!!
Let me know!!

Regards

Marco

pbouf
August 10th, 2008, 08:53 AM
Thanks, I just tried that but I still get a freeze (for both of the luvcview commands).

arjos85
August 10th, 2008, 09:17 AM
Thanks, I just tried that but I still get a freeze (for both of the luvcview commands).

OK,
at the moment I really don't know how to solve this problem, also because I don't know anything about your system.
Which camera do you have?
Can you post me the results of these commands?
$ lsusb
$ sudo lsusb -vv
$ dmesg | grep uvc

Thank you
Regards
Marco

pbouf
August 10th, 2008, 11:33 AM
lsusb:

Bus 007 Device 002: ID 5986:0200 Bison
Bus 007 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

sudo lsusb -vv: see attachment

dmesg | grep uvc:
[ 28.913146] uvcvideo: Found UVC 1.00 device Lenovo Easy Camera (5986:0200)
[ 29.870596] usbcore: registered new interface driver uvcvideo

Also, uname -r:
2.6.24-19-generic

arjos85
August 10th, 2008, 11:41 AM
lsusb:

Bus 007 Device 002: ID 5986:0200 Bison
Bus 007 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000 sudo lsusb -vv: see attachment

dmesg | grep uvc:
[ 28.913146] uvcvideo: Found UVC 1.00 device Lenovo Easy Camera (5986:0200)
[ 29.870596] usbcore: registered new interface driver uvcvideoAlso, uname -r:
2.6.24-19-generic

Ah ok...
maybe I've understood why my patch doesn't work with your webcam...
If I've understood well, your webcam doesn't use YUV format as image format...
but my patch works just with YUV images as I wrote in the HOW-TO.

Just post the result of this command:
$ luvcview -L

Regards,
Marco

pbouf
August 10th, 2008, 11:55 AM
luvcview version 0.2.1
Video driver: x11
A window manager is available
video /dev/video0
/dev/video0 does not support read i/o
{ pixelformat = 'MJPG', description = 'MJPEG' }
{ discrete: width = 640, height = 480 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 320, height = 240 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 160, height = 120 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 352, height = 288 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 176, height = 144 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 1280, height = 1024 }
Time interval between frame: 1/15, 1/7,
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
{ discrete: width = 640, height = 480 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 320, height = 240 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 160, height = 120 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 352, height = 288 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 176, height = 144 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 1280, height = 1024 }
Time interval between frame: 1/7,

arjos85
August 10th, 2008, 12:29 PM
luvcview version 0.2.1
Video driver: x11
A window manager is available
video /dev/video0
/dev/video0 does not support read i/o
{ pixelformat = 'MJPG', description = 'MJPEG' }
{ discrete: width = 640, height = 480 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 320, height = 240 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 160, height = 120 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 352, height = 288 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 176, height = 144 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 1280, height = 1024 }
Time interval between frame: 1/15, 1/7,
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
{ discrete: width = 640, height = 480 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 320, height = 240 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 160, height = 120 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 352, height = 288 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 176, height = 144 }
Time interval between frame: 1/30, 1/15, 1/10,
{ discrete: width = 1280, height = 1024 }
Time interval between frame: 1/7,


Really really strange!!
Your webcam should work!!
Maybe the uvcvideo driver has been modified in such a way my patch can't work anymore.
But I don't think this is true...!!!
As attachement you can find the already patched driver I use myself on my laptop...try to install it!!
I hope this could help...

regards,
Marco

pbouf
August 10th, 2008, 01:15 PM
Ok, so that at least gets a working luvcview, though if I try to maximize/restore the window it sometimes segfaults. And it's still upside down. :)

Edit: Also, Cheese works, but still upside-down.

arjos85
August 10th, 2008, 01:45 PM
Ok, so that at least gets a working luvcview, though if I try to maximize/restore the window it sometimes segfaults. And it's still upside down. :)

Unbelievable!!!
Well...just try to ask for help in the uvcvideo mailing list: http://linux-uvc.berlios.de/

I hope there someone else can help you!!
I'm so sorry my patch doesn't work with you!! :(

Regards,
Marco

pbouf
August 10th, 2008, 01:56 PM
Thanks anyway for all your help. One question -- is there a way to be 100% sure that my system is actually using the uvc driver that I've compiled from your patched sources? If I understand your last post, the image should be right-side-up, if it works at all.

arjos85
August 10th, 2008, 07:49 PM
Thanks anyway for all your help. One question -- is there a way to be 100% sure that my system is actually using the uvc driver that I've compiled from your patched sources? If I understand your last post, the image should be right-side-up, if it works at all.

Try this command:
$ lsmod | grep uvcvideo
on my system I get this output, you should get something similar:
uvcvideo 60040 0
compat_ioctl32 2304 1 uvcvideo
videodev 29440 1 uvcvideo
v4l1_compat 15492 2 uvcvideo,videodev
v4l2_common 18304 2 uvcvideo,videodev
usbcore 146028 5 uvcvideo,hci_usb,ehci_hcd,uhci_hcd

Then try also :
$ sudo modprobe -r uvcvideo
$ sudo depmod -ae
$ sudo modprobe -f uvcvideo
$ dmesg | tail

Let me know,
marco

pbouf
August 10th, 2008, 10:54 PM
[ 31.790324] usbcore: deregistering interface driver uvcvideo
[ 33.554191] v4l2_common: no version for "struct_module" found: kernel tainted.
[ 33.554209] v4l2_common: no version magic, tainting kernel.
[ 33.560503] v4l1_compat: no version magic, tainting kernel.
[ 33.565453] videodev: no version magic, tainting kernel.
[ 33.567502] Linux video capture interface: v2.00
[ 33.568461] compat_ioctl32: no version magic, tainting kernel.
[ 33.572896] uvcvideo: no version magic, tainting kernel.
[ 33.577804] uvcvideo: Found UVC 1.00 device Lenovo Easy Camera (5986:0200)
[ 33.745089] input: Lenovo Easy Camera as /devices/pci0000:00/0000:00:1d.7/usb7/7-6/7-6:1.0/input/input10
[ 33.912692] uvcvideo: Failed to query (1) UVC control 2 (unit 4) : -32 (exp. 8).
[ 33.912702] uvcvideo: I2C dev 0x60 register 0x0a = 0x00 | i2c_req : [0x60][0x01][0x0a][0x00][0x00][0x00][0x00][0xff]
[ 34.072878] uvcvideo: Failed to query (129) UVC control 2 (unit 4) : -32 (exp. 8).
[ 34.072890] uvcvideo: I2C dev 0x00 register 0x00 = 0x00 | i2c_req : [0x00][0x00][0x00][0x00][0x00][0x00][0x00][0x00]
[ 34.073868] uvcvideo: Failed to query (1) UVC control 2 (unit 4) : -32 (exp. 8).
[ 34.073876] uvcvideo: I2C dev 0x60 register 0x0b = 0x00 | i2c_req : [0x60][0x01][0x0b][0x00][0x00][0x00][0x00][0xff]
[ 34.074370] uvcvideo: Failed to query (129) UVC control 2 (unit 4) : -32 (exp. 8).
[ 34.074377] uvcvideo: I2C dev 0x00 register 0x00 = 0x00 | i2c_req : [0x00][0x00][0x00][0x00][0x00][0x00][0x00][0x00]
[ 34.074416] usbcore: registered new interface driver uvcvideo
[ 34.074422] USB Video Class driver (v0.1.0)

arjos85
August 11th, 2008, 04:18 AM
mhhhhh...
something seems to be wrong on your system:
[ 33.554191] v4l2_common: no version for "struct_module" found: kernel tainted.
[ 33.554209] v4l2_common: no version magic, tainting kernel.
[ 33.560503] v4l1_compat: no version magic, tainting kernel.
[ 33.565453] videodev: no version magic, tainting kernel.
[ 33.568461] compat_ioctl32: no version magic, tainting kernel.
[ 33.572896] uvcvideo: no version magic, tainting kernel.

The lines above are very strange. It seems your v4l2 doesn't have any definition for "struct_module"....
maybe your v4l2 is too old!!

Try to install the newest version of v4l2 module.
And look through internet for any solution to your problem...

Good luck!!

Marco

amsterbran
August 14th, 2008, 02:50 PM
same problem, same webcam (and i'm assuming same machine, ideapad y510?) as pbouf.

any luck lately, pbouf? i've tried so many things.

pbouf
August 15th, 2008, 10:05 PM
amsterbran: sorry, no. And the Y510 is out of my hands now. Hopefully a straightforward fix will surface sometime soon. I can't expect the proud new owners of this laptop to do much more than 'sudo apt-get install rightside-up-webcam'... ;)

w_daniel
August 24th, 2008, 05:26 PM
Hi everyone. I've got laptop Asus F3Series and I have the same problem: the patches didn't work. The output of my lsusb command:

Bus 007 Device 003: ID 04ca:f016 Lite-On Technology Corp.
Bus 007 Device 001: ID 0000:0000
Bus 006 Device 002: ID 174f:5a35 Syntek 1.3MPixel Web Cam - Asus G1s
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 002: ID 046d:c019 Logitech, Inc. Optical Tilt Wheel Mouse
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 0b05:1712 ASUSTek Computer, Inc. BT-183 Bluetooth 2.0+EDR adapter
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

I made everything as in how-to but without success, my webcam's output is still upside-down :confused:

Thanks

jacobleonardking
August 25th, 2008, 02:54 PM
I'm having the same problems as pbrouf and amsterbran (same laptop: Y510).

Have any y510 owners had any luck with this patch?

Thanks,
Jacob

amsterbran
August 28th, 2008, 04:16 PM
I'm having the same problems as pbrouf and amsterbran (same laptop: Y510).

Have any y510 owners had any luck with this patch?

Thanks,
Jacob

No luck..I have a y510 as well. I was trying a few things to fix it..mainly things like this

http://forum.skype.com/index.php?showtopic=112470&st=0&p=511530&#entry511530

and

http://ubuntuforums.org/showthread.php?t=725179

but i haven't had much time lately..

jacobleonardking
September 7th, 2008, 03:33 PM
So, I finally gave up on inverting the camera in software, ripped the top half of my laptop apart and physically inverted the camera.

Now, it works fine if I boot off the Ubuntu LiveCD and run any software that uses the webcam.

However, in the process of trying the patch in this thread, if I boot off my hard disk, anything that tries to access the camera makes the machine hang, with the caps lock and scroll lock lights blinking. Can't even Ctrl-Alt-F1. Any idea how to revert to the old driver? Of course, I could just reinstall Ubuntu, but there must be an easier solution.

Simply installing the trunk without the patch doesn't change anything.

Thanks,
Jacob

Cyprus
September 10th, 2008, 11:02 AM
Hi,

I tested first the 2nd solution and "lost" the cam (not in lsusb result anymore); no way back by making with the other solutions, even without patching.
My config: ubuntu 8.04 on Lenovo Ideapad Y510.
"lsmod | grep uvcvideo" gives:
uvcvideo 59656 0
compat_ioctl32 2304 1 uvcvideo
videodev 29440 1 uvcvideo
v4l1_compat 15492 2 uvcvideo,videodev
v4l2_common 18304 2 uvcvideo,videodev
usbcore 146028 5 uvcvideo,usbhid,uhci_hcd,ehci_hcd

with dmesg, some new errors (linked ?):
[ 123.450587] usb 7-2: new full speed USB device using uhci_hcd and address 18
[ 123.457805] usb 7-2: device descriptor read/64, error -71
[ 123.487064] usb 7-2: device descriptor read/64, error -71
[ 123.499925] usb 7-2: new full speed USB device using uhci_hcd and address 19
[ 123.505047] usb 7-2: device descriptor read/64, error -71
[ 123.510933] usb 7-2: device descriptor read/64, error -71
[ 123.520855] usb 7-2: new full speed USB device using uhci_hcd and address 20
[ 123.541759] usb 7-2: device not accepting address 20, error -71
[ 123.551225] usb 7-2: new full speed USB device using uhci_hcd and address 21
[ 123.561921] usb 7-2: device not accepting address 21, error -71

Thanks for your help

Cyprus
September 11th, 2008, 08:46 AM
Ok, uvcvideo is reinstalled. The 2 solutions tested; no correction. No problem anymore except the upside down image. Sorry.

No way to go back with the procedure described in this discussion: Y510 out of my hands, even without patch.
Instead (maybe source problem):
svn checkout http://svn.berlios.de/svnroot/repos/linux-uvc/
cd linux-uvc/linux-uvc/trunk
make
sudo make install
reboot (robust newbie's trick, actually after reinstalling)

(Patches tested with svn.berlios.de/svnroot/repos/linux-uvc/ )

I updated libpt-1.10.10-plugins-v4l2 with libpt-1.11.2-plugins-v4l2

"luvcview" hangs
"luvcview -f yuv" works fine (upside down)

Chybeck
September 21st, 2008, 06:06 PM
Hi,

I have an Asus X53SA , webcam 174f:5a35 , I used patch 1 it work ! .
With patch 2 , webcam seams laggy .

I'll run more tests , thanks u very much !
http://doc.ubuntu-fr.org/x53sa

mexus
September 25th, 2008, 10:54 PM
all 4 doesn't work image is still flipped.
On ASUS f3ke laptop running kubuntu 8.04, chicony 1.3mpx webcam

Anonym5555
October 1st, 2008, 07:06 PM
It works for me:

fujitsu U1010
webcam info: Bus 005 Device 004: ID 05ca:1841 Ricoh Co., Ltd
driver: r5u870

I tried both options 'solution2', and both worked at the very first attempt, with cheese and skype!!

Many thanks for your work!!

AlexH76
October 6th, 2008, 02:39 PM
Great,
I'm on Asus x71a, solution2 (w/o mirrored image) works fine for me!
thx

Espadon
October 11th, 2008, 07:15 PM
Fine,
I'm on Asus x53sa, solution1 w mirrored image works for me!

Thanks

caglar.dursun
October 23rd, 2008, 10:28 PM
When i try to make install i get 2 errors.
make empty variable name stoped.
make install Error 2

Do you have any suggestion ?

caglar.dursun
October 24th, 2008, 11:23 AM
I downloaded your patch file in tar archive.Still nothing...There is no result.The strange things, I have same device that u said.But there is no solution.

This is the result of lsusb :

Bus 007 Device 001: ID 0000:0000
Bus 006 Device 002: ID 174f:5a35 -> Same cam model u said
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 0b05:1712 ASUSTek Computer, Inc.
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

And this is the result of luvcview -L

luvcview version 0.2.1
Video driver: x11
A window manager is available
video /dev/video0
/dev/video0 does not support read i/o
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
{ discrete: width = 640, height = 480 }
Time interval between frame: 1/30, 1/20, 1/15, 1/10, 1/5, 1/1,
{ discrete: width = 352, height = 288 }
Time interval between frame: 1/30, 1/20, 1/15, 1/10, 1/5, 1/1,
{ discrete: width = 320, height = 240 }
Time interval between frame: 1/30, 1/20, 1/15, 1/10, 1/5, 1/1,
{ discrete: width = 176, height = 144 }
Time interval between frame: 1/30, 1/20, 1/15, 1/10, 1/5, 1/1,
{ discrete: width = 160, height = 120 }
Time interval between frame: 1/30, 1/20, 1/15, 1/10, 1/5, 1/1,
{ discrete: width = 1280, height = 960 }
Time interval between frame: 1/9, 1/5, 1/1,
{ discrete: width = 1280, height = 1024 }
Time interval between frame: 1/9, 1/5, 1/1,

I dont get it.What the hell is wrong this things.

caglar.dursun
October 27th, 2008, 05:46 AM
Hi, there is still no working answer about this issue.I try to reinstall driver module.I almost checked every article about this web cam problem but some of svn repository doesn't exist anymore or the procedure not work for my laptop cam.

I did every procedure like written in this article but when i write luvcview -L I saw the one line which is written /dev/video0 does not support read i/o.Is that means I cannot use the cam anymore ?


What i have to do right now? I'm gonna lose my mind.

quini
October 31st, 2008, 03:34 PM
Hi!

I've got a Sony Vaio TZ11MN; it's got a Ricoh usb camera, also supported through the r5u870 driver, but it doesn't seem to compile under the 2.6.27 kernel:

http://ubuntuforums.org/showthread.php?t=927454&highlight=r5u870

Here's the exact camera model:

quini@quinitz:~$ lsusb | grep -i ricoh
Bus 005 Device 005: ID 05ca:183a Ricoh Co., Ltd

I had the hope uvcvideo could also support it, as it seems to fit the needs:

quini@quinitz:~$ sudo lsusb -d 05ca:183a -v | grep "14 Video"
[sudo] password for quini:
bFunctionClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video

But I've had no luck; all 4 solutions get the same dmesg output:

[ 4604.894885] Linux video capture interface: v2.00
[ 4604.923883] uvcvideo: Found UVC 1.00 device <unnamed> (05ca:183a)
[ 4604.926075] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[ 4604.926326] uvcvideo: Failed to query (129) UVC probe control : -32 (exp. 26).
[ 4604.926335] uvcvideo: Failed to initialize the device (-5).
[ 4604.926637] usbcore: registered new interface driver uvcvideo
[ 4604.926647] USB Video Class driver (SVN r262)

Help would be appreciated. TIA :KS

natpu0t
November 6th, 2008, 03:08 PM
Hi!
First of all I want to say thank you for the great work!
But I have a problem. I have an asus u6s with this webcam:
Bus 007 Device 004: ID 090c:e370 Feiya Technology Corp.


The patch "patch_solution2_mirrored" worked fine for me on ubuntu 8.04 hardy, but under ubuntu 8.10 intrepid final, no one of the patches working. the picture is still upside down. Do you have any idea how I could fix that?
Or maybe somebody else? I will be very appreciate!
PS: Sorry for my English! I'm a russian.

pall.e
November 7th, 2008, 10:01 AM
Natppu0t, I had the same problem and also have a Asus U6. After playing around with it for the last 3 hours, trying to reapply every patch nothing worked. I did finally get it to work though. I think what I did was apply the patch manually instead of using the patch command, but as I am a linux noob I am not quite sure what I did so instead I will explain exactly what I did.
This is what I did:
svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
(this gets the newest driver) then
1) open "uvcvideo.c" in the trunk folder and substitute the whole "uvc_video_decode_data()" function with these lines:
{
struct uvc_video_queue *queue = &video->queue;
unsigned int maxlen, nbytes;
void *mem;

unsigned int i, pixel_size;
__u8 *ptr_tmp;

if (len <= 0)
return;

maxlen = buf->buf.length - buf->buf.bytesused;
mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused;
nbytes = min((unsigned int)len, maxlen);

pixel_size = video->streaming->format->bpp / 8;
for (i = 0; i < nbytes; i += 2 * pixel_size) {
ptr_tmp = (__u8 *)(queue->mem + buf->buf.m.offset

+ video->streaming->cur_frame->wWidth * pixel_size
* video->streaming->cur_frame->wHeight
- buf->buf.bytesused
- 2 * pixel_size);
ptr_tmp[0] = ((__u8 *)(data + i))[2];
ptr_tmp[1] = ((__u8 *)(data + i))[1];
ptr_tmp[2] = ((__u8 *)(data + i))[0];
ptr_tmp[3] = ((__u8 *)(data + i))[3];
buf->buf.bytesused += 2 * pixel_size;
}
if (len > maxlen) {
uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n");
buf->state = UVC_BUF_STATE_DONE;
}
}


Then run this code in the terminal
$ sudo modprobe -r uvcvideo
$ make
$ sudo make install
$ sudo cp uvcvideo.ko /lib/modules/`uname -r`/ubuntu/media/usbvideo/
$ sudo cp uvcvideo.ko /lib/modules/`uname -r`/usb/media/
$ sudo depmod -ae
$ sudo modprobe uvcvideo

That fixed it for me. I stole most of my solution from arjos85 post 47 in this thread. Let me know if it works. Also pm and tell me if you have your suspend working on your u6.

FredFlintston
November 13th, 2008, 02:24 PM
Thanks for the patch. It seems to have fixed the problem for me on my ASUS G1S. Oh...I did use the deprecated version from SVN rather than the one from linuxtv.org (the one the deprecated version tells you about when you attempt to build it). Thanks again for the fairly painless solution.

bitokarox
November 16th, 2008, 10:40 AM
Hi everyone!!

I'm new on this Linux world, so I'm sorry for my ignorance :(

I have an ASUS F3SA laptop, with the webcam installed on:

Bus 006 Device 002: ID 174f:5a35

I did all the commands as says the HOW-TO, but I just can't apply the patch!

I'm in the trunk folder, downloaded the second solution (not mirrored image), renamed it for uvc_video_solution2.patch in the trunk folder, but when I issue the command
patch < uvc_video_solution1.patch
it says that the program patch isn't installed...

I've tried to search the file uvc_video.c but doesn't gives me any results. :'(

Does anyone know what I'm doing wrong?
Thanks everyone ! :D

tsl
November 19th, 2008, 03:20 PM
Hi All,


I have an Asus U6S running Intrepid Ibex (kernel 2.6.27-7-generic).

From lsusb my webcam is a 04f2:b036 Chicony Electronics Co., Ltd

Here is how I got my webcam working properly:

- sudo apt-get install subversion
- svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
patched the file with not mirrored patch #2
- make uvcvideo
- modified Makefile with the INSTALL_MOD_DIR := ubuntu/media/usbvideo
- sudo modprobe -r uvcvideo
- sudo make install
- sudo depmod -ae
- sudo modprobe uvcvideo

Everything working well!

Thanks!

yannux
November 30th, 2008, 06:33 AM
Applied patch2 mirrored and works perfectly :)

Thanks !!

damuffinman
December 1st, 2008, 06:49 PM
Hi all, I've got this working before using Ubuntu 8.04 but I'm giving Fedora 10 a try this time round...

right now I'm stuck on the step when you do "make uvcvideo". I get the following error once I type "make uvcvideo" in root:

Building USB Video Class driver...
make: *** /lib/modules/2.6.27.5-117.fc10.x86_64/build: No such file or directory. Stop.

Any light on this?