diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-13 13:37:52 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:08:00 -0400 |
commit | ad0ebb96c220c461386e9a765fca3daf5590d01e (patch) | |
tree | 4c13c24682703cbb94f415eb944c573ac0835ccc /drivers/media/video/em28xx/em28xx.h | |
parent | 78e92006f410a4044f8c1760c25ac9d11d259aa2 (diff) |
V4L/DVB (7540): em28xx: convert to use videobuf-vmalloc
The usage of videobuf-vmalloc allows to cleanup em28xx logic.
Also, it reduced its size by about 5.42% on i386 arch (and about 7.5% on x86_64):
39113 4876 40 44029 abfd old/em28xx.ko
36731 4868 40 41639 a2a7 /home/v4l/master/v4l/em28xx.ko
Also, the preliminary tests, made on a single core 1.5 MHz Centrino showed
that CPU usage reduced from 42%-75% to 28%-33% (reports from "top") command.
A test with time command presented an even better result:
This is the performance tests I did, running code_example to get 1,000 frames
@29.995 Hz (about 35 seconds of stream), tested on a i386 machine, running at
1,5GHz:
The old driver:
$ time -f "%E: %Us User time, %Ss Kernel time, %P CPU used" ./capture_example
0:34.21: 8.22s User time, 25.16s Kernel time, 97% CPU used
The videobuf-based driver:
$ time -f "%E: %Us User time, %Ss Kernel time, %P CPU used" ./capture_example
0:35.36: 0.01s User time, 0.05s Kernel time, 0% CPU used
Conclusion:
The time consumption to receive the stream where reduced from about 33.38
seconds to 0.05 seconds.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx.h')
-rw-r--r-- | drivers/media/video/em28xx/em28xx.h | 94 |
1 files changed, 68 insertions, 26 deletions
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 04e0e48ecabe..dd18ceb30a43 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -26,12 +26,12 @@ | |||
26 | #define _EM28XX_H | 26 | #define _EM28XX_H |
27 | 27 | ||
28 | #include <linux/videodev2.h> | 28 | #include <linux/videodev2.h> |
29 | #include <media/videobuf-vmalloc.h> | ||
30 | |||
29 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
30 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
31 | #include <media/ir-kbd-i2c.h> | 33 | #include <media/ir-kbd-i2c.h> |
32 | 34 | ||
33 | #define UNSET -1 | ||
34 | |||
35 | /* maximum number of em28xx boards */ | 35 | /* maximum number of em28xx boards */ |
36 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ | 36 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ |
37 | 37 | ||
@@ -81,31 +81,69 @@ | |||
81 | /* time in msecs to wait for i2c writes to finish */ | 81 | /* time in msecs to wait for i2c writes to finish */ |
82 | #define EM2800_I2C_WRITE_TIMEOUT 20 | 82 | #define EM2800_I2C_WRITE_TIMEOUT 20 |
83 | 83 | ||
84 | /* the various frame states */ | ||
85 | enum em28xx_frame_state { | ||
86 | F_UNUSED = 0, | ||
87 | F_QUEUED, | ||
88 | F_GRABBING, | ||
89 | F_DONE, | ||
90 | F_ERROR, | ||
91 | }; | ||
92 | |||
93 | /* stream states */ | ||
94 | enum em28xx_stream_state { | 84 | enum em28xx_stream_state { |
95 | STREAM_OFF, | 85 | STREAM_OFF, |
96 | STREAM_INTERRUPT, | 86 | STREAM_INTERRUPT, |
97 | STREAM_ON, | 87 | STREAM_ON, |
98 | }; | 88 | }; |
99 | 89 | ||
100 | /* frames */ | 90 | struct em28xx_usb_isoc_ctl { |
101 | struct em28xx_frame_t { | 91 | /* max packet size of isoc transaction */ |
102 | void *bufmem; | 92 | int max_pkt_size; |
103 | struct v4l2_buffer buf; | 93 | |
104 | enum em28xx_frame_state state; | 94 | /* number of allocated urbs */ |
95 | int num_bufs; | ||
96 | |||
97 | /* urb for isoc transfers */ | ||
98 | struct urb **urb; | ||
99 | |||
100 | /* transfer buffers for isoc transfer */ | ||
101 | char **transfer_buffer; | ||
102 | |||
103 | /* Last buffer command and region */ | ||
104 | u8 cmd; | ||
105 | int pos, size, pktsize; | ||
106 | |||
107 | /* Last field: ODD or EVEN? */ | ||
108 | int field; | ||
109 | |||
110 | /* Stores incomplete commands */ | ||
111 | u32 tmp_buf; | ||
112 | int tmp_buf_len; | ||
113 | |||
114 | /* Stores already requested buffers */ | ||
115 | struct em28xx_buffer *buf; | ||
116 | |||
117 | /* Stores the number of received fields */ | ||
118 | int nfields; | ||
119 | }; | ||
120 | |||
121 | struct em28xx_fmt { | ||
122 | char *name; | ||
123 | u32 fourcc; /* v4l2 format id */ | ||
124 | }; | ||
125 | |||
126 | /* buffer for one video frame */ | ||
127 | struct em28xx_buffer { | ||
128 | /* common v4l buffer stuff -- must be first */ | ||
129 | struct videobuf_buffer vb; | ||
130 | |||
131 | struct em28xx_fmt *fmt; | ||
132 | |||
105 | struct list_head frame; | 133 | struct list_head frame; |
106 | unsigned long vma_use_count; | ||
107 | int top_field; | 134 | int top_field; |
108 | int fieldbytesused; | 135 | int receiving; |
136 | }; | ||
137 | |||
138 | struct em28xx_dmaqueue { | ||
139 | struct list_head active; | ||
140 | struct list_head queued; | ||
141 | struct timer_list timeout; | ||
142 | |||
143 | wait_queue_head_t wq; | ||
144 | |||
145 | /* Counters to control buffer fill */ | ||
146 | int pos; | ||
109 | }; | 147 | }; |
110 | 148 | ||
111 | /* io methods */ | 149 | /* io methods */ |
@@ -255,10 +293,6 @@ struct em28xx { | |||
255 | int mute; | 293 | int mute; |
256 | int volume; | 294 | int volume; |
257 | /* frame properties */ | 295 | /* frame properties */ |
258 | struct em28xx_frame_t frame[EM28XX_NUM_FRAMES]; /* list of frames */ | ||
259 | int num_frames; /* number of frames currently in use */ | ||
260 | unsigned int frame_count; /* total number of transfered frames */ | ||
261 | struct em28xx_frame_t *frame_current; /* the frame that is being filled */ | ||
262 | int width; /* current frame width */ | 296 | int width; /* current frame width */ |
263 | int height; /* current frame height */ | 297 | int height; /* current frame height */ |
264 | int frame_size; /* current frame size */ | 298 | int frame_size; /* current frame size */ |
@@ -277,7 +311,6 @@ struct em28xx { | |||
277 | 311 | ||
278 | /* states */ | 312 | /* states */ |
279 | enum em28xx_dev_state state; | 313 | enum em28xx_dev_state state; |
280 | enum em28xx_stream_state stream; | ||
281 | enum em28xx_io_method io; | 314 | enum em28xx_io_method io; |
282 | 315 | ||
283 | struct work_struct request_module_wk; | 316 | struct work_struct request_module_wk; |
@@ -292,6 +325,11 @@ struct em28xx { | |||
292 | 325 | ||
293 | unsigned char eedata[256]; | 326 | unsigned char eedata[256]; |
294 | 327 | ||
328 | /* Isoc control struct */ | ||
329 | struct em28xx_dmaqueue vidq; | ||
330 | struct em28xx_usb_isoc_ctl isoc_ctl; | ||
331 | spinlock_t slock; | ||
332 | |||
295 | /* usb transfer */ | 333 | /* usb transfer */ |
296 | struct usb_device *udev; /* the usb device */ | 334 | struct usb_device *udev; /* the usb device */ |
297 | int alt; /* alternate */ | 335 | int alt; /* alternate */ |
@@ -315,6 +353,12 @@ struct em28xx_fh { | |||
315 | struct em28xx *dev; | 353 | struct em28xx *dev; |
316 | unsigned int stream_on:1; /* Locks streams */ | 354 | unsigned int stream_on:1; /* Locks streams */ |
317 | int radio; | 355 | int radio; |
356 | |||
357 | unsigned int width, height; | ||
358 | struct videobuf_queue vb_vidq; | ||
359 | struct em28xx_fmt *fmt; | ||
360 | |||
361 | enum v4l2_buf_type type; | ||
318 | }; | 362 | }; |
319 | 363 | ||
320 | struct em28xx_ops { | 364 | struct em28xx_ops { |
@@ -351,8 +395,6 @@ int em28xx_colorlevels_set_default(struct em28xx *dev); | |||
351 | int em28xx_capture_start(struct em28xx *dev, int start); | 395 | int em28xx_capture_start(struct em28xx *dev, int start); |
352 | int em28xx_outfmt_set_yuv422(struct em28xx *dev); | 396 | int em28xx_outfmt_set_yuv422(struct em28xx *dev); |
353 | int em28xx_resolution_set(struct em28xx *dev); | 397 | int em28xx_resolution_set(struct em28xx *dev); |
354 | int em28xx_init_isoc(struct em28xx *dev); | ||
355 | void em28xx_uninit_isoc(struct em28xx *dev); | ||
356 | int em28xx_set_alternate(struct em28xx *dev); | 398 | int em28xx_set_alternate(struct em28xx *dev); |
357 | 399 | ||
358 | /* Provided by em28xx-video.c */ | 400 | /* Provided by em28xx-video.c */ |