Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > b7b6877999d0754e8ed227e0b2f603dc > files > 53

syntek-1.3.1-6mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>SyntekUSBVideoCamera: stk11xx-usb.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<h1>stk11xx-usb.c</h1><a href="stk11xx-usb_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;linux/module.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;linux/init.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;linux/kernel.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;linux/version.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;linux/errno.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;linux/slab.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;linux/kref.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2,6,27)</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor">#include &lt;linux/mm.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#endif</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;linux/usb.h&gt;</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;media/v4l2-common.h&gt;</span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="preprocessor">#include "<a class="code" href="stk11xx_8h.html" title="Driver for Syntek USB video camera.">stk11xx.h</a>"</span>
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 
<a name="l00055"></a><a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">00055</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a> = -1;
<a name="l00056"></a>00056 
<a name="l00061"></a><a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">00061</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a> = -1;
<a name="l00062"></a>00062 
<a name="l00067"></a><a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">00067</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a> = -1;
<a name="l00068"></a>00068 
<a name="l00073"></a><a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">00073</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a> = -1;
<a name="l00074"></a>00074 
<a name="l00079"></a><a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">00079</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a> = -1;
<a name="l00080"></a>00080 
<a name="l00085"></a><a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">00085</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a> = -1;
<a name="l00086"></a>00086 
<a name="l00091"></a><a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">00091</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a> = -1;
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 
<a name="l00098"></a><a class="code" href="stk11xx-usb_8c.html#127a4e93e778356be60aef052a4b2594">00098</a> <span class="keyword">static</span> <span class="keyword">struct </span>usb_device_id <a class="code" href="stk11xx-usb_8c.html#127a4e93e778356be60aef052a4b2594">stk11xx_table</a>[] = {
<a name="l00099"></a>00099     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#b10b64fc880949ce0503df77bcad8ed1">USB_STK_A311_PRODUCT_ID</a>) },
<a name="l00100"></a>00100     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#f8fbeced8d03a4662b945faa8fb97d34">USB_STK_A821_PRODUCT_ID</a>) },
<a name="l00101"></a>00101     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#433f18ebde586610039cb3f98a360a0d">USB_STK_6A31_PRODUCT_ID</a>) },
<a name="l00102"></a>00102     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#0e65935d0a86b7308c3314082e4f8e28">USB_STK_6A33_PRODUCT_ID</a>) },
<a name="l00103"></a>00103     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#7893d73e6865a8b61f07efe5978ce62a">USB_STK_6A51_PRODUCT_ID</a>) },
<a name="l00104"></a>00104     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#9051e3ea42b0b1d3d6083389381cde6f">USB_STK_6A54_PRODUCT_ID</a>) },
<a name="l00105"></a>00105 
<a name="l00106"></a>00106     { USB_DEVICE(<a class="code" href="stk11xx_8h.html#6d15e8c0162bcf42c8192fdf8fc1b516">USB_SYNTEK2_VENDOR_ID</a>, <a class="code" href="stk11xx_8h.html#08f8051e3d5cafd2f39bc274921db312">USB_STK_0501_PRODUCT_ID</a>) },
<a name="l00107"></a>00107     { }
<a name="l00108"></a>00108 };
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 <a class="code" href="stk11xx-usb_8c.html#ee54731989f6ea6cac234dadf5c72ba8">MODULE_DEVICE_TABLE</a>(usb, <a class="code" href="stk11xx-usb_8c.html#127a4e93e778356be60aef052a4b2594">stk11xx_table</a>);        
<a name="l00124"></a><a class="code" href="stk11xx_8h.html#003ffdf3e0f5f20d60b69650e1b7d769">00124</a> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#e7d7590e86071e46320dc3238eb03ef8" title="Initilize an isochronous pipe.">usb_stk11xx_isoc_init</a>(<span class="keyword">struct</span> usb_stk11xx *dev)
<a name="l00125"></a>00125 {
<a name="l00126"></a>00126     <span class="keywordtype">int</span> i, j;
<a name="l00127"></a>00127     <span class="keywordtype">int</span> ret = 0;
<a name="l00128"></a>00128     <span class="keyword">struct </span>urb *urb;
<a name="l00129"></a>00129     <span class="keyword">struct </span>usb_device *udev;
<a name="l00130"></a>00130 
<a name="l00131"></a>00131     <span class="keywordflow">if</span> (dev == NULL)
<a name="l00132"></a>00132         <span class="keywordflow">return</span> -EFAULT;
<a name="l00133"></a>00133 
<a name="l00134"></a>00134     <span class="keywordflow">if</span> (dev-&gt;isoc_init_ok)
<a name="l00135"></a>00135         <span class="keywordflow">return</span> 0;
<a name="l00136"></a>00136 
<a name="l00137"></a>00137     udev = dev-&gt;udev;
<a name="l00138"></a>00138 
<a name="l00139"></a>00139     <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"usb_stk11xx_isoc_init()\n"</span>);
<a name="l00140"></a>00140 
<a name="l00141"></a>00141     <span class="comment">// Allocate URB structure</span>
<a name="l00142"></a>00142     <span class="keywordflow">for</span> (i=0; i&lt;<a class="code" href="stk11xx_8h.html#ac10237297a8b2b0665e56179c99b64f">MAX_ISO_BUFS</a>; i++) {
<a name="l00143"></a>00143         urb = usb_alloc_urb(<a class="code" href="stk11xx_8h.html#e588d0730bf3cd5f13c3888a6b1b6d5a">ISO_FRAMES_PER_DESC</a>, GFP_KERNEL);
<a name="l00144"></a>00144 
<a name="l00145"></a>00145         <span class="keywordflow">if</span> (urb == NULL) {
<a name="l00146"></a>00146             <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Failed to allocate URB %d\n"</span>, i);
<a name="l00147"></a>00147             ret = -ENOMEM;
<a name="l00148"></a>00148             <span class="keywordflow">break</span>;
<a name="l00149"></a>00149         }
<a name="l00150"></a>00150 
<a name="l00151"></a>00151         dev-&gt;isobuf[i].urb = urb;
<a name="l00152"></a>00152     }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154     <span class="keywordflow">if</span> (ret) {
<a name="l00155"></a>00155         <span class="keywordflow">while</span> (i &gt;= 0) {
<a name="l00156"></a>00156             <span class="keywordflow">if</span> (dev-&gt;isobuf[i].urb != NULL)
<a name="l00157"></a>00157                 usb_free_urb(dev-&gt;isobuf[i].urb);
<a name="l00158"></a>00158 
<a name="l00159"></a>00159             dev-&gt;isobuf[i].urb = NULL;
<a name="l00160"></a>00160             i--;
<a name="l00161"></a>00161         }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163         <span class="keywordflow">return</span> ret;
<a name="l00164"></a>00164     }
<a name="l00165"></a>00165 
<a name="l00166"></a>00166     <span class="comment">// Init URB structure</span>
<a name="l00167"></a>00167     <span class="keywordflow">for</span> (i=0; i&lt;MAX_ISO_BUFS; i++) {
<a name="l00168"></a>00168         urb = dev-&gt;isobuf[i].urb;
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         urb-&gt;interval = 1; 
<a name="l00171"></a>00171         urb-&gt;dev = udev;
<a name="l00172"></a>00172         urb-&gt;pipe = usb_rcvisocpipe(udev, dev-&gt;isoc_in_endpointAddr);
<a name="l00173"></a>00173         urb-&gt;transfer_flags = URB_ISO_ASAP;
<a name="l00174"></a>00174         urb-&gt;transfer_buffer = dev-&gt;isobuf[i].data;
<a name="l00175"></a>00175         urb-&gt;transfer_buffer_length = <a class="code" href="stk11xx_8h.html#845fc3faad4ba5aedfae60d91db77736">ISO_BUFFER_SIZE</a>;
<a name="l00176"></a>00176         urb-&gt;complete = <a class="code" href="stk11xx-usb_8c.html#dc5f3754dd0e3a30f0d6cab5135e5d2b" title="ISOC handler.">usb_stk11xx_isoc_handler</a>;
<a name="l00177"></a>00177         urb-&gt;context = dev;
<a name="l00178"></a>00178         urb-&gt;start_frame = 0;
<a name="l00179"></a>00179         urb-&gt;number_of_packets = <a class="code" href="stk11xx_8h.html#e588d0730bf3cd5f13c3888a6b1b6d5a">ISO_FRAMES_PER_DESC</a>;
<a name="l00180"></a>00180 
<a name="l00181"></a>00181         <span class="keywordflow">for</span> (j=0; j&lt;<a class="code" href="stk11xx_8h.html#e588d0730bf3cd5f13c3888a6b1b6d5a">ISO_FRAMES_PER_DESC</a>; j++) {
<a name="l00182"></a>00182             urb-&gt;iso_frame_desc[j].offset = j * <a class="code" href="stk11xx_8h.html#95e294179b485a466ddd6520f56e9431">ISO_MAX_FRAME_SIZE</a>;
<a name="l00183"></a>00183             urb-&gt;iso_frame_desc[j].length = ISO_MAX_FRAME_SIZE; <span class="comment">//dev-&gt;isoc_in_size;</span>
<a name="l00184"></a>00184         }
<a name="l00185"></a>00185     }
<a name="l00186"></a>00186 
<a name="l00187"></a>00187     <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"dev-&gt;isoc_in_size = %X\n"</span>, dev-&gt;isoc_in_size);
<a name="l00188"></a>00188     <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"dev-&gt;isoc_in_endpointAddr = %X\n"</span>, dev-&gt;isoc_in_endpointAddr);
<a name="l00189"></a>00189 
<a name="l00190"></a>00190     <span class="comment">// Link</span>
<a name="l00191"></a>00191     <span class="keywordflow">for</span> (i=0; i&lt;MAX_ISO_BUFS; i++) {
<a name="l00192"></a>00192         ret = usb_submit_urb(dev-&gt;isobuf[i].urb, GFP_KERNEL);
<a name="l00193"></a>00193 
<a name="l00194"></a>00194         <span class="keywordflow">if</span> (ret)
<a name="l00195"></a>00195             <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"isoc_init() submit_urb %d failed with error %d\n"</span>, i, ret);
<a name="l00196"></a>00196         <span class="keywordflow">else</span>
<a name="l00197"></a>00197             <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"URB 0x%p submitted.\n"</span>, dev-&gt;isobuf[i].urb);
<a name="l00198"></a>00198 
<a name="l00199"></a>00199         <span class="keywordflow">switch</span> (ret) {
<a name="l00200"></a>00200             <span class="keywordflow">case</span> -ENOMEM:
<a name="l00201"></a>00201                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"ENOMEM\n"</span>);
<a name="l00202"></a>00202                 <span class="keywordflow">break</span>;
<a name="l00203"></a>00203             <span class="keywordflow">case</span> -ENODEV:
<a name="l00204"></a>00204                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"ENODEV\n"</span>);
<a name="l00205"></a>00205                 <span class="keywordflow">break</span>;
<a name="l00206"></a>00206             <span class="keywordflow">case</span> -ENXIO:
<a name="l00207"></a>00207                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"ENXIO\n"</span>);
<a name="l00208"></a>00208                 <span class="keywordflow">break</span>;
<a name="l00209"></a>00209             <span class="keywordflow">case</span> -EINVAL:
<a name="l00210"></a>00210                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"EINVAL\n"</span>);
<a name="l00211"></a>00211                 <span class="keywordflow">break</span>;
<a name="l00212"></a>00212             <span class="keywordflow">case</span> -EAGAIN:
<a name="l00213"></a>00213                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"EAGAIN\n"</span>);
<a name="l00214"></a>00214                 <span class="keywordflow">break</span>;
<a name="l00215"></a>00215             <span class="keywordflow">case</span> -EFBIG:
<a name="l00216"></a>00216                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"EFBIG\n"</span>);
<a name="l00217"></a>00217                 <span class="keywordflow">break</span>;
<a name="l00218"></a>00218             <span class="keywordflow">case</span> -EPIPE:
<a name="l00219"></a>00219                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"EPIPE\n"</span>);
<a name="l00220"></a>00220                 <span class="keywordflow">break</span>;
<a name="l00221"></a>00221             <span class="keywordflow">case</span> -EMSGSIZE:
<a name="l00222"></a>00222                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"EMSGSIZE\n"</span>);
<a name="l00223"></a>00223                 <span class="keywordflow">break</span>;
<a name="l00224"></a>00224         }
<a name="l00225"></a>00225     }
<a name="l00226"></a>00226 
<a name="l00227"></a>00227     <span class="comment">// All is done</span>
<a name="l00228"></a>00228     dev-&gt;isoc_init_ok = 1;
<a name="l00229"></a>00229 
<a name="l00230"></a>00230     <span class="keywordflow">return</span> 0;
<a name="l00231"></a>00231 }
<a name="l00232"></a>00232 
<a name="l00233"></a>00233 
<a name="l00243"></a>00243 <span class="preprocessor">#if LINUX_VERSION_CODE &lt; KERNEL_VERSION(2,6,19)</span>
<a name="l00244"></a>00244 <span class="preprocessor"></span><span class="keywordtype">void</span> <a class="code" href="stk11xx-usb_8c.html#dc5f3754dd0e3a30f0d6cab5135e5d2b" title="ISOC handler.">usb_stk11xx_isoc_handler</a>(<span class="keyword">struct</span> urb *urb, <span class="keyword">struct</span> pt_regs *regs)
<a name="l00245"></a>00245 <span class="preprocessor">#else</span>
<a name="l00246"></a><a class="code" href="stk11xx_8h.html#b956e6442fd5e152f5846a1db7e9e5eb">00246</a> <span class="preprocessor"></span><span class="keywordtype">void</span> <a class="code" href="stk11xx-usb_8c.html#dc5f3754dd0e3a30f0d6cab5135e5d2b" title="ISOC handler.">usb_stk11xx_isoc_handler</a>(<span class="keyword">struct</span> urb *urb)
<a name="l00247"></a>00247 <span class="preprocessor">#endif</span>
<a name="l00248"></a>00248 <span class="preprocessor"></span>{
<a name="l00249"></a>00249     <span class="keywordtype">int</span> i;
<a name="l00250"></a>00250     <span class="keywordtype">int</span> ret;
<a name="l00251"></a>00251     <span class="keywordtype">int</span> skip;
<a name="l00252"></a>00252 
<a name="l00253"></a>00253     <span class="keywordtype">int</span> awake = 0;
<a name="l00254"></a>00254     <span class="keywordtype">int</span> framestatus;
<a name="l00255"></a>00255     <span class="keywordtype">int</span> framelen;
<a name="l00256"></a>00256 
<a name="l00257"></a>00257     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *fill = NULL;
<a name="l00258"></a>00258     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *iso_buf = NULL;
<a name="l00259"></a>00259 
<a name="l00260"></a>00260     <span class="keyword">struct </span>usb_stk11xx *dev;
<a name="l00261"></a>00261     <span class="keyword">struct </span>stk11xx_frame_buf *framebuf;
<a name="l00262"></a>00262 
<a name="l00263"></a>00263     <a class="code" href="stk11xx_8h.html#649dee4d247234a95351c9d56205623b">STK_STREAM</a>(<span class="stringliteral">"Isoc handler\n"</span>);
<a name="l00264"></a>00264 
<a name="l00265"></a>00265     dev = (<span class="keyword">struct </span>usb_stk11xx *) urb-&gt;context;
<a name="l00266"></a>00266 
<a name="l00267"></a>00267     if (dev == NULL) {
<a name="l00268"></a>00268         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"isoc_handler called with NULL device !\n"</span>);
<a name="l00269"></a>00269         <span class="keywordflow">return</span>;
<a name="l00270"></a>00270     }
<a name="l00271"></a>00271 
<a name="l00272"></a>00272     <span class="keywordflow">if</span> (urb-&gt;status == -ENOENT || urb-&gt;status == -ECONNRESET) {
<a name="l00273"></a>00273         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"URB unlinked synchronuously !\n"</span>);
<a name="l00274"></a>00274         <span class="keywordflow">return</span>;
<a name="l00275"></a>00275     }
<a name="l00276"></a>00276 
<a name="l00277"></a>00277     <span class="keywordflow">if</span> (urb-&gt;status != -EINPROGRESS &amp;&amp; urb-&gt;status != 0) {
<a name="l00278"></a>00278         <span class="keyword">const</span> <span class="keywordtype">char</span> *errmsg;
<a name="l00279"></a>00279 
<a name="l00280"></a>00280         errmsg = <span class="stringliteral">"Unknown"</span>;
<a name="l00281"></a>00281 
<a name="l00282"></a>00282         <span class="keywordflow">switch</span>(urb-&gt;status) {
<a name="l00283"></a>00283             <span class="keywordflow">case</span> -ENOSR:
<a name="l00284"></a>00284                 errmsg = <span class="stringliteral">"Buffer error (overrun)"</span>;
<a name="l00285"></a>00285                 <span class="keywordflow">break</span>;
<a name="l00286"></a>00286 
<a name="l00287"></a>00287             <span class="keywordflow">case</span> -EPIPE:
<a name="l00288"></a>00288                 errmsg = <span class="stringliteral">"Stalled (device not responding)"</span>;
<a name="l00289"></a>00289                 <span class="keywordflow">break</span>;
<a name="l00290"></a>00290 
<a name="l00291"></a>00291             <span class="keywordflow">case</span> -EOVERFLOW:
<a name="l00292"></a>00292                 errmsg = <span class="stringliteral">"Babble (bad cable?)"</span>;
<a name="l00293"></a>00293                 <span class="keywordflow">break</span>;
<a name="l00294"></a>00294 
<a name="l00295"></a>00295             <span class="keywordflow">case</span> -EPROTO:
<a name="l00296"></a>00296                 errmsg = <span class="stringliteral">"Bit-stuff error (bad cable?)"</span>;
<a name="l00297"></a>00297                 <span class="keywordflow">break</span>;
<a name="l00298"></a>00298 
<a name="l00299"></a>00299             <span class="keywordflow">case</span> -EILSEQ:
<a name="l00300"></a>00300                 errmsg = <span class="stringliteral">"CRC/Timeout (could be anything)"</span>;
<a name="l00301"></a>00301                 <span class="keywordflow">break</span>;
<a name="l00302"></a>00302 
<a name="l00303"></a>00303             <span class="keywordflow">case</span> -ETIMEDOUT:
<a name="l00304"></a>00304                 errmsg = <span class="stringliteral">"NAK (device does not respond)"</span>;
<a name="l00305"></a>00305                 <span class="keywordflow">break</span>;
<a name="l00306"></a>00306         }
<a name="l00307"></a>00307 
<a name="l00308"></a>00308         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"isoc_handler() called with status %d [%s].\n"</span>, urb-&gt;status, errmsg);
<a name="l00309"></a>00309 
<a name="l00310"></a>00310         dev-&gt;visoc_errors++;
<a name="l00311"></a>00311 
<a name="l00312"></a>00312         wake_up_interruptible(&amp;dev-&gt;wait_frame);
<a name="l00313"></a>00313 
<a name="l00314"></a>00314         urb-&gt;dev = dev-&gt;udev;
<a name="l00315"></a>00315         ret = usb_submit_urb(urb, GFP_ATOMIC);
<a name="l00316"></a>00316 
<a name="l00317"></a>00317         <span class="keywordflow">if</span> (ret != 0) {
<a name="l00318"></a>00318             <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Error (%d) re-submitting urb in stk11xx_isoc_handler.\n"</span>, ret);
<a name="l00319"></a>00319         }
<a name="l00320"></a>00320 
<a name="l00321"></a>00321         <span class="keywordflow">return</span>;
<a name="l00322"></a>00322     }
<a name="l00323"></a>00323 
<a name="l00324"></a>00324     framebuf = dev-&gt;fill_frame;
<a name="l00325"></a>00325 
<a name="l00326"></a>00326     <span class="keywordflow">if</span> (framebuf == NULL) {
<a name="l00327"></a>00327         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"isoc_handler without valid fill frame !\n"</span>);
<a name="l00328"></a>00328         
<a name="l00329"></a>00329         wake_up_interruptible(&amp;dev-&gt;wait_frame);
<a name="l00330"></a>00330 
<a name="l00331"></a>00331         urb-&gt;dev = dev-&gt;udev;
<a name="l00332"></a>00332         ret = usb_submit_urb(urb, GFP_ATOMIC);
<a name="l00333"></a>00333 
<a name="l00334"></a>00334         <span class="keywordflow">if</span> (ret != 0) {
<a name="l00335"></a>00335             <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Error (%d) re-submitting urb in stk11xx_isoc_handler.\n"</span>, ret);
<a name="l00336"></a>00336         }
<a name="l00337"></a>00337 
<a name="l00338"></a>00338         <span class="keywordflow">return</span>;
<a name="l00339"></a>00339     }
<a name="l00340"></a>00340     <span class="keywordflow">else</span> {
<a name="l00341"></a>00341         fill = framebuf-&gt;data + framebuf-&gt;filled;
<a name="l00342"></a>00342     }
<a name="l00343"></a>00343 
<a name="l00344"></a>00344     <span class="comment">// Reset ISOC error counter</span>
<a name="l00345"></a>00345     dev-&gt;visoc_errors = 0;
<a name="l00346"></a>00346 
<a name="l00347"></a>00347     <span class="comment">// Compact data</span>
<a name="l00348"></a>00348     <span class="keywordflow">for</span> (i=0; i&lt;urb-&gt;number_of_packets; i++) {
<a name="l00349"></a>00349         framestatus = urb-&gt;iso_frame_desc[i].status;
<a name="l00350"></a>00350         framelen = urb-&gt;iso_frame_desc[i].actual_length;
<a name="l00351"></a>00351         iso_buf = urb-&gt;transfer_buffer + urb-&gt;iso_frame_desc[i].offset;
<a name="l00352"></a>00352 
<a name="l00353"></a>00353         <span class="keywordflow">if</span> (framestatus == 0) {
<a name="l00354"></a>00354             skip = 4;
<a name="l00355"></a>00355 
<a name="l00356"></a>00356             <span class="keywordflow">if</span> (framelen &gt; 4) {
<a name="l00357"></a>00357                 <span class="comment">// we found something informational from there</span>
<a name="l00358"></a>00358                 <span class="comment">// the isoc frames have to type of headers</span>
<a name="l00359"></a>00359                 <span class="comment">// type1: 00 xx 00 00 or 20 xx 00 00</span>
<a name="l00360"></a>00360                 <span class="comment">// type2: 80 xx 00 00 00 00 00 00 or a0 xx 00 00 00 00 00 00</span>
<a name="l00361"></a>00361                 <span class="comment">// xx is a sequencer which has never been seen over 0x3f</span>
<a name="l00362"></a>00362                 <span class="comment">//</span>
<a name="l00363"></a>00363                 <span class="comment">// imho data written down looks like bayer, i see similarities after</span>
<a name="l00364"></a>00364                 <span class="comment">// every 640 bytes</span>
<a name="l00365"></a>00365                 <span class="keywordflow">if</span> (*iso_buf &amp; 0x80) {
<a name="l00366"></a>00366                     skip = 8;
<a name="l00367"></a>00367                 }
<a name="l00368"></a>00368 
<a name="l00369"></a>00369                 <span class="comment">// Our buffer is full !!!</span>
<a name="l00370"></a>00370                 <span class="keywordflow">if</span> (framelen - skip + framebuf-&gt;filled &gt; dev-&gt;frame_size) {
<a name="l00371"></a>00371                     <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Frame buffer overflow !\n"</span>);
<a name="l00372"></a>00372                     framebuf-&gt;errors++;
<a name="l00373"></a>00373                 }
<a name="l00374"></a>00374                 <span class="comment">// All is OK</span>
<a name="l00375"></a>00375                 <span class="keywordflow">else</span> {
<a name="l00376"></a>00376                     memcpy(fill, iso_buf + skip, framelen - skip);
<a name="l00377"></a>00377                     fill += framelen - skip;
<a name="l00378"></a>00378                 }
<a name="l00379"></a>00379 
<a name="l00380"></a>00380                 <span class="comment">// New size of our buffer</span>
<a name="l00381"></a>00381                 framebuf-&gt;filled += framelen - skip;
<a name="l00382"></a>00382             }
<a name="l00383"></a>00383 
<a name="l00384"></a>00384             <a class="code" href="stk11xx_8h.html#649dee4d247234a95351c9d56205623b">STK_STREAM</a>(<span class="stringliteral">"URB : Length = %d - Skip = %d - Buffer size = %d\n"</span>,
<a name="l00385"></a>00385                 framelen, skip, framebuf-&gt;filled);
<a name="l00386"></a>00386 
<a name="l00387"></a>00387             <span class="comment">// Data is always follow by a frame with a length '4'</span>
<a name="l00388"></a>00388             <span class="keywordflow">if</span> (framelen == 4) {
<a name="l00389"></a>00389                 <span class="keywordflow">if</span> (framebuf-&gt;filled &gt; 0) {
<a name="l00390"></a>00390                     <span class="comment">// Our buffer has enough data ?</span>
<a name="l00391"></a>00391                     <span class="keywordflow">if</span> (framebuf-&gt;filled &lt; dev-&gt;frame_size)
<a name="l00392"></a>00392                         framebuf-&gt;errors++;
<a name="l00393"></a>00393 
<a name="l00394"></a>00394                     <span class="comment">// If there are errors, we skip a frame...</span>
<a name="l00395"></a>00395                     <span class="keywordflow">if</span> (framebuf-&gt;errors == 0) {
<a name="l00396"></a>00396                         <span class="keywordflow">if</span> (<a class="code" href="stk11xx-buf_8c.html#42ee71f1080bbad747679c4b1f5040f4" title="Prepare the next frame.">stk11xx_next_frame</a>(dev))
<a name="l00397"></a>00397                             dev-&gt;vframes_dumped++;
<a name="l00398"></a>00398                     }
<a name="l00399"></a>00399                     <span class="keywordflow">else</span>
<a name="l00400"></a>00400                         dev-&gt;vframes_error++;
<a name="l00401"></a>00401 
<a name="l00402"></a>00402                     awake = 1;
<a name="l00403"></a>00403                     framebuf = dev-&gt;fill_frame;
<a name="l00404"></a>00404                     framebuf-&gt;filled = 0;
<a name="l00405"></a>00405                     framebuf-&gt;errors = 0;
<a name="l00406"></a>00406                     fill = framebuf-&gt;data;
<a name="l00407"></a>00407                 }
<a name="l00408"></a>00408             }
<a name="l00409"></a>00409         }
<a name="l00410"></a>00410         <span class="keywordflow">else</span> {
<a name="l00411"></a>00411             <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Iso frame %d of USB has error %d\n"</span>, i, framestatus);
<a name="l00412"></a>00412         }
<a name="l00413"></a>00413     }
<a name="l00414"></a>00414 
<a name="l00415"></a>00415     <span class="keywordflow">if</span> (awake == 1)
<a name="l00416"></a>00416         wake_up_interruptible(&amp;dev-&gt;wait_frame);
<a name="l00417"></a>00417 
<a name="l00418"></a>00418     urb-&gt;dev = dev-&gt;udev;
<a name="l00419"></a>00419 
<a name="l00420"></a>00420     ret = usb_submit_urb(urb, GFP_ATOMIC);
<a name="l00421"></a>00421 
<a name="l00422"></a>00422     <span class="keywordflow">if</span> (ret != 0) {
<a name="l00423"></a>00423         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Error (%d) re-submitting urb in stk11xx_isoc_handler.\n"</span>, ret);
<a name="l00424"></a>00424     }
<a name="l00425"></a>00425 }
<a name="l00426"></a>00426 
<a name="l00427"></a>00427 
<a name="l00435"></a><a class="code" href="stk11xx_8h.html#8fb48c1dc48247cb7a580ac09f5e7e75">00435</a> <span class="keywordtype">void</span> <a class="code" href="stk11xx-usb_8c.html#7d77d101c0b0a8bc6100dc6665f3c3f5" title="Clean-up all the ISOC buffers.">usb_stk11xx_isoc_cleanup</a>(<span class="keyword">struct</span> usb_stk11xx *dev)
<a name="l00436"></a>00436 {
<a name="l00437"></a>00437     <span class="keywordtype">int</span> i;
<a name="l00438"></a>00438 
<a name="l00439"></a>00439     <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Isoc cleanup\n"</span>);
<a name="l00440"></a>00440 
<a name="l00441"></a>00441     <span class="keywordflow">if</span> (dev == NULL)
<a name="l00442"></a>00442         <span class="keywordflow">return</span>;
<a name="l00443"></a>00443 
<a name="l00444"></a>00444     <span class="keywordflow">if</span> (dev-&gt;isoc_init_ok == 0)
<a name="l00445"></a>00445         <span class="keywordflow">return</span>;
<a name="l00446"></a>00446 
<a name="l00447"></a>00447     <span class="comment">// Unlinking ISOC buffers</span>
<a name="l00448"></a>00448     <span class="keywordflow">for</span> (i=0; i&lt;<a class="code" href="stk11xx_8h.html#ac10237297a8b2b0665e56179c99b64f">MAX_ISO_BUFS</a>; i++) {
<a name="l00449"></a>00449         <span class="keyword">struct </span>urb *urb;
<a name="l00450"></a>00450 
<a name="l00451"></a>00451         urb = dev-&gt;isobuf[i].urb;
<a name="l00452"></a>00452 
<a name="l00453"></a>00453         <span class="keywordflow">if</span> (urb != 0) {
<a name="l00454"></a>00454             <span class="keywordflow">if</span> (dev-&gt;isoc_init_ok)
<a name="l00455"></a>00455                 usb_kill_urb(urb);
<a name="l00456"></a>00456             
<a name="l00457"></a>00457             usb_free_urb(urb);
<a name="l00458"></a>00458             dev-&gt;isobuf[i].urb = NULL;
<a name="l00459"></a>00459         }
<a name="l00460"></a>00460     }
<a name="l00461"></a>00461 
<a name="l00462"></a>00462     <span class="comment">// All is done</span>
<a name="l00463"></a>00463     dev-&gt;isoc_init_ok = 0;
<a name="l00464"></a>00464 }
<a name="l00465"></a>00465 
<a name="l00466"></a>00466 
<a name="l00467"></a>00467 
<a name="l00478"></a><a class="code" href="stk11xx_8h.html#a982f4b4e3f9b3e7bc30f7f377e4ec6f">00478</a> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#6c06db66c35ba2ebab0de265edb0a989" title="Send the message SET_FEATURE and choose the interface.">usb_stk11xx_set_feature</a>(<span class="keyword">struct</span> usb_stk11xx *dev, <span class="keywordtype">int</span> index)
<a name="l00479"></a>00479 {
<a name="l00480"></a>00480     <span class="keywordtype">int</span> result;
<a name="l00481"></a>00481     <span class="keyword">struct </span>usb_device *udev = dev-&gt;udev;
<a name="l00482"></a>00482 
<a name="l00483"></a>00483     result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
<a name="l00484"></a>00484             USB_REQ_SET_FEATURE,
<a name="l00485"></a>00485             USB_TYPE_STANDARD | USB_DIR_OUT | USB_RECIP_DEVICE,
<a name="l00486"></a>00486             USB_DEVICE_REMOTE_WAKEUP,
<a name="l00487"></a>00487             index,
<a name="l00488"></a>00488             NULL,
<a name="l00489"></a>00489             0,
<a name="l00490"></a>00490             500);
<a name="l00491"></a>00491     
<a name="l00492"></a>00492     <span class="keywordflow">if</span> (result &lt; 0)
<a name="l00493"></a>00493         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"SET FEATURE fail !\n"</span>);
<a name="l00494"></a>00494     <span class="keywordflow">else</span> 
<a name="l00495"></a>00495         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"SET FEATURE\n"</span>);
<a name="l00496"></a>00496 
<a name="l00497"></a>00497     <span class="keywordflow">return</span> result;
<a name="l00498"></a>00498 }
<a name="l00499"></a>00499 
<a name="l00500"></a>00500 
<a name="l00510"></a><a class="code" href="stk11xx_8h.html#cfce4cb3110489637b0617be920c7c8c">00510</a> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#0f0bf21ea32b0c54b3d103a13e628085" title="Send the message SET_CONFIGURATION.">usb_stk11xx_set_configuration</a>(<span class="keyword">struct</span> usb_stk11xx *dev)
<a name="l00511"></a>00511 {
<a name="l00512"></a>00512     <span class="keywordtype">int</span> result;
<a name="l00513"></a>00513     <span class="keyword">struct </span>usb_device *udev = dev-&gt;udev;
<a name="l00514"></a>00514 
<a name="l00515"></a>00515     result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
<a name="l00516"></a>00516             USB_REQ_SET_CONFIGURATION,
<a name="l00517"></a>00517             USB_TYPE_STANDARD | USB_DIR_OUT | USB_RECIP_DEVICE,
<a name="l00518"></a>00518             0,
<a name="l00519"></a>00519             udev-&gt;config[0].desc.bConfigurationValue,
<a name="l00520"></a>00520             NULL,
<a name="l00521"></a>00521             0,
<a name="l00522"></a>00522             500);
<a name="l00523"></a>00523 
<a name="l00524"></a>00524     <span class="keywordflow">if</span> (result &lt; 0)
<a name="l00525"></a>00525         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"SET CONFIGURATION fail !\n"</span>);
<a name="l00526"></a>00526     <span class="keywordflow">else</span> 
<a name="l00527"></a>00527         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"SET CONFIGURATION %d\n"</span>, udev-&gt;config[0].desc.bConfigurationValue);
<a name="l00528"></a>00528 
<a name="l00529"></a>00529     <span class="keywordflow">return</span> result;
<a name="l00530"></a>00530 }
<a name="l00531"></a>00531 
<a name="l00532"></a>00532 
<a name="l00544"></a><a class="code" href="stk11xx_8h.html#ba4a0665d0f900b337b43d411e87ccb0">00544</a> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#4cfecf5949af7bf80f2010cb76dbb999" title="Write a 16-bits value to a 16-bits register.">usb_stk11xx_write_registry</a>(<span class="keyword">struct</span> usb_stk11xx *dev, __u16 index, __u16 value)
<a name="l00545"></a>00545 {
<a name="l00546"></a>00546     <span class="keywordtype">int</span> result;
<a name="l00547"></a>00547     <span class="keyword">struct </span>usb_device *udev = dev-&gt;udev;
<a name="l00548"></a>00548 
<a name="l00549"></a>00549     result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
<a name="l00550"></a>00550             0x01,
<a name="l00551"></a>00551             USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
<a name="l00552"></a>00552             value,
<a name="l00553"></a>00553             index,
<a name="l00554"></a>00554             NULL,
<a name="l00555"></a>00555             0,
<a name="l00556"></a>00556             500);
<a name="l00557"></a>00557 
<a name="l00558"></a>00558     <span class="keywordflow">if</span> (result &lt; 0)
<a name="l00559"></a>00559         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Write registry fails %02X = %02X"</span>, index, value);
<a name="l00560"></a>00560 
<a name="l00561"></a>00561     <span class="keywordflow">return</span> result;
<a name="l00562"></a>00562 }
<a name="l00563"></a>00563 
<a name="l00564"></a>00564 
<a name="l00576"></a><a class="code" href="stk11xx_8h.html#d6ae987a2bad16ca19b2b60de7c96672">00576</a> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#64afbfa08d229babf07bfd9a2c7258ad" title="Read a 16-bits value from a 16-bits register.">usb_stk11xx_read_registry</a>(<span class="keyword">struct</span> usb_stk11xx *dev, __u16 index, <span class="keywordtype">int</span> *value)
<a name="l00577"></a>00577 {
<a name="l00578"></a>00578     <span class="keywordtype">int</span> result;
<a name="l00579"></a>00579 
<a name="l00580"></a>00580     <span class="keyword">struct </span>usb_device *udev = dev-&gt;udev;
<a name="l00581"></a>00581 
<a name="l00582"></a>00582     *value = 0;
<a name="l00583"></a>00583 
<a name="l00584"></a>00584     result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
<a name="l00585"></a>00585             0x00,
<a name="l00586"></a>00586             USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
<a name="l00587"></a>00587             0x00,
<a name="l00588"></a>00588             index,
<a name="l00589"></a>00589             (__u8 *) value,
<a name="l00590"></a>00590             <span class="keyword">sizeof</span>(__u8),
<a name="l00591"></a>00591             500);
<a name="l00592"></a>00592 
<a name="l00593"></a>00593     <span class="keywordflow">if</span> (result &lt; 0)
<a name="l00594"></a>00594         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Read registry fails %02X"</span>, index);
<a name="l00595"></a>00595 
<a name="l00596"></a>00596     <span class="keywordflow">return</span> result;
<a name="l00597"></a>00597 }
<a name="l00598"></a>00598 
<a name="l00599"></a>00599 
<a name="l00610"></a><a class="code" href="stk11xx-usb_8c.html#26007930dc526d4b95cab061a1094560">00610</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#26007930dc526d4b95cab061a1094560" title="Set the default value about the video settings.">usb_stk11xx_default_settings</a>(<span class="keyword">struct</span> usb_stk11xx *dev)
<a name="l00611"></a>00611 {
<a name="l00612"></a>00612     <span class="keywordflow">switch</span> (dev-&gt;webcam_model) {
<a name="l00613"></a>00613         <span class="keywordflow">case</span> SYNTEK_STK_M811:
<a name="l00614"></a>00614         <span class="keywordflow">case</span> SYNTEK_STK_A311:
<a name="l00615"></a>00615             dev-&gt;vsettings.fps = (<a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a> == -1) ? 25 : <a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a>;
<a name="l00616"></a>00616             dev-&gt;vsettings.vflip = (<a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a> == -1) ? 1 : <a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a>;
<a name="l00617"></a>00617             dev-&gt;vsettings.hflip = (<a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a> == -1) ? 1 : <a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a>;
<a name="l00618"></a>00618 
<a name="l00619"></a>00619             dev-&gt;vsettings.brightness = (<a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a>;
<a name="l00620"></a>00620             dev-&gt;vsettings.whiteness = (<a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a>;
<a name="l00621"></a>00621             dev-&gt;vsettings.contrast = (<a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a>;
<a name="l00622"></a>00622             dev-&gt;vsettings.colour = (<a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a>;
<a name="l00623"></a>00623             <span class="keywordflow">break</span>;
<a name="l00624"></a>00624 
<a name="l00625"></a>00625         <span class="keywordflow">case</span> SYNTEK_STK_A821:
<a name="l00626"></a>00626             dev-&gt;vsettings.fps = (<a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a> == -1) ? 25 : <a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a>;
<a name="l00627"></a>00627             dev-&gt;vsettings.vflip = (<a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a> == -1) ? 0 : <a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a>;
<a name="l00628"></a>00628             dev-&gt;vsettings.hflip = (<a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a> == -1) ? 0 : <a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a>;
<a name="l00629"></a>00629 
<a name="l00630"></a>00630             dev-&gt;vsettings.brightness = (<a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a>;
<a name="l00631"></a>00631             dev-&gt;vsettings.whiteness = (<a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a>;
<a name="l00632"></a>00632             dev-&gt;vsettings.contrast = (<a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a>;
<a name="l00633"></a>00633             dev-&gt;vsettings.colour = (<a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a>;
<a name="l00634"></a>00634             <span class="keywordflow">break</span>;
<a name="l00635"></a>00635 
<a name="l00636"></a>00636         <span class="keywordflow">case</span> SYNTEK_STK_6A31:
<a name="l00637"></a>00637         <span class="keywordflow">case</span> SYNTEK_STK_6A33:
<a name="l00638"></a>00638             dev-&gt;vsettings.fps = (<a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a> == -1) ? 25 : <a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a>;
<a name="l00639"></a>00639             dev-&gt;vsettings.vflip = (<a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a> == -1) ? 0 : <a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a>;
<a name="l00640"></a>00640             dev-&gt;vsettings.hflip = (<a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a> == -1) ? 0 : <a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a>;
<a name="l00641"></a>00641 
<a name="l00642"></a>00642             dev-&gt;vsettings.brightness = (<a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a>;
<a name="l00643"></a>00643             dev-&gt;vsettings.whiteness = (<a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a>;
<a name="l00644"></a>00644             dev-&gt;vsettings.contrast = (<a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a>;
<a name="l00645"></a>00645             dev-&gt;vsettings.colour = (<a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a>;
<a name="l00646"></a>00646             <span class="keywordflow">break</span>;
<a name="l00647"></a>00647 
<a name="l00648"></a>00648         <span class="keywordflow">case</span> SYNTEK_STK_6A51:
<a name="l00649"></a>00649         <span class="keywordflow">case</span> SYNTEK_STK_6A54:
<a name="l00650"></a>00650             dev-&gt;vsettings.fps = (<a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a> == -1) ? 25 : <a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a>;
<a name="l00651"></a>00651             dev-&gt;vsettings.vflip = (<a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a> == -1) ? 0 : <a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a>;
<a name="l00652"></a>00652             dev-&gt;vsettings.hflip = (<a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a> == -1) ? 0 : <a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a>;
<a name="l00653"></a>00653 
<a name="l00654"></a>00654             dev-&gt;vsettings.brightness = (<a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a>;
<a name="l00655"></a>00655             dev-&gt;vsettings.whiteness = (<a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a>;
<a name="l00656"></a>00656             dev-&gt;vsettings.contrast = (<a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a>;
<a name="l00657"></a>00657             dev-&gt;vsettings.colour = (<a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a> == -1) ? <a class="code" href="stk11xx_8h.html#563c7087d02e5ac0f5c3a8124b36f231">STK11XX_PERCENT</a>(50, 0xFFFF) : <a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a>;
<a name="l00658"></a>00658             <span class="keywordflow">break</span>;
<a name="l00659"></a>00659 
<a name="l00660"></a>00660         <span class="keywordflow">default</span>:
<a name="l00661"></a>00661             <span class="keywordflow">return</span> -1;
<a name="l00662"></a>00662     }
<a name="l00663"></a>00663 
<a name="l00664"></a>00664     <span class="keywordflow">return</span> 0;
<a name="l00665"></a>00665 }
<a name="l00666"></a>00666 
<a name="l00667"></a>00667 
<a name="l00679"></a><a class="code" href="stk11xx-usb_8c.html#0383d45a66f483766e12609cef2a058a">00679</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#0383d45a66f483766e12609cef2a058a" title="Load the driver.">usb_stk11xx_probe</a>(<span class="keyword">struct</span> usb_interface *interface, <span class="keyword">const</span> <span class="keyword">struct</span> usb_device_id *<span class="keywordtype">id</span>)
<a name="l00680"></a>00680 {
<a name="l00681"></a>00681     <span class="keywordtype">int</span> i;
<a name="l00682"></a>00682     <span class="keywordtype">int</span> err;
<a name="l00683"></a>00683     <span class="keywordtype">size_t</span> buffer_size;
<a name="l00684"></a>00684 
<a name="l00685"></a>00685     <span class="keywordtype">int</span> vendor_id;
<a name="l00686"></a>00686     <span class="keywordtype">int</span> product_id;
<a name="l00687"></a>00687     <span class="keywordtype">int</span> bNumInterfaces;
<a name="l00688"></a>00688     <span class="keywordtype">int</span> webcam_model;
<a name="l00689"></a>00689     <span class="keywordtype">int</span> webcam_type;
<a name="l00690"></a>00690 
<a name="l00691"></a>00691     <span class="keyword">struct </span>usb_stk11xx *dev = NULL;
<a name="l00692"></a>00692     <span class="keyword">struct </span>usb_device *udev = interface_to_usbdev(interface);
<a name="l00693"></a>00693     <span class="keyword">struct </span>usb_host_interface *iface_desc;
<a name="l00694"></a>00694     <span class="keyword">struct </span>usb_endpoint_descriptor *endpoint;
<a name="l00695"></a>00695 
<a name="l00696"></a>00696 
<a name="l00697"></a>00697     <span class="comment">// Get USB VendorID and ProductID</span>
<a name="l00698"></a>00698     vendor_id = le16_to_cpu(udev-&gt;descriptor.idVendor);
<a name="l00699"></a>00699     product_id = le16_to_cpu(udev-&gt;descriptor.idProduct);
<a name="l00700"></a>00700 
<a name="l00701"></a>00701     <span class="comment">// Check if we can handle this device</span>
<a name="l00702"></a>00702     <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Probe function called with VendorID=%04X, ProductID=%04X and InterfaceNumber=%d\n"</span>,
<a name="l00703"></a>00703             vendor_id, product_id, interface-&gt;cur_altsetting-&gt;desc.bInterfaceNumber);
<a name="l00704"></a>00704 
<a name="l00705"></a>00705     <span class="comment">// The interface are probed one by one.</span>
<a name="l00706"></a>00706     <span class="comment">// We are interested in the video interface (always the interface '0')</span>
<a name="l00707"></a>00707     <span class="comment">// The interfaces '1' or '2' (if presents) are the audio control.</span>
<a name="l00708"></a>00708     <span class="keywordflow">if</span> (interface-&gt;cur_altsetting-&gt;desc.bInterfaceNumber &gt; 0)
<a name="l00709"></a>00709         <span class="keywordflow">return</span> -ENODEV;
<a name="l00710"></a>00710 
<a name="l00711"></a>00711     <span class="comment">// Detect device</span>
<a name="l00712"></a>00712     <span class="keywordflow">if</span> (vendor_id == <a class="code" href="stk11xx_8h.html#ec973c0ea6961094f801d3f90d1dcdd6">USB_SYNTEK1_VENDOR_ID</a>) {
<a name="l00713"></a>00713         <span class="keywordflow">switch</span> (product_id) {
<a name="l00714"></a>00714             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#b10b64fc880949ce0503df77bcad8ed1">USB_STK_A311_PRODUCT_ID</a>:
<a name="l00715"></a>00715                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00716"></a>00716                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 1.3M WebCam - Product ID 0xA311.\n"</span>);
<a name="l00717"></a>00717                 webcam_model = SYNTEK_STK_A311;
<a name="l00718"></a>00718                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f13f5de5bc8e126ddba84831bfdf8fdaa8">STK11XX_SXGA</a>;
<a name="l00719"></a>00719                 <span class="keywordflow">break</span>;
<a name="l00720"></a>00720 
<a name="l00721"></a>00721             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#f8fbeced8d03a4662b945faa8fb97d34">USB_STK_A821_PRODUCT_ID</a>:
<a name="l00722"></a>00722                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00723"></a>00723                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 VGA WebCam - Product ID 0xA821.\n"</span>);
<a name="l00724"></a>00724                 webcam_model = SYNTEK_STK_A821;
<a name="l00725"></a>00725                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f1896c4ee082ee0fa3eed44795b4a78e9e">STK11XX_VGA</a>;
<a name="l00726"></a>00726                 <span class="keywordflow">break</span>;
<a name="l00727"></a>00727 
<a name="l00728"></a>00728             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#433f18ebde586610039cb3f98a360a0d">USB_STK_6A31_PRODUCT_ID</a>:
<a name="l00729"></a>00729                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00730"></a>00730                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A31.\n"</span>);
<a name="l00731"></a>00731                 webcam_model = SYNTEK_STK_6A31;
<a name="l00732"></a>00732                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f1896c4ee082ee0fa3eed44795b4a78e9e">STK11XX_VGA</a>;
<a name="l00733"></a>00733                 <span class="keywordflow">break</span>;
<a name="l00734"></a>00734 
<a name="l00735"></a>00735             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#0e65935d0a86b7308c3314082e4f8e28">USB_STK_6A33_PRODUCT_ID</a>:
<a name="l00736"></a>00736                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00737"></a>00737                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A33.\n"</span>);
<a name="l00738"></a>00738                 webcam_model = SYNTEK_STK_6A33;
<a name="l00739"></a>00739                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f1896c4ee082ee0fa3eed44795b4a78e9e">STK11XX_VGA</a>;
<a name="l00740"></a>00740                 <span class="keywordflow">break</span>;
<a name="l00741"></a>00741 
<a name="l00742"></a>00742             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#7893d73e6865a8b61f07efe5978ce62a">USB_STK_6A51_PRODUCT_ID</a>:
<a name="l00743"></a>00743                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00744"></a>00744                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A51.\n"</span>);
<a name="l00745"></a>00745                 webcam_model = SYNTEK_STK_6A51;
<a name="l00746"></a>00746                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f1896c4ee082ee0fa3eed44795b4a78e9e">STK11XX_VGA</a>;
<a name="l00747"></a>00747                 <span class="keywordflow">break</span>;
<a name="l00748"></a>00748 
<a name="l00749"></a>00749             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#9051e3ea42b0b1d3d6083389381cde6f">USB_STK_6A54_PRODUCT_ID</a>:
<a name="l00750"></a>00750                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00751"></a>00751                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A54.\n"</span>);
<a name="l00752"></a>00752                 webcam_model = SYNTEK_STK_6A54;
<a name="l00753"></a>00753                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f1896c4ee082ee0fa3eed44795b4a78e9e">STK11XX_VGA</a>;
<a name="l00754"></a>00754                 <span class="keywordflow">break</span>;
<a name="l00755"></a>00755 
<a name="l00756"></a>00756             <span class="keywordflow">default</span>:
<a name="l00757"></a>00757                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"usb_stk11xx_probe failed ! Camera product 0x%04X is not supported.\n"</span>,
<a name="l00758"></a>00758                         le16_to_cpu(udev-&gt;descriptor.idProduct));
<a name="l00759"></a>00759                 <span class="keywordflow">return</span> -ENODEV;
<a name="l00760"></a>00760         }
<a name="l00761"></a>00761     }
<a name="l00762"></a>00762     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (vendor_id == <a class="code" href="stk11xx_8h.html#6d15e8c0162bcf42c8192fdf8fc1b516">USB_SYNTEK2_VENDOR_ID</a>) {
<a name="l00763"></a>00763         <span class="keywordflow">switch</span> (product_id) {
<a name="l00764"></a>00764             <span class="keywordflow">case</span> <a class="code" href="stk11xx_8h.html#08f8051e3d5cafd2f39bc274921db312">USB_STK_0501_PRODUCT_ID</a>:
<a name="l00765"></a>00765                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 - STK-1135 based webcam found.\n"</span>);
<a name="l00766"></a>00766                 <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x0501.\n"</span>);
<a name="l00767"></a>00767                 webcam_model = SYNTEK_STK_M811;
<a name="l00768"></a>00768                 webcam_type = <a class="code" href="stk11xx_8h.html#5400cbd98f5ec8f3d24ec55313e274f13f5de5bc8e126ddba84831bfdf8fdaa8">STK11XX_SXGA</a>;
<a name="l00769"></a>00769                 <span class="keywordflow">break</span>;
<a name="l00770"></a>00770 
<a name="l00771"></a>00771             <span class="keywordflow">default</span>:
<a name="l00772"></a>00772                 <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"usb_stk11xx_probe failed ! Camera product 0x%04X is not supported.\n"</span>,
<a name="l00773"></a>00773                         le16_to_cpu(udev-&gt;descriptor.idProduct));
<a name="l00774"></a>00774                 <span class="keywordflow">return</span> -ENODEV;
<a name="l00775"></a>00775         }
<a name="l00776"></a>00776     }
<a name="l00777"></a>00777     <span class="keywordflow">else</span>
<a name="l00778"></a>00778         <span class="keywordflow">return</span> -ENODEV;
<a name="l00779"></a>00779 
<a name="l00780"></a>00780     <span class="comment">// Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device</span>
<a name="l00781"></a>00781     dev = kzalloc(<span class="keyword">sizeof</span>(<span class="keyword">struct</span> usb_stk11xx), GFP_KERNEL);
<a name="l00782"></a>00782 
<a name="l00783"></a>00783     <span class="keywordflow">if</span> (dev == NULL) {
<a name="l00784"></a>00784         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Out of memory !\n"</span>);
<a name="l00785"></a>00785         <span class="keywordflow">return</span> -ENOMEM;
<a name="l00786"></a>00786     }
<a name="l00787"></a>00787 
<a name="l00788"></a>00788     <span class="comment">// Init mutexes, spinlock, etc.</span>
<a name="l00789"></a>00789     init_MUTEX(&amp;dev-&gt;mutex);
<a name="l00790"></a>00790     spin_lock_init(&amp;dev-&gt;spinlock);
<a name="l00791"></a>00791     init_waitqueue_head(&amp;dev-&gt;wait_frame);
<a name="l00792"></a>00792 
<a name="l00793"></a>00793     <span class="comment">// Save pointers</span>
<a name="l00794"></a>00794     dev-&gt;webcam_model = webcam_model;
<a name="l00795"></a>00795     dev-&gt;webcam_type = webcam_type;
<a name="l00796"></a>00796     dev-&gt;udev = udev;
<a name="l00797"></a>00797     dev-&gt;interface = interface;
<a name="l00798"></a>00798 
<a name="l00799"></a>00799     <span class="comment">// Read the product release </span>
<a name="l00800"></a>00800     dev-&gt;release = le16_to_cpu(udev-&gt;descriptor.bcdDevice);
<a name="l00801"></a>00801     <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Release: %04x\n"</span>, dev-&gt;release);
<a name="l00802"></a>00802 
<a name="l00803"></a>00803     <span class="comment">// How many interfaces (1 or 3) ?</span>
<a name="l00804"></a>00804     bNumInterfaces = udev-&gt;config-&gt;desc.bNumInterfaces;
<a name="l00805"></a>00805     <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Number of interfaces : %d\n"</span>, bNumInterfaces);
<a name="l00806"></a>00806 
<a name="l00807"></a>00807 
<a name="l00808"></a>00808     <span class="comment">// Constructor</span>
<a name="l00809"></a>00809     dev-&gt;nbuffers = 2;
<a name="l00810"></a>00810     dev-&gt;len_per_image = PAGE_ALIGN((1280 * 1024 * 4));
<a name="l00811"></a>00811 
<a name="l00812"></a>00812 
<a name="l00813"></a>00813     <span class="comment">// Switch on the camera (to detect size of buffers)</span>
<a name="l00814"></a>00814     <a class="code" href="stk11xx-dev_8c.html#e978d7adfeabe3e7c31076fddee9a744" title="This function switchs on the camera.">dev_stk11xx_camera_on</a>(dev);
<a name="l00815"></a>00815 
<a name="l00816"></a>00816 
<a name="l00817"></a>00817     <span class="comment">// Set up the endpoint information </span>
<a name="l00818"></a>00818     <span class="comment">// use only the first int-in and isoc-in endpoints</span>
<a name="l00819"></a>00819     <span class="comment">// for the current alternate setting</span>
<a name="l00820"></a>00820     iface_desc = interface-&gt;cur_altsetting;
<a name="l00821"></a>00821 
<a name="l00822"></a>00822     <span class="keywordflow">for</span> (i = 0; i &lt; iface_desc-&gt;desc.bNumEndpoints; ++i) {
<a name="l00823"></a>00823         endpoint = &amp;iface_desc-&gt;endpoint[i].desc;
<a name="l00824"></a>00824 
<a name="l00825"></a>00825         <span class="keywordflow">if</span> (!dev-&gt;int_in_endpointAddr
<a name="l00826"></a>00826                 &amp;&amp; ((endpoint-&gt;bEndpointAddress &amp; USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
<a name="l00827"></a>00827                 &amp;&amp; ((endpoint-&gt;bmAttributes &amp; USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
<a name="l00828"></a>00828             <span class="comment">// we found an interrupt in endpoint</span>
<a name="l00829"></a>00829             buffer_size = le16_to_cpu(endpoint-&gt;wMaxPacketSize);
<a name="l00830"></a>00830 
<a name="l00831"></a>00831             dev-&gt;int_in_size = buffer_size;
<a name="l00832"></a>00832             dev-&gt;int_in_endpointAddr = (endpoint-&gt;bEndpointAddress &amp; 0xf);
<a name="l00833"></a>00833         }
<a name="l00834"></a>00834 
<a name="l00835"></a>00835         <span class="keywordflow">if</span> (!dev-&gt;isoc_in_endpointAddr
<a name="l00836"></a>00836                 &amp;&amp; ((endpoint-&gt;bEndpointAddress &amp; USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
<a name="l00837"></a>00837                 &amp;&amp; ((endpoint-&gt;bmAttributes &amp; USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_ISOC)) {
<a name="l00838"></a>00838             <span class="comment">// we found an isoc in endpoint</span>
<a name="l00839"></a>00839             buffer_size = le16_to_cpu(endpoint-&gt;wMaxPacketSize);
<a name="l00840"></a>00840 
<a name="l00841"></a>00841             dev-&gt;isoc_in_size = buffer_size;
<a name="l00842"></a>00842             dev-&gt;isoc_in_endpointAddr = (endpoint-&gt;bEndpointAddress &amp; 0xf);
<a name="l00843"></a>00843         }
<a name="l00844"></a>00844     }
<a name="l00845"></a>00845 
<a name="l00846"></a>00846     <span class="keywordflow">if</span> (!(dev-&gt;int_in_endpointAddr &amp;&amp; dev-&gt;isoc_in_endpointAddr)) {
<a name="l00847"></a>00847         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Could not find both int-in and isoc-in endpoints"</span>);
<a name="l00848"></a>00848 
<a name="l00849"></a>00849         kfree(dev);
<a name="l00850"></a>00850 
<a name="l00851"></a>00851         <span class="keywordflow">return</span> -ENODEV;
<a name="l00852"></a>00852     }
<a name="l00853"></a>00853 
<a name="l00854"></a>00854 
<a name="l00855"></a>00855     <span class="comment">// Switch off camera</span>
<a name="l00856"></a>00856     <a class="code" href="stk11xx-dev_8c.html#865eb05993bb42c88ce5c73fb39b210d" title="This function switchs off the camera.">dev_stk11xx_camera_off</a>(dev);
<a name="l00857"></a>00857 
<a name="l00858"></a>00858     <span class="comment">// Initialize the video device</span>
<a name="l00859"></a>00859     dev-&gt;vdev = video_device_alloc();
<a name="l00860"></a>00860 
<a name="l00861"></a>00861     <span class="keywordflow">if</span> (!dev-&gt;vdev) {
<a name="l00862"></a>00862         kfree(dev);
<a name="l00863"></a>00863         <span class="keywordflow">return</span> -ENOMEM;
<a name="l00864"></a>00864     }
<a name="l00865"></a>00865 
<a name="l00866"></a>00866     <span class="comment">// Initialize the camera</span>
<a name="l00867"></a>00867     <a class="code" href="stk11xx-dev_8c.html#1ea9ddc0b8dd43b676ce106c6b562bcb" title="This function permits to initialize the device.">dev_stk11xx_initialize_device</a>(dev);
<a name="l00868"></a>00868     
<a name="l00869"></a>00869     <span class="comment">// Register the video device</span>
<a name="l00870"></a>00870     err = <a class="code" href="stk11xx-v4l_8c.html#5fb1deffc636cce6dffc8b5e971e6115" title="Register the video device.">v4l_stk11xx_register_video_device</a>(dev);
<a name="l00871"></a>00871 
<a name="l00872"></a>00872     <span class="keywordflow">if</span> (err) {
<a name="l00873"></a>00873         kfree(dev);
<a name="l00874"></a>00874         <span class="keywordflow">return</span> err;
<a name="l00875"></a>00875     }
<a name="l00876"></a>00876 
<a name="l00877"></a>00877     <span class="comment">// Create the entries in the sys filesystem</span>
<a name="l00878"></a>00878     <a class="code" href="stk11xx-sysfs_8c.html#6b58e4f6d2baa9c5ccb3a18e5c64bb65" title="Create the &amp;#39;sys&amp;#39; entries.">stk11xx_create_sysfs_files</a>(dev-&gt;vdev);
<a name="l00879"></a>00879 
<a name="l00880"></a>00880     <span class="comment">// Save our data pointer in this interface device</span>
<a name="l00881"></a>00881     usb_set_intfdata(interface, dev);
<a name="l00882"></a>00882 
<a name="l00883"></a>00883     <span class="comment">// Default settings video device</span>
<a name="l00884"></a>00884     <a class="code" href="stk11xx-usb_8c.html#26007930dc526d4b95cab061a1094560" title="Set the default value about the video settings.">usb_stk11xx_default_settings</a>(dev);
<a name="l00885"></a>00885     
<a name="l00886"></a>00886 
<a name="l00887"></a>00887     <span class="keywordflow">return</span> 0;
<a name="l00888"></a>00888 }
<a name="l00889"></a>00889 
<a name="l00890"></a>00890 
<a name="l00897"></a><a class="code" href="stk11xx-usb_8c.html#780c670f6949a3cb0de3fb2e1f084844">00897</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="stk11xx-usb_8c.html#780c670f6949a3cb0de3fb2e1f084844" title="This function is called when the device is disconnected or when the kernel module...">usb_stk11xx_disconnect</a>(<span class="keyword">struct</span> usb_interface *interface)
<a name="l00898"></a>00898 {
<a name="l00899"></a>00899     <span class="keyword">struct </span>usb_stk11xx *dev = usb_get_intfdata(interface);
<a name="l00900"></a>00900 
<a name="l00901"></a>00901     <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 Camera disconnected\n"</span>);
<a name="l00902"></a>00902 
<a name="l00903"></a>00903     usb_set_intfdata(interface, NULL);
<a name="l00904"></a>00904 
<a name="l00905"></a>00905     <span class="comment">// We got unplugged; this is signalled by an EPIPE error code</span>
<a name="l00906"></a>00906     <span class="keywordflow">if</span> (dev-&gt;vopen) {
<a name="l00907"></a>00907         <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Disconnected while webcam is in use !\n"</span>);
<a name="l00908"></a>00908         dev-&gt;error_status = EPIPE;
<a name="l00909"></a>00909     }
<a name="l00910"></a>00910 
<a name="l00911"></a>00911     <span class="comment">// Alert waiting processes</span>
<a name="l00912"></a>00912     wake_up_interruptible(&amp;dev-&gt;wait_frame);
<a name="l00913"></a>00913 
<a name="l00914"></a>00914     <span class="comment">// Wait until device is closed</span>
<a name="l00915"></a>00915     <span class="keywordflow">while</span> (dev-&gt;vopen)
<a name="l00916"></a>00916         schedule();
<a name="l00917"></a>00917 
<a name="l00918"></a>00918     <span class="comment">// Remove the entries in the sys filesystem</span>
<a name="l00919"></a>00919     <a class="code" href="stk11xx-sysfs_8c.html#717ca8ef4a41adb32b2fb33e9c537621" title="Remove the &amp;#39;sys&amp;#39; entries.">stk11xx_remove_sysfs_files</a>(dev-&gt;vdev);
<a name="l00920"></a>00920 
<a name="l00921"></a>00921     <span class="comment">// Unregister the video device</span>
<a name="l00922"></a>00922     <a class="code" href="stk11xx-v4l_8c.html#62bc2469df7a6e1d2fe8c455012bd9ad" title="Unregister the video device.">v4l_stk11xx_unregister_video_device</a>(dev);
<a name="l00923"></a>00923 }
<a name="l00924"></a>00924 
<a name="l00925"></a>00925 
<a name="l00931"></a><a class="code" href="stk11xx-usb_8c.html#b5db116e2406b86c85396777390e0bc4">00931</a> <span class="keyword">static</span> <span class="keyword">struct </span>usb_driver <a class="code" href="stk11xx-usb_8c.html#b5db116e2406b86c85396777390e0bc4">usb_stk11xx_driver</a> = {
<a name="l00932"></a>00932     .name = <span class="stringliteral">"stk11xx"</span>,
<a name="l00933"></a>00933     .probe = <a class="code" href="stk11xx-usb_8c.html#0383d45a66f483766e12609cef2a058a" title="Load the driver.">usb_stk11xx_probe</a>,
<a name="l00934"></a>00934     .disconnect = <a class="code" href="stk11xx-usb_8c.html#780c670f6949a3cb0de3fb2e1f084844" title="This function is called when the device is disconnected or when the kernel module...">usb_stk11xx_disconnect</a>,
<a name="l00935"></a>00935     .id_table = <a class="code" href="stk11xx-usb_8c.html#127a4e93e778356be60aef052a4b2594">stk11xx_table</a>,
<a name="l00936"></a>00936 };
<a name="l00937"></a>00937 
<a name="l00938"></a>00938 
<a name="l00943"></a><a class="code" href="stk11xx-usb_8c.html#681bb2c58cd55763494a71a1935b6de4">00943</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#681bb2c58cd55763494a71a1935b6de4">fps</a>;
<a name="l00944"></a>00944 
<a name="l00949"></a><a class="code" href="stk11xx-usb_8c.html#16f641fad5b6a3a19b62c1486d413728">00949</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#16f641fad5b6a3a19b62c1486d413728">hflip</a> = -1;
<a name="l00950"></a>00950 
<a name="l00955"></a><a class="code" href="stk11xx-usb_8c.html#5cd2e203aadee84bf52b7c8abf5af815">00955</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#5cd2e203aadee84bf52b7c8abf5af815">vflip</a> = -1;
<a name="l00956"></a>00956 
<a name="l00961"></a><a class="code" href="stk11xx-usb_8c.html#f3e3271e8fbc9f3863a2989d0105b070">00961</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#f3e3271e8fbc9f3863a2989d0105b070">brightness</a> = -1;
<a name="l00962"></a>00962 
<a name="l00967"></a><a class="code" href="stk11xx-usb_8c.html#52018367adcbc28f741c69a2f8a369bb">00967</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#52018367adcbc28f741c69a2f8a369bb">whiteness</a> = -1;
<a name="l00968"></a>00968 
<a name="l00973"></a><a class="code" href="stk11xx-usb_8c.html#f7a235a0e8630e9c6cf86db22ec293e8">00973</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#f7a235a0e8630e9c6cf86db22ec293e8">contrast</a> = -1;
<a name="l00974"></a>00974 
<a name="l00979"></a><a class="code" href="stk11xx-usb_8c.html#a68e842dd7ce4ebaf9792928e4a990f0">00979</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="stk11xx-usb_8c.html#a68e842dd7ce4ebaf9792928e4a990f0">colour</a> = -1;
<a name="l00980"></a>00980 
<a name="l00981"></a>00981 
<a name="l00982"></a>00982 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(fps, <span class="keywordtype">int</span>, 0444);           
<a name="l00983"></a>00983 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(hflip, <span class="keywordtype">int</span>, 0444);         
<a name="l00984"></a>00984 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(vflip, <span class="keywordtype">int</span>, 0444);         
<a name="l00986"></a>00986 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(brightness, <span class="keywordtype">int</span>, 0444);    
<a name="l00987"></a>00987 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(whiteness, <span class="keywordtype">int</span>, 0444);     
<a name="l00988"></a>00988 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(contrast, <span class="keywordtype">int</span>, 0444);      
<a name="l00989"></a>00989 <a class="code" href="stk11xx-usb_8c.html#d3f8917f957fa103a606d362039c736b" title="Module frame per second parameter.">module_param</a>(colour, <span class="keywordtype">int</span>, 0444);        
<a name="l01000"></a><a class="code" href="stk11xx-usb_8c.html#31cdece9529fa4b8b61e229f8985be50">01000</a> <span class="keyword">static</span> <span class="keywordtype">int</span> __init <a class="code" href="stk11xx-usb_8c.html#31cdece9529fa4b8b61e229f8985be50" title="Initialize the driver.">usb_stk11xx_init</a>(<span class="keywordtype">void</span>)
<a name="l01001"></a>01001 {
<a name="l01002"></a>01002     <span class="keywordtype">int</span> result;
<a name="l01003"></a>01003 
<a name="l01004"></a>01004 
<a name="l01005"></a>01005     <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"Syntek USB2.0 webcam driver startup\n"</span>);
<a name="l01006"></a>01006 
<a name="l01007"></a>01007     <span class="comment">// Frame per second parameter</span>
<a name="l01008"></a>01008     <span class="keywordflow">if</span> (fps) {
<a name="l01009"></a>01009         <span class="keywordflow">if</span> (fps &lt; 9 || fps &gt; 30) {
<a name="l01010"></a>01010             <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"Framerate out of bounds [10-30] !\n"</span>);
<a name="l01011"></a>01011             <span class="keywordflow">return</span> -EINVAL;
<a name="l01012"></a>01012         }
<a name="l01013"></a>01013 
<a name="l01014"></a>01014         <a class="code" href="stk11xx-usb_8c.html#45c5672f4265c5b7fc4edc9ab803bf5b">default_fps</a> = fps;
<a name="l01015"></a>01015     }
<a name="l01016"></a>01016 
<a name="l01017"></a>01017     <span class="comment">// Horizontal flip value</span>
<a name="l01018"></a>01018     <span class="keywordflow">if</span> ((hflip == 0) || (hflip == 1)) {
<a name="l01019"></a>01019         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Set horizontal flip = %d\n"</span>, hflip);
<a name="l01020"></a>01020 
<a name="l01021"></a>01021         <a class="code" href="stk11xx-usb_8c.html#acdd8bcdee0a42ec976a3e1a3d482cdd">default_hflip</a> = hflip;
<a name="l01022"></a>01022     }
<a name="l01023"></a>01023 
<a name="l01024"></a>01024     <span class="comment">// Vertical flip value</span>
<a name="l01025"></a>01025     <span class="keywordflow">if</span> ((vflip == 0) || (vflip == 1)) {
<a name="l01026"></a>01026         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Set vertical flip = %d\n"</span>, vflip);
<a name="l01027"></a>01027 
<a name="l01028"></a>01028         <a class="code" href="stk11xx-usb_8c.html#509f0056d50f0e8d34d114c33676e1cd">default_vflip</a> = vflip;
<a name="l01029"></a>01029     }
<a name="l01030"></a>01030 
<a name="l01031"></a>01031     <span class="comment">// Brightness value</span>
<a name="l01032"></a>01032     <span class="keywordflow">if</span> (brightness &gt; -1) {
<a name="l01033"></a>01033         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Set brightness = 0x%X\n"</span>, brightness);
<a name="l01034"></a>01034 
<a name="l01035"></a>01035         <a class="code" href="stk11xx-usb_8c.html#24d316f8145699818d317f1249d6e934">default_brightness</a> = 0xffff &amp; brightness;
<a name="l01036"></a>01036     }
<a name="l01037"></a>01037 
<a name="l01038"></a>01038     <span class="comment">// Whiteness value</span>
<a name="l01039"></a>01039     <span class="keywordflow">if</span> (whiteness &gt; -1) {
<a name="l01040"></a>01040         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Set whiteness = 0x%X\n"</span>, whiteness);
<a name="l01041"></a>01041 
<a name="l01042"></a>01042         <a class="code" href="stk11xx-usb_8c.html#8992b6ef16dfe507a52f8da54a46190f">default_whiteness</a> = 0xffff &amp; whiteness;
<a name="l01043"></a>01043     }
<a name="l01044"></a>01044 
<a name="l01045"></a>01045     <span class="comment">// Contrast value</span>
<a name="l01046"></a>01046     <span class="keywordflow">if</span> (contrast &gt; -1) {
<a name="l01047"></a>01047         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Set contrast = 0x%X\n"</span>, contrast);
<a name="l01048"></a>01048 
<a name="l01049"></a>01049         <a class="code" href="stk11xx-usb_8c.html#7d75f9e7cd30d14cefda003bd57abbed">default_contrast</a> = 0xffff &amp; contrast;
<a name="l01050"></a>01050     }
<a name="l01051"></a>01051 
<a name="l01052"></a>01052     <span class="comment">// Colour value</span>
<a name="l01053"></a>01053     <span class="keywordflow">if</span> (colour &gt; -1) {
<a name="l01054"></a>01054         <a class="code" href="stk11xx_8h.html#6a7ffe6803607fae5d467b1b4f5515f2">STK_DEBUG</a>(<span class="stringliteral">"Set colour = 0x%X\n"</span>, colour);
<a name="l01055"></a>01055 
<a name="l01056"></a>01056         <a class="code" href="stk11xx-usb_8c.html#30b73e5bdb081c4927d1e8457f0f20b3">default_colour</a> = 0xffff &amp; colour;
<a name="l01057"></a>01057     }
<a name="l01058"></a>01058 
<a name="l01059"></a>01059 
<a name="l01060"></a>01060     <span class="comment">// Register the driver with the USB subsystem</span>
<a name="l01061"></a>01061     result = usb_register(&amp;usb_stk11xx_driver);
<a name="l01062"></a>01062 
<a name="l01063"></a>01063     <span class="keywordflow">if</span> (result)
<a name="l01064"></a>01064         <a class="code" href="stk11xx_8h.html#2548285f2eade14f8e93c9b611e622d7">STK_ERROR</a>(<span class="stringliteral">"usb_register failed ! Error number %d\n"</span>, result);
<a name="l01065"></a>01065 
<a name="l01066"></a>01066     <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<a class="code" href="stk11xx_8h.html#e578001fe043b4cca7a0edd801cfe9c4">DRIVER_VERSION</a> <span class="stringliteral">" : "</span> <a class="code" href="stk11xx_8h.html#ae26107a17c06584f8bbd0d6fb91013d">DRIVER_DESC</a> <span class="stringliteral">"\n"</span>);
<a name="l01067"></a>01067 
<a name="l01068"></a>01068     <span class="keywordflow">return</span> result;
<a name="l01069"></a>01069 }
<a name="l01070"></a>01070 
<a name="l01071"></a>01071 
<a name="l01077"></a><a class="code" href="stk11xx-usb_8c.html#75e675293ec796f4eda77d1816dc9753">01077</a> <span class="keyword">static</span> <span class="keywordtype">void</span> __exit <a class="code" href="stk11xx-usb_8c.html#75e675293ec796f4eda77d1816dc9753" title="Close the driver.">usb_stk11xx_exit</a>(<span class="keywordtype">void</span>)
<a name="l01078"></a>01078 {
<a name="l01079"></a>01079     <a class="code" href="stk11xx_8h.html#55d1b4af8174ee2f44f9ea2e18f6392d">STK_INFO</a>(<span class="stringliteral">"usb_stk11xx_exit: Syntek USB2.0 webcam driver shutdown\n"</span>);
<a name="l01080"></a>01080 
<a name="l01081"></a>01081     <span class="comment">// Deregister this driver with the USB subsystem</span>
<a name="l01082"></a>01082     usb_deregister(&amp;usb_stk11xx_driver);
<a name="l01083"></a>01083 }
<a name="l01084"></a>01084 
<a name="l01085"></a>01085 
<a name="l01086"></a>01086 <a class="code" href="stk11xx-usb_8c.html#00a9ec936345b54913d86c4c30a2adb1" title="Module initialize.">module_init</a>(<a class="code" href="stk11xx-usb_8c.html#31cdece9529fa4b8b61e229f8985be50" title="Initialize the driver.">usb_stk11xx_init</a>);                      
<a name="l01087"></a>01087 <a class="code" href="stk11xx-usb_8c.html#d6a5fc6c4710c03d688ecf6367fc87ac" title="Module exit.">module_exit</a>(<a class="code" href="stk11xx-usb_8c.html#75e675293ec796f4eda77d1816dc9753" title="Close the driver.">usb_stk11xx_exit</a>);                      
<a name="l01090"></a>01090 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(fps, <span class="stringliteral">"Frames per second [5-30]"</span>);  
<a name="l01091"></a>01091 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(hflip, <span class="stringliteral">"Horizontal image flip"</span>);   
<a name="l01092"></a>01092 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(vflip, <span class="stringliteral">"Vertical image flip"</span>);     
<a name="l01093"></a>01093 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(brightness, <span class="stringliteral">"Brightness setting"</span>); 
<a name="l01094"></a>01094 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(whiteness, <span class="stringliteral">"Whiteness setting"</span>);   
<a name="l01095"></a>01095 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(colour, <span class="stringliteral">"Colour setting"</span>);         
<a name="l01096"></a>01096 <a class="code" href="stk11xx-usb_8c.html#d72152ed15f3e498c799b68500d98b5d" title="Description of &amp;#39;fps&amp;#39; parameter.">MODULE_PARM_DESC</a>(contrast, <span class="stringliteral">"Contrast setting"</span>);     
<a name="l01099"></a>01099 <a class="code" href="stk11xx-usb_8c.html#d94b36675e7eb067ea3ce6ff9e244a44" title="Driver is under licence GPL.">MODULE_LICENSE</a>(<span class="stringliteral">"GPL"</span>);                              
<a name="l01100"></a>01100 <a class="code" href="stk11xx-usb_8c.html#5bb5b544a782cbd3eb4e18c715f81176" title="Driver is written by Nicolas VIVIEN.">MODULE_AUTHOR</a>(<a class="code" href="stk11xx_8h.html#13f5c49b43ae26d3c3b618ec019a7685">DRIVER_AUTHOR</a>);                       
<a name="l01101"></a>01101 <a class="code" href="stk11xx-usb_8c.html#85c7e3d47e7d6d9735e639919fd1da5c" title="Define the description of the driver.">MODULE_DESCRIPTION</a>(<a class="code" href="stk11xx_8h.html#ae26107a17c06584f8bbd0d6fb91013d">DRIVER_DESC</a>);                    
<a name="l01102"></a>01102 <a class="code" href="stk11xx-usb_8c.html#9fca9dc57417b60a77e282058638ea5c" title="List of supported device.">MODULE_SUPPORTED_DEVICE</a>(<a class="code" href="stk11xx_8h.html#4ac4c54762be94083880d2988060a7c4">DRIVER_SUPPORT</a>);            
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Sep 20 12:18:50 2009 for SyntekUSBVideoCamera by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>