Unreachable code

File: drivers/staging/easycap/.tmp_easycap_main.o.preproc
Full description: The code is unreachable by any path. Superfluous semicolon, break or return statement.
Importance: 3
Checker: ReachabilityChecker
Trace:
line 1807: This node is unreachable
line 1807: This node is unreachable
This one is:
False positive index (the lower the better): 0
File contents (this file is distributed under the terms specified in the original file):
    1|static int easycap_debug;
    2|static int easycap_bars;
    3|int easycap_gain = 16;
    4|static inline int *__check_debug(void) { return(&(easycap_debug)); }; static int __param_perm_check_debug = (sizeof(struct { int:-!!(((00400|00040|00004) | 00200) < 0 || ((00400|00040|00004) | 00200) > 0777 || (((00400|00040|00004) | 00200) & 2)); })) + (sizeof(struct { int:-!!(sizeof("") > (64 - sizeof(unsigned long))); })); static const char __param_str_debug[] = "debug"; static struct kernel_param const __param_debug = { __param_str_debug, ¶m_ops_int, (00400|00040|00004) | 00200, 0 ? 2 : 0, { &easycap_debug } }; static const char __mod_debugtype38[] = "parmtype" "=" "debug" ":" "int";
    5|static inline int *__check_bars(void) { return(&(easycap_bars)); }; static int __param_perm_check_bars = (sizeof(struct { int:-!!(((00400|00040|00004) | 00200) < 0 || ((00400|00040|00004) | 00200) > 0777 || (((00400|00040|00004) | 00200) & 2)); })) + (sizeof(struct { int:-!!(sizeof("") > (64 - sizeof(unsigned long))); })); static const char __param_str_bars[] = "bars"; static struct kernel_param const __param_bars = { __param_str_bars, ¶m_ops_int, (00400|00040|00004) | 00200, 0 ? 2 : 0, { &easycap_bars } }; static const char __mod_barstype39[] = "parmtype" "=" "bars" ":" "int";
    6|static inline int *__check_gain(void) { return(&(easycap_gain)); }; static int __param_perm_check_gain = (sizeof(struct { int:-!!(((00400|00040|00004) | 00200) < 0 || ((00400|00040|00004) | 00200) > 0777 || (((00400|00040|00004) | 00200) & 2)); })) + (sizeof(struct { int:-!!(sizeof("") > (64 - sizeof(unsigned long))); })); static const char __param_str_gain[] = "gain"; static struct kernel_param const __param_gain = { __param_str_gain, ¶m_ops_int, (00400|00040|00004) | 00200, 0 ? 2 : 0, { &easycap_gain } }; static const char __mod_gaintype40[] = "parmtype" "=" "gain" ":" "int";
    7|struct easycap_dongle easycap_dongle[8];
    8|static int dongle_this;
    9|static int dongle_done;
   10|
   11|
   12|
   13|
   14|
   15|
   16|struct usb_device_id easycap_usb_device_id_table[] = {
   17|{ .match_flags = (0x0001 | 0x0002), .idVendor = (0x05e1), .idProduct = (0x0408) },
   18|{ }
   19|};
   20|extern const struct usb_device_id __mod_usb_device_table ;
   21|struct usb_driver easycap_usb_driver = {
   22|.name = "easycap",
   23|.id_table = easycap_usb_device_id_table,
   24|.probe = easycap_usb_probe,
   25|.disconnect = easycap_usb_disconnect,
   26|};
   27|const struct file_operations easycap_fops = {
   28| .owner = (&__this_module),
   29| .open = easycap_open,
   30| .release = easycap_release,
   31|
   32| .unlocked_ioctl = easycap_ioctl_noinode,
   33|
   34|
   35|
   36| .poll = easycap_poll,
   37| .mmap = easycap_mmap,
   38| .llseek = no_llseek,
   39|};
   40|struct vm_operations_struct easycap_vm_ops = {
   41| .open = easycap_vma_open,
   42| .close = easycap_vma_close,
   43| .fault = easycap_vma_fault,
   44|};
   45|struct usb_class_driver easycap_class = {
   46| .name = "usb/easycap%d",
   47| .fops = &easycap_fops,
   48| .minor_base = 192,
   49|};
   50|
   51|
   52|
   53|const struct v4l2_file_operations v4l2_fops = {
   54| .owner = (&__this_module),
   55| .open = easycap_open_noinode,
   56| .release = easycap_release_noinode,
   57|
   58| .unlocked_ioctl = easycap_ioctl_noinode,
   59|
   60|
   61|
   62| .poll = easycap_poll,
   63| .mmap = easycap_mmap,
   64|};
   65|const struct file_operations easysnd_fops = {
   66| .owner = (&__this_module),
   67| .open = easysnd_open,
   68| .release = easysnd_release,
   69|
   70| .unlocked_ioctl = easysnd_ioctl_noinode,
   71|
   72|
   73|
   74| .read = easysnd_read,
   75| .llseek = no_llseek,
   76|};
   77|struct usb_class_driver easysnd_class = {
   78|.name = "usb/easysnd%d",
   79|.fops = &easysnd_fops,
   80|.minor_base = 192,
   81|};
   82|
   83|
   84|
   85|
   86|
   87|
   88|int
   89|isdongle(struct easycap *peasycap)
   90|{
   91|int k;
   92|if (((void *)0) == peasycap)
   93| return -2;
   94|for (k = 0; k < 8; k++) {
   95| if (easycap_dongle[k].peasycap == peasycap) {
   96|  peasycap->isdongle = k;
   97|  return k;
   98| }
   99|}
  100|return -1;
  101|}
  102|
  103|
  104|
  105|int
  106|easycap_open_noinode(struct file *file)
  107|{
  108|return easycap_open((struct inode *)((void *)0), file);
  109|}
  110|
  111|
  112|int
  113|easycap_open(struct inode *inode, struct file *file)
  114|{
  115|
  116|
  117|
  118|struct video_device *pvideo_device;
  119|
  120|struct easycap *peasycap;
  121|int rc;
  122|
  123|do {} while (0);
  124|do { printk("<7>" "easycap:: %s: " "==========OPEN=========\n", __func__); } while (0);
  125|
  126|peasycap = (struct easycap *)((void *)0);
  127|pvideo_device = video_devdata(file);
  128|if ((struct video_device *)((void *)0) == pvideo_device) {
  129| do { printk("<7>" "easycap:: %s: " "ERROR: pvideo_device is NULL.\n", __func__); } while (0);
  130| return -14;
  131|}
  132|peasycap = (struct easycap *)video_get_drvdata(pvideo_device);
  133|
  134|
  135|if (((void *)0) == peasycap) {
  136| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
  137| return -14;
  138|}
  139|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
  140| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
  141| return -14;
  142|}
  143|if (((void *)0) == peasycap->pusb_device) {
  144| do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->pusb_device is NULL\n", peasycap->isdongle, __func__);} while (0);
  145| return -14;
  146|} else {
  147| do {} while (0)
  148|                                     ;
  149|}
  150|file->private_data = peasycap;
  151|rc = wakeup_device(peasycap->pusb_device);
  152|if (0 == rc)
  153| do {} while (0);
  154|else {
  155| do { printk("<7>" "easycap::%i%s: " "ERROR: wakeup_device() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  156| if (-19 == rc)
  157|  do { printk("<7>" "easycap::%i%s: " "ERROR: wakeup_device() returned -ENODEV\n", peasycap->isdongle, __func__);} while (0);
  158| else
  159|  do { printk("<7>" "easycap::%i%s: " "ERROR: wakeup_device() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  160| return rc;
  161|}
  162|peasycap->input = 0;
  163|rc = reset(peasycap);
  164|if (0 != rc) {
  165| do { printk("<7>" "easycap::%i%s: " "ERROR: reset() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  166| return -14;
  167|}
  168|return 0;
  169|}
  170|int
  171|reset(struct easycap *peasycap)
  172|{
  173|struct easycap_standard const *peasycap_standard;
  174|int i, rc, input, rate;
  175|bool ntsc, other;
  176|
  177|if (((void *)0) == peasycap) {
  178| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
  179| return -14;
  180|}
  181|input = peasycap->input;
  182|other = false;
  183|if (true == peasycap->ntsc)
  184| do {} while (0);
  185|else
  186| do {} while (0);
  187|rate = ready_saa(peasycap->pusb_device);
  188|if (0 > rate) {
  189| do {} while (0);
  190| if (true == peasycap->ntsc) {
  191|  do {} while (0); ntsc = false;
  192| } else {
  193|  do {} while (0); ntsc = true;
  194|}
  195|rc = setup_stk(peasycap->pusb_device, ntsc);
  196|if (0 == rc)
  197| do {} while (0);
  198|else {
  199| do { printk("<7>" "easycap::%i%s: " "ERROR: setup_stk() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  200| return -14;
  201|}
  202|rc = setup_saa(peasycap->pusb_device, ntsc);
  203|if (0 == rc)
  204| do {} while (0);
  205|else {
  206| do { printk("<7>" "easycap::%i%s: " "ERROR: setup_saa() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  207| return -14;
  208|}
  209|rate = ready_saa(peasycap->pusb_device);
  210|if (0 > rate) {
  211| do {} while (0);
  212| do {} while (0)
  213|                                          ;
  214| ntsc = peasycap->ntsc;
  215| } else {
  216|  do {} while (0);
  217|  ntsc = (0 < (rate/2)) ? true : false ;
  218|  other = true;
  219| }
  220|} else {
  221| do {} while (0);
  222| ntsc = (0 < rate/2) ? true : false ;
  223|}
  224|if (true == ntsc)
  225| do {} while (0);
  226|else
  227| do {} while (0);
  228|
  229|
  230|rc = setup_stk(peasycap->pusb_device, ntsc);
  231|if (0 == rc)
  232| do {} while (0);
  233|else {
  234| do { printk("<7>" "easycap::%i%s: " "ERROR: setup_stk() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  235| return -14;
  236|}
  237|rc = setup_saa(peasycap->pusb_device, ntsc);
  238|if (0 == rc)
  239| do {} while (0);
  240|else {
  241| do { printk("<7>" "easycap::%i%s: " "ERROR: setup_saa() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  242| return -14;
  243|}
  244|
  245|for (i = 0; i < 180; i++)
  246| peasycap->merit[i] = 0;
  247|peasycap->video_eof = 0;
  248|peasycap->audio_eof = 0;
  249|do_gettimeofday(&peasycap->timeval7);
  250|
  251|
  252|
  253|
  254|
  255|
  256|
  257|peasycap->input = -8192;
  258|peasycap->standard_offset = -8192;
  259|if (true == other) {
  260| peasycap_standard = &easycap_standard[0];
  261| while (0xFFFF != peasycap_standard->mask) {
  262|  if (true == ntsc) {
  263|   if (1 ==
  264|    peasycap_standard->v4l2_standard.index) {
  265|    peasycap->inputset[input].standard_offset =
  266|      peasycap_standard -
  267|       &easycap_standard[0];
  268|    break;
  269|   }
  270|  } else {
  271|   if (0 ==
  272|    peasycap_standard->v4l2_standard.index) {
  273|    peasycap->inputset[input].standard_offset =
  274|      peasycap_standard -
  275|       &easycap_standard[0];
  276|    break;
  277|   }
  278|  }
  279|  peasycap_standard++;
  280| }
  281| if (0xFFFF == peasycap_standard->mask) {
  282|  do { printk("<7>" "easycap::%i%s: " "ERROR: standard not found\n", peasycap->isdongle, __func__);} while (0);
  283|  return -22;
  284| }
  285|do {} while (0)
  286|                                                   ;
  287|}
  288|peasycap->format_offset = -8192;
  289|peasycap->brightness = -8192;
  290|peasycap->contrast = -8192;
  291|peasycap->saturation = -8192;
  292|peasycap->hue = -8192;
  293|
  294|rc = newinput(peasycap, input);
  295|
  296|if (0 == rc)
  297| do {} while (0);
  298|else {
  299| do { printk("<7>" "easycap::%i%s: " "ERROR: newinput(.,%i) returned %i\n", peasycap->isdongle, __func__, rc, input);} while (0);
  300| return -14;
  301|}
  302|if (true == peasycap->ntsc)
  303| do {} while (0);
  304|else
  305| do {} while (0);
  306|
  307|if (0 > peasycap->input) {
  308| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->input\n", peasycap->isdongle, __func__, peasycap->input);} while (0);
  309| return -2;
  310|}
  311|if (0 > peasycap->standard_offset) {
  312| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->standard_offset\n", peasycap->isdongle, __func__, peasycap->standard_offset);} while (0)
  313|                                ;
  314| return -2;
  315|}
  316|if (0 > peasycap->format_offset) {
  317| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->format_offset\n", peasycap->isdongle, __func__, peasycap->format_offset);} while (0)
  318|                              ;
  319| return -2;
  320|}
  321|if (0 > peasycap->brightness) {
  322| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->brightness\n", peasycap->isdongle, __func__, peasycap->brightness);} while (0);
  323| return -2;
  324|}
  325|if (0 > peasycap->contrast) {
  326| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->contrast\n", peasycap->isdongle, __func__, peasycap->contrast);} while (0);
  327| return -2;
  328|}
  329|if (0 > peasycap->saturation) {
  330| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->saturation\n", peasycap->isdongle, __func__, peasycap->saturation);} while (0);
  331| return -2;
  332|}
  333|if (0 > peasycap->hue) {
  334| do { printk("<7>" "easycap::%i%s: " "MISTAKE:  %i=peasycap->hue\n", peasycap->isdongle, __func__, peasycap->hue);} while (0);
  335| return -2;
  336|}
  337|return 0;
  338|}
  339|int
  340|newinput(struct easycap *peasycap, int input)
  341|{
  342|int rc, k, m, mood, off;
  343|int inputnow, video_idlenow, audio_idlenow;
  344|bool resubmit;
  345|
  346|if (((void *)0) == peasycap) {
  347| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
  348| return -14;
  349|}
  350|do {} while (0);
  351|
  352|if (0 > input && 6 <= input)
  353| return -2;
  354|inputnow = peasycap->input;
  355|if (input == inputnow)
  356| return 0;
  357|video_idlenow = peasycap->video_idle;
  358|audio_idlenow = peasycap->audio_idle;
  359|
  360|peasycap->video_idle = 1;
  361|peasycap->audio_idle = 1;
  362|if (peasycap->video_isoc_streaming) {
  363| resubmit = true;
  364| kill_video_urbs(peasycap);
  365|} else
  366| resubmit = false;
  367|
  368|if (((void *)0) == peasycap->pusb_device) {
  369| do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->pusb_device is NULL\n", peasycap->isdongle, __func__);} while (0);
  370| return -19;
  371|}
  372|rc = usb_set_interface(peasycap->pusb_device,
  373|   peasycap->video_interface,
  374|   peasycap->video_altsetting_off);
  375|if (0 != rc) {
  376| do { printk("<7>" "easycap::%i%s: " "ERROR: usb_set_interface() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  377| return -14;
  378|}
  379|rc = stop_100(peasycap->pusb_device);
  380|if (0 != rc) {
  381| do { printk("<7>" "easycap::%i%s: " "ERROR: stop_100() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  382| return -14;
  383|}
  384|for (k = 0; k < 4; k++) {
  385| for (m = 0; m < (203 * ((1UL) << 12))/((1UL) << 12); m++)
  386|  __st_memset_st__(peasycap->field_buffer[k][m].pgo, 0, ((1UL) << 12));
  387|}
  388|for (k = 0; k < 6; k++) {
  389| for (m = 0; m < (405 * ((1UL) << 12))/((1UL) << 12); m++)
  390|  __st_memset_st__(peasycap->frame_buffer[k][m].pgo, 0, ((1UL) << 12));
  391|}
  392|peasycap->field_page = 0;
  393|peasycap->field_read = 0;
  394|peasycap->field_fill = 0;
  395|
  396|peasycap->frame_read = 0;
  397|peasycap->frame_fill = 0;
  398|for (k = 0; k < peasycap->input; k++) {
  399| (peasycap->frame_fill)++;
  400| if (peasycap->frame_buffer_many <= peasycap->frame_fill)
  401|  peasycap->frame_fill = 0;
  402|}
  403|peasycap->input = input;
  404|select_input(peasycap->pusb_device, peasycap->input, 9);
  405|
  406|if (input == peasycap->inputset[input].input) {
  407| off = peasycap->inputset[input].standard_offset;
  408| if (off != peasycap->standard_offset) {
  409|  rc = adjust_standard(peasycap,
  410|    easycap_standard[off].v4l2_standard.id);
  411|  if (0 != rc) {
  412|   do { printk("<7>" "easycap::%i%s: " "ERROR: adjust_standard() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  413|   return -14;
  414|  }
  415|  do {} while (0)
  416|                                ;
  417| } else {
  418|  do {} while (0)
  419|                                ;
  420| }
  421| off = peasycap->inputset[input].format_offset;
  422| if (off != peasycap->format_offset) {
  423|  rc = adjust_format(peasycap,
  424|   easycap_format[off].v4l2_format.fmt.pix.width,
  425|   easycap_format[off].v4l2_format.fmt.pix.height,
  426|   easycap_format[off].v4l2_format.fmt.pix.pixelformat,
  427|   easycap_format[off].v4l2_format.fmt.pix.field, false);
  428|  if (0 > rc) {
  429|   do { printk("<7>" "easycap::%i%s: " "ERROR: adjust_format() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  430|   return -14;
  431|  }
  432|  do {} while (0);
  433| } else {
  434|  do {} while (0)
  435|                              ;
  436| }
  437| mood = peasycap->inputset[input].brightness;
  438| if (mood != peasycap->brightness) {
  439|  rc = adjust_brightness(peasycap, mood);
  440|  if (0 != rc) {
  441|   do { printk("<7>" "easycap::%i%s: " "ERROR: adjust_brightness returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  442|   return -14;
  443|  }
  444|  do {} while (0);
  445| }
  446| mood = peasycap->inputset[input].contrast;
  447| if (mood != peasycap->contrast) {
  448|  rc = adjust_contrast(peasycap, mood);
  449|  if (0 != rc) {
  450|   do { printk("<7>" "easycap::%i%s: " "ERROR: adjust_contrast returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  451|   return -14;
  452|  }
  453|  do {} while (0);
  454| }
  455| mood = peasycap->inputset[input].saturation;
  456| if (mood != peasycap->saturation) {
  457|  rc = adjust_saturation(peasycap, mood);
  458|  if (0 != rc) {
  459|   do { printk("<7>" "easycap::%i%s: " "ERROR: adjust_saturation returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  460|   return -14;
  461|  }
  462|  do {} while (0);
  463| }
  464| mood = peasycap->inputset[input].hue;
  465| if (mood != peasycap->hue) {
  466|  rc = adjust_hue(peasycap, mood);
  467|  if (0 != rc) {
  468|   do { printk("<7>" "easycap::%i%s: " "ERROR: adjust_hue returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  469|   return -14;
  470|  }
  471|  do {} while (0);
  472| }
  473|} else {
  474| do { printk("<7>" "easycap::%i%s: " "MISTAKE: easycap.inputset[%i] unpopulated\n", peasycap->isdongle, __func__, input);} while (0);
  475| return -2;
  476|}
  477|
  478|if (((void *)0) == peasycap->pusb_device) {
  479| do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->pusb_device is NULL\n", peasycap->isdongle, __func__);} while (0);
  480| return -19;
  481|}
  482|rc = usb_set_interface(peasycap->pusb_device,
  483|   peasycap->video_interface,
  484|   peasycap->video_altsetting_on);
  485|if (0 != rc) {
  486| do { printk("<7>" "easycap::%i%s: " "ERROR: usb_set_interface() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  487| return -14;
  488|}
  489|rc = start_100(peasycap->pusb_device);
  490|if (0 != rc) {
  491| do { printk("<7>" "easycap::%i%s: " "ERROR: start_100() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
  492| return -14;
  493|}
  494|if (true == resubmit)
  495| submit_video_urbs(peasycap);
  496|
  497|peasycap->video_isoc_sequence = 16 - 1;
  498|peasycap->video_idle = video_idlenow;
  499|peasycap->audio_idle = audio_idlenow;
  500|peasycap->video_junk = 0;
  501|
  502|return 0;
  503|}
  504|
  505|int
  506|submit_video_urbs(struct easycap *peasycap)
  507|{
  508|struct data_urb *pdata_urb;
  509|struct urb *purb;
  510|struct list_head *plist_head;
  511|int j, isbad, nospc, m, rc;
  512|int isbuf;
  513|
  514|if (((void *)0) == peasycap) {
  515| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
  516| return -14;
  517|}
  518|
  519|if (((void *)0) == peasycap->purb_video_head) {
  520| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap->urb_video_head uninitialized\n", __func__); } while (0);
  521| return -14;
  522|}
  523|if (((void *)0) == peasycap->pusb_device) {
  524| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap->pusb_device is NULL\n", __func__); } while (0);
  525| return -19;
  526|}
  527|if (!peasycap->video_isoc_streaming) {
  528| do {} while (0);
  529| isbad = 0; nospc = 0; m = 0;
  530| for (plist_head = ((peasycap->purb_video_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_video_head)); plist_head = plist_head->next) {
  531|  pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );});
  532|  if (((void *)0) != pdata_urb) {
  533|   purb = pdata_urb->purb;
  534|   if (((void *)0) != purb) {
  535|    isbuf = pdata_urb->isbuf;
  536|    purb->interval = 1;
  537|    purb->dev = peasycap->pusb_device;
  538|    purb->pipe =
  539|     ((0 << 30) | __create_pipe(peasycap->pusb_device, peasycap->video_endpointnumber) | 0x80)
  540|                                    ;
  541|    purb->transfer_flags = 0x0002;
  542|    purb->transfer_buffer =
  543|     peasycap->video_isoc_buffer[isbuf].pgo;
  544|    purb->transfer_buffer_length =
  545|     peasycap->video_isoc_buffer_size;
  546|    purb->complete = easycap_complete;
  547|    purb->context = peasycap;
  548|    purb->start_frame = 0;
  549|    purb->number_of_packets =
  550|     peasycap->video_isoc_framesperdesc;
  551|
  552|    for (j = 0; j < peasycap->
  553|     video_isoc_framesperdesc; j++) {
  554|      purb->iso_frame_desc[j].
  555|      offset = j *
  556|      peasycap->
  557|      video_isoc_maxframesize;
  558|      purb->iso_frame_desc[j].
  559|      length = peasycap->
  560|      video_isoc_maxframesize;
  561|     }
  562|
  563|    rc = usb_submit_urb(purb, __st_GFP_KERNEL_st__);
  564|    if (0 != rc) {
  565|     isbad++;
  566|     do { printk("<7>" "easycap::%i%s: " "ERROR: usb_submit_urb() failed " "for urb with rc:\n", peasycap->isdongle, __func__);} while (0)
  567|                            ;
  568|     switch (rc) {
  569|     case -12: {
  570|      do { printk("<7>" "easycap::%i%s: " "ERROR: -ENOMEM=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  571|                            ;
  572|      break;
  573|     }
  574|     case -19: {
  575|      do { printk("<7>" "easycap::%i%s: " "ERROR: -ENODEV=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  576|                            ;
  577|      break;
  578|     }
  579|     case -6: {
  580|      do { printk("<7>" "easycap::%i%s: " "ERROR: -ENXIO=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  581|                            ;
  582|      break;
  583|     }
  584|     case -22: {
  585|      do { printk("<7>" "easycap::%i%s: " "ERROR: -EINVAL=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  586|                            ;
  587|      break;
  588|     }
  589|     case -11: {
  590|      do { printk("<7>" "easycap::%i%s: " "ERROR: -EAGAIN=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  591|                            ;
  592|      break;
  593|     }
  594|     case -27: {
  595|      do { printk("<7>" "easycap::%i%s: " "ERROR: -EFBIG=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  596|                            ;
  597|      break;
  598|     }
  599|     case -32: {
  600|      do { printk("<7>" "easycap::%i%s: " "ERROR: -EPIPE=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  601|                            ;
  602|      break;
  603|     }
  604|     case -90: {
  605|      do { printk("<7>" "easycap::%i%s: " "ERROR: -EMSGSIZE=" "usb_submit_urb()\n", peasycap->isdongle, __func__);} while (0)
  606|                            ;
  607|      break;
  608|     }
  609|     case -28: {
  610|      nospc++;
  611|      break;
  612|     }
  613|     default: {
  614|      do { printk("<7>" "easycap::%i%s: " "ERROR: %i=" "usb_submit_urb()\n", peasycap->isdongle, __func__, rc);} while (0)
  615|
  616|          ;
  617|      break;
  618|     }
  619|     }
  620|    } else {
  621|     m++;
  622|    }
  623|    } else {
  624|      isbad++;
  625|    }
  626|   } else {
  627|     isbad++;
  628|   }
  629|  }
  630| if (nospc) {
  631|  do { printk("<7>" "easycap::%i%s: " "-ENOSPC=usb_submit_urb() for %i urbs\n", peasycap->isdongle, __func__, nospc);} while (0);
  632|  do { printk("<7>" "easycap::%i%s: " ".....  possibly inadequate USB bandwidth\n", peasycap->isdongle, __func__);} while (0);
  633|  peasycap->video_eof = 1;
  634| }
  635|
  636| if (isbad) {
  637|  do {} while (0);
  638|  for (plist_head = ((peasycap->purb_video_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_video_head)); plist_head = plist_head->next) {
  639|   pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );})
  640|                  ;
  641|   if (((void *)0) != pdata_urb) {
  642|    purb = pdata_urb->purb;
  643|    if (((void *)0) != purb)
  644|     usb_kill_urb(purb);
  645|   }
  646|  }
  647|  peasycap->video_isoc_streaming = 0;
  648| } else {
  649|  peasycap->video_isoc_streaming = 1;
  650|  do {} while (0);
  651| }
  652|} else {
  653| do {} while (0);
  654|}
  655|return 0;
  656|}
  657|
  658|int
  659|kill_video_urbs(struct easycap *peasycap)
  660|{
  661|int m;
  662|struct list_head *plist_head;
  663|struct data_urb *pdata_urb;
  664|
  665|if (((void *)0) == peasycap) {
  666| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
  667| return -14;
  668|}
  669|if (peasycap->video_isoc_streaming) {
  670| if ((struct list_head *)((void *)0) != peasycap->purb_video_head) {
  671|  peasycap->video_isoc_streaming = 0;
  672|  do {} while (0);
  673|  m = 0;
  674|  for (plist_head = ((peasycap->purb_video_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_video_head)); plist_head = plist_head->next) {
  675|   pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );})
  676|                  ;
  677|   if (((void *)0) != pdata_urb) {
  678|    if (((void *)0) != pdata_urb->purb) {
  679|     usb_kill_urb(pdata_urb->purb);
  680|     m++;
  681|    }
  682|   }
  683|  }
  684|  do {} while (0);
  685| } else {
  686|  do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->purb_video_head is NULL\n", peasycap->isdongle, __func__);} while (0);
  687|  return -14;
  688| }
  689|} else {
  690| do {} while (0)
  691|                                    ;
  692|}
  693|return 0;
  694|}
  695|
  696|
  697|
  698|int
  699|easycap_release_noinode(struct file *file)
  700|{
  701|return easycap_release((struct inode *)((void *)0), file);
  702|}
  703|
  704|
  705|
  706|int
  707|easycap_release(struct inode *inode, struct file *file)
  708|{
  709|return 0;
  710|}
  711|
  712|
  713|
  714|int
  715|videodev_release(struct video_device *pvideo_device)
  716|{
  717|struct easycap *peasycap;
  718|
  719|do {} while (0);
  720|
  721|peasycap = video_get_drvdata(pvideo_device);
  722|if (((void *)0) == peasycap) {
  723| do { printk("<7>" "easycap:: %s: " "ERROR:  peasycap is NULL\n", __func__); } while (0);
  724| do { printk("<7>" "easycap:: %s: " "ending unsuccessfully\n", __func__); } while (0);
  725| return -14;
  726|}
  727|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
  728| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
  729| return -14;
  730|}
  731|if (0 != kill_video_urbs(peasycap)) {
  732| do { printk("<7>" "easycap::%i%s: " "ERROR: kill_video_urbs() failed\n", peasycap->isdongle, __func__);} while (0);
  733| return -14;
  734|}
  735|do {} while (0);
  736|return 0;
  737|}
  738|void
  739|easycap_delete(struct kref *pkref)
  740|{
  741|int k, m, gone, kd;
  742|int allocation_video_urb, allocation_video_page, allocation_video_struct;
  743|int allocation_audio_urb, allocation_audio_page, allocation_audio_struct;
  744|int registered_video, registered_audio;
  745|struct easycap *peasycap;
  746|struct data_urb *pdata_urb;
  747|struct list_head *plist_head, *plist_next;
  748|
  749|do {} while (0);
  750|
  751|peasycap = ({ const typeof( ((struct easycap *)0)->kref ) *__mptr = (pkref); (struct easycap *)( (char *)__mptr - 1 );});
  752|if (((void *)0) == peasycap) {
  753| do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap is NULL: cannot perform deletions\n", peasycap->isdongle, __func__);} while (0);
  754| return;
  755|}
  756|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
  757| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
  758| return;
  759|}
  760|kd = isdongle(peasycap);
  761|
  762|
  763|
  764|
  765|
  766|if ((struct list_head *)((void *)0) != peasycap->purb_video_head) {
  767| do {} while (0);
  768| m = 0;
  769| for (plist_head = ((peasycap->purb_video_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_video_head)); plist_head = plist_head->next) {
  770|  pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );});
  771|  if (((void *)0) == pdata_urb)
  772|   do {} while (0);
  773|  else {
  774|   if ((struct urb *)((void *)0) != pdata_urb->purb) {
  775|    usb_free_urb(pdata_urb->purb);
  776|    pdata_urb->purb = (struct urb *)((void *)0);
  777|    peasycap->allocation_video_urb -= 1;
  778|    m++;
  779|   }
  780|  }
  781| }
  782|
  783| do {} while (0);
  784|
  785| do {} while (0);
  786| m = 0;
  787| for (plist_head = (peasycap->purb_video_head)->next, plist_next = plist_head->next; plist_head != (peasycap->purb_video_head); plist_head = plist_next, plist_next = plist_head->next) {
  788|  pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );});
  789|  if ((struct data_urb *)((void *)0) != pdata_urb) {
  790|   kfree(pdata_urb); pdata_urb = (struct data_urb *)((void *)0);
  791|   peasycap->allocation_video_struct -=
  792|      sizeof(struct data_urb);
  793|   m++;
  794|  }
  795| }
  796| do {} while (0);
  797| do {} while (0);
  798| peasycap->purb_video_head = (struct list_head *)((void *)0);
  799|}
  800|
  801|do {} while (0);
  802|m = 0;
  803|for (k = 0; k < 16; k++) {
  804| if ((void *)((void *)0) != peasycap->video_isoc_buffer[k].pgo) {
  805|  free_pages((unsigned long)
  806|    (peasycap->video_isoc_buffer[k].pgo),
  807|    3);
  808|  peasycap->video_isoc_buffer[k].pgo = (void *)((void *)0);
  809|  peasycap->allocation_video_page -=
  810|    ((unsigned int)(0x01 << 3));
  811|  m++;
  812| }
  813|}
  814|do {} while (0);
  815|
  816|do {} while (0);
  817|gone = 0;
  818|for (k = 0; k < 4; k++) {
  819| for (m = 0; m < (203 * ((1UL) << 12))/((1UL) << 12); m++) {
  820|  if ((void *)((void *)0) != peasycap->field_buffer[k][m].pgo) {
  821|   free_pages(((unsigned long) (peasycap->field_buffer[k][m].pgo)), 0)
  822|                                        ;
  823|   peasycap->field_buffer[k][m].pgo = (void *)((void *)0);
  824|   peasycap->allocation_video_page -= 1;
  825|   gone++;
  826|  }
  827| }
  828|}
  829|do {} while (0);
  830|
  831|do {} while (0);
  832|gone = 0;
  833|for (k = 0; k < 6; k++) {
  834| for (m = 0; m < (405 * ((1UL) << 12))/((1UL) << 12); m++) {
  835|  if ((void *)((void *)0) != peasycap->frame_buffer[k][m].pgo) {
  836|   free_pages(((unsigned long) (peasycap->frame_buffer[k][m].pgo)), 0)
  837|                                        ;
  838|   peasycap->frame_buffer[k][m].pgo = (void *)((void *)0);
  839|   peasycap->allocation_video_page -= 1;
  840|   gone++;
  841|  }
  842| }
  843|}
  844|do {} while (0);
  845|
  846|
  847|
  848|
  849|
  850|if ((struct list_head *)((void *)0) != peasycap->purb_audio_head) {
  851| do {} while (0);
  852| m = 0;
  853| for (plist_head = ((peasycap->purb_audio_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_audio_head)); plist_head = plist_head->next) {
  854|  pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );});
  855|  if (((void *)0) == pdata_urb)
  856|   do {} while (0);
  857|  else {
  858|   if ((struct urb *)((void *)0) != pdata_urb->purb) {
  859|    usb_free_urb(pdata_urb->purb);
  860|    pdata_urb->purb = (struct urb *)((void *)0);
  861|    peasycap->allocation_audio_urb -= 1;
  862|    m++;
  863|   }
  864|  }
  865| }
  866| do {} while (0);
  867|
  868| do {} while (0);
  869| m = 0;
  870| for (plist_head = (peasycap->purb_audio_head)->next, plist_next = plist_head->next; plist_head != (peasycap->purb_audio_head); plist_head = plist_next, plist_next = plist_head->next) {
  871|  pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );});
  872|  if ((struct data_urb *)((void *)0) != pdata_urb) {
  873|   kfree(pdata_urb); pdata_urb = (struct data_urb *)((void *)0);
  874|   peasycap->allocation_audio_struct -=
  875|      sizeof(struct data_urb);
  876|   m++;
  877|  }
  878| }
  879|do {} while (0);
  880|do {} while (0);
  881|peasycap->purb_audio_head = (struct list_head *)((void *)0);
  882|}
  883|
  884|do {} while (0);
  885|m = 0;
  886|for (k = 0; k < 16; k++) {
  887| if ((void *)((void *)0) != peasycap->audio_isoc_buffer[k].pgo) {
  888|  free_pages((unsigned long)
  889|    (peasycap->audio_isoc_buffer[k].pgo),
  890|    3);
  891|  peasycap->audio_isoc_buffer[k].pgo = (void *)((void *)0);
  892|  peasycap->allocation_audio_page -=
  893|    ((unsigned int)(0x01 << 3));
  894|  m++;
  895| }
  896|}
  897|do {} while (0)
  898|                                    ;
  899|
  900|do {} while (0);
  901|gone = 0;
  902|for (k = 0; k < peasycap->audio_buffer_page_many; k++) {
  903| if ((void *)((void *)0) != peasycap->audio_buffer[k].pgo) {
  904|  free_pages(((unsigned long)(peasycap->audio_buffer[k].pgo)), 0);
  905|  peasycap->audio_buffer[k].pgo = (void *)((void *)0);
  906|  peasycap->allocation_audio_page -= 1;
  907|  gone++;
  908| }
  909|}
  910|do {} while (0);
  911|
  912|do {} while (0);
  913|allocation_video_urb = peasycap->allocation_video_urb;
  914|allocation_video_page = peasycap->allocation_video_page;
  915|allocation_video_struct = peasycap->allocation_video_struct;
  916|registered_video = peasycap->registered_video;
  917|allocation_audio_urb = peasycap->allocation_audio_urb;
  918|allocation_audio_page = peasycap->allocation_audio_page;
  919|allocation_audio_struct = peasycap->allocation_audio_struct;
  920|registered_audio = peasycap->registered_audio;
  921|
  922|kfree(peasycap);
  923|if (0 <= kd && 8 > kd) {
  924| easycap_dongle[kd].peasycap = (struct easycap *)((void *)0);
  925| do {} while (0);
  926| allocation_video_struct -= sizeof(struct easycap);
  927|} else {
  928| do { printk("<7>" "easycap:: %s: " "ERROR: cannot purge easycap_dongle[].peasycap", __func__); } while (0);
  929|}
  930|
  931|do { printk("<7>" "easycap:: %s: " "%8i= video urbs     after all deletions\n", __func__, allocation_video_urb); } while (0);
  932|do { printk("<7>" "easycap:: %s: " "%8i= video pages    after all deletions\n", __func__, allocation_video_page); } while (0);
  933|do { printk("<7>" "easycap:: %s: " "%8i= video structs  after all deletions\n", __func__, allocation_video_struct); } while (0);
  934|do { printk("<7>" "easycap:: %s: " "%8i= video devices  after all deletions\n", __func__, registered_video); } while (0);
  935|do { printk("<7>" "easycap:: %s: " "%8i= audio urbs     after all deletions\n", __func__, allocation_audio_urb); } while (0);
  936|do { printk("<7>" "easycap:: %s: " "%8i= audio pages    after all deletions\n", __func__, allocation_audio_page); } while (0);
  937|do { printk("<7>" "easycap:: %s: " "%8i= audio structs  after all deletions\n", __func__, allocation_audio_struct); } while (0);
  938|do { printk("<7>" "easycap:: %s: " "%8i= audio devices  after all deletions\n", __func__, registered_audio); } while (0);
  939|
  940|do {} while (0);
  941|return;
  942|}
  943|
  944|unsigned int easycap_poll(struct file *file, poll_table *wait)
  945|{
  946|struct easycap *peasycap;
  947|int rc, kd;
  948|
  949|do {} while (0);
  950|
  951|if (((void *)0) == ((poll_table *)wait))
  952| do {} while (0);
  953|if ((struct file *)((void *)0) == file) {
  954| do { printk("<7>" "easycap:: %s: " "ERROR:  file pointer is NULL\n", __func__); } while (0);
  955| return -512;
  956|}
  957|peasycap = file->private_data;
  958|if (((void *)0) == peasycap) {
  959| do { printk("<7>" "easycap:: %s: " "ERROR:  peasycap is NULL\n", __func__); } while (0);
  960| return -14;
  961|}
  962|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
  963| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
  964| return -14;
  965|}
  966|if (((void *)0) == peasycap->pusb_device) {
  967| do { printk("<7>" "easycap:: %s: " "ERROR:  peasycap->pusb_device is NULL\n", __func__); } while (0);
  968| return -14;
  969|}
  970|
  971|kd = isdongle(peasycap);
  972|if (0 <= kd && 8 > kd) {
  973| if (__st_mutex_lock_interruptible_st__(&easycap_dongle[kd].mutex_video)) {
  974|  do { printk("<7>" "easycap:: %s: " "ERROR: cannot down easycap_dongle[%i].mutex_video\n", __func__, kd); } while (0);
  975|  return -512;
  976| }
  977| do {} while (0);
  978|
  979|
  980|
  981|
  982|
  983|
  984|
  985| if (kd != isdongle(peasycap))
  986|  return -512;
  987| if (((void *)0) == file) {
  988|  do { printk("<7>" "easycap:: %s: " "ERROR:  file is NULL\n", __func__); } while (0);
  989|  __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
  990|  return -512;
  991| }
  992| peasycap = file->private_data;
  993| if (((void *)0) == peasycap) {
  994|  do { printk("<7>" "easycap:: %s: " "ERROR:  peasycap is NULL\n", __func__); } while (0);
  995|  __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
  996|  return -512;
  997| }
  998| if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
  999|  do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0)
 1000|                                   ;
 1001|  __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
 1002|  return -512;
 1003| }
 1004| if (((void *)0) == peasycap->pusb_device) {
 1005|  do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->pusb_device is NULL\n", peasycap->isdongle, __func__);} while (0);
 1006|  __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
 1007|  return -512;
 1008| }
 1009|} else
 1010|
 1011|
 1012|
 1013|
 1014|
 1015|
 1016|
 1017| return -512;
 1018|
 1019|rc = easycap_dqbuf(peasycap, 0);
 1020|peasycap->polled = 1;
 1021|__st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
 1022|if (0 == rc)
 1023| return 0x0001 | 0x0040;
 1024|else
 1025| return 0x0008;
 1026|}
 1027|
 1028|
 1029|
 1030|
 1031|
 1032|
 1033|int
 1034|easycap_dqbuf(struct easycap *peasycap, int mode)
 1035|{
 1036|int input, ifield, miss, rc;
 1037|
 1038|do {} while (0);
 1039|
 1040|if (((void *)0) == peasycap) {
 1041| do { printk("<7>" "easycap:: %s: " "ERROR:  peasycap is NULL\n", __func__); } while (0);
 1042| return -14;
 1043|}
 1044|if (((void *)0) == peasycap->pusb_device) {
 1045| do { printk("<7>" "easycap:: %s: " "ERROR:  peasycap->pusb_device is NULL\n", __func__); } while (0);
 1046| return -14;
 1047|}
 1048|ifield = 0;
 1049|do {} while (0);
 1050|input = peasycap->input;
 1051|if (0 <= input && 6 > input) {
 1052| rc = read_saa(peasycap->pusb_device, 0x1F);
 1053| if (0 <= rc) {
 1054|  if (rc & 0x40)
 1055|   peasycap->lost[input] += 1;
 1056|  else
 1057|   peasycap->lost[input] -= 2;
 1058|
 1059| if (0 > peasycap->lost[input])
 1060|  peasycap->lost[input] = 0;
 1061| else if ((2 * 50) < peasycap->lost[input])
 1062|  peasycap->lost[input] = (2 * 50);
 1063| }
 1064|}
 1065|
 1066|
 1067|
 1068|
 1069|
 1070|miss = 0;
 1071|while ((peasycap->field_read == peasycap->field_fill) ||
 1072|    (0 != (0xFF00 & peasycap->field_buffer
 1073|     [peasycap->field_read][0].kount)) ||
 1074|    (ifield != (0x00FF & peasycap->field_buffer
 1075|     [peasycap->field_read][0].kount))) {
 1076| if (mode)
 1077|  return -11;
 1078|
 1079| do {} while (0)
 1080|
 1081|                                               ;
 1082|
 1083| if (0 != (({ int __ret = 0; if (!((peasycap->video_idle || peasycap->video_eof || ((peasycap->field_read != peasycap->field_fill) && (0 == (0xFF00 & peasycap->field_buffer [peasycap->field_read][0].kount)) && (ifield == (0x00FF & peasycap->field_buffer [peasycap->field_read][0].kount)))))) do { wait_queue_t __wait = { .private = get_current(), .func = autoremove_wake_function, .task_list = { &((__wait).task_list), &((__wait).task_list) }, }; for (;;) { prepare_to_wait(&peasycap->wq_video, &__wait, 1); if ((peasycap->video_idle || peasycap->video_eof || ((peasycap->field_read != peasycap->field_fill) && (0 == (0xFF00 & peasycap->field_buffer [peasycap->field_read][0].kount)) && (ifield == (0x00FF & peasycap->field_buffer [peasycap->field_read][0].kount))))) break; if (!signal_pending(get_current())) { schedule(); continue; } __ret = -512; break; } finish_wait(&peasycap->wq_video, &__wait); } while (0); __ret; })
 1084|
 1085|
 1086|
 1087|
 1088|
 1089|                                         )) {
 1090|  do { printk("<7>" "easycap::%i%s: " "aborted by signal\n", peasycap->isdongle, __func__);} while (0);
 1091|  return -5;
 1092|  }
 1093| if (peasycap->video_idle) {
 1094|  do {} while (0)
 1095|                            ;
 1096|  return -11;
 1097| }
 1098| if (peasycap->video_eof) {
 1099|  do {} while (0);
 1100|
 1101|  if (1 == peasycap->status) {
 1102|   do {} while (0);
 1103|   peasycap->video_eof = 0;
 1104|   peasycap->audio_eof = 0;
 1105|   if (0 != reset(peasycap)) {
 1106|    do {} while (0);
 1107|    peasycap->video_eof = 1;
 1108|    peasycap->audio_eof = 1;
 1109|    kill_video_urbs(peasycap);
 1110|    return -5;
 1111|   }
 1112|   peasycap->status = 0;
 1113|   do {} while (0);
 1114|   return -11;
 1115|  }
 1116|
 1117|  peasycap->video_eof = 1;
 1118|  peasycap->audio_eof = 1;
 1119|  kill_video_urbs(peasycap);
 1120|  do {} while (0);
 1121|  return -5;
 1122| }
 1123|miss++;
 1124|}
 1125|do {} while (0);
 1126|
 1127|rc = field2frame(peasycap);
 1128|if (0 != rc)
 1129| do { printk("<7>" "easycap::%i%s: " "ERROR: field2frame() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
 1130|
 1131|
 1132|
 1133|
 1134|
 1135|if (ifield)
 1136| ifield = 0;
 1137|else
 1138| ifield = 1;
 1139|miss = 0;
 1140|while ((peasycap->field_read == peasycap->field_fill) ||
 1141|    (0 != (0xFF00 & peasycap->field_buffer
 1142|     [peasycap->field_read][0].kount)) ||
 1143|    (ifield != (0x00FF & peasycap->field_buffer
 1144|     [peasycap->field_read][0].kount))) {
 1145| if (mode)
 1146|  return -11;
 1147|
 1148| do {} while (0)
 1149|
 1150|                                               ;
 1151| if (0 != (({ int __ret = 0; if (!((peasycap->video_idle || peasycap->video_eof || ((peasycap->field_read != peasycap->field_fill) && (0 == (0xFF00 & peasycap->field_buffer [peasycap->field_read][0].kount)) && (ifield == (0x00FF & peasycap->field_buffer [peasycap->field_read][0]. kount)))))) do { wait_queue_t __wait = { .private = get_current(), .func = autoremove_wake_function, .task_list = { &((__wait).task_list), &((__wait).task_list) }, }; for (;;) { prepare_to_wait(&peasycap->wq_video, &__wait, 1); if ((peasycap->video_idle || peasycap->video_eof || ((peasycap->field_read != peasycap->field_fill) && (0 == (0xFF00 & peasycap->field_buffer [peasycap->field_read][0].kount)) && (ifield == (0x00FF & peasycap->field_buffer [peasycap->field_read][0]. kount))))) break; if (!signal_pending(get_current())) { schedule(); continue; } __ret = -512; break; } finish_wait(&peasycap->wq_video, &__wait); } while (0); __ret; })
 1152|
 1153|
 1154|
 1155|
 1156|
 1157|
 1158|                  )) {
 1159|  do { printk("<7>" "easycap::%i%s: " "aborted by signal\n", peasycap->isdongle, __func__);} while (0);
 1160|  return -5;
 1161| }
 1162| if (peasycap->video_idle) {
 1163|  do {} while (0)
 1164|                            ;
 1165|  return -11;
 1166| }
 1167| if (peasycap->video_eof) {
 1168|  do {} while (0);
 1169|
 1170|  if (1 == peasycap->status) {
 1171|   do {} while (0);
 1172|   peasycap->video_eof = 0;
 1173|   peasycap->audio_eof = 0;
 1174|   if (0 != reset(peasycap)) {
 1175|    do {} while (0);
 1176|    peasycap->video_eof = 1;
 1177|    peasycap->audio_eof = 1;
 1178|    kill_video_urbs(peasycap);
 1179|    return -5;
 1180|   }
 1181|   peasycap->status = 0;
 1182|   do {} while (0);
 1183|   return -11;
 1184|  }
 1185|
 1186|  peasycap->video_eof = 1;
 1187|  peasycap->audio_eof = 1;
 1188|  kill_video_urbs(peasycap);
 1189|  do {} while (0);
 1190|  return -5;
 1191| }
 1192|miss++;
 1193|}
 1194|do {} while (0);
 1195|
 1196|rc = field2frame(peasycap);
 1197|if (0 != rc)
 1198| do { printk("<7>" "easycap::%i%s: " "ERROR: field2frame() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
 1199|
 1200|
 1201|
 1202|
 1203|
 1204|if (0 != peasycap->skip) {
 1205| peasycap->skipped++;
 1206| if (peasycap->skip != peasycap->skipped)
 1207|  return peasycap->skip - peasycap->skipped;
 1208| peasycap->skipped = 0;
 1209|}
 1210|
 1211|peasycap->frame_read = peasycap->frame_fill;
 1212|peasycap->queued[peasycap->frame_read] = 0;
 1213|peasycap->done[peasycap->frame_read] = 0x0004;
 1214|
 1215|(peasycap->frame_fill)++;
 1216|if (peasycap->frame_buffer_many <= peasycap->frame_fill)
 1217| peasycap->frame_fill = 0;
 1218|
 1219|if (0x01 & easycap_standard[peasycap->standard_offset].mask) {
 1220| peasycap->frame_buffer[peasycap->frame_read][0].kount =
 1221|       V4L2_FIELD_TOP;
 1222|} else {
 1223| peasycap->frame_buffer[peasycap->frame_read][0].kount =
 1224|       V4L2_FIELD_BOTTOM;
 1225|}
 1226|
 1227|do {} while (0);
 1228|do {} while (0);
 1229|
 1230|return 0;
 1231|}
 1232|int
 1233|field2frame(struct easycap *peasycap)
 1234|{
 1235|struct timeval timeval;
 1236|long long int above, below;
 1237|__u32 remainder;
 1238|struct signed_div_result sdr;
 1239|
 1240|void *pex, *pad;
 1241|int kex, kad, mex, mad, rex, rad, rad2;
 1242|int c2, c3, w2, w3, cz, wz;
 1243|int rc, bytesperpixel, multiplier, much, more, over, rump, caches, input;
 1244|__u8 mask, margin;
 1245|bool odd, isuy, decimatepixel, offerfields, badinput;
 1246|
 1247|if (((void *)0) == peasycap) {
 1248| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
 1249| return -14;
 1250|}
 1251|
 1252|badinput = false;
 1253|input = 0x07 & peasycap->field_buffer[peasycap->field_read][0].input;
 1254|
 1255|do {} while (0)
 1256|
 1257|
 1258|
 1259|                                              ;
 1260|do {} while (0);
 1261|if (true == peasycap->offerfields)
 1262| do {} while (0);
 1263|
 1264|
 1265|
 1266|
 1267|
 1268|
 1269|if (peasycap->field_read == peasycap->field_fill) {
 1270| do { printk("<7>" "easycap::%i%s: " "ERROR: on entry, still filling field buffer %i\n", peasycap->isdongle, __func__, peasycap->field_read);} while (0)
 1271|                            ;
 1272| return 0;
 1273|}
 1274|
 1275|
 1276|
 1277|if (0 <= input && 6 > input) {
 1278| if (easycap_bars && 50 <= peasycap->lost[input])
 1279|  easycap_testcard(peasycap, peasycap->field_read);
 1280|}
 1281|
 1282|
 1283|
 1284|offerfields = peasycap->offerfields;
 1285|bytesperpixel = peasycap->bytesperpixel;
 1286|decimatepixel = peasycap->decimatepixel;
 1287|
 1288|if ((2 != bytesperpixel) &&
 1289|   (3 != bytesperpixel) &&
 1290|   (4 != bytesperpixel)) {
 1291| do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=bytesperpixel\n", peasycap->isdongle, __func__, bytesperpixel);} while (0);
 1292| return -14;
 1293|}
 1294|if (true == decimatepixel)
 1295| multiplier = 2;
 1296|else
 1297| multiplier = 1;
 1298|
 1299|w2 = 2 * multiplier * (peasycap->width);
 1300|w3 = bytesperpixel *
 1301|  multiplier *
 1302|  (peasycap->width);
 1303|wz = multiplier *
 1304|  (peasycap->height) *
 1305|  multiplier *
 1306|  (peasycap->width);
 1307|
 1308|kex = peasycap->field_read; mex = 0;
 1309|kad = peasycap->frame_fill; mad = 0;
 1310|
 1311|pex = peasycap->field_buffer[kex][0].pgo; rex = ((1UL) << 12);
 1312|pad = peasycap->frame_buffer[kad][0].pgo; rad = ((1UL) << 12);
 1313|if (peasycap->field_buffer[kex][0].kount)
 1314| odd = true;
 1315|else
 1316| odd = false;
 1317|
 1318|if ((true == odd) && (false == decimatepixel)) {
 1319| do {} while (0)
 1320|                          ;
 1321| pad += (w3 / multiplier); rad -= (w3 / multiplier);
 1322|}
 1323|isuy = true;
 1324|mask = 0; rump = 0; caches = 0;
 1325|
 1326|cz = 0;
 1327|while (cz < wz) {
 1328|
 1329|
 1330|
 1331|
 1332|
 1333|
 1334|
 1335| if (false == decimatepixel) {
 1336|  over = w2;
 1337|  do {
 1338|   much = over; more = 0; margin = 0; mask = 0x00;
 1339|   if (rex < much)
 1340|    much = rex;
 1341|   rump = 0;
 1342|
 1343|   if (much % 2) {
 1344|    do { printk("<7>" "easycap::%i%s: " "MISTAKE: much is odd\n", peasycap->isdongle, __func__);} while (0);
 1345|    return -14;
 1346|   }
 1347|
 1348|   more = (bytesperpixel *
 1349|     much) / 2;
 1350|
 1351|   if (1 < bytesperpixel) {
 1352|    if (rad * 2 < much * bytesperpixel) {
 1353|
 1354|
 1355|
 1356|
 1357|
 1358|     rad2 = rad + bytesperpixel - 1;
 1359|     much = ((((2 *
 1360|      rad2)/bytesperpixel)/2) * 2);
 1361|     rump = ((bytesperpixel *
 1362|       much) / 2) - rad;
 1363|     more = rad;
 1364|     }
 1365|    mask = (__u8)rump;
 1366|    margin = 0;
 1367|    if (much == rex) {
 1368|     mask |= 0x04;
 1369|     if ((mex + 1) < (203 * ((1UL) << 12))/
 1370|        ((1UL) << 12)) {
 1371|      margin = *((__u8 *)(peasycap->
 1372|       field_buffer
 1373|       [kex][mex + 1].pgo));
 1374|     } else
 1375|      mask |= 0x08;
 1376|    }
 1377|
 1378|   } else {
 1379|    do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=bytesperpixel\n", peasycap->isdongle, __func__, bytesperpixel);} while (0)
 1380|                    ;
 1381|    return -14;
 1382|   }
 1383|
 1384|   if (rump)
 1385|    caches++;
 1386|    if (true == badinput) {
 1387|     do {} while (0)
 1388|
 1389|
 1390|
 1391|
 1392|                             ;
 1393|    }
 1394|   rc = redaub(peasycap, pad, pex, much, more,
 1395|       mask, margin, isuy);
 1396|   if (0 > rc) {
 1397|    do { printk("<7>" "easycap::%i%s: " "ERROR: redaub() failed\n", peasycap->isdongle, __func__);} while (0);
 1398|    return -14;
 1399|   }
 1400|   if (much % 4) {
 1401|    if (isuy)
 1402|     isuy = false;
 1403|    else
 1404|     isuy = true;
 1405|   }
 1406|   over -= much; cz += much;
 1407|   pex += much; rex -= much;
 1408|   if (!rex) {
 1409|    mex++;
 1410|    pex = peasycap->field_buffer[kex][mex].pgo;
 1411|    rex = ((1UL) << 12);
 1412|    if (peasycap->field_buffer[kex][mex].input !=
 1413|      (0x08|peasycap->input))
 1414|     badinput = true;
 1415|   }
 1416|   pad += more;
 1417|   rad -= more;
 1418|   if (!rad) {
 1419|    mad++;
 1420|    pad = peasycap->frame_buffer[kad][mad].pgo;
 1421|    rad = ((1UL) << 12);
 1422|    if (rump) {
 1423|     pad += rump;
 1424|     rad -= rump;
 1425|    }
 1426|   }
 1427|  } while (over);
 1428|
 1429|
 1430|
 1431|
 1432|
 1433|
 1434|  if ((false == odd) || (cz != wz)) {
 1435|   over = w3;
 1436|   do {
 1437|    if (!rad) {
 1438|     mad++;
 1439|     pad = peasycap->frame_buffer
 1440|      [kad][mad].pgo;
 1441|     rad = ((1UL) << 12);
 1442|    }
 1443|    more = over;
 1444|    if (rad < more)
 1445|     more = rad;
 1446|    over -= more;
 1447|    pad += more;
 1448|    rad -= more;
 1449|   } while (over);
 1450|  }
 1451| } else if (false == odd) {
 1452|  over = w2;
 1453|  do {
 1454|   much = over; more = 0; margin = 0; mask = 0x00;
 1455|   if (rex < much)
 1456|    much = rex;
 1457|   rump = 0;
 1458|
 1459|   if (much % 2) {
 1460|    do { printk("<7>" "easycap::%i%s: " "MISTAKE: much is odd\n", peasycap->isdongle, __func__);} while (0);
 1461|    return -14;
 1462|   }
 1463|
 1464|   more = (bytesperpixel *
 1465|     much) / 4;
 1466|
 1467|   if (1 < bytesperpixel) {
 1468|    if (rad * 4 < much * bytesperpixel) {
 1469|
 1470|
 1471|
 1472|
 1473|
 1474|     rad2 = rad + bytesperpixel - 1;
 1475|     much = ((((2 * rad2)/bytesperpixel)/2)
 1476|         * 4);
 1477|     rump = ((bytesperpixel *
 1478|       much) / 4) - rad;
 1479|     more = rad;
 1480|     }
 1481|    mask = (__u8)rump;
 1482|    margin = 0;
 1483|    if (much == rex) {
 1484|     mask |= 0x04;
 1485|     if ((mex + 1) < (203 * ((1UL) << 12))/
 1486|        ((1UL) << 12)) {
 1487|      margin = *((__u8 *)(peasycap->
 1488|       field_buffer
 1489|       [kex][mex + 1].pgo));
 1490|      }
 1491|     else
 1492|      mask |= 0x08;
 1493|     }
 1494|
 1495|    } else {
 1496|     do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=bytesperpixel\n", peasycap->isdongle, __func__, bytesperpixel);} while (0)
 1497|                    ;
 1498|     return -14;
 1499|    }
 1500|
 1501|   if (rump)
 1502|    caches++;
 1503|
 1504|    if (true == badinput) {
 1505|     do {} while (0)
 1506|
 1507|
 1508|
 1509|
 1510|                             ;
 1511|    }
 1512|   rc = redaub(peasycap, pad, pex, much, more,
 1513|       mask, margin, isuy);
 1514|   if (0 > rc) {
 1515|    do { printk("<7>" "easycap::%i%s: " "ERROR: redaub() failed\n", peasycap->isdongle, __func__);} while (0);
 1516|    return -14;
 1517|   }
 1518|   over -= much; cz += much;
 1519|   pex += much; rex -= much;
 1520|   if (!rex) {
 1521|    mex++;
 1522|    pex = peasycap->field_buffer[kex][mex].pgo;
 1523|    rex = ((1UL) << 12);
 1524|    if (peasycap->field_buffer[kex][mex].input !=
 1525|      (0x08|peasycap->input))
 1526|     badinput = true;
 1527|   }
 1528|   pad += more;
 1529|   rad -= more;
 1530|   if (!rad) {
 1531|    mad++;
 1532|    pad = peasycap->frame_buffer[kad][mad].pgo;
 1533|    rad = ((1UL) << 12);
 1534|    if (rump) {
 1535|     pad += rump;
 1536|     rad -= rump;
 1537|    }
 1538|   }
 1539|  } while (over);
 1540|
 1541|
 1542|
 1543|
 1544|
 1545|
 1546| } else {
 1547|  over = w2;
 1548|  do {
 1549|   if (!rex) {
 1550|    mex++;
 1551|    pex = peasycap->field_buffer[kex][mex].pgo;
 1552|    rex = ((1UL) << 12);
 1553|    if (peasycap->field_buffer[kex][mex].input !=
 1554|      (0x08|peasycap->input)) {
 1555|     do {} while (0)
 1556|
 1557|
 1558|
 1559|
 1560|                             ;
 1561|     badinput = true;
 1562|    }
 1563|   }
 1564|   much = over;
 1565|   if (rex < much)
 1566|    much = rex;
 1567|   over -= much;
 1568|   cz += much;
 1569|   pex += much;
 1570|   rex -= much;
 1571|  } while (over);
 1572| }
 1573|}
 1574|
 1575|
 1576|
 1577|
 1578|
 1579|c2 = (mex + 1)*((1UL) << 12) - rex;
 1580|if (cz != c2)
 1581| do { printk("<7>" "easycap::%i%s: " "ERROR: discrepancy %i in bytes read\n", peasycap->isdongle, __func__, c2 - cz);} while (0);
 1582|c3 = (mad + 1)*((1UL) << 12) - rad;
 1583|
 1584|if (false == decimatepixel) {
 1585| if (bytesperpixel *
 1586|  cz != c3)
 1587|  do { printk("<7>" "easycap::%i%s: " "ERROR: discrepancy %i in bytes written\n", peasycap->isdongle, __func__, c3 - (bytesperpixel * cz));} while (0)
 1588|
 1589|             ;
 1590|} else {
 1591| if (false == odd) {
 1592|  if (bytesperpixel *
 1593|   cz != (4 * c3))
 1594|   do { printk("<7>" "easycap::%i%s: " "ERROR: discrepancy %i in bytes written\n", peasycap->isdongle, __func__, (2*c3)-(bytesperpixel * cz));} while (0)
 1595|
 1596|             ;
 1597|  } else {
 1598|   if (0 != c3)
 1599|    do { printk("<7>" "easycap::%i%s: " "ERROR: discrepancy %i " "in bytes written\n", peasycap->isdongle, __func__, c3);} while (0)
 1600|                               ;
 1601|  }
 1602|}
 1603|if (rump)
 1604| do { printk("<7>" "easycap::%i%s: " "WORRY: undischarged cache at end of line in frame buffer\n", peasycap->isdongle, __func__);} while (0);
 1605|
 1606|do {} while (0);
 1607|do {} while (0);
 1608|
 1609|if (true == odd)
 1610| do {} while (0);
 1611|
 1612|if (peasycap->field_read == peasycap->field_fill)
 1613| do { printk("<7>" "easycap::%i%s: " "WARNING: on exit, filling field buffer %i\n", peasycap->isdongle, __func__, peasycap->field_read);} while (0)
 1614|                            ;
 1615|
 1616|
 1617|
 1618|
 1619|
 1620|do_gettimeofday(&timeval);
 1621|if (peasycap->timeval6.tv_sec) {
 1622| below = ((long long int)(1000000)) *
 1623|  ((long long int)(timeval.tv_sec -
 1624|     peasycap->timeval6.tv_sec)) +
 1625|   (long long int)(timeval.tv_usec - peasycap->timeval6.tv_usec);
 1626| above = (long long int)1000000;
 1627|
 1628| sdr = signed_div(above, below);
 1629| above = sdr.quotient;
 1630| remainder = (__u32)sdr.remainder;
 1631|
 1632| do {} while (0)
 1633|                        ;
 1634|}
 1635|peasycap->timeval6 = timeval;
 1636|
 1637|if (caches)
 1638| do {} while (0);
 1639|return 0;
 1640|}
 1641|
 1642|struct signed_div_result
 1643|signed_div(long long int above, long long int below)
 1644|{
 1645|struct signed_div_result sdr;
 1646|
 1647|if (((0 <= above) && (0 <= below)) || ((0 > above) && (0 > below))) {
 1648| sdr.remainder = (unsigned long long int) ({ uint32_t __base = (below); uint32_t __rem; __rem = ((uint64_t)(above)) % __base; (above) = ((uint64_t)(above)) / __base; __rem; });
 1649| sdr.quotient = (long long int) above;
 1650|} else {
 1651| if (0 > above)
 1652|  above = -above;
 1653| if (0 > below)
 1654|  below = -below;
 1655| sdr.remainder = (unsigned long long int) ({ uint32_t __base = (below); uint32_t __rem; __rem = ((uint64_t)(above)) % __base; (above) = ((uint64_t)(above)) / __base; __rem; });
 1656| sdr.quotient = -((long long int) above);
 1657|}
 1658|return sdr;
 1659|}
 1660|int
 1661|redaub(struct easycap *peasycap, void *pad, void *pex, int much, int more,
 1662|     __u8 mask, __u8 margin, bool isuy)
 1663|{
 1664|static __s32 ay[256], bu[256], rv[256], gu[256], gv[256];
 1665|__u8 *pcache;
 1666|__u8 r, g, b, y, u, v, c, *p2, *p3, *pz, *pr;
 1667|int bytesperpixel;
 1668|bool byteswaporder, decimatepixel, last;
 1669|int j, rump;
 1670|__s32 s32;
 1671|
 1672|if (much % 2) {
 1673| do { printk("<7>" "easycap::%i%s: " "MISTAKE: much is odd\n", peasycap->isdongle, __func__);} while (0);
 1674| return -14;
 1675|}
 1676|bytesperpixel = peasycap->bytesperpixel;
 1677|byteswaporder = peasycap->byteswaporder;
 1678|decimatepixel = peasycap->decimatepixel;
 1679|
 1680|
 1681|if (!bu[255]) {
 1682| for (j = 0; j < 112; j++) {
 1683|  s32 = (0xFF00 & (453 * j)) >> 8;
 1684|  bu[j + 128] = s32; bu[127 - j] = -s32;
 1685|  s32 = (0xFF00 & (359 * j)) >> 8;
 1686|  rv[j + 128] = s32; rv[127 - j] = -s32;
 1687|  s32 = (0xFF00 & (88 * j)) >> 8;
 1688|  gu[j + 128] = s32; gu[127 - j] = -s32;
 1689|  s32 = (0xFF00 & (183 * j)) >> 8;
 1690|  gv[j + 128] = s32; gv[127 - j] = -s32;
 1691| }
 1692| for (j = 0; j < 16; j++) {
 1693|  bu[j] = bu[16]; rv[j] = rv[16];
 1694|  gu[j] = gu[16]; gv[j] = gv[16];
 1695| }
 1696| for (j = 240; j < 256; j++) {
 1697|  bu[j] = bu[239]; rv[j] = rv[239];
 1698|  gu[j] = gu[239]; gv[j] = gv[239];
 1699| }
 1700| for (j = 16; j < 236; j++)
 1701|  ay[j] = j;
 1702| for (j = 0; j < 16; j++)
 1703|  ay[j] = ay[16];
 1704| for (j = 236; j < 256; j++)
 1705|  ay[j] = ay[235];
 1706| do {} while (0);
 1707|}
 1708|pcache = peasycap->pcache;
 1709|if (((void *)0) == pcache)
 1710| pcache = &peasycap->cache[0];
 1711|
 1712|
 1713|
 1714|
 1715|
 1716|if (!pcache) {
 1717| do { printk("<7>" "easycap::%i%s: " "MISTAKE: pcache is NULL\n", peasycap->isdongle, __func__);} while (0);
 1718| return -14;
 1719|}
 1720|
 1721|if (pcache != &peasycap->cache[0])
 1722| do {} while (0);
 1723|p2 = &peasycap->cache[0];
 1724|p3 = (__u8 *)pad - (int)(pcache - &peasycap->cache[0]);
 1725|while (p2 < pcache) {
 1726| *p3++ = *p2; p2++;
 1727|}
 1728|pcache = &peasycap->cache[0];
 1729|if (p3 != pad) {
 1730| do { printk("<7>" "easycap::%i%s: " "MISTAKE: pointer misalignment\n", peasycap->isdongle, __func__);} while (0);
 1731| return -14;
 1732|}
 1733|
 1734|rump = (int)(0x03 & mask);
 1735|u = 0; v = 0;
 1736|p2 = (__u8 *)pex; pz = p2 + much; pr = p3 + more; last = false;
 1737|p2++;
 1738|
 1739|if (true == isuy)
 1740| u = *(p2 - 1);
 1741|else
 1742| v = *(p2 - 1);
 1743|
 1744|if (rump)
 1745| do {} while (0);
 1746|
 1747|
 1748|switch (bytesperpixel) {
 1749|case 2: {
 1750| if (false == decimatepixel) {
 1751|  __st_memcpy_st__(pad, pex, (size_t)much);
 1752|  if (false == byteswaporder)
 1753|
 1754|
 1755|
 1756|
 1757|
 1758|   return 0;
 1759|  else {
 1760|
 1761|
 1762|
 1763|
 1764|
 1765|   p3 = (__u8 *)pad; pz = p3 + much;
 1766|   while (pz > p3) {
 1767|    c = *p3;
 1768|    *p3 = *(p3 + 1);
 1769|    *(p3 + 1) = c;
 1770|    p3 += 2;
 1771|   }
 1772|   return 0;
 1773|  }
 1774| } else {
 1775|  if (false == byteswaporder) {
 1776|
 1777|
 1778|
 1779|
 1780|
 1781|   p2 = (__u8 *)pex; p3 = (__u8 *)pad; pz = p2 + much;
 1782|   while (pz > p2) {
 1783|    *p3 = *p2;
 1784|    *(p3 + 1) = *(p2 + 1);
 1785|    *(p3 + 2) = *(p2 + 2);
 1786|    *(p3 + 3) = *(p2 + 3);
 1787|    p3 += 4; p2 += 8;
 1788|   }
 1789|   return 0;
 1790|  } else {
 1791|
 1792|
 1793|
 1794|
 1795|
 1796|   p2 = (__u8 *)pex; p3 = (__u8 *)pad; pz = p2 + much;
 1797|   while (pz > p2) {
 1798|    *p3 = *(p2 + 1);
 1799|    *(p3 + 1) = *p2;
 1800|    *(p3 + 2) = *(p2 + 3);
 1801|    *(p3 + 3) = *(p2 + 2);
 1802|    p3 += 4; p2 += 8;
 1803|   }
 1804|   return 0;
 1805|  }
 1806| }
 1807| break;
     |This node is unreachable prev next
 1808| }
 1809|case 3:
 1810| {
 1811| if (false == decimatepixel) {
 1812|  if (false == byteswaporder) {
 1813|
 1814|
 1815|
 1816|
 1817|
 1818|   while (pz > p2) {
 1819|    if (pr <= (p3 + bytesperpixel))
 1820|     last = true;
 1821|    else
 1822|     last = false;
 1823|    y = *p2;
 1824|    if ((true == last) && (0x0C & mask)) {
 1825|     if (0x04 & mask) {
 1826|      if (true == isuy)
 1827|       v = margin;
 1828|      else
 1829|       u = margin;
 1830|     } else
 1831|      if (0x08 & mask)
 1832|       ;
 1833|    } else {
 1834|     if (true == isuy)
 1835|      v = *(p2 + 1);
 1836|     else
 1837|      u = *(p2 + 1);
 1838|    }
 1839|
 1840|    s32 = ay[(int)y] + rv[(int)v];
 1841|    r = (255 < s32) ? 255 : ((0 > s32) ?
 1842|       0 : (__u8)s32);
 1843|    s32 = ay[(int)y] - gu[(int)u] - gv[(int)v];
 1844|    g = (255 < s32) ? 255 : ((0 > s32) ?
 1845|       0 : (__u8)s32);
 1846|    s32 = ay[(int)y] + bu[(int)u];
 1847|    b = (255 < s32) ? 255 : ((0 > s32) ?
 1848|       0 : (__u8)s32);
 1849|
 1850|    if ((true == last) && rump) {
 1851|     pcache = &peasycap->cache[0];
 1852|     switch (bytesperpixel - rump) {
 1853|     case 1: {
 1854|      *p3 = r;
 1855|      *pcache++ = g;
 1856|      *pcache++ = b;
 1857|      break;
 1858|     }
 1859|     case 2: {
 1860|      *p3 = r;
 1861|      *(p3 + 1) = g;
 1862|      *pcache++ = b;
 1863|      break;
 1864|     }
 1865|     default: {
 1866|      do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 1867|                            ;
 1868|      return -14;
 1869|     }
 1870|     }
 1871|    } else {
 1872|     *p3 = r;
 1873|     *(p3 + 1) = g;
 1874|     *(p3 + 2) = b;
 1875|    }
 1876|    p2 += 2;
 1877|    if (true == isuy)
 1878|     isuy = false;
 1879|    else
 1880|     isuy = true;
 1881|    p3 += bytesperpixel;
 1882|   }
 1883|   return 0;
 1884|  } else {
 1885|
 1886|
 1887|
 1888|
 1889|
 1890|   while (pz > p2) {
 1891|    if (pr <= (p3 + bytesperpixel))
 1892|     last = true;
 1893|    else
 1894|     last = false;
 1895|    y = *p2;
 1896|    if ((true == last) && (0x0C & mask)) {
 1897|     if (0x04 & mask) {
 1898|      if (true == isuy)
 1899|       v = margin;
 1900|      else
 1901|       u = margin;
 1902|     }
 1903|    else
 1904|     if (0x08 & mask)
 1905|      ;
 1906|    } else {
 1907|     if (true == isuy)
 1908|      v = *(p2 + 1);
 1909|     else
 1910|      u = *(p2 + 1);
 1911|    }
 1912|
 1913|    s32 = ay[(int)y] + rv[(int)v];
 1914|    r = (255 < s32) ? 255 : ((0 > s32) ?
 1915|        0 : (__u8)s32);
 1916|    s32 = ay[(int)y] - gu[(int)u] - gv[(int)v];
 1917|    g = (255 < s32) ? 255 : ((0 > s32) ?
 1918|        0 : (__u8)s32);
 1919|    s32 = ay[(int)y] + bu[(int)u];
 1920|    b = (255 < s32) ? 255 : ((0 > s32) ?
 1921|        0 : (__u8)s32);
 1922|
 1923|    if ((true == last) && rump) {
 1924|     pcache = &peasycap->cache[0];
 1925|     switch (bytesperpixel - rump) {
 1926|     case 1: {
 1927|      *p3 = b;
 1928|      *pcache++ = g;
 1929|      *pcache++ = r;
 1930|      break;
 1931|     }
 1932|     case 2: {
 1933|      *p3 = b;
 1934|      *(p3 + 1) = g;
 1935|      *pcache++ = r;
 1936|      break;
 1937|     }
 1938|     default: {
 1939|      do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 1940|                            ;
 1941|      return -14;
 1942|     }
 1943|     }
 1944|    } else {
 1945|     *p3 = b;
 1946|     *(p3 + 1) = g;
 1947|     *(p3 + 2) = r;
 1948|     }
 1949|    p2 += 2;
 1950|    if (true == isuy)
 1951|     isuy = false;
 1952|    else
 1953|     isuy = true;
 1954|    p3 += bytesperpixel;
 1955|    }
 1956|   }
 1957|  return 0;
 1958| } else {
 1959|  if (false == byteswaporder) {
 1960|
 1961|
 1962|
 1963|
 1964|
 1965|   while (pz > p2) {
 1966|    if (pr <= (p3 + bytesperpixel))
 1967|     last = true;
 1968|    else
 1969|     last = false;
 1970|    y = *p2;
 1971|    if ((true == last) && (0x0C & mask)) {
 1972|     if (0x04 & mask) {
 1973|      if (true == isuy)
 1974|       v = margin;
 1975|      else
 1976|       u = margin;
 1977|     } else
 1978|      if (0x08 & mask)
 1979|       ;
 1980|    } else {
 1981|     if (true == isuy)
 1982|      v = *(p2 + 1);
 1983|     else
 1984|      u = *(p2 + 1);
 1985|    }
 1986|
 1987|    if (true == isuy) {
 1988|     s32 = ay[(int)y] + rv[(int)v];
 1989|     r = (255 < s32) ? 255 : ((0 > s32) ?
 1990|        0 : (__u8)s32);
 1991|     s32 = ay[(int)y] - gu[(int)u] -
 1992|        gv[(int)v];
 1993|     g = (255 < s32) ? 255 : ((0 > s32) ?
 1994|        0 : (__u8)s32);
 1995|     s32 = ay[(int)y] + bu[(int)u];
 1996|     b = (255 < s32) ? 255 : ((0 > s32) ?
 1997|        0 : (__u8)s32);
 1998|
 1999|     if ((true == last) && rump) {
 2000|      pcache = &peasycap->cache[0];
 2001|      switch (bytesperpixel - rump) {
 2002|      case 1: {
 2003|       *p3 = r;
 2004|       *pcache++ = g;
 2005|       *pcache++ = b;
 2006|       break;
 2007|      }
 2008|      case 2: {
 2009|       *p3 = r;
 2010|       *(p3 + 1) = g;
 2011|       *pcache++ = b;
 2012|       break;
 2013|      }
 2014|      default: {
 2015|       do { printk("<7>" "easycap::%i%s: " "MISTAKE: " "%i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 2016|
 2017|                            ;
 2018|       return -14;
 2019|      }
 2020|      }
 2021|     } else {
 2022|      *p3 = r;
 2023|      *(p3 + 1) = g;
 2024|      *(p3 + 2) = b;
 2025|     }
 2026|     isuy = false;
 2027|     p3 += bytesperpixel;
 2028|    } else {
 2029|     isuy = true;
 2030|    }
 2031|    p2 += 2;
 2032|   }
 2033|   return 0;
 2034|  } else {
 2035|
 2036|
 2037|
 2038|
 2039|
 2040|   while (pz > p2) {
 2041|    if (pr <= (p3 + bytesperpixel))
 2042|     last = true;
 2043|    else
 2044|     last = false;
 2045|    y = *p2;
 2046|    if ((true == last) && (0x0C & mask)) {
 2047|     if (0x04 & mask) {
 2048|      if (true == isuy)
 2049|       v = margin;
 2050|      else
 2051|       u = margin;
 2052|     } else
 2053|      if (0x08 & mask)
 2054|       ;
 2055|    } else {
 2056|     if (true == isuy)
 2057|      v = *(p2 + 1);
 2058|     else
 2059|      u = *(p2 + 1);
 2060|    }
 2061|
 2062|    if (true == isuy) {
 2063|
 2064|     s32 = ay[(int)y] + rv[(int)v];
 2065|     r = (255 < s32) ? 255 : ((0 > s32) ?
 2066|        0 : (__u8)s32);
 2067|     s32 = ay[(int)y] - gu[(int)u] -
 2068|        gv[(int)v];
 2069|     g = (255 < s32) ? 255 : ((0 > s32) ?
 2070|        0 : (__u8)s32);
 2071|     s32 = ay[(int)y] + bu[(int)u];
 2072|     b = (255 < s32) ? 255 : ((0 > s32) ?
 2073|        0 : (__u8)s32);
 2074|
 2075|     if ((true == last) && rump) {
 2076|      pcache = &peasycap->cache[0];
 2077|      switch (bytesperpixel - rump) {
 2078|      case 1: {
 2079|       *p3 = b;
 2080|       *pcache++ = g;
 2081|       *pcache++ = r;
 2082|       break;
 2083|      }
 2084|      case 2: {
 2085|       *p3 = b;
 2086|       *(p3 + 1) = g;
 2087|       *pcache++ = r;
 2088|       break;
 2089|      }
 2090|      default: {
 2091|       do { printk("<7>" "easycap::%i%s: " "MISTAKE: " "%i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 2092|
 2093|                            ;
 2094|       return -14;
 2095|      }
 2096|      }
 2097|     } else {
 2098|      *p3 = b;
 2099|      *(p3 + 1) = g;
 2100|      *(p3 + 2) = r;
 2101|      }
 2102|     isuy = false;
 2103|     p3 += bytesperpixel;
 2104|     }
 2105|    else
 2106|     isuy = true;
 2107|    p2 += 2;
 2108|    }
 2109|   return 0;
 2110|   }
 2111|  }
 2112| break;
 2113| }
 2114|case 4:
 2115| {
 2116| if (false == decimatepixel) {
 2117|  if (false == byteswaporder) {
 2118|
 2119|
 2120|
 2121|
 2122|
 2123|   while (pz > p2) {
 2124|    if (pr <= (p3 + bytesperpixel))
 2125|     last = true;
 2126|    else
 2127|     last = false;
 2128|    y = *p2;
 2129|    if ((true == last) && (0x0C & mask)) {
 2130|     if (0x04 & mask) {
 2131|      if (true == isuy)
 2132|       v = margin;
 2133|      else
 2134|       u = margin;
 2135|     } else
 2136|       if (0x08 & mask)
 2137|       ;
 2138|    } else {
 2139|     if (true == isuy)
 2140|      v = *(p2 + 1);
 2141|     else
 2142|      u = *(p2 + 1);
 2143|    }
 2144|
 2145|    s32 = ay[(int)y] + rv[(int)v];
 2146|    r = (255 < s32) ? 255 : ((0 > s32) ?
 2147|        0 : (__u8)s32);
 2148|    s32 = ay[(int)y] - gu[(int)u] - gv[(int)v];
 2149|    g = (255 < s32) ? 255 : ((0 > s32) ?
 2150|        0 : (__u8)s32);
 2151|    s32 = ay[(int)y] + bu[(int)u];
 2152|    b = (255 < s32) ? 255 : ((0 > s32) ?
 2153|        0 : (__u8)s32);
 2154|
 2155|    if ((true == last) && rump) {
 2156|     pcache = &peasycap->cache[0];
 2157|     switch (bytesperpixel - rump) {
 2158|     case 1: {
 2159|      *p3 = r;
 2160|      *pcache++ = g;
 2161|      *pcache++ = b;
 2162|      *pcache++ = 0;
 2163|      break;
 2164|     }
 2165|     case 2: {
 2166|      *p3 = r;
 2167|      *(p3 + 1) = g;
 2168|      *pcache++ = b;
 2169|      *pcache++ = 0;
 2170|      break;
 2171|     }
 2172|     case 3: {
 2173|      *p3 = r;
 2174|      *(p3 + 1) = g;
 2175|      *(p3 + 2) = b;
 2176|      *pcache++ = 0;
 2177|      break;
 2178|     }
 2179|     default: {
 2180|      do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 2181|                            ;
 2182|      return -14;
 2183|     }
 2184|     }
 2185|    } else {
 2186|     *p3 = r;
 2187|     *(p3 + 1) = g;
 2188|     *(p3 + 2) = b;
 2189|     *(p3 + 3) = 0;
 2190|    }
 2191|    p2 += 2;
 2192|    if (true == isuy)
 2193|     isuy = false;
 2194|    else
 2195|     isuy = true;
 2196|    p3 += bytesperpixel;
 2197|   }
 2198|   return 0;
 2199|  } else {
 2200|
 2201|
 2202|
 2203|
 2204|
 2205|   while (pz > p2) {
 2206|    if (pr <= (p3 + bytesperpixel))
 2207|     last = true;
 2208|    else
 2209|     last = false;
 2210|    y = *p2;
 2211|    if ((true == last) && (0x0C & mask)) {
 2212|     if (0x04 & mask) {
 2213|      if (true == isuy)
 2214|       v = margin;
 2215|      else
 2216|       u = margin;
 2217|     } else
 2218|       if (0x08 & mask)
 2219|       ;
 2220|    } else {
 2221|     if (true == isuy)
 2222|      v = *(p2 + 1);
 2223|     else
 2224|      u = *(p2 + 1);
 2225|    }
 2226|
 2227|    s32 = ay[(int)y] + rv[(int)v];
 2228|    r = (255 < s32) ? 255 : ((0 > s32) ?
 2229|        0 : (__u8)s32);
 2230|    s32 = ay[(int)y] - gu[(int)u] - gv[(int)v];
 2231|    g = (255 < s32) ? 255 : ((0 > s32) ?
 2232|        0 : (__u8)s32);
 2233|    s32 = ay[(int)y] + bu[(int)u];
 2234|    b = (255 < s32) ? 255 : ((0 > s32) ?
 2235|        0 : (__u8)s32);
 2236|
 2237|    if ((true == last) && rump) {
 2238|     pcache = &peasycap->cache[0];
 2239|     switch (bytesperpixel - rump) {
 2240|     case 1: {
 2241|      *p3 = b;
 2242|      *pcache++ = g;
 2243|      *pcache++ = r;
 2244|      *pcache++ = 0;
 2245|      break;
 2246|     }
 2247|     case 2: {
 2248|      *p3 = b;
 2249|      *(p3 + 1) = g;
 2250|      *pcache++ = r;
 2251|      *pcache++ = 0;
 2252|      break;
 2253|     }
 2254|     case 3: {
 2255|      *p3 = b;
 2256|      *(p3 + 1) = g;
 2257|      *(p3 + 2) = r;
 2258|      *pcache++ = 0;
 2259|      break;
 2260|     }
 2261|     default: {
 2262|      do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 2263|                            ;
 2264|      return -14;
 2265|     }
 2266|     }
 2267|    } else {
 2268|     *p3 = b;
 2269|     *(p3 + 1) = g;
 2270|     *(p3 + 2) = r;
 2271|     *(p3 + 3) = 0;
 2272|    }
 2273|    p2 += 2;
 2274|    if (true == isuy)
 2275|     isuy = false;
 2276|    else
 2277|     isuy = true;
 2278|    p3 += bytesperpixel;
 2279|   }
 2280|  }
 2281|  return 0;
 2282| } else {
 2283|  if (false == byteswaporder) {
 2284|
 2285|
 2286|
 2287|
 2288|
 2289|   while (pz > p2) {
 2290|    if (pr <= (p3 + bytesperpixel))
 2291|     last = true;
 2292|    else
 2293|     last = false;
 2294|    y = *p2;
 2295|    if ((true == last) && (0x0C & mask)) {
 2296|     if (0x04 & mask) {
 2297|      if (true == isuy)
 2298|       v = margin;
 2299|      else
 2300|       u = margin;
 2301|     } else
 2302|      if (0x08 & mask)
 2303|       ;
 2304|    } else {
 2305|     if (true == isuy)
 2306|      v = *(p2 + 1);
 2307|     else
 2308|      u = *(p2 + 1);
 2309|    }
 2310|
 2311|    if (true == isuy) {
 2312|
 2313|     s32 = ay[(int)y] + rv[(int)v];
 2314|     r = (255 < s32) ? 255 : ((0 > s32) ?
 2315|        0 : (__u8)s32);
 2316|     s32 = ay[(int)y] - gu[(int)u] -
 2317|        gv[(int)v];
 2318|     g = (255 < s32) ? 255 : ((0 > s32) ?
 2319|        0 : (__u8)s32);
 2320|     s32 = ay[(int)y] + bu[(int)u];
 2321|     b = (255 < s32) ? 255 : ((0 > s32) ?
 2322|        0 : (__u8)s32);
 2323|
 2324|     if ((true == last) && rump) {
 2325|      pcache = &peasycap->cache[0];
 2326|      switch (bytesperpixel - rump) {
 2327|      case 1: {
 2328|       *p3 = r;
 2329|       *pcache++ = g;
 2330|       *pcache++ = b;
 2331|       *pcache++ = 0;
 2332|       break;
 2333|      }
 2334|      case 2: {
 2335|       *p3 = r;
 2336|       *(p3 + 1) = g;
 2337|       *pcache++ = b;
 2338|       *pcache++ = 0;
 2339|       break;
 2340|      }
 2341|      case 3: {
 2342|       *p3 = r;
 2343|       *(p3 + 1) = g;
 2344|       *(p3 + 2) = b;
 2345|       *pcache++ = 0;
 2346|       break;
 2347|      }
 2348|      default: {
 2349|       do { printk("<7>" "easycap::%i%s: " "MISTAKE: " "%i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 2350|
 2351|
 2352|            ;
 2353|       return -14;
 2354|       }
 2355|      }
 2356|     } else {
 2357|      *p3 = r;
 2358|      *(p3 + 1) = g;
 2359|      *(p3 + 2) = b;
 2360|      *(p3 + 3) = 0;
 2361|      }
 2362|     isuy = false;
 2363|     p3 += bytesperpixel;
 2364|    } else
 2365|     isuy = true;
 2366|    p2 += 2;
 2367|   }
 2368|   return 0;
 2369|  } else {
 2370|
 2371|
 2372|
 2373|
 2374|
 2375|   while (pz > p2) {
 2376|    if (pr <= (p3 + bytesperpixel))
 2377|     last = true;
 2378|    else
 2379|     last = false;
 2380|    y = *p2;
 2381|    if ((true == last) && (0x0C & mask)) {
 2382|     if (0x04 & mask) {
 2383|      if (true == isuy)
 2384|       v = margin;
 2385|      else
 2386|       u = margin;
 2387|     } else
 2388|      if (0x08 & mask)
 2389|       ;
 2390|    } else {
 2391|     if (true == isuy)
 2392|      v = *(p2 + 1);
 2393|     else
 2394|      u = *(p2 + 1);
 2395|    }
 2396|
 2397|    if (true == isuy) {
 2398|     s32 = ay[(int)y] + rv[(int)v];
 2399|     r = (255 < s32) ? 255 : ((0 > s32) ?
 2400|        0 : (__u8)s32);
 2401|     s32 = ay[(int)y] - gu[(int)u] -
 2402|        gv[(int)v];
 2403|     g = (255 < s32) ? 255 : ((0 > s32) ?
 2404|        0 : (__u8)s32);
 2405|     s32 = ay[(int)y] + bu[(int)u];
 2406|     b = (255 < s32) ? 255 : ((0 > s32) ?
 2407|        0 : (__u8)s32);
 2408|
 2409|     if ((true == last) && rump) {
 2410|      pcache = &peasycap->cache[0];
 2411|      switch (bytesperpixel - rump) {
 2412|      case 1: {
 2413|       *p3 = b;
 2414|       *pcache++ = g;
 2415|       *pcache++ = r;
 2416|       *pcache++ = 0;
 2417|       break;
 2418|      }
 2419|      case 2: {
 2420|       *p3 = b;
 2421|       *(p3 + 1) = g;
 2422|       *pcache++ = r;
 2423|       *pcache++ = 0;
 2424|       break;
 2425|      }
 2426|      case 3: {
 2427|       *p3 = b;
 2428|       *(p3 + 1) = g;
 2429|       *(p3 + 2) = r;
 2430|       *pcache++ = 0;
 2431|       break;
 2432|      }
 2433|      default: {
 2434|       do { printk("<7>" "easycap::%i%s: " "MISTAKE: " "%i=rump\n", peasycap->isdongle, __func__, bytesperpixel - rump);} while (0)
 2435|
 2436|                            ;
 2437|       return -14;
 2438|      }
 2439|      }
 2440|     } else {
 2441|      *p3 = b;
 2442|      *(p3 + 1) = g;
 2443|      *(p3 + 2) = r;
 2444|      *(p3 + 3) = 0;
 2445|     }
 2446|     isuy = false;
 2447|     p3 += bytesperpixel;
 2448|    } else
 2449|     isuy = true;
 2450|     p2 += 2;
 2451|    }
 2452|    return 0;
 2453|   }
 2454|  }
 2455| break;
 2456| }
 2457|default: {
 2458| do { printk("<7>" "easycap::%i%s: " "MISTAKE: %i=bytesperpixel\n", peasycap->isdongle, __func__, bytesperpixel);} while (0);
 2459| return -14;
 2460| }
 2461|}
 2462|return 0;
 2463|}
 2464|
 2465|
 2466|
 2467|
 2468|
 2469|
 2470|int easycap_mmap(struct file *file, struct vm_area_struct *pvma)
 2471|{
 2472|
 2473|do {} while (0);
 2474|
 2475|pvma->vm_ops = &easycap_vm_ops;
 2476|pvma->vm_flags |= 0x00080000;
 2477|if (((void *)0) != file)
 2478| pvma->vm_private_data = file->private_data;
 2479|easycap_vma_open(pvma);
 2480|return 0;
 2481|}
 2482|
 2483|void
 2484|easycap_vma_open(struct vm_area_struct *pvma)
 2485|{
 2486|struct easycap *peasycap;
 2487|
 2488|peasycap = pvma->vm_private_data;
 2489|if (((void *)0) == peasycap) {
 2490| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
 2491| return;
 2492|}
 2493|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
 2494| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
 2495| return;
 2496|}
 2497|peasycap->vma_many++;
 2498|do {} while (0);
 2499|return;
 2500|}
 2501|
 2502|void
 2503|easycap_vma_close(struct vm_area_struct *pvma)
 2504|{
 2505|struct easycap *peasycap;
 2506|
 2507|peasycap = pvma->vm_private_data;
 2508|if (((void *)0) == peasycap) {
 2509| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
 2510| return;
 2511|}
 2512|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
 2513| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
 2514| return;
 2515|}
 2516|peasycap->vma_many--;
 2517|do {} while (0);
 2518|return;
 2519|}
 2520|
 2521|int
 2522|easycap_vma_fault(struct vm_area_struct *pvma, struct vm_fault *pvmf)
 2523|{
 2524|int k, m, retcode;
 2525|void *pbuf;
 2526|struct page *page;
 2527|struct easycap *peasycap;
 2528|
 2529|retcode = 0x0100;
 2530|pbuf = (void *)((void *)0);
 2531|page = (struct page *)((void *)0);
 2532|
 2533|if (((void *)0) == pvma) {
 2534| do { printk("<7>" "easycap:: %s: " "pvma is NULL\n", __func__); } while (0);
 2535| return retcode;
 2536|}
 2537|if (((void *)0) == pvmf) {
 2538| do { printk("<7>" "easycap:: %s: " "pvmf is NULL\n", __func__); } while (0);
 2539| return retcode;
 2540|}
 2541|
 2542|k = (pvmf->pgoff) / ((405 * ((1UL) << 12))/((1UL) << 12));
 2543|m = (pvmf->pgoff) % ((405 * ((1UL) << 12))/((1UL) << 12));
 2544|
 2545|if (!m)
 2546| do {} while (0);
 2547|else
 2548| do {} while (0);
 2549|
 2550|if ((0 > k) || (6 <= k)) {
 2551| do { printk("<7>" "easycap:: %s: " "ERROR: buffer index %i out of range\n", __func__, k); } while (0);
 2552| return retcode;
 2553|}
 2554|if ((0 > m) || ((405 * ((1UL) << 12))/((1UL) << 12) <= m)) {
 2555| do { printk("<7>" "easycap:: %s: " "ERROR: page number  %i out of range\n", __func__, m); } while (0);
 2556| return retcode;
 2557|}
 2558|peasycap = pvma->vm_private_data;
 2559|if (((void *)0) == peasycap) {
 2560| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
 2561| return retcode;
 2562|}
 2563|
 2564|pbuf = peasycap->frame_buffer[k][m].pgo;
 2565|if (((void *)0) == pbuf) {
 2566| do { printk("<7>" "easycap::%i%s: " "ERROR:  pbuf is NULL\n", peasycap->isdongle, __func__);} while (0);
 2567| goto finish;
 2568|}
 2569|page = (((struct page *)(0xffffea0000000000UL)) + (__phys_addr((unsigned long)(pbuf)) >> 12));
 2570|if (((void *)0) == page) {
 2571| do { printk("<7>" "easycap::%i%s: " "ERROR:  page is NULL\n", peasycap->isdongle, __func__);} while (0);
 2572| goto finish;
 2573|}
 2574|get_page(page);
 2575|
 2576|finish:
 2577|if (((void *)0) == page) {
 2578| do { printk("<7>" "easycap::%i%s: " "ERROR:  page is NULL after get_page(page)\n", peasycap->isdongle, __func__);} while (0);
 2579|} else {
 2580| pvmf->page = page;
 2581| retcode = 0;
 2582|}
 2583|return retcode;
 2584|}
 2585|void
 2586|easycap_complete(struct urb *purb)
 2587|{
 2588|struct easycap *peasycap;
 2589|struct data_buffer *pfield_buffer;
 2590|char errbuf[16];
 2591|int i, more, much, leap, rc, last;
 2592|int videofieldamount;
 2593|unsigned int override, bad;
 2594|int framestatus, framelength, frameactual, frameoffset;
 2595|__u8 *pu;
 2596|
 2597|if (((void *)0) == purb) {
 2598| do { printk("<7>" "easycap:: %s: " "ERROR: easycap_complete(): purb is NULL\n", __func__); } while (0);
 2599| return;
 2600|}
 2601|peasycap = purb->context;
 2602|if (((void *)0) == peasycap) {
 2603| do { printk("<7>" "easycap:: %s: " "ERROR: easycap_complete(): peasycap is NULL\n", __func__); } while (0);
 2604| return;
 2605|}
 2606|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
 2607| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
 2608| return;
 2609|}
 2610|if (peasycap->video_eof)
 2611| return;
 2612|for (i = 0; i < 16; i++)
 2613| if (purb->transfer_buffer == peasycap->video_isoc_buffer[i].pgo)
 2614|  break;
 2615|do {} while (0);
 2616|last = peasycap->video_isoc_sequence;
 2617|if ((((16 - 1) == last) &&
 2618|      (0 != i)) ||
 2619| (((16 - 1) != last) &&
 2620|      ((last + 1) != i))) {
 2621| do {} while (0);
 2622|}
 2623|peasycap->video_isoc_sequence = i;
 2624|
 2625|if (peasycap->video_idle) {
 2626| do {} while (0)
 2627|                                                        ;
 2628| if (peasycap->video_isoc_streaming) {
 2629|  rc = usb_submit_urb(purb, ((( gfp_t)0x20u)));
 2630|  if (0 != rc) {
 2631|   switch (rc) {
 2632|   case -12: {
 2633|    do { printk("<7>" "easycap::%i%s: " "ENOMEM\n", peasycap->isdongle, __func__);} while (0);
 2634|    break;
 2635|   }
 2636|   case -19: {
 2637|    do { printk("<7>" "easycap::%i%s: " "ENODEV\n", peasycap->isdongle, __func__);} while (0);
 2638|    break;
 2639|   }
 2640|   case -6: {
 2641|    do { printk("<7>" "easycap::%i%s: " "ENXIO\n", peasycap->isdongle, __func__);} while (0);
 2642|    break;
 2643|   }
 2644|   case -22: {
 2645|    do { printk("<7>" "easycap::%i%s: " "EINVAL\n", peasycap->isdongle, __func__);} while (0);
 2646|    break;
 2647|   }
 2648|   case -11: {
 2649|    do { printk("<7>" "easycap::%i%s: " "EAGAIN\n", peasycap->isdongle, __func__);} while (0);
 2650|    break;
 2651|   }
 2652|   case -27: {
 2653|    do { printk("<7>" "easycap::%i%s: " "EFBIG\n", peasycap->isdongle, __func__);} while (0);
 2654|    break;
 2655|   }
 2656|   case -32: {
 2657|    do { printk("<7>" "easycap::%i%s: " "EPIPE\n", peasycap->isdongle, __func__);} while (0);
 2658|    break;
 2659|   }
 2660|   case -90: {
 2661|    do { printk("<7>" "easycap::%i%s: " "EMSGSIZE\n", peasycap->isdongle, __func__);} while (0);
 2662|    break;
 2663|   }
 2664|   case -28: {
 2665|    do { printk("<7>" "easycap::%i%s: " "ENOSPC\n", peasycap->isdongle, __func__);} while (0);
 2666|    break;
 2667|   }
 2668|   default: {
 2669|    do { printk("<7>" "easycap::%i%s: " "0x%08X\n", peasycap->isdongle, __func__, rc);} while (0);
 2670|    break;
 2671|   }
 2672|   }
 2673|   if (-19 != rc)
 2674|    do { printk("<7>" "easycap::%i%s: " "ERROR: while %i=video_idle, " "usb_submit_urb() " "failed with rc:\n", peasycap->isdongle, __func__, peasycap->video_idle);} while (0)
 2675|
 2676|
 2677|                            ;
 2678|  }
 2679| }
 2680|return;
 2681|}
 2682|override = 0;
 2683|
 2684|if (4 <= peasycap->field_fill) {
 2685| do { printk("<7>" "easycap::%i%s: " "ERROR: bad peasycap->field_fill\n", peasycap->isdongle, __func__);} while (0);
 2686| return;
 2687|}
 2688|if (purb->status) {
 2689| if ((-108 == purb->status) || (-2 == purb->status)) {
 2690|  do {} while (0);
 2691|  return;
 2692| }
 2693|
 2694| (peasycap->field_buffer[peasycap->field_fill][0].kount) |= 0x8000 ;
 2695| do { printk("<7>" "easycap::%i%s: " "ERROR: bad urb status:\n", peasycap->isdongle, __func__);} while (0);
 2696| switch (purb->status) {
 2697| case -115: {
 2698|  do { printk("<7>" "easycap::%i%s: " "-EINPROGRESS\n", peasycap->isdongle, __func__);} while (0); break;
 2699| }
 2700| case -63: {
 2701|  do { printk("<7>" "easycap::%i%s: " "-ENOSR\n", peasycap->isdongle, __func__);} while (0); break;
 2702| }
 2703| case -32: {
 2704|  do { printk("<7>" "easycap::%i%s: " "-EPIPE\n", peasycap->isdongle, __func__);} while (0); break;
 2705| }
 2706| case -75: {
 2707|  do { printk("<7>" "easycap::%i%s: " "-EOVERFLOW\n", peasycap->isdongle, __func__);} while (0); break;
 2708| }
 2709| case -71: {
 2710|  do { printk("<7>" "easycap::%i%s: " "-EPROTO\n", peasycap->isdongle, __func__);} while (0); break;
 2711| }
 2712| case -84: {
 2713|  do { printk("<7>" "easycap::%i%s: " "-EILSEQ\n", peasycap->isdongle, __func__);} while (0); break;
 2714| }
 2715| case -110: {
 2716|  do { printk("<7>" "easycap::%i%s: " "-ETIMEDOUT\n", peasycap->isdongle, __func__);} while (0); break;
 2717| }
 2718| case -90: {
 2719|  do { printk("<7>" "easycap::%i%s: " "-EMSGSIZE\n", peasycap->isdongle, __func__);} while (0); break;
 2720| }
 2721| case -95: {
 2722|  do { printk("<7>" "easycap::%i%s: " "-EOPNOTSUPP\n", peasycap->isdongle, __func__);} while (0); break;
 2723| }
 2724| case -96: {
 2725|  do { printk("<7>" "easycap::%i%s: " "-EPFNOSUPPORT\n", peasycap->isdongle, __func__);} while (0); break;
 2726| }
 2727| case -97: {
 2728|  do { printk("<7>" "easycap::%i%s: " "-EAFNOSUPPORT\n", peasycap->isdongle, __func__);} while (0); break;
 2729| }
 2730| case -98: {
 2731|  do { printk("<7>" "easycap::%i%s: " "-EADDRINUSE\n", peasycap->isdongle, __func__);} while (0); break;
 2732| }
 2733| case -99: {
 2734|  do { printk("<7>" "easycap::%i%s: " "-EADDRNOTAVAIL\n", peasycap->isdongle, __func__);} while (0); break;
 2735| }
 2736| case -105: {
 2737|  do { printk("<7>" "easycap::%i%s: " "-ENOBUFS\n", peasycap->isdongle, __func__);} while (0); break;
 2738| }
 2739| case -106: {
 2740|  do { printk("<7>" "easycap::%i%s: " "-EISCONN\n", peasycap->isdongle, __func__);} while (0); break;
 2741| }
 2742| case -107: {
 2743|  do { printk("<7>" "easycap::%i%s: " "-ENOTCONN\n", peasycap->isdongle, __func__);} while (0); break;
 2744| }
 2745| case -108: {
 2746|  do { printk("<7>" "easycap::%i%s: " "-ESHUTDOWN\n", peasycap->isdongle, __func__);} while (0); break;
 2747| }
 2748| case -2: {
 2749|  do { printk("<7>" "easycap::%i%s: " "-ENOENT\n", peasycap->isdongle, __func__);} while (0); break;
 2750| }
 2751| case -104: {
 2752|  do { printk("<7>" "easycap::%i%s: " "-ECONNRESET\n", peasycap->isdongle, __func__);} while (0); break;
 2753| }
 2754| case -28: {
 2755|  do { printk("<7>" "easycap::%i%s: " "ENOSPC\n", peasycap->isdongle, __func__);} while (0); break;
 2756| }
 2757| default: {
 2758|  do { printk("<7>" "easycap::%i%s: " "unknown error code 0x%08X\n", peasycap->isdongle, __func__, purb->status);} while (0); break;
 2759| }
 2760| }
 2761|
 2762|} else {
 2763| for (i = 0; i < purb->number_of_packets; i++) {
 2764|  if (0 != purb->iso_frame_desc[i].status) {
 2765|   (peasycap->field_buffer
 2766|    [peasycap->field_fill][0].kount) |= 0x8000 ;
 2767|   switch (purb->iso_frame_desc[i].status) {
 2768|   case 0: {
 2769|    strcpy(&errbuf[0], "OK"); break;
 2770|   }
 2771|   case -2: {
 2772|    strcpy(&errbuf[0], "-ENOENT"); break;
 2773|   }
 2774|   case -115: {
 2775|    strcpy(&errbuf[0], "-EINPROGRESS"); break;
 2776|   }
 2777|   case -71: {
 2778|    strcpy(&errbuf[0], "-EPROTO"); break;
 2779|   }
 2780|   case -84: {
 2781|    strcpy(&errbuf[0], "-EILSEQ"); break;
 2782|   }
 2783|   case -62: {
 2784|    strcpy(&errbuf[0], "-ETIME"); break;
 2785|   }
 2786|   case -110: {
 2787|    strcpy(&errbuf[0], "-ETIMEDOUT"); break;
 2788|   }
 2789|   case -32: {
 2790|    strcpy(&errbuf[0], "-EPIPE"); break;
 2791|   }
 2792|   case -70: {
 2793|    strcpy(&errbuf[0], "-ECOMM"); break;
 2794|   }
 2795|   case -63: {
 2796|    strcpy(&errbuf[0], "-ENOSR"); break;
 2797|   }
 2798|   case -75: {
 2799|    strcpy(&errbuf[0], "-EOVERFLOW"); break;
 2800|   }
 2801|   case -121: {
 2802|    strcpy(&errbuf[0], "-EREMOTEIO"); break;
 2803|   }
 2804|   case -19: {
 2805|    strcpy(&errbuf[0], "-ENODEV"); break;
 2806|   }
 2807|   case -18: {
 2808|    strcpy(&errbuf[0], "-EXDEV"); break;
 2809|   }
 2810|   case -22: {
 2811|    strcpy(&errbuf[0], "-EINVAL"); break;
 2812|   }
 2813|   case -104: {
 2814|    strcpy(&errbuf[0], "-ECONNRESET"); break;
 2815|   }
 2816|   case -28: {
 2817|    do { printk("<7>" "easycap::%i%s: " "ENOSPC\n", peasycap->isdongle, __func__);} while (0); break;
 2818|   }
 2819|   case -108: {
 2820|    strcpy(&errbuf[0], "-ESHUTDOWN"); break;
 2821|   }
 2822|   default: {
 2823|    strcpy(&errbuf[0], "unknown error"); break;
 2824|   }
 2825|   }
 2826|  }
 2827|  framestatus = purb->iso_frame_desc[i].status;
 2828|  framelength = purb->iso_frame_desc[i].length;
 2829|  frameactual = purb->iso_frame_desc[i].actual_length;
 2830|  frameoffset = purb->iso_frame_desc[i].offset;
 2831|
 2832|  do {} while (0)
 2833|
 2834|
 2835|
 2836|
 2837|                                                         ;
 2838|  if (!purb->iso_frame_desc[i].status) {
 2839|   more = purb->iso_frame_desc[i].actual_length;
 2840|   pfield_buffer = &peasycap->field_buffer
 2841|      [peasycap->field_fill][peasycap->field_page];
 2842|   videofieldamount = (peasycap->field_page *
 2843|    ((1UL) << 12)) +
 2844|    (int)(pfield_buffer->pto - pfield_buffer->pgo);
 2845|  if (4 == more)
 2846|   peasycap->video_mt++;
 2847|  if (4 < more) {
 2848|   if (peasycap->video_mt) {
 2849|    do {} while (0)
 2850|                          ;
 2851|    peasycap->video_mt = 0;
 2852|   }
 2853|   if (4 <= peasycap->field_fill) {
 2854|    do { printk("<7>" "easycap::%i%s: " "ERROR: bad peasycap->field_fill\n", peasycap->isdongle, __func__);} while (0);
 2855|    return;
 2856|   }
 2857|   if ((203 * ((1UL) << 12))/((1UL) << 12) <=
 2858|       peasycap->field_page) {
 2859|    do { printk("<7>" "easycap::%i%s: " "ERROR: bad peasycap->field_page\n", peasycap->isdongle, __func__);} while (0);
 2860|    return;
 2861|   }
 2862|   pfield_buffer = &peasycap->field_buffer
 2863|    [peasycap->field_fill][peasycap->field_page];
 2864|   pu = (__u8 *)(purb->transfer_buffer +
 2865|     purb->iso_frame_desc[i].offset);
 2866|   if (0x80 & *pu)
 2867|    leap = 8;
 2868|   else
 2869|    leap = 4;
 2870|   if ((8 == more) || override) {
 2871|    if (videofieldamount >
 2872|      peasycap->videofieldamount) {
 2873|     if (2 == videofieldamount -
 2874|       peasycap->
 2875|       videofieldamount) {
 2876|      (peasycap->field_buffer
 2877|      [peasycap->field_fill]
 2878|       [0].kount) |= 0x0100;
 2879|      peasycap->video_junk += (1 +
 2880|       16);
 2881|     } else
 2882|      (peasycap->field_buffer
 2883|      [peasycap->field_fill]
 2884|       [0].kount) |= 0x4000;
 2885|     } else if (videofieldamount <
 2886|       peasycap->
 2887|       videofieldamount) {
 2888|      (peasycap->field_buffer
 2889|      [peasycap->field_fill]
 2890|       [0].kount) |= 0x2000;
 2891|     }
 2892|     bad = 0xFF00 & peasycap->field_buffer
 2893|      [peasycap->field_fill]
 2894|      [0].kount;
 2895|     if (!bad) {
 2896|      (peasycap->video_junk)--;
 2897|      if (-16 >
 2898|       peasycap->video_junk)
 2899|       peasycap->video_junk =
 2900|       -16;
 2901|      peasycap->field_read =
 2902|       (peasycap->
 2903|        field_fill)++;
 2904|      if (4 <=
 2905|        peasycap->
 2906|        field_fill)
 2907|       peasycap->
 2908|        field_fill = 0;
 2909|      peasycap->field_page = 0;
 2910|      pfield_buffer = &peasycap->
 2911|       field_buffer
 2912|       [peasycap->
 2913|       field_fill]
 2914|       [peasycap->
 2915|       field_page];
 2916|      pfield_buffer->pto =
 2917|       pfield_buffer->pgo;
 2918|      do {} while (0)
 2919|
 2920|
 2921|
 2922|
 2923|
 2924|                            ;
 2925|      do {} while (0)
 2926|
 2927|
 2928|
 2929|                        ;
 2930|      do {} while (0)
 2931|                            ;
 2932|      __wake_up(&(peasycap-> wq_video), 1, 1, ((void *)0))
 2933|
 2934|                   ;
 2935|      do_gettimeofday
 2936|       (&peasycap->timeval7);
 2937|     } else {
 2938|     peasycap->video_junk++;
 2939|     if (bad & 0x0010)
 2940|      peasycap->video_junk +=
 2941|      (1 + 16/2);
 2942|     do {} while (0)
 2943|
 2944|
 2945|
 2946|
 2947|
 2948|
 2949|
 2950|             ;
 2951|     (peasycap->field_fill)++;
 2952|
 2953|     if (4 <=
 2954|       peasycap->field_fill)
 2955|      peasycap->field_fill = 0;
 2956|     peasycap->field_page = 0;
 2957|     pfield_buffer =
 2958|      &peasycap->field_buffer
 2959|      [peasycap->field_fill]
 2960|      [peasycap->field_page];
 2961|     pfield_buffer->pto =
 2962|       pfield_buffer->pgo;
 2963|
 2964|     do {} while (0)
 2965|
 2966|
 2967|                                    ;
 2968|    }
 2969|    if (8 == more) {
 2970|     do {} while (0)
 2971|
 2972|                   ;
 2973|     if (0x40 & *pu)
 2974|      pfield_buffer->kount = 0x0000;
 2975|     else
 2976|      pfield_buffer->kount = 0x0001;
 2977|     pfield_buffer->input = 0x08 |
 2978|      (0x07 & peasycap->input);
 2979|     do {} while (0)
 2980|                                  ;
 2981|    }
 2982|   }
 2983|
 2984|
 2985|
 2986|
 2987|
 2988|   pu += leap;
 2989|   more -= leap;
 2990|
 2991|   if (4 <= peasycap->field_fill) {
 2992|    do { printk("<7>" "easycap::%i%s: " "ERROR: bad peasycap->field_fill\n", peasycap->isdongle, __func__);} while (0);
 2993|    return;
 2994|   }
 2995|   if ((203 * ((1UL) << 12))/((1UL) << 12) <=
 2996|       peasycap->field_page) {
 2997|    do { printk("<7>" "easycap::%i%s: " "ERROR: bad peasycap->field_page\n", peasycap->isdongle, __func__);} while (0);
 2998|    return;
 2999|   }
 3000|   pfield_buffer = &peasycap->field_buffer
 3001|    [peasycap->field_fill][peasycap->field_page];
 3002|   while (more) {
 3003|    pfield_buffer = &peasycap->field_buffer
 3004|      [peasycap->field_fill]
 3005|      [peasycap->field_page];
 3006|    if (((1UL) << 12) < (pfield_buffer->pto -
 3007|       pfield_buffer->pgo)) {
 3008|     do { printk("<7>" "easycap::%i%s: " "ERROR: bad pfield_buffer->pto\n", peasycap->isdongle, __func__);} while (0);
 3009|     return;
 3010|    }
 3011|    if (((1UL) << 12) == (pfield_buffer->pto -
 3012|       pfield_buffer->pgo)) {
 3013|     (peasycap->field_page)++;
 3014|     if ((203 * ((1UL) << 12))/((1UL) << 12) <=
 3015|       peasycap->field_page) {
 3016|      do {} while (0)
 3017|                      ;
 3018|      peasycap->field_page = 0;
 3019|     }
 3020|     pfield_buffer = &peasycap->
 3021|       field_buffer
 3022|       [peasycap->field_fill]
 3023|       [peasycap->field_page];
 3024|     pfield_buffer->pto =
 3025|       pfield_buffer->pgo;
 3026|     pfield_buffer->input = 0x08 |
 3027|      (0x07 & peasycap->input);
 3028|     if ((peasycap->field_buffer[peasycap->
 3029|       field_fill][0]).
 3030|        input !=
 3031|       pfield_buffer->input)
 3032|      (peasycap->field_buffer
 3033|       [peasycap->field_fill]
 3034|       [0]).kount |= 0x1000;
 3035|    }
 3036|
 3037|    much = ((1UL) << 12) - (int)(pfield_buffer->pto -
 3038|       pfield_buffer->pgo);
 3039|
 3040|    if (much > more)
 3041|     much = more;
 3042|    __st_memcpy_st__(pfield_buffer->pto, pu, much);
 3043|    pu += much;
 3044|    (pfield_buffer->pto) += much;
 3045|    more -= much;
 3046|    }
 3047|   }
 3048|  }
 3049| }
 3050|}
 3051|if (16 <= peasycap->video_junk) {
 3052| do { printk("<7>" "easycap::%i%s: " "easycap driver shutting down on condition green\n", peasycap->isdongle, __func__);} while (0);
 3053| peasycap->status = 1;
 3054| peasycap->video_eof = 1;
 3055| peasycap->video_junk = 0;
 3056| __wake_up(&peasycap->wq_video, 1, 1, ((void *)0));
 3057|
 3058|
 3059|
 3060|
 3061| return;
 3062|}
 3063|if (peasycap->video_isoc_streaming) {
 3064| rc = usb_submit_urb(purb, ((( gfp_t)0x20u)));
 3065| if (0 != rc) {
 3066|  switch (rc) {
 3067|  case -12: {
 3068|   do { printk("<7>" "easycap::%i%s: " "ENOMEM\n", peasycap->isdongle, __func__);} while (0); break;
 3069|  }
 3070|  case -19: {
 3071|   do { printk("<7>" "easycap::%i%s: " "ENODEV\n", peasycap->isdongle, __func__);} while (0); break;
 3072|  }
 3073|  case -6: {
 3074|   do { printk("<7>" "easycap::%i%s: " "ENXIO\n", peasycap->isdongle, __func__);} while (0); break;
 3075|  }
 3076|  case -22: {
 3077|   do { printk("<7>" "easycap::%i%s: " "EINVAL\n", peasycap->isdongle, __func__);} while (0); break;
 3078|  }
 3079|  case -11: {
 3080|   do { printk("<7>" "easycap::%i%s: " "EAGAIN\n", peasycap->isdongle, __func__);} while (0); break;
 3081|  }
 3082|  case -27: {
 3083|   do { printk("<7>" "easycap::%i%s: " "EFBIG\n", peasycap->isdongle, __func__);} while (0); break;
 3084|  }
 3085|  case -32: {
 3086|   do { printk("<7>" "easycap::%i%s: " "EPIPE\n", peasycap->isdongle, __func__);} while (0); break;
 3087|  }
 3088|  case -90: {
 3089|   do { printk("<7>" "easycap::%i%s: " "EMSGSIZE\n", peasycap->isdongle, __func__);} while (0); break;
 3090|  }
 3091|  case -28: {
 3092|   do { printk("<7>" "easycap::%i%s: " "ENOSPC\n", peasycap->isdongle, __func__);} while (0); break;
 3093|  }
 3094|  default: {
 3095|   do { printk("<7>" "easycap::%i%s: " "0x%08X\n", peasycap->isdongle, __func__, rc);} while (0); break;
 3096|  }
 3097|  }
 3098|  if (-19 != rc)
 3099|   do { printk("<7>" "easycap::%i%s: " "ERROR: while %i=video_idle, " "usb_submit_urb() " "failed with rc:\n", peasycap->isdongle, __func__, peasycap->video_idle);} while (0)
 3100|
 3101|
 3102|                           ;
 3103| }
 3104|}
 3105|return;
 3106|}
 3107|int
 3108|easycap_usb_probe(struct usb_interface *pusb_interface,
 3109|      const struct usb_device_id *id)
 3110|{
 3111|struct usb_device *pusb_device, *pusb_device1;
 3112|struct usb_host_interface *pusb_host_interface;
 3113|struct usb_endpoint_descriptor *pepd;
 3114|struct usb_interface_descriptor *pusb_interface_descriptor;
 3115|struct usb_interface_assoc_descriptor *pusb_interface_assoc_descriptor;
 3116|struct urb *purb;
 3117|struct easycap *peasycap;
 3118|struct data_urb *pdata_urb;
 3119|size_t wMaxPacketSize;
 3120|int ISOCwMaxPacketSize;
 3121|int BULKwMaxPacketSize;
 3122|int INTwMaxPacketSize;
 3123|int CTRLwMaxPacketSize;
 3124|__u8 bEndpointAddress;
 3125|__u8 ISOCbEndpointAddress;
 3126|__u8 INTbEndpointAddress;
 3127|int isin, i, j, k, m, rc;
 3128|__u8 bInterfaceNumber;
 3129|__u8 bInterfaceClass;
 3130|__u8 bInterfaceSubClass;
 3131|void *pbuf;
 3132|int okalt[8], isokalt;
 3133|int okepn[8];
 3134|int okmps[8];
 3135|int maxpacketsize;
 3136|__u16 mask;
 3137|__s32 value;
 3138|struct easycap_format *peasycap_format;
 3139|
 3140|do {} while (0);
 3141|
 3142|if (!dongle_done) {
 3143| dongle_done = 1;
 3144| for (k = 0; k < 8; k++) {
 3145|  easycap_dongle[k].peasycap = (struct easycap *)((void *)0);
 3146|  do { static struct lock_class_key __key; __mutex_init((&easycap_dongle[k].mutex_video), "&easycap_dongle[k].mutex_video", &__key); } while (0);
 3147|  do { static struct lock_class_key __key; __mutex_init((&easycap_dongle[k].mutex_audio), "&easycap_dongle[k].mutex_audio", &__key); } while (0);
 3148| }
 3149|}
 3150|
 3151|peasycap = (struct easycap *)((void *)0);
 3152|
 3153|if ((struct usb_interface *)((void *)0) == pusb_interface) {
 3154| do { printk("<7>" "easycap:: %s: " "ERROR: pusb_interface is NULL\n", __func__); } while (0);
 3155| return -14;
 3156|}
 3157|
 3158|
 3159|
 3160|
 3161|
 3162|pusb_device1 = ({ const typeof( ((struct usb_device *)0)->dev ) *__mptr = (pusb_interface->dev.parent); (struct usb_device *)( (char *)__mptr - 1 );})
 3163|                             ;
 3164|if ((struct usb_device *)((void *)0) == pusb_device1) {
 3165| do { printk("<7>" "easycap:: %s: " "ERROR: pusb_device1 is NULL\n", __func__); } while (0);
 3166| return -14;
 3167|}
 3168|pusb_device = usb_get_dev(pusb_device1);
 3169|if ((struct usb_device *)((void *)0) == pusb_device) {
 3170| do { printk("<7>" "easycap:: %s: " "ERROR: pusb_device is NULL\n", __func__); } while (0);
 3171| return -14;
 3172|}
 3173|if ((unsigned long int)pusb_device1 != (unsigned long int)pusb_device) {
 3174| do {} while (0);
 3175| return -14;
 3176|}
 3177|
 3178|do {} while (0);
 3179|
 3180|
 3181|pusb_host_interface = pusb_interface->cur_altsetting;
 3182|if (((void *)0) == pusb_host_interface) {
 3183| do { printk("<7>" "easycap:: %s: " "ERROR: pusb_host_interface is NULL\n", __func__); } while (0);
 3184| return -14;
 3185|}
 3186|pusb_interface_descriptor = &(pusb_host_interface->desc);
 3187|if (((void *)0) == pusb_interface_descriptor) {
 3188| do { printk("<7>" "easycap:: %s: " "ERROR: pusb_interface_descriptor is NULL\n", __func__); } while (0);
 3189| return -14;
 3190|}
 3191|
 3192|
 3193|
 3194|
 3195|
 3196|bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber;
 3197|bInterfaceClass = pusb_interface_descriptor->bInterfaceClass;
 3198|bInterfaceSubClass = pusb_interface_descriptor->bInterfaceSubClass;
 3199|
 3200|do {} while (0)
 3201|                                                    ;
 3202|do {} while (0)
 3203|
 3204|
 3205|                                  ;
 3206|switch (bInterfaceClass) {
 3207|case 1: {
 3208| do {} while (0)
 3209|                                      ; break;
 3210| }
 3211|case 0x0e: {
 3212| do {} while (0)
 3213|                                      ; break;
 3214| }
 3215|case 0xff: {
 3216| do {} while (0)
 3217|                                      ; break;
 3218| }
 3219|default:
 3220| break;
 3221|}
 3222|switch (bInterfaceSubClass) {
 3223|case 0x01: {
 3224| do {} while (0)
 3225|                                        ; break;
 3226|}
 3227|case 0x02: {
 3228| do {} while (0)
 3229|                                        ; break;
 3230|}
 3231|case 0x03: {
 3232| do {} while (0)
 3233|                                        ; break;
 3234|}
 3235|default:
 3236| break;
 3237|}
 3238|
 3239|pusb_interface_assoc_descriptor = pusb_interface->intf_assoc;
 3240|if (((void *)0) != pusb_interface_assoc_descriptor) {
 3241| do {} while (0)
 3242|
 3243|
 3244|                                                    ;
 3245|} else {
 3246|do {} while (0)
 3247|                        ;
 3248|}
 3249|if (0 == bInterfaceNumber) {
 3250| peasycap = kzalloc(sizeof(struct easycap), __st_GFP_KERNEL_st__);
 3251| if (((void *)0) == peasycap) {
 3252|  do { printk("<7>" "easycap:: %s: " "ERROR: Could not allocate peasycap\n", __func__); } while (0);
 3253|  return -12;
 3254| }
 3255| do { printk("<7>" "easycap::%i%s: " "allocated 0x%08lX=peasycap\n", peasycap->isdongle, __func__, (unsigned long int) peasycap);} while (0);
 3256|
 3257|
 3258| do { printk("<7>" "easycap::%i%s: " "where     0x%08lX=&peasycap->video_device\n", peasycap->isdongle, __func__, (unsigned long int) &peasycap->video_device);} while (0)
 3259|                                                ;
 3260|
 3261| do { printk("<7>" "easycap::%i%s: " "and       0x%08lX=&peasycap->v4l2_device\n", peasycap->isdongle, __func__, (unsigned long int) &peasycap->v4l2_device);} while (0)
 3262|                                               ;
 3263| strcpy(&peasycap->telltale[0], "expectedstring");
 3264| kref_init(&peasycap->kref);
 3265| do {} while (0)
 3266|
 3267|                                                     ;
 3268|
 3269| do { static struct lock_class_key __key; __init_waitqueue_head((&peasycap->wq_video), &__key); } while (0);
 3270| do { static struct lock_class_key __key; __init_waitqueue_head((&peasycap->wq_audio), &__key); } while (0);
 3271|
 3272| for (dongle_this = 0; dongle_this < 8; dongle_this++) {
 3273|  if (((void *)0) == easycap_dongle[dongle_this].peasycap) {
 3274|   if (0 == mutex_is_locked(&easycap_dongle
 3275|      [dongle_this].mutex_video)) {
 3276|    if (0 == mutex_is_locked(&easycap_dongle
 3277|      [dongle_this].mutex_audio)) {
 3278|     easycap_dongle
 3279|      [dongle_this].peasycap =
 3280|        peasycap;
 3281|     do {} while (0)
 3282|
 3283|                                    ;
 3284|     break;
 3285|    }
 3286|   }
 3287|  }
 3288| }
 3289| if (8 <= dongle_this) {
 3290|  do { printk("<7>" "easycap::%i%s: " "ERROR: too many dongles\n", peasycap->isdongle, __func__);} while (0);
 3291|  return -12;
 3292| }
 3293|
 3294| peasycap->allocation_video_struct = sizeof(struct easycap);
 3295| peasycap->allocation_video_page = 0;
 3296| peasycap->allocation_video_urb = 0;
 3297| peasycap->allocation_audio_struct = 0;
 3298| peasycap->allocation_audio_page = 0;
 3299| peasycap->allocation_audio_urb = 0;
 3300|
 3301|
 3302|
 3303|
 3304|
 3305|
 3306| peasycap->pusb_device = pusb_device;
 3307| peasycap->pusb_interface = pusb_interface;
 3308|
 3309| peasycap->ilk = 0;
 3310| peasycap->microphone = false;
 3311|
 3312| peasycap->video_interface = -1;
 3313| peasycap->video_altsetting_on = -1;
 3314| peasycap->video_altsetting_off = -1;
 3315| peasycap->video_endpointnumber = -1;
 3316| peasycap->video_isoc_maxframesize = -1;
 3317| peasycap->video_isoc_buffer_size = -1;
 3318|
 3319| peasycap->audio_interface = -1;
 3320| peasycap->audio_altsetting_on = -1;
 3321| peasycap->audio_altsetting_off = -1;
 3322| peasycap->audio_endpointnumber = -1;
 3323| peasycap->audio_isoc_maxframesize = -1;
 3324| peasycap->audio_isoc_buffer_size = -1;
 3325|
 3326| peasycap->frame_buffer_many = 6;
 3327|
 3328| for (k = 0; k < 6; k++)
 3329|  peasycap->lost[k] = 0;
 3330| peasycap->skip = 0;
 3331| peasycap->skipped = 0;
 3332| peasycap->offerfields = 0;
 3333|
 3334|
 3335|
 3336|
 3337|
 3338| rc = fillin_formats();
 3339| if (0 > rc) {
 3340|  do { printk("<7>" "easycap::%i%s: " "ERROR: fillin_formats() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
 3341|  return -14;
 3342| }
 3343| do {} while (0);
 3344|
 3345|
 3346|
 3347|
 3348|
 3349| for (k = 0; k < 6; k++) {
 3350|  peasycap->inputset[k].input_ok = 0;
 3351|  peasycap->inputset[k].standard_offset_ok = 0;
 3352|  peasycap->inputset[k].format_offset_ok = 0;
 3353|  peasycap->inputset[k].brightness_ok = 0;
 3354|  peasycap->inputset[k].contrast_ok = 0;
 3355|  peasycap->inputset[k].saturation_ok = 0;
 3356|  peasycap->inputset[k].hue_ok = 0;
 3357| }
 3358| if (true == peasycap->ntsc) {
 3359|  i = 0;
 3360|  m = 0;
 3361|  mask = 0;
 3362|  while (0xFFFF != easycap_standard[i].mask) {
 3363|   if (1 == easycap_standard[i].
 3364|       v4l2_standard.index) {
 3365|    m++;
 3366|    for (k = 0; k < 6; k++) {
 3367|     peasycap->inputset[k].
 3368|       standard_offset = i;
 3369|    }
 3370|   mask = easycap_standard[i].mask;
 3371|   }
 3372|   i++;
 3373|  }
 3374| } else {
 3375|  i = 0;
 3376|  m = 0;
 3377|  mask = 0;
 3378|  while (0xFFFF != easycap_standard[i].mask) {
 3379|   if (0 == easycap_standard[i].
 3380|       v4l2_standard.index) {
 3381|    m++;
 3382|    for (k = 0; k < 6; k++) {
 3383|     peasycap->inputset[k].
 3384|       standard_offset = i;
 3385|    }
 3386|   mask = easycap_standard[i].mask;
 3387|   }
 3388|   i++;
 3389|  }
 3390| }
 3391|
 3392| if (1 != m) {
 3393|  do { printk("<7>" "easycap::%i%s: " "MISTAKE: easycap.inputset[].standard_offset " "unpopulated, %i=m\n", peasycap->isdongle, __func__, m);} while (0)
 3394|                               ;
 3395|  return -2;
 3396| }
 3397|
 3398| peasycap_format = &easycap_format[0];
 3399| i = 0;
 3400| m = 0;
 3401| while (0 != peasycap_format->v4l2_format.fmt.pix.width) {
 3402|  if (((peasycap_format->mask & 0x0F) == (mask & 0x0F)) &&
 3403|    (peasycap_format->
 3404|     v4l2_format.fmt.pix.field ==
 3405|       V4L2_FIELD_NONE) &&
 3406|    (peasycap_format->
 3407|     v4l2_format.fmt.pix.pixelformat ==
 3408|       ((__u32)('U') | ((__u32)('Y') << 8) | ((__u32)('V') << 16) | ((__u32)('Y') << 24))) &&
 3409|    (peasycap_format->
 3410|     v4l2_format.fmt.pix.width ==
 3411|       640) &&
 3412|    (peasycap_format->
 3413|     v4l2_format.fmt.pix.height == 480)) {
 3414|   m++;
 3415|   for (k = 0; k < 6; k++)
 3416|    peasycap->inputset[k].format_offset = i;
 3417|   break;
 3418|  }
 3419| peasycap_format++;
 3420| i++;
 3421| }
 3422| if (1 != m) {
 3423|  do { printk("<7>" "easycap::%i%s: " "MISTAKE: easycap.inputset[].format_offset unpopulated\n", peasycap->isdongle, __func__);} while (0);
 3424| return -2;
 3425| }
 3426|
 3427| i = 0;
 3428| m = 0;
 3429| while (0xFFFFFFFF != easycap_control[i].id) {
 3430|  value = easycap_control[i].default_value;
 3431|  if (((0x00980000 | 0x900)+0) == easycap_control[i].id) {
 3432|   m++;
 3433|   for (k = 0; k < 6; k++)
 3434|    peasycap->inputset[k].brightness = value;
 3435|  } else if (((0x00980000 | 0x900)+1) == easycap_control[i].id) {
 3436|   m++;
 3437|   for (k = 0; k < 6; k++)
 3438|    peasycap->inputset[k].contrast = value;
 3439|  } else if (((0x00980000 | 0x900)+2) == easycap_control[i].id) {
 3440|   m++;
 3441|   for (k = 0; k < 6; k++)
 3442|    peasycap->inputset[k].saturation = value;
 3443|  } else if (((0x00980000 | 0x900)+3) == easycap_control[i].id) {
 3444|   m++;
 3445|   for (k = 0; k < 6; k++)
 3446|    peasycap->inputset[k].hue = value;
 3447|  }
 3448|  i++;
 3449| }
 3450| if (4 != m) {
 3451|  do { printk("<7>" "easycap::%i%s: " "MISTAKE: easycap.inputset[].brightness,... " "underpopulated\n", peasycap->isdongle, __func__);} while (0)
 3452|                         ;
 3453|  return -2;
 3454| }
 3455| for (k = 0; k < 6; k++)
 3456|  peasycap->inputset[k].input = k;
 3457| do {} while (0);
 3458| do {} while (0);
 3459|} else {
 3460| if ((0 > dongle_this) || (8 <= dongle_this)) {
 3461|  do { printk("<7>" "easycap:: %s: " "ERROR: bad dongle count\n", __func__); } while (0);
 3462|  return -14;
 3463| }
 3464| peasycap = easycap_dongle[dongle_this].peasycap;
 3465| do {} while (0)
 3466|                                    ;
 3467|
 3468| if ((struct easycap *)((void *)0) == peasycap) {
 3469|  do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL when probing interface %i\n", __func__, bInterfaceNumber); } while (0)
 3470|                        ;
 3471|  return -14;
 3472| }
 3473|}
 3474|
 3475|if ((0x0e == bInterfaceClass) ||
 3476|  (0xff == bInterfaceClass)) {
 3477| if (-1 == peasycap->video_interface) {
 3478|  peasycap->video_interface = bInterfaceNumber;
 3479|  do {} while (0)
 3480|                                ;
 3481| } else {
 3482|  if (peasycap->video_interface != bInterfaceNumber) {
 3483|   do { printk("<7>" "easycap::%i%s: " "ERROR: attempting to reset " "peasycap->video_interface\n", peasycap->isdongle, __func__);} while (0)
 3484|                                   ;
 3485|   do { printk("<7>" "easycap::%i%s: " "...... continuing with " "%i=peasycap->video_interface\n", peasycap->isdongle, __func__, peasycap->video_interface);} while (0)
 3486|
 3487|                               ;
 3488|  }
 3489| }
 3490|} else if ((1 == bInterfaceClass) &&
 3491|      (0x02 == bInterfaceSubClass)) {
 3492| if (-1 == peasycap->audio_interface) {
 3493|  peasycap->audio_interface = bInterfaceNumber;
 3494|  do {} while (0)
 3495|                                 ;
 3496| } else {
 3497|  if (peasycap->audio_interface != bInterfaceNumber) {
 3498|   do { printk("<7>" "easycap::%i%s: " "ERROR: attempting to reset " "peasycap->audio_interface\n", peasycap->isdongle, __func__);} while (0)
 3499|                                   ;
 3500|   do { printk("<7>" "easycap::%i%s: " "...... continuing with " "%i=peasycap->audio_interface\n", peasycap->isdongle, __func__, peasycap->audio_interface);} while (0)
 3501|
 3502|                               ;
 3503|  }
 3504| }
 3505|}
 3506|
 3507|
 3508|
 3509|
 3510|
 3511|
 3512|isokalt = 0;
 3513|
 3514|for (i = 0; i < pusb_interface->num_altsetting; i++) {
 3515| pusb_host_interface = &(pusb_interface->altsetting[i]);
 3516| if ((struct usb_host_interface *)((void *)0) == pusb_host_interface) {
 3517|  do { printk("<7>" "easycap::%i%s: " "ERROR: pusb_host_interface is NULL\n", peasycap->isdongle, __func__);} while (0);
 3518|  return -14;
 3519| }
 3520| pusb_interface_descriptor = &(pusb_host_interface->desc);
 3521| if ((struct usb_interface_descriptor *)((void *)0) ==
 3522|      pusb_interface_descriptor) {
 3523|  do { printk("<7>" "easycap::%i%s: " "ERROR: pusb_interface_descriptor is NULL\n", peasycap->isdongle, __func__);} while (0);
 3524|  return -14;
 3525| }
 3526|
 3527| do {} while (0)
 3528|                                                                 ;
 3529| do {} while (0)
 3530|                                                                  ;
 3531| do {} while (0)
 3532|                                                                   ;
 3533| do {} while (0)
 3534|                                                               ;
 3535| do {} while (0)
 3536|                                                                 ;
 3537| do {} while (0)
 3538|                                                                    ;
 3539| do {} while (0)
 3540|                                                                    ;
 3541| do {} while (0)
 3542|                                                            ;
 3543|
 3544| ISOCwMaxPacketSize = -1;
 3545| BULKwMaxPacketSize = -1;
 3546| INTwMaxPacketSize = -1;
 3547| CTRLwMaxPacketSize = -1;
 3548| ISOCbEndpointAddress = 0;
 3549| INTbEndpointAddress = 0;
 3550|
 3551| if (0 == pusb_interface_descriptor->bNumEndpoints)
 3552|    do {} while (0)
 3553|                           ;
 3554|
 3555| for (j = 0; j < pusb_interface_descriptor->bNumEndpoints; j++) {
 3556|  pepd = &(pusb_host_interface->endpoint[j].desc);
 3557|  if ((struct usb_endpoint_descriptor *)((void *)0) == pepd) {
 3558|   do { printk("<7>" "easycap::%i%s: " "ERROR:  pepd is NULL.\n", peasycap->isdongle, __func__);} while (0);
 3559|   do { printk("<7>" "easycap::%i%s: " "...... skipping\n", peasycap->isdongle, __func__);} while (0);
 3560|   continue;
 3561|  }
 3562|  wMaxPacketSize = (( __u16)(__le16)(pepd->wMaxPacketSize));
 3563|  bEndpointAddress = pepd->bEndpointAddress;
 3564|
 3565|  do {} while (0)
 3566|
 3567|                           ;
 3568|  do {} while (0)
 3569|
 3570|                       ;
 3571|  do {} while (0)
 3572|
 3573|                         ;
 3574|  do {} while (0)
 3575|
 3576|                    ;
 3577|
 3578|  if (pepd->bEndpointAddress & 0x80) {
 3579|   do {} while (0)
 3580|                             ;
 3581|   isin = 1;
 3582|  } else {
 3583|   do {} while (0)
 3584|                             ;
 3585|   do { printk("<7>" "easycap::%i%s: " "ERROR: OUT endpoint unexpected\n", peasycap->isdongle, __func__);} while (0);
 3586|   do { printk("<7>" "easycap::%i%s: " "...... continuing\n", peasycap->isdongle, __func__);} while (0);
 3587|   isin = 0;
 3588|  }
 3589|  if ((pepd->bmAttributes &
 3590|    0x03) ==
 3591|    1) {
 3592|   do {} while (0)
 3593|                             ;
 3594|   if (isin) {
 3595|    switch (bInterfaceClass) {
 3596|    case 0x0e:
 3597|    case 0xff: {
 3598|     if (!peasycap) {
 3599|      do { printk("<7>" "easycap::%i%s: " "MISTAKE: " "peasycap is NULL\n", peasycap->isdongle, __func__);} while (0)
 3600|                            ;
 3601|      return -14;
 3602|     }
 3603|     if (pepd->wMaxPacketSize) {
 3604|      if (8 > isokalt) {
 3605|       okalt[isokalt] = i;
 3606|       do {} while (0)
 3607|
 3608|
 3609|               ;
 3610|       okepn[isokalt] =
 3611|       pepd->
 3612|       bEndpointAddress &
 3613|       0x0F;
 3614|       do {} while (0)
 3615|
 3616|
 3617|               ;
 3618|       okmps[isokalt] =
 3619|       (( __u16)(__le16)(pepd-> wMaxPacketSize))
 3620|                      ;
 3621|       do {} while (0)
 3622|
 3623|
 3624|               ;
 3625|       isokalt++;
 3626|      }
 3627|     } else {
 3628|      if (-1 == peasycap->
 3629|       video_altsetting_off) {
 3630|       peasycap->
 3631|       video_altsetting_off =
 3632|          i;
 3633|       do {} while (0)
 3634|
 3635|
 3636|
 3637|                            ;
 3638|      } else {
 3639|       do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap" "->video_altsetting_" "off already set\n", peasycap->isdongle, __func__);} while (0)
 3640|
 3641|                           ;
 3642|       do { printk("<7>" "easycap::%i%s: " "...... " "continuing with " "%i=peasycap->video_" "altsetting_off\n", peasycap->isdongle, __func__, peasycap-> video_altsetting_off);} while (0)
 3643|
 3644|
 3645|
 3646|
 3647|                            ;
 3648|      }
 3649|     }
 3650|     break;
 3651|    }
 3652|    case 1: {
 3653|     if (0x02 != bInterfaceSubClass)
 3654|      break;
 3655|     if (!peasycap) {
 3656|      do { printk("<7>" "easycap::%i%s: " "MISTAKE: " "peasycap is NULL\n", peasycap->isdongle, __func__);} while (0)
 3657|                           ;
 3658|      return -14;
 3659|     }
 3660|     if (pepd->wMaxPacketSize) {
 3661|      if (8 > isokalt) {
 3662|       okalt[isokalt] = i ;
 3663|       do {} while (0)
 3664|
 3665|
 3666|               ;
 3667|       okepn[isokalt] =
 3668|       pepd->
 3669|       bEndpointAddress &
 3670|       0x0F;
 3671|       do {} while (0)
 3672|
 3673|
 3674|               ;
 3675|       okmps[isokalt] =
 3676|       (( __u16)(__le16)(pepd-> wMaxPacketSize))
 3677|                      ;
 3678|       do {} while (0)
 3679|
 3680|
 3681|               ;
 3682|       isokalt++;
 3683|      }
 3684|     } else {
 3685|      if (-1 == peasycap->
 3686|       audio_altsetting_off) {
 3687|       peasycap->
 3688|       audio_altsetting_off =
 3689|          i;
 3690|       do {} while (0)
 3691|
 3692|
 3693|
 3694|                            ;
 3695|      } else {
 3696|       do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap" "->audio_altsetting_" "off already set\n", peasycap->isdongle, __func__);} while (0)
 3697|
 3698|                           ;
 3699|       do { printk("<7>" "easycap::%i%s: " "...... " "continuing with " "%i=peasycap->							audio_altsetting_" "off\n", peasycap->isdongle, __func__, peasycap-> audio_altsetting_off);} while (0)
 3700|
 3701|
 3702|
 3703|
 3704|
 3705|                            ;
 3706|      }
 3707|     }
 3708|    break;
 3709|    }
 3710|    default:
 3711|     break;
 3712|    }
 3713|   }
 3714|  } else if ((pepd->bmAttributes &
 3715|      0x03) ==
 3716|      2) {
 3717|   do {} while (0)
 3718|                             ;
 3719|  } else if ((pepd->bmAttributes &
 3720|      0x03) ==
 3721|      3) {
 3722|   do {} while (0)
 3723|                             ;
 3724|  } else {
 3725|   do {} while (0)
 3726|                             ;
 3727|  }
 3728|  if (0 == pepd->wMaxPacketSize) {
 3729|   do {} while (0)
 3730|
 3731|                             ;
 3732|  }
 3733| }
 3734|}
 3735|
 3736|
 3737|
 3738|
 3739|
 3740|do {} while (0)
 3741|                                                ;
 3742|switch (bInterfaceNumber) {
 3743|
 3744|
 3745|
 3746|
 3747|
 3748|case 0: {
 3749| if (!peasycap) {
 3750|  do { printk("<7>" "easycap::%i%s: " "MISTAKE: peasycap is NULL\n", peasycap->isdongle, __func__);} while (0);
 3751|  return -14;
 3752| }
 3753| if (!isokalt) {
 3754|  do { printk("<7>" "easycap::%i%s: " "ERROR:  no viable video_altsetting_on\n", peasycap->isdongle, __func__);} while (0);
 3755|  return -2;
 3756| } else {
 3757|  peasycap->video_altsetting_on = okalt[isokalt - 1];
 3758|  do {} while (0)
 3759|                                   ;
 3760| }
 3761|
 3762|
 3763|
 3764|
 3765|
 3766| peasycap->video_endpointnumber = okepn[isokalt - 1];
 3767| do {} while (0);
 3768| maxpacketsize = okmps[isokalt - 1];
 3769| if (3072 > maxpacketsize) {
 3770|  peasycap->video_isoc_maxframesize = maxpacketsize;
 3771| } else {
 3772|  peasycap->video_isoc_maxframesize =
 3773|      3072;
 3774| }
 3775| do {} while (0)
 3776|                                      ;
 3777| if (0 >= peasycap->video_isoc_maxframesize) {
 3778|  do { printk("<7>" "easycap::%i%s: " "ERROR:  bad video_isoc_maxframesize\n", peasycap->isdongle, __func__);} while (0);
 3779|  do { printk("<7>" "easycap::%i%s: " "        possibly because port is USB 1.1\n", peasycap->isdongle, __func__);} while (0);
 3780|  return -2;
 3781| }
 3782| peasycap->video_isoc_framesperdesc = ((unsigned int) 1 << 3);
 3783| do {} while (0)
 3784|                                       ;
 3785| if (0 >= peasycap->video_isoc_framesperdesc) {
 3786|  do { printk("<7>" "easycap::%i%s: " "ERROR:  bad video_isoc_framesperdesc\n", peasycap->isdongle, __func__);} while (0);
 3787|  return -2;
 3788| }
 3789| peasycap->video_isoc_buffer_size =
 3790|    peasycap->video_isoc_maxframesize *
 3791|    peasycap->video_isoc_framesperdesc;
 3792| do {} while (0)
 3793|                                     ;
 3794| if ((((1UL) << 12) << 3) <
 3795|    peasycap->video_isoc_buffer_size) {
 3796|  do { printk("<7>" "easycap::%i%s: " "MISTAKE: peasycap->video_isoc_buffer_size too big\n", peasycap->isdongle, __func__);} while (0);
 3797|  return -14;
 3798| }
 3799|
 3800| if (-1 == peasycap->video_interface) {
 3801|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  video_interface is unset\n", peasycap->isdongle, __func__);} while (0);
 3802|  return -14;
 3803| }
 3804| if (-1 == peasycap->video_altsetting_on) {
 3805|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  video_altsetting_on is unset\n", peasycap->isdongle, __func__);} while (0);
 3806|  return -14;
 3807| }
 3808| if (-1 == peasycap->video_altsetting_off) {
 3809|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  video_interface_off is unset\n", peasycap->isdongle, __func__);} while (0);
 3810|  return -14;
 3811| }
 3812| if (-1 == peasycap->video_endpointnumber) {
 3813|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  video_endpointnumber is unset\n", peasycap->isdongle, __func__);} while (0);
 3814|  return -14;
 3815| }
 3816| if (-1 == peasycap->video_isoc_maxframesize) {
 3817|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  video_isoc_maxframesize is unset\n", peasycap->isdongle, __func__);} while (0);
 3818|  return -14;
 3819| }
 3820| if (-1 == peasycap->video_isoc_buffer_size) {
 3821|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  video_isoc_buffer_size is unset\n", peasycap->isdongle, __func__);} while (0);
 3822|  return -14;
 3823| }
 3824|
 3825|
 3826|
 3827|
 3828|
 3829| INIT_LIST_HEAD(&(peasycap->urb_video_head));
 3830| peasycap->purb_video_head = &(peasycap->urb_video_head);
 3831|
 3832| do {} while (0)
 3833|                                                  ;
 3834| do {} while (0)
 3835|                                  ;
 3836|
 3837| for (k = 0; k < 6; k++) {
 3838|  for (m = 0; m < (405 * ((1UL) << 12))/((1UL) << 12); m++) {
 3839|   if ((void *)((void *)0) != peasycap->frame_buffer[k][m].pgo)
 3840|    do { printk("<7>" "easycap::%i%s: " "attempting to reallocate frame " " buffers\n", peasycap->isdongle, __func__);} while (0)
 3841|                     ;
 3842|   else {
 3843|    pbuf = (void *)__get_free_pages((__st_GFP_KERNEL_st__), 0);
 3844|    if ((void *)((void *)0) == pbuf) {
 3845|     do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate frame " "buffer %i page %i\n", peasycap->isdongle, __func__, k, m);} while (0)
 3846|                                  ;
 3847|     return -12;
 3848|    } else
 3849|     peasycap->allocation_video_page += 1;
 3850|    peasycap->frame_buffer[k][m].pgo = pbuf;
 3851|   }
 3852|   peasycap->frame_buffer[k][m].pto =
 3853|     peasycap->frame_buffer[k][m].pgo;
 3854|  }
 3855| }
 3856|
 3857| peasycap->frame_fill = 0;
 3858| peasycap->frame_read = 0;
 3859| do {} while (0)
 3860|          ;
 3861|
 3862| do {} while (0)
 3863|                                                  ;
 3864| do {} while (0)
 3865|                                 ;
 3866|
 3867| for (k = 0; k < 4; k++) {
 3868|  for (m = 0; m < (203 * ((1UL) << 12))/((1UL) << 12); m++) {
 3869|   if ((void *)((void *)0) != peasycap->field_buffer[k][m].pgo) {
 3870|    do { printk("<7>" "easycap::%i%s: " "ERROR: attempting to reallocate " "field buffers\n", peasycap->isdongle, __func__);} while (0)
 3871|                         ;
 3872|   } else {
 3873|    pbuf = (void *) __get_free_pages((__st_GFP_KERNEL_st__), 0);
 3874|    if ((void *)((void *)0) == pbuf) {
 3875|     do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate field" " buffer %i page %i\n", peasycap->isdongle, __func__, k, m);} while (0)
 3876|                                   ;
 3877|     return -12;
 3878|     }
 3879|    else
 3880|     peasycap->allocation_video_page += 1;
 3881|    peasycap->field_buffer[k][m].pgo = pbuf;
 3882|    }
 3883|   peasycap->field_buffer[k][m].pto =
 3884|     peasycap->field_buffer[k][m].pgo;
 3885|  }
 3886|  peasycap->field_buffer[k][0].kount = 0x0200;
 3887| }
 3888| peasycap->field_fill = 0;
 3889| peasycap->field_page = 0;
 3890| peasycap->field_read = 0;
 3891| do {} while (0)
 3892|          ;
 3893|
 3894| do {} while (0)
 3895|
 3896|                                      ;
 3897| do {} while (0);
 3898|
 3899| for (k = 0; k < 16; k++) {
 3900|  pbuf = (void *)__get_free_pages(__st_GFP_KERNEL_st__, 3);
 3901|  if (((void *)0) == pbuf) {
 3902|   do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate isoc video buffer " "%i\n", peasycap->isdongle, __func__, k);} while (0)
 3903|                  ;
 3904|   return -12;
 3905|  } else
 3906|   peasycap->allocation_video_page +=
 3907|    ((unsigned int)(0x01 << 3));
 3908|
 3909|  peasycap->video_isoc_buffer[k].pgo = pbuf;
 3910|  peasycap->video_isoc_buffer[k].pto = pbuf +
 3911|     peasycap->video_isoc_buffer_size;
 3912|  peasycap->video_isoc_buffer[k].kount = k;
 3913| }
 3914| do {} while (0)
 3915|                                    ;
 3916|
 3917|
 3918|
 3919|
 3920|
 3921| do {} while (0);
 3922| do {} while (0)
 3923|                                        ;
 3924| do {} while (0)
 3925|                                       ;
 3926| do {} while (0)
 3927|                                      ;
 3928|
 3929| for (k = 0; k < 16; k++) {
 3930|  purb = usb_alloc_urb(peasycap->video_isoc_framesperdesc,
 3931|        __st_GFP_KERNEL_st__);
 3932|  if (((void *)0) == purb) {
 3933|   do { printk("<7>" "easycap::%i%s: " "ERROR: usb_alloc_urb returned NULL for buffer " "%i\n", peasycap->isdongle, __func__, k);} while (0)
 3934|                  ;
 3935|   return -12;
 3936|  } else
 3937|   peasycap->allocation_video_urb += 1;
 3938|
 3939|  pdata_urb = kzalloc(sizeof(struct data_urb), __st_GFP_KERNEL_st__);
 3940|  if (((void *)0) == pdata_urb) {
 3941|   do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate struct data_urb.\n", peasycap->isdongle, __func__);} while (0);
 3942|   return -12;
 3943|  } else
 3944|   peasycap->allocation_video_struct +=
 3945|      sizeof(struct data_urb);
 3946|
 3947|  pdata_urb->purb = purb;
 3948|  pdata_urb->isbuf = k;
 3949|  pdata_urb->length = 0;
 3950|  list_add_tail(&(pdata_urb->list_head),
 3951|      peasycap->purb_video_head);
 3952|
 3953|
 3954|
 3955|
 3956|
 3957|  if (!k) {
 3958|   do {} while (0);
 3959|   do {} while (0);
 3960|   do {} while (0);
 3961|   do {} while (0)
 3962|
 3963|                                    ;
 3964|   do {} while (0);
 3965|   do {} while (0)
 3966|                                   ;
 3967|   do {} while (0)
 3968|                                      ;
 3969|   do {} while (0);
 3970|   do {} while (0);
 3971|   do {} while (0);
 3972|   do {} while (0)
 3973|                                        ;
 3974|   do {} while (0)
 3975|                                        ;
 3976|   do {} while (0);
 3977|   do {} while (0)
 3978|                                       ;
 3979|   do {} while (0)
 3980|                                       ;
 3981|   do {} while (0);
 3982|  }
 3983|
 3984|  purb->interval = 1;
 3985|  purb->dev = peasycap->pusb_device;
 3986|  purb->pipe = ((0 << 30) | __create_pipe(peasycap->pusb_device, peasycap->video_endpointnumber) | 0x80)
 3987|                                    ;
 3988|  purb->transfer_flags = 0x0002;
 3989|  purb->transfer_buffer = peasycap->video_isoc_buffer[k].pgo;
 3990|  purb->transfer_buffer_length =
 3991|     peasycap->video_isoc_buffer_size;
 3992|  purb->complete = easycap_complete;
 3993|  purb->context = peasycap;
 3994|  purb->start_frame = 0;
 3995|  purb->number_of_packets = peasycap->video_isoc_framesperdesc;
 3996|  for (j = 0; j < peasycap->video_isoc_framesperdesc; j++) {
 3997|   purb->iso_frame_desc[j].offset = j *
 3998|     peasycap->video_isoc_maxframesize;
 3999|   purb->iso_frame_desc[j].length =
 4000|     peasycap->video_isoc_maxframesize;
 4001|  }
 4002| }
 4003| do {} while (0);
 4004|
 4005|
 4006|
 4007|
 4008|
 4009| usb_set_intfdata(pusb_interface, peasycap);
 4010| peasycap->ntsc = false;
 4011| do {} while (0);
 4012|
 4013| rc = reset(peasycap);
 4014| if (0 != rc) {
 4015|  do { printk("<7>" "easycap::%i%s: " "ERROR: reset() returned %i\n", peasycap->isdongle, __func__, rc);} while (0);
 4016|  return -14;
 4017| }
 4018| if (0 != (v4l2_device_register(&(pusb_interface->dev),
 4019|      &(peasycap->v4l2_device)))) {
 4020|  do { printk("<7>" "easycap::%i%s: " "v4l2_device_register() failed\n", peasycap->isdongle, __func__);} while (0);
 4021|  return -19;
 4022| } else {
 4023|  do {} while (0)
 4024|                                      ;
 4025| }
 4026| peasycap->video_device.v4l2_dev = (struct v4l2_device *)((void *)0);
 4027|
 4028|
 4029|
 4030|
 4031| strcpy(&peasycap->video_device.name[0], "easycapdc60");
 4032|
 4033| peasycap->video_device.fops = &v4l2_fops;
 4034|
 4035|
 4036|
 4037| peasycap->video_device.minor = -1;
 4038| peasycap->video_device.release = (void *)(&videodev_release);
 4039|
 4040| video_set_drvdata(&(peasycap->video_device), (void *)peasycap);
 4041|
 4042| if (0 != (video_register_device(&(peasycap->video_device),
 4043|      0, -1))) {
 4044|  printk("<3>" "easycap" ": " "Not able to register with videodev" "\n");
 4045|  videodev_release(&(peasycap->video_device));
 4046|  return -19;
 4047| } else {
 4048|  (peasycap->registered_video)++;
 4049|  do { printk("<7>" "easycap::%i%s: " "registered with videodev: %i=minor\n", peasycap->isdongle, __func__, peasycap->video_device.minor);} while (0)
 4050|                                   ;
 4051| }
 4052|
 4053|
 4054| break;
 4055|}
 4056|
 4057|
 4058|
 4059|
 4060|
 4061|
 4062|case 1: {
 4063| if (!peasycap) {
 4064|  do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap is NULL\n", peasycap->isdongle, __func__);} while (0);
 4065|  return -14;
 4066| }
 4067|
 4068|
 4069|
 4070|
 4071|
 4072| usb_set_intfdata(pusb_interface, peasycap);
 4073| do {} while (0)
 4074|                                                ;
 4075| break;
 4076|}
 4077|
 4078|case 2: {
 4079| if (!peasycap) {
 4080|  do { printk("<7>" "easycap::%i%s: " "MISTAKE: peasycap is NULL\n", peasycap->isdongle, __func__);} while (0);
 4081|  return -14;
 4082| }
 4083| if (!isokalt) {
 4084|  do { printk("<7>" "easycap::%i%s: " "ERROR:  no viable audio_altsetting_on\n", peasycap->isdongle, __func__);} while (0);
 4085|  return -2;
 4086| } else {
 4087|  peasycap->audio_altsetting_on = okalt[isokalt - 1];
 4088|  do {} while (0)
 4089|                                    ;
 4090| }
 4091|
 4092| peasycap->audio_endpointnumber = okepn[isokalt - 1];
 4093| do {} while (0);
 4094|
 4095| peasycap->audio_isoc_maxframesize = okmps[isokalt - 1];
 4096| do {} while (0)
 4097|                                       ;
 4098| if (0 >= peasycap->audio_isoc_maxframesize) {
 4099|  do { printk("<7>" "easycap::%i%s: " "ERROR:  bad audio_isoc_maxframesize\n", peasycap->isdongle, __func__);} while (0);
 4100|  return -2;
 4101| }
 4102| if (9 == peasycap->audio_isoc_maxframesize) {
 4103|  peasycap->ilk |= 0x02;
 4104|  do { printk("<7>" "easycap::%i%s: " "hardware is FOUR-CVBS\n", peasycap->isdongle, __func__);} while (0);
 4105|  peasycap->microphone = true;
 4106|  peasycap->audio_pages_per_fragment = 4;
 4107| } else if (256 == peasycap->audio_isoc_maxframesize) {
 4108|  peasycap->ilk &= ~0x02;
 4109|  do { printk("<7>" "easycap::%i%s: " "hardware is CVBS+S-VIDEO\n", peasycap->isdongle, __func__);} while (0);
 4110|  peasycap->microphone = false;
 4111|  peasycap->audio_pages_per_fragment = 4;
 4112| } else {
 4113|  do { printk("<7>" "easycap::%i%s: " "hardware is unidentified:\n", peasycap->isdongle, __func__);} while (0);
 4114|  do { printk("<7>" "easycap::%i%s: " "%i=audio_isoc_maxframesize\n", peasycap->isdongle, __func__, peasycap->audio_isoc_maxframesize);} while (0)
 4115|                                       ;
 4116|  return -2;
 4117| }
 4118|
 4119| peasycap->audio_bytes_per_fragment =
 4120|     peasycap->audio_pages_per_fragment *
 4121|        ((1UL) << 12) ;
 4122| peasycap->audio_buffer_page_many = (32 *
 4123|     peasycap->audio_pages_per_fragment);
 4124|
 4125| do {} while (0);
 4126| do {} while (0)
 4127|                                        ;
 4128| do {} while (0)
 4129|                                        ;
 4130| do {} while (0)
 4131|                                      ;
 4132|
 4133| peasycap->audio_isoc_framesperdesc = 128;
 4134|
 4135| do {} while (0)
 4136|                                        ;
 4137| if (0 >= peasycap->audio_isoc_framesperdesc) {
 4138|  do { printk("<7>" "easycap::%i%s: " "ERROR:  bad audio_isoc_framesperdesc\n", peasycap->isdongle, __func__);} while (0);
 4139|  return -2;
 4140| }
 4141|
 4142| peasycap->audio_isoc_buffer_size =
 4143|    peasycap->audio_isoc_maxframesize *
 4144|    peasycap->audio_isoc_framesperdesc;
 4145| do {} while (0)
 4146|                                      ;
 4147| if ((((1UL) << 12) << 3) < peasycap->audio_isoc_buffer_size) {
 4148|   do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_isoc_buffer_size bigger " "than %li=AUDIO_ISOC_BUFFER_SIZE\n", peasycap->isdongle, __func__, (((
 4149|
 4150| 1UL
 4151|   ) << 12) << 3));} while (0)
 4152|
 4153|                             ;
 4154|  return -14;
 4155| }
 4156| if (-1 == peasycap->audio_interface) {
 4157|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_interface is unset\n", peasycap->isdongle, __func__);} while (0);
 4158|  return -14;
 4159| }
 4160| if (-1 == peasycap->audio_altsetting_on) {
 4161|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_altsetting_on is unset\n", peasycap->isdongle, __func__);} while (0);
 4162|  return -14;
 4163| }
 4164| if (-1 == peasycap->audio_altsetting_off) {
 4165|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_interface_off is unset\n", peasycap->isdongle, __func__);} while (0);
 4166|  return -14;
 4167| }
 4168| if (-1 == peasycap->audio_endpointnumber) {
 4169|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_endpointnumber is unset\n", peasycap->isdongle, __func__);} while (0);
 4170|  return -14;
 4171| }
 4172| if (-1 == peasycap->audio_isoc_maxframesize) {
 4173|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_isoc_maxframesize is unset\n", peasycap->isdongle, __func__);} while (0);
 4174|  return -14;
 4175| }
 4176| if (-1 == peasycap->audio_isoc_buffer_size) {
 4177|  do { printk("<7>" "easycap::%i%s: " "MISTAKE:  audio_isoc_buffer_size is unset\n", peasycap->isdongle, __func__);} while (0);
 4178|  return -14;
 4179| }
 4180|
 4181|
 4182|
 4183|
 4184|
 4185| INIT_LIST_HEAD(&(peasycap->urb_audio_head));
 4186| peasycap->purb_audio_head = &(peasycap->urb_audio_head);
 4187|
 4188| do {} while (0);
 4189| do {} while (0)
 4190|                                      ;
 4191|
 4192| for (k = 0; k < peasycap->audio_buffer_page_many; k++) {
 4193|  if ((void *)((void *)0) != peasycap->audio_buffer[k].pgo) {
 4194|   do { printk("<7>" "easycap::%i%s: " "ERROR: attempting to reallocate audio buffers\n", peasycap->isdongle, __func__);} while (0);
 4195|  } else {
 4196|   pbuf = (void *) __get_free_pages((__st_GFP_KERNEL_st__), 0);
 4197|   if ((void *)((void *)0) == pbuf) {
 4198|    do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate audio " "buffer page %i\n", peasycap->isdongle, __func__, k);} while (0)
 4199|                             ;
 4200|    return -12;
 4201|   } else
 4202|    peasycap->allocation_audio_page += 1;
 4203|
 4204|   peasycap->audio_buffer[k].pgo = pbuf;
 4205|  }
 4206|  peasycap->audio_buffer[k].pto = peasycap->audio_buffer[k].pgo;
 4207| }
 4208|
 4209| peasycap->audio_fill = 0;
 4210| peasycap->audio_read = 0;
 4211| do {} while (0);
 4212|
 4213| do {} while (0)
 4214|                                                           ;
 4215| do {} while (0);
 4216|
 4217| for (k = 0; k < 16; k++) {
 4218|  pbuf = (void *)__get_free_pages(__st_GFP_KERNEL_st__, 3);
 4219|  if (((void *)0) == pbuf) {
 4220|   do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate isoc audio buffer " "%i\n", peasycap->isdongle, __func__, k);} while (0)
 4221|                 ;
 4222|   return -12;
 4223|  } else
 4224|   peasycap->allocation_audio_page +=
 4225|    ((unsigned int)(0x01 << 3));
 4226|
 4227|  peasycap->audio_isoc_buffer[k].pgo = pbuf;
 4228|  peasycap->audio_isoc_buffer[k].pto = pbuf +
 4229|  peasycap->audio_isoc_buffer_size;
 4230|  peasycap->audio_isoc_buffer[k].kount = k;
 4231| }
 4232| do {} while (0);
 4233|
 4234|
 4235|
 4236|
 4237|
 4238| do {} while (0);
 4239| do {} while (0)
 4240|                                        ;
 4241| do {} while (0)
 4242|                                       ;
 4243| do {} while (0)
 4244|                                      ;
 4245|
 4246| for (k = 0; k < 16; k++) {
 4247|  purb = usb_alloc_urb(peasycap->audio_isoc_framesperdesc,
 4248|        __st_GFP_KERNEL_st__);
 4249|  if (((void *)0) == purb) {
 4250|   do { printk("<7>" "easycap::%i%s: " "ERROR: usb_alloc_urb returned NULL for buffer " "%i\n", peasycap->isdongle, __func__, k);} while (0)
 4251|                 ;
 4252|   return -12;
 4253|  } else
 4254|   peasycap->allocation_audio_urb += 1 ;
 4255|
 4256|  pdata_urb = kzalloc(sizeof(struct data_urb), __st_GFP_KERNEL_st__);
 4257|  if (((void *)0) == pdata_urb) {
 4258|   do { printk("<7>" "easycap::%i%s: " "ERROR: Could not allocate struct data_urb.\n", peasycap->isdongle, __func__);} while (0);
 4259|   return -12;
 4260|  } else
 4261|   peasycap->allocation_audio_struct +=
 4262|      sizeof(struct data_urb);
 4263|
 4264|  pdata_urb->purb = purb;
 4265|  pdata_urb->isbuf = k;
 4266|  pdata_urb->length = 0;
 4267|  list_add_tail(&(pdata_urb->list_head),
 4268|      peasycap->purb_audio_head);
 4269|
 4270|
 4271|
 4272|
 4273|
 4274|  if (!k) {
 4275|   do {} while (0);
 4276|   do {} while (0);
 4277|   do {} while (0);
 4278|   do {} while (0)
 4279|
 4280|                                    ;
 4281|   do {} while (0);
 4282|   do {} while (0)
 4283|                                            ;
 4284|   do {} while (0)
 4285|                                      ;
 4286|   do {} while (0);
 4287|   do {} while (0);
 4288|   do {} while (0);
 4289|   do {} while (0)
 4290|                                        ;
 4291|   do {} while (0)
 4292|                                        ;
 4293|   do {} while (0);
 4294|   do {} while (0)
 4295|                                       ;
 4296|   do {} while (0)
 4297|                                       ;
 4298|   do {} while (0);
 4299|   }
 4300|
 4301|  purb->interval = 1;
 4302|  purb->dev = peasycap->pusb_device;
 4303|  purb->pipe = ((0 << 30) | __create_pipe(peasycap->pusb_device, peasycap->audio_endpointnumber) | 0x80)
 4304|                                    ;
 4305|  purb->transfer_flags = 0x0002;
 4306|  purb->transfer_buffer = peasycap->audio_isoc_buffer[k].pgo;
 4307|  purb->transfer_buffer_length =
 4308|     peasycap->audio_isoc_buffer_size;
 4309|  purb->complete = easysnd_complete;
 4310|  purb->context = peasycap;
 4311|  purb->start_frame = 0;
 4312|  purb->number_of_packets = peasycap->audio_isoc_framesperdesc;
 4313|  for (j = 0; j < peasycap->audio_isoc_framesperdesc; j++) {
 4314|   purb->iso_frame_desc[j].offset = j *
 4315|     peasycap->audio_isoc_maxframesize;
 4316|   purb->iso_frame_desc[j].length =
 4317|     peasycap->audio_isoc_maxframesize;
 4318|  }
 4319| }
 4320| do {} while (0);
 4321|
 4322|
 4323|
 4324|
 4325|
 4326| usb_set_intfdata(pusb_interface, peasycap);
 4327|
 4328|
 4329|
 4330|
 4331|
 4332| rc = usb_register_dev(pusb_interface, &easysnd_class);
 4333| if (0 != rc) {
 4334|  printk("<3>" "easycap" ": " "Not able to get a minor for this device." "\n");
 4335|  usb_set_intfdata(pusb_interface, ((void *)0));
 4336|  return -19;
 4337| } else {
 4338|  do {} while (0)
 4339|                                          ;
 4340|  kref_get(&peasycap->kref);
 4341|  (peasycap->registered_audio)++;
 4342| }
 4343|
 4344|
 4345|
 4346|
 4347|
 4348| do { printk("<7>" "easycap::%i%s: " "easysnd attached to minor #%d\n", peasycap->isdongle, __func__, pusb_interface->minor);} while (0);
 4349| break;
 4350|}
 4351|
 4352|
 4353|
 4354|
 4355|
 4356|default: {
 4357| do {} while (0);
 4358| return -22;
 4359|}
 4360|}
 4361|do {} while (0)
 4362|                                                ;
 4363|return 0;
 4364|}
 4365|
 4366|
 4367|
 4368|
 4369|
 4370|
 4371|
 4372|void
 4373|easycap_usb_disconnect(struct usb_interface *pusb_interface)
 4374|{
 4375|struct usb_host_interface *pusb_host_interface;
 4376|struct usb_interface_descriptor *pusb_interface_descriptor;
 4377|__u8 bInterfaceNumber;
 4378|struct easycap *peasycap;
 4379|
 4380|struct list_head *plist_head;
 4381|struct data_urb *pdata_urb;
 4382|int minor, m, kd;
 4383|
 4384|
 4385|
 4386|struct v4l2_device *pv4l2_device;
 4387|
 4388|
 4389|
 4390|
 4391|do {} while (0);
 4392|
 4393|if ((struct usb_interface *)((void *)0) == pusb_interface) {
 4394| do {} while (0);
 4395| return;
 4396|}
 4397|pusb_host_interface = pusb_interface->cur_altsetting;
 4398|if ((struct usb_host_interface *)((void *)0) == pusb_host_interface) {
 4399| do {} while (0);
 4400| return;
 4401|}
 4402|pusb_interface_descriptor = &(pusb_host_interface->desc);
 4403|if ((struct usb_interface_descriptor *)((void *)0) == pusb_interface_descriptor) {
 4404| do {} while (0);
 4405| return;
 4406|}
 4407|bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber;
 4408|minor = pusb_interface->minor;
 4409|do {} while (0);
 4410|
 4411|if (1 == bInterfaceNumber)
 4412| return;
 4413|
 4414|peasycap = usb_get_intfdata(pusb_interface);
 4415|if (((void *)0) == peasycap) {
 4416| do { printk("<7>" "easycap:: %s: " "ERROR: peasycap is NULL\n", __func__); } while (0);
 4417| return;
 4418|}
 4419|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
 4420| pv4l2_device = usb_get_intfdata(pusb_interface);
 4421| if ((struct v4l2_device *)((void *)0) == pv4l2_device) {
 4422|  do { printk("<7>" "easycap:: %s: " "ERROR: pv4l2_device is NULL\n", __func__); } while (0);
 4423|  return;
 4424| }
 4425| peasycap = (struct easycap *)
 4426|  ({ const typeof( ((struct easycap *)0)->v4l2_device ) *__mptr = (pv4l2_device); (struct easycap *)( (char *)__mptr - 1 );});
 4427|}
 4428|
 4429|
 4430|
 4431|
 4432|
 4433|if (memcmp(&peasycap->telltale[0], "expectedstring", strlen("expectedstring"))) {
 4434| do { printk("<7>" "easycap:: %s: " "ERROR: bad peasycap: 0x%08lX\n", __func__, (unsigned long int) peasycap); } while (0);
 4435| return;
 4436|}
 4437|
 4438|
 4439|
 4440|
 4441|
 4442|peasycap->video_eof = 1;
 4443|peasycap->audio_eof = 1;
 4444|__wake_up(&(peasycap->wq_video), 1, 1, ((void *)0));
 4445|__wake_up(&(peasycap->wq_audio), 1, 1, ((void *)0));
 4446|
 4447|switch (bInterfaceNumber) {
 4448|case 0: {
 4449| if ((struct list_head *)((void *)0) != peasycap->purb_video_head) {
 4450|  do {} while (0);
 4451|  m = 0;
 4452|  for (plist_head = ((peasycap->purb_video_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_video_head)); plist_head = plist_head->next)
 4453|   {
 4454|   pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );})
 4455|                                ;
 4456|   if ((struct data_urb *)((void *)0) != pdata_urb) {
 4457|    if ((struct urb *)((void *)0) !=
 4458|      pdata_urb->purb) {
 4459|     usb_kill_urb(pdata_urb->purb);
 4460|     m++;
 4461|    }
 4462|   }
 4463|  }
 4464|  do {} while (0);
 4465| }
 4466| break;
 4467|}
 4468|
 4469|case 2: {
 4470| if ((struct list_head *)((void *)0) != peasycap->purb_audio_head) {
 4471|  do {} while (0);
 4472|  m = 0;
 4473|  for (plist_head = ((peasycap->purb_audio_head))->next; __builtin_prefetch(plist_head->next), plist_head != ((peasycap->purb_audio_head)); plist_head = plist_head->next)
 4474|                                  {
 4475|   pdata_urb = ({ const typeof( ((struct data_urb *)0)->list_head ) *__mptr = (plist_head); (struct data_urb *)( (char *)__mptr - 1 );})
 4476|                                ;
 4477|   if ((struct data_urb *)((void *)0) != pdata_urb) {
 4478|    if ((struct urb *)((void *)0) !=
 4479|      pdata_urb->purb) {
 4480|     usb_kill_urb(pdata_urb->purb);
 4481|     m++;
 4482|    }
 4483|   }
 4484|  }
 4485|  do {} while (0);
 4486| }
 4487| break;
 4488|}
 4489|
 4490|default:
 4491| break;
 4492|}
 4493|kd = isdongle(peasycap);
 4494|switch (bInterfaceNumber) {
 4495|case 0: {
 4496| if (0 <= kd && 8 > kd) {
 4497|  __wake_up(&peasycap->wq_video, 1, 1, ((void *)0));
 4498|  do {} while (0);
 4499|  if (__st_mutex_lock_interruptible_st__(&easycap_dongle[kd].
 4500|        mutex_video)) {
 4501|   do { printk("<7>" "easycap:: %s: " "ERROR: cannot lock easycap_dongle[%i]." "mutex_video\n", __func__, kd); } while (0)
 4502|                           ;
 4503|   return;
 4504|  }
 4505|  do {} while (0);
 4506| } else
 4507|  do { printk("<7>" "easycap:: %s: " "ERROR: %i=kd is bad: cannot lock dongle\n", __func__, kd); } while (0);
 4508| if (!peasycap->v4l2_device.name[0]) {
 4509|  do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->v4l2_device.name is empty\n", peasycap->isdongle, __func__);} while (0);
 4510|  if (0 <= kd && 8 > kd)
 4511|   __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
 4512|  return;
 4513| }
 4514| v4l2_device_disconnect(&peasycap->v4l2_device);
 4515| do {} while (0);
 4516| v4l2_device_unregister(&peasycap->v4l2_device);
 4517| do {} while (0);
 4518|
 4519|
 4520| video_unregister_device(&peasycap->video_device);
 4521| do {} while (0);
 4522| (peasycap->registered_video)--;
 4523| do {} while (0);
 4524|
 4525|
 4526|
 4527| if (0 <= kd && 8 > kd) {
 4528|  __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
 4529|  do {} while (0);
 4530| }
 4531| break;
 4532|}
 4533|case 2: {
 4534| if (0 <= kd && 8 > kd) {
 4535|  __wake_up(&peasycap->wq_audio, 1, 1, ((void *)0));
 4536|  do {} while (0);
 4537|  if (__st_mutex_lock_interruptible_st__(&easycap_dongle[kd].
 4538|        mutex_audio)) {
 4539|   do { printk("<7>" "easycap:: %s: " "ERROR: cannot lock easycap_dongle[%i]." "mutex_audio\n", __func__, kd); } while (0)
 4540|                           ;
 4541|   return;
 4542|  }
 4543|  do {} while (0);
 4544| } else
 4545|  do { printk("<7>" "easycap:: %s: " "ERROR: %i=kd is bad: cannot lock dongle\n", __func__, kd); } while (0);
 4546|
 4547| usb_deregister_dev(pusb_interface, &easysnd_class);
 4548| (peasycap->registered_audio)--;
 4549|
 4550| do {} while (0);
 4551| do { printk("<7>" "easycap::%i%s: " "easysnd detached from minor #%d\n", peasycap->isdongle, __func__, minor);} while (0);
 4552|
 4553| if (0 <= kd && 8 > kd) {
 4554|  __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_audio);
 4555|  do {} while (0);
 4556| }
 4557| break;
 4558|}
 4559|default:
 4560| break;
 4561|}
 4562|
 4563|
 4564|
 4565|
 4566|
 4567|if (!peasycap->kref.refcount.counter) {
 4568| do { printk("<7>" "easycap::%i%s: " "ERROR: peasycap->kref.refcount.counter is zero " "so cannot call kref_put()\n", peasycap->isdongle, __func__);} while (0)
 4569|                                    ;
 4570| do { printk("<7>" "easycap::%i%s: " "ending unsuccessfully: may cause memory leak\n", peasycap->isdongle, __func__);} while (0);
 4571| return;
 4572|}
 4573|if (0 <= kd && 8 > kd) {
 4574| do {} while (0);
 4575| if (__st_mutex_lock_interruptible_st__(&easycap_dongle[kd].mutex_video)) {
 4576|  do { printk("<7>" "easycap:: %s: " "ERROR: cannot down easycap_dongle[%i].mutex_video\n", __func__, kd); } while (0);
 4577|  do { printk("<7>" "easycap::%i%s: " "ending unsuccessfully: may cause memory leak\n", peasycap->isdongle, __func__);} while (0);
 4578| return;
 4579| }
 4580| do {} while (0);
 4581| do {} while (0);
 4582| if (__st_mutex_lock_interruptible_st__(&easycap_dongle[kd].mutex_audio)) {
 4583|  do { printk("<7>" "easycap:: %s: " "ERROR: cannot down easycap_dongle[%i].mutex_audio\n", __func__, kd); } while (0);
 4584|  __st_mutex_unlock_st__(&(easycap_dongle[kd].mutex_video));
 4585|  do {} while (0);
 4586|  do { printk("<7>" "easycap::%i%s: " "ending unsuccessfully: may cause memory leak\n", peasycap->isdongle, __func__);} while (0);
 4587|  return;
 4588| }
 4589| do {} while (0);
 4590|}
 4591|do {} while (0)
 4592|                                                         ;
 4593|kref_put(&peasycap->kref, easycap_delete);
 4594|do {} while (0);
 4595|if (0 <= kd && 8 > kd) {
 4596| __st_mutex_unlock_st__(&(easycap_dongle[kd].mutex_audio));
 4597| do {} while (0);
 4598| __st_mutex_unlock_st__(&easycap_dongle[kd].mutex_video);
 4599| do {} while (0);
 4600|}
 4601|
 4602|do {} while (0);
 4603|return;
 4604|}
 4605|
 4606|int
 4607|easycap_module_init(void)
 4608|{
 4609|int result;
 4610|
 4611|do { printk("<7>" "easycap:: %s: " "========easycap=======\n", __func__); } while (0);
 4612|do {} while (0)
 4613|                   ;
 4614|do { printk("<7>" "easycap:: %s: " "version: " "0.8.41" "\n", __func__); } while (0);
 4615|
 4616|
 4617|
 4618|
 4619|
 4620|do {} while (0);
 4621|
 4622|result = usb_register(&easycap_usb_driver);
 4623|if (0 != result)
 4624| do { printk("<7>" "easycap:: %s: " "ERROR:  usb_register returned %i\n", __func__, result); } while (0);
 4625|
 4626|do {} while (0);
 4627|return result;
 4628|}
 4629|
 4630|void
 4631|easycap_module_exit(void)
 4632|{
 4633|do {} while (0);
 4634|
 4635|
 4636|
 4637|
 4638|
 4639|
 4640|usb_deregister(&easycap_usb_driver);
 4641|
 4642|do {} while (0);
 4643|}
 4644|
 4645|
 4646|static inline initcall_t __inittest(void) { return easycap_module_init; } int init_module(void) ;;
 4647|static inline exitcall_t __exittest(void) { return easycap_module_exit; } void cleanup_module(void) ;;
 4648|
 4649|static const char __mod_license5048[] = "license" "=" "GPL";
 4650|static const char __mod_author5049[] = "author" "=" "R.M. Thomas ";
 4651|static const char __mod_description5050[] = "description" "=" "easycapdc60";
 4652|static const char __mod_version5051[] = "version" "=" "0.8.41";
 4653|
 4654|
 4655|
 4656|static const char
 4657| __mod_bars5056
 4658| [] = "parm" "=" "bars" ":" "Testcard bars on input signal failure: 0=>no, 1=>yes(default)"
 4659|                                                                 ;
 4660|static const char __mod_gain5057[] = "parm" "=" "gain" ":" "Audio gain: 0,...,16(default),...31";