aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pwc/pwc-misc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-15 15:49:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-15 15:49:56 -0500
commit122804ecb59493fbb4d31b3ba9ac59faaf45276f (patch)
treecff4d8a158c412e4a8d3abc8d91bb0eb52b01c9a /drivers/media/video/pwc/pwc-misc.c
parent16008d641670571ff4cd750b416c7caf2d89f467 (diff)
parent126400033940afb658123517a2e80eb68259fbd7 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (655 commits) [media] revert patch: HDIC HD29L2 DMB-TH USB2.0 reference design driver mb86a20s: Add a few more register settings at the init seq mb86a20s: Group registers into the same line [media] [PATCH] don't reset the delivery system on DTV_CLEAR [media] [BUG] it913x-fe fix typo error making SNR levels unstable [media] cx23885: Query the CX25840 during enum_input for status [media] cx25840: Add support for g_input_status [media] rc-videomate-m1f.c Rename to match remote controler name [media] drivers: media: au0828: Fix dependency for VIDEO_AU0828 [media] convert drivers/media/* to use module_platform_driver() [media] drivers: video: cx231xx: Fix dependency for VIDEO_CX231XX_DVB [media] Exynos4 JPEG codec v4l2 driver [media] doc: v4l: selection: choose pixels as units for selection rectangles [media] v4l: s5p-tv: mixer: fix setup of VP scaling [media] v4l: s5p-tv: mixer: add support for selection API [media] v4l: emulate old crop API using extended crop/compose API [media] doc: v4l: add documentation for selection API [media] doc: v4l: add binary images for selection API [media] v4l: add support for selection api [media] hd29l2: fix review findings ...
Diffstat (limited to 'drivers/media/video/pwc/pwc-misc.c')
-rw-r--r--drivers/media/video/pwc/pwc-misc.c87
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
30const struct pwc_coord pwc_image_sizes[PSZ_MAX] = 30const 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_ */
41int pwc_decode_size(struct pwc_device *pdev, int width, int height) 41int 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 */
81void pwc_construct(struct pwc_device *pdev) 67void 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}