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