[Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Riconoscimento, installazione e configurazione delle periferiche.
rainboww
Prode Principiante
Messaggi: 42
Iscrizione: sabato 8 agosto 2009, 10:28

[Video] Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da rainboww »

aytin ha scritto: Seguendo lo spunto dell'ottimo Giaccava ho fatto le sostituzioni direttamente sulla patch (la 2 not mirrored, che è quella che preferisco).
In questo modo si può seguire il procedimento principale: scaricare i sorgenti, applicare la patch, make, make install, ecc.
Vi posto il codice e lo allego (sempre che si riesca a scaricare).
La stessa sostituzione fatta alle altre patch lascerebbe inalterata la bontà del processo iniziale

Codice: Seleziona tutto

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-27 12:09:20.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_streaming *stream,
 		struct uvc_buffer *buf, const __u8 *data, int len)
 {
 	struct uvc_video_queue *queue = &stream->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 = stream->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. */
+			+ stream->cur_frame->wWidth * pixel_size
+			* stream->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");
Ciao aytin, ho provato la tua patch ma poi il make mi da errore:

cd v4l-dvb-8dce45a4be76/linux/drivers/media/video/uvc
patch < p2nm.txt
patching file uvc_video.c
Hunk #1 succeeded at 448 (offset 77 lines).
cd v4l-dvb-8dce45a4be76/
make
............
............
CC [M]  /home/dev/Download/v4l-dvb-8dce45a4be76/v4l/uvc_video.o
/home/dev/Download/v4l-dvb-8dce45a4be76/v4l/uvc_video.c: In function 'uvc_video_decode_data':
/home/dev/Download/v4l-dvb-8dce45a4be76/v4l/uvc_video.c:496: error: 'struct uvc_streaming' has no member named 'streaming'
/home/dev/Download/v4l-dvb-8dce45a4be76/v4l/uvc_video.c:507: error: 'struct uvc_streaming' has no member named 'streaming'
/home/dev/Download/v4l-dvb-8dce45a4be76/v4l/uvc_video.c:508: error: 'struct uvc_streaming' has no member named 'streaming'
make[3]: *** [/home/dev/Download/v4l-dvb-8dce45a4be76/v4l/uvc_video.o] Error 1
make[2]: *** [_module_/home/dev/Download/v4l-dvb-8dce45a4be76/v4l] Error 2
make[2]: Leaving directory `/usr/src/linux-headers-2.6.28-15-generic'
make[1]: *** [default] Errore 2
make[1]: uscita dalla directory «/home/dev/Download/v4l-dvb-8dce45a4be76/v4l»
make: *** [all] Errore 2
Avatar utente
aytin
Prode Principiante
Messaggi: 76
Iscrizione: lunedì 28 aprile 2008, 8:22

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da aytin »

???
Avrò postato una versione sbagliata... strano.
Dall'errore (che è quello che facevo prima dell'intervento di giaccava) risulta che nel file uvcvideo.c la nuova struttura dati struct uvc_streaming (variabile stream) fa riferimento ad un oggetto di tipo streaming che non esiste (lo era nella vecchia versione) e giustamente va in errore.
Ma non dovrebbe esserci una simile occorrenza.
Provo a rifare il processo da 0 usando il file che ho postato e ti faccio sapere.
Avatar utente
aytin
Prode Principiante
Messaggi: 76
Iscrizione: lunedì 28 aprile 2008, 8:22

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da aytin »

E infatti era un errore mio.
Il codice quotato era corretto ma non l'allegato.
L'ho corretto ora.
Se lo riscarichi e ripatchi vedrai che andrà a buon fine.
rainboww
Prode Principiante
Messaggi: 42
Iscrizione: sabato 8 agosto 2009, 10:28

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da rainboww »

Grazie aytin, ho riprovato e funge tutto!  (good)
Avatar utente
Tizianub
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 2923
Iscrizione: giovedì 5 aprile 2007, 18:47
Località: Jesi (AN)
Contatti:

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da Tizianub »

Grazie a tutti!!! tutto perfetto  (b2b) (b2b)
Avatar utente
aytin
Prode Principiante
Messaggi: 76
Iscrizione: lunedì 28 aprile 2008, 8:22

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da aytin »

(good)
ok, non rimane che eseguire la sostituzione su tutte e 4 le patch in prima pagina (dopo aver verificato che funzionino ovviamente) e far ritornare tutto alla normalità  ;)
Avatar utente
aytin
Prode Principiante
Messaggi: 76
Iscrizione: lunedì 28 aprile 2008, 8:22

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da aytin »

Ho effettuato le sostituzioni su tutti e 4 i files noti ormai a tutti :)
Intanti li posto e verifico che la compilazione vada a buon fine.
Finita questa verifica, arjos85 può prelevare da qui i files e aggiornare i suoi nel 1° post del 3d, in modo da rendere nuovamente consistente la discussione.
Eventuali correzioni che dovessero rendersi necessarie (spero di non avere problemi con nessuno dei 4) saranno effettute sempre in questo post.

Edit: ho controllato tutte le patch su una macchina linux e funzionano tutte (patch/compilazione/installazione)
Allegati
patch_solution2_NOTmirrored.txt
(3.81 KiB) Scaricato 104 volte
patch_solution2_mirrored.txt
(4.06 KiB) Scaricato 85 volte
patch_solution1_NOTmirrored.txt
(4.59 KiB) Scaricato 93 volte
patch_solution1_mirrored.txt
(3.86 KiB) Scaricato 118 volte
Ultima modifica di aytin il giovedì 17 settembre 2009, 12:42, modificato 1 volta in totale.
Avatar utente
abecchio
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 589
Iscrizione: sabato 20 settembre 2008, 13:15
Località: Solagna

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da abecchio »

Buongiorno a tutti!

Da poco ho ricevuto un ASUS X5DIJseries in regalo per la futura laurea... Tutto funziona (audio, internet, effetti grafici...) a differenza di Jaunty. Solo la webcam è ribaltata (solo su ubuntu, su sVista tutto funziona, quindi non è stata montata al contrario)...

Sto usando una live di Karmic beta e magari può essere questo il problema...

In ogni caso vi posto l'output di

Codice: Seleziona tutto

lsusb

Codice: Seleziona tutto

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 04f2:b071 Chicony Electronics Co., Ltd 2.0M UVC WebCam / CNF7129
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Per quanto riguarda il comando

Codice: Seleziona tutto

ubuntu@ubuntu:~$ sudo lsusb -d 04f2:b071 -v | grep "14 Video"

Codice: Seleziona tutto

 bFunctionClass         14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
Vi chiedo aiuto perchè non capisco molto quello che è scritto sul primo post con tutte le correzioni e update sussegitisi nel tempo... scusate se vi secco :-[
Avatar utente
basettoni
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 682
Iscrizione: venerdì 1 giugno 2007, 14:47

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da basettoni »

abecchio ha scritto: Buongiorno a tutti!

Da poco ho ricevuto un ASUS X5DIJseries in regalo per la futura laurea... Tutto funziona (audio, internet, effetti grafici...) a differenza di Jaunty. Solo la webcam è ribaltata (solo su ubuntu, su sVista tutto funziona, quindi non è stata montata al contrario)...

Sto usando una live di Karmic beta e magari può essere questo il problema...

In ogni caso vi posto l'output di

Codice: Seleziona tutto

lsusb

Codice: Seleziona tutto

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 04f2:b071 Chicony Electronics Co., Ltd 2.0M UVC WebCam / CNF7129
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Per quanto riguarda il comando

Codice: Seleziona tutto

ubuntu@ubuntu:~$ sudo lsusb -d 04f2:b071 -v | grep "14 Video"

Codice: Seleziona tutto

 bFunctionClass         14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
      bInterfaceClass        14 Video
Vi chiedo aiuto perchè non capisco molto quello che è scritto sul primo post con tutte le correzioni e update sussegitisi nel tempo... scusate se vi secco :-[
La webcam è senz' altro montata al contrario altrimenti anche su ubuntu non avresti l' immagine ribaltata, solo che vista te lo danno con i driver modificati mentre su ubuntu li devi modicare tu. Adesso se non sbaglio le patch dovrebbero funzionare, quindi ricomincia a leggere il post dall' inizio e prova a far funzionare la tua webcam, nel frattempo puoi installare cheese (software per gestire le webcam) il quale tra gli altri effetti nè ha uno che ti capavolge l' immagine.
Avatar utente
stevekh3
Prode Principiante
Messaggi: 53
Iscrizione: venerdì 24 ottobre 2008, 11:23
Località: Cervignano del Friuli (UD)

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da stevekh3 »

Sto provando la Beta di Ubuntu 9.10 sul mio ASUS N10J, (webcam Chicony) e finalmente l'immagine è diritta senza bisogno di patch  (good).
Linux user number 486747
bobotti
Prode Principiante
Messaggi: 10
Iscrizione: venerdì 22 maggio 2009, 19:37

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da bobotti »

Ciao.
Webcam capovolta anche io!
Io ho trovato questa versione dei driver sul sito uvcvideo-756ad91a832e.

Il mio problema è che passa alla funzione che dovrei modificare una struttura diversa chiamata "uvc_streaming".
Guardando la libreria ho visto che contiene gli stessi dati della struttura uvc_video_device usata in questa guida allora ho fatto così, ho modificato la patch cercando di adattarla, così:

Codice: Seleziona tutto

static void uvc_video_decode_data(struct uvc_streaming *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->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->cur_frame->wWidth * pixel_size
			* video->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");
		buf->state = UVC_BUF_STATE_DONE;
	}
}
Nella libreria la struttura è così:

Codice: Seleziona tutto

struct uvc_streaming {
	struct list_head list;
	struct uvc_device *dev;
	struct video_device *vdev;
	struct uvc_video_chain *chain;
	atomic_t active;

	struct usb_interface *intf;
	int intfnum;
	__u16 maxpsize;

	struct uvc_streaming_header header;
	enum v4l2_buf_type type;

	unsigned int nformats;
	struct uvc_format *format;

	struct uvc_streaming_control ctrl;
	struct uvc_format *cur_format;
	struct uvc_frame *cur_frame;

	struct mutex mutex;

	unsigned int frozen : 1;
	struct uvc_video_queue queue;
	void (*decode) (struct urb *urb, struct uvc_streaming *video,
			struct uvc_buffer *buf);

	/* Context data used by the bulk completion handler. */
	struct {
		__u8 header[256];
		unsigned int header_size;
		int skip_payload;
		__u32 payload_size;
		__u32 max_payload_size;
	} bulk;

	struct urb *urb[UVC_URBS];
	char *urb_buffer[UVC_URBS];
	dma_addr_t urb_dma[UVC_URBS];
	unsigned int urb_size;

	__u8 last_fid;
};
Purtroppo io non ho fatto delle modifiche pensando al contenuto e al significato delle strutture perché non ho tempo di approfondire, quindi è probabile che io abbia scritto cose senza senso.
Il make finisce bene. Ma il comando modprobe -f uvcvideo mi dice:

Codice: Seleziona tutto

FATAL: Error inserting uvcvideo (/lib/modules/2.6.28-15-generic/kernel/drivers/media/video/uvc/uvcvideo.ko): Invalid module format
Cosa che non succede se lascio il file originale.

Ho delle possibilità?
:(
Ultima modifica di bobotti il giovedì 8 ottobre 2009, 18:27, modificato 1 volta in totale.
Avatar utente
abecchio
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 589
Iscrizione: sabato 20 settembre 2008, 13:15
Località: Solagna

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da abecchio »

basettoni ha scritto: La webcam è senz' altro montata al contrario altrimenti anche su ubuntu non avresti l' immagine ribaltata, solo che vista te lo danno con i driver modificati mentre su ubuntu li devi modicare tu. Adesso se non sbaglio le patch dovrebbero funzionare, quindi ricomincia a leggere il post dall' inizio e prova a far funzionare la tua webcam, nel frattempo puoi installare cheese (software per gestire le webcam) il quale tra gli altri effetti nè ha uno che ti capavolge l' immagine.
Ok... è montata al contrario!

Ma ho riletto il primo post ma mi perdo di continuo... Con tutte le cancellature, update e cambi di colore mi rincretinisco (non è una critica verso il tuo lavoro, ma verso il mio cervello)

avrei bisogno di un how-to meno "didattico"... :-[
Avatar utente
aytin
Prode Principiante
Messaggi: 76
Iscrizione: lunedì 28 aprile 2008, 8:22

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da aytin »

bobotti ha scritto: Ciao.
Webcam capovolta anche io!
Io ho trovato questa versione dei driver sul sito uvcvideo-756ad91a832e.

Il mio problema è che passa alla funzione che dovrei modificare una struttura diversa chiamata "uvc_streaming".
Guardando la libreria ho visto che contiene gli stessi dati della struttura uvc_video_device usata in questa guida allora ho fatto così, ho modificato la patch cercando di adattarla, così:

Codice: Seleziona tutto

static void uvc_video_decode_data(struct uvc_streaming *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->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->cur_frame->wWidth * pixel_size
			* video->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");
		buf->state = UVC_BUF_STATE_DONE;
	}
}
Nella libreria la struttura è così:

Codice: Seleziona tutto

struct uvc_streaming {
	struct list_head list;
	struct uvc_device *dev;
	struct video_device *vdev;
	struct uvc_video_chain *chain;
	atomic_t active;

	struct usb_interface *intf;
	int intfnum;
	__u16 maxpsize;

	struct uvc_streaming_header header;
	enum v4l2_buf_type type;

	unsigned int nformats;
	struct uvc_format *format;

	struct uvc_streaming_control ctrl;
	struct uvc_format *cur_format;
	struct uvc_frame *cur_frame;

	struct mutex mutex;

	unsigned int frozen : 1;
	struct uvc_video_queue queue;
	void (*decode) (struct urb *urb, struct uvc_streaming *video,
			struct uvc_buffer *buf);

	/* Context data used by the bulk completion handler. */
	struct {
		__u8 header[256];
		unsigned int header_size;
		int skip_payload;
		__u32 payload_size;
		__u32 max_payload_size;
	} bulk;

	struct urb *urb[UVC_URBS];
	char *urb_buffer[UVC_URBS];
	dma_addr_t urb_dma[UVC_URBS];
	unsigned int urb_size;

	__u8 last_fid;
};
Purtroppo io non ho fatto delle modifiche pensando al contenuto e al significato delle strutture perché non ho tempo di approfondire, quindi è probabile che io abbia scritto cose senza senso.
Il make finisce bene. Ma il comando modprobe -f uvcvideo mi dice:

Codice: Seleziona tutto

FATAL: Error inserting uvcvideo (/lib/modules/2.6.28-15-generic/kernel/drivers/media/video/uvc/uvcvideo.ko): Invalid module format
Cosa che non succede se lascio il file originale.

Ho delle possibilità?
:(
http://forum.ubuntu-it.org/viewtopic.ph ... 5#p2417805
bobotti
Prode Principiante
Messaggi: 10
Iscrizione: venerdì 22 maggio 2009, 19:37

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribalta

Messaggio da bobotti »

Ultima modifica di bobotti il domenica 11 ottobre 2009, 11:55, modificato 1 volta in totale.
Avatar utente
basettoni
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 682
Iscrizione: venerdì 1 giugno 2007, 14:47

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da basettoni »

Buon giorno a tutti, sto provando la beta di ubuntu 9.10, non riesco a drizzare la webcam, sapreste dirmi se la guida è valida o meno?
rainboww
Prode Principiante
Messaggi: 42
Iscrizione: sabato 8 agosto 2009, 10:28

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da rainboww »

basettoni ha scritto: Buon giorno a tutti, sto provando la beta di ubuntu 9.10, non riesco a drizzare la webcam, sapreste dirmi se la guida è valida o meno?
Ciao, anche io sono passato a karmic e il problema della webcam ribaltata si è ripresentato.
Sembra che ci siano problemi con il kernel in fase di compilazione come si capisce da questo post
http://www.mail-archive.com/ubuntu-deve ... 09422.html

Vengono proposte due soluzioni:

"So a quick work around is to disable the firedtv driver by modifying the
./v4l/.config file and changing '=m' to '=n' on the firedtv line.

The longer solution is to install the kernel source and then modify the
makefile configuration options to use that instead of the headers (it will
default to using the headers still if not configured correctly). If you're
not using firedtv, this is not worth it."

Faccio dei test.

Quando finisco faccio sapere.  :)
Ultima modifica di rainboww il giovedì 22 ottobre 2009, 19:25, modificato 1 volta in totale.
rainboww
Prode Principiante
Messaggi: 42
Iscrizione: sabato 8 agosto 2009, 10:28

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da rainboww »

rainboww ha scritto:
basettoni ha scritto: Buon giorno a tutti, sto provando la beta di ubuntu 9.10, non riesco a drizzare la webcam, sapreste dirmi se la guida è valida o meno?
Ciao, anche io sono passato a karmic e il problema della webcam ribaltata si è ripresentato.
Sembra che ci siano problemi con il kernel in fase di compilazione come si capisce da questo post
http://www.mail-archive.com/ubuntu-deve ... 09422.html

Vengono proposte due soluzioni:

"So a quick work around is to disable the firedtv driver by modifying the
./v4l/.config file and changing '=m' to '=n' on the firedtv line.

The longer solution is to install the kernel source and then modify the
makefile configuration options to use that instead of the headers (it will
default to using the headers still if not configured correctly). If you're
not using firedtv, this is not worth it."

Faccio dei test.

Quando finisco faccio sapere.  :)
Per chi è passato a karmic è possibile installare ugualmente le patch, ma prima bisogna aggirare un problema in fase di compilazione di v4l-dvb.

Mi sono rifatto a questo post
http://www.mail-archive.com/ubuntu-deve ... 09367.html

Dopo aver applicato la patch preferita, prima del make va utilizzato sudo make menuconfig in modo da disattivare FireDTV and FloppyDTV

In pratica dando da terminale il comando sudo make menuconfig dovete navigare nel pannello di configurazione che appare seguendo questo percorso:
Multimedia support --->DVB/ATSC adapters  --->FireDTV and FloppyDTV
quando avete selezionato la voce FireDTV and FloppyDTV la disattivate col tasto N quindi premete sempre Esc e prima di uscire dalla configurazione confermate salvando la modifica.

Dopo questo potete procedere normalmente con make e continuare come indicato su questa guida.
Allegati
FireDTV.png
Ultima modifica di rainboww il giovedì 22 ottobre 2009, 19:46, modificato 1 volta in totale.
Avatar utente
Tizianub
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 2923
Iscrizione: giovedì 5 aprile 2007, 18:47
Località: Jesi (AN)
Contatti:

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da Tizianub »

rainboww ha scritto:
Dopo aver applicato la patch preferita, prima del make va utilizzato sudo make menuconfig in modo da disattivare FireDTV and FloppyDTV

facendo questo ricevo questo errore:

Codice: Seleziona tutto

make -C /home/tiziano/v4l-dvb-b8282a1720c4/v4l menuconfig
make[1]: ingresso nella directory «/home/tiziano/v4l-dvb-b8282a1720c4/v4l»
make -C /lib/modules/2.6.31-14-generic/build -f /home/tiziano/v4l-dvb-b8282a1720c4/v4l/Makefile.kernel config-targets=1 mixed-targets=0 dot-config=0 SRCDIR=/lib/modules/2.6.31-14-generic/build v4l-mconf
make[2]: Entering directory `/usr/src/linux-headers-2.6.31-14-generic'
make -f /lib/modules/2.6.31-14-generic/build/scripts/Makefile.build obj=scripts/kconfig hostprogs-y=mconf scripts/kconfig/mconf
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
make[3]: *** [scripts/kconfig/dochecklxdialog] Error 1
make[2]: *** [v4l-mconf] Error 2
make[2]: Leaving directory `/usr/src/linux-headers-2.6.31-14-generic'
make[1]: *** [/lib/modules/2.6.31-14-generic/build/scripts/kconfig/mconf] Errore 2
make[1]: uscita dalla directory «/home/tiziano/v4l-dvb-b8282a1720c4/v4l»
make: *** [menuconfig] Errore 2
non so come andare avanti
rainboww
Prode Principiante
Messaggi: 42
Iscrizione: sabato 8 agosto 2009, 10:28

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da rainboww »

Come dice il messaggio ti mancano le librerie ncurses che devi installare da gestore pacchetti
Ti allego quelle che ho io  :)
Allegati
libncurses.png
Avatar utente
Tizianub
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 2923
Iscrizione: giovedì 5 aprile 2007, 18:47
Località: Jesi (AN)
Contatti:

Re: [Driver] [HOW TO] UVCVIDEO : come risolvere il problema della webcam ribaltata

Messaggio da Tizianub »

rainboww ha scritto: Come dice il messaggio ti mancano le librerie ncurses che devi installare da gestore pacchetti
Ti allego quelle che ho io  :)
grazie, avevo provato con sudo apt-get install ncurses, ma ovviamente non c'era, non ho pensato a synaptic. ora ho fatto la web non è più capovolta.... ma l'immagine è ferma.

spiego meglio appena apro cheese si vede la mia immagine ma poi non si muove più se provo a fare una foto o un video li fa correttamente ma non vedo l'immagine muoversi sullo schermo

dimenticavo quando era capovolta funzionava
Scrivi risposta

Ritorna a “Driver e periferiche”

Chi c’è in linea

Visualizzano questa sezione: 0 utenti iscritti e 7 ospiti