diff options
Diffstat (limited to 'drivers/media/video/pwc/pwc-dec23.c')
-rw-r--r-- | drivers/media/video/pwc/pwc-dec23.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/media/video/pwc/pwc-dec23.c b/drivers/media/video/pwc/pwc-dec23.c index 2c6709112b2f..3792fedff951 100644 --- a/drivers/media/video/pwc/pwc-dec23.c +++ b/drivers/media/video/pwc/pwc-dec23.c | |||
@@ -294,22 +294,17 @@ static unsigned char pwc_crop_table[256 + 2*MAX_OUTER_CROP_VALUE]; | |||
294 | 294 | ||
295 | 295 | ||
296 | /* If the type or the command change, we rebuild the lookup table */ | 296 | /* If the type or the command change, we rebuild the lookup table */ |
297 | int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd) | 297 | void pwc_dec23_init(struct pwc_device *pdev, const unsigned char *cmd) |
298 | { | 298 | { |
299 | int flags, version, shift, i; | 299 | int flags, version, shift, i; |
300 | struct pwc_dec23_private *pdec; | 300 | struct pwc_dec23_private *pdec = &pdev->dec23; |
301 | |||
302 | if (pwc->decompress_data == NULL) { | ||
303 | pdec = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); | ||
304 | if (pdec == NULL) | ||
305 | return -ENOMEM; | ||
306 | pwc->decompress_data = pdec; | ||
307 | } | ||
308 | pdec = pwc->decompress_data; | ||
309 | 301 | ||
310 | mutex_init(&pdec->lock); | 302 | mutex_init(&pdec->lock); |
311 | 303 | ||
312 | if (DEVICE_USE_CODEC3(type)) { | 304 | if (pdec->last_cmd_valid && pdec->last_cmd == cmd[2]) |
305 | return; | ||
306 | |||
307 | if (DEVICE_USE_CODEC3(pdev->type)) { | ||
313 | flags = cmd[2] & 0x18; | 308 | flags = cmd[2] & 0x18; |
314 | if (flags == 8) | 309 | if (flags == 8) |
315 | pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */ | 310 | pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */ |
@@ -356,7 +351,8 @@ int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd) | |||
356 | pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255; | 351 | pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255; |
357 | #endif | 352 | #endif |
358 | 353 | ||
359 | return 0; | 354 | pdec->last_cmd = cmd[2]; |
355 | pdec->last_cmd_valid = 1; | ||
360 | } | 356 | } |
361 | 357 | ||
362 | /* | 358 | /* |
@@ -659,12 +655,12 @@ static void DecompressBand23(struct pwc_dec23_private *pdec, | |||
659 | * src: raw data | 655 | * src: raw data |
660 | * dst: image output | 656 | * dst: image output |
661 | */ | 657 | */ |
662 | void pwc_dec23_decompress(const struct pwc_device *pwc, | 658 | void pwc_dec23_decompress(struct pwc_device *pdev, |
663 | const void *src, | 659 | const void *src, |
664 | void *dst) | 660 | void *dst) |
665 | { | 661 | { |
666 | int bandlines_left, bytes_per_block; | 662 | int bandlines_left, bytes_per_block; |
667 | struct pwc_dec23_private *pdec = pwc->decompress_data; | 663 | struct pwc_dec23_private *pdec = &pdev->dec23; |
668 | 664 | ||
669 | /* YUV420P image format */ | 665 | /* YUV420P image format */ |
670 | unsigned char *pout_planar_y; | 666 | unsigned char *pout_planar_y; |
@@ -674,23 +670,22 @@ void pwc_dec23_decompress(const struct pwc_device *pwc, | |||
674 | 670 | ||
675 | mutex_lock(&pdec->lock); | 671 | mutex_lock(&pdec->lock); |
676 | 672 | ||
677 | bandlines_left = pwc->height / 4; | 673 | bandlines_left = pdev->height / 4; |
678 | bytes_per_block = pwc->width * 4; | 674 | bytes_per_block = pdev->width * 4; |
679 | plane_size = pwc->height * pwc->width; | 675 | plane_size = pdev->height * pdev->width; |
680 | 676 | ||
681 | pout_planar_y = dst; | 677 | pout_planar_y = dst; |
682 | pout_planar_u = dst + plane_size; | 678 | pout_planar_u = dst + plane_size; |
683 | pout_planar_v = dst + plane_size + plane_size / 4; | 679 | pout_planar_v = dst + plane_size + plane_size / 4; |
684 | 680 | ||
685 | while (bandlines_left--) { | 681 | while (bandlines_left--) { |
686 | DecompressBand23(pwc->decompress_data, | 682 | DecompressBand23(pdec, src, |
687 | src, | ||
688 | pout_planar_y, pout_planar_u, pout_planar_v, | 683 | pout_planar_y, pout_planar_u, pout_planar_v, |
689 | pwc->width, pwc->width); | 684 | pdev->width, pdev->width); |
690 | src += pwc->vbandlength; | 685 | src += pdev->vbandlength; |
691 | pout_planar_y += bytes_per_block; | 686 | pout_planar_y += bytes_per_block; |
692 | pout_planar_u += pwc->width; | 687 | pout_planar_u += pdev->width; |
693 | pout_planar_v += pwc->width; | 688 | pout_planar_v += pdev->width; |
694 | } | 689 | } |
695 | mutex_unlock(&pdec->lock); | 690 | mutex_unlock(&pdec->lock); |
696 | } | 691 | } |