aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorThierry MERLE <thierry.merle@free.fr>2006-12-15 14:46:53 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-27 11:19:04 -0500
commit38284ba361d69eca34a3bfc553ebfac81fea2698 (patch)
treeab923c9b82ac8f3be51006ccbd425182f3c07f42 /drivers/media
parent3a4456a073150c8b0d790daa007d2aab9ebdecb5 (diff)
V4L/DVB (4970): Usbvision memory fixes
- 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 'drivers/media')
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c48
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c3
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c14
-rw-r--r--drivers/media/video/usbvision/usbvision.h2
4 files changed, 19 insertions, 48 deletions
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index 612687305003..68542f2cf00c 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -374,7 +374,7 @@ static void scratch_reset(struct usb_usbvision *usbvision)
374 374
375int usbvision_scratch_alloc(struct usb_usbvision *usbvision) 375int usbvision_scratch_alloc(struct usb_usbvision *usbvision)
376{ 376{
377 usbvision->scratch = vmalloc(scratch_buf_size); 377 usbvision->scratch = vmalloc_32(scratch_buf_size);
378 scratch_reset(usbvision); 378 scratch_reset(usbvision);
379 if(usbvision->scratch == NULL) { 379 if(usbvision->scratch == NULL) {
380 err("%s: unable to allocate %d bytes for scratch", 380 err("%s: unable to allocate %d bytes for scratch",
@@ -485,7 +485,7 @@ static void usbvision_testpattern(struct usb_usbvision *usbvision,
485int usbvision_decompress_alloc(struct usb_usbvision *usbvision) 485int usbvision_decompress_alloc(struct usb_usbvision *usbvision)
486{ 486{
487 int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2; 487 int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2;
488 usbvision->IntraFrameBuffer = vmalloc(IFB_size); 488 usbvision->IntraFrameBuffer = vmalloc_32(IFB_size);
489 if (usbvision->IntraFrameBuffer == NULL) { 489 if (usbvision->IntraFrameBuffer == NULL) {
490 err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size); 490 err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size);
491 return -ENOMEM; 491 return -ENOMEM;
@@ -2204,6 +2204,7 @@ int usbvision_power_on(struct usb_usbvision *usbvision)
2204 usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN); 2204 usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN);
2205 usbvision_write_reg(usbvision, USBVISION_PWR_REG, 2205 usbvision_write_reg(usbvision, USBVISION_PWR_REG,
2206 USBVISION_SSPND_EN | USBVISION_RES2); 2206 USBVISION_SSPND_EN | USBVISION_RES2);
2207
2207 usbvision_write_reg(usbvision, USBVISION_PWR_REG, 2208 usbvision_write_reg(usbvision, USBVISION_PWR_REG,
2208 USBVISION_SSPND_EN | USBVISION_PWR_VID); 2209 USBVISION_SSPND_EN | USBVISION_PWR_VID);
2209 errCode = usbvision_write_reg(usbvision, USBVISION_PWR_REG, 2210 errCode = usbvision_write_reg(usbvision, USBVISION_PWR_REG,
@@ -2351,40 +2352,6 @@ int usbvision_setup(struct usb_usbvision *usbvision,int format)
2351 return USBVISION_IS_OPERATIONAL(usbvision); 2352 return USBVISION_IS_OPERATIONAL(usbvision);
2352} 2353}
2353 2354
2354
2355int usbvision_sbuf_alloc(struct usb_usbvision *usbvision)
2356{
2357 int i, errCode = 0;
2358 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
2359
2360 /* Clean pointers so we know if we allocated something */
2361 for (i = 0; i < USBVISION_NUMSBUF; i++)
2362 usbvision->sbuf[i].data = NULL;
2363
2364 for (i = 0; i < USBVISION_NUMSBUF; i++) {
2365 usbvision->sbuf[i].data = kzalloc(sb_size, GFP_KERNEL);
2366 if (usbvision->sbuf[i].data == NULL) {
2367 err("%s: unable to allocate %d bytes for sbuf", __FUNCTION__, sb_size);
2368 errCode = -ENOMEM;
2369 break;
2370 }
2371 }
2372 return errCode;
2373}
2374
2375
2376void usbvision_sbuf_free(struct usb_usbvision *usbvision)
2377{
2378 int i;
2379
2380 for (i = 0; i < USBVISION_NUMSBUF; i++) {
2381 if (usbvision->sbuf[i].data != NULL) {
2382 kfree(usbvision->sbuf[i].data);
2383 usbvision->sbuf[i].data = NULL;
2384 }
2385 }
2386}
2387
2388/* 2355/*
2389 * usbvision_init_isoc() 2356 * usbvision_init_isoc()
2390 * 2357 *
@@ -2393,6 +2360,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2393{ 2360{
2394 struct usb_device *dev = usbvision->dev; 2361 struct usb_device *dev = usbvision->dev;
2395 int bufIdx, errCode, regValue; 2362 int bufIdx, errCode, regValue;
2363 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
2396 2364
2397 if (!USBVISION_IS_OPERATIONAL(usbvision)) 2365 if (!USBVISION_IS_OPERATIONAL(usbvision))
2398 return -EFAULT; 2366 return -EFAULT;
@@ -2428,6 +2396,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2428 return -ENOMEM; 2396 return -ENOMEM;
2429 } 2397 }
2430 usbvision->sbuf[bufIdx].urb = urb; 2398 usbvision->sbuf[bufIdx].urb = urb;
2399 usbvision->sbuf[bufIdx].data = usb_buffer_alloc(usbvision->dev, sb_size, GFP_KERNEL,&urb->transfer_dma);
2431 urb->dev = dev; 2400 urb->dev = dev;
2432 urb->context = usbvision; 2401 urb->context = usbvision;
2433 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp); 2402 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);
@@ -2469,6 +2438,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2469void usbvision_stop_isoc(struct usb_usbvision *usbvision) 2438void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2470{ 2439{
2471 int bufIdx, errCode, regValue; 2440 int bufIdx, errCode, regValue;
2441 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
2472 2442
2473 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL)) 2443 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL))
2474 return; 2444 return;
@@ -2476,6 +2446,12 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2476 /* Unschedule all of the iso td's */ 2446 /* Unschedule all of the iso td's */
2477 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) { 2447 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) {
2478 usb_kill_urb(usbvision->sbuf[bufIdx].urb); 2448 usb_kill_urb(usbvision->sbuf[bufIdx].urb);
2449 if (usbvision->sbuf[bufIdx].data){
2450 usb_buffer_free(usbvision->dev,
2451 sb_size,
2452 usbvision->sbuf[bufIdx].data,
2453 usbvision->sbuf[bufIdx].urb->transfer_dma);
2454 }
2479 usb_free_urb(usbvision->sbuf[bufIdx].urb); 2455 usb_free_urb(usbvision->sbuf[bufIdx].urb);
2480 usbvision->sbuf[bufIdx].urb = NULL; 2456 usbvision->sbuf[bufIdx].urb = NULL;
2481 } 2457 }
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index efcd25bc1615..858252c15084 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -319,6 +319,9 @@ static int attach_inform(struct i2c_client *client)
319 case 0x4a: 319 case 0x4a:
320 PDEBUG(DBG_I2C,"attach_inform: saa7113 detected."); 320 PDEBUG(DBG_I2C,"attach_inform: saa7113 detected.");
321 break; 321 break;
322 case 0x48:
323 PDEBUG(DBG_I2C,"attach_inform: saa7111 detected.");
324 break;
322 case 0xa0: 325 case 0xa0:
323 PDEBUG(DBG_I2C,"attach_inform: eeprom detected."); 326 PDEBUG(DBG_I2C,"attach_inform: eeprom detected.");
324 break; 327 break;
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index b77e25ea8838..31b133ef0698 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -353,20 +353,15 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
353 if(!errCode) { 353 if(!errCode) {
354 /* Allocate memory for the scratch ring buffer */ 354 /* Allocate memory for the scratch ring buffer */
355 errCode = usbvision_scratch_alloc(usbvision); 355 errCode = usbvision_scratch_alloc(usbvision);
356 if(!errCode) { 356 if ((!errCode) && (isocMode==ISOC_MODE_COMPRESS)) {
357 /* Allocate memory for the USB S buffers */ 357 /* Allocate intermediate decompression buffers only if needed */
358 errCode = usbvision_sbuf_alloc(usbvision); 358 errCode = usbvision_decompress_alloc(usbvision);
359 if ((!errCode) && (usbvision->isocMode==ISOC_MODE_COMPRESS)) {
360 /* Allocate intermediate decompression buffers only if needed */
361 errCode = usbvision_decompress_alloc(usbvision);
362 }
363 } 359 }
364 } 360 }
365 if (errCode) { 361 if (errCode) {
366 /* Deallocate all buffers if trouble */ 362 /* Deallocate all buffers if trouble */
367 usbvision_frames_free(usbvision); 363 usbvision_frames_free(usbvision);
368 usbvision_scratch_free(usbvision); 364 usbvision_scratch_free(usbvision);
369 usbvision_sbuf_free(usbvision);
370 usbvision_decompress_free(usbvision); 365 usbvision_decompress_free(usbvision);
371 } 366 }
372 } 367 }
@@ -437,9 +432,8 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
437 usbvision_stop_isoc(usbvision); 432 usbvision_stop_isoc(usbvision);
438 433
439 usbvision_decompress_free(usbvision); 434 usbvision_decompress_free(usbvision);
440 usbvision_rvfree(usbvision->fbuf, usbvision->fbuf_size); 435 usbvision_frames_free(usbvision);
441 usbvision_scratch_free(usbvision); 436 usbvision_scratch_free(usbvision);
442 usbvision_sbuf_free(usbvision);
443 437
444 usbvision->user--; 438 usbvision->user--;
445 439
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index b1645f9e572d..e2bcaba93871 100644
--- a/drivers/media/video/usbvision/usbvision.h
+++ b/drivers/media/video/usbvision/usbvision.h
@@ -495,8 +495,6 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision);
495void usbvision_frames_free(struct usb_usbvision *usbvision); 495void usbvision_frames_free(struct usb_usbvision *usbvision);
496int usbvision_scratch_alloc(struct usb_usbvision *usbvision); 496int usbvision_scratch_alloc(struct usb_usbvision *usbvision);
497void usbvision_scratch_free(struct usb_usbvision *usbvision); 497void usbvision_scratch_free(struct usb_usbvision *usbvision);
498int usbvision_sbuf_alloc(struct usb_usbvision *usbvision);
499void usbvision_sbuf_free(struct usb_usbvision *usbvision);
500int usbvision_decompress_alloc(struct usb_usbvision *usbvision); 498int usbvision_decompress_alloc(struct usb_usbvision *usbvision);
501void usbvision_decompress_free(struct usb_usbvision *usbvision); 499void usbvision_decompress_free(struct usb_usbvision *usbvision);
502 500