brintos

brintos / linux-shallow public Read only

0
0
Text · 2.2 KiB · e77fd5b Raw
82 lines · c
1// SPDX-License-Identifier: GPL-2.0-or-later2/* Linux driver for Philips webcam3   Various miscellaneous functions and tables.4   (C) 1999-2003 Nemosoft Unv.5   (C) 2004-2006 Luc Saillard (luc@saillard.org)6 7   NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx8   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 the11   Nemosoft binary pwcx module. Caveat emptor.12 13*/14 15 16#include "pwc.h"17 18const int pwc_image_sizes[PSZ_MAX][2] =19{20	{ 128,  96 }, /* sqcif */21	{ 160, 120 }, /* qsif */22	{ 176, 144 }, /* qcif */23	{ 320, 240 }, /* sif */24	{ 352, 288 }, /* cif */25	{ 640, 480 }, /* vga */26};27 28/* x,y -> PSZ_ */29int pwc_get_size(struct pwc_device *pdev, int width, int height)30{31	int i;32 33	/* Find the largest size supported by the camera that fits into the34	   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 */45	for (i = 0; i < PSZ_MAX; i++) {46		if (pdev->image_mask & (1 << i))47			return i;48	}49 50	/* Never reached there always is at least one supported mode */51	return 0;52}53 54/* initialize variables depending on type and decompressor */55void pwc_construct(struct pwc_device *pdev)56{57	if (DEVICE_USE_CODEC1(pdev->type)) {58 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;64 65	} else if (DEVICE_USE_CODEC3(pdev->type)) {66 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;72 73	} else /* if (DEVICE_USE_CODEC2(pdev->type)) */ {74 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;80	}81}82