diff options
author | Matthieu Herrb <matthieu.herrb@laas.fr> | 2012-08-12 17:54:19 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu.herrb@laas.fr> | 2012-08-12 17:54:19 +0200 |
commit | 6910535d75d9a8197a414794c4595b069adc27bd (patch) | |
tree | c51fbe15f5cc87d4e76050db9a9d6e2bbc46dbbf /src/z4l.c | |
parent | 76cd88877be9f4663ce5d8620e01a2325b72a88d (diff) | |
parent | 0e64b1252c51e380f72f6ff0bdb6836a6e27071d (diff) |
Merge remote-tracking branch 'origin/master' into obsd
Conflicts:
src/geode_msr.c
Diffstat (limited to 'src/z4l.c')
-rw-r--r-- | src/z4l.c | 1258 |
1 files changed, 630 insertions, 628 deletions
@@ -47,6 +47,8 @@ #include "xf86xv.h" #include "fourcc.h" +#include "compat-api.h" + #define __s64 __s_64 typedef long long __s64; @@ -132,22 +134,19 @@ static XF86ImageRec pixfmts[] = { #define NUM_PIXFMTS (sizeof(pixfmts)/sizeof(pixfmts[0])) -typedef struct s_std_data -{ +typedef struct s_std_data { int inp; v4l2_std_id std; unsigned int fmt; } t_std_data; -typedef struct s_ovly_bfrs -{ +typedef struct s_ovly_bfrs { void *start; unsigned long offset; size_t length; } t_ovly_bfrs; -typedef struct -{ +typedef struct { int fd; int run; int dir; @@ -181,7 +180,7 @@ IoCtl(int fd, unsigned int fn, void *arg, int flag) errno = 0; ret = ioctl(fd, fn, arg); if (ret != 0 && flag != 0) - DBLOG(0, "ioctl(%08x)=%d\n", fn, ret); + DBLOG(0, "ioctl(%08x)=%d\n", fn, ret); return ret; } @@ -192,10 +191,10 @@ z4l_ovly_unmap(Z4lPortPrivRec * pPriv) nbfrs = pPriv->nbfrs; for (i = 0; i < nbfrs; ++i) { - if (pPriv->bfrs[i].start != NULL) { - munmap(pPriv->bfrs[i].start, pPriv->bfrs[i].length); - pPriv->bfrs[i].start = NULL; - } + if (pPriv->bfrs[i].start != NULL) { + munmap(pPriv->bfrs[i].start, pPriv->bfrs[i].length); + pPriv->bfrs[i].start = NULL; + } } pPriv->nbfrs = -1; pPriv->bufsz = -1; @@ -210,10 +209,10 @@ z4l_ovly_map(Z4lPortPrivRec * pPriv, int dir) struct v4l2_buffer bfr; struct v4l2_requestbuffers req; int type = dir >= 0 ? - V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VIDEO_OVERLAY; + V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VIDEO_OVERLAY; if (pPriv->run > 0) { - DBLOG(1, "busy\n"); - return; + DBLOG(1, "busy\n"); + return; } fd = pPriv->fd; memset(&req, 0, sizeof(req)); @@ -221,51 +220,51 @@ z4l_ovly_map(Z4lPortPrivRec * pPriv, int dir) req.memory = V4L2_MEMORY_MMAP; req.count = MAX_BUFFERS; if (ioctl(fd, VIDIOC_REQBUFS, &req) < 0) - goto xit; + goto xit; pPriv->nbfrs = req.count; if (pPriv->nbfrs <= 0) { - DBLOG(1, "no vidmem\n"); - return; + DBLOG(1, "no vidmem\n"); + return; } memset(&pPriv->bfrs, 0, sizeof(pPriv->bfrs)); for (i = 0; i < pPriv->nbfrs; ++i) { - memset(&bfr, 0, sizeof(bfr)); - bfr.type = type; - bfr.index = i; - if (ioctl(fd, VIDIOC_QUERYBUF, &bfr) < 0) - goto xit; - offset = bfr.m.offset; - pPriv->bfrs[i].offset = offset; - pPriv->bfrs[i].length = bfr.length; - bsz = offset + bfr.length; - if (pPriv->bufsz < bsz) - pPriv->bufsz = bsz; + memset(&bfr, 0, sizeof(bfr)); + bfr.type = type; + bfr.index = i; + if (ioctl(fd, VIDIOC_QUERYBUF, &bfr) < 0) + goto xit; + offset = bfr.m.offset; + pPriv->bfrs[i].offset = offset; + pPriv->bfrs[i].length = bfr.length; + bsz = offset + bfr.length; + if (pPriv->bufsz < bsz) + pPriv->bufsz = bsz; } for (i = 0; i < pPriv->nbfrs; ++i) { - pPriv->bfrs[i].start = mmap(NULL, bfr.length, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, pPriv->bfrs[i].offset); - if (pPriv->bfrs[i].start == MAP_FAILED) - goto xit; + pPriv->bfrs[i].start = mmap(NULL, bfr.length, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, pPriv->bfrs[i].offset); + if (pPriv->bfrs[i].start == MAP_FAILED) + goto xit; } for (i = 0; i < pPriv->nbfrs; ++i) { - DBLOG(3, "bfr %d ofs %#lx adr %p sz %lu\n", i, pPriv->bfrs[i].offset, - pPriv->bfrs[i].start, (unsigned long)pPriv->bfrs[i].length); - memset(pPriv->bfrs[i].start, 0x80, pPriv->bfrs[i].length); + DBLOG(3, "bfr %d ofs %#lx adr %p sz %lu\n", i, pPriv->bfrs[i].offset, + pPriv->bfrs[i].start, (unsigned long) pPriv->bfrs[i].length); + memset(pPriv->bfrs[i].start, 0x80, pPriv->bfrs[i].length); } pPriv->last = 0; while (pPriv->last < pPriv->nbfrs - 1) { - bfr.index = pPriv->last++; - bfr.type = type; - if (ioctl(fd, VIDIOC_QBUF, &bfr) < 0) - goto xit; + bfr.index = pPriv->last++; + bfr.type = type; + if (ioctl(fd, VIDIOC_QBUF, &bfr) < 0) + goto xit; } return; - xit: + xit: z4l_ovly_unmap(pPriv); } @@ -285,7 +284,7 @@ z4l_ovly_dqbuf(Z4lPortPrivRec * pPriv) tmo.tv_sec = 0; tmo.tv_usec = 0; if (select(fd + 1, &dqset, NULL, NULL, &tmo) <= 0) - return -1; + return -1; #endif memset(&bfr, 0, sizeof(bfr)); bfr.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; @@ -301,15 +300,15 @@ z4l_open_device(Z4lPortPrivRec * pPriv) int enable; if (pPriv->fd < 0) { - pPriv->fd = open(&pPriv->dev_path[0], O_RDWR, 0); - DBLOG(1, "open(%s)=%d\n", &pPriv->dev_path[0], pPriv->fd); - enable = 1; + pPriv->fd = open(&pPriv->dev_path[0], O_RDWR, 0); + DBLOG(1, "open(%s)=%d\n", &pPriv->dev_path[0], pPriv->fd); + enable = 1; #ifdef NONBLK_IO - if (IoCtl(pPriv->fd, FIONBIO, &enable, 1) != 0) { - DBLOG(1, "open cant enable nonblocking\n"); - close(pPriv->fd); - pPriv->fd = -1; - } + if (IoCtl(pPriv->fd, FIONBIO, &enable, 1) != 0) { + DBLOG(1, "open cant enable nonblocking\n"); + close(pPriv->fd); + pPriv->fd = -1; + } #endif } return pPriv->fd; @@ -321,13 +320,13 @@ z4l_close_device(Z4lPortPrivRec * pPriv) int ret = 0; if (pPriv->fd >= 0) { - ret = close(pPriv->fd); - pPriv->fd = -1; - DBLOG(1, "close()=%d\n", ret); + ret = close(pPriv->fd); + pPriv->fd = -1; + DBLOG(1, "close()=%d\n", ret); } if (pPriv->run > 0) { - z4l_ovly_unmap(pPriv); - pPriv->run = -1; + z4l_ovly_unmap(pPriv); + pPriv->run = -1; } return ret; @@ -339,8 +338,8 @@ z4l_ovly_reset(Z4lPortPrivRec * pPriv) int ret = 0; if (pPriv->run > 0) { - z4l_close_device(pPriv); - ret = z4l_open_device(pPriv); + z4l_close_device(pPriv); + ret = z4l_open_device(pPriv); } return ret; @@ -353,28 +352,29 @@ z4l_fourcc_pixfmt(int fourcc) switch (fourcc) { case FOURCC_UYVY: - pixfmt = V4L2_PIX_FMT_UYVY; - break; + pixfmt = V4L2_PIX_FMT_UYVY; + break; case FOURCC_YV12: - pixfmt = V4L2_PIX_FMT_YVU420; - break; + pixfmt = V4L2_PIX_FMT_YVU420; + break; case FOURCC_Y800: case FOURCC_I420: - pixfmt = V4L2_PIX_FMT_YUV420; - break; + pixfmt = V4L2_PIX_FMT_YUV420; + break; case FOURCC_YUY2: - pixfmt = V4L2_PIX_FMT_YUYV; - break; + pixfmt = V4L2_PIX_FMT_YUYV; + break; } return pixfmt; } + static void z4l_ovly_pixfmt(Z4lPortPrivRec * pPriv, unsigned int pixfmt) { struct v4l2_framebuffer fbuf; - DBLOG(1, "pixfmt %4.4s %4.4s\n", (char *)&pPriv->pixfmt, (char *)&pixfmt); + DBLOG(1, "pixfmt %4.4s %4.4s\n", (char *) &pPriv->pixfmt, (char *) &pixfmt); memset(&fbuf, 0, sizeof(fbuf)); IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1); fbuf.fmt.pixelformat = pixfmt; @@ -400,8 +400,8 @@ z4l_ovly_bfr(Z4lPortPrivRec * pPriv, int width, int height) static void z4l_ovly_rect(Z4lPortPrivRec * pPriv, - int src_x, int src_y, int src_w, int src_h, - int drw_x, int drw_y, int drw_w, int drw_h) + int src_x, int src_y, int src_w, int src_h, + int drw_x, int drw_y, int drw_w, int drw_h) { int x, dx, w, y, dy, h; struct v4l2_format fmt; @@ -416,66 +416,66 @@ z4l_ovly_rect(Z4lPortPrivRec * pPriv, pPriv->drw_h = drw_h; if ((drw_x -= z4l_x_offset) < 0) { - if ((w = pPriv->drw_w) <= 0) - w = 1; - x = -drw_x; - dx = x * pPriv->src_w / w; - src_x = pPriv->src_x + dx; - src_w = pPriv->src_w - dx; - drw_w = pPriv->drw_w - x; - drw_x = 0; + if ((w = pPriv->drw_w) <= 0) + w = 1; + x = -drw_x; + dx = x * pPriv->src_w / w; + src_x = pPriv->src_x + dx; + src_w = pPriv->src_w - dx; + drw_w = pPriv->drw_w - x; + drw_x = 0; } if ((drw_y -= z4l_y_offset) < 0) { - if ((h = pPriv->drw_h) <= 0) - h = 1; - y = -drw_y; - dy = y * pPriv->src_h / h; - src_y = pPriv->src_y + dy; - src_h = pPriv->src_h - dy; - drw_h = pPriv->drw_h - y; - drw_y = 0; + if ((h = pPriv->drw_h) <= 0) + h = 1; + y = -drw_y; + dy = y * pPriv->src_h / h; + src_y = pPriv->src_y + dy; + src_h = pPriv->src_h - dy; + drw_h = pPriv->drw_h - y; + drw_y = 0; } memset(&fmt, 0, sizeof(fmt)); fmt.type = 0x100; IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1); if (pPriv->src_is_set != 0) { - if (src_x != fmt.fmt.win.w.left || src_y != fmt.fmt.win.w.top || - src_w != fmt.fmt.win.w.width || src_h != fmt.fmt.win.w.height) - pPriv->src_is_set = 0; + if (src_x != fmt.fmt.win.w.left || src_y != fmt.fmt.win.w.top || + src_w != fmt.fmt.win.w.width || src_h != fmt.fmt.win.w.height) + pPriv->src_is_set = 0; } if (pPriv->src_is_set == 0) { - pPriv->src_is_set = 1; - fmt.fmt.win.w.left = src_x; - fmt.fmt.win.w.top = src_y; - fmt.fmt.win.w.width = src_w; - fmt.fmt.win.w.height = src_h; - IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1); - DBLOG(3, " set src %d,%d %dx%d\n", src_x, src_y, src_w, src_h); + pPriv->src_is_set = 1; + fmt.fmt.win.w.left = src_x; + fmt.fmt.win.w.top = src_y; + fmt.fmt.win.w.width = src_w; + fmt.fmt.win.w.height = src_h; + IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1); + DBLOG(3, " set src %d,%d %dx%d\n", src_x, src_y, src_w, src_h); } memset(&fmt, 0, sizeof(fmt)); fmt.type = 0x101; IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1); if (pPriv->drw_is_set != 0) { - if (drw_x != fmt.fmt.win.w.left || drw_y != fmt.fmt.win.w.top || - drw_w != fmt.fmt.win.w.width || drw_h != fmt.fmt.win.w.height) - pPriv->drw_is_set = 0; + if (drw_x != fmt.fmt.win.w.left || drw_y != fmt.fmt.win.w.top || + drw_w != fmt.fmt.win.w.width || drw_h != fmt.fmt.win.w.height) + pPriv->drw_is_set = 0; } if (pPriv->drw_is_set == 0) { - pPriv->drw_is_set = 1; - fmt.fmt.win.w.left = drw_x; - fmt.fmt.win.w.top = drw_y; - fmt.fmt.win.w.width = drw_w; - fmt.fmt.win.w.height = drw_h; - IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1); - DBLOG(3, " set drw %d,%d %dx%d\n", drw_x, drw_y, drw_w, drw_h); + pPriv->drw_is_set = 1; + fmt.fmt.win.w.left = drw_x; + fmt.fmt.win.w.top = drw_y; + fmt.fmt.win.w.width = drw_w; + fmt.fmt.win.w.height = drw_h; + IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1); + DBLOG(3, " set drw %d,%d %dx%d\n", drw_x, drw_y, drw_w, drw_h); } } static void z4l_ovly_pitch(unsigned int pixfmt, int w, int h, int *py_pitch, - int *puv_pitch, int *poffset1, int *poffset2, int *psize) + int *puv_pitch, int *poffset1, int *poffset2, int *psize) { int y_pitch, uv_pitch; int offset1, offset2; @@ -484,22 +484,22 @@ z4l_ovly_pitch(unsigned int pixfmt, int w, int h, int *py_pitch, switch (pixfmt) { case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_YUV420: - is_420 = 1; - y_pitch = ((w + 1) / 2) * 2; - uv_pitch = (w + 1) / 2; - break; + is_420 = 1; + y_pitch = ((w + 1) / 2) * 2; + uv_pitch = (w + 1) / 2; + break; default: - is_420 = 0; - y_pitch = ((w + 1) / 2) * 4; - uv_pitch = 0; - break; + is_420 = 0; + y_pitch = ((w + 1) / 2) * 4; + uv_pitch = 0; + break; } offset1 = y_pitch * h; offset2 = uv_pitch * h; if (is_420 != 0) - offset2 /= 2; + offset2 /= 2; size = offset1 + 2 * offset2; *py_pitch = y_pitch; @@ -517,10 +517,10 @@ z4l_ovly_set_colorkey(Z4lPortPrivRec * pPriv, int key) memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; if (IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1) < 0) - return 0; + return 0; fmt.fmt.win.chromakey = key; if (IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1) < 0) - return 0; + return 0; pPriv->colorkey = key; return 1; @@ -534,7 +534,7 @@ z4l_ovly_get_colorkey(Z4lPortPrivRec * pPriv, int *key) memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; if (IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1) < 0) - return 0; + return 0; *key = fmt.fmt.win.chromakey; return 1; @@ -547,16 +547,16 @@ z4l_ovly_set_keymode(Z4lPortPrivRec * pPriv, int enable) memset(&fbuf, 0, sizeof(fbuf)); if (IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1) < 0) - return 0; + return 0; if (enable != 0) - fbuf.flags |= V4L2_FBUF_FLAG_CHROMAKEY; + fbuf.flags |= V4L2_FBUF_FLAG_CHROMAKEY; else - fbuf.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY; + fbuf.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY; fbuf.base = NULL; if (IoCtl(pPriv->fd, VIDIOC_S_FBUF, &fbuf, 1) < 0) - return 0; + return 0; pPriv->keymode = enable; return 1; @@ -569,7 +569,7 @@ z4l_ovly_get_keymode(Z4lPortPrivRec * pPriv, int *enable) memset(&fbuf, 0, sizeof(fbuf)); if (IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1) < 0) - return 0; + return 0; *enable = (fbuf.flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0 ? 1 : 0; return 1; @@ -590,7 +590,7 @@ z4l_ovly_set_encoding(Z4lPortPrivRec * pPriv, int id) adpt = pPriv->adpt; DBLOG(1, "z4l_ovly_set_encoding(%d)\n", id); if (id < 0 || id >= adpt->nEncodings) - return 0; + return 0; enc = &adpt->pEncodings[id]; cp = &enc->name[0]; n = sizeof(int) - 1; @@ -600,32 +600,32 @@ z4l_ovly_set_encoding(Z4lPortPrivRec * pPriv, int id) inp = sp->inp; DBLOG(1, " nm %s fmt %4.4s inp %d std %llx\n", - cp, (char *)&sp->fmt, sp->inp, sp->std); + cp, (char *) &sp->fmt, sp->inp, sp->std); if (IoCtl(pPriv->fd, VIDIOC_S_INPUT, &inp, 1) < 0) - return 0; + return 0; std = sp->std; if (IoCtl(pPriv->fd, VIDIOC_S_STD, &std, 1) < 0) - return 0; + return 0; memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1) < 0) - return 0; + return 0; fmt.fmt.pix.pixelformat = sp->fmt; if (IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1) < 0) - return 0; + return 0; memset(&fbuf, 0, sizeof(fbuf)); if (IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1) < 0) - return 0; + return 0; fbuf.fmt.pixelformat = sp->fmt; fbuf.base = NULL; if (IoCtl(pPriv->fd, VIDIOC_S_FBUF, &fbuf, 1) < 0) - return 0; + return 0; pPriv->pixfmt = sp->fmt; pPriv->enc = enc; pPriv->src_is_set = pPriv->drw_is_set = 0; @@ -648,21 +648,21 @@ z4l_ovly_stop(Z4lPortPrivRec * pPriv) int type, enable, fd; if (pPriv->run < 0) - return; + return; fd = pPriv->fd; if (pPriv->dir > 0) { - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - ioctl(fd, VIDIOC_STREAMOFF, &type); + type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + ioctl(fd, VIDIOC_STREAMOFF, &type); } if (pPriv->dir <= 0) { - enable = 0; - ioctl(fd, VIDIOC_OVERLAY, &enable); + enable = 0; + ioctl(fd, VIDIOC_OVERLAY, &enable); } if (pPriv->dir != 0) - z4l_ovly_unmap(pPriv); + z4l_ovly_unmap(pPriv); pPriv->run = -1; z4l_close_device(pPriv); @@ -674,16 +674,16 @@ z4l_ovly_start(Z4lPortPrivRec * pPriv, int dir) int enable; if (pPriv->run >= 0) - return; + return; if ((pPriv->dir = dir) != 0) - z4l_ovly_map(pPriv, dir); + z4l_ovly_map(pPriv, dir); enable = 1; if (IoCtl(pPriv->fd, VIDIOC_OVERLAY, &enable, 1) != 0) { - z4l_ovly_stop(pPriv); - return; + z4l_ovly_stop(pPriv); + return; } pPriv->run = 1; @@ -696,39 +696,37 @@ z4l_region_equal(RegionPtr ap, RegionPtr bp) BoxPtr abox, bbox; if (ap == NULL && bp == NULL) - return 1; + return 1; if (ap == NULL || bp == NULL) - return 0; + return 0; if ((nboxes = REGION_NUM_RECTS(ap)) != REGION_NUM_RECTS(bp) || - ap->extents.x1 != bp->extents.x1 || - ap->extents.x2 != bp->extents.x2 - || ap->extents.y1 != bp->extents.y1 - || ap->extents.y2 != bp->extents.y2) - return 0; + ap->extents.x1 != bp->extents.x1 || + ap->extents.x2 != bp->extents.x2 + || ap->extents.y1 != bp->extents.y1 || ap->extents.y2 != bp->extents.y2) + return 0; abox = REGION_RECTS(ap); bbox = REGION_RECTS(bp); while (--nboxes >= 0) { - if (abox->x1 != bbox->x1 || abox->y1 != bbox->y1 || - abox->x2 != bbox->x2 || abox->y2 != bbox->y2) - return 0; - ++abox; - ++bbox; + if (abox->x1 != bbox->x1 || abox->y1 != bbox->y1 || + abox->x2 != bbox->x2 || abox->y2 != bbox->y2) + return 0; + ++abox; + ++bbox; } return 1; } static void -z4l_setup_colorkey(Z4lPortPrivRec * pPriv, ScreenPtr pScrn, - RegionPtr clipBoxes) +z4l_setup_colorkey(Z4lPortPrivRec * pPriv, ScreenPtr pScrn, RegionPtr clipBoxes) { if (pPriv->run > 0 && pPriv->dir <= 0 && pPriv->keymode != 0 && - z4l_region_equal(&pPriv->clips, clipBoxes) == 0) { - xf86XVFillKeyHelper(pScrn, pPriv->colorkey, clipBoxes); - REGION_COPY(pScrn, &pPriv->clips, clipBoxes); + z4l_region_equal(&pPriv->clips, clipBoxes) == 0) { + xf86XVFillKeyHelper(pScrn, pPriv->colorkey, clipBoxes); + REGION_COPY(pScrn, &pPriv->clips, clipBoxes); } } @@ -740,34 +738,34 @@ Z4lStopVideo(ScrnInfoPtr pScrni, pointer data, Bool exit) DBLOG(1, "Z4lStopVideo()\n"); if (exit != 0) - z4l_ovly_stop(pPriv); + z4l_ovly_stop(pPriv); else - pPriv->src_is_set = pPriv->drw_is_set = 0; + pPriv->src_is_set = pPriv->drw_is_set = 0; REGION_EMPTY(pScrni->pScreen, &pPriv->clips); } static void Z4lQueryBestSize(ScrnInfoPtr pScrni, Bool motion, - short vid_w, short vid_h, short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, pointer data) + short vid_w, short vid_h, short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, pointer data) { if (drw_w > MAX_OVLY_WIDTH) - drw_w = MAX_OVLY_WIDTH; + drw_w = MAX_OVLY_WIDTH; if (drw_h > MAX_OVLY_HEIGHT) - drw_h = MAX_OVLY_HEIGHT; + drw_h = MAX_OVLY_HEIGHT; *p_w = drw_w; *p_h = drw_h; DBLOG(1, "Z4lQueryBestSize(%d, src %dx%d dst %dx%d)\n", motion, vid_w, - vid_h, drw_w, drw_h); + vid_h, drw_w, drw_h); } static int Z4lPutImage(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x, - short drw_y, short src_w, short src_h, short drw_w, short drw_h, - int id, unsigned char *buf, short width, short height, - Bool sync, RegionPtr clipBoxes, pointer data, DrawablePtr pDraw) + short drw_y, short src_w, short src_h, short drw_w, short drw_h, + int id, unsigned char *buf, short width, short height, + Bool sync, RegionPtr clipBoxes, pointer data, DrawablePtr pDraw) { int fd, size; int y_pitch, uv_pitch, offset1, offset2; @@ -777,63 +775,64 @@ Z4lPutImage(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x, Z4lPortPrivRec *pPriv = (Z4lPortPrivRec *) data; if (pPriv->run > 0 && pPriv->dir >= 0) - return BadMatch; + return BadMatch; if (pPriv->fd < 0) { - z4l_open_device(pPriv); - if (pPriv->fd < 0) - return BadValue; + z4l_open_device(pPriv); + if (pPriv->fd < 0) + return BadValue; } fd = pPriv->fd; if (pPriv->run < 0) { - DBLOG(2, "PutImg id %#x src %d,%d %dx%d drw %d,%d %dx%d bfr %p " - "%dx%d data %p\n", id, src_x, src_y, src_w, src_h, drw_x, - drw_y, drw_w, drw_h, buf, width, height, data); - pPriv->pixfmt = pPriv->height = -1; - pPriv->src_is_set = pPriv->drw_is_set = 0; + DBLOG(2, "PutImg id %#x src %d,%d %dx%d drw %d,%d %dx%d bfr %p " + "%dx%d data %p\n", id, src_x, src_y, src_w, src_h, drw_x, + drw_y, drw_w, drw_h, buf, width, height, data); + pPriv->pixfmt = pPriv->height = -1; + pPriv->src_is_set = pPriv->drw_is_set = 0; } pixfmt = z4l_fourcc_pixfmt(id); if (pixfmt != pPriv->pixfmt) { - z4l_ovly_reset(pPriv); - z4l_ovly_pixfmt(pPriv, pixfmt); + z4l_ovly_reset(pPriv); + z4l_ovly_pixfmt(pPriv, pixfmt); } if (pPriv->width != width || pPriv->height != height) { - z4l_ovly_reset(pPriv); - z4l_ovly_bfr(pPriv, width, height); + z4l_ovly_reset(pPriv); + z4l_ovly_bfr(pPriv, width, height); } if (pPriv->src_is_set == 0 || pPriv->drw_is_set == 0 || - pPriv->src_x != src_x || pPriv->src_y != src_y || - pPriv->src_w != src_w || pPriv->src_h != src_h || - pPriv->drw_x != drw_x || pPriv->drw_y != drw_y || - pPriv->drw_w != drw_w || pPriv->drw_h != drw_h) - z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, - drw_h); + pPriv->src_x != src_x || pPriv->src_y != src_y || + pPriv->src_w != src_w || pPriv->src_h != src_h || + pPriv->drw_x != drw_x || pPriv->drw_y != drw_y || + pPriv->drw_w != drw_w || pPriv->drw_h != drw_h) + z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, + drw_h); if (pPriv->run < 0) { - z4l_ovly_start(pPriv, -1); - if (pPriv->run < 0) - return BadValue; + z4l_ovly_start(pPriv, -1); + if (pPriv->run < 0) + return BadValue; } if (pPriv->last < 0 && (pPriv->last = z4l_ovly_dqbuf(pPriv)) < 0) - return BadAlloc; + return BadAlloc; z4l_ovly_pitch(pixfmt, width, height, &y_pitch, &uv_pitch, - &offset1, &offset2, &size); + &offset1, &offset2, &size); src = buf; - dst = (unsigned char *)pPriv->bfrs[pPriv->last].start; + dst = (unsigned char *) pPriv->bfrs[pPriv->last].start; DBLOG(3, "cpy %4.4s src %p dst %p yp %d uvp %d o1 %d o2 %d sz %d\n", - (char *)&id, src, dst, y_pitch, uv_pitch, offset1, offset2, size); + (char *) &id, src, dst, y_pitch, uv_pitch, offset1, offset2, size); if (id == FOURCC_Y800) { - memcpy(dst, src, offset1); - src += offset1; - dst += offset1; - memset(dst, 0x80, 2 * offset2); - } else - memcpy(dst, src, size); + memcpy(dst, src, offset1); + src += offset1; + dst += offset1; + memset(dst, 0x80, 2 * offset2); + } + else + memcpy(dst, src, size); memset(&bfr, 0, sizeof(bfr)); bfr.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; @@ -842,7 +841,7 @@ Z4lPutImage(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x, bfr.timestamp.tv_usec = 0; bfr.flags |= V4L2_BUF_FLAG_TIMECODE; if (IoCtl(fd, VIDIOC_QBUF, &bfr, 1) != 0) - return BadAccess; + return BadAccess; pPriv->last = z4l_ovly_dqbuf(pPriv); z4l_setup_colorkey(pPriv, pScrni->pScreen, clipBoxes); @@ -852,7 +851,7 @@ Z4lPutImage(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x, static int Z4lQueryImageAttributes(ScrnInfoPtr pScrni, int id, unsigned short *width, - unsigned short *height, int *pitches, int *offsets) + unsigned short *height, int *pitches, int *offsets) { int w, h, size; int y_pitch, uv_pitch, offset1, offset2; @@ -861,70 +860,70 @@ Z4lQueryImageAttributes(ScrnInfoPtr pScrni, int id, unsigned short *width, w = *width; h = *height; if (w > MAX_OVLY_WIDTH) - w = MAX_OVLY_WIDTH; + w = MAX_OVLY_WIDTH; if (h > MAX_OVLY_HEIGHT) - h = MAX_OVLY_HEIGHT; + h = MAX_OVLY_HEIGHT; z4l_ovly_pitch(pixfmt, w, h, &y_pitch, &uv_pitch, - &offset1, &offset2, &size); + &offset1, &offset2, &size); if (offsets != NULL) - offsets[0] = 0; + offsets[0] = 0; if (pitches != NULL) - pitches[0] = y_pitch; + pitches[0] = y_pitch; switch (pixfmt) { case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_YUV420: - if (offsets != NULL) { - offsets[1] = offset1; - offsets[2] = offset1 + offset2; - } - if (pitches != NULL) - pitches[1] = pitches[2] = uv_pitch; - h = (h + 1) & ~1; - break; + if (offsets != NULL) { + offsets[1] = offset1; + offsets[2] = offset1 + offset2; + } + if (pitches != NULL) + pitches[1] = pitches[2] = uv_pitch; + h = (h + 1) & ~1; + break; } w = (w + 1) & ~1; *width = w; *height = h; DBLOG(1, "Z4lQueryImageAttributes(%4.4s) = %d, %dx%d %d/%d %d/%d\n", - (char *)&id, size, w, h, y_pitch, uv_pitch, offset1, offset2); + (char *) &id, size, w, h, y_pitch, uv_pitch, offset1, offset2); return size; } static int Z4lPutVideo(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x, - short drw_y, short src_w, short src_h, short drw_w, short drw_h, - RegionPtr clipBoxes, pointer data, DrawablePtr pDraw) + short drw_y, short src_w, short src_h, short drw_w, short drw_h, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw) { int id; Z4lPortPrivRec *pPriv = (Z4lPortPrivRec *) data; DBLOG(2, "PutVid src %d,%d %dx%d drw %d,%d %dx%d data %p\n", - src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, data); + src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, data); if (z4l_open_device(pPriv) >= 0) { - if (pPriv->run < 0) { - DBLOG(2, "PutVid start\n"); - z4l_ovly_get_encoding(pPriv, &id); - z4l_ovly_set_encoding(pPriv, id); - } - DBLOG(2, "PutVid priv %d,%d %dx%d drw %d,%d %dx%d\n", - pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h, - pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h); - if (pPriv->src_is_set == 0 || pPriv->drw_is_set == 0 || - pPriv->src_w != src_w || pPriv->src_h != src_h || - pPriv->drw_x != drw_x || pPriv->drw_y != drw_y || - pPriv->drw_w != drw_w || pPriv->drw_h != drw_h) - z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y, - drw_w, drw_h); - if (pPriv->run < 0) - z4l_ovly_start(pPriv, 0); - - z4l_setup_colorkey(pPriv, pScrni->pScreen, clipBoxes); + if (pPriv->run < 0) { + DBLOG(2, "PutVid start\n"); + z4l_ovly_get_encoding(pPriv, &id); + z4l_ovly_set_encoding(pPriv, id); + } + DBLOG(2, "PutVid priv %d,%d %dx%d drw %d,%d %dx%d\n", + pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h, + pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h); + if (pPriv->src_is_set == 0 || pPriv->drw_is_set == 0 || + pPriv->src_w != src_w || pPriv->src_h != src_h || + pPriv->drw_x != drw_x || pPriv->drw_y != drw_y || + pPriv->drw_w != drw_w || pPriv->drw_h != drw_h) + z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y, + drw_w, drw_h); + if (pPriv->run < 0) + z4l_ovly_start(pPriv, 0); + + z4l_setup_colorkey(pPriv, pScrni->pScreen, clipBoxes); } return Success; @@ -935,10 +934,10 @@ Z4lNewEncoding(XF86VideoEncodingPtr * encs, int *nencs) { XF86VideoEncodingPtr enc; XF86VideoEncodingPtr tencs = - (XF86VideoEncodingPtr) realloc(*encs, sizeof(*tencs) * (*nencs + 1)); + (XF86VideoEncodingPtr) realloc(*encs, sizeof(*tencs) * (*nencs + 1)); if (tencs == NULL) - return NULL; + return NULL; *encs = tencs; enc = &tencs[*nencs]; @@ -954,60 +953,61 @@ Z4lEncodingName(char *ename, int l, char *inp_name, char *std_name, char *fmt) int i, ch; while ((ch = *inp_name++) != 0) { - if (isalnum(ch) == 0) - continue; - if (--l <= 0) - goto xit; - *ename++ = ch; + if (isalnum(ch) == 0) + continue; + if (--l <= 0) + goto xit; + *ename++ = ch; } if (--l <= 0) - goto xit; + goto xit; *ename++ = '-'; while ((ch = *std_name++) != 0) { - if (isalnum(ch) == 0) - continue; - if (--l <= 0) - goto xit; - *ename++ = ch; + if (isalnum(ch) == 0) + continue; + if (--l <= 0) + goto xit; + *ename++ = ch; } if (--l <= 0) - goto xit; + goto xit; *ename++ = '-'; i = 4; while (--i >= 0 && (ch = *fmt++) != 0) { - if (isalnum(ch) == 0) - continue; - if (--l <= 0) - goto xit; - *ename++ = ch; + if (isalnum(ch) == 0) + continue; + if (--l <= 0) + goto xit; + *ename++ = ch; } - xit: + xit: *ename = 0; } static int Z4lAddEncoding(XF86VideoEncodingPtr enc, char *name, int id, int width, - int height, int numer, int denom, int inp, v4l2_std_id std, - unsigned int fmt) + int height, int numer, int denom, int inp, v4l2_std_id std, + unsigned int fmt) { int l, n; t_std_data *sp; char *cp; + n = sizeof(int) - 1; l = strlen(&name[0]) + 1; l = (l + n) & ~n; n = l + sizeof(*sp); - cp = (char *)malloc(n); + cp = (char *) malloc(n); if (cp == NULL) - return 0; + return 0; sp = (t_std_data *) (cp + l); enc->id = id; @@ -1030,10 +1030,10 @@ Z4lNewImage(XF86ImagePtr * imgs, int *nimgs) { XF86ImagePtr img; XF86ImagePtr timgs = - (XF86ImagePtr) realloc(*imgs, sizeof(*timgs) * (*nimgs + 1)); + (XF86ImagePtr) realloc(*imgs, sizeof(*timgs) * (*nimgs + 1)); if (timgs == NULL) - return NULL; + return NULL; *imgs = timgs; img = &timgs[*nimgs]; @@ -1047,7 +1047,7 @@ static int Z4lAddImage(XF86ImagePtr img, XF86ImagePtr ip) { *img = *ip; - DBLOG(1, "img %4.4s\n", (char *)&img->id); + DBLOG(1, "img %4.4s\n", (char *) &img->id); return 1; } @@ -1056,10 +1056,10 @@ Z4lNewAttribute(XF86AttributePtr * attrs, int *nattrs) { XF86AttributePtr attr; XF86AttributePtr tattrs = - (XF86AttributePtr) realloc(*attrs, sizeof(*tattrs) * (*nattrs + 1)); + (XF86AttributePtr) realloc(*attrs, sizeof(*tattrs) * (*nattrs + 1)); if (tattrs == NULL) - return NULL; + return NULL; *attrs = tattrs; attr = &tattrs[*nattrs]; @@ -1076,22 +1076,22 @@ Z4lAttributeName(char *bp, int l, char *cp) char *atomNm = bp; if (l > 0) { - *bp++ = 'X'; - --l; + *bp++ = 'X'; + --l; } if (l > 0) { - *bp++ = 'V'; - --l; + *bp++ = 'V'; + --l; } if (l > 0) { - *bp++ = '_'; - --l; + *bp++ = '_'; + --l; } while (l > 0 && (ch = *cp++) != 0) { - if (isalnum(ch) == 0) - continue; - *bp++ = toupper(ch); + if (isalnum(ch) == 0) + continue; + *bp++ = toupper(ch); } *bp = 0; @@ -1099,13 +1099,12 @@ Z4lAttributeName(char *bp, int l, char *cp) } static int -Z4lAddAttribute(XF86AttributePtr attr, char *name, - int min, int max, int flags) +Z4lAddAttribute(XF86AttributePtr attr, char *name, int min, int max, int flags) { - char *cp = (char *)malloc(strlen((char *)&name[0]) + 1); + char *cp = (char *) malloc(strlen((char *) &name[0]) + 1); if (cp == NULL) - return 0; + return 0; attr->name = cp; strcpy(&attr->name[0], name); @@ -1125,10 +1124,10 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs) XF86VideoAdaptorPtr adpt, *tadpts; tadpts = (XF86VideoAdaptorPtr *) realloc(*adpts, - sizeof(*tadpts) * (*nadpts + 1)); + sizeof(*tadpts) * (*nadpts + 1)); if (tadpts == NULL) - return NULL; + return NULL; *adpts = tadpts; n = sizeof(*adpt) + sizeof(*pPriv) + 1 * sizeof(*adpt->pPortPrivates); @@ -1136,12 +1135,12 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs) adpt = (XF86VideoAdaptorPtr) malloc(n); if (adpt == NULL) - return NULL; + return NULL; memset(adpt, 0, n); tadpts[*nadpts] = adpt; ++*nadpts; - adpt->pPortPrivates = (DevUnion *) & adpt[1]; + adpt->pPortPrivates = (DevUnion *) &adpt[1]; pPriv = (Z4lPortPrivRec *) & adpt->pPortPrivates[1]; adpt->pPortPrivates[0].ptr = (pointer) pPriv; pPriv->adpt = adpt; @@ -1152,7 +1151,7 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs) static int Z4lSetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 value, - pointer data) + pointer data) { Z4lPortPrivRec *pPriv = (Z4lPortPrivRec *) data; XF86VideoAdaptorPtr adpt; @@ -1162,58 +1161,58 @@ Z4lSetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 value, const char *name = NameForAtom(attribute); int old_fd = pPriv->fd; - DBLOG(1, "Z4lSetPortAttribute(%#lx,%d) '%s'\n", (unsigned long)attribute, - (int)value, name != NULL ? name : "_null_"); + DBLOG(1, "Z4lSetPortAttribute(%#lx,%d) '%s'\n", (unsigned long) attribute, + (int) value, name != NULL ? name : "_null_"); if (name == NULL) - return BadImplementation; + return BadImplementation; if (old_fd < 0 && z4l_open_device(pPriv) < 0) - return BadAccess; + return BadAccess; adpt = pPriv->adpt; attr = adpt->pAttributes; nattrs = adpt->nAttributes; for (i = 0; i < nattrs; ++i, ++attr) - if (strcmp(attr->name, name) == 0) - break; + if (strcmp(attr->name, name) == 0) + break; if (i >= nattrs) - return BadMatch; + return BadMatch; attrId = pPriv->attrIds[i]; val = value; switch (attrId) { case ATTR_ENCODING_ID: - z4l_ovly_set_encoding(pPriv, val); - break; + z4l_ovly_set_encoding(pPriv, val); + break; case ATTR_KEYMODE_ID: - z4l_ovly_set_keymode(pPriv, val); - REGION_EMPTY(pScrni->pScreen, &pPriv->clips); - z4l_setup_colorkey(pPriv, pScrni->pScreen, &pPriv->clips); - break; + z4l_ovly_set_keymode(pPriv, val); + REGION_EMPTY(pScrni->pScreen, &pPriv->clips); + z4l_setup_colorkey(pPriv, pScrni->pScreen, &pPriv->clips); + break; case ATTR_COLORKEY_ID: - z4l_ovly_set_colorkey(pPriv, val); - break; + z4l_ovly_set_colorkey(pPriv, val); + break; default: - memset(&ctrl, 0, sizeof(ctrl)); - ctrl.id = attrId + V4L2_CID_BASE; - ctrl.value = val; - if (IoCtl(pPriv->fd, VIDIOC_S_CTRL, &ctrl, 1) != 0) - return BadMatch; - break; + memset(&ctrl, 0, sizeof(ctrl)); + ctrl.id = attrId + V4L2_CID_BASE; + ctrl.value = val; + if (IoCtl(pPriv->fd, VIDIOC_S_CTRL, &ctrl, 1) != 0) + return BadMatch; + break; } if (old_fd < 0) - z4l_close_device(pPriv); + z4l_close_device(pPriv); return Success; } static int -Z4lGetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 * value, - pointer data) +Z4lGetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 *value, + pointer data) { Z4lPortPrivRec *pPriv = (Z4lPortPrivRec *) data; XF86VideoAdaptorPtr adpt; @@ -1224,80 +1223,82 @@ Z4lGetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 * value, int old_fd = pPriv->fd; DBLOG(1, "Z4lGetPortAttribute(%#lx) '%s'\n", - (unsigned long)attribute, name != NULL ? name : "_null_"); + (unsigned long) attribute, name != NULL ? name : "_null_"); if (name == NULL) - return BadImplementation; + return BadImplementation; if (old_fd < 0 && z4l_open_device(pPriv) < 0) - return BadAccess; + return BadAccess; adpt = pPriv->adpt; attr = adpt->pAttributes; nattrs = adpt->nAttributes; for (i = 0; i < nattrs; ++i, ++attr) - if (strcmp(attr->name, name) == 0) - break; + if (strcmp(attr->name, name) == 0) + break; if (i >= nattrs) - return BadMatch; + return BadMatch; attrId = pPriv->attrIds[i]; val = 0; switch (attrId) { case ATTR_ENCODING_ID: - z4l_ovly_get_encoding(pPriv, &val); - *value = val; - break; + z4l_ovly_get_encoding(pPriv, &val); + *value = val; + break; case ATTR_KEYMODE_ID: - z4l_ovly_get_keymode(pPriv, &val); - *value = val; - break; + z4l_ovly_get_keymode(pPriv, &val); + *value = val; + break; case ATTR_COLORKEY_ID: - z4l_ovly_get_colorkey(pPriv, &val); - break; + z4l_ovly_get_colorkey(pPriv, &val); + break; default: - memset(&ctrl, 0, sizeof(ctrl)); - ctrl.id = attrId + V4L2_CID_BASE; - if (IoCtl(pPriv->fd, VIDIOC_G_CTRL, &ctrl, 1) != 0) - return BadMatch; - val = ctrl.value; - break; + memset(&ctrl, 0, sizeof(ctrl)); + ctrl.id = attrId + V4L2_CID_BASE; + if (IoCtl(pPriv->fd, VIDIOC_G_CTRL, &ctrl, 1) != 0) + return BadMatch; + val = ctrl.value; + break; } if (old_fd < 0) - z4l_close_device(pPriv); + z4l_close_device(pPriv); *value = val; return Success; } -static void (*oldAdjustFrame) (int scrnIndex, int x, int y, int flags) = NULL; +static void (*oldAdjustFrame) (ADJUST_FRAME_ARGS_DECL) = NULL; static void -Z4lAdjustFrame(int scrnIndex, int x, int y, int flags) +Z4lAdjustFrame(ADJUST_FRAME_ARGS_DECL) { + SCRN_INFO_PTR(arg); int i; XF86VideoAdaptorPtr adpt; Z4lPortPrivRec *pPriv; - DBLOG(3, "Z4lAdjustFrame(%d,%d,%d)\n", x, y, flags); + DBLOG(3, "Z4lAdjustFrame(%d,%d)\n", x, y); z4l_x_offset = x; z4l_y_offset = y; - oldAdjustFrame(scrnIndex, x, y, flags); + oldAdjustFrame(ADJUST_FRAME_ARGS(x, y)); /* xv adjust does not handle putvideo case */ for (i = 0; i < Z4l_nAdaptors; ++i) { - adpt = Z4l_pAdaptors[i]; - pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr; - if (pPriv->run > 0) { - pPriv->drw_is_set = 0; - z4l_ovly_rect(pPriv, - pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h, - pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h); - } + adpt = Z4l_pAdaptors[i]; + pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr; + if (pPriv->run > 0) { + pPriv->drw_is_set = 0; + z4l_ovly_rect(pPriv, + pPriv->src_x, pPriv->src_y, pPriv->src_w, + pPriv->src_h, pPriv->drw_x, pPriv->drw_y, + pPriv->drw_w, pPriv->drw_h); + } } } @@ -1328,8 +1329,8 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors) DBLOG(1, "Init\n"); if (oldAdjustFrame == NULL) { - oldAdjustFrame = pScrni->AdjustFrame; - pScrni->AdjustFrame = Z4lAdjustFrame; + oldAdjustFrame = pScrni->AdjustFrame; + pScrni->AdjustFrame = Z4lAdjustFrame; } fd = -1; @@ -1348,254 +1349,255 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors) has_video = has_image = has_colorkey = 0; for (dev = 0; z4l_dev_paths[dev] != NULL; ++dev) { - fd = open(z4l_dev_paths[dev], O_RDWR, 0); - if (fd < 0) - continue; - DBLOG(1, "%s open ok\n", z4l_dev_paths[dev]); - msg = NULL; - enable = 1; - if (IoCtl(fd, VIDIOC_QUERYCAP, &capability, 1) < 0) - msg = "bad querycap"; - else if ((capability.capabilities & V4L2_CAP_VIDEO_OVERLAY) == 0) - msg = "no overlay"; - else if ((capability.capabilities & V4L2_CAP_STREAMING) == 0) - msg = "no streaming"; + fd = open(z4l_dev_paths[dev], O_RDWR, 0); + if (fd < 0) + continue; + DBLOG(1, "%s open ok\n", z4l_dev_paths[dev]); + msg = NULL; + enable = 1; + if (IoCtl(fd, VIDIOC_QUERYCAP, &capability, 1) < 0) + msg = "bad querycap"; + else if ((capability.capabilities & V4L2_CAP_VIDEO_OVERLAY) == 0) + msg = "no overlay"; + else if ((capability.capabilities & V4L2_CAP_STREAMING) == 0) + msg = "no streaming"; #ifdef NONBLK_IO - else if (IoCtl(fd, FIONBIO, &enable, 1) != 0) - msg = "cant enable non-blocking io"; + else if (IoCtl(fd, FIONBIO, &enable, 1) != 0) + msg = "cant enable non-blocking io"; #endif - if (msg == NULL) { - memset(&format, 0, sizeof(format)); - format.type = 0x100; - if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) != 0) - msg = "no src/dst ovly fmt"; - } - if (msg != NULL) { - DBLOG(0, "%s %s\n", z4l_dev_paths[dev], msg); - close(fd); - continue; - } - - memset(&cfmt, 0, sizeof(cfmt)); - cfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (IoCtl(fd, VIDIOC_G_FMT, &cfmt, 1) < 0) - goto fail; - if (IoCtl(fd, VIDIOC_G_STD, &cstd_id, 1) < 0) - goto fail; - if (IoCtl(fd, VIDIOC_G_INPUT, &cinp, 1) < 0) - goto fail; - cpixfmt = cfmt.fmt.pix.pixelformat; - cenc = 0; - for (inp = 0;; ++inp) { - memset(&input, 0, sizeof(input)); - input.index = inp; - if (IoCtl(fd, VIDIOC_ENUMINPUT, &input, 0) < 0) - break; - id = inp; - if (IoCtl(fd, VIDIOC_S_INPUT, &id, 1) < 0) - goto fail; - for (std = 0;; ++std) { - memset(&standard, 0, sizeof(standard)); - standard.index = std; - if (IoCtl(fd, VIDIOC_ENUMSTD, &standard, 0) < 0) - break; - std_id = standard.id; - denom = standard.frameperiod.denominator; - numer = standard.frameperiod.numerator; - if (IoCtl(fd, VIDIOC_S_STD, &std_id, 1) < 0) - continue; - memset(&format, 0, sizeof(format)); - format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) < 0) - continue; - width = format.fmt.pix.width; - height = format.fmt.pix.height; - for (fmt = 0;; ++fmt) { - memset(&fmtdesc, 0, sizeof(fmtdesc)); - fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - fmtdesc.index = fmt; - if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0) - break; - pixfmt = fmtdesc.pixelformat; - ip = &pixfmts[0]; - for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0; - ++ip) - if (z4l_fourcc_pixfmt(ip->id) == pixfmt) - break; - - if (i >= 0) { - id = nencs; - has_video = 1; - if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL) - goto fail; - Z4lEncodingName(&enc_name[0], sizeof(enc_name), - (char *)&input.name[0], - (char *)&standard.name[0], (char *)&pixfmt); - if (Z4lAddEncoding(enc, &enc_name[0], id, width, - height, denom, numer, inp, std_id, - pixfmt) == 0) - goto fail; - if (std_id == cstd_id && inp == cinp - && pixfmt == cpixfmt) - cenc = id; - } - } - } - } - - if (IoCtl(fd, VIDIOC_S_INPUT, &cinp, 1) < 0) - goto fail; - if (IoCtl(fd, VIDIOC_S_STD, &cstd_id, 1) < 0) - goto fail; - if (IoCtl(fd, VIDIOC_S_FMT, &cfmt, 1) < 0) - goto fail; - - if (encs == NULL) { - DBLOG(0, "no encodings\n"); - goto fail; - } - - for (fmt = 0;; ++fmt) { - memset(&fmtdesc, 0, sizeof(fmtdesc)); - fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - fmtdesc.index = fmt; - if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0) - break; - pixfmt = fmtdesc.pixelformat; - ip = &pixfmts[0]; - for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0; ++ip) - if (z4l_fourcc_pixfmt(ip->id) == pixfmt) - break; - - if (i >= 0) { - has_image = 1; - if ((img = Z4lNewImage(&imgs, &nimgs)) == NULL) - goto fail; - if (Z4lAddImage(img, ip) == 0) - goto fail; - } - } - - if (nimgs > 0) { - id = nencs; - if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL) - goto fail; - if (Z4lAddEncoding(enc, "XV_IMAGE", id, MAX_OVLY_WIDTH, - MAX_OVLY_HEIGHT, 0, 0, 0, 0, pixfmt) == 0) - goto fail; - } - - ctl = 0; - for (ctl = 0; ctl < (V4L2_CID_LASTP1 - V4L2_CID_BASE); ++ctl) { - memset(&queryctrl, 0, sizeof(queryctrl)); - queryctrl.id = V4L2_CID_BASE + ctl; - if (IoCtl(fd, VIDIOC_QUERYCTRL, &queryctrl, 0) < 0) - continue; - if (queryctrl.type != V4L2_CTRL_TYPE_INTEGER && - queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN) - continue; - attrIds[nattrs] = ctl; - if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) - goto fail; - Z4lAttributeName(&attr_name[0], sizeof(attr_name), - (char *)&queryctrl.name[0]); - if (Z4lAddAttribute(attr, &attr_name[0], - queryctrl.minimum, queryctrl.maximum, - XvSettable | XvGettable) == 0) - goto fail; - } - attrIds[nattrs] = ATTR_ENCODING_ID; - if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) - goto fail; - Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_ENCODING); - if (Z4lAddAttribute(attr, &attr_name[0], 0, nencs - 1, - XvSettable | XvGettable) == 0) - goto fail; - memset(&fbuf, 0, sizeof(fbuf)); - if (IoCtl(fd, VIDIOC_G_FBUF, &fbuf, 1) < 0) - goto fail; - opixfmt = fbuf.fmt.pixelformat; - - if ((fbuf.capability & V4L2_FBUF_CAP_CHROMAKEY) != 0) { - attrIds[nattrs] = ATTR_KEYMODE_ID; - if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) - goto fail; - Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_KEYMODE); - if (Z4lAddAttribute(attr, &attr_name[0], 0, 1, - XvSettable | XvGettable) == 0) - goto fail; - attrIds[nattrs] = ATTR_COLORKEY_ID; - if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) - goto fail; - Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_COLORKEY); - if (Z4lAddAttribute(attr, &attr_name[0], 0, 0xffffff, - XvSettable | XvGettable) == 0) - goto fail; - has_colorkey = 1; - } - - dp = malloc(strlen((char *)&capability.card[0]) + 1); - if (dp == NULL) - goto fail; - strcpy(dp, (char *)&capability.card[0]); - if ((adpt = Z4lNewAdaptor(&adpts, &nadpts, nattrs)) == NULL) - goto fail; - adpt->type = XvWindowMask | XvInputMask; - if (has_video != 0) - adpt->type |= XvVideoMask; - if (has_image != 0) - adpt->type |= XvImageMask; - adpt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adpt->name = dp; - adpt->type = XvInputMask | XvWindowMask | XvVideoMask | XvImageMask; - adpt->pEncodings = encs; - adpt->nEncodings = nencs; - adpt->pFormats = &Formats[0]; - adpt->nFormats = sizeof(Formats) / sizeof(Formats[0]); - adpt->pAttributes = attrs; - adpt->nAttributes = nattrs; - attrs = NULL; - nattrs = 0; - adpt->pImages = imgs; - adpt->nImages = nimgs; - imgs = NULL; - nimgs = 0; - adpt->PutVideo = Z4lPutVideo; - adpt->StopVideo = Z4lStopVideo; - adpt->SetPortAttribute = Z4lSetPortAttribute; - adpt->GetPortAttribute = Z4lGetPortAttribute; - adpt->QueryBestSize = Z4lQueryBestSize; - adpt->PutImage = Z4lPutImage; - adpt->QueryImageAttributes = Z4lQueryImageAttributes; - pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr; - pPriv->fd = fd; - pPriv->run = -1; - pPriv->dir = 0; - pPriv->nbfrs = -1; - pPriv->bufsz = -1; - pPriv->last = -1; - pPriv->pixfmt = opixfmt; + if (msg == NULL) { + memset(&format, 0, sizeof(format)); + format.type = 0x100; + if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) != 0) + msg = "no src/dst ovly fmt"; + } + if (msg != NULL) { + DBLOG(0, "%s %s\n", z4l_dev_paths[dev], msg); + close(fd); + continue; + } + + memset(&cfmt, 0, sizeof(cfmt)); + cfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (IoCtl(fd, VIDIOC_G_FMT, &cfmt, 1) < 0) + goto fail; + if (IoCtl(fd, VIDIOC_G_STD, &cstd_id, 1) < 0) + goto fail; + if (IoCtl(fd, VIDIOC_G_INPUT, &cinp, 1) < 0) + goto fail; + cpixfmt = cfmt.fmt.pix.pixelformat; + cenc = 0; + for (inp = 0;; ++inp) { + memset(&input, 0, sizeof(input)); + input.index = inp; + if (IoCtl(fd, VIDIOC_ENUMINPUT, &input, 0) < 0) + break; + id = inp; + if (IoCtl(fd, VIDIOC_S_INPUT, &id, 1) < 0) + goto fail; + for (std = 0;; ++std) { + memset(&standard, 0, sizeof(standard)); + standard.index = std; + if (IoCtl(fd, VIDIOC_ENUMSTD, &standard, 0) < 0) + break; + std_id = standard.id; + denom = standard.frameperiod.denominator; + numer = standard.frameperiod.numerator; + if (IoCtl(fd, VIDIOC_S_STD, &std_id, 1) < 0) + continue; + memset(&format, 0, sizeof(format)); + format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) < 0) + continue; + width = format.fmt.pix.width; + height = format.fmt.pix.height; + for (fmt = 0;; ++fmt) { + memset(&fmtdesc, 0, sizeof(fmtdesc)); + fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + fmtdesc.index = fmt; + if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0) + break; + pixfmt = fmtdesc.pixelformat; + ip = &pixfmts[0]; + for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0; + ++ip) + if (z4l_fourcc_pixfmt(ip->id) == pixfmt) + break; + + if (i >= 0) { + id = nencs; + has_video = 1; + if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL) + goto fail; + Z4lEncodingName(&enc_name[0], sizeof(enc_name), + (char *) &input.name[0], + (char *) &standard.name[0], + (char *) &pixfmt); + if (Z4lAddEncoding + (enc, &enc_name[0], id, width, height, denom, numer, + inp, std_id, pixfmt) == 0) + goto fail; + if (std_id == cstd_id && inp == cinp + && pixfmt == cpixfmt) + cenc = id; + } + } + } + } + + if (IoCtl(fd, VIDIOC_S_INPUT, &cinp, 1) < 0) + goto fail; + if (IoCtl(fd, VIDIOC_S_STD, &cstd_id, 1) < 0) + goto fail; + if (IoCtl(fd, VIDIOC_S_FMT, &cfmt, 1) < 0) + goto fail; + + if (encs == NULL) { + DBLOG(0, "no encodings\n"); + goto fail; + } + + for (fmt = 0;; ++fmt) { + memset(&fmtdesc, 0, sizeof(fmtdesc)); + fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + fmtdesc.index = fmt; + if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0) + break; + pixfmt = fmtdesc.pixelformat; + ip = &pixfmts[0]; + for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0; ++ip) + if (z4l_fourcc_pixfmt(ip->id) == pixfmt) + break; + + if (i >= 0) { + has_image = 1; + if ((img = Z4lNewImage(&imgs, &nimgs)) == NULL) + goto fail; + if (Z4lAddImage(img, ip) == 0) + goto fail; + } + } + + if (nimgs > 0) { + id = nencs; + if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL) + goto fail; + if (Z4lAddEncoding(enc, "XV_IMAGE", id, MAX_OVLY_WIDTH, + MAX_OVLY_HEIGHT, 0, 0, 0, 0, pixfmt) == 0) + goto fail; + } + + ctl = 0; + for (ctl = 0; ctl < (V4L2_CID_LASTP1 - V4L2_CID_BASE); ++ctl) { + memset(&queryctrl, 0, sizeof(queryctrl)); + queryctrl.id = V4L2_CID_BASE + ctl; + if (IoCtl(fd, VIDIOC_QUERYCTRL, &queryctrl, 0) < 0) + continue; + if (queryctrl.type != V4L2_CTRL_TYPE_INTEGER && + queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN) + continue; + attrIds[nattrs] = ctl; + if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) + goto fail; + Z4lAttributeName(&attr_name[0], sizeof(attr_name), + (char *) &queryctrl.name[0]); + if (Z4lAddAttribute(attr, &attr_name[0], + queryctrl.minimum, queryctrl.maximum, + XvSettable | XvGettable) == 0) + goto fail; + } + attrIds[nattrs] = ATTR_ENCODING_ID; + if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) + goto fail; + Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_ENCODING); + if (Z4lAddAttribute(attr, &attr_name[0], 0, nencs - 1, + XvSettable | XvGettable) == 0) + goto fail; + memset(&fbuf, 0, sizeof(fbuf)); + if (IoCtl(fd, VIDIOC_G_FBUF, &fbuf, 1) < 0) + goto fail; + opixfmt = fbuf.fmt.pixelformat; + + if ((fbuf.capability & V4L2_FBUF_CAP_CHROMAKEY) != 0) { + attrIds[nattrs] = ATTR_KEYMODE_ID; + if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) + goto fail; + Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_KEYMODE); + if (Z4lAddAttribute(attr, &attr_name[0], 0, 1, + XvSettable | XvGettable) == 0) + goto fail; + attrIds[nattrs] = ATTR_COLORKEY_ID; + if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL) + goto fail; + Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_COLORKEY); + if (Z4lAddAttribute(attr, &attr_name[0], 0, 0xffffff, + XvSettable | XvGettable) == 0) + goto fail; + has_colorkey = 1; + } + + dp = malloc(strlen((char *) &capability.card[0]) + 1); + if (dp == NULL) + goto fail; + strcpy(dp, (char *) &capability.card[0]); + if ((adpt = Z4lNewAdaptor(&adpts, &nadpts, nattrs)) == NULL) + goto fail; + adpt->type = XvWindowMask | XvInputMask; + if (has_video != 0) + adpt->type |= XvVideoMask; + if (has_image != 0) + adpt->type |= XvImageMask; + adpt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adpt->name = dp; + adpt->type = XvInputMask | XvWindowMask | XvVideoMask | XvImageMask; + adpt->pEncodings = encs; + adpt->nEncodings = nencs; + adpt->pFormats = &Formats[0]; + adpt->nFormats = sizeof(Formats) / sizeof(Formats[0]); + adpt->pAttributes = attrs; + adpt->nAttributes = nattrs; + attrs = NULL; + nattrs = 0; + adpt->pImages = imgs; + adpt->nImages = nimgs; + imgs = NULL; + nimgs = 0; + adpt->PutVideo = Z4lPutVideo; + adpt->StopVideo = Z4lStopVideo; + adpt->SetPortAttribute = Z4lSetPortAttribute; + adpt->GetPortAttribute = Z4lGetPortAttribute; + adpt->QueryBestSize = Z4lQueryBestSize; + adpt->PutImage = Z4lPutImage; + adpt->QueryImageAttributes = Z4lQueryImageAttributes; + pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr; + pPriv->fd = fd; + pPriv->run = -1; + pPriv->dir = 0; + pPriv->nbfrs = -1; + pPriv->bufsz = -1; + pPriv->last = -1; + pPriv->pixfmt = opixfmt; #if defined(REGION_NULL) - REGION_NULL(pScrni->pScreen, &pPriv->clips); + REGION_NULL(pScrni->pScreen, &pPriv->clips); #else - REGION_INIT(pScrni->pScreen, &pPriv->clips, NullBox, 0); + REGION_INIT(pScrni->pScreen, &pPriv->clips, NullBox, 0); #endif - strncpy(&pPriv->dev_path[0], z4l_dev_paths[dev], - sizeof(pPriv->dev_path)); - pPriv->enc = &encs[cenc]; - for (i = 0; i < adpt->nAttributes; ++i) - pPriv->attrIds[i] = attrIds[i]; - DBLOG(1, "adpt %s\n", dp); - if (has_colorkey != 0) { - z4l_ovly_set_colorkey(pPriv, DEFAULT_COLORKEY); - z4l_ovly_set_keymode(pPriv, DEFAULT_KEYMODE); - } - close(fd); - pPriv->fd = -1; - adpt = NULL; - cenc = 0; - encs = NULL; - nencs = 0; + strncpy(&pPriv->dev_path[0], z4l_dev_paths[dev], + sizeof(pPriv->dev_path)); + pPriv->enc = &encs[cenc]; + for (i = 0; i < adpt->nAttributes; ++i) + pPriv->attrIds[i] = attrIds[i]; + DBLOG(1, "adpt %s\n", dp); + if (has_colorkey != 0) { + z4l_ovly_set_colorkey(pPriv, DEFAULT_COLORKEY); + z4l_ovly_set_keymode(pPriv, DEFAULT_KEYMODE); + } + close(fd); + pPriv->fd = -1; + adpt = NULL; + cenc = 0; + encs = NULL; + nencs = 0; } DBLOG(0, "init done, %d device(s) found\n", nadpts); @@ -1605,52 +1607,52 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors) return nadpts; - fail: + fail: if (attrs != NULL) { - for (i = 0; i < nattrs; ++i) - if (attrs[i].name != NULL) - free(attrs[i].name); - free(attrs); + for (i = 0; i < nattrs; ++i) + if (attrs[i].name != NULL) + free(attrs[i].name); + free(attrs); } if (encs != NULL) { - for (i = 0; i < nencs; ++i) { - if (encs[i].name != NULL) - free(encs[i].name); - } - free(encs); + for (i = 0; i < nencs; ++i) { + if (encs[i].name != NULL) + free(encs[i].name); + } + free(encs); } if (imgs != NULL) - free(imgs); + free(imgs); if (adpts != NULL) { - for (i = 0; i < nadpts; ++i) { - if ((adpt = adpts[i]) != NULL) { - if (adpt->name != NULL) - free(adpt->name); - if ((attrs = adpt->pAttributes) != NULL) { - for (i = 0; i < adpt->nAttributes; ++i) - if (attrs[i].name != NULL) - free(attrs[i].name); - free(attrs); - } - if ((encs = adpt->pEncodings) != NULL) { - for (i = 0; i < adpt->nEncodings; ++i, ++enc) - if (encs[i].name != NULL) - free(encs[i].name); - free(encs); - } - if ((imgs = adpt->pImages) != NULL) - free(imgs); - free(adpt); - } - } - free(adpts); + for (i = 0; i < nadpts; ++i) { + if ((adpt = adpts[i]) != NULL) { + if (adpt->name != NULL) + free(adpt->name); + if ((attrs = adpt->pAttributes) != NULL) { + for (i = 0; i < adpt->nAttributes; ++i) + if (attrs[i].name != NULL) + free(attrs[i].name); + free(attrs); + } + if ((encs = adpt->pEncodings) != NULL) { + for (i = 0; i < adpt->nEncodings; ++i, ++enc) + if (encs[i].name != NULL) + free(encs[i].name); + free(encs); + } + if ((imgs = adpt->pImages) != NULL) + free(imgs); + free(adpt); + } + } + free(adpts); } if (fd >= 0) - close(fd); + close(fd); return 0; } @@ -1660,7 +1662,7 @@ Z4lProbe(DriverPtr drv, int flags) { DBLOG(1, "Probe\n"); if (flags & PROBE_DETECT) - return TRUE; + return TRUE; xf86XVRegisterGenericAdaptorDriver(Z4lInit); drv->refCount++; @@ -1711,21 +1713,21 @@ z4lSetup(pointer module, pointer opts, int *errmaj, int *errmin) static Bool setupDone = FALSE; if (setupDone != FALSE) { - if (errmaj != NULL) - *errmaj = LDR_ONCEONLY; - return NULL; + if (errmaj != NULL) + *errmaj = LDR_ONCEONLY; + return NULL; } setupDone = TRUE; LoaderGetOS(&osname, NULL, NULL, NULL); if (osname == NULL || strcmp(osname, "linux") != 0) { - if (errmaj) - *errmaj = LDR_BADOS; - if (errmin) - *errmin = 0; + if (errmaj) + *errmaj = LDR_BADOS; + if (errmin) + *errmin = 0; - return NULL; + return NULL; } xf86AddDriver(&Z4l, module, 0); @@ -1734,4 +1736,4 @@ z4lSetup(pointer module, pointer opts, int *errmaj, int *errmin) } #endif -#endif /* !XvExtension */ +#endif /* !XvExtension */ |