提交 50e1fbdc 编写于 作者: T Tomas Winkler 提交者: Greg Kroah-Hartman

staging/easycap: add first level indentation to easycap_ioctl.c

Add the first level indentation to easycap_testcard.c with astyle -t8.
About 100 of 80 columns warnings were left out for further fix

Cc: Mike Thomas <rmthomas@sciolus.org>
Signed-off-by: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 abb46c8c
...@@ -42,257 +42,277 @@ ...@@ -42,257 +42,277 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int adjust_standard(struct easycap *peasycap, v4l2_std_id std_id) int adjust_standard(struct easycap *peasycap, v4l2_std_id std_id)
{ {
struct easycap_standard const *peasycap_standard; struct easycap_standard const *peasycap_standard;
u16 reg, set; u16 reg, set;
int ir, rc, need, k; int ir, rc, need, k;
unsigned int itwas, isnow; unsigned int itwas, isnow;
bool resubmit; bool resubmit;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
peasycap_standard = &easycap_standard[0];
while (0xFFFF != peasycap_standard->mask) {
if (std_id == peasycap_standard->v4l2_standard.id)
break;
peasycap_standard++;
}
if (0xFFFF == peasycap_standard->mask) {
peasycap_standard = &easycap_standard[0]; peasycap_standard = &easycap_standard[0];
while (0xFFFF != peasycap_standard->mask) { while (0xFFFF != peasycap_standard->mask) {
if (std_id & peasycap_standard->v4l2_standard.id) if (std_id == peasycap_standard->v4l2_standard.id)
break; break;
peasycap_standard++; peasycap_standard++;
} }
} if (0xFFFF == peasycap_standard->mask) {
if (0xFFFF == peasycap_standard->mask) { peasycap_standard = &easycap_standard[0];
SAM("ERROR: 0x%08X=std_id: standard not found\n", while (0xFFFF != peasycap_standard->mask) {
(unsigned int)std_id); if (std_id & peasycap_standard->v4l2_standard.id)
return -EINVAL; break;
} peasycap_standard++;
SAM("selected standard: %s\n", }
&(peasycap_standard->v4l2_standard.name[0])); }
if (peasycap->standard_offset == if (0xFFFF == peasycap_standard->mask) {
(int)(peasycap_standard - &easycap_standard[0])) { SAM("ERROR: 0x%08X=std_id: standard not found\n",
SAM("requested standard already in effect\n"); (unsigned int)std_id);
return 0; return -EINVAL;
} }
peasycap->standard_offset = (int)(peasycap_standard - &easycap_standard[0]); SAM("selected standard: %s\n",
for (k = 0; k < INPUT_MANY; k++) { &(peasycap_standard->v4l2_standard.name[0]));
if (!peasycap->inputset[k].standard_offset_ok) { if (peasycap->standard_offset == peasycap_standard - easycap_standard) {
SAM("requested standard already in effect\n");
return 0;
}
peasycap->standard_offset = peasycap_standard - easycap_standard;
for (k = 0; k < INPUT_MANY; k++) {
if (!peasycap->inputset[k].standard_offset_ok) {
peasycap->inputset[k].standard_offset = peasycap->inputset[k].standard_offset =
peasycap->standard_offset; peasycap->standard_offset;
}
} }
} if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) { peasycap->inputset[peasycap->input].standard_offset =
peasycap->inputset[peasycap->input].standard_offset = peasycap->standard_offset;
peasycap->standard_offset; peasycap->inputset[peasycap->input].standard_offset_ok = 1;
peasycap->inputset[peasycap->input].standard_offset_ok = 1; } else
} else JOM(8, "%i=peasycap->input\n", peasycap->input);
JOM(8, "%i=peasycap->input\n", peasycap->input);
peasycap->fps = peasycap_standard->v4l2_standard.frameperiod.denominator / peasycap->fps = peasycap_standard->v4l2_standard.frameperiod.denominator /
peasycap_standard->v4l2_standard.frameperiod.numerator; peasycap_standard->v4l2_standard.frameperiod.numerator;
switch (peasycap->fps) { switch (peasycap->fps) {
case 6: case 6:
case 30: { case 30: {
peasycap->ntsc = true; peasycap->ntsc = true;
break; break;
} }
case 5: case 5:
case 25: { case 25: {
peasycap->ntsc = false; peasycap->ntsc = false;
break; break;
} }
default: { default: {
SAM("MISTAKE: %i=frames-per-second\n", peasycap->fps); SAM("MISTAKE: %i=frames-per-second\n", peasycap->fps);
return -ENOENT; return -ENOENT;
} }
} }
JOM(8, "%i frames-per-second\n", peasycap->fps); JOM(8, "%i frames-per-second\n", peasycap->fps);
if (0x8000 & peasycap_standard->mask) { if (0x8000 & peasycap_standard->mask) {
peasycap->skip = 5; peasycap->skip = 5;
peasycap->usec = 1000000 / (2 * (5 * peasycap->fps)); peasycap->usec = 1000000 / (2 * (5 * peasycap->fps));
peasycap->tolerate = 1000 * (25 / (5 * peasycap->fps)); peasycap->tolerate = 1000 * (25 / (5 * peasycap->fps));
} else { } else {
peasycap->skip = 0; peasycap->skip = 0;
peasycap->usec = 1000000 / (2 * peasycap->fps); peasycap->usec = 1000000 / (2 * peasycap->fps);
peasycap->tolerate = 1000 * (25 / peasycap->fps); peasycap->tolerate = 1000 * (25 / peasycap->fps);
} }
if (peasycap->video_isoc_streaming) { if (peasycap->video_isoc_streaming) {
resubmit = true; resubmit = true;
kill_video_urbs(peasycap); kill_video_urbs(peasycap);
} else } else
resubmit = false; resubmit = false;
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* SAA7113H DATASHEET PAGE 44, TABLE 42 * SAA7113H DATASHEET PAGE 44, TABLE 42
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
need = 0; itwas = 0; reg = 0x00; set = 0x00; need = 0;
switch (peasycap_standard->mask & 0x000F) { itwas = 0;
case NTSC_M_JP: { reg = 0x00;
reg = 0x0A; set = 0x95; set = 0x00;
ir = read_saa(peasycap->pusb_device, reg); switch (peasycap_standard->mask & 0x000F) {
if (0 > ir) case NTSC_M_JP: {
SAM("ERROR: cannot read SAA register 0x%02X\n", reg); reg = 0x0A;
else set = 0x95;
itwas = (unsigned int)ir; ir = read_saa(peasycap->pusb_device, reg);
rc = write_saa(peasycap->pusb_device, reg, set);
if (rc)
SAM("ERROR: failed to set SAA register "
"0x%02X to 0x%02X for JP standard\n", reg, set);
else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
JOM(8, "SAA register 0x%02X changed " SAM("ERROR: cannot read SAA register 0x%02X\n", reg);
"to 0x%02X\n", reg, isnow);
else else
JOM(8, "SAA register 0x%02X changed " itwas = (unsigned int)ir;
"from 0x%02X to 0x%02X\n", reg, itwas, isnow); rc = write_saa(peasycap->pusb_device, reg, set);
} if (rc)
SAM("ERROR: failed to set SAA register "
"0x%02X to 0x%02X for JP standard\n", reg, set);
else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir)
JOM(8, "SAA register 0x%02X changed "
"to 0x%02X\n", reg, isnow);
else
JOM(8, "SAA register 0x%02X changed "
"from 0x%02X to 0x%02X\n", reg, itwas, isnow);
}
reg = 0x0B; set = 0x48; reg = 0x0B;
ir = read_saa(peasycap->pusb_device, reg); set = 0x48;
if (0 > ir) ir = read_saa(peasycap->pusb_device, reg);
SAM("ERROR: cannot read SAA register 0x%02X\n", reg);
else
itwas = (unsigned int)ir;
rc = write_saa(peasycap->pusb_device, reg, set);
if (rc)
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X "
"for JP standard\n", reg, set);
else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
JOM(8, "SAA register 0x%02X changed " SAM("ERROR: cannot read SAA register 0x%02X\n", reg);
"to 0x%02X\n", reg, isnow);
else else
JOM(8, "SAA register 0x%02X changed " itwas = (unsigned int)ir;
"from 0x%02X to 0x%02X\n", reg, itwas, isnow); rc = write_saa(peasycap->pusb_device, reg, set);
} if (rc)
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X "
"for JP standard\n", reg, set);
else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir)
JOM(8, "SAA register 0x%02X changed "
"to 0x%02X\n", reg, isnow);
else
JOM(8, "SAA register 0x%02X changed "
"from 0x%02X to 0x%02X\n", reg, itwas, isnow);
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* NOTE: NO break HERE: RUN ON TO NEXT CASE * NOTE: NO break HERE: RUN ON TO NEXT CASE
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
} }
case NTSC_M: case NTSC_M:
case PAL_BGHIN: { case PAL_BGHIN: {
reg = 0x0E; set = 0x01; need = 1; break; reg = 0x0E;
} set = 0x01;
case NTSC_N_443: need = 1;
case PAL_60: { break;
reg = 0x0E; set = 0x11; need = 1; break; }
} case NTSC_N_443:
case NTSC_443: case PAL_60: {
case PAL_Nc: { reg = 0x0E;
reg = 0x0E; set = 0x21; need = 1; break; set = 0x11;
} need = 1;
case NTSC_N: break;
case PAL_M: { }
reg = 0x0E; set = 0x31; need = 1; break; case NTSC_443:
} case PAL_Nc: {
case SECAM: { reg = 0x0E;
reg = 0x0E; set = 0x51; need = 1; break; set = 0x21;
} need = 1;
default: break;
break; }
} case NTSC_N:
case PAL_M: {
reg = 0x0E;
set = 0x31;
need = 1;
break;
}
case SECAM: {
reg = 0x0E;
set = 0x51;
need = 1;
break;
}
default:
break;
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
if (need) { if (need) {
ir = read_saa(peasycap->pusb_device, reg); ir = read_saa(peasycap->pusb_device, reg);
if (0 > ir)
SAM("ERROR: failed to read SAA register 0x%02X\n", reg);
else
itwas = (unsigned int)ir;
rc = write_saa(peasycap->pusb_device, reg, set);
if (0 != write_saa(peasycap->pusb_device, reg, set)) {
SAM("ERROR: failed to set SAA register "
"0x%02X to 0x%02X for table 42\n", reg, set);
} else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
JOM(8, "SAA register 0x%02X changed " SAM("ERROR: failed to read SAA register 0x%02X\n", reg);
"to 0x%02X\n", reg, isnow);
else else
JOM(8, "SAA register 0x%02X changed " itwas = (unsigned int)ir;
"from 0x%02X to 0x%02X\n", reg, itwas, isnow); rc = write_saa(peasycap->pusb_device, reg, set);
if (0 != write_saa(peasycap->pusb_device, reg, set)) {
SAM("ERROR: failed to set SAA register "
"0x%02X to 0x%02X for table 42\n", reg, set);
} else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir)
JOM(8, "SAA register 0x%02X changed "
"to 0x%02X\n", reg, isnow);
else
JOM(8, "SAA register 0x%02X changed "
"from 0x%02X to 0x%02X\n", reg, itwas, isnow);
}
} }
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* SAA7113H DATASHEET PAGE 41 * SAA7113H DATASHEET PAGE 41
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
reg = 0x08; reg = 0x08;
ir = read_saa(peasycap->pusb_device, reg); ir = read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
SAM("ERROR: failed to read SAA register 0x%02X " SAM("ERROR: failed to read SAA register 0x%02X "
"so cannot reset\n", reg); "so cannot reset\n", reg);
else {
itwas = (unsigned int)ir;
if (peasycap_standard->mask & 0x0001)
set = itwas | 0x40 ;
else
set = itwas & ~0x40 ;
rc = write_saa(peasycap->pusb_device, reg, set);
if (rc)
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X\n",
reg, set);
else { else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); itwas = (unsigned int)ir;
if (0 > ir) if (peasycap_standard->mask & 0x0001)
JOM(8, "SAA register 0x%02X changed to 0x%02X\n", set = itwas | 0x40 ;
reg, isnow);
else else
JOM(8, "SAA register 0x%02X changed " set = itwas & ~0x40 ;
"from 0x%02X to 0x%02X\n", reg, itwas, isnow); rc = write_saa(peasycap->pusb_device, reg, set);
if (rc)
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X\n",
reg, set);
else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir)
JOM(8, "SAA register 0x%02X changed to 0x%02X\n",
reg, isnow);
else
JOM(8, "SAA register 0x%02X changed "
"from 0x%02X to 0x%02X\n", reg, itwas, isnow);
}
} }
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* SAA7113H DATASHEET PAGE 51, TABLE 57 * SAA7113H DATASHEET PAGE 51, TABLE 57
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
reg = 0x40; reg = 0x40;
ir = read_saa(peasycap->pusb_device, reg); ir = read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
SAM("ERROR: failed to read SAA register 0x%02X " SAM("ERROR: failed to read SAA register 0x%02X "
"so cannot reset\n", reg); "so cannot reset\n", reg);
else {
itwas = (unsigned int)ir;
if (peasycap_standard->mask & 0x0001)
set = itwas | 0x80 ;
else
set = itwas & ~0x80 ;
rc = write_saa(peasycap->pusb_device, reg, set);
if (rc)
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X\n",
reg, set);
else { else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); itwas = (unsigned int)ir;
if (0 > ir) if (peasycap_standard->mask & 0x0001)
JOM(8, "SAA register 0x%02X changed to 0x%02X\n", set = itwas | 0x80 ;
reg, isnow);
else else
JOM(8, "SAA register 0x%02X changed " set = itwas & ~0x80 ;
"from 0x%02X to 0x%02X\n", reg, itwas, isnow); rc = write_saa(peasycap->pusb_device, reg, set);
if (rc)
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X\n",
reg, set);
else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir)
JOM(8, "SAA register 0x%02X changed to 0x%02X\n",
reg, isnow);
else
JOM(8, "SAA register 0x%02X changed "
"from 0x%02X to 0x%02X\n", reg, itwas, isnow);
}
} }
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* SAA7113H DATASHEET PAGE 53, TABLE 66 * SAA7113H DATASHEET PAGE 53, TABLE 66
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
reg = 0x5A; reg = 0x5A;
ir = read_saa(peasycap->pusb_device, reg); ir = read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
SAM("ERROR: failed to read SAA register 0x%02X but continuing\n", reg); SAM("ERROR: failed to read SAA register 0x%02X but continuing\n", reg);
itwas = (unsigned int)ir; itwas = (unsigned int)ir;
if (peasycap_standard->mask & 0x0001) if (peasycap_standard->mask & 0x0001)
set = 0x0A ; set = 0x0A ;
...@@ -300,19 +320,19 @@ if (0 > ir) ...@@ -300,19 +320,19 @@ if (0 > ir)
set = 0x07 ; set = 0x07 ;
if (0 != write_saa(peasycap->pusb_device, reg, set)) if (0 != write_saa(peasycap->pusb_device, reg, set))
SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X\n", SAM("ERROR: failed to set SAA register 0x%02X to 0x%02X\n",
reg, set); reg, set);
else { else {
isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); isnow = (unsigned int)read_saa(peasycap->pusb_device, reg);
if (0 > ir) if (0 > ir)
JOM(8, "SAA register 0x%02X changed " JOM(8, "SAA register 0x%02X changed "
"to 0x%02X\n", reg, isnow); "to 0x%02X\n", reg, isnow);
else else
JOM(8, "SAA register 0x%02X changed " JOM(8, "SAA register 0x%02X changed "
"from 0x%02X to 0x%02X\n", reg, itwas, isnow); "from 0x%02X to 0x%02X\n", reg, itwas, isnow);
} }
if (true == resubmit) if (true == resubmit)
submit_video_urbs(peasycap); submit_video_urbs(peasycap);
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
...@@ -340,564 +360,545 @@ return 0; ...@@ -340,564 +360,545 @@ return 0;
*/ */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int adjust_format(struct easycap *peasycap, int adjust_format(struct easycap *peasycap,
u32 width, u32 height, u32 pixelformat, int field, bool try) u32 width, u32 height, u32 pixelformat, int field, bool try)
{ {
struct easycap_format *peasycap_format, *peasycap_best_format; struct easycap_format *peasycap_format, *peasycap_best_format;
u16 mask; u16 mask;
struct usb_device *p; struct usb_device *p;
int miss, multiplier, best, k; int miss, multiplier, best, k;
char bf[5], fo[32], *pc; char bf[5], fo[32], *pc;
u32 uc; u32 uc;
bool resubmit; bool resubmit;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (0 > peasycap->standard_offset) { if (0 > peasycap->standard_offset) {
JOM(8, "%i=peasycap->standard_offset\n", peasycap->standard_offset); JOM(8, "%i=peasycap->standard_offset\n", peasycap->standard_offset);
return -EBUSY; return -EBUSY;
} }
p = peasycap->pusb_device; p = peasycap->pusb_device;
if (NULL == p) { if (NULL == p) {
SAM("ERROR: peaycap->pusb_device is NULL\n"); SAM("ERROR: peaycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
pc = &bf[0]; pc = &bf[0];
uc = pixelformat; uc = pixelformat;
memcpy((void *)pc, (void *)(&uc), 4); memcpy((void *)pc, (void *)(&uc), 4);
bf[4] = 0; bf[4] = 0;
mask = 0xFF & easycap_standard[peasycap->standard_offset].mask; mask = 0xFF & easycap_standard[peasycap->standard_offset].mask;
SAM("sought: %ix%i,%s(0x%08X),%i=field,0x%02X=std mask\n", SAM("sought: %ix%i,%s(0x%08X),%i=field,0x%02X=std mask\n",
width, height, pc, pixelformat, field, mask); width, height, pc, pixelformat, field, mask);
switch (field) { switch (field) {
case V4L2_FIELD_ANY: { case V4L2_FIELD_ANY: {
strcpy(&fo[0], "V4L2_FIELD_ANY "); strcpy(&fo[0], "V4L2_FIELD_ANY ");
break; break;
} }
case V4L2_FIELD_NONE: { case V4L2_FIELD_NONE: {
strcpy(&fo[0], "V4L2_FIELD_NONE"); strcpy(&fo[0], "V4L2_FIELD_NONE");
break; break;
} }
case V4L2_FIELD_TOP: { case V4L2_FIELD_TOP: {
strcpy(&fo[0], "V4L2_FIELD_TOP"); strcpy(&fo[0], "V4L2_FIELD_TOP");
break; break;
} }
case V4L2_FIELD_BOTTOM: { case V4L2_FIELD_BOTTOM: {
strcpy(&fo[0], "V4L2_FIELD_BOTTOM"); strcpy(&fo[0], "V4L2_FIELD_BOTTOM");
break; break;
} }
case V4L2_FIELD_INTERLACED: { case V4L2_FIELD_INTERLACED: {
strcpy(&fo[0], "V4L2_FIELD_INTERLACED"); strcpy(&fo[0], "V4L2_FIELD_INTERLACED");
break; break;
} }
case V4L2_FIELD_SEQ_TB: { case V4L2_FIELD_SEQ_TB: {
strcpy(&fo[0], "V4L2_FIELD_SEQ_TB"); strcpy(&fo[0], "V4L2_FIELD_SEQ_TB");
break; break;
} }
case V4L2_FIELD_SEQ_BT: { case V4L2_FIELD_SEQ_BT: {
strcpy(&fo[0], "V4L2_FIELD_SEQ_BT"); strcpy(&fo[0], "V4L2_FIELD_SEQ_BT");
break; break;
} }
case V4L2_FIELD_ALTERNATE: { case V4L2_FIELD_ALTERNATE: {
strcpy(&fo[0], "V4L2_FIELD_ALTERNATE"); strcpy(&fo[0], "V4L2_FIELD_ALTERNATE");
break; break;
} }
case V4L2_FIELD_INTERLACED_TB: { case V4L2_FIELD_INTERLACED_TB: {
strcpy(&fo[0], "V4L2_FIELD_INTERLACED_TB"); strcpy(&fo[0], "V4L2_FIELD_INTERLACED_TB");
break; break;
} }
case V4L2_FIELD_INTERLACED_BT: { case V4L2_FIELD_INTERLACED_BT: {
strcpy(&fo[0], "V4L2_FIELD_INTERLACED_BT"); strcpy(&fo[0], "V4L2_FIELD_INTERLACED_BT");
break; break;
} }
default: { default: {
strcpy(&fo[0], "V4L2_FIELD_... UNKNOWN "); strcpy(&fo[0], "V4L2_FIELD_... UNKNOWN ");
break; break;
} }
} }
SAM("sought: %s\n", &fo[0]); SAM("sought: %s\n", &fo[0]);
if (V4L2_FIELD_ANY == field) { if (V4L2_FIELD_ANY == field) {
field = V4L2_FIELD_NONE; field = V4L2_FIELD_NONE;
SAM("prefer: V4L2_FIELD_NONE=field, was V4L2_FIELD_ANY\n"); SAM("prefer: V4L2_FIELD_NONE=field, was V4L2_FIELD_ANY\n");
} }
peasycap_best_format = NULL; peasycap_best_format = NULL;
peasycap_format = &easycap_format[0]; peasycap_format = &easycap_format[0];
while (0 != peasycap_format->v4l2_format.fmt.pix.width) { while (0 != peasycap_format->v4l2_format.fmt.pix.width) {
JOM(16, ".> %i %i 0x%08X %ix%i\n", JOM(16, ".> %i %i 0x%08X %ix%i\n",
peasycap_format->mask & 0x01, peasycap_format->mask & 0x01,
peasycap_format->v4l2_format.fmt.pix.field, peasycap_format->v4l2_format.fmt.pix.field,
peasycap_format->v4l2_format.fmt.pix.pixelformat, peasycap_format->v4l2_format.fmt.pix.pixelformat,
peasycap_format->v4l2_format.fmt.pix.width, peasycap_format->v4l2_format.fmt.pix.width,
peasycap_format->v4l2_format.fmt.pix.height); peasycap_format->v4l2_format.fmt.pix.height);
if (((peasycap_format->mask & 0x1F) == (mask & 0x1F)) && if (((peasycap_format->mask & 0x1F) == (mask & 0x1F)) &&
(peasycap_format->v4l2_format.fmt.pix.field == field) && (peasycap_format->v4l2_format.fmt.pix.field == field) &&
(peasycap_format->v4l2_format.fmt.pix.pixelformat == (peasycap_format->v4l2_format.fmt.pix.pixelformat == pixelformat) &&
pixelformat) && (peasycap_format->v4l2_format.fmt.pix.width == width) &&
(peasycap_format->v4l2_format.fmt.pix.width == width) && (peasycap_format->v4l2_format.fmt.pix.height == height)) {
(peasycap_format->v4l2_format.fmt.pix.height == height)) {
peasycap_best_format = peasycap_format; peasycap_best_format = peasycap_format;
break; break;
} }
peasycap_format++; peasycap_format++;
} }
if (0 == peasycap_format->v4l2_format.fmt.pix.width) { if (0 == peasycap_format->v4l2_format.fmt.pix.width) {
SAM("cannot do: %ix%i with standard mask 0x%02X\n", SAM("cannot do: %ix%i with standard mask 0x%02X\n",
width, height, mask); width, height, mask);
peasycap_format = &easycap_format[0]; best = -1; peasycap_format = &easycap_format[0];
while (0 != peasycap_format->v4l2_format.fmt.pix.width) { best = -1;
if (((peasycap_format->mask & 0x1F) == (mask & 0x1F)) && while (0 != peasycap_format->v4l2_format.fmt.pix.width) {
(peasycap_format->v4l2_format.fmt.pix if (((peasycap_format->mask & 0x1F) == (mask & 0x1F)) &&
.field == field) && (peasycap_format->v4l2_format.fmt.pix.field == field) &&
(peasycap_format->v4l2_format.fmt.pix (peasycap_format->v4l2_format.fmt.pix.pixelformat == pixelformat)) {
.pixelformat == pixelformat)) {
miss = abs(peasycap_format-> miss = abs(peasycap_format->v4l2_format.fmt.pix.width - width);
v4l2_format.fmt.pix.width - width); if ((best > miss) || (best < 0)) {
if ((best > miss) || (best < 0)) { best = miss;
best = miss; peasycap_best_format = peasycap_format;
peasycap_best_format = peasycap_format; if (!miss)
if (!miss) break;
break; }
} }
peasycap_format++;
}
if (-1 == best) {
SAM("cannot do %ix... with standard mask 0x%02X\n",
width, mask);
SAM("cannot do ...x%i with standard mask 0x%02X\n",
height, mask);
SAM(" %ix%i unmatched\n", width, height);
return peasycap->format_offset;
} }
peasycap_format++;
} }
if (-1 == best) { if (NULL == peasycap_best_format) {
SAM("cannot do %ix... with standard mask 0x%02X\n", SAM("MISTAKE: peasycap_best_format is NULL");
width, mask); return -EINVAL;
SAM("cannot do ...x%i with standard mask 0x%02X\n",
height, mask);
SAM(" %ix%i unmatched\n", width, height);
return peasycap->format_offset;
} }
} peasycap_format = peasycap_best_format;
if (NULL == peasycap_best_format) {
SAM("MISTAKE: peasycap_best_format is NULL");
return -EINVAL;
}
peasycap_format = peasycap_best_format;
/*...........................................................................*/ /*...........................................................................*/
if (true == try) if (try)
return (int)(peasycap_best_format - &easycap_format[0]); return peasycap_best_format - easycap_format;
/*...........................................................................*/ /*...........................................................................*/
if (false != try) { if (false != try) {
SAM("MISTAKE: true==try where is should be false\n"); SAM("MISTAKE: true==try where is should be false\n");
return -EINVAL; return -EINVAL;
} }
SAM("actioning: %ix%i %s\n", SAM("actioning: %ix%i %s\n",
peasycap_format->v4l2_format.fmt.pix.width, peasycap_format->v4l2_format.fmt.pix.width,
peasycap_format->v4l2_format.fmt.pix.height, peasycap_format->v4l2_format.fmt.pix.height,
&peasycap_format->name[0]); &peasycap_format->name[0]);
peasycap->height = peasycap_format->v4l2_format.fmt.pix.height; peasycap->height = peasycap_format->v4l2_format.fmt.pix.height;
peasycap->width = peasycap_format->v4l2_format.fmt.pix.width; peasycap->width = peasycap_format->v4l2_format.fmt.pix.width;
peasycap->pixelformat = peasycap_format->v4l2_format.fmt.pix.pixelformat; peasycap->pixelformat = peasycap_format->v4l2_format.fmt.pix.pixelformat;
peasycap->format_offset = (int)(peasycap_format - &easycap_format[0]); peasycap->format_offset = peasycap_format - easycap_format;
for (k = 0; k < INPUT_MANY; k++) { for (k = 0; k < INPUT_MANY; k++) {
if (!peasycap->inputset[k].format_offset_ok) { if (!peasycap->inputset[k].format_offset_ok) {
peasycap->inputset[k].format_offset = peasycap->inputset[k].format_offset =
peasycap->format_offset; peasycap->format_offset;
}
} }
} if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) { peasycap->inputset[peasycap->input].format_offset =
peasycap->inputset[peasycap->input].format_offset = peasycap->format_offset;
peasycap->format_offset; peasycap->inputset[peasycap->input].format_offset_ok = 1;
peasycap->inputset[peasycap->input].format_offset_ok = 1; } else
} else JOM(8, "%i=peasycap->input\n", peasycap->input);
JOM(8, "%i=peasycap->input\n", peasycap->input);
peasycap->bytesperpixel = (0x00E0 & peasycap_format->mask) >> 5 ;
peasycap->bytesperpixel = (0x00E0 & peasycap_format->mask) >> 5 ; if (0x0100 & peasycap_format->mask)
if (0x0100 & peasycap_format->mask) peasycap->byteswaporder = true;
peasycap->byteswaporder = true; else
else peasycap->byteswaporder = false;
peasycap->byteswaporder = false; if (0x0200 & peasycap_format->mask)
if (0x0200 & peasycap_format->mask) peasycap->skip = 5;
peasycap->skip = 5; else
else peasycap->skip = 0;
peasycap->skip = 0; if (0x0800 & peasycap_format->mask)
if (0x0800 & peasycap_format->mask) peasycap->decimatepixel = true;
peasycap->decimatepixel = true; else
else peasycap->decimatepixel = false;
peasycap->decimatepixel = false; if (0x1000 & peasycap_format->mask)
if (0x1000 & peasycap_format->mask) peasycap->offerfields = true;
peasycap->offerfields = true; else
else peasycap->offerfields = false;
peasycap->offerfields = false; if (true == peasycap->decimatepixel)
if (true == peasycap->decimatepixel) multiplier = 2;
multiplier = 2; else
else multiplier = 1;
multiplier = 1; peasycap->videofieldamount =
peasycap->videofieldamount = multiplier * peasycap->width * multiplier * peasycap->width * multiplier * peasycap->height;
multiplier * peasycap->height; peasycap->frame_buffer_used =
peasycap->frame_buffer_used = peasycap->bytesperpixel * peasycap->bytesperpixel * peasycap->width * peasycap->height;
peasycap->width * peasycap->height; if (peasycap->video_isoc_streaming) {
if (peasycap->video_isoc_streaming) { resubmit = true;
resubmit = true; kill_video_urbs(peasycap);
kill_video_urbs(peasycap); } else
} else resubmit = false;
resubmit = false;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* PAL * PAL
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
if (0 == (0x01 & peasycap_format->mask)) { if (0 == (0x01 & peasycap_format->mask)) {
if (((720 == peasycap_format->v4l2_format.fmt.pix.width) && if (((720 == peasycap_format->v4l2_format.fmt.pix.width) &&
(576 == (576 == peasycap_format->v4l2_format.fmt.pix.height)) ||
peasycap_format->v4l2_format.fmt.pix.height)) || ((360 == peasycap_format->v4l2_format.fmt.pix.width) &&
((360 == (288 == peasycap_format->v4l2_format.fmt.pix.height))) {
peasycap_format->v4l2_format.fmt.pix.width) && if (set_resolution(p, 0x0000, 0x0001, 0x05A0, 0x0121)) {
(288 == SAM("ERROR: set_resolution() failed\n");
peasycap_format->v4l2_format.fmt.pix.height))) { return -EINVAL;
if (0 != set_resolution(p, 0x0000, 0x0001, 0x05A0, 0x0121)) { }
SAM("ERROR: set_resolution() failed\n"); } else if ((704 == peasycap_format->v4l2_format.fmt.pix.width) &&
return -EINVAL; (576 == peasycap_format->v4l2_format.fmt.pix.height)) {
} if (set_resolution(p, 0x0004, 0x0001, 0x0584, 0x0121)) {
} else if ((704 == peasycap_format->v4l2_format.fmt.pix.width) && SAM("ERROR: set_resolution() failed\n");
(576 == peasycap_format->v4l2_format.fmt.pix.height)) { return -EINVAL;
if (0 != set_resolution(p, 0x0004, 0x0001, 0x0584, 0x0121)) { }
SAM("ERROR: set_resolution() failed\n"); } else if (((640 == peasycap_format->v4l2_format.fmt.pix.width) &&
return -EINVAL; (480 == peasycap_format->v4l2_format.fmt.pix.height)) ||
} ((320 == peasycap_format->v4l2_format.fmt.pix.width) &&
} else if (((640 == peasycap_format->v4l2_format.fmt.pix.width) && (240 == peasycap_format->v4l2_format.fmt.pix.height))) {
(480 == if (set_resolution(p, 0x0014, 0x0020, 0x0514, 0x0110)) {
peasycap_format->v4l2_format.fmt.pix.height)) || SAM("ERROR: set_resolution() failed\n");
((320 == return -EINVAL;
peasycap_format->v4l2_format.fmt.pix.width) && }
(240 == } else {
peasycap_format->v4l2_format.fmt.pix.height))) { SAM("MISTAKE: bad format, cannot set resolution\n");
if (0 != set_resolution(p, 0x0014, 0x0020, 0x0514, 0x0110)) {
SAM("ERROR: set_resolution() failed\n");
return -EINVAL; return -EINVAL;
} }
} else {
SAM("MISTAKE: bad format, cannot set resolution\n");
return -EINVAL;
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* NTSC * NTSC
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
} else { } else {
if (((720 == peasycap_format->v4l2_format.fmt.pix.width) && if (((720 == peasycap_format->v4l2_format.fmt.pix.width) &&
(480 == (480 == peasycap_format->v4l2_format.fmt.pix.height)) ||
peasycap_format->v4l2_format.fmt.pix.height)) || ((360 == peasycap_format->v4l2_format.fmt.pix.width) &&
((360 == (240 == peasycap_format->v4l2_format.fmt.pix.height))) {
peasycap_format->v4l2_format.fmt.pix.width) && if (set_resolution(p, 0x0000, 0x0003, 0x05A0, 0x00F3)) {
(240 == SAM("ERROR: set_resolution() failed\n");
peasycap_format->v4l2_format.fmt.pix.height))) { return -EINVAL;
if (0 != set_resolution(p, 0x0000, 0x0003, 0x05A0, 0x00F3)) { }
SAM("ERROR: set_resolution() failed\n"); } else if (((640 == peasycap_format->v4l2_format.fmt.pix.width) &&
return -EINVAL; (480 == peasycap_format->v4l2_format.fmt.pix.height)) ||
} ((320 == peasycap_format->v4l2_format.fmt.pix.width) &&
} else if (((640 == peasycap_format->v4l2_format.fmt.pix.width) && (240 == peasycap_format->v4l2_format.fmt.pix.height))) {
(480 == if (set_resolution(p, 0x0014, 0x0003, 0x0514, 0x00F3)) {
peasycap_format->v4l2_format.fmt.pix.height)) || SAM("ERROR: set_resolution() failed\n");
((320 == return -EINVAL;
peasycap_format->v4l2_format.fmt.pix.width) && }
(240 == } else {
peasycap_format->v4l2_format.fmt.pix.height))) { SAM("MISTAKE: bad format, cannot set resolution\n");
if (0 != set_resolution(p, 0x0014, 0x0003, 0x0514, 0x00F3)) {
SAM("ERROR: set_resolution() failed\n");
return -EINVAL; return -EINVAL;
} }
} else {
SAM("MISTAKE: bad format, cannot set resolution\n");
return -EINVAL;
} }
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
if (true == resubmit) if (resubmit)
submit_video_urbs(peasycap); submit_video_urbs(peasycap);
return (int)(peasycap_best_format - &easycap_format[0]);
return peasycap_best_format - easycap_format;
} }
/*****************************************************************************/ /*****************************************************************************/
int adjust_brightness(struct easycap *peasycap, int value) int adjust_brightness(struct easycap *peasycap, int value)
{ {
unsigned int mood; unsigned int mood;
int i1, k; int i1, k;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
i1 = 0; i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (V4L2_CID_BRIGHTNESS == easycap_control[i1].id) { if (V4L2_CID_BRIGHTNESS == easycap_control[i1].id) {
if ((easycap_control[i1].minimum > value) || if ((easycap_control[i1].minimum > value) ||
(easycap_control[i1].maximum < value)) (easycap_control[i1].maximum < value))
value = easycap_control[i1].default_value; value = easycap_control[i1].default_value;
if ((easycap_control[i1].minimum <= peasycap->brightness) && if ((easycap_control[i1].minimum <= peasycap->brightness) &&
(easycap_control[i1].maximum >= (easycap_control[i1].maximum >= peasycap->brightness)) {
peasycap->brightness)) { if (peasycap->brightness == value) {
if (peasycap->brightness == value) { SAM("unchanged brightness at 0x%02X\n",
SAM("unchanged brightness at 0x%02X\n", value);
value); return 0;
}
}
peasycap->brightness = value;
for (k = 0; k < INPUT_MANY; k++) {
if (!peasycap->inputset[k].brightness_ok)
peasycap->inputset[k].brightness =
peasycap->brightness;
}
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
peasycap->inputset[peasycap->input].brightness =
peasycap->brightness;
peasycap->inputset[peasycap->input].brightness_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int)peasycap->brightness;
if (!write_saa(peasycap->pusb_device, 0x0A, mood)) {
SAM("adjusting brightness to 0x%02X\n", mood);
return 0; return 0;
} else {
SAM("WARNING: failed to adjust brightness "
"to 0x%02X\n", mood);
return -ENOENT;
} }
break;
} }
peasycap->brightness = value; i1++;
for (k = 0; k < INPUT_MANY; k++) {
if (!peasycap->inputset[k].brightness_ok)
peasycap->inputset[k].brightness =
peasycap->brightness;
}
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
peasycap->inputset[peasycap->input].brightness =
peasycap->brightness;
peasycap->inputset[peasycap->input].brightness_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int)peasycap->brightness;
if (!write_saa(peasycap->pusb_device, 0x0A, mood)) {
SAM("adjusting brightness to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust brightness "
"to 0x%02X\n", mood);
return -ENOENT;
}
break;
} }
i1++; SAM("WARNING: failed to adjust brightness: control not found\n");
} return -ENOENT;
SAM("WARNING: failed to adjust brightness: control not found\n");
return -ENOENT;
} }
/*****************************************************************************/ /*****************************************************************************/
int adjust_contrast(struct easycap *peasycap, int value) int adjust_contrast(struct easycap *peasycap, int value)
{ {
unsigned int mood; unsigned int mood;
int i1, k; int i1, k;
if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n");
return -EFAULT;
}
if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT;
}
i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) {
if (V4L2_CID_CONTRAST == easycap_control[i1].id) {
if ((easycap_control[i1].minimum > value) ||
(easycap_control[i1].maximum < value))
value = easycap_control[i1].default_value;
if ((easycap_control[i1].minimum <= peasycap->contrast) && if (NULL == peasycap) {
(easycap_control[i1].maximum >= SAY("ERROR: peasycap is NULL\n");
peasycap->contrast)) { return -EFAULT;
if (peasycap->contrast == value) { }
SAM("unchanged contrast at 0x%02X\n", value); if (NULL == peasycap->pusb_device) {
return 0; SAM("ERROR: peasycap->pusb_device is NULL\n");
} return -EFAULT;
} }
peasycap->contrast = value; i1 = 0;
for (k = 0; k < INPUT_MANY; k++) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (!peasycap->inputset[k].contrast_ok) { if (V4L2_CID_CONTRAST == easycap_control[i1].id) {
peasycap->inputset[k].contrast = if ((easycap_control[i1].minimum > value) ||
peasycap->contrast; (easycap_control[i1].maximum < value))
} value = easycap_control[i1].default_value;
}
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
peasycap->inputset[peasycap->input].contrast = if ((easycap_control[i1].minimum <= peasycap->contrast) &&
peasycap->contrast; (easycap_control[i1].maximum >= peasycap->contrast)) {
peasycap->inputset[peasycap->input].contrast_ok = 1; if (peasycap->contrast == value) {
} else SAM("unchanged contrast at 0x%02X\n", value);
JOM(8, "%i=peasycap->input\n", peasycap->input); return 0;
mood = 0x00FF & (unsigned int) (peasycap->contrast - 128); }
if (!write_saa(peasycap->pusb_device, 0x0B, mood)) { }
SAM("adjusting contrast to 0x%02X\n", mood); peasycap->contrast = value;
return 0; for (k = 0; k < INPUT_MANY; k++) {
} else { if (!peasycap->inputset[k].contrast_ok)
SAM("WARNING: failed to adjust contrast to " peasycap->inputset[k].contrast = peasycap->contrast;
"0x%02X\n", mood); }
return -ENOENT;
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
peasycap->inputset[peasycap->input].contrast =
peasycap->contrast;
peasycap->inputset[peasycap->input].contrast_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->contrast - 128);
if (!write_saa(peasycap->pusb_device, 0x0B, mood)) {
SAM("adjusting contrast to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust contrast to "
"0x%02X\n", mood);
return -ENOENT;
}
break;
} }
break; i1++;
} }
i1++; SAM("WARNING: failed to adjust contrast: control not found\n");
} return -ENOENT;
SAM("WARNING: failed to adjust contrast: control not found\n");
return -ENOENT;
} }
/*****************************************************************************/ /*****************************************************************************/
int adjust_saturation(struct easycap *peasycap, int value) int adjust_saturation(struct easycap *peasycap, int value)
{ {
unsigned int mood; unsigned int mood;
int i1, k; int i1, k;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
i1 = 0; i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (V4L2_CID_SATURATION == easycap_control[i1].id) { if (V4L2_CID_SATURATION == easycap_control[i1].id) {
if ((easycap_control[i1].minimum > value) || if ((easycap_control[i1].minimum > value) ||
(easycap_control[i1].maximum < value)) (easycap_control[i1].maximum < value))
value = easycap_control[i1].default_value; value = easycap_control[i1].default_value;
if ((easycap_control[i1].minimum <= peasycap->saturation) && if ((easycap_control[i1].minimum <= peasycap->saturation) &&
(easycap_control[i1].maximum >= (easycap_control[i1].maximum >= peasycap->saturation)) {
peasycap->saturation)) { if (peasycap->saturation == value) {
if (peasycap->saturation == value) { SAM("unchanged saturation at 0x%02X\n",
SAM("unchanged saturation at 0x%02X\n", value);
value); return 0;
return 0; }
} }
} peasycap->saturation = value;
peasycap->saturation = value; for (k = 0; k < INPUT_MANY; k++) {
for (k = 0; k < INPUT_MANY; k++) { if (!peasycap->inputset[k].saturation_ok)
if (!peasycap->inputset[k].saturation_ok) { peasycap->inputset[k].saturation =
peasycap->inputset[k].saturation = peasycap->saturation;
peasycap->saturation;
} }
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
peasycap->inputset[peasycap->input].saturation =
peasycap->saturation;
peasycap->inputset[peasycap->input].saturation_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->saturation - 128);
if (!write_saa(peasycap->pusb_device, 0x0C, mood)) {
SAM("adjusting saturation to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust saturation to "
"0x%02X\n", mood);
return -ENOENT;
}
break;
} }
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) { i1++;
peasycap->inputset[peasycap->input].saturation =
peasycap->saturation;
peasycap->inputset[peasycap->input].saturation_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->saturation - 128);
if (!write_saa(peasycap->pusb_device, 0x0C, mood)) {
SAM("adjusting saturation to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust saturation to "
"0x%02X\n", mood);
return -ENOENT;
}
break;
} }
i1++; SAM("WARNING: failed to adjust saturation: control not found\n");
} return -ENOENT;
SAM("WARNING: failed to adjust saturation: control not found\n");
return -ENOENT;
} }
/*****************************************************************************/ /*****************************************************************************/
int adjust_hue(struct easycap *peasycap, int value) int adjust_hue(struct easycap *peasycap, int value)
{ {
unsigned int mood; unsigned int mood;
int i1, i2, k; int i1, i2, k;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
i1 = 0; i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (V4L2_CID_HUE == easycap_control[i1].id) { if (V4L2_CID_HUE == easycap_control[i1].id) {
if ((easycap_control[i1].minimum > value) || if ((easycap_control[i1].minimum > value) ||
(easycap_control[i1].maximum < value)) (easycap_control[i1].maximum < value))
value = easycap_control[i1].default_value; value = easycap_control[i1].default_value;
if ((easycap_control[i1].minimum <= peasycap->hue) && if ((easycap_control[i1].minimum <= peasycap->hue) &&
(easycap_control[i1].maximum >= (easycap_control[i1].maximum >= peasycap->hue)) {
peasycap->hue)) { if (peasycap->hue == value) {
if (peasycap->hue == value) { SAM("unchanged hue at 0x%02X\n", value);
SAM("unchanged hue at 0x%02X\n", value); return 0;
}
}
peasycap->hue = value;
for (k = 0; k < INPUT_MANY; k++) {
if (!peasycap->inputset[k].hue_ok)
peasycap->inputset[k].hue = peasycap->hue;
}
if (0 <= peasycap->input && INPUT_MANY > peasycap->input) {
peasycap->inputset[peasycap->input].hue = peasycap->hue;
peasycap->inputset[peasycap->input].hue_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
i2 = peasycap->hue - 128;
mood = 0x00FF & ((int) i2);
if (!write_saa(peasycap->pusb_device, 0x0D, mood)) {
SAM("adjusting hue to 0x%02X\n", mood);
return 0; return 0;
} else {
SAM("WARNING: failed to adjust hue to 0x%02X\n", mood);
return -ENOENT;
} }
break;
} }
peasycap->hue = value; i1++;
for (k = 0; k < INPUT_MANY; k++) {
if (!peasycap->inputset[k].hue_ok)
peasycap->inputset[k].hue = peasycap->hue;
}
if ((0 <= peasycap->input) && (INPUT_MANY > peasycap->input)) {
peasycap->inputset[peasycap->input].hue =
peasycap->hue;
peasycap->inputset[peasycap->input].hue_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
i2 = peasycap->hue - 128;
mood = 0x00FF & ((int) i2);
if (!write_saa(peasycap->pusb_device, 0x0D, mood)) {
SAM("adjusting hue to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust hue to 0x%02X\n", mood);
return -ENOENT;
}
break;
} }
i1++; SAM("WARNING: failed to adjust hue: control not found\n");
} return -ENOENT;
SAM("WARNING: failed to adjust hue: control not found\n");
return -ENOENT;
} }
/*****************************************************************************/ /*****************************************************************************/
int adjust_volume(struct easycap *peasycap, int value) int adjust_volume(struct easycap *peasycap, int value)
{ {
s8 mood; s8 mood;
int i1; int i1;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
i1 = 0; i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (V4L2_CID_AUDIO_VOLUME == easycap_control[i1].id) { if (V4L2_CID_AUDIO_VOLUME == easycap_control[i1].id) {
if ((easycap_control[i1].minimum > value) || if ((easycap_control[i1].minimum > value) ||
(easycap_control[i1].maximum < value)) (easycap_control[i1].maximum < value))
value = easycap_control[i1].default_value; value = easycap_control[i1].default_value;
if ((easycap_control[i1].minimum <= peasycap->volume) &&
(easycap_control[i1].maximum >= if ((easycap_control[i1].minimum <= peasycap->volume) &&
peasycap->volume)) { (easycap_control[i1].maximum >= peasycap->volume)) {
if (peasycap->volume == value) { if (peasycap->volume == value) {
SAM("unchanged volume at 0x%02X\n", value); SAM("unchanged volume at 0x%02X\n", value);
return 0;
}
}
peasycap->volume = value;
mood = (16 > peasycap->volume) ? 16 :
((31 < peasycap->volume) ? 31 :
(s8) peasycap->volume);
if (!audio_gainset(peasycap->pusb_device, mood)) {
SAM("adjusting volume to 0x%02X\n", mood);
return 0; return 0;
} else {
SAM("WARNING: failed to adjust volume to "
"0x%2X\n", mood);
return -ENOENT;
} }
break;
} }
peasycap->volume = value; i1++;
mood = (16 > peasycap->volume) ? 16 :
((31 < peasycap->volume) ? 31 :
(s8) peasycap->volume);
if (!audio_gainset(peasycap->pusb_device, mood)) {
SAM("adjusting volume to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust volume to "
"0x%2X\n", mood);
return -ENOENT;
}
break;
} }
i1++; SAM("WARNING: failed to adjust volume: control not found\n");
} return -ENOENT;
SAM("WARNING: failed to adjust volume: control not found\n");
return -ENOENT;
} }
/*****************************************************************************/ /*****************************************************************************/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -913,1550 +914,1566 @@ return -ENOENT; ...@@ -913,1550 +914,1566 @@ return -ENOENT;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int adjust_mute(struct easycap *peasycap, int value) static int adjust_mute(struct easycap *peasycap, int value)
{ {
int i1; int i1;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
i1 = 0; i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (V4L2_CID_AUDIO_MUTE == easycap_control[i1].id) { if (V4L2_CID_AUDIO_MUTE == easycap_control[i1].id) {
peasycap->mute = value; peasycap->mute = value;
switch (peasycap->mute) { switch (peasycap->mute) {
case 1: { case 1: {
peasycap->audio_idle = 1; peasycap->audio_idle = 1;
peasycap->timeval0.tv_sec = 0; peasycap->timeval0.tv_sec = 0;
SAM("adjusting mute: %i=peasycap->audio_idle\n", SAM("adjusting mute: %i=peasycap->audio_idle\n",
peasycap->audio_idle); peasycap->audio_idle);
return 0; return 0;
} }
default: { default: {
peasycap->audio_idle = 0; peasycap->audio_idle = 0;
SAM("adjusting mute: %i=peasycap->audio_idle\n", SAM("adjusting mute: %i=peasycap->audio_idle\n",
peasycap->audio_idle); peasycap->audio_idle);
return 0; return 0;
} }
}
break;
} }
break; i1++;
} }
i1++; SAM("WARNING: failed to adjust mute: control not found\n");
} return -ENOENT;
SAM("WARNING: failed to adjust mute: control not found\n");
return -ENOENT;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
long easycap_unlocked_ioctl(struct file *file, long easycap_unlocked_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct easycap *peasycap; struct easycap *peasycap;
struct usb_device *p; struct usb_device *p;
int kd; int kd;
if (NULL == file) {
SAY("ERROR: file is NULL\n");
return -ERESTARTSYS;
}
peasycap = file->private_data;
if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n");
return -1;
}
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n");
return -EFAULT;
}
p = peasycap->pusb_device;
if (NULL == p) {
SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT;
}
kd = isdongle(peasycap);
if (0 <= kd && DONGLE_MANY > kd) {
if (mutex_lock_interruptible(&easycapdc60_dongle[kd].mutex_video)) {
SAY("ERROR: cannot lock "
"easycapdc60_dongle[%i].mutex_video\n", kd);
return -ERESTARTSYS;
}
JOM(4, "locked easycapdc60_dongle[%i].mutex_video\n", kd);
/*---------------------------------------------------------------------------*/
/*
* MEANWHILE, easycap_usb_disconnect() MAY HAVE FREED POINTER peasycap,
* IN WHICH CASE A REPEAT CALL TO isdongle() WILL FAIL.
* IF NECESSARY, BAIL OUT.
*/
/*---------------------------------------------------------------------------*/
if (kd != isdongle(peasycap))
return -ERESTARTSYS;
if (NULL == file) { if (NULL == file) {
SAY("ERROR: file is NULL\n"); SAY("ERROR: file is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
peasycap = file->private_data; peasycap = file->private_data;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -1;
return -ERESTARTSYS;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
p = peasycap->pusb_device; p = peasycap->pusb_device;
if (NULL == peasycap->pusb_device) { if (NULL == p) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); return -EFAULT;
return -ERESTARTSYS;
} }
} else { kd = isdongle(peasycap);
if (0 <= kd && DONGLE_MANY > kd) {
if (mutex_lock_interruptible(&easycapdc60_dongle[kd].mutex_video)) {
SAY("ERROR: cannot lock "
"easycapdc60_dongle[%i].mutex_video\n", kd);
return -ERESTARTSYS;
}
JOM(4, "locked easycapdc60_dongle[%i].mutex_video\n", kd);
/*---------------------------------------------------------------------------*/
/*
* MEANWHILE, easycap_usb_disconnect() MAY HAVE FREED POINTER peasycap,
* IN WHICH CASE A REPEAT CALL TO isdongle() WILL FAIL.
* IF NECESSARY, BAIL OUT.
*/
/*---------------------------------------------------------------------------*/
if (kd != isdongle(peasycap))
return -ERESTARTSYS;
if (NULL == file) {
SAY("ERROR: file is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ERESTARTSYS;
}
peasycap = file->private_data;
if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ERESTARTSYS;
}
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
p = peasycap->pusb_device;
if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ERESTARTSYS;
}
} else {
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* IF easycap_usb_disconnect() HAS ALREADY FREED POINTER peasycap BEFORE THE * IF easycap_usb_disconnect() HAS ALREADY FREED POINTER peasycap BEFORE THE
* ATTEMPT TO ACQUIRE THE SEMAPHORE, isdongle() WILL HAVE FAILED. BAIL OUT. * ATTEMPT TO ACQUIRE THE SEMAPHORE, isdongle() WILL HAVE FAILED. BAIL OUT.
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
return -ERESTARTSYS; return -ERESTARTSYS;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
switch (cmd) { switch (cmd) {
case VIDIOC_QUERYCAP: { case VIDIOC_QUERYCAP: {
struct v4l2_capability v4l2_capability; struct v4l2_capability v4l2_capability;
char version[16], *p1, *p2; char version[16], *p1, *p2;
int i, rc, k[3]; int i, rc, k[3];
long lng; long lng;
JOM(8, "VIDIOC_QUERYCAP\n"); JOM(8, "VIDIOC_QUERYCAP\n");
if (16 <= strlen(EASYCAP_DRIVER_VERSION)) { if (16 <= strlen(EASYCAP_DRIVER_VERSION)) {
SAM("ERROR: bad driver version string\n"); SAM("ERROR: bad driver version string\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
strcpy(&version[0], EASYCAP_DRIVER_VERSION); strcpy(&version[0], EASYCAP_DRIVER_VERSION);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
k[i] = 0; k[i] = 0;
p2 = &version[0]; i = 0; p2 = &version[0];
while (*p2) { i = 0;
p1 = p2; while (*p2) {
while (*p2 && ('.' != *p2)) p1 = p2;
p2++; while (*p2 && ('.' != *p2))
if (*p2) p2++;
*p2++ = 0; if (*p2)
if (3 > i) { *p2++ = 0;
rc = (int) strict_strtol(p1, 10, &lng); if (3 > i) {
if (rc) { rc = (int) strict_strtol(p1, 10, &lng);
SAM("ERROR: %i=strict_strtol(%s,.,,)\n", if (rc) {
rc, p1); SAM("ERROR: %i=strict_strtol(%s,.,,)\n",
mutex_unlock(&easycapdc60_dongle[kd]. rc, p1);
mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
}
k[i] = (int)lng;
} }
k[i] = (int)lng; i++;
} }
i++;
}
memset(&v4l2_capability, 0, sizeof(struct v4l2_capability)); memset(&v4l2_capability, 0, sizeof(struct v4l2_capability));
strlcpy(&v4l2_capability.driver[0], "easycap", strlcpy(&v4l2_capability.driver[0],
sizeof(v4l2_capability.driver)); "easycap", sizeof(v4l2_capability.driver));
v4l2_capability.capabilities = v4l2_capability.capabilities = V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_STREAMING |
V4L2_CAP_AUDIO | V4L2_CAP_READWRITE; V4L2_CAP_AUDIO |
V4L2_CAP_READWRITE;
v4l2_capability.version = KERNEL_VERSION(k[0], k[1], k[2]); v4l2_capability.version = KERNEL_VERSION(k[0], k[1], k[2]);
JOM(8, "v4l2_capability.version=(%i,%i,%i)\n", k[0], k[1], k[2]); JOM(8, "v4l2_capability.version=(%i,%i,%i)\n", k[0], k[1], k[2]);
strlcpy(&v4l2_capability.card[0], "EasyCAP DC60", strlcpy(&v4l2_capability.card[0],
sizeof(v4l2_capability.card)); "EasyCAP DC60", sizeof(v4l2_capability.card));
if (usb_make_path(peasycap->pusb_device, &v4l2_capability.bus_info[0], if (usb_make_path(peasycap->pusb_device,
&v4l2_capability.bus_info[0],
sizeof(v4l2_capability.bus_info)) < 0) { sizeof(v4l2_capability.bus_info)) < 0) {
strlcpy(&v4l2_capability.bus_info[0], "EasyCAP bus_info",
sizeof(v4l2_capability.bus_info)); strlcpy(&v4l2_capability.bus_info[0], "EasyCAP bus_info",
JOM(8, "%s=v4l2_capability.bus_info\n", sizeof(v4l2_capability.bus_info));
&v4l2_capability.bus_info[0]); JOM(8, "%s=v4l2_capability.bus_info\n",
} &v4l2_capability.bus_info[0]);
if (0 != copy_to_user((void __user *)arg, &v4l2_capability, }
sizeof(struct v4l2_capability))) { if (copy_to_user((void __user *)arg, &v4l2_capability,
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); sizeof(struct v4l2_capability))) {
return -EFAULT; mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_ENUMINPUT: { case VIDIOC_ENUMINPUT: {
struct v4l2_input v4l2_input; struct v4l2_input v4l2_input;
u32 index; u32 index;
JOM(8, "VIDIOC_ENUMINPUT\n"); JOM(8, "VIDIOC_ENUMINPUT\n");
if (0 != copy_from_user(&v4l2_input, (void __user *)arg, if (copy_from_user(&v4l2_input, (void __user *)arg,
sizeof(struct v4l2_input))) { sizeof(struct v4l2_input))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
index = v4l2_input.index; index = v4l2_input.index;
memset(&v4l2_input, 0, sizeof(struct v4l2_input)); memset(&v4l2_input, 0, sizeof(struct v4l2_input));
switch (index) {
case 0: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS0");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 1: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS1");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 2: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS2");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 3: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS3");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 4: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS4");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 5: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "S-VIDEO");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
default: {
JOM(8, "%i=index: exhausts inputs\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
if (0 != copy_to_user((void __user *)arg, &v4l2_input, switch (index) {
sizeof(struct v4l2_input))) { case 0: {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); v4l2_input.index = index;
return -EFAULT; strcpy(&v4l2_input.name[0], "CVBS0");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL |
V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 1: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS1");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 2: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS2");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 3: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS3");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 4: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "CVBS4");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
case 5: {
v4l2_input.index = index;
strcpy(&v4l2_input.name[0], "S-VIDEO");
v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
v4l2_input.audioset = 0x01;
v4l2_input.tuner = 0;
v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
V4L2_STD_NTSC ;
v4l2_input.status = 0;
JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
break;
}
default: {
JOM(8, "%i=index: exhausts inputs\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
if (copy_to_user((void __user *)arg, &v4l2_input,
sizeof(struct v4l2_input))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_INPUT: { case VIDIOC_G_INPUT: {
u32 index; u32 index;
JOM(8, "VIDIOC_G_INPUT\n"); JOM(8, "VIDIOC_G_INPUT\n");
index = (u32)peasycap->input; index = (u32)peasycap->input;
JOM(8, "user is told: %i\n", index); JOM(8, "user is told: %i\n", index);
if (0 != copy_to_user((void __user *)arg, &index, sizeof(u32))) { if (copy_to_user((void __user *)arg, &index, sizeof(u32))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_INPUT: case VIDIOC_S_INPUT:
{ {
u32 index; u32 index;
int rc; int rc;
JOM(8, "VIDIOC_S_INPUT\n"); JOM(8, "VIDIOC_S_INPUT\n");
if (0 != copy_from_user(&index, (void __user *)arg, sizeof(u32))) { if (0 != copy_from_user(&index, (void __user *)arg, sizeof(u32))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
JOM(8, "user requests input %i\n", index);
if ((int)index == peasycap->input) {
SAM("requested input already in effect\n");
break;
}
JOM(8, "user requests input %i\n", index); if ((0 > index) || (INPUT_MANY <= index)) {
JOM(8, "ERROR: bad requested input: %i\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
if ((int)index == peasycap->input) { rc = newinput(peasycap, (int)index);
SAM("requested input already in effect\n"); if (0 == rc) {
JOM(8, "newinput(.,%i) OK\n", (int)index);
} else {
SAM("ERROR: newinput(.,%i) returned %i\n", (int)index, rc);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break; break;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
if ((0 > index) || (INPUT_MANY <= index)) { case VIDIOC_ENUMAUDIO: {
JOM(8, "ERROR: bad requested input: %i\n", index); JOM(8, "VIDIOC_ENUMAUDIO\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
rc = newinput(peasycap, (int)index);
if (0 == rc) {
JOM(8, "newinput(.,%i) OK\n", (int)index);
} else {
SAM("ERROR: newinput(.,%i) returned %i\n", (int)index, rc);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_ENUMAUDIO: { case VIDIOC_ENUMAUDOUT: {
JOM(8, "VIDIOC_ENUMAUDIO\n"); struct v4l2_audioout v4l2_audioout;
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_ENUMAUDOUT: {
struct v4l2_audioout v4l2_audioout;
JOM(8, "VIDIOC_ENUMAUDOUT\n"); JOM(8, "VIDIOC_ENUMAUDOUT\n");
if (0 != copy_from_user(&v4l2_audioout, (void __user *)arg, if (copy_from_user(&v4l2_audioout, (void __user *)arg,
sizeof(struct v4l2_audioout))) { sizeof(struct v4l2_audioout))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
if (0 != v4l2_audioout.index) { if (0 != v4l2_audioout.index) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
memset(&v4l2_audioout, 0, sizeof(struct v4l2_audioout)); memset(&v4l2_audioout, 0, sizeof(struct v4l2_audioout));
v4l2_audioout.index = 0; v4l2_audioout.index = 0;
strcpy(&v4l2_audioout.name[0], "Soundtrack"); strcpy(&v4l2_audioout.name[0], "Soundtrack");
if (0 != copy_to_user((void __user *)arg, &v4l2_audioout, if (copy_to_user((void __user *)arg, &v4l2_audioout,
sizeof(struct v4l2_audioout))) { sizeof(struct v4l2_audioout))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_QUERYCTRL: { case VIDIOC_QUERYCTRL: {
int i1; int i1;
struct v4l2_queryctrl v4l2_queryctrl; struct v4l2_queryctrl v4l2_queryctrl;
JOM(8, "VIDIOC_QUERYCTRL\n"); JOM(8, "VIDIOC_QUERYCTRL\n");
if (0 != copy_from_user(&v4l2_queryctrl, (void __user *)arg, if (0 != copy_from_user(&v4l2_queryctrl, (void __user *)arg,
sizeof(struct v4l2_queryctrl))) { sizeof(struct v4l2_queryctrl))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
i1 = 0; i1 = 0;
while (0xFFFFFFFF != easycap_control[i1].id) { while (0xFFFFFFFF != easycap_control[i1].id) {
if (easycap_control[i1].id == v4l2_queryctrl.id) { if (easycap_control[i1].id == v4l2_queryctrl.id) {
JOM(8, "VIDIOC_QUERYCTRL %s=easycap_control[%i]" JOM(8, "VIDIOC_QUERYCTRL %s=easycap_control[%i]"
".name\n", &easycap_control[i1].name[0], i1); ".name\n", &easycap_control[i1].name[0], i1);
memcpy(&v4l2_queryctrl, &easycap_control[i1], memcpy(&v4l2_queryctrl, &easycap_control[i1],
sizeof(struct v4l2_queryctrl)); sizeof(struct v4l2_queryctrl));
break; break;
}
i1++;
} }
i1++; if (0xFFFFFFFF == easycap_control[i1].id) {
JOM(8, "%i=index: exhausts controls\n", i1);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
if (copy_to_user((void __user *)arg, &v4l2_queryctrl,
sizeof(struct v4l2_queryctrl))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
} }
if (0xFFFFFFFF == easycap_control[i1].id) { /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
JOM(8, "%i=index: exhausts controls\n", i1); case VIDIOC_QUERYMENU: {
JOM(8, "VIDIOC_QUERYMENU unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
if (0 != copy_to_user((void __user *)arg, &v4l2_queryctrl,
sizeof(struct v4l2_queryctrl))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_QUERYMENU: {
JOM(8, "VIDIOC_QUERYMENU unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_CTRL: { case VIDIOC_G_CTRL: {
struct v4l2_control *pv4l2_control; struct v4l2_control *pv4l2_control;
JOM(8, "VIDIOC_G_CTRL\n"); JOM(8, "VIDIOC_G_CTRL\n");
pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL); pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL);
if (!pv4l2_control) { if (!pv4l2_control) {
SAM("ERROR: out of memory\n"); SAM("ERROR: out of memory\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOMEM; return -ENOMEM;
} }
if (0 != copy_from_user(pv4l2_control, (void __user *)arg, if (0 != copy_from_user(pv4l2_control, (void __user *)arg,
sizeof(struct v4l2_control))) { sizeof(struct v4l2_control))) {
kfree(pv4l2_control); kfree(pv4l2_control);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
switch (pv4l2_control->id) { switch (pv4l2_control->id) {
case V4L2_CID_BRIGHTNESS: { case V4L2_CID_BRIGHTNESS: {
pv4l2_control->value = peasycap->brightness; pv4l2_control->value = peasycap->brightness;
JOM(8, "user enquires brightness: %i\n", pv4l2_control->value); JOM(8, "user enquires brightness: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_CONTRAST: { case V4L2_CID_CONTRAST: {
pv4l2_control->value = peasycap->contrast; pv4l2_control->value = peasycap->contrast;
JOM(8, "user enquires contrast: %i\n", pv4l2_control->value); JOM(8, "user enquires contrast: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_SATURATION: { case V4L2_CID_SATURATION: {
pv4l2_control->value = peasycap->saturation; pv4l2_control->value = peasycap->saturation;
JOM(8, "user enquires saturation: %i\n", pv4l2_control->value); JOM(8, "user enquires saturation: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_HUE: { case V4L2_CID_HUE: {
pv4l2_control->value = peasycap->hue; pv4l2_control->value = peasycap->hue;
JOM(8, "user enquires hue: %i\n", pv4l2_control->value); JOM(8, "user enquires hue: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_AUDIO_VOLUME: { case V4L2_CID_AUDIO_VOLUME: {
pv4l2_control->value = peasycap->volume; pv4l2_control->value = peasycap->volume;
JOM(8, "user enquires volume: %i\n", pv4l2_control->value); JOM(8, "user enquires volume: %i\n", pv4l2_control->value);
break; break;
} }
case V4L2_CID_AUDIO_MUTE: { case V4L2_CID_AUDIO_MUTE: {
if (1 == peasycap->mute) if (1 == peasycap->mute)
pv4l2_control->value = true; pv4l2_control->value = true;
else else
pv4l2_control->value = false; pv4l2_control->value = false;
JOM(8, "user enquires mute: %i\n", pv4l2_control->value); JOM(8, "user enquires mute: %i\n", pv4l2_control->value);
break; break;
} }
default: { default: {
SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", SAM("ERROR: unknown V4L2 control: 0x%08X=id\n",
pv4l2_control->id); pv4l2_control->id);
kfree(pv4l2_control); kfree(pv4l2_control);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
} }
if (0 != copy_to_user((void __user *)arg, pv4l2_control, if (copy_to_user((void __user *)arg, pv4l2_control,
sizeof(struct v4l2_control))) { sizeof(struct v4l2_control))) {
kfree(pv4l2_control);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
kfree(pv4l2_control); kfree(pv4l2_control);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); break;
return -EFAULT;
} }
kfree(pv4l2_control);
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_CTRL: case VIDIOC_S_CTRL:
{ {
struct v4l2_control v4l2_control; struct v4l2_control v4l2_control;
JOM(8, "VIDIOC_S_CTRL\n"); JOM(8, "VIDIOC_S_CTRL\n");
if (0 != copy_from_user(&v4l2_control, (void __user *)arg, if (0 != copy_from_user(&v4l2_control, (void __user *)arg,
sizeof(struct v4l2_control))) { sizeof(struct v4l2_control))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
switch (v4l2_control.id) { switch (v4l2_control.id) {
case V4L2_CID_BRIGHTNESS: { case V4L2_CID_BRIGHTNESS: {
JOM(8, "user requests brightness %i\n", v4l2_control.value); JOM(8, "user requests brightness %i\n", v4l2_control.value);
if (0 != adjust_brightness(peasycap, v4l2_control.value)) if (0 != adjust_brightness(peasycap, v4l2_control.value))
; ;
break; break;
} }
case V4L2_CID_CONTRAST: { case V4L2_CID_CONTRAST: {
JOM(8, "user requests contrast %i\n", v4l2_control.value); JOM(8, "user requests contrast %i\n", v4l2_control.value);
if (0 != adjust_contrast(peasycap, v4l2_control.value)) if (0 != adjust_contrast(peasycap, v4l2_control.value))
; ;
break; break;
} }
case V4L2_CID_SATURATION: { case V4L2_CID_SATURATION: {
JOM(8, "user requests saturation %i\n", v4l2_control.value); JOM(8, "user requests saturation %i\n", v4l2_control.value);
if (0 != adjust_saturation(peasycap, v4l2_control.value)) if (0 != adjust_saturation(peasycap, v4l2_control.value))
; ;
break; break;
} }
case V4L2_CID_HUE: { case V4L2_CID_HUE: {
JOM(8, "user requests hue %i\n", v4l2_control.value); JOM(8, "user requests hue %i\n", v4l2_control.value);
if (0 != adjust_hue(peasycap, v4l2_control.value)) if (0 != adjust_hue(peasycap, v4l2_control.value))
; ;
break; break;
} }
case V4L2_CID_AUDIO_VOLUME: { case V4L2_CID_AUDIO_VOLUME: {
JOM(8, "user requests volume %i\n", v4l2_control.value); JOM(8, "user requests volume %i\n", v4l2_control.value);
if (0 != adjust_volume(peasycap, v4l2_control.value)) if (0 != adjust_volume(peasycap, v4l2_control.value))
; ;
break; break;
} }
case V4L2_CID_AUDIO_MUTE: { case V4L2_CID_AUDIO_MUTE: {
int mute; int mute;
JOM(8, "user requests mute %i\n", v4l2_control.value); JOM(8, "user requests mute %i\n", v4l2_control.value);
if (true == v4l2_control.value) if (true == v4l2_control.value)
mute = 1; mute = 1;
else else
mute = 0; mute = 0;
if (0 != adjust_mute(peasycap, mute)) if (0 != adjust_mute(peasycap, mute))
SAM("WARNING: failed to adjust mute to %i\n", mute); SAM("WARNING: failed to adjust mute to %i\n", mute);
break;
}
default: {
SAM("ERROR: unknown V4L2 control: 0x%08X=id\n",
v4l2_control.id);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
break; break;
} }
default: {
SAM("ERROR: unknown V4L2 control: 0x%08X=id\n",
v4l2_control.id);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_EXT_CTRLS: {
JOM(8, "VIDIOC_S_EXT_CTRLS unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_ENUM_FMT: { case VIDIOC_S_EXT_CTRLS: {
u32 index; JOM(8, "VIDIOC_S_EXT_CTRLS unsupported\n");
struct v4l2_fmtdesc v4l2_fmtdesc;
JOM(8, "VIDIOC_ENUM_FMT\n");
if (0 != copy_from_user(&v4l2_fmtdesc, (void __user *)arg,
sizeof(struct v4l2_fmtdesc))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
index = v4l2_fmtdesc.index;
memset(&v4l2_fmtdesc, 0, sizeof(struct v4l2_fmtdesc));
v4l2_fmtdesc.index = index;
v4l2_fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
switch (index) {
case 0: {
v4l2_fmtdesc.flags = 0;
strcpy(&v4l2_fmtdesc.description[0], "uyvy");
v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_UYVY;
JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
case 1: {
v4l2_fmtdesc.flags = 0;
strcpy(&v4l2_fmtdesc.description[0], "yuy2");
v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_YUYV;
JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
case 2: {
v4l2_fmtdesc.flags = 0;
strcpy(&v4l2_fmtdesc.description[0], "rgb24");
v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB24;
JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
case 3: {
v4l2_fmtdesc.flags = 0;
strcpy(&v4l2_fmtdesc.description[0], "rgb32");
v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB32;
JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
case 4: {
v4l2_fmtdesc.flags = 0;
strcpy(&v4l2_fmtdesc.description[0], "bgr24");
v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR24;
JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
case 5: {
v4l2_fmtdesc.flags = 0;
strcpy(&v4l2_fmtdesc.description[0], "bgr32");
v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR32;
JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
default: {
JOM(8, "%i=index: exhausts formats\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
}
if (0 != copy_to_user((void __user *)arg, &v4l2_fmtdesc,
sizeof(struct v4l2_fmtdesc))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* case VIDIOC_ENUM_FMT: {
* THE RESPONSE TO VIDIOC_ENUM_FRAMESIZES MUST BE CONDITIONED ON THE u32 index;
* THE CURRENT STANDARD, BECAUSE THAT IS WHAT gstreamer EXPECTS. BEWARE. struct v4l2_fmtdesc v4l2_fmtdesc;
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_ENUM_FRAMESIZES: {
u32 index;
struct v4l2_frmsizeenum v4l2_frmsizeenum;
JOM(8, "VIDIOC_ENUM_FRAMESIZES\n"); JOM(8, "VIDIOC_ENUM_FMT\n");
if (0 != copy_from_user(&v4l2_frmsizeenum, (void __user *)arg, if (0 != copy_from_user(&v4l2_fmtdesc, (void __user *)arg,
sizeof(struct v4l2_frmsizeenum))) { sizeof(struct v4l2_fmtdesc))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
index = v4l2_frmsizeenum.index; index = v4l2_fmtdesc.index;
memset(&v4l2_fmtdesc, 0, sizeof(struct v4l2_fmtdesc));
v4l2_frmsizeenum.type = (u32) V4L2_FRMSIZE_TYPE_DISCRETE; v4l2_fmtdesc.index = index;
v4l2_fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (true == peasycap->ntsc) {
switch (index) { switch (index) {
case 0: { case 0: {
v4l2_frmsizeenum.discrete.width = 640; v4l2_fmtdesc.flags = 0;
v4l2_frmsizeenum.discrete.height = 480; strcpy(&v4l2_fmtdesc.description[0], "uyvy");
JOM(8, "%i=index: %ix%i\n", index, v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_UYVY;
(int)(v4l2_frmsizeenum. JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break; break;
} }
case 1: { case 1: {
v4l2_frmsizeenum.discrete.width = 320; v4l2_fmtdesc.flags = 0;
v4l2_frmsizeenum.discrete.height = 240; strcpy(&v4l2_fmtdesc.description[0], "yuy2");
JOM(8, "%i=index: %ix%i\n", index, v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_YUYV;
(int)(v4l2_frmsizeenum. JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break; break;
} }
case 2: { case 2: {
v4l2_frmsizeenum.discrete.width = 720; v4l2_fmtdesc.flags = 0;
v4l2_frmsizeenum.discrete.height = 480; strcpy(&v4l2_fmtdesc.description[0], "rgb24");
JOM(8, "%i=index: %ix%i\n", index, v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB24;
(int)(v4l2_frmsizeenum. JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break; break;
} }
case 3: { case 3: {
v4l2_frmsizeenum.discrete.width = 360; v4l2_fmtdesc.flags = 0;
v4l2_frmsizeenum.discrete.height = 240; strcpy(&v4l2_fmtdesc.description[0], "rgb32");
JOM(8, "%i=index: %ix%i\n", index, v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB32;
(int)(v4l2_frmsizeenum. JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break; break;
} }
default: { case 4: {
JOM(8, "%i=index: exhausts framesizes\n", index); v4l2_fmtdesc.flags = 0;
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); strcpy(&v4l2_fmtdesc.description[0], "bgr24");
return -EINVAL; v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR24;
} JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
}
} else {
switch (index) {
case 0: {
v4l2_frmsizeenum.discrete.width = 640;
v4l2_frmsizeenum.discrete.height = 480;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 1: {
v4l2_frmsizeenum.discrete.width = 320;
v4l2_frmsizeenum.discrete.height = 240;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 2: {
v4l2_frmsizeenum.discrete.width = 704;
v4l2_frmsizeenum.discrete.height = 576;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 3: {
v4l2_frmsizeenum.discrete.width = 720;
v4l2_frmsizeenum.discrete.height = 576;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break; break;
} }
case 4: { case 5: {
v4l2_frmsizeenum.discrete.width = 360; v4l2_fmtdesc.flags = 0;
v4l2_frmsizeenum.discrete.height = 288; strcpy(&v4l2_fmtdesc.description[0], "bgr32");
JOM(8, "%i=index: %ix%i\n", index, v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR32;
(int)(v4l2_frmsizeenum. JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break; break;
} }
default: { default: {
JOM(8, "%i=index: exhausts framesizes\n", index); JOM(8, "%i=index: exhausts formats\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
} }
if (copy_to_user((void __user *)arg, &v4l2_fmtdesc,
sizeof(struct v4l2_fmtdesc))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
} }
if (0 != copy_to_user((void __user *)arg, &v4l2_frmsizeenum,
sizeof(struct v4l2_frmsizeenum))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* /*
* THE RESPONSE TO VIDIOC_ENUM_FRAMEINTERVALS MUST BE CONDITIONED ON THE * THE RESPONSE TO VIDIOC_ENUM_FRAMESIZES MUST BE CONDITIONED ON THE
* THE CURRENT STANDARD, BECAUSE THAT IS WHAT gstreamer EXPECTS. BEWARE. * THE CURRENT STANDARD, BECAUSE THAT IS WHAT gstreamer EXPECTS. BEWARE.
*/ */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_ENUM_FRAMEINTERVALS: { case VIDIOC_ENUM_FRAMESIZES: {
u32 index; u32 index;
int denominator; struct v4l2_frmsizeenum v4l2_frmsizeenum;
struct v4l2_frmivalenum v4l2_frmivalenum;
JOM(8, "VIDIOC_ENUM_FRAMEINTERVALS\n");
if (peasycap->fps) JOM(8, "VIDIOC_ENUM_FRAMESIZES\n");
denominator = peasycap->fps;
else {
if (true == peasycap->ntsc)
denominator = 30;
else
denominator = 25;
}
if (0 != copy_from_user(&v4l2_frmivalenum, (void __user *)arg, if (0 != copy_from_user(&v4l2_frmsizeenum, (void __user *)arg,
sizeof(struct v4l2_frmivalenum))) { sizeof(struct v4l2_frmsizeenum))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
index = v4l2_frmivalenum.index; index = v4l2_frmsizeenum.index;
v4l2_frmivalenum.type = (u32) V4L2_FRMIVAL_TYPE_DISCRETE; v4l2_frmsizeenum.type = (u32) V4L2_FRMSIZE_TYPE_DISCRETE;
switch (index) { if (true == peasycap->ntsc) {
case 0: { switch (index) {
v4l2_frmivalenum.discrete.numerator = 1; case 0: {
v4l2_frmivalenum.discrete.denominator = denominator; v4l2_frmsizeenum.discrete.width = 640;
JOM(8, "%i=index: %i/%i\n", index, v4l2_frmsizeenum.discrete.height = 480;
(int)(v4l2_frmivalenum.discrete.numerator), JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmivalenum.discrete.denominator)); (int)(v4l2_frmsizeenum.
break; discrete.width),
} (int)(v4l2_frmsizeenum.
case 1: { discrete.height));
v4l2_frmivalenum.discrete.numerator = 1; break;
v4l2_frmivalenum.discrete.denominator = denominator/5; }
JOM(8, "%i=index: %i/%i\n", index, case 1: {
(int)(v4l2_frmivalenum.discrete.numerator), v4l2_frmsizeenum.discrete.width = 320;
(int)(v4l2_frmivalenum.discrete.denominator)); v4l2_frmsizeenum.discrete.height = 240;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 2: {
v4l2_frmsizeenum.discrete.width = 720;
v4l2_frmsizeenum.discrete.height = 480;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 3: {
v4l2_frmsizeenum.discrete.width = 360;
v4l2_frmsizeenum.discrete.height = 240;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
default: {
JOM(8, "%i=index: exhausts framesizes\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
} else {
switch (index) {
case 0: {
v4l2_frmsizeenum.discrete.width = 640;
v4l2_frmsizeenum.discrete.height = 480;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 1: {
v4l2_frmsizeenum.discrete.width = 320;
v4l2_frmsizeenum.discrete.height = 240;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 2: {
v4l2_frmsizeenum.discrete.width = 704;
v4l2_frmsizeenum.discrete.height = 576;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 3: {
v4l2_frmsizeenum.discrete.width = 720;
v4l2_frmsizeenum.discrete.height = 576;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
case 4: {
v4l2_frmsizeenum.discrete.width = 360;
v4l2_frmsizeenum.discrete.height = 288;
JOM(8, "%i=index: %ix%i\n", index,
(int)(v4l2_frmsizeenum.
discrete.width),
(int)(v4l2_frmsizeenum.
discrete.height));
break;
}
default: {
JOM(8, "%i=index: exhausts framesizes\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
}
if (copy_to_user((void __user *)arg, &v4l2_frmsizeenum,
sizeof(struct v4l2_frmsizeenum))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break; break;
} }
default: { /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
JOM(8, "%i=index: exhausts frameintervals\n", index); /*
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); * THE RESPONSE TO VIDIOC_ENUM_FRAMEINTERVALS MUST BE CONDITIONED ON THE
return -EINVAL; * THE CURRENT STANDARD, BECAUSE THAT IS WHAT gstreamer EXPECTS. BEWARE.
} */
} /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
if (0 != copy_to_user((void __user *)arg, &v4l2_frmivalenum, case VIDIOC_ENUM_FRAMEINTERVALS: {
u32 index;
int denominator;
struct v4l2_frmivalenum v4l2_frmivalenum;
JOM(8, "VIDIOC_ENUM_FRAMEINTERVALS\n");
if (peasycap->fps)
denominator = peasycap->fps;
else {
if (true == peasycap->ntsc)
denominator = 30;
else
denominator = 25;
}
if (0 != copy_from_user(&v4l2_frmivalenum, (void __user *)arg,
sizeof(struct v4l2_frmivalenum))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
index = v4l2_frmivalenum.index;
v4l2_frmivalenum.type = (u32) V4L2_FRMIVAL_TYPE_DISCRETE;
switch (index) {
case 0: {
v4l2_frmivalenum.discrete.numerator = 1;
v4l2_frmivalenum.discrete.denominator = denominator;
JOM(8, "%i=index: %i/%i\n", index,
(int)(v4l2_frmivalenum.discrete.numerator),
(int)(v4l2_frmivalenum.discrete.denominator));
break;
}
case 1: {
v4l2_frmivalenum.discrete.numerator = 1;
v4l2_frmivalenum.discrete.denominator = denominator/5;
JOM(8, "%i=index: %i/%i\n", index,
(int)(v4l2_frmivalenum.discrete.numerator),
(int)(v4l2_frmivalenum.discrete.denominator));
break;
}
default: {
JOM(8, "%i=index: exhausts frameintervals\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
}
if (copy_to_user((void __user *)arg, &v4l2_frmivalenum,
sizeof(struct v4l2_frmivalenum))) { sizeof(struct v4l2_frmivalenum))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_FMT: { case VIDIOC_G_FMT: {
struct v4l2_format *pv4l2_format; struct v4l2_format *pv4l2_format;
struct v4l2_pix_format *pv4l2_pix_format; struct v4l2_pix_format *pv4l2_pix_format;
JOM(8, "VIDIOC_G_FMT\n"); JOM(8, "VIDIOC_G_FMT\n");
pv4l2_format = kzalloc(sizeof(struct v4l2_format), GFP_KERNEL); pv4l2_format = kzalloc(sizeof(struct v4l2_format), GFP_KERNEL);
if (!pv4l2_format) { if (!pv4l2_format) {
SAM("ERROR: out of memory\n"); SAM("ERROR: out of memory\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOMEM; return -ENOMEM;
} }
pv4l2_pix_format = kzalloc(sizeof(struct v4l2_pix_format), GFP_KERNEL); pv4l2_pix_format = kzalloc(sizeof(struct v4l2_pix_format), GFP_KERNEL);
if (!pv4l2_pix_format) { if (!pv4l2_pix_format) {
SAM("ERROR: out of memory\n"); SAM("ERROR: out of memory\n");
kfree(pv4l2_format); kfree(pv4l2_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOMEM; return -ENOMEM;
} }
if (0 != copy_from_user(pv4l2_format, (void __user *)arg, if (0 != copy_from_user(pv4l2_format, (void __user *)arg,
sizeof(struct v4l2_format))) { sizeof(struct v4l2_format))) {
kfree(pv4l2_format); kfree(pv4l2_format);
kfree(pv4l2_pix_format); kfree(pv4l2_pix_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
if (pv4l2_format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (pv4l2_format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
kfree(pv4l2_format); kfree(pv4l2_format);
kfree(pv4l2_pix_format); kfree(pv4l2_pix_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
memset(pv4l2_pix_format, 0, sizeof(struct v4l2_pix_format)); memset(pv4l2_pix_format, 0, sizeof(struct v4l2_pix_format));
pv4l2_format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; pv4l2_format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
memcpy(&pv4l2_format->fmt.pix, memcpy(&pv4l2_format->fmt.pix,
&easycap_format[peasycap->format_offset] &easycap_format[peasycap->format_offset]
.v4l2_format.fmt.pix, sizeof(struct v4l2_pix_format)); .v4l2_format.fmt.pix, sizeof(struct v4l2_pix_format));
JOM(8, "user is told: %s\n", JOM(8, "user is told: %s\n",
&easycap_format[peasycap->format_offset].name[0]); &easycap_format[peasycap->format_offset].name[0]);
if (0 != copy_to_user((void __user *)arg, pv4l2_format, if (copy_to_user((void __user *)arg, pv4l2_format,
sizeof(struct v4l2_format))) { sizeof(struct v4l2_format))) {
kfree(pv4l2_format);
kfree(pv4l2_pix_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
kfree(pv4l2_format); kfree(pv4l2_format);
kfree(pv4l2_pix_format); kfree(pv4l2_pix_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); break;
return -EFAULT;
} }
kfree(pv4l2_format);
kfree(pv4l2_pix_format);
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_TRY_FMT: case VIDIOC_TRY_FMT:
case VIDIOC_S_FMT: { case VIDIOC_S_FMT: {
struct v4l2_format v4l2_format; struct v4l2_format v4l2_format;
struct v4l2_pix_format v4l2_pix_format; struct v4l2_pix_format v4l2_pix_format;
bool try; bool try;
int best_format; int best_format;
if (VIDIOC_TRY_FMT == cmd) { if (VIDIOC_TRY_FMT == cmd) {
JOM(8, "VIDIOC_TRY_FMT\n"); JOM(8, "VIDIOC_TRY_FMT\n");
try = true; try = true;
} else { } else {
JOM(8, "VIDIOC_S_FMT\n"); JOM(8, "VIDIOC_S_FMT\n");
try = false; try = false;
} }
if (0 != copy_from_user(&v4l2_format, (void __user *)arg, if (0 != copy_from_user(&v4l2_format, (void __user *)arg,
sizeof(struct v4l2_format))) { sizeof(struct v4l2_format))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
best_format = adjust_format(peasycap, best_format = adjust_format(peasycap,
v4l2_format.fmt.pix.width, v4l2_format.fmt.pix.width,
v4l2_format.fmt.pix.height, v4l2_format.fmt.pix.height,
v4l2_format.fmt.pix.pixelformat, v4l2_format.fmt.pix.pixelformat,
v4l2_format.fmt.pix.field, v4l2_format.fmt.pix.field,
try); try);
if (0 > best_format) { if (0 > best_format) {
if (-EBUSY == best_format) { if (-EBUSY == best_format) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EBUSY;
}
JOM(8, "WARNING: adjust_format() returned %i\n", best_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EBUSY; return -ENOENT;
} }
JOM(8, "WARNING: adjust_format() returned %i\n", best_format);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOENT;
}
/*...........................................................................*/ /*...........................................................................*/
memset(&v4l2_pix_format, 0, sizeof(struct v4l2_pix_format)); memset(&v4l2_pix_format, 0, sizeof(struct v4l2_pix_format));
v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
memcpy(&(v4l2_format.fmt.pix), &(easycap_format[best_format] memcpy(&(v4l2_format.fmt.pix),
.v4l2_format.fmt.pix), sizeof(v4l2_pix_format)); &(easycap_format[best_format].v4l2_format.fmt.pix),
JOM(8, "user is told: %s\n", &easycap_format[best_format].name[0]); sizeof(v4l2_pix_format));
JOM(8, "user is told: %s\n", &easycap_format[best_format].name[0]);
if (0 != copy_to_user((void __user *)arg, &v4l2_format, if (copy_to_user((void __user *)arg, &v4l2_format,
sizeof(struct v4l2_format))) { sizeof(struct v4l2_format))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_CROPCAP: { case VIDIOC_CROPCAP: {
struct v4l2_cropcap v4l2_cropcap; struct v4l2_cropcap v4l2_cropcap;
JOM(8, "VIDIOC_CROPCAP\n"); JOM(8, "VIDIOC_CROPCAP\n");
if (0 != copy_from_user(&v4l2_cropcap, (void __user *)arg, if (0 != copy_from_user(&v4l2_cropcap, (void __user *)arg,
sizeof(struct v4l2_cropcap))) { sizeof(struct v4l2_cropcap))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
if (v4l2_cropcap.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
JOM(8, "v4l2_cropcap.type != V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
memset(&v4l2_cropcap, 0, sizeof(struct v4l2_cropcap));
v4l2_cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2_cropcap.bounds.left = 0;
v4l2_cropcap.bounds.top = 0;
v4l2_cropcap.bounds.width = peasycap->width;
v4l2_cropcap.bounds.height = peasycap->height;
v4l2_cropcap.defrect.left = 0;
v4l2_cropcap.defrect.top = 0;
v4l2_cropcap.defrect.width = peasycap->width;
v4l2_cropcap.defrect.height = peasycap->height;
v4l2_cropcap.pixelaspect.numerator = 1;
v4l2_cropcap.pixelaspect.denominator = 1;
JOM(8, "user is told: %ix%i\n", peasycap->width, peasycap->height);
if (0 != copy_to_user((void __user *)arg, &v4l2_cropcap, if (v4l2_cropcap.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
JOM(8, "v4l2_cropcap.type != V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
memset(&v4l2_cropcap, 0, sizeof(struct v4l2_cropcap));
v4l2_cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2_cropcap.bounds.left = 0;
v4l2_cropcap.bounds.top = 0;
v4l2_cropcap.bounds.width = peasycap->width;
v4l2_cropcap.bounds.height = peasycap->height;
v4l2_cropcap.defrect.left = 0;
v4l2_cropcap.defrect.top = 0;
v4l2_cropcap.defrect.width = peasycap->width;
v4l2_cropcap.defrect.height = peasycap->height;
v4l2_cropcap.pixelaspect.numerator = 1;
v4l2_cropcap.pixelaspect.denominator = 1;
JOM(8, "user is told: %ix%i\n", peasycap->width, peasycap->height);
if (copy_to_user((void __user *)arg, &v4l2_cropcap,
sizeof(struct v4l2_cropcap))) { sizeof(struct v4l2_cropcap))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_CROP:
case VIDIOC_S_CROP: {
JOM(8, "VIDIOC_G_CROP|VIDIOC_S_CROP unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_QUERYSTD: { case VIDIOC_G_CROP:
JOM(8, "VIDIOC_QUERYSTD: " case VIDIOC_S_CROP: {
"EasyCAP is incapable of detecting standard\n"); JOM(8, "VIDIOC_G_CROP|VIDIOC_S_CROP unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*---------------------------------------------------------------------------*/
/*
* THE MANIPULATIONS INVOLVING last0,last1,last2,last3 CONSTITUTE A WORKAROUND
* FOR WHAT APPEARS TO BE A BUG IN 64-BIT mplayer.
* NOT NEEDED, BUT HOPEFULLY HARMLESS, FOR 32-BIT mplayer.
*/
/*---------------------------------------------------------------------------*/
case VIDIOC_ENUMSTD: {
int last0 = -1, last1 = -1, last2 = -1, last3 = -1;
struct v4l2_standard v4l2_standard;
u32 index;
struct easycap_standard const *peasycap_standard;
JOM(8, "VIDIOC_ENUMSTD\n");
if (0 != copy_from_user(&v4l2_standard, (void __user *)arg,
sizeof(struct v4l2_standard))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EINVAL;
}
index = v4l2_standard.index;
last3 = last2; last2 = last1; last1 = last0; last0 = index;
if ((index == last3) && (index == last2) &&
(index == last1) && (index == last0)) {
index++;
last3 = last2; last2 = last1; last1 = last0; last0 = index;
}
memset(&v4l2_standard, 0, sizeof(struct v4l2_standard));
peasycap_standard = &easycap_standard[0];
while (0xFFFF != peasycap_standard->mask) {
if ((int)(peasycap_standard - &easycap_standard[0]) == index)
break;
peasycap_standard++;
} }
if (0xFFFF == peasycap_standard->mask) { /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
JOM(8, "%i=index: exhausts standards\n", index); case VIDIOC_QUERYSTD: {
JOM(8, "VIDIOC_QUERYSTD: "
"EasyCAP is incapable of detecting standard\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
break;
} }
JOM(8, "%i=index: %s\n", index, /*-------------------------------------------------------------------*/
&(peasycap_standard->v4l2_standard.name[0])); /*
memcpy(&v4l2_standard, &(peasycap_standard->v4l2_standard), * THE MANIPULATIONS INVOLVING last0,last1,last2,last3
sizeof(struct v4l2_standard)); * CONSTITUTE A WORKAROUND * FOR WHAT APPEARS TO BE
* A BUG IN 64-BIT mplayer.
* NOT NEEDED, BUT HOPEFULLY HARMLESS, FOR 32-BIT mplayer.
*/
/*------------------------------------------------------------------*/
case VIDIOC_ENUMSTD: {
int last0 = -1, last1 = -1, last2 = -1, last3 = -1;
struct v4l2_standard v4l2_standard;
u32 index;
struct easycap_standard const *peasycap_standard;
JOM(8, "VIDIOC_ENUMSTD\n");
if (0 != copy_from_user(&v4l2_standard, (void __user *)arg,
sizeof(struct v4l2_standard))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
index = v4l2_standard.index;
last3 = last2;
last2 = last1;
last1 = last0;
last0 = index;
if ((index == last3) && (index == last2) &&
(index == last1) && (index == last0)) {
index++;
last3 = last2;
last2 = last1;
last1 = last0;
last0 = index;
}
v4l2_standard.index = index; memset(&v4l2_standard, 0, sizeof(struct v4l2_standard));
if (0 != copy_to_user((void __user *)arg, &v4l2_standard, peasycap_standard = &easycap_standard[0];
sizeof(struct v4l2_standard))) { while (0xFFFF != peasycap_standard->mask) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); if ((int)(peasycap_standard - &easycap_standard[0]) == index)
return -EFAULT; break;
peasycap_standard++;
}
if (0xFFFF == peasycap_standard->mask) {
JOM(8, "%i=index: exhausts standards\n", index);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
JOM(8, "%i=index: %s\n", index,
&(peasycap_standard->v4l2_standard.name[0]));
memcpy(&v4l2_standard, &(peasycap_standard->v4l2_standard),
sizeof(struct v4l2_standard));
v4l2_standard.index = index;
if (copy_to_user((void __user *)arg, &v4l2_standard,
sizeof(struct v4l2_standard))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_STD: { case VIDIOC_G_STD: {
v4l2_std_id std_id; v4l2_std_id std_id;
struct easycap_standard const *peasycap_standard; struct easycap_standard const *peasycap_standard;
JOM(8, "VIDIOC_G_STD\n"); JOM(8, "VIDIOC_G_STD\n");
if (0 > peasycap->standard_offset) { if (0 > peasycap->standard_offset) {
JOM(8, "%i=peasycap->standard_offset\n", JOM(8, "%i=peasycap->standard_offset\n",
peasycap->standard_offset); peasycap->standard_offset);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EBUSY; return -EBUSY;
} }
if (0 != copy_from_user(&std_id, (void __user *)arg, if (0 != copy_from_user(&std_id, (void __user *)arg,
sizeof(v4l2_std_id))) { sizeof(v4l2_std_id))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
peasycap_standard = &easycap_standard[peasycap->standard_offset]; peasycap_standard = &easycap_standard[peasycap->standard_offset];
std_id = peasycap_standard->v4l2_standard.id; std_id = peasycap_standard->v4l2_standard.id;
JOM(8, "user is told: %s\n", JOM(8, "user is told: %s\n",
&peasycap_standard->v4l2_standard.name[0]); &peasycap_standard->v4l2_standard.name[0]);
if (0 != copy_to_user((void __user *)arg, &std_id, if (copy_to_user((void __user *)arg, &std_id,
sizeof(v4l2_std_id))) { sizeof(v4l2_std_id))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_STD: { case VIDIOC_S_STD: {
v4l2_std_id std_id; v4l2_std_id std_id;
int rc; int rc;
JOM(8, "VIDIOC_S_STD\n"); JOM(8, "VIDIOC_S_STD\n");
if (0 != copy_from_user(&std_id, (void __user *)arg, if (0 != copy_from_user(&std_id, (void __user *)arg,
sizeof(v4l2_std_id))) { sizeof(v4l2_std_id))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
JOM(8, "User requests standard: 0x%08X%08X\n", JOM(8, "User requests standard: 0x%08X%08X\n",
(int)((std_id & (((v4l2_std_id)0xFFFFFFFF) << 32)) >> 32), (int)((std_id & (((v4l2_std_id)0xFFFFFFFF) << 32)) >> 32),
(int)(std_id & ((v4l2_std_id)0xFFFFFFFF))); (int)(std_id & ((v4l2_std_id)0xFFFFFFFF)));
rc = adjust_standard(peasycap, std_id); rc = adjust_standard(peasycap, std_id);
if (0 > rc) { if (0 > rc) {
JOM(8, "WARNING: adjust_standard() returned %i\n", rc); JOM(8, "WARNING: adjust_standard() returned %i\n", rc);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOENT; return -ENOENT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_REQBUFS: { case VIDIOC_REQBUFS: {
int nbuffers; int nbuffers;
struct v4l2_requestbuffers v4l2_requestbuffers; struct v4l2_requestbuffers v4l2_requestbuffers;
JOM(8, "VIDIOC_REQBUFS\n"); JOM(8, "VIDIOC_REQBUFS\n");
if (0 != copy_from_user(&v4l2_requestbuffers, (void __user *)arg, if (0 != copy_from_user(&v4l2_requestbuffers,
sizeof(struct v4l2_requestbuffers))) { (void __user *)arg,
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); sizeof(struct v4l2_requestbuffers))) {
return -EFAULT; mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
} return -EFAULT;
}
if (v4l2_requestbuffers.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (v4l2_requestbuffers.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
if (v4l2_requestbuffers.memory != V4L2_MEMORY_MMAP) { if (v4l2_requestbuffers.memory != V4L2_MEMORY_MMAP) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
nbuffers = v4l2_requestbuffers.count; nbuffers = v4l2_requestbuffers.count;
JOM(8, " User requests %i buffers ...\n", nbuffers); JOM(8, " User requests %i buffers ...\n", nbuffers);
if (nbuffers < 2) if (nbuffers < 2)
nbuffers = 2; nbuffers = 2;
if (nbuffers > FRAME_BUFFER_MANY) if (nbuffers > FRAME_BUFFER_MANY)
nbuffers = FRAME_BUFFER_MANY; nbuffers = FRAME_BUFFER_MANY;
if (v4l2_requestbuffers.count == nbuffers) { if (v4l2_requestbuffers.count == nbuffers) {
JOM(8, " ... agree to %i buffers\n", JOM(8, " ... agree to %i buffers\n",
nbuffers); nbuffers);
} else { } else {
JOM(8, " ... insist on %i buffers\n", JOM(8, " ... insist on %i buffers\n",
nbuffers); nbuffers);
v4l2_requestbuffers.count = nbuffers; v4l2_requestbuffers.count = nbuffers;
} }
peasycap->frame_buffer_many = nbuffers; peasycap->frame_buffer_many = nbuffers;
if (0 != copy_to_user((void __user *)arg, &v4l2_requestbuffers, if (copy_to_user((void __user *)arg, &v4l2_requestbuffers,
sizeof(struct v4l2_requestbuffers))) { sizeof(struct v4l2_requestbuffers))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_QUERYBUF: { case VIDIOC_QUERYBUF: {
u32 index; u32 index;
struct v4l2_buffer v4l2_buffer; struct v4l2_buffer v4l2_buffer;
JOM(8, "VIDIOC_QUERYBUF\n"); JOM(8, "VIDIOC_QUERYBUF\n");
if (peasycap->video_eof) { if (peasycap->video_eof) {
JOM(8, "returning -EIO because %i=video_eof\n", JOM(8, "returning -EIO because %i=video_eof\n",
peasycap->video_eof); peasycap->video_eof);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EIO; return -EIO;
} }
if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg,
sizeof(struct v4l2_buffer))) { sizeof(struct v4l2_buffer))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
index = v4l2_buffer.index; index = v4l2_buffer.index;
if (index < 0 || index >= peasycap->frame_buffer_many) if (index < 0 || index >= peasycap->frame_buffer_many)
return -EINVAL; return -EINVAL;
memset(&v4l2_buffer, 0, sizeof(struct v4l2_buffer)); memset(&v4l2_buffer, 0, sizeof(struct v4l2_buffer));
v4l2_buffer.index = index; v4l2_buffer.index = index;
v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2_buffer.bytesused = peasycap->frame_buffer_used; v4l2_buffer.bytesused = peasycap->frame_buffer_used;
v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED |
peasycap->done[index] | peasycap->done[index] |
peasycap->queued[index]; peasycap->queued[index];
v4l2_buffer.field = V4L2_FIELD_NONE; v4l2_buffer.field = V4L2_FIELD_NONE;
v4l2_buffer.memory = V4L2_MEMORY_MMAP; v4l2_buffer.memory = V4L2_MEMORY_MMAP;
v4l2_buffer.m.offset = index * FRAME_BUFFER_SIZE; v4l2_buffer.m.offset = index * FRAME_BUFFER_SIZE;
v4l2_buffer.length = FRAME_BUFFER_SIZE; v4l2_buffer.length = FRAME_BUFFER_SIZE;
JOM(16, " %10i=index\n", v4l2_buffer.index); JOM(16, " %10i=index\n", v4l2_buffer.index);
JOM(16, " 0x%08X=type\n", v4l2_buffer.type); JOM(16, " 0x%08X=type\n", v4l2_buffer.type);
JOM(16, " %10i=bytesused\n", v4l2_buffer.bytesused); JOM(16, " %10i=bytesused\n", v4l2_buffer.bytesused);
JOM(16, " 0x%08X=flags\n", v4l2_buffer.flags); JOM(16, " 0x%08X=flags\n", v4l2_buffer.flags);
JOM(16, " %10i=field\n", v4l2_buffer.field); JOM(16, " %10i=field\n", v4l2_buffer.field);
JOM(16, " %10li=timestamp.tv_usec\n", JOM(16, " %10li=timestamp.tv_usec\n",
(long)v4l2_buffer.timestamp.tv_usec); (long)v4l2_buffer.timestamp.tv_usec);
JOM(16, " %10i=sequence\n", v4l2_buffer.sequence); JOM(16, " %10i=sequence\n", v4l2_buffer.sequence);
JOM(16, " 0x%08X=memory\n", v4l2_buffer.memory); JOM(16, " 0x%08X=memory\n", v4l2_buffer.memory);
JOM(16, " %10i=m.offset\n", v4l2_buffer.m.offset); JOM(16, " %10i=m.offset\n", v4l2_buffer.m.offset);
JOM(16, " %10i=length\n", v4l2_buffer.length); JOM(16, " %10i=length\n", v4l2_buffer.length);
if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, if (copy_to_user((void __user *)arg, &v4l2_buffer,
sizeof(struct v4l2_buffer))) { sizeof(struct v4l2_buffer))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_QBUF: { case VIDIOC_QBUF: {
struct v4l2_buffer v4l2_buffer; struct v4l2_buffer v4l2_buffer;
JOM(8, "VIDIOC_QBUF\n"); JOM(8, "VIDIOC_QBUF\n");
if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg,
sizeof(struct v4l2_buffer))) { sizeof(struct v4l2_buffer))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
if (v4l2_buffer.memory != V4L2_MEMORY_MMAP) { if (v4l2_buffer.memory != V4L2_MEMORY_MMAP) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
if (v4l2_buffer.index < 0 || if (v4l2_buffer.index < 0 ||
(v4l2_buffer.index >= peasycap->frame_buffer_many)) { v4l2_buffer.index >= peasycap->frame_buffer_many) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED; v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED;
peasycap->done[v4l2_buffer.index] = 0; peasycap->done[v4l2_buffer.index] = 0;
peasycap->queued[v4l2_buffer.index] = V4L2_BUF_FLAG_QUEUED; peasycap->queued[v4l2_buffer.index] = V4L2_BUF_FLAG_QUEUED;
if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, if (copy_to_user((void __user *)arg, &v4l2_buffer,
sizeof(struct v4l2_buffer))) { sizeof(struct v4l2_buffer))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
JOM(8, "..... user queueing frame buffer %i\n", JOM(8, "..... user queueing frame buffer %i\n",
(int)v4l2_buffer.index); (int)v4l2_buffer.index);
peasycap->frame_lock = 0; peasycap->frame_lock = 0;
break; break;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_DQBUF: case VIDIOC_DQBUF:
{ {
struct timeval timeval, timeval2; struct timeval timeval, timeval2;
int i, j; int i, j;
struct v4l2_buffer v4l2_buffer; struct v4l2_buffer v4l2_buffer;
int rcdq; int rcdq;
u16 input; u16 input;
JOM(8, "VIDIOC_DQBUF\n"); JOM(8, "VIDIOC_DQBUF\n");
if ((peasycap->video_idle) || (peasycap->video_eof)) { if ((peasycap->video_idle) || (peasycap->video_eof)) {
JOM(8, "returning -EIO because " JOM(8, "returning -EIO because "
"%i=video_idle %i=video_eof\n", "%i=video_idle %i=video_eof\n",
peasycap->video_idle, peasycap->video_eof); peasycap->video_idle, peasycap->video_eof);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EIO; return -EIO;
} }
if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg,
sizeof(struct v4l2_buffer))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (copy_from_user(&v4l2_buffer, (void __user *)arg,
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); sizeof(struct v4l2_buffer))) {
return -EINVAL; mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
} return -EFAULT;
}
if (true == peasycap->offerfields) { if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
/*-----------------------------------------------------------*/ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
/* return -EINVAL;
* IN ITS 50 "fps" MODE tvtime SEEMS ALWAYS TO REQUEST }
* V4L2_FIELD_BOTTOM
*/
/*-----------------------------------------------------------*/
if (V4L2_FIELD_TOP == v4l2_buffer.field)
JOM(8, "user wants V4L2_FIELD_TOP\n");
else if (V4L2_FIELD_BOTTOM == v4l2_buffer.field)
JOM(8, "user wants V4L2_FIELD_BOTTOM\n");
else if (V4L2_FIELD_ANY == v4l2_buffer.field)
JOM(8, "user wants V4L2_FIELD_ANY\n");
else
JOM(8, "user wants V4L2_FIELD_...UNKNOWN: %i\n",
v4l2_buffer.field);
}
if (!peasycap->video_isoc_streaming) { if (peasycap->offerfields) {
JOM(16, "returning -EIO because video urbs not streaming\n"); /*---------------------------------------------------*/
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); /*
return -EIO; * IN ITS 50 "fps" MODE tvtime SEEMS ALWAYS TO REQUEST
} * V4L2_FIELD_BOTTOM
/*---------------------------------------------------------------------------*/ */
/* /*---------------------------------------------------*/
* IF THE USER HAS PREVIOUSLY CALLED easycap_poll(), AS DETERMINED BY FINDING if (V4L2_FIELD_TOP == v4l2_buffer.field)
* THE FLAG peasycap->polled SET, THERE MUST BE NO FURTHER WAIT HERE. IN THIS JOM(8, "user wants V4L2_FIELD_TOP\n");
* CASE, JUST CHOOSE THE FRAME INDICATED BY peasycap->frame_read else if (V4L2_FIELD_BOTTOM == v4l2_buffer.field)
*/ JOM(8, "user wants V4L2_FIELD_BOTTOM\n");
/*---------------------------------------------------------------------------*/ else if (V4L2_FIELD_ANY == v4l2_buffer.field)
JOM(8, "user wants V4L2_FIELD_ANY\n");
else
JOM(8, "user wants V4L2_FIELD_...UNKNOWN: %i\n",
v4l2_buffer.field);
}
if (!peasycap->polled) { if (!peasycap->video_isoc_streaming) {
do { JOM(16, "returning -EIO because video urbs not streaming\n");
rcdq = easycap_dqbuf(peasycap, 0);
if (-EIO == rcdq) {
JOM(8, "returning -EIO because "
"dqbuf() returned -EIO\n");
mutex_unlock(&easycapdc60_dongle[kd].
mutex_video);
return -EIO;
}
} while (0 != rcdq);
} else {
if (peasycap->video_eof) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EIO; return -EIO;
} }
} /*-------------------------------------------------------------------*/
if (V4L2_BUF_FLAG_DONE != peasycap->done[peasycap->frame_read]) { /*
JOM(8, "V4L2_BUF_FLAG_DONE != 0x%08X\n", * IF THE USER HAS PREVIOUSLY CALLED easycap_poll(),
peasycap->done[peasycap->frame_read]); * AS DETERMINED BY FINDING
} * THE FLAG peasycap->polled SET, THERE MUST BE
peasycap->polled = 0; * NO FURTHER WAIT HERE. IN THIS
* CASE, JUST CHOOSE THE FRAME INDICATED BY peasycap->frame_read
if (!(peasycap->isequence % 10)) { */
for (i = 0; i < 179; i++) /*-------------------------------------------------------------------*/
peasycap->merit[i] = peasycap->merit[i+1];
peasycap->merit[179] = merit_saa(peasycap->pusb_device); if (!peasycap->polled) {
j = 0; do {
for (i = 0; i < 180; i++) rcdq = easycap_dqbuf(peasycap, 0);
j += peasycap->merit[i]; if (-EIO == rcdq) {
if (90 < j) { JOM(8, "returning -EIO because "
SAM("easycap driver shutting down " "dqbuf() returned -EIO\n");
"on condition blue\n"); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
peasycap->video_eof = 1; peasycap->audio_eof = 1; return -EIO;
}
} while (0 != rcdq);
} else {
if (peasycap->video_eof) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EIO;
}
}
if (V4L2_BUF_FLAG_DONE != peasycap->done[peasycap->frame_read]) {
JOM(8, "V4L2_BUF_FLAG_DONE != 0x%08X\n",
peasycap->done[peasycap->frame_read]);
}
peasycap->polled = 0;
if (!(peasycap->isequence % 10)) {
for (i = 0; i < 179; i++)
peasycap->merit[i] = peasycap->merit[i+1];
peasycap->merit[179] = merit_saa(peasycap->pusb_device);
j = 0;
for (i = 0; i < 180; i++)
j += peasycap->merit[i];
if (90 < j) {
SAM("easycap driver shutting down "
"on condition blue\n");
peasycap->video_eof = 1;
peasycap->audio_eof = 1;
}
} }
}
v4l2_buffer.index = peasycap->frame_read; v4l2_buffer.index = peasycap->frame_read;
v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2_buffer.bytesused = peasycap->frame_buffer_used; v4l2_buffer.bytesused = peasycap->frame_buffer_used;
v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE; v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE;
if (true == peasycap->offerfields) if (true == peasycap->offerfields)
v4l2_buffer.field = V4L2_FIELD_BOTTOM; v4l2_buffer.field = V4L2_FIELD_BOTTOM;
else else
v4l2_buffer.field = V4L2_FIELD_NONE; v4l2_buffer.field = V4L2_FIELD_NONE;
do_gettimeofday(&timeval); do_gettimeofday(&timeval);
timeval2 = timeval; timeval2 = timeval;
v4l2_buffer.timestamp = timeval2; v4l2_buffer.timestamp = timeval2;
v4l2_buffer.sequence = peasycap->isequence++; v4l2_buffer.sequence = peasycap->isequence++;
v4l2_buffer.memory = V4L2_MEMORY_MMAP; v4l2_buffer.memory = V4L2_MEMORY_MMAP;
v4l2_buffer.m.offset = v4l2_buffer.index * FRAME_BUFFER_SIZE; v4l2_buffer.m.offset = v4l2_buffer.index * FRAME_BUFFER_SIZE;
v4l2_buffer.length = FRAME_BUFFER_SIZE; v4l2_buffer.length = FRAME_BUFFER_SIZE;
JOM(16, " %10i=index\n", v4l2_buffer.index); JOM(16, " %10i=index\n", v4l2_buffer.index);
JOM(16, " 0x%08X=type\n", v4l2_buffer.type); JOM(16, " 0x%08X=type\n", v4l2_buffer.type);
JOM(16, " %10i=bytesused\n", v4l2_buffer.bytesused); JOM(16, " %10i=bytesused\n", v4l2_buffer.bytesused);
JOM(16, " 0x%08X=flags\n", v4l2_buffer.flags); JOM(16, " 0x%08X=flags\n", v4l2_buffer.flags);
JOM(16, " %10i=field\n", v4l2_buffer.field); JOM(16, " %10i=field\n", v4l2_buffer.field);
JOM(16, " %10li=timestamp.tv_sec\n", JOM(16, " %10li=timestamp.tv_sec\n",
(long)v4l2_buffer.timestamp.tv_sec); (long)v4l2_buffer.timestamp.tv_sec);
JOM(16, " %10li=timestamp.tv_usec\n", JOM(16, " %10li=timestamp.tv_usec\n",
(long)v4l2_buffer.timestamp.tv_usec); (long)v4l2_buffer.timestamp.tv_usec);
JOM(16, " %10i=sequence\n", v4l2_buffer.sequence); JOM(16, " %10i=sequence\n", v4l2_buffer.sequence);
JOM(16, " 0x%08X=memory\n", v4l2_buffer.memory); JOM(16, " 0x%08X=memory\n", v4l2_buffer.memory);
JOM(16, " %10i=m.offset\n", v4l2_buffer.m.offset); JOM(16, " %10i=m.offset\n", v4l2_buffer.m.offset);
JOM(16, " %10i=length\n", v4l2_buffer.length); JOM(16, " %10i=length\n", v4l2_buffer.length);
if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, if (copy_to_user((void __user *)arg, &v4l2_buffer,
sizeof(struct v4l2_buffer))) { sizeof(struct v4l2_buffer))) {
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
input = peasycap->frame_buffer[peasycap->frame_read][0].input; input = peasycap->frame_buffer[peasycap->frame_read][0].input;
if (0x08 & input) { if (0x08 & input) {
JOM(8, "user is offered frame buffer %i, input %i\n", JOM(8, "user is offered frame buffer %i, input %i\n",
peasycap->frame_read, (0x07 & input)); peasycap->frame_read, (0x07 & input));
} else { } else {
JOM(8, "user is offered frame buffer %i\n", JOM(8, "user is offered frame buffer %i\n",
peasycap->frame_read); peasycap->frame_read);
} }
peasycap->frame_lock = 1; peasycap->frame_lock = 1;
JOM(8, "%i=peasycap->frame_fill\n", peasycap->frame_fill); JOM(8, "%i=peasycap->frame_fill\n", peasycap->frame_fill);
if (peasycap->frame_read == peasycap->frame_fill) { if (peasycap->frame_read == peasycap->frame_fill) {
if (peasycap->frame_lock) { if (peasycap->frame_lock) {
JOM(8, "WORRY: filling frame buffer " JOM(8, "WORRY: filling frame buffer "
"while offered to user\n"); "while offered to user\n");
}
} }
break;
} }
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_STREAMON: { case VIDIOC_STREAMON: {
int i; int i;
JOM(8, "VIDIOC_STREAMON\n"); JOM(8, "VIDIOC_STREAMON\n");
peasycap->isequence = 0; peasycap->isequence = 0;
for (i = 0; i < 180; i++) for (i = 0; i < 180; i++)
peasycap->merit[i] = 0; peasycap->merit[i] = 0;
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
}
submit_video_urbs(peasycap);
peasycap->video_idle = 0;
peasycap->audio_idle = 0;
peasycap->video_eof = 0;
peasycap->audio_eof = 0;
break;
} }
submit_video_urbs(peasycap);
peasycap->video_idle = 0;
peasycap->audio_idle = 0;
peasycap->video_eof = 0;
peasycap->audio_eof = 0;
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_STREAMOFF: { case VIDIOC_STREAMOFF: {
JOM(8, "VIDIOC_STREAMOFF\n"); JOM(8, "VIDIOC_STREAMOFF\n");
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
peasycap->video_idle = 1; peasycap->video_idle = 1;
peasycap->audio_idle = 1; peasycap->timeval0.tv_sec = 0; peasycap->audio_idle = 1;
peasycap->timeval0.tv_sec = 0;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* IF THE WAIT QUEUES ARE NOT CLEARED IN RESPONSE TO THE STREAMOFF COMMAND * IF THE WAIT QUEUES ARE NOT CLEARED IN RESPONSE TO THE STREAMOFF COMMAND
* THE USERSPACE PROGRAM, E.G. mplayer, MAY HANG ON EXIT. BEWARE. * THE USERSPACE PROGRAM, E.G. mplayer, MAY HANG ON EXIT. BEWARE.
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
JOM(8, "calling wake_up on wq_video and wq_audio\n"); JOM(8, "calling wake_up on wq_video and wq_audio\n");
wake_up_interruptible(&(peasycap->wq_video)); wake_up_interruptible(&(peasycap->wq_video));
#ifdef CONFIG_EASYCAP_OSS #ifdef CONFIG_EASYCAP_OSS
wake_up_interruptible(&(peasycap->wq_audio)); wake_up_interruptible(&(peasycap->wq_audio));
#else #else
if (NULL != peasycap->psubstream) if (NULL != peasycap->psubstream)
snd_pcm_period_elapsed(peasycap->psubstream); snd_pcm_period_elapsed(peasycap->psubstream);
#endif /* CONFIG_EASYCAP_OSS */ #endif /* CONFIG_EASYCAP_OSS */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
break; break;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_PARM: { case VIDIOC_G_PARM: {
struct v4l2_streamparm *pv4l2_streamparm; struct v4l2_streamparm *pv4l2_streamparm;
JOM(8, "VIDIOC_G_PARM\n"); JOM(8, "VIDIOC_G_PARM\n");
pv4l2_streamparm = kzalloc(sizeof(struct v4l2_streamparm), GFP_KERNEL); pv4l2_streamparm = kzalloc(sizeof(struct v4l2_streamparm), GFP_KERNEL);
if (!pv4l2_streamparm) { if (!pv4l2_streamparm) {
SAM("ERROR: out of memory\n"); SAM("ERROR: out of memory\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOMEM; return -ENOMEM;
} }
if (0 != copy_from_user(pv4l2_streamparm, (void __user *)arg, if (copy_from_user(pv4l2_streamparm,
sizeof(struct v4l2_streamparm))) { (void __user *)arg, sizeof(struct v4l2_streamparm))) {
kfree(pv4l2_streamparm); kfree(pv4l2_streamparm);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT; return -EFAULT;
} }
if (pv4l2_streamparm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (pv4l2_streamparm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
kfree(pv4l2_streamparm); kfree(pv4l2_streamparm);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
pv4l2_streamparm->parm.capture.capability = 0; pv4l2_streamparm->parm.capture.capability = 0;
pv4l2_streamparm->parm.capture.capturemode = 0; pv4l2_streamparm->parm.capture.capturemode = 0;
pv4l2_streamparm->parm.capture.timeperframe.numerator = 1; pv4l2_streamparm->parm.capture.timeperframe.numerator = 1;
if (peasycap->fps) { if (peasycap->fps) {
pv4l2_streamparm->parm.capture.timeperframe.
denominator = peasycap->fps;
} else {
if (true == peasycap->ntsc) {
pv4l2_streamparm->parm.capture.timeperframe. pv4l2_streamparm->parm.capture.timeperframe.
denominator = 30; denominator = peasycap->fps;
} else { } else {
pv4l2_streamparm->parm.capture.timeperframe. if (true == peasycap->ntsc) {
denominator = 25; pv4l2_streamparm->parm.capture.timeperframe.
denominator = 30;
} else {
pv4l2_streamparm->parm.capture.timeperframe.
denominator = 25;
}
} }
}
pv4l2_streamparm->parm.capture.readbuffers = pv4l2_streamparm->parm.capture.readbuffers =
peasycap->frame_buffer_many; peasycap->frame_buffer_many;
pv4l2_streamparm->parm.capture.extendedmode = 0; pv4l2_streamparm->parm.capture.extendedmode = 0;
if (0 != copy_to_user((void __user *)arg, pv4l2_streamparm, if (copy_to_user((void __user *)arg,
sizeof(struct v4l2_streamparm))) { pv4l2_streamparm,
sizeof(struct v4l2_streamparm))) {
kfree(pv4l2_streamparm);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EFAULT;
}
kfree(pv4l2_streamparm); kfree(pv4l2_streamparm);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); break;
return -EFAULT;
} }
kfree(pv4l2_streamparm);
break;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_PARM: { case VIDIOC_S_PARM: {
JOM(8, "VIDIOC_S_PARM unsupported\n"); JOM(8, "VIDIOC_S_PARM unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_AUDIO: { case VIDIOC_G_AUDIO: {
JOM(8, "VIDIOC_G_AUDIO unsupported\n"); JOM(8, "VIDIOC_G_AUDIO unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_AUDIO: { case VIDIOC_S_AUDIO: {
JOM(8, "VIDIOC_S_AUDIO unsupported\n"); JOM(8, "VIDIOC_S_AUDIO unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_S_TUNER: { case VIDIOC_S_TUNER: {
JOM(8, "VIDIOC_S_TUNER unsupported\n"); JOM(8, "VIDIOC_S_TUNER unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_FBUF: case VIDIOC_G_FBUF:
case VIDIOC_S_FBUF: case VIDIOC_S_FBUF:
case VIDIOC_OVERLAY: { case VIDIOC_OVERLAY: {
JOM(8, "VIDIOC_G_FBUF|VIDIOC_S_FBUF|VIDIOC_OVERLAY unsupported\n"); JOM(8, "VIDIOC_G_FBUF|VIDIOC_S_FBUF|VIDIOC_OVERLAY unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
case VIDIOC_G_TUNER: { case VIDIOC_G_TUNER: {
JOM(8, "VIDIOC_G_TUNER unsupported\n"); JOM(8, "VIDIOC_G_TUNER unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
case VIDIOC_G_FREQUENCY: case VIDIOC_G_FREQUENCY:
case VIDIOC_S_FREQUENCY: { case VIDIOC_S_FREQUENCY: {
JOM(8, "VIDIOC_G_FREQUENCY|VIDIOC_S_FREQUENCY unsupported\n"); JOM(8, "VIDIOC_G_FREQUENCY|VIDIOC_S_FREQUENCY unsupported\n");
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL; return -EINVAL;
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
default: { default: {
JOM(8, "ERROR: unrecognized V4L2 IOCTL command: 0x%08X\n", cmd); JOM(8, "ERROR: unrecognized V4L2 IOCTL command: 0x%08X\n", cmd);
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOIOCTLCMD;
}
}
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -ENOIOCTLCMD; JOM(4, "unlocked easycapdc60_dongle[%i].mutex_video\n", kd);
} return 0;
}
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
JOM(4, "unlocked easycapdc60_dongle[%i].mutex_video\n", kd);
return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册