]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
d56410e0 | 2 | /* Linux driver for Philips webcam |
1da177e4 LT |
3 | Various miscellaneous functions and tables. |
4 | (C) 1999-2003 Nemosoft Unv. | |
2b455db6 | 5 | (C) 2004-2006 Luc Saillard (luc@saillard.org) |
1da177e4 LT |
6 | |
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. | |
12 | ||
1da177e4 LT |
13 | */ |
14 | ||
1da177e4 LT |
15 | |
16 | #include "pwc.h" | |
17 | ||
795e6eb3 | 18 | const int pwc_image_sizes[PSZ_MAX][2] = |
1da177e4 | 19 | { |
795e6eb3 HG |
20 | { 128, 96 }, /* sqcif */ |
21 | { 160, 120 }, /* qsif */ | |
22 | { 176, 144 }, /* qcif */ | |
23 | { 320, 240 }, /* sif */ | |
24 | { 352, 288 }, /* cif */ | |
25 | { 640, 480 }, /* vga */ | |
1da177e4 LT |
26 | }; |
27 | ||
28 | /* x,y -> PSZ_ */ | |
795e6eb3 | 29 | int pwc_get_size(struct pwc_device *pdev, int width, int height) |
1da177e4 | 30 | { |
795e6eb3 | 31 | int i; |
1da177e4 LT |
32 | |
33 | /* Find the largest size supported by the camera that fits into the | |
795e6eb3 HG |
34 | requested size. */ |
35 | for (i = PSZ_MAX - 1; i >= 0; i--) { | |
36 | if (!(pdev->image_mask & (1 << i))) | |
37 | continue; | |
38 | ||
39 | if (pwc_image_sizes[i][0] <= width && | |
40 | pwc_image_sizes[i][1] <= height) | |
41 | return i; | |
42 | } | |
43 | ||
44 | /* No mode found, return the smallest mode we have */ | |
1da177e4 | 45 | for (i = 0; i < PSZ_MAX; i++) { |
795e6eb3 HG |
46 | if (pdev->image_mask & (1 << i)) |
47 | return i; | |
1da177e4 | 48 | } |
795e6eb3 | 49 | |
3e4d8f48 | 50 | /* Never reached there always is at least one supported mode */ |
795e6eb3 | 51 | return 0; |
1da177e4 LT |
52 | } |
53 | ||
795e6eb3 | 54 | /* initialize variables depending on type and decompressor */ |
1da177e4 LT |
55 | void pwc_construct(struct pwc_device *pdev) |
56 | { | |
2b455db6 LS |
57 | if (DEVICE_USE_CODEC1(pdev->type)) { |
58 | ||
1da177e4 LT |
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; | |
2b455db6 LS |
64 | |
65 | } else if (DEVICE_USE_CODEC3(pdev->type)) { | |
66 | ||
2b455db6 | 67 | pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA; |
2b455db6 LS |
68 | pdev->vcinterface = 3; |
69 | pdev->vendpoint = 5; | |
70 | pdev->frame_header_size = TOUCAM_HEADER_SIZE; | |
71 | pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE; | |
72 | ||
73 | } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ { | |
74 | ||
1da177e4 | 75 | pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA; |
1da177e4 LT |
76 | pdev->vcinterface = 3; |
77 | pdev->vendpoint = 4; | |
78 | pdev->frame_header_size = 0; | |
79 | pdev->frame_trailer_size = 0; | |
1da177e4 | 80 | } |
1da177e4 | 81 | } |