This source file includes following definitions.
- pwc_decompress
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <asm/current.h>
18 #include <asm/types.h>
19
20 #include "pwc.h"
21 #include "pwc-dec1.h"
22 #include "pwc-dec23.h"
23
24 int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
25 {
26 int n, line, col;
27 void *yuv, *image;
28 u16 *src;
29 u16 *dsty, *dstu, *dstv;
30
31 image = vb2_plane_vaddr(&fbuf->vb.vb2_buf, 0);
32
33 yuv = fbuf->data + pdev->frame_header_size;
34
35
36 if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
37 {
38 struct pwc_raw_frame *raw_frame = image;
39 raw_frame->type = cpu_to_le16(pdev->type);
40 raw_frame->vbandlength = cpu_to_le16(pdev->vbandlength);
41
42
43
44 memcpy(raw_frame->cmd, pdev->cmd_buf, 4);
45 memcpy(raw_frame+1, yuv, pdev->frame_size);
46 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
47 pdev->frame_size + sizeof(struct pwc_raw_frame));
48 return 0;
49 }
50
51 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
52 pdev->width * pdev->height * 3 / 2);
53
54 if (pdev->vbandlength == 0) {
55
56
57
58
59
60 src = (u16 *)yuv;
61 n = pdev->width * pdev->height;
62 dsty = (u16 *)(image);
63 dstu = (u16 *)(image + n);
64 dstv = (u16 *)(image + n + n / 4);
65
66 for (line = 0; line < pdev->height; line++) {
67 for (col = 0; col < pdev->width; col += 4) {
68 *dsty++ = *src++;
69 *dsty++ = *src++;
70 if (line & 1)
71 *dstv++ = *src++;
72 else
73 *dstu++ = *src++;
74 }
75 }
76
77 return 0;
78 }
79
80
81
82
83
84
85 if (DEVICE_USE_CODEC1(pdev->type)) {
86
87
88 PWC_ERROR("This chipset is not supported for now\n");
89 return -ENXIO;
90
91 } else {
92 pwc_dec23_decompress(pdev, yuv, image);
93 }
94 return 0;
95 }