Commit 9fbdfdf7 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: rip the pwc decompressor hooks out of the kernel, as they are a GPL violation.

Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent bc612c10
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Makefile for USB Media drivers # Makefile for USB Media drivers
# #
pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o
sn9c102-objs := sn9c102_core.o sn9c102_pas106b.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o sn9c102_pas202bcb.o sn9c102-objs := sn9c102_core.o sn9c102_pas106b.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o sn9c102_pas202bcb.o
obj-$(CONFIG_USB_DABUSB) += dabusb.o obj-$(CONFIG_USB_DABUSB) += dabusb.o
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "pwc.h" #include "pwc.h"
#include "pwc-ioctl.h" #include "pwc-ioctl.h"
#include "pwc-uncompress.h"
/* Request types: video */ /* Request types: video */
#define SET_LUM_CTL 0x01 #define SET_LUM_CTL 0x01
...@@ -268,8 +267,6 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra ...@@ -268,8 +267,6 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
Debug("Failed to send video command... %d\n", ret); Debug("Failed to send video command... %d\n", ret);
return ret; return ret;
} }
if (pEntry->compressed && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
pdev->cmd_len = 3; pdev->cmd_len = 3;
memcpy(pdev->cmd_buf, buf, 3); memcpy(pdev->cmd_buf, buf, 3);
...@@ -336,9 +333,6 @@ static inline int set_video_mode_Timon(struct pwc_device *pdev, int size, int fr ...@@ -336,9 +333,6 @@ static inline int set_video_mode_Timon(struct pwc_device *pdev, int size, int fr
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
pdev->cmd_len = 13; pdev->cmd_len = 13;
memcpy(pdev->cmd_buf, buf, 13); memcpy(pdev->cmd_buf, buf, 13);
...@@ -421,9 +415,6 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr ...@@ -421,9 +415,6 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
pdev->cmd_len = 12; pdev->cmd_len = 12;
memcpy(pdev->cmd_buf, buf, 12); memcpy(pdev->cmd_buf, buf, 12);
/* All set and go */ /* All set and go */
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "pwc.h" #include "pwc.h"
#include "pwc-ioctl.h" #include "pwc-ioctl.h"
#include "pwc-uncompress.h"
/* Function prototypes and driver templates */ /* Function prototypes and driver templates */
...@@ -302,14 +301,6 @@ static int pwc_allocate_buffers(struct pwc_device *pdev) ...@@ -302,14 +301,6 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
/* Allocate decompressor table space */ /* Allocate decompressor table space */
kbuf = NULL; kbuf = NULL;
if (pdev->decompressor != NULL) {
kbuf = kmalloc(pdev->decompressor->table_size, GFP_KERNEL);
if (kbuf == NULL) {
Err("Failed to allocate decompress table.\n");
return -ENOMEM;
}
Trace(TRACE_MEMORY, "Allocated decompress table %p.\n", kbuf);
}
pdev->decompress_data = kbuf; pdev->decompress_data = kbuf;
/* Allocate image buffer; double buffer for mmap() */ /* Allocate image buffer; double buffer for mmap() */
...@@ -550,14 +541,6 @@ static int pwc_handle_frame(struct pwc_device *pdev) ...@@ -550,14 +541,6 @@ static int pwc_handle_frame(struct pwc_device *pdev)
#if PWC_DEBUG #if PWC_DEBUG
Trace(TRACE_SEQUENCE, "Decompressing frame %d\n", pdev->read_frame->sequence); Trace(TRACE_SEQUENCE, "Decompressing frame %d\n", pdev->read_frame->sequence);
#endif #endif
/* Decompression is a lenghty process, so it's outside of the lock.
This gives the isoc_handler the opportunity to fill more frames
in the mean time.
*/
spin_unlock_irqrestore(&pdev->ptrlock, flags);
ret = pwc_decompress(pdev);
spin_lock_irqsave(&pdev->ptrlock, flags);
/* We're done with read_buffer, tack it to the end of the empty buffer list */ /* We're done with read_buffer, tack it to the end of the empty buffer list */
if (pdev->empty_frames == NULL) { if (pdev->empty_frames == NULL) {
pdev->empty_frames = pdev->read_frame; pdev->empty_frames = pdev->read_frame;
...@@ -1014,11 +997,7 @@ static int pwc_video_open(struct inode *inode, struct file *file) ...@@ -1014,11 +997,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
if (pwc_set_leds(pdev, led_on, led_off) < 0) if (pwc_set_leds(pdev, led_on, led_off) < 0)
Info("Failed to set LED on/off time.\n"); Info("Failed to set LED on/off time.\n");
/* Find our decompressor, if any */ pdev->decompressor = NULL;
pdev->decompressor = pwc_find_decompressor(pdev->type);
#if PWC_DEBUG
Debug("Found decompressor for %d at 0x%p\n", pdev->type, pdev->decompressor);
#endif
pwc_construct(pdev); /* set min/max sizes correct */ pwc_construct(pdev); /* set min/max sizes correct */
/* So far, so good. Allocate memory. */ /* So far, so good. Allocate memory. */
...@@ -1073,12 +1052,6 @@ static int pwc_video_open(struct inode *inode, struct file *file) ...@@ -1073,12 +1052,6 @@ static int pwc_video_open(struct inode *inode, struct file *file)
pdev->vopen++; pdev->vopen++;
file->private_data = vdev; file->private_data = vdev;
/* lock decompressor; this has a small race condition, since we
could in theory unload pwcx.o between pwc_find_decompressor()
above and this call. I doubt it's ever going to be a problem.
*/
if (pdev->decompressor != NULL)
pdev->decompressor->lock();
up(&pdev->modlock); up(&pdev->modlock);
Trace(TRACE_OPEN, "<< video_open() returns 0.\n"); Trace(TRACE_OPEN, "<< video_open() returns 0.\n");
return 0; return 0;
...@@ -1104,12 +1077,6 @@ static int pwc_video_close(struct inode *inode, struct file *file) ...@@ -1104,12 +1077,6 @@ static int pwc_video_close(struct inode *inode, struct file *file)
if (pdev->vframe_count > 20) if (pdev->vframe_count > 20)
Info("Closing video device: %d frames received, dumped %d frames, %d frames with errors.\n", pdev->vframe_count, pdev->vframes_dumped, pdev->vframes_error); Info("Closing video device: %d frames received, dumped %d frames, %d frames with errors.\n", pdev->vframe_count, pdev->vframes_dumped, pdev->vframes_error);
if (pdev->decompressor != NULL) {
pdev->decompressor->exit();
pdev->decompressor->unlock();
pdev->decompressor = NULL;
}
pwc_isoc_cleanup(pdev); pwc_isoc_cleanup(pdev);
pwc_free_buffers(pdev); pwc_free_buffers(pdev);
......
/* Linux driver for Philips webcam
Decompression frontend.
(C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
This is where the decompression routines register and unregister
themselves. It also has a decompressor wrapper function.
*/
#include <asm/current.h>
#include <asm/types.h>
// #include <linux/sched.h>
#include "pwc.h"
#include "pwc-uncompress.h"
/* This contains a list of all registered decompressors */
static LIST_HEAD(pwc_decompressor_list);
/* Should the pwc_decompress structure ever change, we increase the
version number so that we don't get nasty surprises, or can
dynamically adjust our structure.
*/
const int pwc_decompressor_version = PWC_MAJOR;
/* Add decompressor to list, ignoring duplicates */
void pwc_register_decompressor(struct pwc_decompressor *pwcd)
{
if (pwc_find_decompressor(pwcd->type) == NULL) {
Trace(TRACE_PWCX, "Adding decompressor for model %d.\n", pwcd->type);
list_add_tail(&pwcd->pwcd_list, &pwc_decompressor_list);
}
}
/* Remove decompressor from list */
void pwc_unregister_decompressor(int type)
{
struct pwc_decompressor *find;
find = pwc_find_decompressor(type);
if (find != NULL) {
Trace(TRACE_PWCX, "Removing decompressor for model %d.\n", type);
list_del(&find->pwcd_list);
}
}
/* Find decompressor in list */
struct pwc_decompressor *pwc_find_decompressor(int type)
{
struct list_head *tmp;
struct pwc_decompressor *pwcd;
list_for_each(tmp, &pwc_decompressor_list) {
pwcd = list_entry(tmp, struct pwc_decompressor, pwcd_list);
if (pwcd->type == type)
return pwcd;
}
return NULL;
}
int pwc_decompress(struct pwc_device *pdev)
{
struct pwc_frame_buf *fbuf;
int n, line, col, stride;
void *yuv, *image;
u16 *src;
u16 *dsty, *dstu, *dstv;
if (pdev == NULL)
return -EFAULT;
#if defined(__KERNEL__) && defined(PWC_MAGIC)
if (pdev->magic != PWC_MAGIC) {
Err("pwc_decompress(): magic failed.\n");
return -EFAULT;
}
#endif
fbuf = pdev->read_frame;
if (fbuf == NULL)
return -EFAULT;
image = pdev->image_ptr[pdev->fill_image];
if (!image)
return -EFAULT;
yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
/* Raw format; that's easy... */
if (pdev->vpalette == VIDEO_PALETTE_RAW)
{
memcpy(image, yuv, pdev->frame_size);
return 0;
}
if (pdev->vbandlength == 0) {
/* Uncompressed mode. We copy the data into the output buffer,
using the viewport size (which may be larger than the image
size). Unfortunately we have to do a bit of byte stuffing
to get the desired output format/size.
*/
/*
* We do some byte shuffling here to go from the
* native format to YUV420P.
*/
src = (u16 *)yuv;
n = pdev->view.x * pdev->view.y;
/* offset in Y plane */
stride = pdev->view.x * pdev->offset.y + pdev->offset.x;
dsty = (u16 *)(image + stride);
/* offsets in U/V planes */
stride = pdev->view.x * pdev->offset.y / 4 + pdev->offset.x / 2;
dstu = (u16 *)(image + n + stride);
dstv = (u16 *)(image + n + n / 4 + stride);
/* increment after each line */
stride = (pdev->view.x - pdev->image.x) / 2; /* u16 is 2 bytes */
for (line = 0; line < pdev->image.y; line++) {
for (col = 0; col < pdev->image.x; col += 4) {
*dsty++ = *src++;
*dsty++ = *src++;
if (line & 1)
*dstv++ = *src++;
else
*dstu++ = *src++;
}
dsty += stride;
if (line & 1)
dstv += (stride >> 1);
else
dstu += (stride >> 1);
}
}
else {
/* Compressed; the decompressor routines will write the data
in planar format immediately.
*/
int flags;
flags = PWCX_FLAG_PLANAR;
if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
flags |= PWCX_FLAG_BAYER;
if (pdev->decompressor)
pdev->decompressor->decompress(
&pdev->image, &pdev->view, &pdev->offset,
yuv, image,
flags,
pdev->decompress_data, pdev->vbandlength);
else
return -ENXIO; /* No such device or address: missing decompressor */
}
return 0;
}
/* Make sure these functions are available for the decompressor plugin
both when this code is compiled into the kernel or as as module.
*/
EXPORT_SYMBOL_NOVERS(pwc_decompressor_version);
EXPORT_SYMBOL(pwc_register_decompressor);
EXPORT_SYMBOL(pwc_unregister_decompressor);
/* (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* This file is the bridge between the kernel module and the plugin; it
describes the structures and datatypes used in both modules. Any
significant change should be reflected by increasing the
pwc_decompressor_version major number.
*/
#ifndef PWC_UNCOMPRESS_H
#define PWC_UNCOMPRESS_H
#include <linux/config.h>
#include <linux/linkage.h>
#include <linux/list.h>
#include "pwc-ioctl.h"
/* from pwc-dec.h */
#define PWCX_FLAG_PLANAR 0x0001
/* */
#ifdef __cplusplus
extern "C" {
#endif
/* The decompressor structure.
Every type of decompressor registers itself with the main module.
When a device is opened, it looks up the correct compressor, and
uses that when a compressed video mode is requested.
*/
struct pwc_decompressor
{
int type; /* type of camera (645, 680, etc) */
int table_size; /* memory needed */
void (* init)(int type, int release, void *buffer, void *table); /* Initialization routine; should be called after each set_video_mode */
void (* exit)(void); /* Cleanup routine */
void (* decompress)(struct pwc_coord *image, struct pwc_coord *view,
struct pwc_coord *offset,
void *src, void *dst, int flags,
void *table, int bandlength);
void (* lock)(void); /* make sure module cannot be unloaded */
void (* unlock)(void); /* release lock on module */
struct list_head pwcd_list;
};
/* Our structure version number. Is set to the version number major */
extern const int pwc_decompressor_version;
/* Adds decompressor to list, based on its 'type' field (which matches the 'type' field in pwc_device; ignores any double requests */
extern void pwc_register_decompressor(struct pwc_decompressor *pwcd);
/* Removes decompressor, based on the type number */
extern void pwc_unregister_decompressor(int type);
/* Returns pointer to decompressor struct, or NULL if it doesn't exist */
extern struct pwc_decompressor *pwc_find_decompressor(int type);
#ifdef CONFIG_USB_PWCX
/* If the decompressor is compiled in, we must call these manually */
extern int usb_pwcx_init(void);
extern void usb_pwcx_exit(void);
#endif
#ifdef __cplusplus
}
#endif
#endif
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/errno.h> #include <asm/errno.h>
#include "pwc-uncompress.h"
#include "pwc-ioctl.h" #include "pwc-ioctl.h"
/* Defines and structures for the Philips webcam */ /* Defines and structures for the Philips webcam */
...@@ -258,11 +257,6 @@ extern int pwc_camera_power(struct pwc_device *pdev, int power); ...@@ -258,11 +257,6 @@ extern int pwc_camera_power(struct pwc_device *pdev, int power);
/* Private ioctl()s; see pwc-ioctl.h */ /* Private ioctl()s; see pwc-ioctl.h */
extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg); extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg);
/** pwc-uncompress.c */
/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */
extern int pwc_decompress(struct pwc_device *pdev);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment