Lines Matching refs:zr
263 static void v4l_fbuffer_free(struct zoran *zr);
264 static void jpg_fbuffer_free(struct zoran *zr);
265 static void zoran_feed_stat_com(struct zoran *zr);
278 static int v4l_fbuffer_alloc(struct zoran *zr) in v4l_fbuffer_alloc() argument
284 if (zr->v4l_gbuf[i].fbuffer) in v4l_fbuffer_alloc()
287 zr->name, i); in v4l_fbuffer_alloc()
299 zr->name); in v4l_fbuffer_alloc()
300 v4l_fbuffer_free(zr); in v4l_fbuffer_alloc()
303 zr->v4l_gbuf[i].fbuffer = mem; in v4l_fbuffer_alloc()
304 zr->v4l_gbuf[i].fbuffer_phys = virt_to_phys(mem); in v4l_fbuffer_alloc()
305 zr->v4l_gbuf[i].fbuffer_bus = virt_to_bus(mem); in v4l_fbuffer_alloc()
311 zr->name, i, (unsigned long) mem, in v4l_fbuffer_alloc()
324 zr->name); in v4l_fbuffer_alloc()
325 v4l_fbuffer_free(zr); in v4l_fbuffer_alloc()
328 zr->v4l_gbuf[i].fbuffer = mem; in v4l_fbuffer_alloc()
329 zr->v4l_gbuf[i].fbuffer_phys = virt_to_phys(mem); in v4l_fbuffer_alloc()
330 zr->v4l_gbuf[i].fbuffer_bus = virt_to_bus(mem); in v4l_fbuffer_alloc()
334 zr->name, i, (unsigned) mem, in v4l_fbuffer_alloc()
338 memset(zr->v4l_gbuf[i].fbuffer, 0, v4l_bufsize); in v4l_fbuffer_alloc()
344 zr->name); in v4l_fbuffer_alloc()
347 zr->name, v4l_bufsize >> 10); in v4l_fbuffer_alloc()
358 static void v4l_fbuffer_free(struct zoran *zr) in v4l_fbuffer_free() argument
364 if (!zr->v4l_gbuf[i].fbuffer) in v4l_fbuffer_free()
368 mem = zr->v4l_gbuf[i].fbuffer; in v4l_fbuffer_free()
371 kfree((void *) zr->v4l_gbuf[i].fbuffer); in v4l_fbuffer_free()
375 bigphysarea_free_pages((void *) zr->v4l_gbuf[i]. in v4l_fbuffer_free()
378 zr->v4l_gbuf[i].fbuffer = NULL; in v4l_fbuffer_free()
406 static int jpg_fbuffer_alloc(struct zoran *zr) in jpg_fbuffer_alloc() argument
416 for (i = 0; i < zr->jpg_nbufs; i++) { in jpg_fbuffer_alloc()
417 if (zr->jpg_gbuf[i].frag_tab) in jpg_fbuffer_alloc()
420 zr->name, i); in jpg_fbuffer_alloc()
428 zr->name, i); in jpg_fbuffer_alloc()
429 jpg_fbuffer_free(zr); in jpg_fbuffer_alloc()
433 zr->jpg_gbuf[i].frag_tab = (u32 *) mem; in jpg_fbuffer_alloc()
434 zr->jpg_gbuf[i].frag_tab_bus = virt_to_bus((void *) mem); in jpg_fbuffer_alloc()
437 if (zr->need_contiguous) { in jpg_fbuffer_alloc()
438 mem = (unsigned long) kmalloc(zr->jpg_bufsize, GFP_KERNEL); in jpg_fbuffer_alloc()
441 zr->name, i); in jpg_fbuffer_alloc()
442 jpg_fbuffer_free(zr); in jpg_fbuffer_alloc()
445 zr->jpg_gbuf[i].frag_tab[0] = virt_to_bus((void *) mem); in jpg_fbuffer_alloc()
446 zr->jpg_gbuf[i].frag_tab[1] = in jpg_fbuffer_alloc()
447 ((zr->jpg_bufsize / 4) << 1) | 1; in jpg_fbuffer_alloc()
448 for (off = 0; off < zr->jpg_bufsize; off += PAGE_SIZE) in jpg_fbuffer_alloc()
452 for (j = 0; j < zr->jpg_bufsize / PAGE_SIZE; j++) in jpg_fbuffer_alloc()
458 zr->name, i); in jpg_fbuffer_alloc()
459 jpg_fbuffer_free(zr); in jpg_fbuffer_alloc()
463 zr->jpg_gbuf[i].frag_tab[2 * j] = in jpg_fbuffer_alloc()
465 zr->jpg_gbuf[i].frag_tab[2 * j + 1] = in jpg_fbuffer_alloc()
470 zr->jpg_gbuf[i].frag_tab[2 * j - 1] |= 1; in jpg_fbuffer_alloc()
475 ("%s: jpg_fbuffer_alloc: %ld KB allocated\n", zr->name, in jpg_fbuffer_alloc()
476 (zr->jpg_nbufs * zr->jpg_bufsize) >> 10)); in jpg_fbuffer_alloc()
477 zr->jpg_buffers_allocated = 1; in jpg_fbuffer_alloc()
482 static void jpg_fbuffer_free(struct zoran *zr) in jpg_fbuffer_free() argument
492 for (i = 0; i < zr->jpg_nbufs; i++) { in jpg_fbuffer_free()
493 if (!zr->jpg_gbuf[i].frag_tab) in jpg_fbuffer_free()
497 if (zr->need_contiguous) { in jpg_fbuffer_free()
498 if (zr->jpg_gbuf[i].frag_tab[0]) { in jpg_fbuffer_free()
500 (unsigned char *) bus_to_virt(zr-> in jpg_fbuffer_free()
505 for (off = 0; off < zr->jpg_bufsize; in jpg_fbuffer_free()
510 zr->jpg_gbuf[i].frag_tab[0] = 0; in jpg_fbuffer_free()
511 zr->jpg_gbuf[i].frag_tab[1] = 0; in jpg_fbuffer_free()
514 for (j = 0; j < zr->jpg_bufsize / PAGE_SIZE; j++) { in jpg_fbuffer_free()
515 if (!zr->jpg_gbuf[i].frag_tab[2 * j]) in jpg_fbuffer_free()
519 (zr->jpg_gbuf[i]. in jpg_fbuffer_free()
522 bus_to_virt(zr->jpg_gbuf[i]. in jpg_fbuffer_free()
524 zr->jpg_gbuf[i].frag_tab[2 * j] = 0; in jpg_fbuffer_free()
525 zr->jpg_gbuf[i].frag_tab[2 * j + 1] = 0; in jpg_fbuffer_free()
529 free_page((unsigned long) zr->jpg_gbuf[i].frag_tab); in jpg_fbuffer_free()
530 zr->jpg_gbuf[i].frag_tab = NULL; in jpg_fbuffer_free()
532 zr->jpg_buffers_allocated = 0; in jpg_fbuffer_free()
547 struct zoran *zr = (struct zoran *) bus->data; in i2c_setlines() local
554 struct zoran *zr = (struct zoran *) bus->data; in i2c_getdataline() local
561 struct zoran *zr = (struct zoran *) bus->data; in attach_inform() local
563 DEBUG1(printk(KERN_DEBUG "%s: i2c attach %02x\n", zr->name, id)); in attach_inform()
566 if (zr->revision < 2) { in attach_inform()
567 zr->card = DC10; in attach_inform()
568 sprintf(zr->name, "DC10[%u]", zr->id); in attach_inform()
570 zr->card = DC10plus; in attach_inform()
571 sprintf(zr->name, "DC10plus[%u]", zr->id); in attach_inform()
576 zr->card = LML33; in attach_inform()
577 sprintf(zr->name, "LML33[%u]", zr->id); in attach_inform()
581 zr->card = BUZ; in attach_inform()
582 sprintf(zr->name, "Buz[%u]", zr->id); in attach_inform()
590 DEBUG1(struct zoran *zr = (struct zoran *) bus->data); in detach_inform()
591 DEBUG1(printk(KERN_DEBUG "%s: i2c detach %02x\n", zr->name, id)); in detach_inform()
708 static void zr36057_adjust_vfe(struct zoran *zr, in zr36057_adjust_vfe() argument
724 if (zr->params.norm == VIDEO_MODE_NTSC) in zr36057_adjust_vfe()
740 static void zr36057_set_vfe(struct zoran *zr, int video_width, in zr36057_set_vfe() argument
753 tvn = zr->timing; in zr36057_set_vfe()
760 if (zr->params.norm != VIDEO_MODE_PAL in zr36057_set_vfe()
761 && zr->params.norm != VIDEO_MODE_NTSC in zr36057_set_vfe()
762 && zr->params.norm != VIDEO_MODE_SECAM) { in zr36057_set_vfe()
764 zr->name, zr->params.norm); in zr36057_set_vfe()
770 zr->name, video_width, video_height); in zr36057_set_vfe()
777 zr->video_interlace = (video_height > Ha / 2); in zr36057_set_vfe()
789 if (zr->card == LML33) in zr36057_set_vfe()
791 if (zr->card == BUZ) { //HStart += 67; in zr36057_set_vfe()
799 if (zr->card != BUZ) in zr36057_set_vfe()
804 DispMode = !zr->video_interlace; in zr36057_set_vfe()
831 if (zr->params.norm != VIDEO_MODE_NTSC) in zr36057_set_vfe()
857 printk(KERN_INFO "%s: Unknown color_fmt=%x\n", zr->name, in zr36057_set_vfe()
876 if (triton || zr->revision <= 1) in zr36057_set_vfe()
887 reg = virt_to_bus(zr->overlay_mask); in zr36057_set_vfe()
889 reg = virt_to_bus(zr->overlay_mask + mask_line_size); in zr36057_set_vfe()
891 reg = mask_line_size - (zr->window.width + 31) / 32; in zr36057_set_vfe()
897 zr36057_adjust_vfe(zr, zr->codec_mode); in zr36057_set_vfe()
905 static void zr36057_overlay(struct zoran *zr, int on) in zr36057_overlay() argument
915 switch (zr->buffer.depth) { in zr36057_overlay()
937 zr36057_set_vfe(zr, zr->window.width, zr->window.height, in zr36057_overlay()
947 (u32) zr->buffer.base + zr->window.x * bpp + in zr36057_overlay()
948 zr->window.y * zr->buffer.bytesperline; in zr36057_overlay()
953 zr->name); in zr36057_overlay()
954 if (zr->video_interlace) in zr36057_overlay()
955 reg += zr->buffer.bytesperline; in zr36057_overlay()
960 reg = zr->buffer.bytesperline - zr->window.width * bpp; in zr36057_overlay()
961 if (zr->video_interlace) in zr36057_overlay()
962 reg += zr->buffer.bytesperline; in zr36057_overlay()
966 zr->name); in zr36057_overlay()
973 if (zr->window.clipcount) in zr36057_overlay()
990 static void write_overlay_mask(struct zoran *zr, struct video_clip *vp, in write_overlay_mask() argument
1000 memset(zr->overlay_mask, ~0, mask_line_size * 4 * BUZ_MAX_HEIGHT); in write_overlay_mask()
1019 if (x + width > zr->window.width) { in write_overlay_mask()
1020 width = zr->window.width - x; in write_overlay_mask()
1022 if (y + height > zr->window.height) { in write_overlay_mask()
1023 height = zr->window.height - y; in write_overlay_mask()
1038 mask = zr->overlay_mask + (y + j) * mask_line_size; in write_overlay_mask()
1049 static void zr36057_set_memgrab(struct zoran *zr, int mode) in zr36057_set_memgrab() argument
1056 zr->name); in zr36057_set_memgrab()
1061 btor(cardvsync[zr->card], ZR36057_ICR); // SW in zr36057_set_memgrab()
1069 zr36057_set_vfe(zr, zr->gwidth, zr->gheight, zr->gformat); in zr36057_set_memgrab()
1071 zr->v4l_memgrab_active = 1; in zr36057_set_memgrab()
1073 zr->v4l_memgrab_active = 0; in zr36057_set_memgrab()
1081 if (zr->v4l_overlay_active) { in zr36057_set_memgrab()
1082 zr36057_overlay(zr, 1); in zr36057_set_memgrab()
1090 static int wait_grab_pending(struct zoran *zr) in wait_grab_pending() argument
1096 if (!zr->v4l_memgrab_active) in wait_grab_pending()
1099 while (zr->v4l_pend_tail != zr->v4l_pend_head) { in wait_grab_pending()
1100 interruptible_sleep_on(&zr->v4l_capq); in wait_grab_pending()
1105 spin_lock_irqsave(&zr->lock, flags); in wait_grab_pending()
1106 zr36057_set_memgrab(zr, 0); in wait_grab_pending()
1107 spin_unlock_irqrestore(&zr->lock, flags); in wait_grab_pending()
1116 static int v4l_grab(struct zoran *zr, struct video_mmap *mp) in v4l_grab() argument
1131 (KERN_ERR "%s: Can not grab frame %d\n", zr->name, in v4l_grab()
1141 (KERN_ERR "%s: Wrong frame size.\n", zr->name)); in v4l_grab()
1149 zr->name)); in v4l_grab()
1158 zr->name)); in v4l_grab()
1166 (KERN_ERR "%s: Wrong frame alingment\n", zr->name)); in v4l_grab()
1177 if (zr->v4l_memgrab_active in v4l_grab()
1178 && (zr->gwidth != mp->width || zr->gheight != mp->height in v4l_grab()
1179 || zr->gformat != mp->format)) { in v4l_grab()
1180 res = wait_grab_pending(zr); in v4l_grab()
1184 zr->gwidth = mp->width; in v4l_grab()
1185 zr->gheight = mp->height; in v4l_grab()
1186 zr->gformat = mp->format; in v4l_grab()
1187 zr->gbpl = bpp * zr->gwidth; in v4l_grab()
1190 spin_lock_irqsave(&zr->lock, flags); in v4l_grab()
1194 switch (zr->v4l_gbuf[mp->frame].state) { in v4l_grab()
1204 zr->v4l_pend[zr->v4l_pend_head++ & V4L_MASK_FRAME] = in v4l_grab()
1206 zr->v4l_gbuf[mp->frame].state = BUZ_STATE_PEND; in v4l_grab()
1214 if (!res && !zr->v4l_memgrab_active) in v4l_grab()
1215 zr36057_set_memgrab(zr, 1); in v4l_grab()
1217 spin_unlock_irqrestore(&zr->lock, flags); in v4l_grab()
1227 static int v4l_sync(struct zoran *zr, int frame) in v4l_sync() argument
1235 zr->name, frame)); in v4l_sync()
1241 if (zr->v4l_gbuf[frame].state == BUZ_STATE_USER) { in v4l_sync()
1244 zr->name)); in v4l_sync()
1250 while (zr->v4l_gbuf[frame].state == BUZ_STATE_PEND) { in v4l_sync()
1251 interruptible_sleep_on(&zr->v4l_capq); in v4l_sync()
1258 if (zr->v4l_gbuf[frame].state != BUZ_STATE_DONE) in v4l_sync()
1260 zr->name); in v4l_sync()
1264 spin_lock_irqsave(&zr->lock, flags); in v4l_sync()
1266 if (zr->v4l_pend_tail == zr->v4l_pend_head) in v4l_sync()
1267 zr36057_set_memgrab(zr, 0); in v4l_sync()
1269 spin_unlock_irqrestore(&zr->lock, flags); in v4l_sync()
1282 static int post_office_wait(struct zoran *zr) in post_office_wait() argument
1290 if ((por & ZR36057_POR_POTime) && zr->card != LML33 in post_office_wait()
1291 && zr->card != BUZ) { in post_office_wait()
1293 printk(KERN_WARNING "%s: pop timeout %08x\n", zr->name, por); in post_office_wait()
1299 static int post_office_write(struct zoran *zr, unsigned guest, in post_office_write() argument
1308 return post_office_wait(zr); in post_office_write()
1311 static int post_office_read(struct zoran *zr, unsigned guest, unsigned reg) in post_office_read() argument
1317 if (post_office_wait(zr) < 0) { in post_office_read()
1323 static int zr36060_write_8(struct zoran *zr, unsigned reg, unsigned val) in zr36060_write_8() argument
1325 if (post_office_wait(zr) in zr36060_write_8()
1326 || post_office_write(zr, 0, 1, reg >> 8) in zr36060_write_8()
1327 || post_office_write(zr, 0, 2, reg)) { in zr36060_write_8()
1330 return post_office_write(zr, 0, 3, val); in zr36060_write_8()
1333 static int zr36060_write_16(struct zoran *zr, unsigned reg, unsigned val) in zr36060_write_16() argument
1335 if (zr36060_write_8(zr, reg + 0, val >> 8)) { in zr36060_write_16()
1338 return zr36060_write_8(zr, reg + 1, val >> 0); in zr36060_write_16()
1341 static int zr36060_write_24(struct zoran *zr, unsigned reg, unsigned val) in zr36060_write_24() argument
1343 if (zr36060_write_8(zr, reg + 0, val >> 16)) { in zr36060_write_24()
1346 return zr36060_write_16(zr, reg + 1, val >> 0); in zr36060_write_24()
1349 static int zr36060_write_32(struct zoran *zr, unsigned reg, unsigned val) in zr36060_write_32() argument
1351 if (zr36060_write_16(zr, reg + 0, val >> 16)) { in zr36060_write_32()
1354 return zr36060_write_16(zr, reg + 2, val >> 0); in zr36060_write_32()
1357 static u32 zr36060_read_8(struct zoran *zr, unsigned reg) in zr36060_read_8() argument
1359 if (post_office_wait(zr) in zr36060_read_8()
1360 || post_office_write(zr, 0, 1, reg >> 8) in zr36060_read_8()
1361 || post_office_write(zr, 0, 2, reg)) { in zr36060_read_8()
1364 return post_office_read(zr, 0, 3) & 0xFF; in zr36060_read_8()
1369 static void GPIO(struct zoran *zr, unsigned bit, unsigned value) in GPIO() argument
1384 static void zr36060_sleep(struct zoran *zr, int sleep) in zr36060_sleep() argument
1386 switch (zr->card) { in zr36060_sleep()
1389 GPIO(zr, 3, !sleep); in zr36060_sleep()
1393 GPIO(zr, 1, !sleep); in zr36060_sleep()
1404 static int zr36060_reset(struct zoran *zr) in zr36060_reset() argument
1406 switch (zr->card) { in zr36060_reset()
1409 zr36060_sleep(zr, 0); in zr36060_reset()
1410 GPIO(zr, 0, 0); in zr36060_reset()
1412 GPIO(zr, 0, 1); in zr36060_reset()
1417 zr36060_sleep(zr, 0); in zr36060_reset()
1418 post_office_write(zr, 3, 0, 0); in zr36060_reset()
1425 static void set_frame(struct zoran *zr, int val) in set_frame() argument
1427 switch (zr->card) { in set_frame()
1430 GPIO(zr, 6, val); in set_frame()
1434 GPIO(zr, 3, val); in set_frame()
1441 static void set_videobus_dir(struct zoran *zr, int val) in set_videobus_dir() argument
1443 switch (zr->card) { in set_videobus_dir()
1446 GPIO(zr, 1, val); in set_videobus_dir()
1450 GPIO(zr, 5, val); in set_videobus_dir()
1452 GPIO(zr, 5, 1); in set_videobus_dir()
1460 static void set_videobus_enable(struct zoran *zr, int val) in set_videobus_enable() argument
1462 switch (zr->card) { in set_videobus_enable()
1464 GPIO(zr, 7, val); in set_videobus_enable()
1474 static void zr36060_set_jpg(struct zoran *zr, enum zoran_codec_mode mode) in zr36060_set_jpg() argument
1484 zr36060_write_8(zr, 0x002, reg); in zr36060_set_jpg()
1500 zr36060_write_8(zr, 0x003, reg); in zr36060_set_jpg()
1503 zr36060_write_8(zr, 0x004, reg); in zr36060_set_jpg()
1508 tvn = zr->timing; in zr36060_set_jpg()
1510 (tvn->Ha / 2) * (tvn->Wa) / (zr->params.HorDcm) / in zr36060_set_jpg()
1511 (zr->params.VerDcm); in zr36060_set_jpg()
1516 size = size * zr->params.quality / 400; /* quality = 100 is a compression ratio 1:4 */ in zr36060_set_jpg()
1523 if (size * zr->params.field_per_buff > zr->jpg_bufsize * 6) in zr36060_set_jpg()
1524 size = zr->jpg_bufsize * 6 / zr->params.field_per_buff; in zr36060_set_jpg()
1529 zr36060_write_8(zr, 0x005, reg); in zr36060_set_jpg()
1532 reg = (zr->params.jpeg_markers) & 0x38; /* DRI, DQT, DHT */ in zr36060_set_jpg()
1533 if (zr->params.COM_len) in zr36060_set_jpg()
1535 if (zr->params.APP_len) in zr36060_set_jpg()
1537 zr36060_write_8(zr, 0x006, reg); in zr36060_set_jpg()
1539 if (zr->card != LML33 && zr->card != BUZ) { in zr36060_set_jpg()
1550 zr36060_write_8(zr, 0x007, reg); in zr36060_set_jpg()
1553 zr36060_write_32(zr, 0x009, reg); in zr36060_set_jpg()
1556 …zr36060_write_32(zr, 0x00d, reg); // Not needed for compr. with variable scale factor, just in cas… in zr36060_set_jpg()
1560 zr36060_write_16(zr, 0x011, reg); in zr36060_set_jpg()
1563 zr36060_write_24(zr, 0x013, reg); in zr36060_set_jpg()
1566 zr36060_write_16(zr, 0x024, reg); in zr36060_set_jpg()
1571 static void zr36060_set_video(struct zoran *zr, enum zoran_codec_mode mode) in zr36060_set_video() argument
1577 tvn = zr->timing; in zr36060_set_video()
1590 zr36060_write_8(zr, 0x030, reg); in zr36060_set_video()
1592 switch (zr->card) { in zr36060_set_video()
1626 zr36060_write_8(zr, 0x031, reg); in zr36060_set_video()
1628 switch (zr->params.HorDcm) { in zr36060_set_video()
1642 if (zr->params.VerDcm == 2) in zr36060_set_video()
1644 zr36060_write_8(zr, 0x032, reg); in zr36060_set_video()
1647 zr36060_write_8(zr, 0x033, reg); in zr36060_set_video()
1650 zr36060_write_8(zr, 0x034, reg); in zr36060_set_video()
1653 zr36060_write_8(zr, 0x035, reg); in zr36060_set_video()
1658 zr36060_write_16(zr, 0x036, reg); in zr36060_set_video()
1661 zr36060_write_16(zr, 0x038, reg); in zr36060_set_video()
1664 zr36060_write_8(zr, 0x03a, reg); in zr36060_set_video()
1667 reg = (zr->params.norm == 1 ? 57 : 68); in zr36060_set_video()
1668 zr36060_write_8(zr, 0x03b, reg); in zr36060_set_video()
1671 zr36060_write_8(zr, 0x03c, reg); in zr36060_set_video()
1674 zr36060_write_16(zr, 0x03e, reg); in zr36060_set_video()
1677 zr36060_write_8(zr, 0x03d, reg); in zr36060_set_video()
1680 zr36060_write_16(zr, 0x040, reg); in zr36060_set_video()
1683 reg = zr->params.img_y + tvn->VStart; /* Vstart */ in zr36060_set_video()
1684 zr36060_write_16(zr, 0x042, reg); in zr36060_set_video()
1686 reg += zr->params.img_height; /* Vend */ in zr36060_set_video()
1687 zr36060_write_16(zr, 0x044, reg); in zr36060_set_video()
1690 if (zr->card == BUZ) { in zr36060_set_video()
1695 reg = zr->params.img_x + HStart; /* Hstart */ in zr36060_set_video()
1696 zr36060_write_16(zr, 0x046, reg); in zr36060_set_video()
1698 reg += zr->params.img_width; /* Hend */ in zr36060_set_video()
1699 zr36060_write_16(zr, 0x048, reg); in zr36060_set_video()
1703 zr36060_write_16(zr, 0x04a, reg); in zr36060_set_video()
1706 zr36060_write_16(zr, 0x04c, reg); in zr36060_set_video()
1709 zr36060_write_16(zr, 0x04e, reg); in zr36060_set_video()
1712 zr36060_write_16(zr, 0x050, reg); in zr36060_set_video()
1715 static void zr36060_set_jpg_SOF(struct zoran *zr) in zr36060_set_jpg_SOF() argument
1721 zr36060_write_16(zr, 0x060, reg); in zr36060_set_jpg_SOF()
1724 zr36060_write_16(zr, 0x062, reg); in zr36060_set_jpg_SOF()
1727 zr36060_write_8(zr, 0x064, reg); in zr36060_set_jpg_SOF()
1729 reg = zr->params.img_height / zr->params.VerDcm; /* image height */ in zr36060_set_jpg_SOF()
1730 zr36060_write_16(zr, 0x065, reg); in zr36060_set_jpg_SOF()
1732 reg = zr->params.img_width / zr->params.HorDcm; /* image width */ in zr36060_set_jpg_SOF()
1733 zr36060_write_16(zr, 0x067, reg); in zr36060_set_jpg_SOF()
1736 zr36060_write_8(zr, 0x069, reg); in zr36060_set_jpg_SOF()
1739 zr36060_write_24(zr, 0x06a, reg); in zr36060_set_jpg_SOF()
1742 zr36060_write_24(zr, 0x06d, reg); in zr36060_set_jpg_SOF()
1745 zr36060_write_24(zr, 0x070, reg); in zr36060_set_jpg_SOF()
1748 static void zr36060_set_jpg_SOS(struct zoran *zr) in zr36060_set_jpg_SOS() argument
1754 zr36060_write_16(zr, 0x07a, reg); in zr36060_set_jpg_SOS()
1757 zr36060_write_16(zr, 0x07c, reg); in zr36060_set_jpg_SOS()
1760 zr36060_write_8(zr, 0x07e, reg); in zr36060_set_jpg_SOS()
1763 zr36060_write_16(zr, 0x07f, reg); in zr36060_set_jpg_SOS()
1766 zr36060_write_16(zr, 0x081, reg); in zr36060_set_jpg_SOS()
1769 zr36060_write_16(zr, 0x083, reg); in zr36060_set_jpg_SOS()
1772 zr36060_write_24(zr, 0x085, reg); in zr36060_set_jpg_SOS()
1775 static void zr36060_set_jpg_DRI(struct zoran *zr) in zr36060_set_jpg_DRI() argument
1781 zr36060_write_16(zr, 0x0c0, reg); in zr36060_set_jpg_DRI()
1784 zr36060_write_16(zr, 0x0c2, reg); in zr36060_set_jpg_DRI()
1787 zr36060_write_16(zr, 0x0c4, reg); in zr36060_set_jpg_DRI()
1790 static void zr36060_set_jpg_DQT(struct zoran *zr) in zr36060_set_jpg_DQT() argument
1820 zr36060_write_8(zr, adr++, dqt[i]); in zr36060_set_jpg_DQT()
1824 static void zr36060_set_jpg_DHT(struct zoran *zr) in zr36060_set_jpg_DHT() argument
1906 zr36060_write_8(zr, adr++, dht[i]); in zr36060_set_jpg_DHT()
1910 static void zr36060_set_jpg_APP(struct zoran *zr) in zr36060_set_jpg_APP() argument
1917 len = zr->params.APP_len; in zr36060_set_jpg_APP()
1923 i = zr->params.APPn; in zr36060_set_jpg_APP()
1930 zr36060_write_16(zr, 0x380, reg); in zr36060_set_jpg_APP()
1933 zr36060_write_16(zr, 0x382, reg); in zr36060_set_jpg_APP()
1938 zr36060_write_8(zr, adr++, in zr36060_set_jpg_APP()
1939 (i < len ? zr->params.APP_data[i] : 0)); in zr36060_set_jpg_APP()
1943 static void zr36060_set_jpg_COM(struct zoran *zr) in zr36060_set_jpg_COM() argument
1950 len = zr->params.COM_len; in zr36060_set_jpg_COM()
1957 zr36060_write_16(zr, 0x3c0, reg); in zr36060_set_jpg_COM()
1960 zr36060_write_16(zr, 0x3c2, reg); in zr36060_set_jpg_COM()
1965 zr36060_write_8(zr, adr++, in zr36060_set_jpg_COM()
1966 (i < len ? zr->params.COM_data[i] : 0)); in zr36060_set_jpg_COM()
1970 static void zr36060_set_cap(struct zoran *zr, enum zoran_codec_mode mode) in zr36060_set_cap() argument
1975 zr36060_reset(zr); in zr36060_set_cap()
1980 zr36060_write_8(zr, 0x000, reg); in zr36060_set_cap()
1982 zr36060_set_jpg(zr, mode); in zr36060_set_cap()
1983 zr36060_set_video(zr, mode); in zr36060_set_cap()
1984 zr36060_set_jpg_SOF(zr); in zr36060_set_cap()
1985 zr36060_set_jpg_SOS(zr); in zr36060_set_cap()
1986 zr36060_set_jpg_DRI(zr); in zr36060_set_cap()
1987 zr36060_set_jpg_DQT(zr); in zr36060_set_cap()
1988 zr36060_set_jpg_DHT(zr); in zr36060_set_cap()
1989 zr36060_set_jpg_APP(zr); in zr36060_set_cap()
1990 zr36060_set_jpg_COM(zr); in zr36060_set_cap()
1994 zr36060_write_8(zr, 0x000, reg); in zr36060_set_cap()
1998 reg = zr36060_read_8(zr, 0x001); in zr36060_set_cap()
2004 printk(KERN_ERR "%sZR36060: stuck busy, statux=%02x\n", zr->name, in zr36060_set_cap()
2008 static void init_jpeg_queue(struct zoran *zr) in init_jpeg_queue() argument
2012 zr->jpg_que_head = 0; in init_jpeg_queue()
2013 zr->jpg_dma_head = 0; in init_jpeg_queue()
2014 zr->jpg_dma_tail = 0; in init_jpeg_queue()
2015 zr->jpg_que_tail = 0; in init_jpeg_queue()
2016 zr->jpg_seq_num = 0; in init_jpeg_queue()
2017 zr->JPEG_error = 0; in init_jpeg_queue()
2018 zr->num_errors = 0; in init_jpeg_queue()
2019 zr->jpg_err_seq = 0; in init_jpeg_queue()
2020 zr->jpg_err_shift = 0; in init_jpeg_queue()
2021 zr->jpg_queued_num = 0; in init_jpeg_queue()
2022 for (i = 0; i < zr->jpg_nbufs; i++) { in init_jpeg_queue()
2023 zr->jpg_gbuf[i].state = BUZ_STATE_USER; /* nothing going on */ in init_jpeg_queue()
2026 zr->stat_com[i] = 1; /* mark as unavailable to zr36057 */ in init_jpeg_queue()
2030 static void zr36057_set_jpg(struct zoran *zr, enum zoran_codec_mode mode) in zr36057_set_jpg() argument
2035 tvn = zr->timing; in zr36057_set_jpg()
2065 if (zr->params.field_per_buff == 1) in zr36057_set_jpg()
2074 reg = ((zr->params.img_y + tvn->VStart) << ZR36057_FVAP_NAY) in zr36057_set_jpg()
2075 | (zr->params.img_height << ZR36057_FVAP_PAY); in zr36057_set_jpg()
2085 reg = ((zr->params.img_x + tvn->HStart + 4) << ZR36057_FHAP_NAX) in zr36057_set_jpg()
2086 | (zr->params.img_width << ZR36057_FHAP_PAX); in zr36057_set_jpg()
2090 if (zr->params.odd_even) in zr36057_set_jpg()
2094 if (mode == BUZ_MODE_MOTION_DECOMPRESS && zr->card != LML33 in zr36057_set_jpg()
2095 && zr->card != BUZ) in zr36057_set_jpg()
2104 reg = virt_to_bus(zr->stat_com); in zr36057_set_jpg()
2127 zr36057_adjust_vfe(zr, mode); in zr36057_set_jpg()
2132 static void dump_guests(struct zoran *zr) in dump_guests() argument
2137 guest[i] = post_office_read(zr, i, 0); in dump_guests()
2140 printk(KERN_INFO "%s: Guests:", zr->name); in dump_guests()
2155 static void detect_guest_activity(struct zoran *zr) in detect_guest_activity() argument
2160 dump_guests(zr); in detect_guest_activity()
2162 zr->name); in detect_guest_activity()
2164 guest0[i] = guest[i] = post_office_read(zr, i, 0); in detect_guest_activity()
2174 res = post_office_read(zr, i, 0); in detect_guest_activity()
2188 printk(KERN_INFO "%s: Guests:", zr->name); in detect_guest_activity()
2195 printk(KERN_INFO "%s: No activity detected.\n", zr->name); in detect_guest_activity()
2199 printk(KERN_INFO "%s: %6d: %d => 0x%02x\n", zr->name, in detect_guest_activity()
2205 static void print_interrupts(struct zoran *zr) in print_interrupts() argument
2209 printk(KERN_INFO "%s: interrupts received:", zr->name); in print_interrupts()
2210 if ((res = zr->field_counter) < -1 || res > 1) { in print_interrupts()
2213 if ((res = zr->intr_counter_GIRQ1) != 0) { in print_interrupts()
2217 if ((res = zr->intr_counter_GIRQ0) != 0) { in print_interrupts()
2221 if ((res = zr->intr_counter_CodRepIRQ) != 0) { in print_interrupts()
2225 if ((res = zr->intr_counter_JPEGRepIRQ) != 0) { in print_interrupts()
2229 if (zr->JPEG_max_missed) { in print_interrupts()
2230 printk(" JPEG delays: max=%d min=%d", zr->JPEG_max_missed, in print_interrupts()
2231 zr->JPEG_min_missed); in print_interrupts()
2233 if (zr->END_event_missed) { in print_interrupts()
2234 printk(" ENDs missed: %d", zr->END_event_missed); in print_interrupts()
2237 printk(" queue_state=%ld/%ld/%ld/%ld", zr->jpg_que_tail, in print_interrupts()
2238 zr->jpg_dma_tail, zr->jpg_dma_head, zr->jpg_que_head); in print_interrupts()
2246 static void clear_interrupt_counters(struct zoran *zr) in clear_interrupt_counters() argument
2248 zr->intr_counter_GIRQ1 = 0; in clear_interrupt_counters()
2249 zr->intr_counter_GIRQ0 = 0; in clear_interrupt_counters()
2250 zr->intr_counter_CodRepIRQ = 0; in clear_interrupt_counters()
2251 zr->intr_counter_JPEGRepIRQ = 0; in clear_interrupt_counters()
2252 zr->field_counter = 0; in clear_interrupt_counters()
2253 zr->IRQ1_in = 0; in clear_interrupt_counters()
2254 zr->IRQ1_out = 0; in clear_interrupt_counters()
2255 zr->JPEG_in = 0; in clear_interrupt_counters()
2256 zr->JPEG_out = 0; in clear_interrupt_counters()
2257 zr->JPEG_0 = 0; in clear_interrupt_counters()
2258 zr->JPEG_1 = 0; in clear_interrupt_counters()
2259 zr->END_event_missed = 0; in clear_interrupt_counters()
2260 zr->JPEG_missed = 0; in clear_interrupt_counters()
2261 zr->JPEG_max_missed = 0; in clear_interrupt_counters()
2262 zr->JPEG_min_missed = 0x7fffffff; in clear_interrupt_counters()
2265 static u32 count_reset_interrupt(struct zoran *zr) in count_reset_interrupt() argument
2271 zr->intr_counter_GIRQ1++; in count_reset_interrupt()
2275 zr->intr_counter_GIRQ0++; in count_reset_interrupt()
2279 zr->intr_counter_CodRepIRQ++; in count_reset_interrupt()
2283 zr->intr_counter_JPEGRepIRQ++; in count_reset_interrupt()
2289 static void jpeg_start(struct zoran *zr) in jpeg_start() argument
2292 zr->frame_num = 0; in jpeg_start()
2300 set_frame(zr, 0); // \FRAME in jpeg_start()
2311 set_frame(zr, 1); // /FRAME in jpeg_start()
2314 static void zr36057_enable_jpg(struct zoran *zr, in zr36057_enable_jpg() argument
2320 zr->codec_mode = mode; in zr36057_enable_jpg()
2324 set_videobus_enable(zr, 0); in zr36057_enable_jpg()
2325 set_videobus_dir(zr, 0); // GPIO(zr, 1, 0); in zr36057_enable_jpg()
2326 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEODECODER, in zr36057_enable_jpg()
2328 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEOENCODER, in zr36057_enable_jpg()
2330 set_videobus_enable(zr, 1); in zr36057_enable_jpg()
2331 zr36060_sleep(zr, 0); in zr36057_enable_jpg()
2332 zr36060_set_cap(zr, mode); // Load ZR36060 in zr36057_enable_jpg()
2333 init_jpeg_queue(zr); in zr36057_enable_jpg()
2334 zr36057_set_jpg(zr, mode); // \P_Reset, ... Video param, FIFO in zr36057_enable_jpg()
2336 clear_interrupt_counters(zr); in zr36057_enable_jpg()
2339 zr->name)); in zr36057_enable_jpg()
2343 set_videobus_enable(zr, 0); in zr36057_enable_jpg()
2344 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEODECODER, in zr36057_enable_jpg()
2346 set_videobus_dir(zr, 1); // GPIO(zr, 1, 1); in zr36057_enable_jpg()
2347 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEOENCODER, in zr36057_enable_jpg()
2349 set_videobus_enable(zr, 1); in zr36057_enable_jpg()
2350 zr36060_sleep(zr, 0); in zr36057_enable_jpg()
2351 zr36060_set_cap(zr, mode); // Load ZR36060 in zr36057_enable_jpg()
2352 init_jpeg_queue(zr); in zr36057_enable_jpg()
2353 zr36057_set_jpg(zr, mode); // \P_Reset, ... Video param, FIFO in zr36057_enable_jpg()
2355 clear_interrupt_counters(zr); in zr36057_enable_jpg()
2358 zr->name)); in zr36057_enable_jpg()
2364 btand(~(cardjpegint[zr->card] | ZR36057_ICR_JPEGRepIRQ), in zr36057_enable_jpg()
2366 btwrite(cardjpegint[zr->card] | ZR36057_ICR_JPEGRepIRQ, in zr36057_enable_jpg()
2373 set_videobus_dir(zr, 0); // GPIO(zr, 1, 0); in zr36057_enable_jpg()
2374 set_frame(zr, 1); //GPIO(zr, 6, 1); // /FRAME in zr36057_enable_jpg()
2379 zr36060_reset(zr); in zr36057_enable_jpg()
2380 zr36060_sleep(zr, 1); in zr36057_enable_jpg()
2381 zr36057_adjust_vfe(zr, mode); in zr36057_enable_jpg()
2382 set_videobus_enable(zr, 0); in zr36057_enable_jpg()
2383 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEODECODER, in zr36057_enable_jpg()
2385 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEOENCODER, in zr36057_enable_jpg()
2387 set_videobus_enable(zr, 1); in zr36057_enable_jpg()
2389 (KERN_INFO "%s: enable_jpg IDLE\n", zr->name)); in zr36057_enable_jpg()
2399 static int jpg_qbuf(struct zoran *zr, int frame, in jpg_qbuf() argument
2407 if (!zr->jpg_buffers_allocated) { in jpg_qbuf()
2410 zr->name); in jpg_qbuf()
2417 if (zr->codec_mode == mode) { in jpg_qbuf()
2418 zr36057_enable_jpg(zr, BUZ_MODE_IDLE); in jpg_qbuf()
2423 zr->name); in jpg_qbuf()
2430 if (frame >= zr->jpg_nbufs) { in jpg_qbuf()
2432 zr->name, frame); in jpg_qbuf()
2438 if (zr->codec_mode == BUZ_MODE_IDLE) { in jpg_qbuf()
2440 zr36057_enable_jpg(zr, mode); in jpg_qbuf()
2441 } else if (zr->codec_mode != mode) { in jpg_qbuf()
2444 zr->name); in jpg_qbuf()
2448 spin_lock_irqsave(&zr->lock, flags); in jpg_qbuf()
2452 switch (zr->jpg_gbuf[frame].state) { in jpg_qbuf()
2458 zr->name)); in jpg_qbuf()
2461 zr->jpg_pend[zr->jpg_que_head++ & BUZ_MASK_FRAME] = frame; in jpg_qbuf()
2462 zr->jpg_gbuf[frame].state = BUZ_STATE_PEND; in jpg_qbuf()
2463 zoran_feed_stat_com(zr); in jpg_qbuf()
2475 spin_unlock_irqrestore(&zr->lock, flags); in jpg_qbuf()
2478 if (zr->jpg_que_head == 1) in jpg_qbuf()
2479 jpeg_start(zr); in jpg_qbuf()
2488 static int jpg_sync(struct zoran *zr, struct zoran_sync *bs) in jpg_sync() argument
2493 if (zr->codec_mode != BUZ_MODE_MOTION_DECOMPRESS in jpg_sync()
2494 && zr->codec_mode != BUZ_MODE_MOTION_COMPRESS) { in jpg_sync()
2497 zr->name)); in jpg_sync()
2500 while (zr->jpg_que_tail == zr->jpg_dma_tail) { in jpg_sync()
2501 if (zr->jpg_dma_tail == zr->jpg_dma_head) in jpg_sync()
2504 interruptible_sleep_on_timeout(&zr->jpg_capq, 10 * HZ); in jpg_sync()
2510 zr->name, zr36060_read_8(zr, 0x008), in jpg_sync()
2511 zr36060_read_8(zr, 0x001)); in jpg_sync()
2517 spin_lock_irqsave(&zr->lock, flags); in jpg_sync()
2519 if (zr->jpg_dma_tail != zr->jpg_dma_head) in jpg_sync()
2520 frame = zr->jpg_pend[zr->jpg_que_tail++ & BUZ_MASK_FRAME]; in jpg_sync()
2522 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME]; in jpg_sync()
2526 if (zr->jpg_gbuf[frame].state != BUZ_STATE_DONE) in jpg_sync()
2528 zr->name); in jpg_sync()
2531 *bs = zr->jpg_gbuf[frame].bs; in jpg_sync()
2532 zr->jpg_gbuf[frame].state = BUZ_STATE_USER; in jpg_sync()
2534 spin_unlock_irqrestore(&zr->lock, flags); in jpg_sync()
2540 static void zoran_feed_stat_com(struct zoran *zr) in zoran_feed_stat_com() argument
2547 (zr->params.TmpDcm == in zoran_feed_stat_com()
2550 while ((zr->jpg_dma_head - zr->jpg_dma_tail) < max_stat_com in zoran_feed_stat_com()
2551 && zr->jpg_dma_head < zr->jpg_que_head) { in zoran_feed_stat_com()
2553 frame = zr->jpg_pend[zr->jpg_dma_head & BUZ_MASK_FRAME]; in zoran_feed_stat_com()
2554 if (zr->params.TmpDcm == 1) { in zoran_feed_stat_com()
2556 i = (zr->jpg_dma_head - in zoran_feed_stat_com()
2557 zr->jpg_err_shift) & BUZ_MASK_STAT_COM; in zoran_feed_stat_com()
2558 if (!(zr->stat_com[i] & 1)) in zoran_feed_stat_com()
2560 zr->stat_com[i] = zr->jpg_gbuf[frame].frag_tab_bus; in zoran_feed_stat_com()
2563 i = ((zr->jpg_dma_head - in zoran_feed_stat_com()
2564 zr->jpg_err_shift) & 1) * 2; in zoran_feed_stat_com()
2565 if (!(zr->stat_com[i] & 1)) in zoran_feed_stat_com()
2567 zr->stat_com[i] = zr->jpg_gbuf[frame].frag_tab_bus; in zoran_feed_stat_com()
2568 zr->stat_com[i + 1] = in zoran_feed_stat_com()
2569 zr->jpg_gbuf[frame].frag_tab_bus; in zoran_feed_stat_com()
2571 zr->jpg_gbuf[frame].state = BUZ_STATE_DMA; in zoran_feed_stat_com()
2572 zr->jpg_dma_head++; in zoran_feed_stat_com()
2575 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS) in zoran_feed_stat_com()
2576 zr->jpg_queued_num++; in zoran_feed_stat_com()
2580 static void zoran_reap_stat_com(struct zoran *zr) in zoran_reap_stat_com() argument
2594 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS) { in zoran_reap_stat_com()
2595 zr->jpg_seq_num++; in zoran_reap_stat_com()
2597 while (zr->jpg_dma_tail < zr->jpg_dma_head) { in zoran_reap_stat_com()
2598 if (zr->params.TmpDcm == 1) in zoran_reap_stat_com()
2599 i = (zr->jpg_dma_tail - in zoran_reap_stat_com()
2600 zr->jpg_err_shift) & BUZ_MASK_STAT_COM; in zoran_reap_stat_com()
2602 i = ((zr->jpg_dma_tail - in zoran_reap_stat_com()
2603 zr->jpg_err_shift) & 1) * 2 + 1; in zoran_reap_stat_com()
2605 stat_com = zr->stat_com[i]; in zoran_reap_stat_com()
2610 frame = zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME]; in zoran_reap_stat_com()
2611 gbuf = &zr->jpg_gbuf[frame]; in zoran_reap_stat_com()
2614 if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { in zoran_reap_stat_com()
2619 seq = ((stat_com >> 24) + zr->jpg_err_seq) & 0xff; in zoran_reap_stat_com()
2620 dif = (seq - zr->jpg_seq_num) & 0xff; in zoran_reap_stat_com()
2621 zr->jpg_seq_num += dif; in zoran_reap_stat_com()
2626 zr->params.TmpDcm == in zoran_reap_stat_com()
2627 2 ? (zr->jpg_seq_num >> 1) : zr->jpg_seq_num; in zoran_reap_stat_com()
2630 zr->jpg_dma_tail++; in zoran_reap_stat_com()
2634 static void error_handler(struct zoran *zr, u32 astat, u32 stat) in error_handler() argument
2637 if ((zr->codec_mode != BUZ_MODE_MOTION_COMPRESS) in error_handler()
2638 && (zr->codec_mode != BUZ_MODE_MOTION_DECOMPRESS)) { in error_handler()
2643 && zr->codec_mode == BUZ_MODE_MOTION_COMPRESS in error_handler()
2644 && zr->jpg_dma_tail - zr->jpg_que_tail >= zr->jpg_nbufs) { in error_handler()
2646 zoran_reap_stat_com(zr); in error_handler()
2647 zoran_feed_stat_com(zr); in error_handler()
2648 wake_up_interruptible(&zr->jpg_capq); in error_handler()
2649 zr->JPEG_missed = 0; in error_handler()
2652 if (zr->JPEG_error != 1) { in error_handler()
2670 stat | (post_office_read(zr, 7, 0) & 3) << 8 | in error_handler()
2671 zr36060_read_8(zr, 0x008); in error_handler()
2674 zr36060_reset(zr); in error_handler()
2675 zr36060_sleep(zr, 1); in error_handler()
2676 zr->JPEG_error = 1; in error_handler()
2677 zr->num_errors++; in error_handler()
2680 if (zr->num_errors <= 8) { in error_handler()
2683 zr->jpg_pend[zr-> in error_handler()
2687 zr->name, stat, zr->last_isr, in error_handler()
2688 zr->jpg_que_tail, zr->jpg_dma_tail, in error_handler()
2689 zr->jpg_dma_head, zr->jpg_que_head, in error_handler()
2690 zr->jpg_seq_num, frame); in error_handler()
2695 for (i = 0; i < zr->jpg_nbufs; i++) { in error_handler()
2696 if (zr->stat_com[j] == in error_handler()
2697 zr->jpg_gbuf[i]. in error_handler()
2712 if (zr->params.TmpDcm == 1) in error_handler()
2713 i = (zr->jpg_dma_tail - in error_handler()
2714 zr-> in error_handler()
2717 i = ((zr->jpg_dma_tail - in error_handler()
2718 zr->jpg_err_shift) & 1) * 2; in error_handler()
2719 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS) { in error_handler()
2721 zr->stat_com[i] |= 1; in error_handler()
2722 if (zr->params.TmpDcm != 1) in error_handler()
2723 zr->stat_com[i + 1] |= 1; in error_handler()
2725 zoran_reap_stat_com(zr); in error_handler()
2726 zoran_feed_stat_com(zr); in error_handler()
2727 wake_up_interruptible(&zr->jpg_capq); in error_handler()
2729 if (zr->params.TmpDcm == 1) in error_handler()
2730 i = (zr->jpg_dma_tail - in error_handler()
2731 zr-> in error_handler()
2735 i = ((zr->jpg_dma_tail - in error_handler()
2736 zr->jpg_err_shift) & 1) * 2; in error_handler()
2743 memcpy(bus_addr, zr->stat_com, in error_handler()
2746 zr->stat_com[j] = in error_handler()
2751 zr->jpg_err_shift += i; in error_handler()
2752 zr->jpg_err_shift &= BUZ_MASK_STAT_COM; in error_handler()
2754 if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) in error_handler()
2755 zr->jpg_err_seq = zr->jpg_seq_num; /* + 1; */ in error_handler()
2763 if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) in error_handler()
2764 i2c_control_device(&zr->i2c, in error_handler()
2767 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS in error_handler()
2770 zr36060_reset(zr); in error_handler()
2771 zr36060_set_cap(zr, zr->codec_mode); in error_handler()
2772 zr36057_set_jpg(zr, zr->codec_mode); in error_handler()
2773 jpeg_start(zr); in error_handler()
2775 if (zr->num_errors <= 8) in error_handler()
2777 zr->name); in error_handler()
2779 zr->JPEG_missed = 0; in error_handler()
2780 zr->JPEG_error = 2; in error_handler()
2790 struct zoran *zr; in zoran_irq() local
2793 zr = (struct zoran *) dev_id; in zoran_irq()
2796 if (zr->testing) { in zoran_irq()
2798 spin_lock_irqsave(&zr->lock, flags); in zoran_irq()
2799 while ((stat = count_reset_interrupt(zr))) { in zoran_irq()
2804 zr->name, stat); in zoran_irq()
2805 wake_up_interruptible(&zr->test_q); in zoran_irq()
2808 zr->last_isr = stat; in zoran_irq()
2809 spin_unlock_irqrestore(&zr->lock, flags); in zoran_irq()
2813 spin_lock_irqsave(&zr->lock, flags); in zoran_irq()
2816 stat = count_reset_interrupt(zr); in zoran_irq()
2821 if (astat & cardvsync[zr->card]) { // SW in zoran_irq()
2823 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS in zoran_irq()
2824 || zr->codec_mode == in zoran_irq()
2827 zr->JPEG_missed++; in zoran_irq()
2833 if (zr->v4l_memgrab_active) { in zoran_irq()
2840 zr->name); in zoran_irq()
2842 if (zr->v4l_grab_frame != NO_GRAB_ACTIVE) { in zoran_irq()
2850 zr->v4l_gbuf[zr-> in zoran_irq()
2853 zr->v4l_grab_frame = in zoran_irq()
2855 zr->v4l_grab_seq++; in zoran_irq()
2856 zr->v4l_pend_tail++; in zoran_irq()
2860 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE) in zoran_irq()
2861 wake_up_interruptible(&zr-> in zoran_irq()
2866 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE in zoran_irq()
2867 && zr->v4l_pend_tail != in zoran_irq()
2868 zr->v4l_pend_head) { in zoran_irq()
2871 zr->v4l_pend[zr-> in zoran_irq()
2876 zr->v4l_grab_frame = frame; in zoran_irq()
2883 zr->v4l_gbuf[frame]. in zoran_irq()
2886 if (zr->video_interlace) in zoran_irq()
2887 reg += zr->gbpl; in zoran_irq()
2893 if (zr->video_interlace) in zoran_irq()
2894 reg += zr->gbpl; in zoran_irq()
2910 zr->intr_counter_CodRepIRQ++; in zoran_irq()
2913 zr->name)); in zoran_irq()
2921 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS in zoran_irq()
2922 || zr->codec_mode == in zoran_irq()
2925 if (!zr->frame_num || zr->JPEG_error) { in zoran_irq()
2928 zr->name, stat, in zoran_irq()
2929 zr->params.odd_even, in zoran_irq()
2930 zr->params.field_per_buff, in zoran_irq()
2931 zr->JPEG_missed); in zoran_irq()
2938 if (zr-> in zoran_irq()
2947 zr->name, sv, in zoran_irq()
2948 zr->jpg_que_tail, in zoran_irq()
2949 zr->jpg_dma_tail, in zoran_irq()
2950 zr->jpg_dma_head, in zoran_irq()
2951 zr->jpg_que_head); in zoran_irq()
2954 if (zr->JPEG_missed > zr->JPEG_max_missed) // Get statistics in zoran_irq()
2955 zr->JPEG_max_missed = in zoran_irq()
2956 zr->JPEG_missed; in zoran_irq()
2957 if (zr->JPEG_missed < in zoran_irq()
2958 zr->JPEG_min_missed) in zoran_irq()
2959 zr->JPEG_min_missed = in zoran_irq()
2960 zr->JPEG_missed; in zoran_irq()
2964 if (zr->frame_num < 6) { in zoran_irq()
2967 zr->name, zr->jpg_seq_num); in zoran_irq()
2970 zr->stat_com[i]); in zoran_irq()
2975 zr->frame_num++; in zoran_irq()
2976 zr->JPEG_missed = 0; in zoran_irq()
2977 zr->JPEG_error = 0; in zoran_irq()
2978 zoran_reap_stat_com(zr); in zoran_irq()
2979 zoran_feed_stat_com(zr); in zoran_irq()
2980 wake_up_interruptible(&zr->jpg_capq); in zoran_irq()
2987 if ((astat & cardjpegint[zr->card]) /* DATERR interrupt received */ in zoran_irq()
2988 ||zr->JPEG_missed > 25 /* Too many fields missed without processing */ in zoran_irq()
2989 || zr->JPEG_error == 1 /* We are already in error processing */ in zoran_irq()
2990 || ((zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS) in zoran_irq()
2991 && (zr-> in zoran_irq()
2992 frame_num & (zr->JPEG_missed > in zoran_irq()
2993 zr->params.field_per_buff))) in zoran_irq()
2996 error_handler(zr, astat, stat); in zoran_irq()
3001 printk(KERN_WARNING "%s: irq loop %d\n", zr->name, in zoran_irq()
3007 zr->name); in zoran_irq()
3011 zr->last_isr = stat; in zoran_irq()
3013 spin_unlock_irqrestore(&zr->lock, flags); in zoran_irq()
3018 static int zoran_check_params(struct zoran *zr, in zoran_check_params() argument
3030 params->norm = zr->params.norm; in zoran_check_params()
3031 params->input = zr->params.input; in zoran_check_params()
3045 params->img_width = zr->timing->Wa; in zoran_check_params()
3046 params->img_height = zr->timing->Ha / 2; in zoran_check_params()
3058 params->img_width = zr->timing->Wa; in zoran_check_params()
3059 params->img_height = zr->timing->Ha / 2; in zoran_check_params()
3071 params->img_width = zr->timing->Wa; in zoran_check_params()
3072 params->img_height = zr->timing->Ha / 2; in zoran_check_params()
3098 if (params->img_x + params->img_width > zr->timing->Wa) in zoran_check_params()
3101 zr->timing->Ha / 2) in zoran_check_params()
3113 zr->name)); in zoran_check_params()
3121 zr->name, params->decimation)); in zoran_check_params()
3150 static void zoran_open_init_params(struct zoran *zr) in zoran_open_init_params() argument
3156 zr->map_mjpeg_buffers = 0; in zoran_open_init_params()
3160 zr->window_set = 0; in zoran_open_init_params()
3162 zr->window.x = 0; in zoran_open_init_params()
3163 zr->window.y = 0; in zoran_open_init_params()
3164 zr->window.width = 0; in zoran_open_init_params()
3165 zr->window.height = 0; in zoran_open_init_params()
3166 zr->window.chromakey = 0; in zoran_open_init_params()
3167 zr->window.flags = 0; in zoran_open_init_params()
3168 zr->window.clips = NULL; in zoran_open_init_params()
3169 zr->window.clipcount = 0; in zoran_open_init_params()
3171 zr->video_interlace = 0; in zoran_open_init_params()
3173 zr->v4l_memgrab_active = 0; in zoran_open_init_params()
3174 zr->v4l_overlay_active = 0; in zoran_open_init_params()
3176 zr->v4l_grab_frame = NO_GRAB_ACTIVE; in zoran_open_init_params()
3177 zr->v4l_grab_seq = 0; in zoran_open_init_params()
3179 zr->gwidth = 0; in zoran_open_init_params()
3180 zr->gheight = 0; in zoran_open_init_params()
3181 zr->gformat = 0; in zoran_open_init_params()
3182 zr->gbpl = 0; in zoran_open_init_params()
3186 zr->v4l_pend_tail = 0; in zoran_open_init_params()
3187 zr->v4l_pend_head = 0; in zoran_open_init_params()
3189 zr->v4l_gbuf[i].state = BUZ_STATE_USER; /* nothing going on */ in zoran_open_init_params()
3194 zr->params.decimation = 1; in zoran_open_init_params()
3196 zr->params.quality = 50; /* default compression factor 8 */ in zoran_open_init_params()
3197 if (zr->card != BUZ) in zoran_open_init_params()
3198 zr->params.odd_even = 1; in zoran_open_init_params()
3200 zr->params.odd_even = 0; in zoran_open_init_params()
3202 zr->params.APPn = 0; in zoran_open_init_params()
3203 zr->params.APP_len = 0; /* No APPn marker */ in zoran_open_init_params()
3205 zr->params.APP_data[i] = 0; in zoran_open_init_params()
3207 zr->params.COM_len = 0; /* No COM marker */ in zoran_open_init_params()
3209 zr->params.COM_data[i] = 0; in zoran_open_init_params()
3211 zr->params.VFIFO_FB = 0; in zoran_open_init_params()
3213 memset(zr->params.reserved, 0, sizeof(zr->params.reserved)); in zoran_open_init_params()
3215 zr->params.jpeg_markers = JPEG_MARKER_DHT | JPEG_MARKER_DQT; in zoran_open_init_params()
3217 i = zoran_check_params(zr, &zr->params); in zoran_open_init_params()
3221 zr->name); in zoran_open_init_params()
3223 clear_interrupt_counters(zr); in zoran_open_init_params()
3224 zr->testing = 0; in zoran_open_init_params()
3233 struct zoran *zr = (struct zoran *) dev; in zoran_open() local
3237 (KERN_INFO "%s: zoran_open, %s pid=[%d]\n", zr->name, in zoran_open()
3243 if (zr->user > 1) { in zoran_open()
3246 zr->name)); in zoran_open()
3249 zr->user++; in zoran_open()
3251 if (zr->user == 1 && v4l_fbuffer_alloc(zr) < 0) { in zoran_open()
3252 zr->user--; in zoran_open()
3255 zr->name); in zoran_open()
3261 if (zr->user == 1) { /* First device open */ in zoran_open()
3262 zoran_open_init_params(zr); in zoran_open()
3264 zr36057_enable_jpg(zr, BUZ_MODE_IDLE); in zoran_open()
3279 zr->name, flags)); in zoran_open()
3290 struct zoran *zr = (struct zoran *) dev; in zoran_close() local
3294 (KERN_INFO "%s: zoran_close, %s pid=[%d]\n", zr->name, in zoran_close()
3298 wake_up_interruptible(&zr->jpg_capq); in zoran_close()
3299 zr36057_enable_jpg(zr, BUZ_MODE_IDLE); in zoran_close()
3300 jpg_fbuffer_free(zr); in zoran_close()
3301 zr->jpg_nbufs = 0; in zoran_close()
3303 if (zr->user == 1) { /* Last process */ in zoran_close()
3308 print_interrupts(zr); in zoran_close()
3311 wake_up_interruptible(&zr->v4l_capq); in zoran_close()
3312 zr36057_set_memgrab(zr, 0); in zoran_close()
3313 if (zr->v4l_overlay_active) in zoran_close()
3314 zr36057_overlay(zr, 0); in zoran_close()
3315 v4l_fbuffer_free(zr); in zoran_close()
3318 set_videobus_enable(zr, 0); in zoran_close()
3319 i2c_control_device(&zr->i2c, in zoran_close()
3322 i2c_control_device(&zr->i2c, in zoran_close()
3325 set_videobus_enable(zr, 1); in zoran_close()
3330 zr->user--; in zoran_close()
3333 DEBUG2(printk(KERN_INFO "%s: zoran_close done\n", zr->name)); in zoran_close()
3353 static int do_zoran_ioctl(struct zoran *zr, unsigned int cmd, in do_zoran_ioctl() argument
3361 DEBUG2(printk("%s: ioctl VIDIOCGCAP\n", zr->name)); in do_zoran_ioctl()
3363 strncpy(b.name, zr->video_dev.name, in do_zoran_ioctl()
3372 if (zr->card == DC10 || zr->card == DC10plus) { in do_zoran_ioctl()
3398 zr->name, v.channel)); in do_zoran_ioctl()
3407 if (zr->card == DC10 in do_zoran_ioctl()
3408 || zr->card == DC10plus) { in do_zoran_ioctl()
3415 zr->name, v.channel)); in do_zoran_ioctl()
3421 v.norm = zr->params.norm; in do_zoran_ioctl()
3450 if (zr->codec_mode != BUZ_MODE_IDLE) { in do_zoran_ioctl()
3451 if (v.norm != zr->params.norm in do_zoran_ioctl()
3452 || v.channel != zr->params.input) { in do_zoran_ioctl()
3455 zr->name)); in do_zoran_ioctl()
3460 zr->name)); in do_zoran_ioctl()
3466 zr->name, v.channel, v.norm)); in do_zoran_ioctl()
3469 if (zr->card == BUZ) in do_zoran_ioctl()
3478 if (zr->card == DC10 in do_zoran_ioctl()
3479 || zr->card == DC10plus) { in do_zoran_ioctl()
3486 zr->name, v.channel)); in do_zoran_ioctl()
3491 if (lock_norm && v.norm != zr->params.norm) { in do_zoran_ioctl()
3495 zr->name)); in do_zoran_ioctl()
3500 zr->name)); in do_zoran_ioctl()
3501 v.norm = zr->params.norm; in do_zoran_ioctl()
3508 if (!cardnorms[zr->card][v.norm]) { in do_zoran_ioctl()
3511 zr->name, v.norm)); in do_zoran_ioctl()
3517 zr->params.norm = v.norm; in do_zoran_ioctl()
3518 zr->params.input = v.channel; in do_zoran_ioctl()
3519 zr->timing = cardnorms[zr->card][zr->params.norm]; in do_zoran_ioctl()
3524 on = zr->v4l_overlay_active in do_zoran_ioctl()
3525 && !zr->v4l_memgrab_active; in do_zoran_ioctl()
3527 zr36057_overlay(zr, 0); in do_zoran_ioctl()
3529 set_videobus_enable(zr, 0); in do_zoran_ioctl()
3530 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
3533 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
3536 &zr->params.norm); in do_zoran_ioctl()
3537 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
3541 set_videobus_enable(zr, 1); in do_zoran_ioctl()
3544 zr36057_overlay(zr, 1); in do_zoran_ioctl()
3547 res = wait_grab_pending(zr); in do_zoran_ioctl()
3559 zr->name)); in do_zoran_ioctl()
3568 zr->name)); in do_zoran_ioctl()
3575 struct video_picture p = zr->picture; in do_zoran_ioctl()
3578 ("%s: ioctl VIDIOCGPICT\n", zr->name)); in do_zoran_ioctl()
3579 p.depth = zr->buffer.depth; in do_zoran_ioctl()
3580 switch (zr->buffer.depth) { in do_zoran_ioctl()
3612 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
3617 zr->name, p.brightness, p.hue, p.colour, in do_zoran_ioctl()
3621 zr->picture = p; in do_zoran_ioctl()
3634 ("%s: ioctl VIDIOCCAPTURE: %d\n", zr->name, in do_zoran_ioctl()
3639 if ((v && zr->v4l_overlay_active) in do_zoran_ioctl()
3640 || (!v && !zr->v4l_overlay_active)) in do_zoran_ioctl()
3644 zr->v4l_overlay_active = 0; in do_zoran_ioctl()
3645 if (!zr->v4l_memgrab_active) in do_zoran_ioctl()
3646 zr36057_overlay(zr, 0); in do_zoran_ioctl()
3649 if (!zr->buffer_set || !zr->window_set) { in do_zoran_ioctl()
3652 zr->name)); in do_zoran_ioctl()
3655 zr->v4l_overlay_active = 1; in do_zoran_ioctl()
3656 if (!zr->v4l_memgrab_active) in do_zoran_ioctl()
3657 zr36057_overlay(zr, 1); in do_zoran_ioctl()
3661 res = wait_grab_pending(zr); in do_zoran_ioctl()
3670 DEBUG2(printk("%s: ioctl VIDIOCGWIN\n", zr->name)); in do_zoran_ioctl()
3672 (arg, &zr->window, sizeof(zr->window))) { in do_zoran_ioctl()
3686 tvn = zr->timing; in do_zoran_ioctl()
3697 zr->name, vw.x, vw.y, vw.width, vw.height, in do_zoran_ioctl()
3700 if (!zr->buffer_set) { in do_zoran_ioctl()
3703 zr->name)); in do_zoran_ioctl()
3712 if (zr->buffer.depth == 15 in do_zoran_ioctl()
3713 || zr->buffer.depth == 16) { in do_zoran_ioctl()
3719 if (zr->buffer.depth == 24) { in do_zoran_ioctl()
3737 zr->name, vw.width, vw.height)); in do_zoran_ioctl()
3741 zr->window.x = vw.x; in do_zoran_ioctl()
3742 zr->window.y = vw.y; in do_zoran_ioctl()
3743 zr->window.width = vw.width; in do_zoran_ioctl()
3744 zr->window.height = vw.height; in do_zoran_ioctl()
3745 zr->window.chromakey = 0; in do_zoran_ioctl()
3746 zr->window.flags = 0; // RJ: Is this intended for interlace on/off ? in do_zoran_ioctl()
3747 zr->window.clips = NULL; in do_zoran_ioctl()
3757 on = zr->v4l_overlay_active in do_zoran_ioctl()
3758 && !zr->v4l_memgrab_active; in do_zoran_ioctl()
3760 zr36057_overlay(zr, 0); in do_zoran_ioctl()
3775 zr->name); in do_zoran_ioctl()
3785 write_overlay_mask(zr, vcp, vw.clipcount); in do_zoran_ioctl()
3788 zr->window.clipcount = vw.clipcount; in do_zoran_ioctl()
3791 zr36057_overlay(zr, 1); in do_zoran_ioctl()
3792 zr->window_set = 1; in do_zoran_ioctl()
3795 res = wait_grab_pending(zr); in do_zoran_ioctl()
3806 ("%s: ioctl VIDIOCGFBUF\n", zr->name)); in do_zoran_ioctl()
3808 (arg, &zr->buffer, sizeof(zr->buffer))) { in do_zoran_ioctl()
3825 zr->name)); in do_zoran_ioctl()
3833 zr->name, (u32) v.base, v.width, v.height, in do_zoran_ioctl()
3835 if (zr->v4l_overlay_active) { in do_zoran_ioctl()
3839 zr->name)); in do_zoran_ioctl()
3846 zr->name, v.depth)); in do_zoran_ioctl()
3853 zr->name)); in do_zoran_ioctl()
3859 zr->name)); in do_zoran_ioctl()
3863 zr->buffer.base = in do_zoran_ioctl()
3866 zr->buffer.height = v.height; in do_zoran_ioctl()
3867 zr->buffer.width = v.width; in do_zoran_ioctl()
3868 zr->buffer.depth = v.depth; in do_zoran_ioctl()
3869 zr->buffer.bytesperline = v.bytesperline; in do_zoran_ioctl()
3871 if (zr->buffer.base) in do_zoran_ioctl()
3872 zr->buffer_set = 1; in do_zoran_ioctl()
3873 zr->window_set = 0; /* The user should set new window parameters */ in do_zoran_ioctl()
3883 DEBUG2(printk("%s: ioctl VIDIOCKEY\n", zr->name)); in do_zoran_ioctl()
3892 zr->name)); in do_zoran_ioctl()
3901 zr->name)); in do_zoran_ioctl()
3910 zr->name)); in do_zoran_ioctl()
3919 zr->name)); in do_zoran_ioctl()
3932 ("%s: ioctl VIDIOCSYNC %d\n", zr->name, v)); in do_zoran_ioctl()
3933 return v4l_sync(zr, v); in do_zoran_ioctl()
3947 zr->name, vm.frame, vm.width, vm.height, in do_zoran_ioctl()
3949 return v4l_grab(zr, &vm); in do_zoran_ioctl()
3959 ("%s: ioctl VIDIOCGMBUF\n", zr->name)); in do_zoran_ioctl()
3967 zr->map_mjpeg_buffers = 0; in do_zoran_ioctl()
3981 ("%s: ioctl VIDIOCGUNIT\n", zr->name)); in do_zoran_ioctl()
3982 vu.video = zr->video_dev.minor; in do_zoran_ioctl()
4004 zr->name)); in do_zoran_ioctl()
4013 zr->name)); in do_zoran_ioctl()
4021 ("%s: ioctl BUZIOC_G_PARAMS\n", zr->name)); in do_zoran_ioctl()
4024 (arg, &(zr->params), sizeof(zr->params))) { in do_zoran_ioctl()
4036 if (zr->codec_mode != BUZ_MODE_IDLE) { in do_zoran_ioctl()
4039 zr->name)); in do_zoran_ioctl()
4047 ("%s: ioctl BUZIOC_S_PARAMS\n", zr->name)); in do_zoran_ioctl()
4051 if (zoran_check_params(zr, &bp)) in do_zoran_ioctl()
4054 zr->params = bp; in do_zoran_ioctl()
4072 if (zr->jpg_buffers_allocated) { in do_zoran_ioctl()
4075 zr->name)); in do_zoran_ioctl()
4083 zr->name, br.count, br.size)); in do_zoran_ioctl()
4096 if (zr->need_contiguous in do_zoran_ioctl()
4100 zr->jpg_nbufs = br.count; in do_zoran_ioctl()
4101 zr->jpg_bufsize = br.size; in do_zoran_ioctl()
4103 if (jpg_fbuffer_alloc(zr)) in do_zoran_ioctl()
4107 zr->map_mjpeg_buffers = 1; in do_zoran_ioctl()
4126 zr->name, nb)); in do_zoran_ioctl()
4127 return jpg_qbuf(zr, nb, BUZ_MODE_MOTION_COMPRESS); in do_zoran_ioctl()
4141 zr->name, nb)); in do_zoran_ioctl()
4142 return jpg_qbuf(zr, nb, in do_zoran_ioctl()
4153 ("%s: ioctl BUZIOC_SYNC\n", zr->name)); in do_zoran_ioctl()
4154 res = jpg_sync(zr, &bs); in do_zoran_ioctl()
4167 if (zr->codec_mode != BUZ_MODE_IDLE) { in do_zoran_ioctl()
4170 zr->name)); in do_zoran_ioctl()
4178 ("%s: ioctl BUZIOC_G_STATUS\n", zr->name)); in do_zoran_ioctl()
4182 if (zr->card == BUZ) in do_zoran_ioctl()
4193 zr->name, bs.input)); in do_zoran_ioctl()
4200 set_videobus_enable(zr, 0); in do_zoran_ioctl()
4201 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
4204 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
4207 set_videobus_enable(zr, 1); in do_zoran_ioctl()
4216 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
4231 if (zr->card == BUZ) in do_zoran_ioctl()
4232 input = zr->params.input == 0 ? 3 : 7; in do_zoran_ioctl()
4234 input = zr->params.input == 0 ? 0 : 7; in do_zoran_ioctl()
4235 set_videobus_enable(zr, 0); in do_zoran_ioctl()
4236 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
4239 i2c_control_device(&zr->i2c, in do_zoran_ioctl()
4242 &zr->params.norm); in do_zoran_ioctl()
4243 set_videobus_enable(zr, 1); in do_zoran_ioctl()
4254 ("%s: UNKNOWN ioctl cmd: 0x%x\n", zr->name, cmd)); in do_zoran_ioctl()
4262 struct zoran *zr = (struct zoran *) dev; in zoran_ioctl() local
4265 down(&zr->sem); in zoran_ioctl()
4266 err = do_zoran_ioctl(zr, cmd, arg); in zoran_ioctl()
4267 up(&zr->sem); in zoran_ioctl()
4280 static int do_zoran_mmap(struct zoran *zr, const char *adr, in do_zoran_mmap() argument
4288 (KERN_INFO "%s: mmap at 0x%08lx, size %lu\n", zr->name, in do_zoran_mmap()
4290 if (zr->map_mjpeg_buffers) { in do_zoran_mmap()
4293 if (!zr->jpg_buffers_allocated) { in do_zoran_mmap()
4296 zr->name)); in do_zoran_mmap()
4300 if (size > zr->jpg_nbufs * zr->jpg_bufsize) { in do_zoran_mmap()
4303 zr->name, zr->jpg_nbufs * zr->jpg_bufsize, in do_zoran_mmap()
4308 if (size != zr->jpg_nbufs * zr->jpg_bufsize) in do_zoran_mmap()
4311 zr->name, zr->jpg_nbufs * zr->jpg_bufsize, in do_zoran_mmap()
4314 for (i = 0; i < zr->jpg_nbufs; i++) { in do_zoran_mmap()
4315 for (j = 0; j < zr->jpg_bufsize / PAGE_SIZE; j++) { in do_zoran_mmap()
4317 (zr->jpg_gbuf[i]. in do_zoran_mmap()
4323 (unsigned long) zr->jpg_gbuf[i]. in do_zoran_mmap()
4330 zr->name); in do_zoran_mmap()
4337 if (zr->jpg_gbuf[i]. in do_zoran_mmap()
4350 zr->name, v4l_nbufs * v4l_bufsize, size)); in do_zoran_mmap()
4357 zr->name, v4l_nbufs * v4l_bufsize, size)); in do_zoran_mmap()
4363 page = zr->v4l_gbuf[i].fbuffer_phys; in do_zoran_mmap()
4371 zr->name); in do_zoran_mmap()
4387 struct zoran *zr = (struct zoran *) dev; in zoran_mmap() local
4389 down(&zr->sem); in zoran_mmap()
4390 err = do_zoran_mmap(zr, adr, size); in zoran_mmap()
4391 up(&zr->sem); in zoran_mmap()
4419 static void zr36057_init_vfe(struct zoran *zr) in zr36057_init_vfe() argument
4429 if (triton || zr->revision <= 1) in zr36057_init_vfe()
4436 static void test_interrupts(struct zoran *zr) in test_interrupts() argument
4440 clear_interrupt_counters(zr); in test_interrupts()
4441 zr->testing = 1; in test_interrupts()
4444 timeout = interruptible_sleep_on_timeout(&zr->test_q, 1 * HZ); in test_interrupts()
4447 zr->testing = 0; in test_interrupts()
4448 printk(KERN_INFO "%s: Testing interrupts...\n", zr->name); in test_interrupts()
4452 print_interrupts(zr); in test_interrupts()
4458 struct zoran *zr = &zoran[i]; in zr36057_init() local
4465 printk(KERN_INFO "%s: Initializing card[%d], zr=%x\n", zr->name, i, (int) zr); in zr36057_init()
4469 zr->user = 0; in zr36057_init()
4471 init_waitqueue_head(&zr->v4l_capq); in zr36057_init()
4472 init_waitqueue_head(&zr->jpg_capq); in zr36057_init()
4473 init_waitqueue_head(&zr->test_q); in zr36057_init()
4475 zr->map_mjpeg_buffers = 0; /* Map V4L buffers by default */ in zr36057_init()
4477 zr->jpg_nbufs = 0; in zr36057_init()
4478 zr->jpg_bufsize = 0; in zr36057_init()
4479 zr->jpg_buffers_allocated = 0; in zr36057_init()
4481 zr->buffer_set = 0; /* Flag if frame buffer has been set */ in zr36057_init()
4482 zr->buffer.base = (void *) vidmem; in zr36057_init()
4483 zr->buffer.width = 0; in zr36057_init()
4484 zr->buffer.height = 0; in zr36057_init()
4485 zr->buffer.depth = 0; in zr36057_init()
4486 zr->buffer.bytesperline = 0; in zr36057_init()
4488 …zr->params.norm = default_norm = (default_norm < 3 ? default_norm : VIDEO_MODE_PAL); /* Avoid nons… in zr36057_init()
4489 if (!(zr->timing = cardnorms[zr->card][zr->params.norm])) { in zr36057_init()
4492 zr->name); in zr36057_init()
4493 zr->params.norm = VIDEO_MODE_PAL; in zr36057_init()
4494 zr->timing = cardnorms[zr->card][zr->params.norm]; in zr36057_init()
4496 zr->params.input = default_input = (default_input ? 1 : 0); /* Avoid nonsense settings from user */ in zr36057_init()
4497 zr->video_interlace = 0; in zr36057_init()
4501 zr->picture.colour = 32768; in zr36057_init()
4502 zr->picture.brightness = 32768; in zr36057_init()
4503 zr->picture.hue = 32768; in zr36057_init()
4504 zr->picture.contrast = 32768; in zr36057_init()
4505 zr->picture.whiteness = 0; in zr36057_init()
4506 zr->picture.depth = 0; in zr36057_init()
4507 zr->picture.palette = 0; in zr36057_init()
4510 zr->v4l_gbuf[i].fbuffer = 0; in zr36057_init()
4511 zr->v4l_gbuf[i].fbuffer_phys = 0; in zr36057_init()
4512 zr->v4l_gbuf[i].fbuffer_bus = 0; in zr36057_init()
4515 zr->stat_com = 0; in zr36057_init()
4519 zoran_open_init_params(zr); in zr36057_init()
4528 printk(KERN_ERR "%s: zr36057_init: kmalloc (STAT_COM + ovl.mask) failed\n", zr->name); in zr36057_init()
4533 zr->stat_com = (u32 *) mem; in zr36057_init()
4535 zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ in zr36057_init()
4537 zr->overlay_mask = (u32 *) (mem + BUZ_NUM_STAT_COM * 4); in zr36057_init()
4542 zr->jpg_gbuf[j].frag_tab = 0; in zr36057_init()
4543 zr->jpg_gbuf[j].frag_tab_bus = 0; in zr36057_init()
4544 zr->jpg_gbuf[j].state = BUZ_STATE_USER; in zr36057_init()
4545 zr->jpg_gbuf[j].bs.frame = j; in zr36057_init()
4551 memcpy(&zr->video_dev, &zoran_template, sizeof(zoran_template)); in zr36057_init()
4552 strcpy(zr->video_dev.name, zr->name); in zr36057_init()
4553 if (video_register_device(&zr->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) { in zr36057_init()
4554 i2c_unregister_bus(&zr->i2c); in zr36057_init()
4555 kfree((void *) zr->stat_com); in zr36057_init()
4560 pci_set_master(zr->pci_dev); in zr36057_init()
4562 if (zr->card == BUZ) in zr36057_init()
4563 j = zr->params.input == 0 ? 3 : 7; in zr36057_init()
4565 j = zr->params.input == 0 ? 0 : 7; in zr36057_init()
4566 set_videobus_enable(zr, 0); in zr36057_init()
4567 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEODECODER, in zr36057_init()
4569 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEODECODER, in zr36057_init()
4570 DECODER_SET_NORM, &zr->params.norm); in zr36057_init()
4571 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEOENCODER, in zr36057_init()
4572 ENCODER_SET_NORM, &zr->params.norm); in zr36057_init()
4573 set_videobus_enable(zr, 1); in zr36057_init()
4576 zr36060_sleep(zr, 1); in zr36057_init()
4577 zr36060_sleep(zr, 0); in zr36057_init()
4587 zr36057_init_vfe(zr); in zr36057_init()
4589 zr->zoran_proc = NULL; in zr36057_init()
4590 zr->initialized = 1; in zr36057_init()
4592 zr36057_enable_jpg(zr, BUZ_MODE_IDLE); in zr36057_init()
4594 detect_guest_activity(zr); in zr36057_init()
4596 test_interrupts(zr); in zr36057_init()
4599 set_videobus_enable(zr, 0); in zr36057_init()
4600 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEODECODER, in zr36057_init()
4602 i2c_control_device(&zr->i2c, I2C_DRIVERID_VIDEOENCODER, in zr36057_init()
4604 set_videobus_enable(zr, 1); in zr36057_init()
4615 struct zoran *zr; in release_dc10() local
4618 zr = &zoran[i]; in release_dc10()
4620 if (!zr->initialized) in release_dc10()
4624 i2c_unregister_bus((&zr->i2c)); in release_dc10()
4627 pci_read_config_byte(zr->pci_dev, PCI_COMMAND, &command); in release_dc10()
4629 pci_write_config_byte(zr->pci_dev, PCI_COMMAND, command); in release_dc10()
4634 free_irq(zr->pci_dev->irq, zr); in release_dc10()
4638 kfree((void *) zr->stat_com); in release_dc10()
4641 iounmap(zr->zr36057_mem); in release_dc10()
4643 video_unregister_device(&zr->video_dev); in release_dc10()
4655 struct zoran *zr; in find_zr36057() local
4666 zr = &zoran[zoran_num]; in find_zr36057()
4667 zr->pci_dev = dev; in find_zr36057()
4668 zr->zr36057_mem = NULL; in find_zr36057()
4669 zr->id = zoran_num; in find_zr36057()
4670 sprintf(zr->name, "MJPEG[%u]", zr->id); in find_zr36057()
4672 spin_lock_init(&zr->lock); in find_zr36057()
4673 init_MUTEX(&zr->sem); in find_zr36057()
4678 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); in find_zr36057()
4679 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, in find_zr36057()
4680 &zr->revision); in find_zr36057()
4681 if (zr->revision < 2) { in find_zr36057()
4684 zr->name, zr->revision, zr->pci_dev->irq, in find_zr36057()
4685 zr->zr36057_adr); in find_zr36057()
4688 ss_vendor_id = zr->pci_dev->subsystem_vendor; in find_zr36057()
4689 ss_id = zr->pci_dev->subsystem_device; in find_zr36057()
4692 zr->name, zr->revision, zr->pci_dev->irq, in find_zr36057()
4693 zr->zr36057_adr); in find_zr36057()
4696 zr->name, ss_vendor_id, ss_id); in find_zr36057()
4699 zr->zr36057_mem = ioremap_nocache(zr->zr36057_adr, 0x1000); in find_zr36057()
4700 if (!zr->zr36057_mem) { in find_zr36057()
4701 printk(KERN_ERR "%s: ioremap failed\n", zr->name); in find_zr36057()
4705 result = request_irq(zr->pci_dev->irq, zoran_irq, SA_SHIRQ | SA_INTERRUPT, zr->name, (void *) zr); in find_zr36057()
4710 zr->name); in find_zr36057()
4714 zr->name, zr->pci_dev->irq); in find_zr36057()
4718 zr->name, result); in find_zr36057()
4720 iounmap(zr->zr36057_mem); in find_zr36057()
4725 pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, &latency); in find_zr36057()
4726 need_latency = zr->revision > 1 ? 32 : 48; in find_zr36057()
4728 printk(KERN_INFO "%s: Changing PCI latency from %d to %d.\n", zr->name, latency, need_latency); in find_zr36057()
4729 pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, need_latency); in find_zr36057()
4745 memcpy(&zr->i2c, &zoran_i2c_bus_template, in find_zr36057()
4747 strcpy(zr->i2c.name, zr->name); in find_zr36057()
4748 zr->i2c.data = zr; in find_zr36057()
4749 printk(KERN_INFO "%s: Initializing i2c bus...\n", zr->name); in find_zr36057()
4750 if (i2c_register_bus(&zr->i2c) < 0) { in find_zr36057()
4753 free_irq(zr->pci_dev->irq, zr); in find_zr36057()
4754 iounmap(zr->zr36057_mem); in find_zr36057()
4755 printk(KERN_ERR "%s: Can't initialize i2c bus\n", zr->name); in find_zr36057()
4759 if (zr->card != DC10 && zr->card != DC10plus in find_zr36057()
4760 && zr->card != LML33 && zr->card != BUZ) { in find_zr36057()
4762 i2c_unregister_bus((&zr->i2c)); in find_zr36057()
4765 free_irq(zr->pci_dev->irq, zr); in find_zr36057()
4766 iounmap(zr->zr36057_mem); in find_zr36057()
4768 zr->name); in find_zr36057()
4771 printk(KERN_INFO "%s card detected\n", zr->name); in find_zr36057()
4772 if (zr->card == LML33) { in find_zr36057()
4773 GPIO(zr, 2, 1); // Set Composite input/output in find_zr36057()
4777 zr36060_sleep(zr, 1); in find_zr36057()
4778 zr36060_reset(zr); in find_zr36057()
4783 if (zr36060_read_8(zr, 0x022) == 0x33) { in find_zr36057()
4785 zr->name, zr36060_read_8(zr, 0x023)); in find_zr36057()
4788 i2c_unregister_bus((&zr->i2c)); in find_zr36057()
4791 free_irq(zr->pci_dev->irq, zr); in find_zr36057()
4792 iounmap(zr->zr36057_mem); in find_zr36057()
4794 zr->name); in find_zr36057()