From patchwork Fri Jan 28 19:35:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Lachowsky X-Patchwork-Id: 515621 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0SJZKZ1014423 for ; Fri, 28 Jan 2011 19:35:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754220Ab1A1TfJ (ORCPT ); Fri, 28 Jan 2011 14:35:09 -0500 Received: from antispam01.maxim-ic.com ([205.153.101.182]:37041 "EHLO antispam01.dummydomain.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753721Ab1A1TfI (ORCPT ); Fri, 28 Jan 2011 14:35:08 -0500 X-ASG-Debug-ID: 1296243307-62116bf90001-rVgMWv Received: from terlingua.dalsemi.com (terlingua.dalsemi.com [180.0.34.46]) by antispam01.dummydomain.com with ESMTP id ORJaSPBWhNmuX0Hp; Fri, 28 Jan 2011 13:35:07 -0600 (CST) X-Barracuda-Envelope-From: stephan.lachowsky@maxim-ic.com X-Barracuda-Apparent-Source-IP: 180.0.34.46 Received: from maxdalex02.maxim-ic.internal (maxdalex02.maxim-ic.internal [10.16.15.104] (may be forged)) by terlingua.dalsemi.com (8.10.2/8.10.2) with ESMTP id p0SJZ6I24585; Fri, 28 Jan 2011 13:35:06 -0600 (CST) Received: from maxsvlex01.maxim-ic.internal (172.18.47.214) by maxdalex02.maxim-ic.internal (10.16.15.104) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 28 Jan 2011 13:35:06 -0600 Received: from [10.32.80.201] (10.32.80.201) by maxsvlex01.maxim-ic.internal (172.18.47.214) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 28 Jan 2011 11:35:05 -0800 Subject: [PATCH RFC] uvcvideo: Add support for MPEG-2 TS payload From: Stephan Lachowsky X-ASG-Orig-Subj: [PATCH RFC] uvcvideo: Add support for MPEG-2 TS payload To: Laurent Pinchart CC: "linux-media@vger.kernel.org" , "linux-uvc-devel@lists.berlios.de" Date: Fri, 28 Jan 2011 11:35:05 -0800 Message-ID: <1296243305.17673.20.camel@svmlwks101> MIME-Version: 1.0 X-Mailer: Evolution 2.32.1 (2.32.1-1.fc14) X-Barracuda-Connect: terlingua.dalsemi.com[180.0.34.46] X-Barracuda-Start-Time: 1296243307 X-Barracuda-URL: http://AntiSpam02.maxim-ic.com:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at dummydomain.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.53710 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 28 Jan 2011 19:35:40 +0000 (UTC) diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c index a1e9dfb..6bcb9e1 100644 --- a/drivers/media/video/uvc/uvc_driver.c +++ b/drivers/media/video/uvc/uvc_driver.c @@ -103,6 +103,11 @@ static struct uvc_format_desc uvc_fmts[] = { .guid = UVC_GUID_FORMAT_BY8, .fcc = V4L2_PIX_FMT_SBGGR8, }, + { + .name = "MPEG2 TS", + .guid = UVC_GUID_FORMAT_MPEG, + .fcc = V4L2_PIX_FMT_MPEG, + }, }; /* ------------------------------------------------------------------------ @@ -398,6 +403,33 @@ static int uvc_parse_format(struct uvc_device *dev, break; case UVC_VS_FORMAT_MPEG2TS: + n = dev->uvc_version >= 0x0110 ? 23 : 7; + if (buflen < n) { + uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " + "interface %d FORMAT error\n", + dev->udev->devnum, + alts->desc.bInterfaceNumber); + return -EINVAL; + } + + strlcpy(format->name, "MPEG2 TS", sizeof format->name); + format->fcc = V4L2_PIX_FMT_MPEG; + format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM; + format->bpp = 0; + ftype = 0; + + /* Create a dummy frame descriptor. */ + frame = &format->frame[0]; + memset(&format->frame[0], 0, sizeof format->frame[0]); + frame->bFrameIntervalType = 0; + frame->dwDefaultFrameInterval = 1; + frame->dwFrameInterval = *intervals; + *(*intervals)++ = 1; + *(*intervals)++ = 10000000; + *(*intervals)++ = 1; + format->nframes = 1; + break; + case UVC_VS_FORMAT_STREAM_BASED: /* Not supported yet. */ default: @@ -673,6 +705,14 @@ static int uvc_parse_streaming(struct uvc_device *dev, break; case UVC_VS_FORMAT_MPEG2TS: + /* MPEG2TS format has no frame descriptor. We will create a + * dummy frame descriptor with a dummy frame interval range. + */ + nformats++; + nframes++; + nintervals += 3; + break; + case UVC_VS_FORMAT_STREAM_BASED: uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " "interface %d FORMAT %u is not supported.\n", @@ -724,6 +764,7 @@ static int uvc_parse_streaming(struct uvc_device *dev, switch (buffer[2]) { case UVC_VS_FORMAT_UNCOMPRESSED: case UVC_VS_FORMAT_MJPEG: + case UVC_VS_FORMAT_MPEG2TS: case UVC_VS_FORMAT_DV: case UVC_VS_FORMAT_FRAME_BASED: format->frame = frame; diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index 45f01e7..e522f99 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h @@ -152,6 +152,9 @@ struct uvc_xu_control { #define UVC_GUID_FORMAT_BY8 \ { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} +#define UVC_GUID_FORMAT_MPEG \ + { 'M', 'P', 'E', 'G', 0x00, 0x00, 0x10, 0x00, \ + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} /* ------------------------------------------------------------------------ * Driver specific constants.