提交 56ae24aa 编写于 作者: H Hans de Goede 提交者: Mauro Carvalho Chehab

[media] pwc: Make decoder data part of the main pwc struct

Signed-off-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 54d3fb3b
...@@ -213,9 +213,7 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames, ...@@ -213,9 +213,7 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames,
return ret; return ret;
} }
if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
ret = pwc_dec1_init(pdev, pdev->type, pdev->release, buf); pwc_dec1_init(pdev, buf);
if (ret < 0)
return ret;
} }
pdev->cmd_len = 3; pdev->cmd_len = 3;
...@@ -281,9 +279,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, ...@@ -281,9 +279,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames,
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
ret = pwc_dec23_init(pdev, pdev->type, buf); pwc_dec23_init(pdev, buf);
if (ret < 0)
return ret;
} }
pdev->cmd_len = 13; pdev->cmd_len = 13;
...@@ -341,9 +337,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, ...@@ -341,9 +337,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames,
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) { if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
ret = pwc_dec23_init(pdev, pdev->type, buf); pwc_dec23_init(pdev, buf);
if (ret < 0)
return ret;
} }
pdev->cmd_len = 12; pdev->cmd_len = 12;
...@@ -368,7 +362,8 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, ...@@ -368,7 +362,8 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
{ {
int ret, size; int ret, size;
PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n", width, height, frames, pdev->pixfmt); PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n",
width, height, frames, pdev->pixfmt);
size = pwc_get_size(pdev, width, height); size = pwc_get_size(pdev, width, height);
PWC_TRACE("decode_size = %d.\n", size); PWC_TRACE("decode_size = %d.\n", size);
......
...@@ -22,19 +22,11 @@ ...@@ -22,19 +22,11 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "pwc-dec1.h" #include "pwc.h"
int pwc_dec1_init(struct pwc_device *pwc, int type, int release, void *buffer) void pwc_dec1_init(struct pwc_device *pdev, void *buffer)
{ {
struct pwc_dec1_private *pdec; struct pwc_dec1_private *pdec = &pdev->dec1;
if (pwc->decompress_data == NULL) { pdec->version = pdev->release;
pdec = kmalloc(sizeof(struct pwc_dec1_private), GFP_KERNEL);
if (pdec == NULL)
return -ENOMEM;
pwc->decompress_data = pdec;
}
pdec = pwc->decompress_data;
return 0;
} }
...@@ -25,13 +25,15 @@ ...@@ -25,13 +25,15 @@
#ifndef PWC_DEC1_H #ifndef PWC_DEC1_H
#define PWC_DEC1_H #define PWC_DEC1_H
#include "pwc.h" #include <linux/mutex.h>
struct pwc_device;
struct pwc_dec1_private struct pwc_dec1_private
{ {
int version; int version;
}; };
int pwc_dec1_init(struct pwc_device *pwc, int type, int release, void *buffer); void pwc_dec1_init(struct pwc_device *pdev, void *buffer);
#endif #endif
...@@ -294,22 +294,14 @@ static unsigned char pwc_crop_table[256 + 2*MAX_OUTER_CROP_VALUE]; ...@@ -294,22 +294,14 @@ static unsigned char pwc_crop_table[256 + 2*MAX_OUTER_CROP_VALUE];
/* If the type or the command change, we rebuild the lookup table */ /* If the type or the command change, we rebuild the lookup table */
int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd) void pwc_dec23_init(struct pwc_device *pdev, unsigned char *cmd)
{ {
int flags, version, shift, i; int flags, version, shift, i;
struct pwc_dec23_private *pdec; struct pwc_dec23_private *pdec = &pdev->dec23;
if (pwc->decompress_data == NULL) {
pdec = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
if (pdec == NULL)
return -ENOMEM;
pwc->decompress_data = pdec;
}
pdec = pwc->decompress_data;
mutex_init(&pdec->lock); mutex_init(&pdec->lock);
if (DEVICE_USE_CODEC3(type)) { if (DEVICE_USE_CODEC3(pdev->type)) {
flags = cmd[2] & 0x18; flags = cmd[2] & 0x18;
if (flags == 8) if (flags == 8)
pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */ 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,8 +347,6 @@ int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd)
for (i=0; i<MAX_OUTER_CROP_VALUE; i++) for (i=0; i<MAX_OUTER_CROP_VALUE; i++)
pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255; pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255;
#endif #endif
return 0;
} }
/* /*
...@@ -659,12 +649,12 @@ static void DecompressBand23(struct pwc_dec23_private *pdec, ...@@ -659,12 +649,12 @@ static void DecompressBand23(struct pwc_dec23_private *pdec,
* src: raw data * src: raw data
* dst: image output * dst: image output
*/ */
void pwc_dec23_decompress(const struct pwc_device *pwc, void pwc_dec23_decompress(struct pwc_device *pdev,
const void *src, const void *src,
void *dst) void *dst)
{ {
int bandlines_left, bytes_per_block; int bandlines_left, bytes_per_block;
struct pwc_dec23_private *pdec = pwc->decompress_data; struct pwc_dec23_private *pdec = &pdev->dec23;
/* YUV420P image format */ /* YUV420P image format */
unsigned char *pout_planar_y; unsigned char *pout_planar_y;
...@@ -674,23 +664,22 @@ void pwc_dec23_decompress(const struct pwc_device *pwc, ...@@ -674,23 +664,22 @@ void pwc_dec23_decompress(const struct pwc_device *pwc,
mutex_lock(&pdec->lock); mutex_lock(&pdec->lock);
bandlines_left = pwc->height / 4; bandlines_left = pdev->height / 4;
bytes_per_block = pwc->width * 4; bytes_per_block = pdev->width * 4;
plane_size = pwc->height * pwc->width; plane_size = pdev->height * pdev->width;
pout_planar_y = dst; pout_planar_y = dst;
pout_planar_u = dst + plane_size; pout_planar_u = dst + plane_size;
pout_planar_v = dst + plane_size + plane_size / 4; pout_planar_v = dst + plane_size + plane_size / 4;
while (bandlines_left--) { while (bandlines_left--) {
DecompressBand23(pwc->decompress_data, DecompressBand23(pdec, src,
src,
pout_planar_y, pout_planar_u, pout_planar_v, pout_planar_y, pout_planar_u, pout_planar_v,
pwc->width, pwc->width); pdev->width, pdev->width);
src += pwc->vbandlength; src += pdev->vbandlength;
pout_planar_y += bytes_per_block; pout_planar_y += bytes_per_block;
pout_planar_u += pwc->width; pout_planar_u += pdev->width;
pout_planar_v += pwc->width; pout_planar_v += pdev->width;
} }
mutex_unlock(&pdec->lock); mutex_unlock(&pdec->lock);
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef PWC_DEC23_H #ifndef PWC_DEC23_H
#define PWC_DEC23_H #define PWC_DEC23_H
#include "pwc.h" struct pwc_device;
struct pwc_dec23_private struct pwc_dec23_private
{ {
...@@ -51,8 +51,8 @@ struct pwc_dec23_private ...@@ -51,8 +51,8 @@ struct pwc_dec23_private
}; };
int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd); void pwc_dec23_init(struct pwc_device *pdev, unsigned char *cmd);
void pwc_dec23_decompress(const struct pwc_device *pwc, void pwc_dec23_decompress(struct pwc_device *pdev,
const void *src, const void *src,
void *dst); void *dst);
#endif #endif
...@@ -603,14 +603,6 @@ static void pwc_video_release(struct v4l2_device *v) ...@@ -603,14 +603,6 @@ static void pwc_video_release(struct v4l2_device *v)
if (device_hint[hint].pdev == pdev) if (device_hint[hint].pdev == pdev)
device_hint[hint].pdev = NULL; device_hint[hint].pdev = NULL;
/* Free intermediate decompression buffer & tables */
if (pdev->decompress_data != NULL) {
PWC_DEBUG_MEMORY("Freeing decompression buffer at %p.\n",
pdev->decompress_data);
kfree(pdev->decompress_data);
pdev->decompress_data = NULL;
}
v4l2_ctrl_handler_free(&pdev->ctrl_handler); v4l2_ctrl_handler_free(&pdev->ctrl_handler);
kfree(pdev); kfree(pdev);
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#ifdef CONFIG_USB_PWC_INPUT_EVDEV #ifdef CONFIG_USB_PWC_INPUT_EVDEV
#include <linux/input.h> #include <linux/input.h>
#endif #endif
#include "pwc-dec1.h"
#include "pwc-dec23.h"
/* Version block */ /* Version block */
#define PWC_VERSION "10.0.15" #define PWC_VERSION "10.0.15"
...@@ -272,7 +274,10 @@ struct pwc_device ...@@ -272,7 +274,10 @@ struct pwc_device
int frame_total_size; /* including header & trailer */ int frame_total_size; /* including header & trailer */
int drop_frames; int drop_frames;
void *decompress_data; /* private data for decompression engine */ union { /* private data for decompression engine */
struct pwc_dec1_private dec1;
struct pwc_dec23_private dec23;
};
/* /*
* We have an 'image' and a 'view', where 'image' is the fixed-size img * We have an 'image' and a 'view', where 'image' is the fixed-size img
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册