mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: V4L-DVB Maintainers <v4l-dvb-maintainer@linuxtv.org>,
	Thierry MERLE <thierry.merle@free.fr>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: [PATCH 09/28] V4L/DVB (4970): Usbvision memory fixes
Date: Wed, 27 Dec 2006 14:57:28 -0200	[thread overview]
Message-ID: <20061227165728.PS70472000009@infradead.org> (raw)
In-Reply-To: <20061227165016.PS89442900000@infradead.org>


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>
---

 drivers/media/video/usbvision/usbvision-core.c  |   48 ++++++-----------------
 drivers/media/video/usbvision/usbvision-i2c.c   |    3 +
 drivers/media/video/usbvision/usbvision-video.c |   14 ++-----
 drivers/media/video/usbvision/usbvision.h       |    2 -
 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 6126873..68542f2 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_usb
 
 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",
@@ -485,7 +485,7 @@ static void usbvision_testpattern(struct
 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;
@@ -2204,6 +2204,7 @@ int usbvision_power_on(struct usb_usbvis
 	usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN);
 	usbvision_write_reg(usbvision, USBVISION_PWR_REG,
 			 USBVISION_SSPND_EN | USBVISION_RES2);
+
 	usbvision_write_reg(usbvision, USBVISION_PWR_REG,
 			 USBVISION_SSPND_EN | USBVISION_PWR_VID);
 	errCode = usbvision_write_reg(usbvision, USBVISION_PWR_REG,
@@ -2351,40 +2352,6 @@ int usbvision_setup(struct usb_usbvision
 	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;
-
-	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;
-		}
-	}
-	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()
  *
@@ -2393,6 +2360,7 @@ int usbvision_init_isoc(struct usb_usbvi
 {
 	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;
@@ -2428,6 +2396,7 @@ int usbvision_init_isoc(struct usb_usbvi
 			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);
@@ -2469,6 +2438,7 @@ int usbvision_init_isoc(struct usb_usbvi
 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;
@@ -2476,6 +2446,12 @@ void usbvision_stop_isoc(struct usb_usbv
 	/* Unschedule all of the iso td's */
 	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;
 	}
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index efcd25b..858252c 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_clie
 		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/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index b77e25e..31b133e 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 in
 		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);
 		}
 	}
@@ -437,9 +432,8 @@ static int usbvision_v4l2_close(struct i
 	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/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index b1645f9..e2bcaba 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_us
 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);
 


  parent reply	other threads:[~2006-12-27 17:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-27 16:50 [PATCH 00/28] V4L/DVB fixes Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 05/28] V4L/DVB (4960): Removal of unused code from usbvision-i2c.c Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 02/28] V4L/DVB (4956): [NOVA-T-USB2] Put remote-debugging in the right place Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 04/28] V4L/DVB (4959): Usbvision: possible cleanups Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 01/28] V4L/DVB (4955): Fix autosearch index Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 03/28] V4L/DVB (4958): Fix namespace conflict between w9968cf.c on MIPS Mauro Carvalho Chehab
2006-12-27 16:57 ` Mauro Carvalho Chehab [this message]
2006-12-27 16:57 ` [PATCH 06/28] V4L/DVB (4964): VIDEO_PALETTE_YUYV and VIDEO_PALETTE_YUV422 are the same palette Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 08/28] V4L/DVB (4968): Add PAL-60 support for cx2584x Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 07/28] V4L/DVB (4967): Add missing tuner module option pal=60 for PAL-60 support Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 12/28] V4L/DVB (4979): Fixes compilation when CONFIG_V4L1_COMPAT is not selected Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 10/28] V4L/DVB (4972): Dvb-core: fix bug in CRC-32 checking on 64-bit systems Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 13/28] V4L/DVB (4980): Fixes bug 7267: PAL/60 is not working Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 11/28] V4L/DVB (4973): Dvb-core: fix printk type warning Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 17/28] V4L/DVB (4988): Cx2341x audio_properties is an u16, not u8 Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 16/28] V4L/DVB (4984): LOG_STATUS should show the real temporal filter value Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 14/28] V4L/DVB (4982): Fix broken audio mode handling for line-in in msp3400 Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 18/28] V4L/DVB (4990): Cpia2/cpia2_usb.c: fix error-path leak Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 15/28] V4L/DVB (4983): Force temporal filter to 0 when scaling to prevent ghosting Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 19/28] V4L/DVB (4991): Cafe_ccic.c: fix NULL dereference Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 22/28] V4L/DVB (4995): Vivi: fix kthread_run() error check Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 21/28] V4L/DVB (4994): Vivi: fix use after free in list_for_each() Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 20/28] V4L/DVB (4992): Fix typo in saa7134-dvb.c Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 27/28] V4L/DVB (5012): Usbvision fix: It was using "&&" instead "&" Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 26/28] V4L/DVB (5001): Add two required headers on kernel 2.6.20-rc1 Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 23/28] V4L/DVB (4996): Msp3400: fix kthread_run error check Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 25/28] V4L/DVB (5014): Allyesconfig build fixes on some non x86 arch Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 24/28] V4L/DVB (4997): Bttv: delete duplicated ioremap() Mauro Carvalho Chehab
2006-12-27 16:57 ` [PATCH 28/28] V4L/DVB (5010): Cx88: Fix leadtek_eeprom tagging Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061227165728.PS70472000009@infradead.org \
    --to=mchehab@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thierry.merle@free.fr \
    --cc=v4l-dvb-maintainer@linuxtv.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®