diff options
Diffstat (limited to 'drivers/media/video/pwc/pwc-misc.c')
-rw-r--r-- | drivers/media/video/pwc/pwc-misc.c | 87 |
1 files changed, 26 insertions, 61 deletions
diff --git a/drivers/media/video/pwc/pwc-misc.c b/drivers/media/video/pwc/pwc-misc.c index 0b031336eab..23a55b5814f 100644 --- a/drivers/media/video/pwc/pwc-misc.c +++ b/drivers/media/video/pwc/pwc-misc.c | |||
@@ -27,67 +27,47 @@ | |||
27 | 27 | ||
28 | #include "pwc.h" | 28 | #include "pwc.h" |
29 | 29 | ||
30 | const struct pwc_coord pwc_image_sizes[PSZ_MAX] = | 30 | const int pwc_image_sizes[PSZ_MAX][2] = |
31 | { | 31 | { |
32 | { 128, 96, 0 }, /* sqcif */ | 32 | { 128, 96 }, /* sqcif */ |
33 | { 160, 120, 0 }, /* qsif */ | 33 | { 160, 120 }, /* qsif */ |
34 | { 176, 144, 0 }, /* qcif */ | 34 | { 176, 144 }, /* qcif */ |
35 | { 320, 240, 0 }, /* sif */ | 35 | { 320, 240 }, /* sif */ |
36 | { 352, 288, 0 }, /* cif */ | 36 | { 352, 288 }, /* cif */ |
37 | { 640, 480, 0 }, /* vga */ | 37 | { 640, 480 }, /* vga */ |
38 | }; | 38 | }; |
39 | 39 | ||
40 | /* x,y -> PSZ_ */ | 40 | /* x,y -> PSZ_ */ |
41 | int pwc_decode_size(struct pwc_device *pdev, int width, int height) | 41 | int pwc_get_size(struct pwc_device *pdev, int width, int height) |
42 | { | 42 | { |
43 | int i, find; | 43 | int i; |
44 | |||
45 | /* Make sure we don't go beyond our max size. | ||
46 | NB: we have different limits for RAW and normal modes. In case | ||
47 | you don't have the decompressor loaded or use RAW mode, | ||
48 | the maximum viewable size is smaller. | ||
49 | */ | ||
50 | if (pdev->pixfmt != V4L2_PIX_FMT_YUV420) | ||
51 | { | ||
52 | if (width > pdev->abs_max.x || height > pdev->abs_max.y) | ||
53 | { | ||
54 | PWC_DEBUG_SIZE("VIDEO_PALETTE_RAW: going beyond abs_max.\n"); | ||
55 | return -1; | ||
56 | } | ||
57 | } | ||
58 | else | ||
59 | { | ||
60 | if (width > pdev->view_max.x || height > pdev->view_max.y) | ||
61 | { | ||
62 | PWC_DEBUG_SIZE("VIDEO_PALETTE_not RAW: going beyond view_max.\n"); | ||
63 | return -1; | ||
64 | } | ||
65 | } | ||
66 | 44 | ||
67 | /* Find the largest size supported by the camera that fits into the | 45 | /* Find the largest size supported by the camera that fits into the |
68 | requested size. | 46 | requested size. */ |
69 | */ | 47 | for (i = PSZ_MAX - 1; i >= 0; i--) { |
70 | find = -1; | 48 | if (!(pdev->image_mask & (1 << i))) |
49 | continue; | ||
50 | |||
51 | if (pwc_image_sizes[i][0] <= width && | ||
52 | pwc_image_sizes[i][1] <= height) | ||
53 | return i; | ||
54 | } | ||
55 | |||
56 | /* No mode found, return the smallest mode we have */ | ||
71 | for (i = 0; i < PSZ_MAX; i++) { | 57 | for (i = 0; i < PSZ_MAX; i++) { |
72 | if (pdev->image_mask & (1 << i)) { | 58 | if (pdev->image_mask & (1 << i)) |
73 | if (pwc_image_sizes[i].x <= width && pwc_image_sizes[i].y <= height) | 59 | return i; |
74 | find = i; | ||
75 | } | ||
76 | } | 60 | } |
77 | return find; | 61 | |
62 | /* Never reached there always is atleast one supported mode */ | ||
63 | return 0; | ||
78 | } | 64 | } |
79 | 65 | ||
80 | /* initialize variables depending on type and decompressor*/ | 66 | /* initialize variables depending on type and decompressor */ |
81 | void pwc_construct(struct pwc_device *pdev) | 67 | void pwc_construct(struct pwc_device *pdev) |
82 | { | 68 | { |
83 | if (DEVICE_USE_CODEC1(pdev->type)) { | 69 | if (DEVICE_USE_CODEC1(pdev->type)) { |
84 | 70 | ||
85 | pdev->view_min.x = 128; | ||
86 | pdev->view_min.y = 96; | ||
87 | pdev->view_max.x = 352; | ||
88 | pdev->view_max.y = 288; | ||
89 | pdev->abs_max.x = 352; | ||
90 | pdev->abs_max.y = 288; | ||
91 | pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF; | 71 | pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF; |
92 | pdev->vcinterface = 2; | 72 | pdev->vcinterface = 2; |
93 | pdev->vendpoint = 4; | 73 | pdev->vendpoint = 4; |
@@ -96,13 +76,7 @@ void pwc_construct(struct pwc_device *pdev) | |||
96 | 76 | ||
97 | } else if (DEVICE_USE_CODEC3(pdev->type)) { | 77 | } else if (DEVICE_USE_CODEC3(pdev->type)) { |
98 | 78 | ||
99 | pdev->view_min.x = 160; | ||
100 | pdev->view_min.y = 120; | ||
101 | pdev->view_max.x = 640; | ||
102 | pdev->view_max.y = 480; | ||
103 | pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA; | 79 | pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA; |
104 | pdev->abs_max.x = 640; | ||
105 | pdev->abs_max.y = 480; | ||
106 | pdev->vcinterface = 3; | 80 | pdev->vcinterface = 3; |
107 | pdev->vendpoint = 5; | 81 | pdev->vendpoint = 5; |
108 | pdev->frame_header_size = TOUCAM_HEADER_SIZE; | 82 | pdev->frame_header_size = TOUCAM_HEADER_SIZE; |
@@ -110,20 +84,11 @@ void pwc_construct(struct pwc_device *pdev) | |||
110 | 84 | ||
111 | } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ { | 85 | } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ { |
112 | 86 | ||
113 | pdev->view_min.x = 128; | ||
114 | pdev->view_min.y = 96; | ||
115 | /* Anthill bug #38: PWC always reports max size, even without PWCX */ | ||
116 | pdev->view_max.x = 640; | ||
117 | pdev->view_max.y = 480; | ||
118 | pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA; | 87 | pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA; |
119 | pdev->abs_max.x = 640; | ||
120 | pdev->abs_max.y = 480; | ||
121 | pdev->vcinterface = 3; | 88 | pdev->vcinterface = 3; |
122 | pdev->vendpoint = 4; | 89 | pdev->vendpoint = 4; |
123 | pdev->frame_header_size = 0; | 90 | pdev->frame_header_size = 0; |
124 | pdev->frame_trailer_size = 0; | 91 | pdev->frame_trailer_size = 0; |
125 | } | 92 | } |
126 | pdev->pixfmt = V4L2_PIX_FMT_YUV420; /* default */ | 93 | pdev->pixfmt = V4L2_PIX_FMT_YUV420; /* default */ |
127 | pdev->view_min.size = pdev->view_min.x * pdev->view_min.y; | ||
128 | pdev->view_max.size = pdev->view_max.x * pdev->view_max.y; | ||
129 | } | 94 | } |