Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
846 giacomo 1
/* Linux driver for Philips webcam
2
   Various miscellaneous functions and tables.
3
   (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
4
 
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 2 of the License, or
8
   (at your option) any later version.
9
 
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, write to the Free Software
17
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
*/  
19
 
20
#include <linux/slab.h>
21
 
22
#include "pwc.h"
23
 
24
struct pwc_coord pwc_image_sizes[PSZ_MAX] =
25
{
26
        { 128,  96, 0 },
27
        { 160, 120, 0 },
28
        { 176, 144, 0 },
29
        { 320, 240, 0 },
30
        { 352, 288, 0 },
31
        { 640, 480, 0 },
32
};
33
 
34
/* x,y -> PSZ_ */
35
int pwc_decode_size(struct pwc_device *pdev, int width, int height)
36
{
37
        int i, find;
38
 
39
        /* Make sure we don't go beyond our max size */
40
        if (width > pdev->view_max.x || height > pdev->view_max.y)
41
                return -1;
42
        /* Find the largest size supported by the camera that fits into the
43
           requested size.
44
         */
45
        find = -1;
46
        for (i = 0; i < PSZ_MAX; i++) {
47
                if (pdev->image_mask & (1 << i)) {
48
                        if (pwc_image_sizes[i].x <= width && pwc_image_sizes[i].y <= height)
49
                                find = i;
50
                }
51
        }
52
        return find;
53
}
54
 
55
/* initialize variables depending on type and decompressor*/
56
void pwc_construct(struct pwc_device *pdev)
57
{
58
        switch(pdev->type) {
59
        case 645:
60
        case 646:
61
                pdev->view_min.x = 128;
62
                pdev->view_min.y =  96;
63
                pdev->view_max.x = 352;
64
                pdev->view_max.y = 288;
65
                pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
66
                pdev->vcinterface = 2;
67
                pdev->vendpoint = 4;
68
                pdev->frame_header_size = 0;
69
                pdev->frame_trailer_size = 0;
70
                break;
71
        case 675:
72
        case 680:
73
        case 690:
74
                pdev->view_min.x = 128;
75
                pdev->view_min.y =  96;
76
                /* Anthill bug #38: PWC always reports max size, even without PWCX */
77
                if (pdev->decompressor != NULL) {
78
                        pdev->view_max.x = 640;
79
                        pdev->view_max.y = 480;
80
                        pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
81
                }
82
                else {
83
                        pdev->view_max.x = 352;
84
                        pdev->view_max.y = 288;
85
                        pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF;
86
                }
87
                pdev->vcinterface = 3;
88
                pdev->vendpoint = 4;
89
                pdev->frame_header_size = 0;
90
                pdev->frame_trailer_size = 0;
91
                break;
92
        case 720:
93
        case 730:
94
        case 740:
95
        case 750:
96
                pdev->view_min.x = 160;
97
                pdev->view_min.y = 120;
98
                /* Anthill bug #38: PWC always reports max size, even without PWCX */
99
                if (pdev->decompressor != NULL) {
100
                        pdev->view_max.x = 640;
101
                        pdev->view_max.y = 480;
102
                        pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
103
                }
104
                else {
105
                        /* Tell CIF, even though SIF really is the maximum, but some tools really need CIF */
106
                        pdev->view_max.x = 352;
107
                        pdev->view_max.y = 288;
108
                        pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF;
109
                }
110
                pdev->vcinterface = 3;
111
                pdev->vendpoint = 5;
112
                pdev->frame_header_size = TOUCAM_HEADER_SIZE;
113
                pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
114
                break;
115
        }
116
        pdev->view_min.size = pdev->view_min.x * pdev->view_min.y;
117
        pdev->view_max.size = pdev->view_max.x * pdev->view_max.y;
118
        /* length of image, in YUV format */
119
        pdev->len_per_image = (pdev->view_max.size * 3) / 2;
120
}
121
 
122