summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-12-15 17:46:53 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-15 17:46:53 -0200
commitd0f2036ec4877863739bed422ec66a985e443956 (patch)
tree380e64dd71ec95311411a8512a7487d118202f1b /linux
parent2bf10f4704af48d1f3b0d403ef9dc13114a8afca (diff)
downloadmediapointer-dvb-s2-d0f2036ec4877863739bed422ec66a985e443956.tar.gz
mediapointer-dvb-s2-d0f2036ec4877863739bed422ec66a985e443956.tar.bz2
usbvision memory fixes
From: Thierry MERLE <thierry.merle@free.fr> - fix decompression buffer allocation not done at first driver open - simplification of USB sbuf allocation (use of usb_buffer_alloc) - replaced vmalloc by vmalloc_32 (for homogeneity) - add of saa7111 (i2cAddr=0x48) detection printout in attach_inform Signed-off-by: Thierry MERLE <thierry.merle@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/video/cx88/cx88-core.c25
-rw-r--r--linux/drivers/media/video/tda9887.c4
-rw-r--r--linux/drivers/media/video/usbvision/usbvision-core.c77
-rw-r--r--linux/drivers/media/video/usbvision/usbvision-i2c.c3
-rw-r--r--linux/drivers/media/video/usbvision/usbvision-video.c14
-rw-r--r--linux/drivers/media/video/usbvision/usbvision.h2
6 files changed, 42 insertions, 83 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c
index c2e6df733..00080018a 100644
--- a/linux/drivers/media/video/cx88/cx88-core.c
+++ b/linux/drivers/media/video/cx88/cx88-core.c
@@ -688,24 +688,29 @@ static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm)
static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm)
{
- static const unsigned int ntsc = 28636360;
- static const unsigned int pal = 35468950;
- static const unsigned int palm = 28604892;
-
if (norm->id & V4L2_STD_PAL_M)
- return palm;
+ return 28604892; // 3.575611 MHz
+
+ /* Does PAL/N' use the same carrier freq? */
+ if (norm->id & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc))
+ return 28656448; // 3.582056 MHz
+
+ if (norm->id & V4L2_STD_NTSC)
+ return 28636360; // 3.57954545 MHz +/- 10 Hz
- return (norm->id & V4L2_STD_625_50) ? pal : ntsc;
+ /* SECAM have also different sub carrier for chroma. Maybe their
+ freqs should also be here to improve video quality */
+
+ return 35468950; // 4.43361875 MHz
}
static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
{
- /* Should always be Line Draw Time / (4*FSC) */
- if (norm->id & V4L2_STD_PAL_M)
- return 909;
+ unsigned int fsc4=norm_fsc8(norm)/2;
- return (norm->id & V4L2_STD_625_50) ? 1135 : 910;
+ /* returns 4*FSC / frames per seconds / vtotal */
+ return (norm->id & V4L2_STD_625_50) ? fsc4/25/625 : fsc4*30000/1001/525;
}
static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm)
diff --git a/linux/drivers/media/video/tda9887.c b/linux/drivers/media/video/tda9887.c
index a1577cff9..26ecd7ddb 100644
--- a/linux/drivers/media/video/tda9887.c
+++ b/linux/drivers/media/video/tda9887.c
@@ -120,8 +120,8 @@ struct tvnorm {
static struct tvnorm tvnorms[] = {
{
- .std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H | V4L2_STD_PAL_N,
- .name = "PAL-BGHN",
+ .std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H | V4L2_STD_PAL_N | V4L2_STD_PAL_60,
+ .name = "PAL-BGHN60",
.b = ( cNegativeFmTV |
cQSS ),
.c = ( cDeemphasisON |
diff --git a/linux/drivers/media/video/usbvision/usbvision-core.c b/linux/drivers/media/video/usbvision/usbvision-core.c
index 81a4f6eb5..071b11e75 100644
--- a/linux/drivers/media/video/usbvision/usbvision-core.c
+++ b/linux/drivers/media/video/usbvision/usbvision-core.c
@@ -414,7 +414,7 @@ static void scratch_reset(struct usb_usbvision *usbvision)
int usbvision_scratch_alloc(struct usb_usbvision *usbvision)
{
- usbvision->scratch = vmalloc(scratch_buf_size);
+ usbvision->scratch = vmalloc_32(scratch_buf_size);
scratch_reset(usbvision);
if(usbvision->scratch == NULL) {
err("%s: unable to allocate %d bytes for scratch",
@@ -525,7 +525,7 @@ static void usbvision_testpattern(struct usb_usbvision *usbvision,
int usbvision_decompress_alloc(struct usb_usbvision *usbvision)
{
int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2;
- usbvision->IntraFrameBuffer = vmalloc(IFB_size);
+ usbvision->IntraFrameBuffer = vmalloc_32(IFB_size);
if (usbvision->IntraFrameBuffer == NULL) {
err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size);
return -ENOMEM;
@@ -2268,18 +2268,7 @@ int usbvision_power_on(struct usb_usbvision *usbvision)
usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN);
usbvision_write_reg(usbvision, USBVISION_PWR_REG,
USBVISION_SSPND_EN | USBVISION_RES2);
-#if 0
- /* Set input format expected from decoder, should this be moved to usbvision_set_input() ?? */
- if(usbvision_device_data[usbvision->DevModel].Codec == CODEC_SAA7113) {
- /* SAA7113 uses 8 bit output */
- usbvision_write_reg(usbvision, USBVISION_VIN_REG1, USBVISION_8_422_SYNC);
- } else {
- /* I'm sure only about d2-d0 [010] 16 bit 4:2:2 usin sync pulses
- * as that is how saa7111 is configured */
- usbvision_write_reg(usbvision, USBVISION_VIN_REG1, USBVISION_16_422_SYNC);
- /* | USBVISION_VSNC_POL | USBVISION_VCLK_POL);*/
- }
-#endif
+
usbvision_write_reg(usbvision, USBVISION_PWR_REG,
USBVISION_SSPND_EN | USBVISION_PWR_VID);
errCode = usbvision_write_reg(usbvision, USBVISION_PWR_REG,
@@ -2431,51 +2420,6 @@ int usbvision_setup(struct usb_usbvision *usbvision,int format)
return USBVISION_IS_OPERATIONAL(usbvision);
}
-
-int usbvision_sbuf_alloc(struct usb_usbvision *usbvision)
-{
- int i, errCode = 0;
- const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
-
- /* Clean pointers so we know if we allocated something */
- for (i = 0; i < USBVISION_NUMSBUF; i++)
- usbvision->sbuf[i].data = NULL;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
- for (i = 0; i < USBVISION_NUMSBUF; i++) {
- usbvision->sbuf[i].data = kmalloc(sb_size, GFP_KERNEL);
- if (usbvision->sbuf[i].data == NULL) {
- err("%s: unable to allocate %d bytes for sbuf", __FUNCTION__, sb_size);
- errCode = -ENOMEM;
- break;
- }
- }
-#else
- for (i = 0; i < USBVISION_NUMSBUF; i++) {
- usbvision->sbuf[i].data = kzalloc(sb_size, GFP_KERNEL);
- if (usbvision->sbuf[i].data == NULL) {
- err("%s: unable to allocate %d bytes for sbuf", __FUNCTION__, sb_size);
- errCode = -ENOMEM;
- break;
- }
- }
-#endif
- return errCode;
-}
-
-
-void usbvision_sbuf_free(struct usb_usbvision *usbvision)
-{
- int i;
-
- for (i = 0; i < USBVISION_NUMSBUF; i++) {
- if (usbvision->sbuf[i].data != NULL) {
- kfree(usbvision->sbuf[i].data);
- usbvision->sbuf[i].data = NULL;
- }
- }
-}
-
/*
* usbvision_init_isoc()
*
@@ -2484,6 +2428,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
{
struct usb_device *dev = usbvision->dev;
int bufIdx, errCode, regValue;
+ const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
if (!USBVISION_IS_OPERATIONAL(usbvision))
return -EFAULT;
@@ -2523,6 +2468,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
return -ENOMEM;
}
usbvision->sbuf[bufIdx].urb = urb;
+ usbvision->sbuf[bufIdx].data = usb_buffer_alloc(usbvision->dev, sb_size, GFP_KERNEL,&urb->transfer_dma);
urb->dev = dev;
urb->context = usbvision;
urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);
@@ -2583,6 +2529,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
void usbvision_stop_isoc(struct usb_usbvision *usbvision)
{
int bufIdx, errCode, regValue;
+ const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL))
return;
@@ -2591,6 +2538,12 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) {
usb_kill_urb(usbvision->sbuf[bufIdx].urb);
+ if (usbvision->sbuf[bufIdx].data){
+ usb_buffer_free(usbvision->dev,
+ sb_size,
+ usbvision->sbuf[bufIdx].data,
+ usbvision->sbuf[bufIdx].urb->transfer_dma);
+ }
usb_free_urb(usbvision->sbuf[bufIdx].urb);
usbvision->sbuf[bufIdx].urb = NULL;
}
@@ -2601,6 +2554,12 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
err("%s: usb_unlink_urb() failed: error %d", __FUNCTION__, errCode);
}
+ if (usbvision->sbuf[bufIdx].data){
+ usb_buffer_free(usbvision->dev,
+ (EM28XX_NUM_PACKETS*usbvision->max_pkt_size),
+ usbvision->sbuf[bufIdx].data,
+ usbvision->sbuf[bufIdx].urb->transfer_dma);
+ }
/* Delete them all */
for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++)
usb_free_urb(usbvision->sbuf[bufIdx].urb);
diff --git a/linux/drivers/media/video/usbvision/usbvision-i2c.c b/linux/drivers/media/video/usbvision/usbvision-i2c.c
index 8bca4434e..30cb93a70 100644
--- a/linux/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/linux/drivers/media/video/usbvision/usbvision-i2c.c
@@ -342,6 +342,9 @@ static int attach_inform(struct i2c_client *client)
case 0x4a:
PDEBUG(DBG_I2C,"attach_inform: saa7113 detected.");
break;
+ case 0x48:
+ PDEBUG(DBG_I2C,"attach_inform: saa7111 detected.");
+ break;
case 0xa0:
PDEBUG(DBG_I2C,"attach_inform: eeprom detected.");
break;
diff --git a/linux/drivers/media/video/usbvision/usbvision-video.c b/linux/drivers/media/video/usbvision/usbvision-video.c
index 2fb71fbd7..45e4f3b0e 100644
--- a/linux/drivers/media/video/usbvision/usbvision-video.c
+++ b/linux/drivers/media/video/usbvision/usbvision-video.c
@@ -373,20 +373,15 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
if(!errCode) {
/* Allocate memory for the scratch ring buffer */
errCode = usbvision_scratch_alloc(usbvision);
- if(!errCode) {
- /* Allocate memory for the USB S buffers */
- errCode = usbvision_sbuf_alloc(usbvision);
- if ((!errCode) && (usbvision->isocMode==ISOC_MODE_COMPRESS)) {
- /* Allocate intermediate decompression buffers only if needed */
- errCode = usbvision_decompress_alloc(usbvision);
- }
+ if ((!errCode) && (isocMode==ISOC_MODE_COMPRESS)) {
+ /* Allocate intermediate decompression buffers only if needed */
+ errCode = usbvision_decompress_alloc(usbvision);
}
}
if (errCode) {
/* Deallocate all buffers if trouble */
usbvision_frames_free(usbvision);
usbvision_scratch_free(usbvision);
- usbvision_sbuf_free(usbvision);
usbvision_decompress_free(usbvision);
}
}
@@ -466,9 +461,8 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
usbvision_stop_isoc(usbvision);
usbvision_decompress_free(usbvision);
- usbvision_rvfree(usbvision->fbuf, usbvision->fbuf_size);
+ usbvision_frames_free(usbvision);
usbvision_scratch_free(usbvision);
- usbvision_sbuf_free(usbvision);
usbvision->user--;
diff --git a/linux/drivers/media/video/usbvision/usbvision.h b/linux/drivers/media/video/usbvision/usbvision.h
index 5c048d0ac..79976c399 100644
--- a/linux/drivers/media/video/usbvision/usbvision.h
+++ b/linux/drivers/media/video/usbvision/usbvision.h
@@ -520,8 +520,6 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision);
void usbvision_frames_free(struct usb_usbvision *usbvision);
int usbvision_scratch_alloc(struct usb_usbvision *usbvision);
void usbvision_scratch_free(struct usb_usbvision *usbvision);
-int usbvision_sbuf_alloc(struct usb_usbvision *usbvision);
-void usbvision_sbuf_free(struct usb_usbvision *usbvision);
int usbvision_decompress_alloc(struct usb_usbvision *usbvision);
void usbvision_decompress_free(struct usb_usbvision *usbvision);