0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <asm/current.h>
0015 #include <asm/types.h>
0016
0017 #include "pwc.h"
0018 #include "pwc-dec1.h"
0019 #include "pwc-dec23.h"
0020
0021 int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
0022 {
0023 int n, line, col;
0024 void *yuv, *image;
0025 u16 *src;
0026 u16 *dsty, *dstu, *dstv;
0027
0028 image = vb2_plane_vaddr(&fbuf->vb.vb2_buf, 0);
0029
0030 yuv = fbuf->data + pdev->frame_header_size;
0031
0032
0033 if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
0034 {
0035 struct pwc_raw_frame *raw_frame = image;
0036 raw_frame->type = cpu_to_le16(pdev->type);
0037 raw_frame->vbandlength = cpu_to_le16(pdev->vbandlength);
0038
0039
0040
0041 memcpy(raw_frame->cmd, pdev->cmd_buf, 4);
0042 memcpy(raw_frame+1, yuv, pdev->frame_size);
0043 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
0044 struct_size(raw_frame, rawframe, pdev->frame_size));
0045 return 0;
0046 }
0047
0048 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
0049 pdev->width * pdev->height * 3 / 2);
0050
0051 if (pdev->vbandlength == 0) {
0052
0053
0054
0055
0056
0057 src = (u16 *)yuv;
0058 n = pdev->width * pdev->height;
0059 dsty = (u16 *)(image);
0060 dstu = (u16 *)(image + n);
0061 dstv = (u16 *)(image + n + n / 4);
0062
0063 for (line = 0; line < pdev->height; line++) {
0064 for (col = 0; col < pdev->width; col += 4) {
0065 *dsty++ = *src++;
0066 *dsty++ = *src++;
0067 if (line & 1)
0068 *dstv++ = *src++;
0069 else
0070 *dstu++ = *src++;
0071 }
0072 }
0073
0074 return 0;
0075 }
0076
0077
0078
0079
0080
0081
0082 if (DEVICE_USE_CODEC1(pdev->type)) {
0083
0084
0085 PWC_ERROR("This chipset is not supported for now\n");
0086 return -ENXIO;
0087
0088 } else {
0089 pwc_dec23_decompress(pdev, yuv, image);
0090 }
0091 return 0;
0092 }