commit f4f16ed465bd95aee21e3d52b7e8488e77f181da
parent 2bb74d4c3a87beb16808fc1ca4833fc903e8f9f2
Author: alex <alex@022568fa-442e-4ef8-a3e8-54dcafdb011a>
Date: Tue, 15 Jan 2008 08:02:28 +0000
Use a helper function to get DMA information, instead of littering code
with #ifdefs.
git-svn-id: http://svn.mediati.org/svn/r5u870/trunk@31 022568fa-442e-4ef8-a3e8-54dcafdb011a
Diffstat:
M | usbcam.c | | | 29 | ++++++++++++----------------- |
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/usbcam.c b/usbcam.c
@@ -272,6 +272,15 @@ static void usbcam_capture_stop_nondestructive(struct usbcam_dev *udp)
usbcam_capture_stop(udp);
}
+static inline struct videobuf_dmabuf* usbframe_get_dmabuf(struct videobuf_buffer *buf)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+ return buf->dma;
+#else
+ return videobuf_to_dma(buf);
+#endif
+}
+
/*
* External APIs for minidriver access to the frame queue
@@ -287,11 +296,7 @@ int usbcam_curframe_get(struct usbcam_dev *udp, struct usbcam_curframe *cf)
if (!framep || !&framep->vbb)
return -ENOENT;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- dma = &framep->vbb.dma;
-#else
- dma = videobuf_to_dma(&framep->vbb);
-#endif
+ dma = usbframe_get_dmabuf(&framep->vbb);
cf->uc_base = (u8 *) (framep->vmap_sof
? framep->vmap_sof
@@ -642,12 +647,7 @@ static int usbcam_videobuf_setup(struct videobuf_queue *vq,
static void usbcam_videobuf_free(struct videobuf_queue *vq,
struct usbcam_frame *framep)
{
- struct videobuf_dmabuf *dma;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- dma = &framep->vbb.dma;
-#else
- dma = videobuf_to_dma(&framep->vbb);
-#endif
+ struct videobuf_dmabuf *dma = usbframe_get_dmabuf(&framep->vbb);
videobuf_waiton(&framep->vbb, 0, 0);
videobuf_dma_unmap(vq, dma);
@@ -671,14 +671,9 @@ static int usbcam_videobuf_prepare(struct videobuf_queue *vq,
struct usbcam_dev *udp = ufp->uf_dev;
struct usbcam_frame *framep =
container_of(vb, struct usbcam_frame, vbb);
+ struct videobuf_dmabuf *dma = usbframe_get_dmabuf(&framep->vbb);
int res;
- struct videobuf_dmabuf *dma;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- dma = &framep->vbb.dma;
-#else
- dma = videobuf_to_dma(&framep->vbb);
-#endif
framep->vbb.size = udp->ud_format.sizeimage;
if (framep->vbb.baddr && (framep->vbb.bsize < framep->vbb.size)) {