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.
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.
10 The decompression routines have been implemented by reverse-engineering the
11 Nemosoft binary pwcx module. Caveat emptor.
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 */
29 int pwc_get_size(struct pwc_device *pdev, int width, int height)
33 /* Find the largest size supported by the camera that fits into the
35 for (i = PSZ_MAX - 1; i >= 0; i--) {
36 if (!(pdev->image_mask & (1 << i)))
39 if (pwc_image_sizes[i][0] <= width &&
40 pwc_image_sizes[i][1] <= height)
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))
50 /* Never reached there always is at least one supported mode */
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;
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;
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;
78 pdev->frame_header_size = 0;
79 pdev->frame_trailer_size = 0;