2019-05-27 09:55:05 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Linux driver for Philips webcam
|
|
|
|
Decompression frontend.
|
|
|
|
(C) 1999-2003 Nemosoft Unv.
|
2006-04-24 17:29:46 +04:00
|
|
|
(C) 2004-2006 Luc Saillard (luc@saillard.org)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
|
|
|
|
driver and thus may have bugs that are not present in the original version.
|
|
|
|
Please send bug reports and support requests to <luc@saillard.org>.
|
|
|
|
The decompression routines have been implemented by reverse-engineering the
|
|
|
|
Nemosoft binary pwcx module. Caveat emptor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/current.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
|
|
|
|
#include "pwc.h"
|
2006-04-24 17:29:46 +04:00
|
|
|
#include "pwc-dec1.h"
|
|
|
|
#include "pwc-dec23.h"
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-06-06 22:33:44 +04:00
|
|
|
int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-01-04 23:58:44 +04:00
|
|
|
int n, line, col;
|
2005-04-17 02:20:36 +04:00
|
|
|
void *yuv, *image;
|
|
|
|
u16 *src;
|
|
|
|
u16 *dsty, *dstu, *dstv;
|
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 16:30:30 +03:00
|
|
|
image = vb2_plane_vaddr(&fbuf->vb.vb2_buf, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
|
|
|
|
|
|
|
|
/* Raw format; that's easy... */
|
2010-09-13 00:05:11 +04:00
|
|
|
if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2006-04-24 17:29:46 +04:00
|
|
|
struct pwc_raw_frame *raw_frame = image;
|
|
|
|
raw_frame->type = cpu_to_le16(pdev->type);
|
|
|
|
raw_frame->vbandlength = cpu_to_le16(pdev->vbandlength);
|
|
|
|
/* cmd_buf is always 4 bytes, but sometimes, only the
|
|
|
|
* first 3 bytes is filled (Nala case). We can
|
|
|
|
* determine this using the type of the webcam */
|
|
|
|
memcpy(raw_frame->cmd, pdev->cmd_buf, 4);
|
|
|
|
memcpy(raw_frame+1, yuv, pdev->frame_size);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 16:30:30 +03:00
|
|
|
vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
|
2011-06-06 22:33:44 +04:00
|
|
|
pdev->frame_size + sizeof(struct pwc_raw_frame));
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 16:30:30 +03:00
|
|
|
vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
|
2012-01-04 23:58:44 +04:00
|
|
|
pdev->width * pdev->height * 3 / 2);
|
2011-06-06 22:33:44 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (pdev->vbandlength == 0) {
|
2006-04-24 17:29:46 +04:00
|
|
|
/* Uncompressed mode.
|
|
|
|
*
|
|
|
|
* We do some byte shuffling here to go from the
|
|
|
|
* native format to YUV420P.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2006-04-24 17:29:46 +04:00
|
|
|
src = (u16 *)yuv;
|
2012-01-04 23:58:44 +04:00
|
|
|
n = pdev->width * pdev->height;
|
|
|
|
dsty = (u16 *)(image);
|
|
|
|
dstu = (u16 *)(image + n);
|
|
|
|
dstv = (u16 *)(image + n + n / 4);
|
2006-04-24 17:29:46 +04:00
|
|
|
|
2012-01-04 23:58:44 +04:00
|
|
|
for (line = 0; line < pdev->height; line++) {
|
|
|
|
for (col = 0; col < pdev->width; col += 4) {
|
2006-04-24 17:29:46 +04:00
|
|
|
*dsty++ = *src++;
|
|
|
|
*dsty++ = *src++;
|
2005-04-17 02:20:36 +04:00
|
|
|
if (line & 1)
|
2006-04-24 17:29:46 +04:00
|
|
|
*dstv++ = *src++;
|
2005-04-17 02:20:36 +04:00
|
|
|
else
|
2006-04-24 17:29:46 +04:00
|
|
|
*dstu++ = *src++;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2006-04-24 17:29:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2006-04-24 17:29:46 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compressed;
|
|
|
|
* the decompressor routines will write the data in planar format
|
|
|
|
* immediately.
|
|
|
|
*/
|
|
|
|
if (DEVICE_USE_CODEC1(pdev->type)) {
|
|
|
|
|
|
|
|
/* TODO & FIXME */
|
|
|
|
PWC_ERROR("This chipset is not supported for now\n");
|
|
|
|
return -ENXIO; /* No such device or address: missing decompressor */
|
|
|
|
|
|
|
|
} else {
|
2011-12-31 17:52:02 +04:00
|
|
|
pwc_dec23_decompress(pdev, yuv, image);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|