34 #include <linux/module.h> 35 #include <linux/init.h> 36 #include <linux/kernel.h> 37 #include <linux/version.h> 38 #include <linux/errno.h> 39 #include <linux/slab.h> 40 #include <linux/kref.h> 42 #include <linux/usb.h> 43 #include <media/v4l2-common.h> 48 #define MAX(a,b) ((a)>(b)?(a):(b)) 49 #define MIN(a,b) ((a)<(b)?(a):(b)) 50 #define CLIP(a,low,high) MAX((low),MIN((high),(a))) 55 const int,
const int,
const int);
58 const int,
const int,
const int);
61 const int,
const int,
const int);
64 const int,
const int,
const int);
68 const int,
const int,
const int);
71 const int,
const int,
const int);
78 static signed short stk11xx_yuv_interp[256][8] = {
79 {0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,1,0,0,0,1,0,0},{0,1,0,0,0,1,-1,0},
80 {1,2,0,0,-1,2,-1,0},{1,2,0,0,-1,2,-2,0},{1,3,0,-1,-1,3,-2,0},{2,3,0,-1,-2,3,-2,0},
81 {2,4,0,-1,-2,4,-3,0},{2,5,1,-1,-2,4,-3,0},{2,5,1,-1,-3,5,-4,0},{3,6,1,-1,-3,5,-4,0},
82 {3,6,1,-2,-3,6,-5,0},{3,7,1,-2,-4,6,-5,-1},{4,7,1,-2,-4,7,-5,-1},{4,8,1,-2,-4,7,-6,-1},
83 {4,9,1,-2,-5,8,-6,-1},{5,9,1,-2,-5,8,-7,-1},{5,10,2,-3,-5,9,-7,-1},{5,10,2,-3,-6,9,-7,-1},
84 {5,11,2,-3,-6,10,-8,-1},{6,11,2,-3,-6,10,-8,-1},{6,12,2,-3,-7,11,-9,-1},{6,13,2,-3,-7,11,-9,-1},
85 {7,13,2,-4,-7,12,-10,-1},{7,14,2,-4,-8,12,-10,-2},{7,14,2,-4,-8,13,-10,-2},{8,15,3,-4,-8,13,-11,-2},
86 {8,15,3,-4,-9,14,-11,-2},{8,16,3,-4,-9,14,-12,-2},{8,17,3,-5,-9,15,-12,-2},{9,17,3,-5,-10,15,-12,-2},
87 {9,18,3,-5,-10,16,-13,-2},{9,18,3,-5,-10,16,-13,-2},{10,19,3,-5,-11,17,-14,-2},{10,19,3,-5,-11,17,-14,-2},
88 {10,20,4,-6,-11,18,-15,-2},{11,20,4,-6,-12,18,-15,-3},{11,21,4,-6,-12,19,-15,-3},{11,22,4,-6,-12,19,-16,-3},
89 {11,22,4,-6,-13,20,-16,-3},{12,23,4,-6,-13,20,-17,-3},{12,23,4,-7,-13,21,-17,-3},{12,24,4,-7,-14,21,-18,-3},
90 {13,24,5,-7,-14,22,-18,-3},{13,25,5,-7,-14,22,-18,-3},{13,26,5,-7,-15,23,-19,-3},{14,26,5,-7,-15,23,-19,-3},
91 {14,27,5,-8,-15,24,-20,-3},{14,27,5,-8,-16,24,-20,-3},{14,28,5,-8,-16,25,-20,-4},{15,28,5,-8,-16,25,-21,-4},
92 {15,29,5,-8,-17,26,-21,-4},{15,30,6,-8,-17,26,-22,-4},{16,30,6,-9,-17,27,-22,-4},{16,31,6,-9,-18,27,-23,-4},
93 {16,31,6,-9,-18,28,-23,-4},{17,32,6,-9,-18,28,-23,-4},{17,32,6,-9,-19,29,-24,-4},{17,33,6,-9,-19,29,-24,-4},
94 {17,34,6,-10,-19,30,-25,-4},{18,34,6,-10,-20,30,-25,-4},{18,35,7,-10,-20,31,-25,-5},{18,35,7,-10,-20,31,-26,-5},
95 {19,36,7,-10,-21,32,-26,-5},{19,36,7,-10,-21,32,-27,-5},{19,37,7,-11,-21,33,-27,-5},{20,37,7,-11,-22,33,-28,-5},
96 {20,38,7,-11,-22,34,-28,-5},{20,39,7,-11,-22,34,-28,-5},{20,39,7,-11,-23,35,-29,-5},{21,40,8,-11,-23,35,-29,-5},
97 {21,40,8,-12,-23,36,-30,-5},{21,41,8,-12,-24,36,-30,-5},{22,41,8,-12,-24,37,-30,-6},{22,42,8,-12,-24,37,-31,-6},
98 {22,43,8,-12,-25,38,-31,-6},{23,43,8,-12,-25,38,-32,-6},{23,44,8,-13,-25,39,-32,-6},{23,44,9,-13,-26,39,-33,-6},
99 {23,45,9,-13,-26,40,-33,-6},{24,45,9,-13,-26,40,-33,-6},{24,46,9,-13,-27,41,-34,-6},{24,47,9,-14,-27,41,-34,-6},
100 {25,47,9,-14,-27,42,-35,-6},{25,48,9,-14,-28,42,-35,-6},{25,48,9,-14,-28,43,-36,-6},{26,49,9,-14,-28,43,-36,-7},
101 {26,49,10,-14,-29,44,-36,-7},{26,50,10,-15,-29,44,-37,-7},{26,51,10,-15,-29,45,-37,-7},{27,51,10,-15,-30,45,-38,-7},
102 {27,52,10,-15,-30,46,-38,-7},{27,52,10,-15,-30,46,-38,-7},{28,53,10,-15,-31,47,-39,-7},{28,53,10,-16,-31,47,-39,-7},
103 {28,54,10,-16,-31,48,-40,-7},{29,54,11,-16,-32,48,-40,-7},{29,55,11,-16,-32,49,-41,-7},{29,56,11,-16,-32,49,-41,-8},
104 {29,56,11,-16,-33,50,-41,-8},{30,57,11,-17,-33,50,-42,-8},{30,57,11,-17,-33,51,-42,-8},{30,58,11,-17,-34,51,-43,-8},
105 {31,58,11,-17,-34,52,-43,-8},{31,59,11,-17,-34,52,-43,-8},{31,60,12,-17,-35,53,-44,-8},{31,60,12,-18,-35,53,-44,-8},
106 {32,61,12,-18,-35,54,-45,-8},{32,61,12,-18,-36,54,-45,-8},{32,62,12,-18,-36,55,-46,-8},{33,62,12,-18,-36,55,-46,-9},
107 {33,63,12,-18,-37,56,-46,-9},{33,64,12,-19,-37,56,-47,-9},{34,64,12,-19,-37,57,-47,-9},{34,65,13,-19,-38,57,-48,-9},
108 {34,65,13,-19,-38,58,-48,-9},{34,66,13,-19,-38,58,-48,-9},{35,66,13,-19,-39,59,-49,-9},{35,67,13,-20,-39,59,-49,-9},
109 {35,68,13,-20,-39,60,-50,-9},{36,68,13,-20,-40,60,-50,-9},{36,69,13,-20,-40,61,-51,-9},{36,69,14,-20,-40,61,-51,-9},
110 {37,70,14,-20,-41,62,-51,-10},{37,70,14,-21,-41,62,-52,-10},{37,71,14,-21,-41,63,-52,-10},{37,72,14,-21,-42,63,-53,-10},
111 {38,72,14,-21,-42,64,-53,-10},{38,73,14,-21,-42,64,-54,-10},{38,73,14,-21,-43,65,-54,-10},{39,74,14,-22,-43,65,-54,-10},
112 {39,74,15,-22,-43,66,-55,-10},{39,75,15,-22,-44,66,-55,-10},{40,75,15,-22,-44,67,-56,-10},{40,76,15,-22,-44,67,-56,-10},
113 {40,77,15,-22,-45,68,-56,-11},{40,77,15,-23,-45,68,-57,-11},{41,78,15,-23,-45,69,-57,-11},{41,78,15,-23,-46,69,-58,-11},
114 {41,79,15,-23,-46,70,-58,-11},{42,79,16,-23,-46,70,-59,-11},{42,80,16,-23,-47,71,-59,-11},{42,81,16,-24,-47,71,-59,-11},
115 {43,81,16,-24,-47,72,-60,-11},{43,82,16,-24,-48,72,-60,-11},{43,82,16,-24,-48,73,-61,-11},{43,83,16,-24,-48,73,-61,-11},
116 {44,83,16,-24,-49,74,-61,-12},{44,84,16,-25,-49,74,-62,-12},{44,85,17,-25,-49,75,-62,-12},{45,85,17,-25,-50,75,-63,-12},
117 {45,86,17,-25,-50,76,-63,-12},{45,86,17,-25,-50,76,-64,-12},{46,87,17,-25,-51,77,-64,-12},{46,87,17,-26,-51,77,-64,-12},
118 {46,88,17,-26,-51,78,-65,-12},{46,89,17,-26,-52,78,-65,-12},{47,89,18,-26,-52,79,-66,-12},{47,90,18,-26,-52,79,-66,-12},
119 {47,90,18,-26,-53,80,-66,-13},{48,91,18,-27,-53,80,-67,-13},{48,91,18,-27,-53,81,-67,-13},{48,92,18,-27,-54,81,-68,-13},
120 {49,92,18,-27,-54,82,-68,-13},{49,93,18,-27,-54,82,-69,-13},{49,94,18,-28,-54,83,-69,-13},{49,94,19,-28,-55,83,-69,-13},
121 {50,95,19,-28,-55,84,-70,-13},{50,95,19,-28,-55,84,-70,-13},{50,96,19,-28,-56,85,-71,-13},{51,96,19,-28,-56,85,-71,-13},
122 {51,97,19,-29,-56,86,-72,-13},{51,98,19,-29,-57,86,-72,-14},{52,98,19,-29,-57,87,-72,-14},{52,99,19,-29,-57,87,-73,-14},
123 {52,99,20,-29,-58,88,-73,-14},{52,100,20,-29,-58,88,-74,-14},{53,100,20,-30,-58,89,-74,-14},{53,101,20,-30,-59,89,-74,-14},
124 {53,102,20,-30,-59,90,-75,-14},{54,102,20,-30,-59,90,-75,-14},{54,103,20,-30,-60,91,-76,-14},{54,103,20,-30,-60,91,-76,-14},
125 {55,104,20,-31,-60,92,-77,-14},{55,104,21,-31,-61,92,-77,-15},{55,105,21,-31,-61,93,-77,-15},{55,106,21,-31,-61,93,-78,-15},
126 {56,106,21,-31,-62,94,-78,-15},{56,107,21,-31,-62,94,-79,-15},{56,107,21,-32,-62,95,-79,-15},{57,108,21,-32,-63,95,-79,-15},
127 {57,108,21,-32,-63,96,-80,-15},{57,109,22,-32,-63,96,-80,-15},{58,109,22,-32,-64,97,-81,-15},{58,110,22,-32,-64,97,-81,-15},
128 {58,111,22,-33,-64,98,-82,-15},{58,111,22,-33,-65,98,-82,-16},{59,112,22,-33,-65,99,-82,-16},{59,112,22,-33,-65,99,-83,-16},
129 {59,113,22,-33,-66,100,-83,-16},{60,113,22,-33,-66,100,-84,-16},{60,114,23,-34,-66,101,-84,-16},{60,115,23,-34,-67,101,-84,-16},
130 {60,115,23,-34,-67,102,-85,-16},{61,116,23,-34,-67,102,-85,-16},{61,116,23,-34,-68,103,-86,-16},{61,117,23,-34,-68,103,-86,-16},
131 {62,117,23,-35,-68,104,-87,-16},{62,118,23,-35,-69,104,-87,-16},{62,119,23,-35,-69,105,-87,-17},{63,119,24,-35,-69,105,-88,-17},
132 {63,120,24,-35,-70,106,-88,-17},{63,120,24,-35,-70,106,-89,-17},{63,121,24,-36,-70,107,-89,-17},{64,121,24,-36,-71,107,-90,-17},
133 {64,122,24,-36,-71,108,-90,-17},{64,123,24,-36,-71,108,-90,-17},{65,123,24,-36,-72,109,-91,-17},{65,124,24,-36,-72,109,-91,-17},
134 {65,124,25,-37,-72,110,-92,-17},{66,125,25,-37,-73,110,-92,-17},{66,125,25,-37,-73,111,-92,-18},{66,126,25,-37,-73,111,-93,-18},
135 {66,127,25,-37,-74,112,-93,-18},{67,127,25,-37,-74,112,-94,-18},{67,128,25,-38,-74,113,-94,-18},{67,128,25,-38,-75,113,-95,-18},
136 {68,129,25,-38,-75,114,-95,-18},{68,129,26,-38,-75,114,-95,-18},{68,130,26,-38,-76,115,-96,-18},{69,130,26,-38,-76,115,-96,-18},
137 {69,131,26,-39,-76,116,-97,-18},{69,132,26,-39,-77,116,-97,-18},{69,132,26,-39,-77,117,-97,-19},{70,133,26,-39,-77,117,-98,-19},
138 {70,133,26,-39,-78,118,-98,-19},{70,134,27,-39,-78,118,-99,-19},{71,134,27,-40,-78,119,-99,-19},{71,135,27,-40,-79,119,-100,-19},
139 {71,136,27,-40,-79,120,-100,-19},{72,136,27,-40,-79,120,-100,-19},{72,137,27,-40,-80,121,-101,-19},{72,137,27,-40,-80,121,-101,-19},
140 {72,138,27,-41,-80,122,-102,-19},{73,138,27,-41,-81,122,-102,-19},{73,139,28,-41,-81,123,-103,-19},{73,140,28,-41,-81,123,-103,-20},
141 {74,140,28,-41,-82,124,-103,-20},{74,141,28,-42,-82,124,-104,-20},{74,141,28,-42,-82,125,-104,-20},{75,142,28,-42,-83,125,-105,-20},
142 {75,142,28,-42,-83,126,-105,-20},{75,143,28,-42,-83,126,-105,-20},{75,144,28,-42,-84,127,-106,-20},{76,144,29,-43,-84,127,-106,-20}
166 framebuf = dev->read_frame;
168 if (framebuf == NULL)
171 image = dev->image_data;
172 image += dev->images[dev->fill_image].
offset;
174 data = framebuf->data;
176 switch (dev->resolution) {
185 case STK11XX_160x120:
189 case STK11XX_213x160:
193 case STK11XX_320x240:
197 case STK11XX_640x480:
201 case STK11XX_720x576:
202 case STK11XX_800x600:
206 case STK11XX_1024x768:
210 case STK11XX_1280x1024:
220 case STK11XX_PALETTE_RGB24:
225 case STK11XX_PALETTE_RGB32:
230 case STK11XX_PALETTE_BGR24:
235 case STK11XX_PALETTE_BGR32:
240 case STK11XX_PALETTE_UYVY:
245 case STK11XX_PALETTE_YUYV:
279 case STK11XX_PALETTE_RGB24:
280 case STK11XX_PALETTE_BGR24:
281 case STK11XX_PALETTE_RGB32:
282 case STK11XX_PALETTE_BGR32:
283 depth = (depth == 24) ? 3 : 4;
285 if (brightness >= 32767) {
286 x = (brightness - 32767) / 256;
288 for (i = 0; i < (width * height * depth); i++) {
289 if ((*(img + i) + (
unsigned char) x) > 255)
292 *(img + i) += (
unsigned char) x;
298 for (i = 0; i < (width * height * depth); i++) {
299 if ((
unsigned char) x > *(img + i))
302 *(img + i) -= (
unsigned char) x;
308 case STK11XX_PALETTE_UYVY:
311 if (brightness >= 32767) {
312 x = (brightness - 32767) / 256;
314 for (i = 1; i < (width * height * depth); i=i+depth) {
315 if ((*(img + i) + (
unsigned char) x) > 255)
318 *(img + i) += (
unsigned char) x;
324 for (i = 1; i < (width * height * depth); i=i+depth) {
325 if ((
unsigned char) x > *(img + i))
328 *(img + i) -= (
unsigned char) x;
334 case STK11XX_PALETTE_YUYV:
337 if (brightness >= 32767) {
338 x = (brightness - 32767) / 256;
340 for (i = 0; i < (width * height * depth); i=i+depth) {
341 if ((*(img + i) + (
unsigned char) x) > 255)
344 *(img + i) += (
unsigned char) x;
350 for (i = 0; i < (width * height * depth); i=i+depth) {
351 if ((
unsigned char) x > *(img + i))
354 *(img + i) -= (
unsigned char) x;
385 int width = image->
x;
386 int height = image->
y;
388 int nwidth = width / factor;
389 int nheight = height / factor;
423 rgb += ((view->
y - nheight) / 2) * view->
x * 3;
426 rgb += ((view->
x - nwidth) / 2) * 3;
429 memset(rgb, 0, nwidth * 3);
434 for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
436 b = bayer + y * width + offset;
439 rgb += (view->
x - nwidth) * 3;
448 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
450 *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
451 *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
455 *rgb++ = (*(b-width) + *(b+width)) >> 1;
457 *rgb++ = (*(b-1) + *(b+1)) >> 1;
475 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
477 *rgb++ = (*(b-1) + *(b+1)) >> 1;
479 *rgb++ = (*(b-width) + *(b+width)) >> 1;
483 *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
484 *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
498 memset(rgb, 0, nwidth * 3);
524 int width = image->
x;
525 int height = image->
y;
527 int nwidth = width / factor;
528 int nheight = height / factor;
562 rgb += ((view->
y - nheight) / 2) * view->
x * 4;
565 rgb += ((view->
x - nwidth) / 2) * 4;
568 memset(rgb, 0, nwidth * 4);
573 for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
575 b = bayer + y * width + offset;
578 rgb += (view->
x - nwidth) * 4;
588 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
590 *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
591 *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
596 *rgb++ = (*(b-width) + *(b+width)) >> 1;
598 *rgb++ = (*(b-1) + *(b+1)) >> 1;
619 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
621 *rgb++ = (*(b-1) + *(b+1)) >> 1;
623 *rgb++ = (*(b-width) + *(b+width)) >> 1;
628 *rgb++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
629 *rgb++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
645 memset(rgb, 0, nwidth * 4);
671 int width = image->
x;
672 int height = image->
y;
674 int nwidth = width / factor;
675 int nheight = height / factor;
709 bgr += ((view->
y - nheight) / 2) * view->
x * 3;
712 bgr += ((view->
x - nwidth) / 2) * 3;
715 memset(bgr, 0, nwidth * 3);
720 for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
722 b = bayer + y * width + offset;
725 bgr += (view->
x - nwidth) * 3;
734 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
737 *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
738 *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
741 *bgr++ = (*(b-1) + *(b+1)) >> 1;
743 *bgr++ = (*(b-width) + *(b+width)) >> 1;
761 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
763 *bgr++ = (*(b-width) + *(b+width)) >> 1;
765 *bgr++ = (*(b-1) + *(b+1)) >> 1;
768 *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
769 *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
784 memset(bgr, 0, nwidth * 3);
810 int width = image->
x;
811 int height = image->
y;
813 int nwidth = width / factor;
814 int nheight = height / factor;
848 bgr += ((view->
y - nheight) / 2) * view->
x * 4;
851 bgr += ((view->
x - nwidth) / 2) * 4;
854 memset(bgr, 0, nwidth * 4);
859 for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
861 b = bayer + y * width + offset;
864 bgr += (view->
x - nwidth) * 4;
874 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
877 *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
878 *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
882 *bgr++ = (*(b-1) + *(b+1)) >> 1;
884 *bgr++ = (*(b-width) + *(b+width)) >> 1;
905 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
907 *bgr++ = (*(b-width) + *(b+width)) >> 1;
909 *bgr++ = (*(b-1) + *(b+1)) >> 1;
913 *bgr++ = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
914 *bgr++ = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
931 memset(bgr, 0, nwidth * 4);
960 int width = image->
x;
961 int height = image->
y;
963 int nwidth = width / factor;
964 int nheight = height / factor;
994 memset(yuv, 16, width * 2);
995 for (i=0; i<width*2; i=i+2, *(yuv+i)=128);
996 for (i=1; i<height; i++)
997 memcpy(yuv+i*width*2, yuv, width*2);
1003 yuv += ((view->
y - nheight) / 2) * view->
x * 2;
1006 yuv += ((view->
x - nwidth) / 2) * 2;
1009 memset(yuv, 16, nwidth * 2);
1010 for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=128);
1015 for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
1017 b = bayer + y * width + offset;
1020 yuv += (view->
x - nwidth) * 2;
1028 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1030 pR = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1031 pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1035 pR = (*(b-width) + *(b+width)) >> 1;
1037 pB = (*(b-1) + *(b+1)) >> 1;
1040 pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1041 pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1042 pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1044 pY = CLIP(pY, 0,255);
1045 pU = CLIP(pU, -127,127);
1046 pV = CLIP(pV, -127,127);
1049 *yuv++ = (112 * pU)/127 + 128;
1050 *yuv++ = (219 * pY)/255 + 16;
1053 *yuv++ = (112 * pV)/127 + 128;
1054 *yuv++ = (219 * pY)/255 + 16;
1070 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1072 pR = (*(b-1) + *(b+1)) >> 1;
1074 pB = (*(b-width) + *(b+width)) >> 1;
1078 pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1079 pB = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1082 pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1083 pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1084 pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1086 pY = CLIP(pY, 0,255);
1087 pU = CLIP(pU, -127,127);
1088 pV = CLIP(pV, -127,127);
1091 *yuv++ = (112 * pU)/127 + 128;
1092 *yuv++ = (219 * pY)/255 + 16;
1095 *yuv++ = (112 * pV)/127 + 128;
1096 *yuv++ = (219 * pY)/255 + 16;
1109 memset(yuv, 16, nwidth * 2);
1110 for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=128);
1139 int width = image->
x;
1140 int height = image->
y;
1142 int nwidth = width / factor;
1143 int nheight = height / factor;
1152 starty = height - 2;
1173 memset(yuv, 128, width * 2);
1174 for (i=0; i<width*2; i=i+2, *(yuv+i)=16);
1175 for (i=1; i<height; i++)
1176 memcpy(yuv+i*width*2, yuv, width*2);
1182 yuv += ((view->
y - nheight) / 2) * view->
x * 2;
1185 yuv += ((view->
x - nwidth) / 2) * 2;
1188 memset(yuv, 128, nwidth * 2);
1189 for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=16);
1194 for (j=0, y=starty; j<nheight-2; j++, y=y+stepy) {
1196 b = bayer + y * width + offset;
1199 yuv += (view->
x - nwidth) * 2;
1207 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1209 pR = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1210 pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1214 pR = (*(b-width) + *(b+width)) >> 1;
1216 pB = (*(b-1) + *(b+1)) >> 1;
1219 pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1220 pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1221 pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1223 pY = CLIP(pY, 0,255);
1224 pU = CLIP(pU, -127,127);
1225 pV = CLIP(pV, -127,127);
1228 *yuv++ = (219 * pY)/255 + 16;
1229 *yuv++ = (112 * pU)/127 + 128;
1232 *yuv++ = (219 * pY)/255 + 16;
1233 *yuv++ = (112 * pV)/127 + 128;
1249 for (i=0, x=startx; i<nwidth-2; i++, x=x+stepx) {
1251 pR = (*(b-1) + *(b+1)) >> 1;
1253 pB = (*(b-width) + *(b+width)) >> 1;
1257 pG = (*(b-width) + *(b-1) + *(b+1) + *(b+width)) >> 2;
1258 pB = (*(b-width-1) + *(b-width+1) + *(b+width-1) + *(b+width+1)) >> 2;
1261 pY = stk11xx_yuv_interp[pR][0] + stk11xx_yuv_interp[pG][1] + stk11xx_yuv_interp[pB][2];
1262 pU = stk11xx_yuv_interp[pR][3] + stk11xx_yuv_interp[pG][4] + stk11xx_yuv_interp[pB][5];
1263 pV = stk11xx_yuv_interp[pR][5] + stk11xx_yuv_interp[pG][6] + stk11xx_yuv_interp[pB][7];
1265 pY = CLIP(pY, 0,255);
1266 pU = CLIP(pU, -127,127);
1267 pV = CLIP(pV, -127,127);
1270 *yuv++ = (219 * pY)/255 + 16;
1271 *yuv++ = (112 * pU)/127 + 128;
1274 *yuv++ = (219 * pY)/255 + 16;
1275 *yuv++ = (112 * pV)/127 + 128;
1288 memset(yuv, 128, nwidth * 2);
1289 for (i=0; i<nwidth*2; i=i+2, *(yuv+i)=16);
void stk11xx_correct_brightness(uint8_t *, const int, const int, const int, int, int)
Correct the brightness of an image.
void stk11xx_b2bgr32(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to BGR32.
void stk11xx_b2rgb32(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to RGB32.
void stk11xx_b2uyvy(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to YUV (UYVY)
struct stk11xx_video vsettings
void stk11xx_b2yuyv(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to YUV (YUYV)
void stk11xx_b2bgr24(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to BGR24.
void stk11xx_b2rgb24(uint8_t *, uint8_t *, struct stk11xx_coord *, struct stk11xx_coord *, const int, const int, const int)
This function permits to convert an image from bayer to RGB24.
int stk11xx_decompress(struct usb_stk11xx *dev)
Decompress a frame.
Driver for Syntek USB video camera.