Hello Please try out the attached patch on top of current master head (commit a5937769d5cd9dd9f1f46e645f52c373d69bf4f9)
I tested this on x86_64 seems to help a bit with cpu usage making the jpeg header static causes CPU-0 CPU-1 LoadAvg-1 min LoadAvg-5 min LoadAvg-15 min 2.0 3.9-5.8 0.04 0.06 0.06 Use of static + likely/unlikely macros causes CPU-0 CPU-1 LoadAvg-1 min LoadAvg-5 min LoadAvg-15 min 2.0 2.8-3.8 0.03 0.03 0.05 webcam was pointed at an unchanging scene, the above is the average reading the 2.0 % usage is from htop process, the other readings were ~0.0% if webcam was not being used. # insmod sn9c20x.ko jpeg=1 $ LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so mplayer tv:// -tv driver=v4l2:width=640:height=480:fps=30:device=/dev/video0 -vo x11 Mplayer was the same "old" version MPlayer 1.0rc2-4.3.2 libv4l-0 was v0.5.8-1~intrepidppa1 feedback is MANDATORY ^_^ Neekhil PS: Can we standardize on a single method of measuring webcam FPS during capture ? --~--~---------~--~----~------------~-------~--~----~ Lets make microdia webcams plug'n play, (currently plug'n pray) To post to this group, send email to [email protected] Visit us online https://groups.google.com/group/microdia -~----------~----~----~----~------~----~------~--~---
From 9acf577b137c40e829c343083f5dc50a2e506254 Mon Sep 17 00:00:00 2001 From: Neekhil <[email protected]> Date: Sat, 31 Jan 2009 12:31:20 +0030 Subject: [PATCH] Performance optimizations for jpeg=1 Performance optimizations for jpeg=1 - JPEG Frame header should be static upon every function call (Preferably const as well) - playing with likely()/unlikely() macros for GCC optimizations Signed-off-by: Neekhil <[email protected]> --- sn9c20x-usb.c | 4 ++-- sn9c20x-v4l2.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sn9c20x-usb.c b/sn9c20x-usb.c index f98e12e..f8a4878 100644 --- a/sn9c20x-usb.c +++ b/sn9c20x-usb.c @@ -379,7 +379,7 @@ int usb_sn9c20x_init_urbs(struct usb_sn9c20x *dev) if (ret < 0) return ret; - if (!bulk) { + if (likely(!bulk)) { if (bandwidth > 8) return -EINVAL; @@ -596,7 +596,7 @@ void usb_sn9c20x_completion_handler(struct urb *urb) buf = list_first_entry(&queue->irqqueue, struct sn9c20x_buffer, queue); spin_unlock_irqrestore(&queue->irqlock, flags); - if (!bulk) { + if (likely(!bulk)) { for (i = 0; i < urb->number_of_packets; i++) { if (urb->iso_frame_desc[i].status != 0) { UDIA_ERROR("Iso frame %d of USB has error %d\n", diff --git a/sn9c20x-v4l2.c b/sn9c20x-v4l2.c index cecd2bf..01f38a4 100644 --- a/sn9c20x-v4l2.c +++ b/sn9c20x-v4l2.c @@ -185,7 +185,7 @@ void v4l2_set_control_default(struct usb_sn9c20x *dev, __u32 ctrl, __u16 value) void v4l_add_jpegheader(struct usb_sn9c20x *dev, __u8 *buffer, __u32 buffer_size) { - __u8 jpeg_header[589] = { + static __u8 jpeg_header[589] = { 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x06, 0x04, 0x05, 0x06, 0x05, 0x04, 0x06, 0x06, 0x05, 0x06, 0x07, 0x07, 0x06, 0x08, 0x0a, 0x10, 0x0a, 0x0a, 0x09, 0x09, 0x0a, 0x14, 0x0e, @@ -246,7 +246,7 @@ void v4l_add_jpegheader(struct usb_sn9c20x *dev, __u8 *buffer, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00 }; - __u8 qtable1[128] = { + static __u8 qtable1[128] = { 0x0d, 0x08, 0x08, 0x0d, 0x08, 0x08, 0x0d, 0x0d, 0x0d, 0x0d, 0x11, 0x0d, 0x0d, 0x11, 0x15, 0x21, 0x15, 0x15, 0x11, 0x11, 0x15, 0x2a, 0x1d, 0x1d, @@ -479,7 +479,7 @@ static ssize_t v4l_sn9c20x_read(struct file *fp, char __user *buf, dev = video_get_drvdata(video_devdata(fp)); ret = v4l_get_privileges(fp); - if (ret < 0) + if (unlikely(ret < 0)) return ret; if (dev->mode != SN9C20X_MODE_IDLE && @@ -488,10 +488,10 @@ static ssize_t v4l_sn9c20x_read(struct file *fp, char __user *buf, buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buffer.memory = V4L2_MEMORY_MMAP; - if (dev->mode == SN9C20X_MODE_IDLE) { + if (likely(dev->mode == SN9C20X_MODE_IDLE)) { nbuffers = sn9c20x_alloc_buffers(&dev->queue, 2, dev->vsettings.format.sizeimage); - if (nbuffers < 0) + if (unlikely(nbuffers < 0)) return nbuffers; for (i = 0; i < nbuffers; i++) { @@ -500,7 +500,7 @@ static ssize_t v4l_sn9c20x_read(struct file *fp, char __user *buf, } ret = v4l2_enable_video(dev, SN9C20X_MODE_READ); - if (ret < 0) + if (unlikely(ret < 0)) return ret; } -- 1.5.6.3
