Merge tag 'regmap-fix-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux/fpc-iii.git] / drivers / media / usb / pwc / pwc-misc.c
blobe77fd5bd5e33cf295fa0cb015cd71b2ee5472330
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Linux driver for Philips webcam
3 Various miscellaneous functions and tables.
4 (C) 1999-2003 Nemosoft Unv.
5 (C) 2004-2006 Luc Saillard (luc@saillard.org)
7 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
8 driver and thus may have bugs that are not present in the original version.
9 Please send bug reports and support requests to <luc@saillard.org>.
10 The decompression routines have been implemented by reverse-engineering the
11 Nemosoft binary pwcx module. Caveat emptor.
16 #include "pwc.h"
18 const int pwc_image_sizes[PSZ_MAX][2] =
20 { 128, 96 }, /* sqcif */
21 { 160, 120 }, /* qsif */
22 { 176, 144 }, /* qcif */
23 { 320, 240 }, /* sif */
24 { 352, 288 }, /* cif */
25 { 640, 480 }, /* vga */
28 /* x,y -> PSZ_ */
29 int pwc_get_size(struct pwc_device *pdev, int width, int height)
31 int i;
33 /* Find the largest size supported by the camera that fits into the
34 requested size. */
35 for (i = PSZ_MAX - 1; i >= 0; i--) {
36 if (!(pdev->image_mask & (1 << i)))
37 continue;
39 if (pwc_image_sizes[i][0] <= width &&
40 pwc_image_sizes[i][1] <= height)
41 return i;
44 /* No mode found, return the smallest mode we have */
45 for (i = 0; i < PSZ_MAX; i++) {
46 if (pdev->image_mask & (1 << i))
47 return i;
50 /* Never reached there always is at least one supported mode */
51 return 0;
54 /* initialize variables depending on type and decompressor */
55 void pwc_construct(struct pwc_device *pdev)
57 if (DEVICE_USE_CODEC1(pdev->type)) {
59 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
60 pdev->vcinterface = 2;
61 pdev->vendpoint = 4;
62 pdev->frame_header_size = 0;
63 pdev->frame_trailer_size = 0;
65 } else if (DEVICE_USE_CODEC3(pdev->type)) {
67 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
68 pdev->vcinterface = 3;
69 pdev->vendpoint = 5;
70 pdev->frame_header_size = TOUCAM_HEADER_SIZE;
71 pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
73 } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ {
75 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
76 pdev->vcinterface = 3;
77 pdev->vendpoint = 4;
78 pdev->frame_header_size = 0;
79 pdev->frame_trailer_size = 0;