aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pwc/pwc-ctrl.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-01-04 14:58:44 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-06 07:46:46 -0500
commit795e6eb3262d3b7247ce450835eea6df6571d103 (patch)
tree558c161d69a04a172f54c1edd38c44b2553bf10e /drivers/media/video/pwc/pwc-ctrl.c
parenta08d2c727153dc6cea1d5d54a43fd7d69c1467c3 (diff)
[media] pwc: Remove software emulation of arbritary resolutions
The pwc driver claims to support any resolution between 160x120 and 640x480, but emulates this by simply drawing a black border around the image. Userspace can draw its own black border if it really wants one. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pwc/pwc-ctrl.c')
-rw-r--r--drivers/media/video/pwc/pwc-ctrl.c69
1 files changed, 13 insertions, 56 deletions
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c
index 684b7c50eea..6b9c97fff27 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -102,8 +102,6 @@ static struct Nala_table_entry Nala_table[PSZ_MAX][PWC_FPS_MAX_NALA] =
102#include "pwc-nala.h" 102#include "pwc-nala.h"
103}; 103};
104 104
105static void pwc_set_image_buffer_size(struct pwc_device *pdev);
106
107/****************************************************************************/ 105/****************************************************************************/
108 106
109static int _send_control_msg(struct pwc_device *pdev, 107static int _send_control_msg(struct pwc_device *pdev,
@@ -221,8 +219,9 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)
221 /* Set various parameters */ 219 /* Set various parameters */
222 pdev->vframes = frames; 220 pdev->vframes = frames;
223 pdev->valternate = pEntry->alternate; 221 pdev->valternate = pEntry->alternate;
224 pdev->image = pwc_image_sizes[size]; 222 pdev->width = pwc_image_sizes[size][0];
225 pdev->frame_size = (pdev->image.x * pdev->image.y * 3) / 2; 223 pdev->height = pwc_image_sizes[size][1];
224 pdev->frame_size = (pdev->width * pdev->height * 3) / 2;
226 if (pEntry->compressed) { 225 if (pEntry->compressed) {
227 if (pdev->release < 5) { /* 4 fold compression */ 226 if (pdev->release < 5) { /* 4 fold compression */
228 pdev->vbandlength = 528; 227 pdev->vbandlength = 528;
@@ -282,12 +281,13 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames,
282 /* Set various parameters */ 281 /* Set various parameters */
283 pdev->vframes = frames; 282 pdev->vframes = frames;
284 pdev->valternate = pChoose->alternate; 283 pdev->valternate = pChoose->alternate;
285 pdev->image = pwc_image_sizes[size]; 284 pdev->width = pwc_image_sizes[size][0];
285 pdev->height = pwc_image_sizes[size][1];
286 pdev->vbandlength = pChoose->bandlength; 286 pdev->vbandlength = pChoose->bandlength;
287 if (pChoose->bandlength > 0) 287 if (pChoose->bandlength > 0)
288 pdev->frame_size = (pChoose->bandlength * pdev->image.y) / 4; 288 pdev->frame_size = (pChoose->bandlength * pdev->height) / 4;
289 else 289 else
290 pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8; 290 pdev->frame_size = (pdev->width * pdev->height * 12) / 8;
291 return 0; 291 return 0;
292} 292}
293 293
@@ -339,37 +339,25 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames,
339 /* All set and go */ 339 /* All set and go */
340 pdev->vframes = frames; 340 pdev->vframes = frames;
341 pdev->valternate = pChoose->alternate; 341 pdev->valternate = pChoose->alternate;
342 pdev->image = pwc_image_sizes[size]; 342 pdev->width = pwc_image_sizes[size][0];
343 pdev->height = pwc_image_sizes[size][1];
343 pdev->vbandlength = pChoose->bandlength; 344 pdev->vbandlength = pChoose->bandlength;
344 if (pdev->vbandlength > 0) 345 if (pdev->vbandlength > 0)
345 pdev->frame_size = (pdev->vbandlength * pdev->image.y) / 4; 346 pdev->frame_size = (pdev->vbandlength * pdev->height) / 4;
346 else 347 else
347 pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8; 348 pdev->frame_size = (pdev->width * pdev->height * 12) / 8;
348 PWC_TRACE("frame_size=%d, vframes=%d, vsize=%d, vbandlength=%d\n", 349 PWC_TRACE("frame_size=%d, vframes=%d, vsize=%d, vbandlength=%d\n",
349 pdev->frame_size, pdev->vframes, size, pdev->vbandlength); 350 pdev->frame_size, pdev->vframes, size, pdev->vbandlength);
350 return 0; 351 return 0;
351} 352}
352 353
353
354
355/**
356 @pdev: device structure
357 @width: viewport width
358 @height: viewport height
359 @frame: framerate, in fps
360 @compression: preferred compression ratio
361 */
362int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, 354int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
363 int frames, int compression) 355 int frames, int compression)
364{ 356{
365 int ret, size; 357 int ret, size;
366 358
367 PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", width, height, frames, pdev->pixfmt); 359 PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", width, height, frames, pdev->pixfmt);
368 size = pwc_decode_size(pdev, width, height); 360 size = pwc_get_size(pdev, width, height);
369 if (size < 0) {
370 PWC_DEBUG_MODULE("Could not find suitable size.\n");
371 return -ERANGE;
372 }
373 PWC_TRACE("decode_size = %d.\n", size); 361 PWC_TRACE("decode_size = %d.\n", size);
374 362
375 if (DEVICE_USE_CODEC1(pdev->type)) { 363 if (DEVICE_USE_CODEC1(pdev->type)) {
@@ -385,12 +373,9 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
385 PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret); 373 PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
386 return ret; 374 return ret;
387 } 375 }
388 pdev->view.x = width;
389 pdev->view.y = height;
390 pdev->vcompression = compression; 376 pdev->vcompression = compression;
391 pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size; 377 pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size;
392 pwc_set_image_buffer_size(pdev); 378 PWC_DEBUG_SIZE("Set resolution to %dx%d\n", pdev->width, pdev->height);
393 PWC_DEBUG_SIZE("Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y);
394 return 0; 379 return 0;
395} 380}
396 381
@@ -447,34 +432,6 @@ unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned i
447 return ret; 432 return ret;
448} 433}
449 434
450static void pwc_set_image_buffer_size(struct pwc_device *pdev)
451{
452 int factor = 0;
453
454 /* for V4L2_PIX_FMT_YUV420 */
455 switch (pdev->pixfmt) {
456 case V4L2_PIX_FMT_YUV420:
457 factor = 6;
458 break;
459 case V4L2_PIX_FMT_PWC1:
460 case V4L2_PIX_FMT_PWC2:
461 factor = 6; /* can be uncompressed YUV420P */
462 break;
463 }
464
465 /* Set sizes in bytes */
466 pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
467 pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
468
469 /* Align offset, or you'll get some very weird results in
470 YUV420 mode... x must be multiple of 4 (to get the Y's in
471 place), and y even (or you'll mixup U & V). This is less of a
472 problem for YUV420P.
473 */
474 pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
475 pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
476}
477
478int pwc_get_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data) 435int pwc_get_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data)
479{ 436{
480 int ret; 437 int ret;