48 #include <linux/module.h>
50 #include <linux/slab.h>
51 #include <linux/pci.h>
53 #include <linux/wait.h>
56 #include <linux/i2c.h>
61 #include <linux/videodev2.h>
66 #include <asm/byteorder.h>
68 #include <asm/uaccess.h>
79 .name =
"15-bit RGB LE",
88 .name =
"15-bit RGB BE",
96 .name =
"16-bit RGB LE",
105 .name =
"16-bit RGB BE",
113 .name =
"24-bit RGB",
121 .name =
"32-bit RGB LE",
129 .name =
"32-bit RGB BE",
137 .name =
"4:2:2, packed, YUYV",
145 .name =
"4:2:2, packed, UYVY",
153 .name =
"Hardware-encoded Motion-JPEG",
162 #define NUM_FORMATS ARRAY_SIZE(zoran_formats)
188 static void v4l_fbuffer_free(
struct zoran_fh *fh);
189 static void jpg_fbuffer_free(
struct zoran_fh *fh);
192 static void map_mode_raw(
struct zoran_fh *fh)
198 static void map_mode_jpg(
struct zoran_fh *fh,
int play)
215 static int v4l_fbuffer_alloc(
struct zoran_fh *fh)
221 for (i = 0; i < fh->
buffers.num_buffers; i++) {
222 if (fh->
buffers.buffer[i].v4l.fbuffer)
225 "%s: %s - buffer %d already allocated!?\n",
234 "%s: %s - kmalloc for V4L buf %d failed\n",
236 v4l_fbuffer_free(fh);
242 for (off = 0; off < fh->
buffers.buffer_size;
247 "%s: %s - V4L frame %d mem 0x%lx (bus: 0x%llx)\n",
248 ZR_DEVNAME(zr), __func__, i, (
unsigned long) mem,
258 static void v4l_fbuffer_free(
struct zoran_fh *fh)
266 for (i = 0; i < fh->
buffers.num_buffers; i++) {
267 if (!fh->
buffers.buffer[i].v4l.fbuffer)
270 mem = fh->
buffers.buffer[
i].v4l.fbuffer;
271 for (off = 0; off < fh->
buffers.buffer_size;
309 static int jpg_fbuffer_alloc(
struct zoran_fh *fh)
315 for (i = 0; i < fh->
buffers.num_buffers; i++) {
316 if (fh->
buffers.buffer[i].jpg.frag_tab)
319 "%s: %s - buffer %d already allocated!?\n",
328 "%s: %s - get_zeroed_page (frag_tab) failed for buffer %d\n",
330 jpg_fbuffer_free(fh);
336 if (fh->
buffers.need_contiguous) {
341 "%s: %s - kmalloc failed for buffer %d\n",
343 jpg_fbuffer_free(fh);
346 fh->
buffers.buffer[
i].jpg.frag_tab[0] =
348 fh->
buffers.buffer[
i].jpg.frag_tab[1] =
359 "%s: %s - get_zeroed_page failed for buffer %d\n",
361 jpg_fbuffer_free(fh);
365 fh->
buffers.buffer[
i].jpg.frag_tab[2 *
j] =
367 fh->
buffers.buffer[
i].jpg.frag_tab[2 * j + 1] =
387 static void jpg_fbuffer_free(
struct zoran_fh *fh)
397 for (i = 0, buffer = &fh->
buffers.buffer[0];
398 i < fh->buffers.num_buffers; i++, buffer++) {
399 if (!buffer->
jpg.frag_tab)
402 if (fh->
buffers.need_contiguous) {
403 frag_tab = buffer->
jpg.frag_tab[0];
410 buffer->
jpg.frag_tab[0] = 0;
411 buffer->
jpg.frag_tab[1] = 0;
415 frag_tab = buffer->
jpg.frag_tab[2 *
j];
421 buffer->
jpg.frag_tab[2 *
j] = 0;
422 buffer->
jpg.frag_tab[2 * j + 1] = 0;
438 zoran_v4l_set_format (
struct zoran_fh *fh,
452 "%s: %s - wrong frame size (%dx%d)\n",
457 bpp = (format->
depth + 7) / 8;
460 if (height * width * bpp > fh->
buffers.buffer_size) {
463 "%s: %s - video buffer size (%d kB) is too small\n",
470 if ((bpp == 2 && (width & 1)) || (bpp == 3 && (width & 3))) {
473 "%s: %s - wrong frame alignment\n",
486 static int zoran_v4l_queue_frame(
struct zoran_fh *fh,
int num)
495 "%s: %s - buffers not yet allocated\n",
501 if (num >= fh->
buffers.num_buffers || num < 0) {
504 "%s: %s - buffer %d is out of range\n",
518 "%s: %s - another session is already capturing\n",
538 "%s: %s - queueing buffer %d in state DONE!?\n",
553 spin_unlock_irqrestore(&zr->
spinlock, flags);
573 "%s: %s - no grab active for this session\n",
579 if (frame >= fh->
buffers.num_buffers || frame < 0) {
581 KERN_ERR "%s: %s - frame %d is invalid\n",
590 "%s: %s - attempt to sync on a buffer which was not queued?\n",
605 KERN_ERR "%s: %s - internal state error\n",
622 spin_unlock_irqrestore(&zr->
spinlock, flags);
631 static int zoran_jpg_queue_frame(
struct zoran_fh *fh,
int num,
642 "%s: %s - buffers not yet allocated\n",
648 if (num >= fh->
buffers.num_buffers || num < 0) {
651 "%s: %s - buffer %d out of range\n",
663 "%s: %s - codec in wrong mode\n",
675 "%s: %s - another session is already capturing\n",
693 "%s: %s - queing frame in BUZ_STATE_DONE state!?\n",
715 spin_unlock_irqrestore(&zr->
spinlock, flags);
734 "%s: %s(-1) - session not active\n",
745 "%s: %s - stop streaming but not in streaming mode\n",
751 if ((res = zoran_jpg_queue_frame(fh, frame, mode)))
774 "%s: %s - capture is not currently active\n",
782 "%s: %s - codec not in streaming mode\n",
798 "%s: %s - timeout: codec isr=0x%02x\n",
817 KERN_ERR "%s: %s - internal state error\n",
825 spin_unlock_irqrestore(&zr->
spinlock, flags);
830 static void zoran_open_init_session(
struct zoran_fh *fh)
859 static void zoran_close_end_session(
struct zoran_fh *fh)
881 spin_unlock_irqrestore(&zr->
spinlock, flags);
886 v4l_fbuffer_free(fh);
897 jpg_fbuffer_free(fh);
905 static int zoran_open(
struct file *
file)
907 struct zoran *zr = video_drvdata(file);
909 int res, first_open = 0;
916 if (zr->
user >= 2048) {
928 "%s: %s - allocation of zoran_fh failed\n",
940 "%s: %s - allocation of overlay_mask failed\n",
963 zoran_open_init_session(fh);
980 zoran_close(
struct file *file)
992 zoran_close_end_session(fh);
994 if (zr->
user-- == 1) {
1037 zoran_read (
struct file *file,
1048 zoran_write (
struct file *file,
1049 const char __user *
data,
1058 static int setup_fbuffer(
struct zoran_fh *fh,
1080 bytesperline = width * ((fmt->
depth + 7) & ~7) / 8;
1092 "%s: %s - forced overlay turnoff because framebuffer changed\n",
1101 "%s: %s - no valid overlay format given\n",
1105 if (height <= 0 || width <= 0 || bytesperline <= 0) {
1108 "%s: %s - invalid height/width/bpl value (%d|%d|%d)\n",
1109 ZR_DEVNAME(zr), __func__, width, height, bytesperline);
1112 if (bytesperline & 3) {
1115 "%s: %s - bytesperline (%d) must be 4-byte aligned\n",
1120 zr->
vbuf_base = (
void *) ((
unsigned long) base & ~3);
1134 static int setup_window(
struct zoran_fh *fh,
1140 unsigned int clipcount,
1151 "%s: %s - frame buffer has to be set first\n",
1159 "%s: %s - no overlay format set\n",
1164 if (clipcount > 2048) {
1167 "%s: %s - invalid clipcount\n",
1177 end = (x +
width) & ~1;
1183 end = (x +
width) & ~3;
1198 "%s: %s - width = %d or height = %d invalid\n",
1232 (width * height + 7) / 8)) {
1235 }
else if (clipcount) {
1241 "%s: %s - Alloc of clip mask failed\n",
1246 (vcp, clips,
sizeof(
struct v4l2_clip) * clipcount)) {
1266 static int setup_overlay(
struct zoran_fh *fh,
int on)
1280 "%s: %s - overlay is already active for another session\n",
1288 "%s: %s - you cannot cancel someone else's session\n",
1305 "%s: %s - buffer or window not set\n",
1312 "%s: %s - no overlay format set\n",
1331 static int zoran_v4l2_buffer_status(
struct zoran_fh *fh,
1335 unsigned long flags;
1342 if (num < 0 || num >= fh->
buffers.num_buffers ||
1346 "%s: %s - wrong number or buffers not allocated\n",
1354 "%s: %s() - raw active=%c, buffer %d: state=%c, map=%c\n",
1356 "FAL"[fh->
buffers.active], num,
1358 fh->
buffers.buffer[num].map ?
'Y' :
'N');
1359 spin_unlock_irqrestore(&zr->
spinlock, flags);
1386 if (num < 0 || num >= fh->
buffers.num_buffers ||
1390 "%s: %s - wrong number or buffers not allocated\n",
1425 "%s: %s - invalid buffer type|map_mode (%d|%d)\n",
1438 zoran_set_norm (
struct zoran *zr,
1447 "%s: %s called while in playback/capture mode\n",
1452 if (!(norm & zr->
card.norms)) {
1454 KERN_ERR "%s: %s - unsupported norm %llx\n",
1473 "%s: %s - no norm detected\n",
1508 zoran_set_input (
struct zoran *zr,
1511 if (input == zr->
input) {
1519 "%s: %s called while in playback/capture mode\n",
1524 if (input < 0 || input >= zr->
card.inputs) {
1527 "%s: %s - unnsupported input %d\n",
1535 zr->
card.input[input].muxsel, 0, 0);
1544 static int zoran_querycap(
struct file *file,
void *__fh,
struct v4l2_capability *
cap)
1549 memset(cap, 0,
sizeof(*cap));
1561 unsigned int num,
i;
1564 if (zoran_formats[i].flags & flag && num++ == fmt->
index) {
1577 static int zoran_enum_fmt_vid_cap(
struct file *file,
void *__fh,
1586 static int zoran_enum_fmt_vid_out(
struct file *file,
void *__fh,
1595 static int zoran_enum_fmt_vid_overlay(
struct file *file,
void *__fh,
1604 static int zoran_g_fmt_vid_out(
struct file *file,
void *__fh,
1623 fmt->
fmt.
pix.bytesperline = 0;
1630 static int zoran_g_fmt_vid_cap(
struct file *file,
void *__fh,
1637 return zoran_g_fmt_vid_out(file, fh, fmt);
1655 static int zoran_g_fmt_vid_overlay(
struct file *file,
void *__fh,
1676 static int zoran_try_fmt_vid_overlay(
struct file *file,
void *__fh,
1697 static int zoran_try_fmt_vid_out(
struct file *file,
void *__fh,
1713 settings.TmpDcm = 1;
1715 settings.TmpDcm = 2;
1716 settings.decimation = 0;
1718 settings.VerDcm = 2;
1720 settings.VerDcm = 1;
1722 settings.HorDcm = 4;
1724 settings.HorDcm = 2;
1726 settings.HorDcm = 1;
1727 if (settings.TmpDcm == 1)
1728 settings.field_per_buff = 2;
1730 settings.field_per_buff = 1;
1732 if (settings.HorDcm > 1) {
1743 goto tryfmt_unlock_and_return;
1746 fmt->
fmt.
pix.width = settings.img_width / settings.HorDcm;
1747 fmt->
fmt.
pix.height = settings.img_height * 2 /
1748 (settings.TmpDcm * settings.VerDcm);
1749 if (settings.TmpDcm == 1)
1756 fmt->
fmt.
pix.sizeimage = zoran_v4l2_calc_bufsize(&settings);
1757 fmt->
fmt.
pix.bytesperline = 0;
1759 tryfmt_unlock_and_return:
1764 static int zoran_try_fmt_vid_cap(
struct file *file,
void *__fh,
1773 return zoran_try_fmt_vid_out(file, fh, fmt);
1778 if (zoran_formats[i].fourcc == fmt->
fmt.
pix.pixelformat)
1781 if (i == NUM_FORMATS) {
1795 static int zoran_s_fmt_vid_overlay(
struct file *file,
void *__fh,
1802 dprintk(3,
"x=%d, y=%d, w=%d, h=%d, cnt=%d, map=0x%p\n",
1809 res = setup_window(fh, fmt->
fmt.
win.w.left, fmt->
fmt.
win.w.top,
1817 static int zoran_s_fmt_vid_out(
struct file *file,
void *__fh,
1826 dprintk(3,
"size=%dx%d, fmt=0x%x (%4.4s)\n",
1828 fmt->
fmt.
pix.pixelformat,
1829 (
char *) &printformat);
1836 dprintk(1,
KERN_ERR "%s: VIDIOC_S_FMT - cannot change capture mode\n",
1839 goto sfmtjpg_unlock_and_return;
1846 settings.TmpDcm = 1;
1848 settings.TmpDcm = 2;
1849 settings.decimation = 0;
1851 settings.VerDcm = 2;
1853 settings.VerDcm = 1;
1855 settings.HorDcm = 4;
1857 settings.HorDcm = 2;
1859 settings.HorDcm = 1;
1860 if (settings.TmpDcm == 1)
1861 settings.field_per_buff = 2;
1863 settings.field_per_buff = 1;
1865 if (settings.HorDcm > 1) {
1876 goto sfmtjpg_unlock_and_return;
1885 fmt->
fmt.
pix.width = settings.img_width / settings.HorDcm;
1886 fmt->
fmt.
pix.height = settings.img_height * 2 /
1887 (settings.TmpDcm * settings.VerDcm);
1888 if (settings.TmpDcm == 1)
1894 fmt->
fmt.
pix.bytesperline = 0;
1898 sfmtjpg_unlock_and_return:
1903 static int zoran_s_fmt_vid_cap(
struct file *file,
void *__fh,
1912 return zoran_s_fmt_vid_out(file, fh, fmt);
1915 if (fmt->
fmt.
pix.pixelformat == zoran_formats[i].
fourcc)
1917 if (i == NUM_FORMATS) {
1918 dprintk(1,
KERN_ERR "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x\n",
1927 dprintk(1,
KERN_ERR "%s: VIDIOC_S_FMT - cannot change capture mode\n",
1930 goto sfmtv4l_unlock_and_return;
1939 res = zoran_v4l_set_format(fh, fmt->
fmt.
pix.width, fmt->
fmt.
pix.height,
1942 goto sfmtv4l_unlock_and_return;
1953 sfmtv4l_unlock_and_return:
1958 static int zoran_g_fbuf(
struct file *file,
void *__fh,
1964 memset(fb, 0,
sizeof(*fb));
1980 static int zoran_s_fbuf(
struct file *file,
void *__fh,
1989 if (zoran_formats[i].fourcc == fb->
fmt.pixelformat)
1991 if (i == NUM_FORMATS) {
1992 dprintk(1,
KERN_ERR "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n",
1994 (
char *)&printformat);
1999 res = setup_fbuffer(fh, fb->
base, &zoran_formats[i], fb->
fmt.width,
2000 fb->
fmt.height, fb->
fmt.bytesperline);
2006 static int zoran_overlay(
struct file *file,
void *__fh,
unsigned int on)
2013 res = setup_overlay(fh, on);
2019 static int zoran_streamoff(
struct file *file,
void *__fh,
enum v4l2_buf_type type);
2030 "%s: only MEMORY_MMAP capture is supported, not %d\n",
2035 if (req->
count == 0)
2036 return zoran_streamoff(file, fh, req->
type);
2042 "%s: VIDIOC_REQBUFS - buffers already allocated\n",
2045 goto v4l2reqbuf_unlock_and_return;
2060 if (v4l_fbuffer_alloc(fh)) {
2062 goto v4l2reqbuf_unlock_and_return;
2077 if (jpg_fbuffer_alloc(fh)) {
2079 goto v4l2reqbuf_unlock_and_return;
2084 "%s: VIDIOC_REQBUFS - unknown type %d\n",
2087 goto v4l2reqbuf_unlock_and_return;
2089 v4l2reqbuf_unlock_and_return:
2095 static int zoran_querybuf(
struct file *file,
void *__fh,
struct v4l2_buffer *buf)
2102 res = zoran_v4l2_buffer_status(fh, buf, buf->
index);
2108 static int zoran_qbuf(
struct file *file,
void *__fh,
struct v4l2_buffer *buf)
2120 "%s: VIDIOC_QBUF - invalid buf->type=%d for map_mode=%d\n",
2123 goto qbuf_unlock_and_return;
2126 res = zoran_v4l_queue_frame(fh, buf->
index);
2128 goto qbuf_unlock_and_return;
2143 if (buf->
type != buf_type) {
2145 "%s: VIDIOC_QBUF - invalid buf->type=%d for map_mode=%d\n",
2148 goto qbuf_unlock_and_return;
2153 goto qbuf_unlock_and_return;
2162 "%s: VIDIOC_QBUF - unsupported type %d\n",
2167 qbuf_unlock_and_return:
2173 static int zoran_dqbuf(
struct file *file,
void *__fh,
struct v4l2_buffer *buf)
2177 int res = 0, buf_type, num = -1;
2185 "%s: VIDIOC_QBUF - invalid buf->type=%d for map_mode=%d\n",
2188 goto dqbuf_unlock_and_return;
2195 goto dqbuf_unlock_and_return;
2197 res = v4l_sync(fh, num);
2199 goto dqbuf_unlock_and_return;
2201 res = zoran_v4l2_buffer_status(fh, buf, num);
2214 if (buf->
type != buf_type) {
2216 "%s: VIDIOC_QBUF - invalid buf->type=%d for map_mode=%d\n",
2219 goto dqbuf_unlock_and_return;
2227 goto dqbuf_unlock_and_return;
2230 res = jpg_sync(fh, &bs);
2232 goto dqbuf_unlock_and_return;
2233 res = zoran_v4l2_buffer_status(fh, buf, bs.
frame);
2239 "%s: VIDIOC_DQBUF - unsupported type %d\n",
2244 dqbuf_unlock_and_return:
2250 static int zoran_streamon(
struct file *file,
void *__fh,
enum v4l2_buf_type type)
2263 goto strmon_unlock_and_return;
2282 goto strmon_unlock_and_return;
2296 "%s: VIDIOC_STREAMON - invalid map mode %d\n",
2301 strmon_unlock_and_return:
2307 static int zoran_streamoff(
struct file *file,
void *__fh,
enum v4l2_buf_type type)
2312 unsigned long flags;
2321 goto strmoff_unlock_and_return;
2324 goto strmoff_unlock_and_return;
2333 for (i = 0; i < fh->
buffers.num_buffers; i++)
2343 spin_unlock_irqrestore(&zr->
spinlock, flags);
2352 goto strmoff_unlock_and_return;
2355 goto strmoff_unlock_and_return;
2357 res = jpg_qbuf(fh, -1,
2362 goto strmoff_unlock_and_return;
2366 "%s: VIDIOC_STREAMOFF - invalid map mode %d\n",
2371 strmoff_unlock_and_return:
2377 static int zoran_queryctrl(
struct file *file,
void *__fh,
2393 static int zoran_g_ctrl(
struct file *file,
void *__fh,
struct v4l2_control *ctrl)
2410 static int zoran_s_ctrl(
struct file *file,
void *__fh,
struct v4l2_control *ctrl)
2427 static int zoran_g_std(
struct file *file,
void *__fh,
v4l2_std_id *std)
2438 static int zoran_s_std(
struct file *file,
void *__fh,
v4l2_std_id *std)
2445 res = zoran_set_norm(zr, *std);
2447 goto sstd_unlock_and_return;
2450 sstd_unlock_and_return:
2455 static int zoran_enum_input(
struct file *file,
void *__fh,
2465 sizeof(inp->
name) - 1);
2476 static int zoran_g_input(
struct file *file,
void *__fh,
unsigned int *input)
2488 static int zoran_s_input(
struct file *file,
void *__fh,
unsigned int input)
2495 res = zoran_set_input(zr, input);
2497 goto sinput_unlock_and_return;
2501 sinput_unlock_and_return:
2506 static int zoran_enum_output(
struct file *file,
void *__fh,
2509 if (outp->
index != 0)
2519 static int zoran_g_output(
struct file *file,
void *__fh,
unsigned int *output)
2526 static int zoran_s_output(
struct file *file,
void *__fh,
unsigned int output)
2535 static int zoran_cropcap(
struct file *file,
void *__fh,
2540 int type = cropcap->
type, res = 0;
2542 memset(cropcap, 0,
sizeof(*cropcap));
2551 "%s: VIDIOC_CROPCAP - subcapture only supported for compressed capture\n",
2554 goto cropcap_unlock_and_return;
2563 cropcap_unlock_and_return:
2568 static int zoran_g_crop(
struct file *file,
void *__fh,
struct v4l2_crop *crop)
2572 int type = crop->
type, res = 0;
2574 memset(crop, 0,
sizeof(*crop));
2584 "%s: VIDIOC_G_CROP - subcapture only supported for compressed capture\n",
2587 goto gcrop_unlock_and_return;
2595 gcrop_unlock_and_return:
2601 static int zoran_s_crop(
struct file *file,
void *__fh,
const struct v4l2_crop *crop)
2614 "%s: VIDIOC_S_CROP - cannot change settings while active\n",
2617 goto scrop_unlock_and_return;
2624 "%s: VIDIOC_G_CROP - subcapture only supported for compressed capture\n",
2627 goto scrop_unlock_and_return;
2631 settings.img_x = crop->
c.left;
2632 settings.img_y = crop->
c.top;
2633 settings.img_width = crop->
c.width;
2634 settings.img_height = crop->
c.height;
2639 goto scrop_unlock_and_return;
2644 scrop_unlock_and_return:
2649 static int zoran_g_jpegcomp(
struct file *file,
void *__fh,
2654 memset(params, 0,
sizeof(*params));
2676 static int zoran_s_jpegcomp(
struct file *file,
void *__fh,
2686 settings.jpg_comp = *
params;
2692 "%s: VIDIOC_S_JPEGCOMP called while in playback/capture mode\n",
2695 goto sjpegc_unlock_and_return;
2700 goto sjpegc_unlock_and_return;
2705 sjpegc_unlock_and_return:
2712 zoran_poll (
struct file *file,
2718 unsigned long flags;
2732 poll_wait(file, &zr->
v4l_capq, wait);
2738 "%s: %s() raw - active=%c, sync_tail=%lu/%c, pend_tail=%lu, pend_head=%lu\n",
2748 spin_unlock_irqrestore(&zr->
spinlock, flags);
2754 poll_wait(file, &zr->
jpg_capq, wait);
2760 "%s: %s() jpg - active=%c, que_tail=%lu/%c, que_head=%lu, dma=%lu/%lu\n",
2772 spin_unlock_irqrestore(&zr->
spinlock, flags);
2779 "%s: %s - internal error, unknown map_mode=%d\n",
2818 if (--map->
count > 0)
2822 __func__, mode_name(fh->
map_mode));
2824 for (i = 0; i < fh->
buffers.num_buffers; i++) {
2825 if (fh->
buffers.buffer[i].map == map)
2831 for (i = 0; i < fh->
buffers.num_buffers; i++)
2832 if (fh->
buffers.buffer[i].map)
2836 __func__, mode_name(fh->
map_mode));
2842 unsigned long flags;
2848 spin_unlock_irqrestore(&zr->
spinlock, flags);
2850 v4l_fbuffer_free(fh);
2857 jpg_fbuffer_free(fh);
2863 static const struct vm_operations_struct zoran_vm_ops = {
2864 .open = zoran_vm_open,
2865 .close = zoran_vm_close,
2869 zoran_mmap (
struct file *file,
2883 KERN_INFO "%s: %s(%s) of 0x%08lx-0x%08lx (size=%lu)\n",
2891 "%s: %s - no MAP_SHARED/PROT_{READ,WRITE} given\n",
2901 "%s: %s(%s) - buffers not yet allocated\n",
2904 goto mmap_unlock_and_return;
2907 first = offset / fh->
buffers.buffer_size;
2908 last = first - 1 + size / fh->
buffers.buffer_size;
2909 if (offset % fh->
buffers.buffer_size != 0 ||
2910 size % fh->
buffers.buffer_size != 0 || first < 0 ||
2911 last < 0 || first >= fh->
buffers.num_buffers ||
2912 last >= fh->
buffers.buffer_size) {
2915 "%s: %s(%s) - offset=%lu or size=%lu invalid for bufsize=%d and numbufs=%d\n",
2920 goto mmap_unlock_and_return;
2924 for (i = first; i <= last; i++) {
2925 if (fh->
buffers.buffer[i].map) {
2928 "%s: %s(%s) - buffer %d already mapped\n",
2931 goto mmap_unlock_and_return;
2939 goto mmap_unlock_and_return;
2944 vma->
vm_ops = &zoran_vm_ops;
2949 for (i = first; i <= last; i++) {
2953 page = fh->
buffers.buffer[
i].v4l.fbuffer_phys;
2955 todo, PAGE_SHARED)) {
2958 "%s: %s(V4L) - remap_pfn_range failed\n",
2961 goto mmap_unlock_and_return;
2970 for (i = first; i <= last; i++) {
2976 frag_tab[2 * j + 1]) & ~1) << 1;
2982 buffer[i].
jpg.frag_tab[2 * j]);
2987 todo, PAGE_SHARED)) {
2990 "%s: %s(V4L) - remap_pfn_range failed\n",
2993 goto mmap_unlock_and_return;
3000 frag_tab[2 * j + 1]) & 1)
3010 mmap_unlock_and_return:
3017 .vidioc_querycap = zoran_querycap,
3018 .vidioc_cropcap = zoran_cropcap,
3019 .vidioc_s_crop = zoran_s_crop,
3020 .vidioc_g_crop = zoran_g_crop,
3021 .vidioc_enum_input = zoran_enum_input,
3022 .vidioc_g_input = zoran_g_input,
3023 .vidioc_s_input = zoran_s_input,
3024 .vidioc_enum_output = zoran_enum_output,
3025 .vidioc_g_output = zoran_g_output,
3026 .vidioc_s_output = zoran_s_output,
3027 .vidioc_g_fbuf = zoran_g_fbuf,
3028 .vidioc_s_fbuf = zoran_s_fbuf,
3029 .vidioc_g_std = zoran_g_std,
3030 .vidioc_s_std = zoran_s_std,
3031 .vidioc_g_jpegcomp = zoran_g_jpegcomp,
3032 .vidioc_s_jpegcomp = zoran_s_jpegcomp,
3033 .vidioc_overlay = zoran_overlay,
3034 .vidioc_reqbufs = zoran_reqbufs,
3035 .vidioc_querybuf = zoran_querybuf,
3036 .vidioc_qbuf = zoran_qbuf,
3037 .vidioc_dqbuf = zoran_dqbuf,
3038 .vidioc_streamon = zoran_streamon,
3039 .vidioc_streamoff = zoran_streamoff,
3040 .vidioc_enum_fmt_vid_cap = zoran_enum_fmt_vid_cap,
3041 .vidioc_enum_fmt_vid_out = zoran_enum_fmt_vid_out,
3042 .vidioc_enum_fmt_vid_overlay = zoran_enum_fmt_vid_overlay,
3043 .vidioc_g_fmt_vid_cap = zoran_g_fmt_vid_cap,
3044 .vidioc_g_fmt_vid_out = zoran_g_fmt_vid_out,
3045 .vidioc_g_fmt_vid_overlay = zoran_g_fmt_vid_overlay,
3046 .vidioc_s_fmt_vid_cap = zoran_s_fmt_vid_cap,
3047 .vidioc_s_fmt_vid_out = zoran_s_fmt_vid_out,
3048 .vidioc_s_fmt_vid_overlay = zoran_s_fmt_vid_overlay,
3049 .vidioc_try_fmt_vid_cap = zoran_try_fmt_vid_cap,
3050 .vidioc_try_fmt_vid_out = zoran_try_fmt_vid_out,
3051 .vidioc_try_fmt_vid_overlay = zoran_try_fmt_vid_overlay,
3052 .vidioc_queryctrl = zoran_queryctrl,
3053 .vidioc_s_ctrl = zoran_s_ctrl,
3054 .vidioc_g_ctrl = zoran_g_ctrl,
3058 static long zoran_ioctl(
struct file *file,
unsigned int cmd,
3075 .release = zoran_close,
3076 .unlocked_ioctl = zoran_ioctl,
3078 .write = zoran_write,
3085 .fops = &zoran_fops,
3086 .ioctl_ops = &zoran_ioctl_ops,