Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] pwc: Remove software emulation of arbritary resolutions

The pwc driver claims to support any resolution between 160x120
and 640x480, but emulates this by simply drawing a black border
around the image. Userspace can draw its own black border if it
really wants one.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans de Goede and committed by
Mauro Carvalho Chehab
795e6eb3 a08d2c72

+93 -223
-10
Documentation/feature-removal-schedule.txt
··· 460 460 461 461 ---------------------------- 462 462 463 - What: Software emulation of arbritary resolutions in the pwc driver 464 - When: 3.3 465 - Why: The pwc driver claims to support any resolution between 160x120 466 - and 640x480, but emulates this by simply drawing a black border 467 - around the image. Userspace can draw its own black border if it 468 - really wants one. 469 - Who: Hans de Goede <hdegoede@redhat.com> 470 - 471 - ---------------------------- 472 - 473 463 What: For VIDIOC_S_FREQUENCY the type field must match the device node's type. 474 464 If not, return -EINVAL. 475 465 When: 3.2
+13 -56
drivers/media/video/pwc/pwc-ctrl.c
··· 102 102 #include "pwc-nala.h" 103 103 }; 104 104 105 - static void pwc_set_image_buffer_size(struct pwc_device *pdev); 106 - 107 105 /****************************************************************************/ 108 106 109 107 static int _send_control_msg(struct pwc_device *pdev, ··· 219 221 /* Set various parameters */ 220 222 pdev->vframes = frames; 221 223 pdev->valternate = pEntry->alternate; 222 - pdev->image = pwc_image_sizes[size]; 223 - pdev->frame_size = (pdev->image.x * pdev->image.y * 3) / 2; 224 + pdev->width = pwc_image_sizes[size][0]; 225 + pdev->height = pwc_image_sizes[size][1]; 226 + pdev->frame_size = (pdev->width * pdev->height * 3) / 2; 224 227 if (pEntry->compressed) { 225 228 if (pdev->release < 5) { /* 4 fold compression */ 226 229 pdev->vbandlength = 528; ··· 281 282 /* Set various parameters */ 282 283 pdev->vframes = frames; 283 284 pdev->valternate = pChoose->alternate; 284 - pdev->image = pwc_image_sizes[size]; 285 + pdev->width = pwc_image_sizes[size][0]; 286 + pdev->height = pwc_image_sizes[size][1]; 285 287 pdev->vbandlength = pChoose->bandlength; 286 288 if (pChoose->bandlength > 0) 287 - pdev->frame_size = (pChoose->bandlength * pdev->image.y) / 4; 289 + pdev->frame_size = (pChoose->bandlength * pdev->height) / 4; 288 290 else 289 - pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8; 291 + pdev->frame_size = (pdev->width * pdev->height * 12) / 8; 290 292 return 0; 291 293 } 292 294 ··· 339 339 /* All set and go */ 340 340 pdev->vframes = frames; 341 341 pdev->valternate = pChoose->alternate; 342 - pdev->image = pwc_image_sizes[size]; 342 + pdev->width = pwc_image_sizes[size][0]; 343 + pdev->height = pwc_image_sizes[size][1]; 343 344 pdev->vbandlength = pChoose->bandlength; 344 345 if (pdev->vbandlength > 0) 345 - pdev->frame_size = (pdev->vbandlength * pdev->image.y) / 4; 346 + pdev->frame_size = (pdev->vbandlength * pdev->height) / 4; 346 347 else 347 - pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8; 348 + pdev->frame_size = (pdev->width * pdev->height * 12) / 8; 348 349 PWC_TRACE("frame_size=%d, vframes=%d, vsize=%d, vbandlength=%d\n", 349 350 pdev->frame_size, pdev->vframes, size, pdev->vbandlength); 350 351 return 0; 351 352 } 352 353 353 - 354 - 355 - /** 356 - @pdev: device structure 357 - @width: viewport width 358 - @height: viewport height 359 - @frame: framerate, in fps 360 - @compression: preferred compression ratio 361 - */ 362 354 int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, 363 355 int frames, int compression) 364 356 { 365 357 int ret, size; 366 358 367 359 PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", width, height, frames, pdev->pixfmt); 368 - size = pwc_decode_size(pdev, width, height); 369 - if (size < 0) { 370 - PWC_DEBUG_MODULE("Could not find suitable size.\n"); 371 - return -ERANGE; 372 - } 360 + size = pwc_get_size(pdev, width, height); 373 361 PWC_TRACE("decode_size = %d.\n", size); 374 362 375 363 if (DEVICE_USE_CODEC1(pdev->type)) { ··· 373 385 PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret); 374 386 return ret; 375 387 } 376 - pdev->view.x = width; 377 - pdev->view.y = height; 378 388 pdev->vcompression = compression; 379 389 pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size; 380 - pwc_set_image_buffer_size(pdev); 381 - PWC_DEBUG_SIZE("Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y); 390 + PWC_DEBUG_SIZE("Set resolution to %dx%d\n", pdev->width, pdev->height); 382 391 return 0; 383 392 } 384 393 ··· 430 445 } 431 446 432 447 return ret; 433 - } 434 - 435 - static void pwc_set_image_buffer_size(struct pwc_device *pdev) 436 - { 437 - int factor = 0; 438 - 439 - /* for V4L2_PIX_FMT_YUV420 */ 440 - switch (pdev->pixfmt) { 441 - case V4L2_PIX_FMT_YUV420: 442 - factor = 6; 443 - break; 444 - case V4L2_PIX_FMT_PWC1: 445 - case V4L2_PIX_FMT_PWC2: 446 - factor = 6; /* can be uncompressed YUV420P */ 447 - break; 448 - } 449 - 450 - /* Set sizes in bytes */ 451 - pdev->image.size = pdev->image.x * pdev->image.y * factor / 4; 452 - pdev->view.size = pdev->view.x * pdev->view.y * factor / 4; 453 - 454 - /* Align offset, or you'll get some very weird results in 455 - YUV420 mode... x must be multiple of 4 (to get the Y's in 456 - place), and y even (or you'll mixup U & V). This is less of a 457 - problem for YUV420P. 458 - */ 459 - pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC; 460 - pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE; 461 448 } 462 449 463 450 int pwc_get_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data)
+10 -19
drivers/media/video/pwc/pwc-dec23.c
··· 656 656 * 657 657 * Uncompress a pwc23 buffer. 658 658 * 659 - * pwc.view: size of the image wanted 660 - * pwc.image: size of the image returned by the camera 661 - * pwc.offset: (x,y) to displayer image in the view 662 - * 663 659 * src: raw data 664 660 * dst: image output 665 661 */ ··· 663 667 const void *src, 664 668 void *dst) 665 669 { 666 - int bandlines_left, stride, bytes_per_block; 670 + int bandlines_left, bytes_per_block; 667 671 struct pwc_dec23_private *pdec = pwc->decompress_data; 668 672 669 673 /* YUV420P image format */ ··· 674 678 675 679 mutex_lock(&pdec->lock); 676 680 677 - bandlines_left = pwc->image.y / 4; 678 - bytes_per_block = pwc->view.x * 4; 679 - plane_size = pwc->view.x * pwc->view.y; 681 + bandlines_left = pwc->height / 4; 682 + bytes_per_block = pwc->width * 4; 683 + plane_size = pwc->height * pwc->width; 680 684 681 - /* offset in Y plane */ 682 - stride = pwc->view.x * pwc->offset.y; 683 - pout_planar_y = dst + stride + pwc->offset.x; 684 - 685 - /* offsets in U/V planes */ 686 - stride = (pwc->view.x * pwc->offset.y) / 4 + pwc->offset.x / 2; 687 - pout_planar_u = dst + plane_size + stride; 688 - pout_planar_v = dst + plane_size + plane_size / 4 + stride; 685 + pout_planar_y = dst; 686 + pout_planar_u = dst + plane_size; 687 + pout_planar_v = dst + plane_size + plane_size / 4; 689 688 690 689 while (bandlines_left--) { 691 690 DecompressBand23(pwc->decompress_data, 692 691 src, 693 692 pout_planar_y, pout_planar_u, pout_planar_v, 694 - pwc->image.x, pwc->view.x); 693 + pwc->width, pwc->width); 695 694 src += pwc->vbandlength; 696 695 pout_planar_y += bytes_per_block; 697 - pout_planar_u += pwc->view.x; 698 - pout_planar_v += pwc->view.x; 696 + pout_planar_u += pwc->width; 697 + pout_planar_v += pwc->width; 699 698 } 700 699 mutex_unlock(&pdec->lock); 701 700 }
+6 -4
drivers/media/video/pwc/pwc-if.c
··· 656 656 unsigned int sizes[], void *alloc_ctxs[]) 657 657 { 658 658 struct pwc_device *pdev = vb2_get_drv_priv(vq); 659 + int size; 659 660 660 661 if (*nbuffers < MIN_FRAMES) 661 662 *nbuffers = MIN_FRAMES; ··· 665 664 666 665 *nplanes = 1; 667 666 668 - sizes[0] = PAGE_ALIGN((pdev->abs_max.x * pdev->abs_max.y * 3) / 2); 667 + size = pwc_get_size(pdev, MAX_WIDTH, MAX_HEIGHT); 668 + sizes[0] = PAGE_ALIGN(pwc_image_sizes[size][0] * 669 + pwc_image_sizes[size][1] * 3 / 2); 669 670 670 671 return 0; 671 672 } ··· 745 742 pwc_camera_power(pdev, 1); 746 743 if (pdev->power_save) { 747 744 /* Restore video mode */ 748 - pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, 745 + pwc_set_video_mode(pdev, pdev->width, pdev->height, 749 746 pdev->vframes, pdev->vcompression); 750 747 } 751 748 pwc_set_leds(pdev, led_on, led_off); ··· 1059 1056 } 1060 1057 pdev->type = type_id; 1061 1058 pdev->vframes = default_fps; 1062 - strcpy(pdev->serial, serial_number); 1063 1059 pdev->features = features; 1064 1060 pwc_construct(pdev); /* set min/max sizes correct */ 1065 1061 ··· 1121 1119 pwc_set_leds(pdev, 0, 0); 1122 1120 1123 1121 /* Setup intial videomode */ 1124 - rc = pwc_set_video_mode(pdev, pdev->view_max.x, pdev->view_max.y, 1122 + rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, 1125 1123 pdev->vframes, pdev->vcompression); 1126 1124 if (rc) 1127 1125 goto err_free_mem;
+27 -62
drivers/media/video/pwc/pwc-misc.c
··· 27 27 28 28 #include "pwc.h" 29 29 30 - const struct pwc_coord pwc_image_sizes[PSZ_MAX] = 30 + const int pwc_image_sizes[PSZ_MAX][2] = 31 31 { 32 - { 128, 96, 0 }, /* sqcif */ 33 - { 160, 120, 0 }, /* qsif */ 34 - { 176, 144, 0 }, /* qcif */ 35 - { 320, 240, 0 }, /* sif */ 36 - { 352, 288, 0 }, /* cif */ 37 - { 640, 480, 0 }, /* vga */ 32 + { 128, 96 }, /* sqcif */ 33 + { 160, 120 }, /* qsif */ 34 + { 176, 144 }, /* qcif */ 35 + { 320, 240 }, /* sif */ 36 + { 352, 288 }, /* cif */ 37 + { 640, 480 }, /* vga */ 38 38 }; 39 39 40 40 /* x,y -> PSZ_ */ 41 - int pwc_decode_size(struct pwc_device *pdev, int width, int height) 41 + int pwc_get_size(struct pwc_device *pdev, int width, int height) 42 42 { 43 - int i, find; 44 - 45 - /* Make sure we don't go beyond our max size. 46 - NB: we have different limits for RAW and normal modes. In case 47 - you don't have the decompressor loaded or use RAW mode, 48 - the maximum viewable size is smaller. 49 - */ 50 - if (pdev->pixfmt != V4L2_PIX_FMT_YUV420) 51 - { 52 - if (width > pdev->abs_max.x || height > pdev->abs_max.y) 53 - { 54 - PWC_DEBUG_SIZE("VIDEO_PALETTE_RAW: going beyond abs_max.\n"); 55 - return -1; 56 - } 57 - } 58 - else 59 - { 60 - if (width > pdev->view_max.x || height > pdev->view_max.y) 61 - { 62 - PWC_DEBUG_SIZE("VIDEO_PALETTE_not RAW: going beyond view_max.\n"); 63 - return -1; 64 - } 65 - } 43 + int i; 66 44 67 45 /* Find the largest size supported by the camera that fits into the 68 - requested size. 69 - */ 70 - find = -1; 71 - for (i = 0; i < PSZ_MAX; i++) { 72 - if (pdev->image_mask & (1 << i)) { 73 - if (pwc_image_sizes[i].x <= width && pwc_image_sizes[i].y <= height) 74 - find = i; 75 - } 46 + requested size. */ 47 + for (i = PSZ_MAX - 1; i >= 0; i--) { 48 + if (!(pdev->image_mask & (1 << i))) 49 + continue; 50 + 51 + if (pwc_image_sizes[i][0] <= width && 52 + pwc_image_sizes[i][1] <= height) 53 + return i; 76 54 } 77 - return find; 55 + 56 + /* No mode found, return the smallest mode we have */ 57 + for (i = 0; i < PSZ_MAX; i++) { 58 + if (pdev->image_mask & (1 << i)) 59 + return i; 60 + } 61 + 62 + /* Never reached there always is atleast one supported mode */ 63 + return 0; 78 64 } 79 65 80 - /* initialize variables depending on type and decompressor*/ 66 + /* initialize variables depending on type and decompressor */ 81 67 void pwc_construct(struct pwc_device *pdev) 82 68 { 83 69 if (DEVICE_USE_CODEC1(pdev->type)) { 84 70 85 - pdev->view_min.x = 128; 86 - pdev->view_min.y = 96; 87 - pdev->view_max.x = 352; 88 - pdev->view_max.y = 288; 89 - pdev->abs_max.x = 352; 90 - pdev->abs_max.y = 288; 91 71 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF; 92 72 pdev->vcinterface = 2; 93 73 pdev->vendpoint = 4; ··· 76 96 77 97 } else if (DEVICE_USE_CODEC3(pdev->type)) { 78 98 79 - pdev->view_min.x = 160; 80 - pdev->view_min.y = 120; 81 - pdev->view_max.x = 640; 82 - pdev->view_max.y = 480; 83 99 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA; 84 - pdev->abs_max.x = 640; 85 - pdev->abs_max.y = 480; 86 100 pdev->vcinterface = 3; 87 101 pdev->vendpoint = 5; 88 102 pdev->frame_header_size = TOUCAM_HEADER_SIZE; ··· 84 110 85 111 } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ { 86 112 87 - pdev->view_min.x = 128; 88 - pdev->view_min.y = 96; 89 - /* Anthill bug #38: PWC always reports max size, even without PWCX */ 90 - pdev->view_max.x = 640; 91 - pdev->view_max.y = 480; 92 113 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA; 93 - pdev->abs_max.x = 640; 94 - pdev->abs_max.y = 480; 95 114 pdev->vcinterface = 3; 96 115 pdev->vendpoint = 4; 97 116 pdev->frame_header_size = 0; 98 117 pdev->frame_trailer_size = 0; 99 118 } 100 119 pdev->pixfmt = V4L2_PIX_FMT_YUV420; /* default */ 101 - pdev->view_min.size = pdev->view_min.x * pdev->view_min.y; 102 - pdev->view_max.size = pdev->view_max.x * pdev->view_max.y; 103 120 }
+9 -29
drivers/media/video/pwc/pwc-uncompress.c
··· 35 35 36 36 int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf) 37 37 { 38 - int n, line, col, stride; 38 + int n, line, col; 39 39 void *yuv, *image; 40 40 u16 *src; 41 41 u16 *dsty, *dstu, *dstv; ··· 60 60 return 0; 61 61 } 62 62 63 - vb2_set_plane_payload(&fbuf->vb, 0, pdev->view.size); 63 + vb2_set_plane_payload(&fbuf->vb, 0, 64 + pdev->width * pdev->height * 3 / 2); 64 65 65 66 if (pdev->vbandlength == 0) { 66 67 /* Uncompressed mode. 67 - * We copy the data into the output buffer, using the viewport 68 - * size (which may be larger than the image size). 69 - * Unfortunately we have to do a bit of byte stuffing to get 70 - * the desired output format/size. 71 68 * 72 69 * We do some byte shuffling here to go from the 73 70 * native format to YUV420P. 74 71 */ 75 72 src = (u16 *)yuv; 76 - n = pdev->view.x * pdev->view.y; 73 + n = pdev->width * pdev->height; 74 + dsty = (u16 *)(image); 75 + dstu = (u16 *)(image + n); 76 + dstv = (u16 *)(image + n + n / 4); 77 77 78 - /* offset in Y plane */ 79 - stride = pdev->view.x * pdev->offset.y + pdev->offset.x; 80 - dsty = (u16 *)(image + stride); 81 - 82 - /* offsets in U/V planes */ 83 - stride = pdev->view.x * pdev->offset.y / 4 + pdev->offset.x / 2; 84 - dstu = (u16 *)(image + n + stride); 85 - dstv = (u16 *)(image + n + n / 4 + stride); 86 - 87 - /* increment after each line */ 88 - stride = (pdev->view.x - pdev->image.x) / 2; /* u16 is 2 bytes */ 89 - 90 - for (line = 0; line < pdev->image.y; line++) { 91 - for (col = 0; col < pdev->image.x; col += 4) { 78 + for (line = 0; line < pdev->height; line++) { 79 + for (col = 0; col < pdev->width; col += 4) { 92 80 *dsty++ = *src++; 93 81 *dsty++ = *src++; 94 82 if (line & 1) ··· 84 96 else 85 97 *dstu++ = *src++; 86 98 } 87 - dsty += stride; 88 - if (line & 1) 89 - dstv += (stride >> 1); 90 - else 91 - dstu += (stride >> 1); 92 99 } 93 100 94 101 return 0; ··· 105 122 } 106 123 return 0; 107 124 } 108 - 109 - 110 - /* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
+22 -30
drivers/media/video/pwc/pwc-v4l.c
··· 398 398 static void pwc_vidioc_fill_fmt(const struct pwc_device *pdev, struct v4l2_format *f) 399 399 { 400 400 memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format)); 401 - f->fmt.pix.width = pdev->view.x; 402 - f->fmt.pix.height = pdev->view.y; 401 + f->fmt.pix.width = pdev->width; 402 + f->fmt.pix.height = pdev->height; 403 403 f->fmt.pix.field = V4L2_FIELD_NONE; 404 404 if (pdev->pixfmt == V4L2_PIX_FMT_YUV420) { 405 405 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; ··· 429 429 /* ioctl(VIDIOC_TRY_FMT) */ 430 430 static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f) 431 431 { 432 + int size; 433 + 432 434 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 433 435 PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); 434 436 return -EINVAL; ··· 457 455 458 456 } 459 457 460 - if (f->fmt.pix.width > pdev->view_max.x) 461 - f->fmt.pix.width = pdev->view_max.x; 462 - else if (f->fmt.pix.width < pdev->view_min.x) 463 - f->fmt.pix.width = pdev->view_min.x; 464 - 465 - if (f->fmt.pix.height > pdev->view_max.y) 466 - f->fmt.pix.height = pdev->view_max.y; 467 - else if (f->fmt.pix.height < pdev->view_min.y) 468 - f->fmt.pix.height = pdev->view_min.y; 458 + size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height); 459 + f->fmt.pix.width = pwc_image_sizes[size][0]; 460 + f->fmt.pix.height = pwc_image_sizes[size][1]; 469 461 470 462 return 0; 471 463 } ··· 968 972 969 973 mutex_lock(&pdev->udevlock); /* To avoid race with s_fmt */ 970 974 PWC_DEBUG_IOCTL("ioctl(VIDIOC_G_FMT) return size %dx%d\n", 971 - pdev->image.x, pdev->image.y); 975 + pdev->width, pdev->height); 972 976 pwc_vidioc_fill_fmt(pdev, f); 973 977 mutex_unlock(&pdev->udevlock); 974 978 return 0; ··· 1057 1061 struct pwc_device *pdev = video_drvdata(file); 1058 1062 unsigned int i = 0, index = fsize->index; 1059 1063 1060 - if (fsize->pixel_format == V4L2_PIX_FMT_YUV420) { 1064 + if (fsize->pixel_format == V4L2_PIX_FMT_YUV420 || 1065 + (fsize->pixel_format == V4L2_PIX_FMT_PWC1 && 1066 + DEVICE_USE_CODEC1(pdev->type)) || 1067 + (fsize->pixel_format == V4L2_PIX_FMT_PWC2 && 1068 + DEVICE_USE_CODEC23(pdev->type))) { 1061 1069 for (i = 0; i < PSZ_MAX; i++) { 1062 - if (pdev->image_mask & (1UL << i)) { 1063 - if (!index--) { 1064 - fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; 1065 - fsize->discrete.width = pwc_image_sizes[i].x; 1066 - fsize->discrete.height = pwc_image_sizes[i].y; 1067 - return 0; 1068 - } 1070 + if (!(pdev->image_mask & (1UL << i))) 1071 + continue; 1072 + if (!index--) { 1073 + fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; 1074 + fsize->discrete.width = pwc_image_sizes[i][0]; 1075 + fsize->discrete.height = pwc_image_sizes[i][1]; 1076 + return 0; 1069 1077 } 1070 1078 } 1071 - } else if (fsize->index == 0 && 1072 - ((fsize->pixel_format == V4L2_PIX_FMT_PWC1 && DEVICE_USE_CODEC1(pdev->type)) || 1073 - (fsize->pixel_format == V4L2_PIX_FMT_PWC2 && DEVICE_USE_CODEC23(pdev->type)))) { 1074 - 1075 - fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; 1076 - fsize->discrete.width = pdev->abs_max.x; 1077 - fsize->discrete.height = pdev->abs_max.y; 1078 - return 0; 1079 1079 } 1080 1080 return -EINVAL; 1081 1081 } ··· 1084 1092 unsigned int i; 1085 1093 1086 1094 for (i = 0; i < PSZ_MAX; i++) { 1087 - if (pwc_image_sizes[i].x == fival->width && 1088 - pwc_image_sizes[i].y == fival->height) { 1095 + if (pwc_image_sizes[i][0] == fival->width && 1096 + pwc_image_sizes[i][1] == fival->height) { 1089 1097 size = i; 1090 1098 break; 1091 1099 }
+6 -13
drivers/media/video/pwc/pwc.h
··· 107 107 #define FEATURE_CODEC1 0x0002 108 108 #define FEATURE_CODEC2 0x0004 109 109 110 + #define MAX_WIDTH 640 111 + #define MAX_HEIGHT 480 112 + 110 113 /* Ignore errors in the first N frames, to allow for startup delays */ 111 114 #define FRAME_LOWMARK 5 112 115 ··· 208 205 __u8 rawframe[0]; /* frame_size = H / 4 * vbandlength */ 209 206 } __packed; 210 207 211 - /* structure for transferring x & y coordinates */ 212 - struct pwc_coord { 213 - int x, y; /* guess what */ 214 - int size; /* size, or offset */ 215 - }; 216 - 217 208 /* intermediate buffers with raw data from the USB cam */ 218 209 struct pwc_frame_buf 219 210 { ··· 230 233 int type; 231 234 int release; /* release number */ 232 235 int features; /* feature bits */ 233 - char serial[30]; /* serial number (string) */ 234 236 235 237 /*** Video data ***/ 236 238 struct file *capt_file; /* file doing video capture */ ··· 282 286 * a gray or black border. view_min <= image <= view <= view_max; 283 287 */ 284 288 int image_mask; /* supported sizes */ 285 - struct pwc_coord view_min, view_max; /* minimum and maximum view */ 286 - struct pwc_coord abs_max; /* maximum supported size */ 287 - struct pwc_coord image, view; /* image and viewport size */ 288 - struct pwc_coord offset; /* offset of the viewport */ 289 + int width, height; /* current resolution */ 289 290 290 291 #ifdef CONFIG_USB_PWC_INPUT_EVDEV 291 292 struct input_dev *button_dev; /* webcam snapshot button input */ ··· 357 364 358 365 /** Functions in pwc-misc.c */ 359 366 /* sizes in pixels */ 360 - extern const struct pwc_coord pwc_image_sizes[PSZ_MAX]; 367 + extern const int pwc_image_sizes[PSZ_MAX][2]; 361 368 362 - int pwc_decode_size(struct pwc_device *pdev, int width, int height); 369 + int pwc_get_size(struct pwc_device *pdev, int width, int height); 363 370 void pwc_construct(struct pwc_device *pdev); 364 371 365 372 /** Functions in pwc-ctrl.c */