diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-01-08 09:29:19 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-16 08:07:29 -0500 |
commit | 56ae24aad8f9e25dfef995c3e898e5f394cf0beb (patch) | |
tree | 2ac5f9df9453057eef01f577647101101fae08d1 | |
parent | 54d3fb3b11a7c38b112585e54b7af7cb3faa5c91 (diff) |
[media] pwc: Make decoder data part of the main pwc struct
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/pwc/pwc-ctrl.c | 15 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-dec1.c | 16 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-dec1.h | 6 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-dec23.c | 37 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-dec23.h | 6 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 8 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc.h | 7 |
7 files changed, 35 insertions, 60 deletions
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c index c6dea6bc3225..34a01b209251 100644 --- a/drivers/media/video/pwc/pwc-ctrl.c +++ b/drivers/media/video/pwc/pwc-ctrl.c | |||
@@ -213,9 +213,7 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames, | |||
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { | 215 | if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { |
216 | ret = pwc_dec1_init(pdev, pdev->type, pdev->release, buf); | 216 | pwc_dec1_init(pdev, buf); |
217 | if (ret < 0) | ||
218 | return ret; | ||
219 | } | 217 | } |
220 | 218 | ||
221 | pdev->cmd_len = 3; | 219 | pdev->cmd_len = 3; |
@@ -281,9 +279,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, | |||
281 | return ret; | 279 | return ret; |
282 | 280 | ||
283 | if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { | 281 | if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { |
284 | ret = pwc_dec23_init(pdev, pdev->type, buf); | 282 | pwc_dec23_init(pdev, buf); |
285 | if (ret < 0) | ||
286 | return ret; | ||
287 | } | 283 | } |
288 | 284 | ||
289 | pdev->cmd_len = 13; | 285 | pdev->cmd_len = 13; |
@@ -341,9 +337,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, | |||
341 | return ret; | 337 | return ret; |
342 | 338 | ||
343 | if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { | 339 | if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { |
344 | ret = pwc_dec23_init(pdev, pdev->type, buf); | 340 | pwc_dec23_init(pdev, buf); |
345 | if (ret < 0) | ||
346 | return ret; | ||
347 | } | 341 | } |
348 | 342 | ||
349 | pdev->cmd_len = 12; | 343 | pdev->cmd_len = 12; |
@@ -368,7 +362,8 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, | |||
368 | { | 362 | { |
369 | int ret, size; | 363 | int ret, size; |
370 | 364 | ||
371 | PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", width, height, frames, pdev->pixfmt); | 365 | PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", |
366 | width, height, frames, pdev->pixfmt); | ||
372 | size = pwc_get_size(pdev, width, height); | 367 | size = pwc_get_size(pdev, width, height); |
373 | PWC_TRACE("decode_size = %d.\n", size); | 368 | PWC_TRACE("decode_size = %d.\n", size); |
374 | 369 | ||
diff --git a/drivers/media/video/pwc/pwc-dec1.c b/drivers/media/video/pwc/pwc-dec1.c index be0e02cb487f..bac0d83fe119 100644 --- a/drivers/media/video/pwc/pwc-dec1.c +++ b/drivers/media/video/pwc/pwc-dec1.c | |||
@@ -22,19 +22,11 @@ | |||
22 | along with this program; if not, write to the Free Software | 22 | along with this program; if not, write to the Free Software |
23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | */ | 24 | */ |
25 | #include "pwc-dec1.h" | 25 | #include "pwc.h" |
26 | 26 | ||
27 | int pwc_dec1_init(struct pwc_device *pwc, int type, int release, void *buffer) | 27 | void pwc_dec1_init(struct pwc_device *pdev, void *buffer) |
28 | { | 28 | { |
29 | struct pwc_dec1_private *pdec; | 29 | struct pwc_dec1_private *pdec = &pdev->dec1; |
30 | 30 | ||
31 | if (pwc->decompress_data == NULL) { | 31 | pdec->version = pdev->release; |
32 | pdec = kmalloc(sizeof(struct pwc_dec1_private), GFP_KERNEL); | ||
33 | if (pdec == NULL) | ||
34 | return -ENOMEM; | ||
35 | pwc->decompress_data = pdec; | ||
36 | } | ||
37 | pdec = pwc->decompress_data; | ||
38 | |||
39 | return 0; | ||
40 | } | 32 | } |
diff --git a/drivers/media/video/pwc/pwc-dec1.h b/drivers/media/video/pwc/pwc-dec1.h index a57d8601080b..6e8f3c561c9b 100644 --- a/drivers/media/video/pwc/pwc-dec1.h +++ b/drivers/media/video/pwc/pwc-dec1.h | |||
@@ -25,13 +25,15 @@ | |||
25 | #ifndef PWC_DEC1_H | 25 | #ifndef PWC_DEC1_H |
26 | #define PWC_DEC1_H | 26 | #define PWC_DEC1_H |
27 | 27 | ||
28 | #include "pwc.h" | 28 | #include <linux/mutex.h> |
29 | |||
30 | struct pwc_device; | ||
29 | 31 | ||
30 | struct pwc_dec1_private | 32 | struct pwc_dec1_private |
31 | { | 33 | { |
32 | int version; | 34 | int version; |
33 | }; | 35 | }; |
34 | 36 | ||
35 | int pwc_dec1_init(struct pwc_device *pwc, int type, int release, void *buffer); | 37 | void pwc_dec1_init(struct pwc_device *pdev, void *buffer); |
36 | 38 | ||
37 | #endif | 39 | #endif |
diff --git a/drivers/media/video/pwc/pwc-dec23.c b/drivers/media/video/pwc/pwc-dec23.c index 2c6709112b2f..6d48c1f90683 100644 --- a/drivers/media/video/pwc/pwc-dec23.c +++ b/drivers/media/video/pwc/pwc-dec23.c | |||
@@ -294,22 +294,14 @@ 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, 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 (DEVICE_USE_CODEC3(pdev->type)) { |
313 | flags = cmd[2] & 0x18; | 305 | flags = cmd[2] & 0x18; |
314 | if (flags == 8) | 306 | if (flags == 8) |
315 | pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */ | 307 | pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */ |
@@ -355,8 +347,6 @@ int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd) | |||
355 | for (i=0; i<MAX_OUTER_CROP_VALUE; i++) | 347 | for (i=0; i<MAX_OUTER_CROP_VALUE; i++) |
356 | pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255; | 348 | pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255; |
357 | #endif | 349 | #endif |
358 | |||
359 | return 0; | ||
360 | } | 350 | } |
361 | 351 | ||
362 | /* | 352 | /* |
@@ -659,12 +649,12 @@ static void DecompressBand23(struct pwc_dec23_private *pdec, | |||
659 | * src: raw data | 649 | * src: raw data |
660 | * dst: image output | 650 | * dst: image output |
661 | */ | 651 | */ |
662 | void pwc_dec23_decompress(const struct pwc_device *pwc, | 652 | void pwc_dec23_decompress(struct pwc_device *pdev, |
663 | const void *src, | 653 | const void *src, |
664 | void *dst) | 654 | void *dst) |
665 | { | 655 | { |
666 | int bandlines_left, bytes_per_block; | 656 | int bandlines_left, bytes_per_block; |
667 | struct pwc_dec23_private *pdec = pwc->decompress_data; | 657 | struct pwc_dec23_private *pdec = &pdev->dec23; |
668 | 658 | ||
669 | /* YUV420P image format */ | 659 | /* YUV420P image format */ |
670 | unsigned char *pout_planar_y; | 660 | unsigned char *pout_planar_y; |
@@ -674,23 +664,22 @@ void pwc_dec23_decompress(const struct pwc_device *pwc, | |||
674 | 664 | ||
675 | mutex_lock(&pdec->lock); | 665 | mutex_lock(&pdec->lock); |
676 | 666 | ||
677 | bandlines_left = pwc->height / 4; | 667 | bandlines_left = pdev->height / 4; |
678 | bytes_per_block = pwc->width * 4; | 668 | bytes_per_block = pdev->width * 4; |
679 | plane_size = pwc->height * pwc->width; | 669 | plane_size = pdev->height * pdev->width; |
680 | 670 | ||
681 | pout_planar_y = dst; | 671 | pout_planar_y = dst; |
682 | pout_planar_u = dst + plane_size; | 672 | pout_planar_u = dst + plane_size; |
683 | pout_planar_v = dst + plane_size + plane_size / 4; | 673 | pout_planar_v = dst + plane_size + plane_size / 4; |
684 | 674 | ||
685 | while (bandlines_left--) { | 675 | while (bandlines_left--) { |
686 | DecompressBand23(pwc->decompress_data, | 676 | DecompressBand23(pdec, src, |
687 | src, | ||
688 | pout_planar_y, pout_planar_u, pout_planar_v, | 677 | pout_planar_y, pout_planar_u, pout_planar_v, |
689 | pwc->width, pwc->width); | 678 | pdev->width, pdev->width); |
690 | src += pwc->vbandlength; | 679 | src += pdev->vbandlength; |
691 | pout_planar_y += bytes_per_block; | 680 | pout_planar_y += bytes_per_block; |
692 | pout_planar_u += pwc->width; | 681 | pout_planar_u += pdev->width; |
693 | pout_planar_v += pwc->width; | 682 | pout_planar_v += pdev->width; |
694 | } | 683 | } |
695 | mutex_unlock(&pdec->lock); | 684 | mutex_unlock(&pdec->lock); |
696 | } | 685 | } |
diff --git a/drivers/media/video/pwc/pwc-dec23.h b/drivers/media/video/pwc/pwc-dec23.h index d64a3c281af6..a29068ee428b 100644 --- a/drivers/media/video/pwc/pwc-dec23.h +++ b/drivers/media/video/pwc/pwc-dec23.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #ifndef PWC_DEC23_H | 25 | #ifndef PWC_DEC23_H |
26 | #define PWC_DEC23_H | 26 | #define PWC_DEC23_H |
27 | 27 | ||
28 | #include "pwc.h" | 28 | struct pwc_device; |
29 | 29 | ||
30 | struct pwc_dec23_private | 30 | struct pwc_dec23_private |
31 | { | 31 | { |
@@ -51,8 +51,8 @@ struct pwc_dec23_private | |||
51 | 51 | ||
52 | }; | 52 | }; |
53 | 53 | ||
54 | int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd); | 54 | void pwc_dec23_init(struct pwc_device *pdev, unsigned char *cmd); |
55 | void pwc_dec23_decompress(const struct pwc_device *pwc, | 55 | void pwc_dec23_decompress(struct pwc_device *pdev, |
56 | const void *src, | 56 | const void *src, |
57 | void *dst); | 57 | void *dst); |
58 | #endif | 58 | #endif |
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index 5592068b2f92..250ad4c3e9d8 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -603,14 +603,6 @@ static void pwc_video_release(struct v4l2_device *v) | |||
603 | if (device_hint[hint].pdev == pdev) | 603 | if (device_hint[hint].pdev == pdev) |
604 | device_hint[hint].pdev = NULL; | 604 | device_hint[hint].pdev = NULL; |
605 | 605 | ||
606 | /* Free intermediate decompression buffer & tables */ | ||
607 | if (pdev->decompress_data != NULL) { | ||
608 | PWC_DEBUG_MEMORY("Freeing decompression buffer at %p.\n", | ||
609 | pdev->decompress_data); | ||
610 | kfree(pdev->decompress_data); | ||
611 | pdev->decompress_data = NULL; | ||
612 | } | ||
613 | |||
614 | v4l2_ctrl_handler_free(&pdev->ctrl_handler); | 606 | v4l2_ctrl_handler_free(&pdev->ctrl_handler); |
615 | 607 | ||
616 | kfree(pdev); | 608 | kfree(pdev); |
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h index 47c518fef179..0f3bc1b3a971 100644 --- a/drivers/media/video/pwc/pwc.h +++ b/drivers/media/video/pwc/pwc.h | |||
@@ -44,6 +44,8 @@ | |||
44 | #ifdef CONFIG_USB_PWC_INPUT_EVDEV | 44 | #ifdef CONFIG_USB_PWC_INPUT_EVDEV |
45 | #include <linux/input.h> | 45 | #include <linux/input.h> |
46 | #endif | 46 | #endif |
47 | #include "pwc-dec1.h" | ||
48 | #include "pwc-dec23.h" | ||
47 | 49 | ||
48 | /* Version block */ | 50 | /* Version block */ |
49 | #define PWC_VERSION "10.0.15" | 51 | #define PWC_VERSION "10.0.15" |
@@ -272,7 +274,10 @@ struct pwc_device | |||
272 | int frame_total_size; /* including header & trailer */ | 274 | int frame_total_size; /* including header & trailer */ |
273 | int drop_frames; | 275 | int drop_frames; |
274 | 276 | ||
275 | void *decompress_data; /* private data for decompression engine */ | 277 | union { /* private data for decompression engine */ |
278 | struct pwc_dec1_private dec1; | ||
279 | struct pwc_dec23_private dec23; | ||
280 | }; | ||
276 | 281 | ||
277 | /* | 282 | /* |
278 | * We have an 'image' and a 'view', where 'image' is the fixed-size img | 283 | * We have an 'image' and a 'view', where 'image' is the fixed-size img |