Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] [V4L] Re: Xv and v4l device



Hi Gerd, 
since you are one of the authors of the v4l module for Xfree I send
you this patch and of course for everyone on the v4l list who is
interested. The same goes for the linux-dvb list for anyone who wants
to compile a new v4l_drv.o to get scaling support with Xv for their dvb card.

I added a query for UYVY in the v4l and the Xv driver if the
YUV422 query failed. This way it works with bttv and dvb driver, but
if I turn it around the bttv colors are wrong because UYVY would be
chosen. The way I wrote it right now is not very elegant. There should
probably be some procedure checking all possible color modes for the
v4l device and the graphics card and deciding which one too choose to
get the best results. 


Marcus


135a136
>     int                         yuv_format;
341c342
< 	pPPriv->pict.palette = VIDEO_PALETTE_YUV422;
---
> 	pPPriv->pict.palette = pPPriv->yuv_format;
891,907c892,941
< 	    ioctl(fd,VIDIOCGPICT,&pPPriv->pict);    
< 	    if (VIDEO_PALETTE_YUV422 == pPPriv->pict.palette) {
< 		/* works, check screen capabilities */
< 		DEBUG(xf86Msg(X_INFO, "v4l: kernel driver supports yuv422.\n"));
< 		pPPriv->format = xf86XVQueryOffscreenImages
< 		    (pScreen,&pPPriv->nformat);
< 		DEBUG(xf86Msg(X_INFO, "v4l: screen driver supports %d yuv formats (%p)\n",
< 			      pPPriv->nformat,pPPriv->format));
< 		for (j = 0; j < pPPriv->nformat; j++) {
< 		    DEBUG(xf86Msg(X_INFO, "v4l: yuv format: %4.4s\n",
< 				  (char*)&(pPPriv->format[j].image->id)));
< 		    if (pPPriv->format[j].image->id     == 0x32595559 &&
< 			pPPriv->format[j].image->format == XvPacked) {
< 			pPPriv->have_yuv = 1;
< 			pPPriv->myfmt = pPPriv->format+j;
< 			DEBUG(xf86Msg(X_INFO,  "v4l: matching format found, offscreen yuv enabled.\n"));
< 		    }
---
> 		ioctl(fd,VIDIOCGPICT,&pPPriv->pict);    
> 		if (VIDEO_PALETTE_YUV422 == pPPriv->pict.palette) {
> 	    /* works, check screen capabilities */
> 			DEBUG(xf86Msg(X_INFO, "v4l: kernel driver supports yuv422.\n"));
> 			pPPriv->format = xf86XVQueryOffscreenImages
> 	      (pScreen,&pPPriv->nformat);
> 			DEBUG(xf86Msg(X_INFO, "v4l: screen driver supports %d yuv formats (%p)\n",
> 				      pPPriv->nformat,pPPriv->format));
> 			for (j = 0; j < pPPriv->nformat; j++) {
> 				DEBUG(xf86Msg(X_INFO, "v4l: yuv format: %4.4s\n",
> 					      (char*)&(pPPriv->format[j].image->id)));
> 				if (pPPriv->format[j].image->id     == 0x32595559 &&
> 				    pPPriv->format[j].image->format == XvPacked) {
> 					pPPriv->have_yuv = 1;
> 					pPPriv->yuv_format = VIDEO_PALETTE_YUV422;
> 					pPPriv->myfmt = pPPriv->format+j;
> 					DEBUG(xf86Msg(X_INFO,  "v4l: matching format found, offscreen yuv enabled.\n"));
> 				}
> 			}
> 		}
> 	}
> #endif
> #if 1
> 	if ( !pPPriv->have_yuv){ 
> 		/* test v4l device for yuv support:  check if the driver
> 		   accepts VIDEO_PALETTE_UYVY */
> 		ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
> 		pPPriv->pict.palette = VIDEO_PALETTE_UYVY;
> 		pPPriv->pict.depth   = 16;
> 		if (0 == ioctl(fd,VIDIOCSPICT,&pPPriv->pict)) {
> 			ioctl(fd,VIDIOCGPICT,&pPPriv->pict);    
> 			if ( VIDEO_PALETTE_UYVY == pPPriv->pict.palette) {
> 		    /* works, check screen capabilities */
> 				DEBUG(xf86Msg(X_INFO, "v4l: kernel driver supports uyvy.\n"));
> 				pPPriv->format = xf86XVQueryOffscreenImages
> 					(pScreen,&pPPriv->nformat);
> 				DEBUG(xf86Msg(X_INFO, "v4l: screen driver supports %d yuv formats (%p)\n",
> 					      pPPriv->nformat,pPPriv->format));
> 				for (j = 0; j < pPPriv->nformat; j++) {
> 					DEBUG(xf86Msg(X_INFO, "v4l: yuv format: %4.4s\n",
> 						      (char*)&(pPPriv->format[j].image->id)));
> 					if (pPPriv->format[j].image->id     == 0x59565955 &&
> 					    pPPriv->format[j].image->format == XvPacked) {
> 						pPPriv->have_yuv = 1;
> 						pPPriv->yuv_format = VIDEO_PALETTE_UYVY;
> 						pPPriv->myfmt = pPPriv->format+j;
> 						DEBUG(xf86Msg(X_INFO,  "v4l: matching format found, offscreen yuv enabled.\n"));
> 					}
> 				}
> 			}
909d942
< 	    }




-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.


Home | Main Index | Thread Index