Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /* Linux driver for Philips webcam
0003    Various miscellaneous functions and tables.
0004    (C) 1999-2003 Nemosoft Unv.
0005    (C) 2004-2006 Luc Saillard (luc@saillard.org)
0006 
0007    NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
0008    driver and thus may have bugs that are not present in the original version.
0009    Please send bug reports and support requests to <luc@saillard.org>.
0010    The decompression routines have been implemented by reverse-engineering the
0011    Nemosoft binary pwcx module. Caveat emptor.
0012 
0013 */
0014 
0015 
0016 #include "pwc.h"
0017 
0018 const int pwc_image_sizes[PSZ_MAX][2] =
0019 {
0020     { 128,  96 }, /* sqcif */
0021     { 160, 120 }, /* qsif */
0022     { 176, 144 }, /* qcif */
0023     { 320, 240 }, /* sif */
0024     { 352, 288 }, /* cif */
0025     { 640, 480 }, /* vga */
0026 };
0027 
0028 /* x,y -> PSZ_ */
0029 int pwc_get_size(struct pwc_device *pdev, int width, int height)
0030 {
0031     int i;
0032 
0033     /* Find the largest size supported by the camera that fits into the
0034        requested size. */
0035     for (i = PSZ_MAX - 1; i >= 0; i--) {
0036         if (!(pdev->image_mask & (1 << i)))
0037             continue;
0038 
0039         if (pwc_image_sizes[i][0] <= width &&
0040             pwc_image_sizes[i][1] <= height)
0041             return i;
0042     }
0043 
0044     /* No mode found, return the smallest mode we have */
0045     for (i = 0; i < PSZ_MAX; i++) {
0046         if (pdev->image_mask & (1 << i))
0047             return i;
0048     }
0049 
0050     /* Never reached there always is at least one supported mode */
0051     return 0;
0052 }
0053 
0054 /* initialize variables depending on type and decompressor */
0055 void pwc_construct(struct pwc_device *pdev)
0056 {
0057     if (DEVICE_USE_CODEC1(pdev->type)) {
0058 
0059         pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
0060         pdev->vcinterface = 2;
0061         pdev->vendpoint = 4;
0062         pdev->frame_header_size = 0;
0063         pdev->frame_trailer_size = 0;
0064 
0065     } else if (DEVICE_USE_CODEC3(pdev->type)) {
0066 
0067         pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
0068         pdev->vcinterface = 3;
0069         pdev->vendpoint = 5;
0070         pdev->frame_header_size = TOUCAM_HEADER_SIZE;
0071         pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
0072 
0073     } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ {
0074 
0075         pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
0076         pdev->vcinterface = 3;
0077         pdev->vendpoint = 4;
0078         pdev->frame_header_size = 0;
0079         pdev->frame_trailer_size = 0;
0080     }
0081 }